/* * blapi.h - public prototypes for the freebl library * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* ** RSA encryption/decryption. When encrypting/decrypting the output ** buffer must be at least the size of the public key modulus.
*/
extern SECStatus BL_Init(void);
/* ** Generate and return a new RSA public and private key. ** Both keys are encoded in a single RSAPrivateKey structure. ** "cx" is the random number generator context ** "keySizeInBits" is the size of the key to be generated, in bits. ** 512, 1024, etc. ** "publicExponent" when not NULL is a pointer to some data that ** represents the public exponent to use. The data is a byte ** encoded integer, in "big endian" order.
*/ extern RSAPrivateKey *RSA_NewKey(int keySizeInBits,
SECItem *publicExponent);
/* ** Perform a raw public-key operation ** Length of input and output buffers are equal to key's modulus len.
*/ extern SECStatus RSA_PublicKeyOp(RSAPublicKey *key, unsignedchar *output, constunsignedchar *input);
/* ** Perform a raw private-key operation ** Length of input and output buffers are equal to key's modulus len.
*/ extern SECStatus RSA_PrivateKeyOp(RSAPrivateKey *key, unsignedchar *output, constunsignedchar *input);
/* ** Perform a raw private-key operation, and check the parameters used in ** the operation for validity by performing a test operation first. ** Length of input and output buffers are equal to key's modulus len.
*/ extern SECStatus RSA_PrivateKeyOpDoubleChecked(RSAPrivateKey *key, unsignedchar *output, constunsignedchar *input);
/* ** Perform a check of private key parameters for consistency.
*/ extern SECStatus RSA_PrivateKeyCheck(const RSAPrivateKey *key);
/* ** Given only minimal private key parameters, fill in the rest of the ** parameters. ** ** ** All the entries, including those supplied by the caller, will be ** overwritten with data alocated out of the arena. ** ** If no arena is supplied, one will be created. ** ** The following fields must be supplied in order for this function ** to succeed: ** one of either publicExponent or privateExponent ** two more of the following 5 parameters (not counting the above). ** modulus (n) ** prime1 (p) ** prime2 (q) ** publicExponent (e) ** privateExponent (d) ** ** NOTE: if only the publicExponent, privateExponent, and one prime is given, ** then there may be more than one RSA key that matches that combination. If ** we find 2 possible valid keys that meet this criteria, we return an error. ** If we return the wrong key, and the original modulus is compared to the ** new modulus, both can be factored by calculateing gcd(n_old,n_new) to get ** the common prime. ** ** NOTE: in some cases the publicExponent must be less than 2^23 for this ** function to work correctly. (The case where we have only one of: modulus ** prime1 and prime2). ** ** All parameters will be replaced in the key structure with new parameters ** allocated out of the arena. There is no attempt to free the old structures. ** prime1 will always be greater than prime2 (even if the caller supplies the ** smaller prime as prime1 or the larger prime as prime2). The parameters are ** not overwritten on failure. ** ** While the remaining Chinese remainder theorem parameters (dp,dp, and qinv) ** can also be used in reconstructing the private key, they are currently ** ignored in this implementation.
*/ extern SECStatus RSA_PopulatePrivateKey(RSAPrivateKey *key);
/******************************************************************** ** Raw signing/encryption/decryption operations. ** ** No padding or formatting will be applied. ** inputLen MUST be equivalent to the modulus size (in bytes).
*/ extern SECStatus
RSA_SignRaw(RSAPrivateKey *key, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/******************************************************************** ** RSAES-OAEP encryption/decryption, as defined in RFC 3447, Section 7.1. ** ** Note: Only MGF1 is supported as the mask generation function. It will be ** used with maskHashAlg as the inner hash function. ** ** Unless performing Known Answer Tests, "seed" should be NULL, indicating that ** freebl should generate a random value. Otherwise, it should be an octet ** string of seedLen bytes, which should be the same size as the output of ** hashAlg.
*/ extern SECStatus
RSA_EncryptOAEP(RSAPublicKey *key,
HASH_HashType hashAlg,
HASH_HashType maskHashAlg, constunsignedchar *label, unsignedint labelLen, constunsignedchar *seed, unsignedint seedLen, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/******************************************************************** ** RSASSA-PSS signing/verifying, as defined in RFC 3447, Section 8.1. ** ** Note: Only MGF1 is supported as the mask generation function. It will be ** used with maskHashAlg as the inner hash function. ** ** Unless performing Known Answer Tests, "salt" should be NULL, indicating that ** freebl should generate a random value.
*/ extern SECStatus
RSA_SignPSS(RSAPrivateKey *key,
HASH_HashType hashAlg,
HASH_HashType maskHashAlg, constunsignedchar *salt, unsignedint saltLen, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/******************************************************************** ** RSASSA-PKCS1-v1_5 signing/verifying, as defined in RFC 3447, Section 8.2. ** ** These functions expect as input to be the raw value to be signed. For most ** cases using PKCS1-v1_5, this should be the value of T, the DER-encoded ** DigestInfo structure defined in Section 9.2, Step 2. ** Note: This can also be used for signatures that use PKCS1-v1_5 padding, such ** as the signatures used in SSL/TLS, which sign a raw hash.
*/ extern SECStatus
RSA_Sign(RSAPrivateKey *key, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *data, unsignedint dataLen);
/* Generate a new random value within the interval [2, q-1].
*/ extern SECStatus DSA_NewRandom(PLArenaPool *arena, const SECItem *q,
SECItem *random);
/* ** Generate and return a new DSA public and private key pair, ** both of which are encoded into a single DSAPrivateKey struct. ** "params" is a pointer to the PQG parameters for the domain ** Uses a random seed.
*/ extern SECStatus DSA_NewKey(const PQGParams *params,
DSAPrivateKey **privKey);
/* signature is caller-supplied buffer of at least 20 bytes. ** On input, signature->len == size of buffer to hold signature. ** digest->len == size of digest. ** On output, signature->len == size of signature in buffer. ** Uses a random seed.
*/ extern SECStatus DSA_SignDigest(DSAPrivateKey *key,
SECItem *signature, const SECItem *digest);
/* signature is caller-supplied buffer of at least 20 bytes. ** On input, signature->len == size of buffer to hold signature. ** digest->len == size of digest.
*/ extern SECStatus DSA_VerifyDigest(DSAPublicKey *key, const SECItem *signature, const SECItem *digest);
/* For FIPS compliance testing. Seed must be exactly 20 bytes long */ extern SECStatus DSA_NewKeyFromSeed(const PQGParams *params, constunsignedchar *seed,
DSAPrivateKey **privKey);
/* For FIPS compliance testing. Seed must be exactly 20 bytes. */ extern SECStatus DSA_SignDigestWithSeed(DSAPrivateKey *key,
SECItem *signature, const SECItem *digest, constunsignedchar *seed);
/* Generates parameters for Diffie-Helman key generation. ** primeLen is the length in bytes of prime P to be generated.
*/ extern SECStatus DH_GenParam(int primeLen, DHParams **params);
/* Generates a public and private key, both of which are encoded in a single ** DHPrivateKey struct. Params is input, privKey are output. ** This is Phase 1 of Diffie Hellman.
*/ extern SECStatus DH_NewKey(DHParams *params,
DHPrivateKey **privKey);
/* ** DH_Derive does the Diffie-Hellman phase 2 calculation, using the ** other party's publicValue, and the prime and our privateValue. ** maxOutBytes is the requested length of the generated secret in bytes. ** A zero value means produce a value of any length up to the size of ** the prime. If successful, derivedSecret->data is set ** to the address of the newly allocated buffer containing the derived ** secret, and derivedSecret->len is the size of the secret produced. ** The size of the secret produced will depend on the value of outBytes. ** If outBytes is 0, the key length will be all the significant bytes of ** the derived secret (leading zeros are dropped). This length could be less ** than the length of the prime. If outBytes is nonzero, the length of the ** produced key will be outBytes long. If the key is truncated, the most ** significant bytes are truncated. If it is expanded, zero bytes are added ** at the beginning. ** It is the caller's responsibility to free the allocated buffer ** containing the derived secret.
*/ extern SECStatus DH_Derive(SECItem *publicValue,
SECItem *prime,
SECItem *privateValue,
SECItem *derivedSecret, unsignedint outBytes);
/* ** KEA_CalcKey returns octet string with the private key for a dual ** Diffie-Helman key generation as specified for government key exchange.
*/ extern SECStatus KEA_Derive(SECItem *prime,
SECItem *public1,
SECItem *public2,
SECItem *private1,
SECItem *private2,
SECItem *derivedSecret);
/* * verify that a KEA or DSA public key is a valid key for this prime and * subprime domain.
*/ extern PRBool KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime);
/* verify a value is prime */
PRBool KEA_PrimeCheck(SECItem *prime);
/**************************************** * J-PAKE key transport
*/
/* Given gx == g^x, create a Schnorr zero-knowledge proof for the value x * using the specified hash algorithm and signer ID. The signature is * returned in the values gv and r. testRandom must be NULL for a PRNG * generated random committment to be used in the sigature. When testRandom * is non-NULL, that value must contain a value in the subgroup q; that * value will be used instead of a PRNG-generated committment in order to * facilitate known-answer tests. * * If gxIn is non-NULL then it must contain a pre-computed value of g^x that * will be used by the function; in this case, the gxOut parameter must be NULL. * If the gxIn parameter is NULL then gxOut must be non-NULL; in this case * gxOut will contain the value g^x on output. * * gx (if not supplied by the caller), gv, and r will be allocated in the arena. * The arena is *not* optional so do not pass NULL for the arena parameter. * The arena should be zeroed when it is freed.
*/
SECStatus
JPAKE_Sign(PLArenaPool *arena, const PQGParams *pqg, HASH_HashType hashType, const SECItem *signerID, const SECItem *x, const SECItem *testRandom, const SECItem *gxIn, SECItem *gxOut,
SECItem *gv, SECItem *r);
/* Given gx == g^x, verify the Schnorr zero-knowledge proof (gv, r) for the * value x using the specified hash algorithm and signer ID. * * The arena is *not* optional so do not pass NULL for the arena parameter.
*/
SECStatus
JPAKE_Verify(PLArenaPool *arena, const PQGParams *pqg,
HASH_HashType hashType, const SECItem *signerID, const SECItem *peerID, const SECItem *gx, const SECItem *gv, const SECItem *r);
/* Call before round 2 with x2, s, and x2s all non-NULL. This will calculate * base = g^(x1+x3+x4) (mod p) and x2s = x2*s (mod q). The values to send in * round 2 (A and the proof of knowledge of x2s) can then be calculated with * JPAKE_Sign using pqg->base = base and x = x2s. * * Call after round 2 with x2, s, and x2s all NULL, and passing (gx1, gx2, gx3) * instead of (gx1, gx3, gx4). This will calculate base = g^(x1+x2+x3). Then call * JPAKE_Verify with pqg->base = base and then JPAKE_Final. * * base and x2s will be allocated in the arena. The arena is *not* optional so * do not pass NULL for the arena parameter. The arena should be zeroed when it * is freed.
*/
SECStatus
JPAKE_Round2(PLArenaPool *arena, const SECItem *p, const SECItem *q, const SECItem *gx1, const SECItem *gx3, const SECItem *gx4,
SECItem *base, const SECItem *x2, const SECItem *s, SECItem *x2s);
/* K = (B/g^(x2*x4*s))^x2 (mod p) * * K will be allocated in the arena. The arena is *not* optional so do not pass * NULL for the arena parameter. The arena should be zeroed when it is freed.
*/
SECStatus
JPAKE_Final(PLArenaPool *arena, const SECItem *p, const SECItem *q, const SECItem *x2, const SECItem *gx4, const SECItem *x2s, const SECItem *B, SECItem *K);
/* Generates a public and private key, both of which are encoded ** in a single ECPrivateKey struct. Params is input, privKey are ** output.
*/ extern SECStatus EC_NewKey(ECParams *params,
ECPrivateKey **privKey);
extern SECStatus EC_NewKeyFromSeed(ECParams *params,
ECPrivateKey **privKey, constunsignedchar *seed, int seedlen);
/* Validates an EC public key as described in Section 5.2.2 of * X9.62. Such validation prevents against small subgroup attacks * when the ECDH primitive is used with the cofactor.
*/ extern SECStatus EC_ValidatePublicKey(ECParams *params,
SECItem *publicValue);
/* ** ECDH_Derive performs a scalar point multiplication of a point ** representing a (peer's) public key and a large integer representing ** a private key (its own). Both keys must use the same elliptic curve ** parameters. If the withCofactor parameter is true, the ** multiplication also uses the cofactor associated with the curve ** parameters. The output of this scheme is the x-coordinate of the ** resulting point. If successful, derivedSecret->data is set to the ** address of the newly allocated buffer containing the derived ** secret, and derivedSecret->len is the size of the secret ** produced. It is the caller's responsibility to free the allocated ** buffer containing the derived secret.
*/ extern SECStatus ECDH_Derive(SECItem *publicValue,
ECParams *params,
SECItem *privateValue,
PRBool withCofactor,
SECItem *derivedSecret);
/* On input, signature->len == size of buffer to hold signature. ** digest->len == size of digest. ** On output, signature->len == size of signature in buffer. ** Uses a random seed.
*/ extern SECStatus ECDSA_SignDigest(ECPrivateKey *key,
SECItem *signature, const SECItem *digest);
/* On input, signature->len == size of buffer to hold signature. ** digest->len == size of digest.
*/ extern SECStatus ECDSA_VerifyDigest(ECPublicKey *key, const SECItem *signature, const SECItem *digest);
/* ** Create a new RC4 context suitable for RC4 encryption/decryption. ** "key" raw key data ** "len" the number of bytes of key data
*/ extern RC4Context *RC4_CreateContext(constunsignedchar *key, int len);
/* ** Destroy an RC4 encryption/decryption context. ** "cx" the context ** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/ externvoid RC4_DestroyContext(RC4Context *cx, PRBool freeit);
/* ** Perform RC4 encryption. ** "cx" the context ** "output" the output buffer to store the encrypted 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
*/ extern SECStatus RC4_Encrypt(RC4Context *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Perform RC4 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
*/ extern SECStatus RC4_Decrypt(RC4Context *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Create a new RC2 context suitable for RC2 encryption/decryption. ** "key" raw key data ** "len" the number of bytes of key data ** "iv" is the CBC initialization vector (if mode is NSS_RC2_CBC) ** "mode" one of NSS_RC2 or NSS_RC2_CBC ** "effectiveKeyLen" is the effective key length (as specified in ** RFC 2268) in bytes (not bits). ** ** When mode is set to NSS_RC2_CBC the RC2 cipher is run in "cipher block ** chaining" mode.
*/ extern RC2Context *RC2_CreateContext(constunsignedchar *key, unsignedint len, constunsignedchar *iv, int mode, unsigned effectiveKeyLen); extern RC2Context *RC2_AllocateContext(void); extern SECStatus RC2_InitContext(RC2Context *cx, constunsignedchar *key, unsignedint keylen, constunsignedchar *iv, int mode, unsignedint effectiveKeyLen, unsignedint);
/* ** Destroy an RC2 encryption/decryption context. ** "cx" the context ** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/ externvoid RC2_DestroyContext(RC2Context *cx, PRBool freeit);
/* ** Perform RC2 encryption. ** "cx" the context ** "output" the output buffer to store the encrypted 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
*/ extern SECStatus RC2_Encrypt(RC2Context *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Perform RC2 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
*/ extern SECStatus RC2_Decrypt(RC2Context *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Create a new RC5 context suitable for RC5 encryption/decryption. ** "key" raw key data ** "len" the number of bytes of key data ** "iv" is the CBC initialization vector (if mode is NSS_RC5_CBC) ** "mode" one of NSS_RC5 or NSS_RC5_CBC ** ** When mode is set to NSS_RC5_CBC the RC5 cipher is run in "cipher block ** chaining" mode.
*/ extern RC5Context *RC5_CreateContext(const SECItem *key, unsignedint rounds, unsignedint wordSize, constunsignedchar *iv, int mode); extern RC5Context *RC5_AllocateContext(void); extern SECStatus RC5_InitContext(RC5Context *cx, constunsignedchar *key, unsignedint keylen, constunsignedchar *iv, int mode, unsignedint rounds, unsignedint wordSize);
/* ** Destroy an RC5 encryption/decryption context. ** "cx" the context ** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/ externvoid RC5_DestroyContext(RC5Context *cx, PRBool freeit);
/* ** Perform RC5 encryption. ** "cx" the context ** "output" the output buffer to store the encrypted 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
*/ extern SECStatus RC5_Encrypt(RC5Context *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Perform RC5 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
*/
/******************************************/ /* ** DES symmetric block cypher
*/
/* ** Create a new DES context suitable for DES encryption/decryption. ** "key" raw key data ** "len" the number of bytes of key data ** "iv" is the CBC initialization vector (if mode is NSS_DES_CBC or ** mode is DES_EDE3_CBC) ** "mode" one of NSS_DES, NSS_DES_CBC, NSS_DES_EDE3 or NSS_DES_EDE3_CBC ** "encrypt" is PR_TRUE if the context will be used for encryption ** ** When mode is set to NSS_DES_CBC or NSS_DES_EDE3_CBC then the DES ** cipher is run in "cipher block chaining" mode.
*/ extern DESContext *DES_CreateContext(constunsignedchar *key, constunsignedchar *iv, int mode, PRBool encrypt); extern DESContext *DES_AllocateContext(void); extern SECStatus DES_InitContext(DESContext *cx, constunsignedchar *key, unsignedint keylen, constunsignedchar *iv, int mode, unsignedint encrypt, unsignedint);
/* ** Destroy an DES encryption/decryption context. ** "cx" the context ** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/ externvoid DES_DestroyContext(DESContext *cx, PRBool freeit);
/* ** Perform DES encryption. ** "cx" the context ** "output" the output buffer to store the encrypted 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_Encrypt(DESContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint 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, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Create a new AES context suitable for AES encryption/decryption. ** "key" raw key data ** "keylen" the number of bytes of key data (16, 24, or 32) ** "blocklen" is the blocksize to use. NOTE: only 16 is supported!
*/ extern AESContext *
AES_CreateContext(constunsignedchar *key, constunsignedchar *iv, int mode, int encrypt, unsignedint keylen, unsignedint blocklen); extern AESContext *AES_AllocateContext(void); extern SECStatus AES_InitContext(AESContext *cx, constunsignedchar *key, unsignedint keylen, constunsignedchar *iv, int mode, unsignedint encrypt, unsignedint blocklen);
/* ** Destroy a AES encryption/decryption context. ** "cx" the context ** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/ externvoid
AES_DestroyContext(AESContext *cx, PRBool freeit);
/* ** Perform AES encryption. ** "cx" the context ** "output" the output buffer to store the encrypted 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
*/ extern SECStatus
AES_Encrypt(AESContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Perform AES 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
*/ extern SECStatus
AES_Decrypt(AESContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen); /* ** Perform AES AEAD operation (either encrypt or decrypt), controlled by ** the context. ** "cx" the context ** "output" the output buffer to store the encrypted 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 ** "params" pointer to an AEAD specific param PKCS #11 param structure ** "paramsLen" length of the param structure pointed to by params ** "aad" addition authenticated data ** "aadLen" the amount of additional authenticated data.
*/ extern SECStatus
AES_AEAD(AESContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen, void *params, unsignedint paramsLen, constunsignedchar *aad, unsignedint aadLen);
/* ** Create a new AES context suitable for AES encryption/decryption. ** "key" raw key data ** "iv" The 8 byte "initial value" ** "encrypt", a boolean, true for key wrapping, false for unwrapping. ** "keylen" the number of bytes of key data (16, 24, or 32)
*/ extern AESKeyWrapContext *
AESKeyWrap_CreateContext(constunsignedchar *key, constunsignedchar *iv, int encrypt, unsignedint keylen); extern AESKeyWrapContext *AESKeyWrap_AllocateContext(void); extern SECStatus
AESKeyWrap_InitContext(AESKeyWrapContext *cx, constunsignedchar *key, unsignedint keylen, constunsignedchar *iv, int, unsignedint encrypt, unsignedint);
/* ** Destroy a AES KeyWrap context. ** "cx" the context ** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/ externvoid
AESKeyWrap_DestroyContext(AESKeyWrapContext *cx, PRBool freeit);
/* ** Perform AES key wrap. ** "cx" the context ** "output" the output buffer to store the encrypted 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
*/ extern SECStatus
AESKeyWrap_Encrypt(AESKeyWrapContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Perform AES key unwrap. ** "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
*/ extern SECStatus
AESKeyWrap_Decrypt(AESKeyWrapContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Perform AES padded key wrap. ** "cx" the context ** "output" the output buffer to store the encrypted 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
*/ extern SECStatus
AESKeyWrap_EncryptKWP(AESKeyWrapContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Perform AES padded key unwrap. ** "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
*/ extern SECStatus
AESKeyWrap_DecryptKWP(AESKeyWrapContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Create a new Camellia context suitable for Camellia encryption/decryption. ** "key" raw key data ** "keylen" the number of bytes of key data (16, 24, or 32)
*/ extern CamelliaContext *
Camellia_CreateContext(constunsignedchar *key, constunsignedchar *iv, int mode, int encrypt, unsignedint keylen);
extern CamelliaContext *Camellia_AllocateContext(void); extern SECStatus Camellia_InitContext(CamelliaContext *cx, constunsignedchar *key, unsignedint keylen, constunsignedchar *iv, int mode, unsignedint encrypt, unsignedint unused); /* ** Destroy a Camellia encryption/decryption context. ** "cx" the context ** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/ externvoid
Camellia_DestroyContext(CamelliaContext *cx, PRBool freeit);
/* ** Perform Camellia encryption. ** "cx" the context ** "output" the output buffer to store the encrypted 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
*/ extern SECStatus
Camellia_Encrypt(CamelliaContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/* ** Perform Camellia 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
*/ extern SECStatus
Camellia_Decrypt(CamelliaContext *cx, unsignedchar *output, unsignedint *outputLen, unsignedint maxOutputLen, constunsignedchar *input, unsignedint inputLen);
/******************************************/ /* ** MD5 secure hash function
*/
/* ** Hash a null terminated string "src" into "dest" using MD5
*/ extern SECStatus MD5_Hash(unsignedchar *dest, constchar *src);
/* ** Hash a non-null terminated string "src" into "dest" using MD5
*/ extern SECStatus MD5_HashBuf(unsignedchar *dest, constunsignedchar *src,
PRUint32 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
*/ externvoid MD5_DestroyContext(MD5Context *cx, PRBool freeit);
/* ** Reset an MD5 context, preparing it for a fresh round of hashing
*/ externvoid 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
*/ externvoid MD5_Update(MD5Context *cx, constunsignedchar *input, unsignedint 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"
*/ externvoid MD5_End(MD5Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen);
/* ** Export the current state of the MD5 hash without appending the standard ** padding and length bytes. 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 (optional) ** "maxDigestLen" the maximum amount of data that can ever be ** stored in "digest"
*/ externvoid MD5_EndRaw(MD5Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen);
/* * Return the the size of a buffer needed to flatten the MD5 Context into * "cx" the context * returns size;
*/ externunsignedint 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, unsignedchar *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(unsignedchar *space, void *arg); externvoid MD5_Clone(MD5Context *dest, MD5Context *src);
/* ** trace the intermediate state info of the MD5 hash.
*/ externvoid MD5_TraceState(MD5Context *cx);
/******************************************/ /* ** MD2 secure hash function
*/
/* ** Hash a null terminated string "src" into "dest" using MD2
*/ extern SECStatus MD2_Hash(unsignedchar *dest, constchar *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
*/ externvoid MD2_DestroyContext(MD2Context *cx, PRBool freeit);
/* ** Reset an MD2 context, preparing it for a fresh round of hashing
*/ externvoid 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
*/ externvoid MD2_Update(MD2Context *cx, constunsignedchar *input, unsignedint 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"
*/ externvoid MD2_End(MD2Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen);
/* * Return the the size of a buffer needed to flatten the MD2 Context into * "cx" the context * returns size;
*/ externunsignedint 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, unsignedchar *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(unsignedchar *space, void *arg); externvoid MD2_Clone(MD2Context *dest, MD2Context *src);
/******************************************/ /* ** SHA-1 secure hash function
*/
/* ** Hash a null terminated string "src" into "dest" using SHA-1
*/ extern SECStatus SHA1_Hash(unsignedchar *dest, constchar *src);
/* ** Hash a non-null terminated string "src" into "dest" using SHA-1
*/ extern SECStatus SHA1_HashBuf(unsignedchar *dest, constunsignedchar *src,
PRUint32 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
*/ externvoid SHA1_DestroyContext(SHA1Context *cx, PRBool freeit);
/* ** Reset a SHA-1 context, preparing it for a fresh round of hashing
*/ externvoid 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
*/ externvoid SHA1_Update(SHA1Context *cx, constunsignedchar *input, unsignedint 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"
*/ externvoid SHA1_End(SHA1Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen);
/* ** Export the current state of the SHA-1 hash without appending the standard ** padding and length bytes. Produce the digested results in "digest" ** "cx" the context ** "digest" where the 20 bytes of digest data are stored ** "digestLen" where the digest length (20) is stored (optional) ** "maxDigestLen" the maximum amount of data that can ever be ** stored in "digest"
*/ externvoid SHA1_EndRaw(SHA1Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen);
/* ** trace the intermediate state info of the SHA1 hash.
*/ externvoid SHA1_TraceState(SHA1Context *cx);
/* * Return the the size of a buffer needed to flatten the SHA-1 Context into * "cx" the context * returns size;
*/ externunsignedint 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, unsignedchar *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(unsignedchar *space, void *arg); externvoid SHA1_Clone(SHA1Context *dest, SHA1Context *src);
/******************************************/
/******************************************/ /* ** SHA-2 secure hash function ** The SHA-2 family includes SHA224, SHA256, SHA384, and SHA512
*/
extern SHA224Context *SHA224_NewContext(void); externvoid SHA224_DestroyContext(SHA224Context *cx, PRBool freeit); externvoid SHA224_Begin(SHA224Context *cx); externvoid SHA224_Update(SHA224Context *cx, constunsignedchar *input, unsignedint inputLen); externvoid SHA224_End(SHA224Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen); /* ** Export the current state of the SHA-224 hash without appending the standard ** padding and length bytes. Produce the digested results in "digest" ** "cx" the context ** "digest" where the 28 bytes of digest data are stored ** "digestLen" where the digest length (28) is stored (optional) ** "maxDigestLen" the maximum amount of data that can ever be ** stored in "digest"
*/ externvoid SHA224_EndRaw(SHA224Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen); extern SECStatus SHA224_HashBuf(unsignedchar *dest, constunsignedchar *src,
PRUint32 src_length); extern SECStatus SHA224_Hash(unsignedchar *dest, constchar *src); externvoid SHA224_TraceState(SHA224Context *cx); externunsignedint SHA224_FlattenSize(SHA224Context *cx); extern SECStatus SHA224_Flatten(SHA224Context *cx, unsignedchar *space); extern SHA224Context *SHA224_Resurrect(unsignedchar *space, void *arg); externvoid SHA224_Clone(SHA224Context *dest, SHA224Context *src);
/******************************************/
extern SHA256Context *SHA256_NewContext(void); externvoid SHA256_DestroyContext(SHA256Context *cx, PRBool freeit); externvoid SHA256_Begin(SHA256Context *cx); externvoid SHA256_Update(SHA256Context *cx, constunsignedchar *input, unsignedint inputLen); externvoid SHA256_End(SHA256Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen); /* ** Export the current state of the SHA-256 hash without appending the standard ** padding and length bytes. Produce the digested results in "digest" ** "cx" the context ** "digest" where the 32 bytes of digest data are stored ** "digestLen" where the digest length (32) is stored (optional) ** "maxDigestLen" the maximum amount of data that can ever be ** stored in "digest"
*/ externvoid SHA256_EndRaw(SHA256Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen); extern SECStatus SHA256_HashBuf(unsignedchar *dest, constunsignedchar *src,
PRUint32 src_length); extern SECStatus SHA256_Hash(unsignedchar *dest, constchar *src); externvoid SHA256_TraceState(SHA256Context *cx); externunsignedint SHA256_FlattenSize(SHA256Context *cx); extern SECStatus SHA256_Flatten(SHA256Context *cx, unsignedchar *space); extern SHA256Context *SHA256_Resurrect(unsignedchar *space, void *arg); externvoid SHA256_Clone(SHA256Context *dest, SHA256Context *src);
/******************************************/
extern SHA512Context *SHA512_NewContext(void); externvoid SHA512_DestroyContext(SHA512Context *cx, PRBool freeit); externvoid SHA512_Begin(SHA512Context *cx); externvoid SHA512_Update(SHA512Context *cx, constunsignedchar *input, unsignedint inputLen); /* ** Export the current state of the SHA-512 hash without appending the standard ** padding and length bytes. Produce the digested results in "digest" ** "cx" the context ** "digest" where the 64 bytes of digest data are stored ** "digestLen" where the digest length (64) is stored (optional) ** "maxDigestLen" the maximum amount of data that can ever be ** stored in "digest"
*/ externvoid SHA512_EndRaw(SHA512Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen); externvoid SHA512_End(SHA512Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen); extern SECStatus SHA512_HashBuf(unsignedchar *dest, constunsignedchar *src,
PRUint32 src_length); extern SECStatus SHA512_Hash(unsignedchar *dest, constchar *src); externvoid SHA512_TraceState(SHA512Context *cx); externunsignedint SHA512_FlattenSize(SHA512Context *cx); extern SECStatus SHA512_Flatten(SHA512Context *cx, unsignedchar *space); extern SHA512Context *SHA512_Resurrect(unsignedchar *space, void *arg); externvoid SHA512_Clone(SHA512Context *dest, SHA512Context *src);
/******************************************/
extern SHA384Context *SHA384_NewContext(void); externvoid SHA384_DestroyContext(SHA384Context *cx, PRBool freeit); externvoid SHA384_Begin(SHA384Context *cx); externvoid SHA384_Update(SHA384Context *cx, constunsignedchar *input, unsignedint inputLen); externvoid SHA384_End(SHA384Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen); /* ** Export the current state of the SHA-384 hash without appending the standard ** padding and length bytes. Produce the digested results in "digest" ** "cx" the context ** "digest" where the 48 bytes of digest data are stored ** "digestLen" where the digest length (48) is stored (optional) ** "maxDigestLen" the maximum amount of data that can ever be ** stored in "digest"
*/ externvoid SHA384_EndRaw(SHA384Context *cx, unsignedchar *digest, unsignedint *digestLen, unsignedint maxDigestLen); extern SECStatus SHA384_HashBuf(unsignedchar *dest, constunsignedchar *src,
PRUint32 src_length); extern SECStatus SHA384_Hash(unsignedchar *dest, constchar *src); externvoid SHA384_TraceState(SHA384Context *cx); externunsignedint SHA384_FlattenSize(SHA384Context *cx); extern SECStatus SHA384_Flatten(SHA384Context *cx, unsignedchar *space); extern SHA384Context *SHA384_Resurrect(unsignedchar *space, void *arg); externvoid SHA384_Clone(SHA384Context *dest, SHA384Context *src);
/******************************************/ /* ** SHA-3 secure hash function ** The SHA-3 family includes SHA3_224, SHA3_256, SHA3_384, and SHA3_512
*/
/* ** Create a new Blake2b context
*/ extern BLAKE2BContext *BLAKE2B_NewContext(void);
/* ** Destroy a Blake2b secure hash context. ** "ctx" the context ** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/ externvoid BLAKE2B_DestroyContext(BLAKE2BContext *ctx, PRBool freeit);
/* ** Reset a Blake2b context, preparing it for a fresh round of hashing
*/ extern SECStatus BLAKE2B_Begin(BLAKE2BContext *ctx);
/* ** Update the Blake hash function with more data.
*/ extern SECStatus BLAKE2B_Update(BLAKE2BContext *ctx, constunsignedchar *in, unsignedint inlen);
/* ** Finish the Blake hash function. Produce the digested results in "digest"
*/ extern SECStatus BLAKE2B_End(BLAKE2BContext *ctx, unsignedchar *out, unsignedint *digestLen, size_t maxDigestLen);
/* * Return the size of a buffer needed to flatten the Blake2b Context into * "ctx" the context * returns size;
*/ externunsignedint BLAKE2B_FlattenSize(BLAKE2BContext *ctx);
/* * Flatten the Blake2b Context into a buffer: * "ctx" the context * "space" the buffer to flatten to * returns status;
*/ extern SECStatus BLAKE2B_Flatten(BLAKE2BContext *ctx, unsignedchar *space);
/* * Resurrect a flattened context into a Blake2b Context * "space" the buffer of the flattend buffer * "arg" ptr to void used by cryptographic resurrect * returns resurected context
*/ extern BLAKE2BContext *BLAKE2B_Resurrect(unsignedchar *space, void *arg); externvoid BLAKE2B_Clone(BLAKE2BContext *dest, BLAKE2BContext *src);
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Dauer der Verarbeitung: 0.52 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.