blapi.h
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 742 行 · 第 1/2 页
H
742 行
** after some data is stored in output.** "maxOutputLen" the maximum amount of data that can ever be** stored in "output"** "input" the input data** "inputLen" the amount of input data**** NOTE: the inputLen must be a multiple of DES_KEY_LENGTH*/extern SECStatus DES_Encrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, unsigned char *input, unsigned int inputLen);/*** Perform DES decryption.** "cx" the context** "output" the output buffer to store the decrypted data.** "outputLen" how much data is stored in "output". Set by the routine** after some data is stored in output.** "maxOutputLen" the maximum amount of data that can ever be** stored in "output"** "input" the input data** "inputLen" the amount of input data**** NOTE: the inputLen must be a multiple of DES_KEY_LENGTH*/extern SECStatus DES_Decrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, unsigned char *input, unsigned int inputLen);/******************************************//*** MD5 secure hash function*//*** Hash a null terminated string "src" into "dest" using MD5*/extern SECStatus MD5_Hash(unsigned char *dest, const char *src);/*** Hash a non-null terminated string "src" into "dest" using MD5*/extern SECStatus MD5_HashBuf(unsigned char *dest, const unsigned char *src, uint32 src_length);/*** Create a new MD5 context*/extern MD5Context *MD5_NewContext(void);/*** Destroy an MD5 secure hash context.** "cx" the context** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void MD5_DestroyContext(MD5Context *cx, PRBool freeit);/*** Reset an MD5 context, preparing it for a fresh round of hashing*/extern void MD5_Begin(MD5Context *cx);/*** Update the MD5 hash function with more data.** "cx" the context** "input" the data to hash** "inputLen" the amount of data to hash*/extern void MD5_Update(MD5Context *cx, const unsigned char *input, unsigned int inputLen);/*** Finish the MD5 hash function. Produce the digested results in "digest"** "cx" the context** "digest" where the 16 bytes of digest data are stored** "digestLen" where the digest length (16) is stored** "maxDigestLen" the maximum amount of data that can ever be** stored in "digest"*/extern void MD5_End(MD5Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen);/* * Return the the size of a buffer needed to flatten the MD5 Context into * "cx" the context * returns size; */extern unsigned int MD5_FlattenSize(MD5Context *cx);/* * Flatten the MD5 Context into a buffer: * "cx" the context * "space" the buffer to flatten to * returns status; */extern SECStatus MD5_Flatten(MD5Context *cx,unsigned char *space);/* * Resurrect a flattened context into a MD5 Context * "space" the buffer of the flattend buffer * "arg" ptr to void used by cryptographic resurrect * returns resurected context; */extern MD5Context * MD5_Resurrect(unsigned char *space, void *arg);/*** trace the intermediate state info of the MD5 hash.*/extern void MD5_TraceState(MD5Context *cx);/******************************************//*** MD2 secure hash function*//*** Hash a null terminated string "src" into "dest" using MD2*/extern SECStatus MD2_Hash(unsigned char *dest, const char *src);/*** Create a new MD2 context*/extern MD2Context *MD2_NewContext(void);/*** Destroy an MD2 secure hash context.** "cx" the context** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void MD2_DestroyContext(MD2Context *cx, PRBool freeit);/*** Reset an MD2 context, preparing it for a fresh round of hashing*/extern void MD2_Begin(MD2Context *cx);/*** Update the MD2 hash function with more data.** "cx" the context** "input" the data to hash** "inputLen" the amount of data to hash*/extern void MD2_Update(MD2Context *cx, const unsigned char *input, unsigned int inputLen);/*** Finish the MD2 hash function. Produce the digested results in "digest"** "cx" the context** "digest" where the 16 bytes of digest data are stored** "digestLen" where the digest length (16) is stored** "maxDigestLen" the maximum amount of data that can ever be** stored in "digest"*/extern void MD2_End(MD2Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen);/* * Return the the size of a buffer needed to flatten the MD2 Context into * "cx" the context * returns size; */extern unsigned int MD2_FlattenSize(MD2Context *cx);/* * Flatten the MD2 Context into a buffer: * "cx" the context * "space" the buffer to flatten to * returns status; */extern SECStatus MD2_Flatten(MD2Context *cx,unsigned char *space);/* * Resurrect a flattened context into a MD2 Context * "space" the buffer of the flattend buffer * "arg" ptr to void used by cryptographic resurrect * returns resurected context; */extern MD2Context * MD2_Resurrect(unsigned char *space, void *arg);/******************************************//*** SHA-1 secure hash function*//*** Hash a null terminated string "src" into "dest" using SHA-1*/extern SECStatus SHA1_Hash(unsigned char *dest, const char *src);/*** Hash a non-null terminated string "src" into "dest" using SHA-1*/extern SECStatus SHA1_HashBuf(unsigned char *dest, const unsigned char *src, uint32 src_length);/*** Create a new SHA-1 context*/extern SHA1Context *SHA1_NewContext(void);/*** Destroy a SHA-1 secure hash context.** "cx" the context** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void SHA1_DestroyContext(SHA1Context *cx, PRBool freeit);/*** Reset a SHA-1 context, preparing it for a fresh round of hashing*/extern void SHA1_Begin(SHA1Context *cx);/*** Update the SHA-1 hash function with more data.** "cx" the context** "input" the data to hash** "inputLen" the amount of data to hash*/extern void SHA1_Update(SHA1Context *cx, const unsigned char *input, unsigned int inputLen);/*** Finish the SHA-1 hash function. Produce the digested results in "digest"** "cx" the context** "digest" where the 16 bytes of digest data are stored** "digestLen" where the digest length (20) is stored** "maxDigestLen" the maximum amount of data that can ever be** stored in "digest"*/extern void SHA1_End(SHA1Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen);/*** trace the intermediate state info of the SHA1 hash.*/extern void SHA1_TraceState(MD5Context *cx);/* * Return the the size of a buffer needed to flatten the SHA-1 Context into * "cx" the context * returns size; */extern unsigned int SHA1_FlattenSize(SHA1Context *cx);/* * Flatten the SHA-1 Context into a buffer: * "cx" the context * "space" the buffer to flatten to * returns status; */extern SECStatus SHA1_Flatten(SHA1Context *cx,unsigned char *space);/* * Resurrect a flattened context into a SHA-1 Context * "space" the buffer of the flattend buffer * "arg" ptr to void used by cryptographic resurrect * returns resurected context; */extern SHA1Context * SHA1_Resurrect(unsigned char *space, void *arg);/******************************************//*** Pseudo Random Number Generation. FIPS compliance desirable.*//*** Initialize the global RNG context and give it some seed input taken** from the system. This function is thread-safe and will only allow** the global context to be initialized once. The seed input is likely** small, so it is imperative that RNG_RandomUpdate() be called with** additional seed data before the generator is used. A good way to** provide the generator with additional entropy is to call** RNG_SystemInfoForRNG(). Note that NSS_Init() does exactly that.*/extern SECStatus RNG_RNGInit(void);/*** Update the global random number generator with more seeding** material*/extern SECStatus RNG_RandomUpdate(void *data, size_t bytes);/*** Generate some random bytes, using the global random number generator** object.*/extern SECStatus RNG_GenerateGlobalRandomBytes(void *dest, size_t len);/* Destroy the global RNG context. After a call to RNG_RNGShutdown()** a call to RNG_RNGInit() is required in order to use the generator again,** along with seed data (see the comment above RNG_RNGInit()).*/extern void RNG_RNGShutdown(void);/* Generate PQGParams and PQGVerify structs. * Length of seed and length of h both equal length of P. * All lengths are specified by "j", according to the table above. */extern SECStatusPQG_ParamGen(unsigned int j, /* input : determines length of P. */ PQGParams **pParams, /* output: P Q and G returned here */ PQGVerify **pVfy); /* output: counter and seed. *//* Generate PQGParams and PQGVerify structs. * Length of P specified by j. Length of h will match length of P. * Length of SEED in bytes specified in seedBytes. * seedBbytes must be in the range [20..255] or an error will result. */extern SECStatusPQG_ParamGenSeedLen( unsigned int j, /* input : determines length of P. */ unsigned int seedBytes, /* input : length of seed in bytes.*/ PQGParams **pParams, /* output: P Q and G returned here */ PQGVerify **pVfy); /* output: counter and seed. *//* Test PQGParams for validity as DSS PQG values. * If vfy is non-NULL, test PQGParams to make sure they were generated * using the specified seed, counter, and h values. * * Return value indicates whether Verification operation ran succesfully * to completion, but does not indicate if PQGParams are valid or not. * If return value is SECSuccess, then *pResult has these meanings: * SECSuccess: PQGParams are valid. * SECFailure: PQGParams are invalid. * * Verify the following 12 facts about PQG counter SEED g and h * 1. Q is 160 bits long. * 2. P is one of the 9 valid lengths. * 3. G < P * 4. P % Q == 1 * 5. Q is prime * 6. P is prime * Steps 7-12 are done only if the optional PQGVerify is supplied. * 7. counter < 4096 * 8. g >= 160 and g < 2048 (g is length of seed in bits) * 9. Q generated from SEED matches Q in PQGParams. * 10. P generated from (L, counter, g, SEED, Q) matches P in PQGParams. * 11. 1 < h < P-1 * 12. G generated from h matches G in PQGParams. */extern SECStatus PQG_VerifyParams(const PQGParams *params, const PQGVerify *vfy, SECStatus *result);/************************************************************************** * Free the PQGParams struct and the things it points to. * **************************************************************************/extern void PQG_DestroyParams(PQGParams *params);/************************************************************************** * Free the PQGVerify struct and the things it points to. * **************************************************************************/extern void PQG_DestroyVerify(PQGVerify *vfy);SEC_END_PROTOS#endif /* _BLAPI_H_ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?