2008-06-06 16:40:11 +04:00
|
|
|
/*
|
2014-04-28 07:39:24 +04:00
|
|
|
* blapi.h - public prototypes for the freebl library
|
2008-06-06 16:40:11 +04:00
|
|
|
*
|
2012-10-01 22:02:15 +04:00
|
|
|
* 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/. */
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
#ifndef _BLAPI_H_
|
|
|
|
#define _BLAPI_H_
|
|
|
|
|
|
|
|
#include "blapit.h"
|
|
|
|
#include "hasht.h"
|
|
|
|
#include "alghmac.h"
|
|
|
|
|
|
|
|
SEC_BEGIN_PROTOS
|
|
|
|
|
|
|
|
/*
|
|
|
|
** RSA encryption/decryption. When encrypting/decrypting the output
|
|
|
|
** buffer must be at least the size of the public key modulus.
|
|
|
|
*/
|
|
|
|
|
2009-02-10 20:18:32 +03:00
|
|
|
extern SECStatus BL_Init(void);
|
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/*
|
|
|
|
** Generate and return a new RSA public and private key.
|
2016-08-30 08:58:30 +03:00
|
|
|
** 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.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern RSAPrivateKey *RSA_NewKey(int keySizeInBits,
|
|
|
|
SECItem *publicExponent);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
2016-08-30 08:58:30 +03:00
|
|
|
** Perform a raw public-key operation
|
|
|
|
** Length of input and output buffers are equal to key's modulus len.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus RSA_PublicKeyOp(RSAPublicKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
const unsigned char *input);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
2016-08-30 08:58:30 +03:00
|
|
|
** Perform a raw private-key operation
|
|
|
|
** Length of input and output buffers are equal to key's modulus len.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus RSA_PrivateKeyOp(RSAPrivateKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
const unsigned char *input);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform a raw private-key operation, and check the parameters used in
|
|
|
|
** the operation for validity by performing a test operation first.
|
2016-08-30 08:58:30 +03:00
|
|
|
** Length of input and output buffers are equal to key's modulus len.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus RSA_PrivateKeyOpDoubleChecked(RSAPrivateKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
const unsigned char *input);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform a check of private key parameters for consistency.
|
|
|
|
*/
|
Bug 1020695: Update Mozilla to use NSS 3.16.2 Beta 4. Includes fixes for
bug 1013088, bug 996237, bug 970539, bug 1016567, bug 485732, bug 334013,
bug 959864, bug 1016836, bug 1016811, bug 1018536, bug 996250, bug 1009227,
bug 963150, bug 1007126, bug 1021102.
2014-06-14 01:17:18 +04:00
|
|
|
extern SECStatus RSA_PrivateKeyCheck(const RSAPrivateKey *key);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2010-12-09 14:04:11 +03:00
|
|
|
/*
|
|
|
|
** Given only minimal private key parameters, fill in the rest of the
|
|
|
|
** parameters.
|
|
|
|
**
|
|
|
|
**
|
2016-08-30 08:58:30 +03:00
|
|
|
** All the entries, including those supplied by the caller, will be
|
2010-12-09 14:04:11 +03:00
|
|
|
** 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);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2013-11-26 05:08:17 +04:00
|
|
|
/********************************************************************
|
|
|
|
** RSA algorithm
|
|
|
|
*/
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
** Raw signing/encryption/decryption operations.
|
|
|
|
**
|
|
|
|
** No padding or formatting will be applied.
|
|
|
|
** inputLen MUST be equivalent to the modulus size (in bytes).
|
|
|
|
*/
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_SignRaw(RSAPrivateKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned int inputLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_CheckSignRaw(RSAPublicKey *key,
|
|
|
|
const unsigned char *sig,
|
|
|
|
unsigned int sigLen,
|
|
|
|
const unsigned char *hash,
|
|
|
|
unsigned int hashLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_CheckSignRecoverRaw(RSAPublicKey *key,
|
|
|
|
unsigned char *data,
|
|
|
|
unsigned int *dataLen,
|
|
|
|
unsigned int maxDataLen,
|
|
|
|
const unsigned char *sig,
|
|
|
|
unsigned int sigLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_EncryptRaw(RSAPublicKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned int inputLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_DecryptRaw(RSAPrivateKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned int inputLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
** 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
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_EncryptOAEP(RSAPublicKey *key,
|
|
|
|
HASH_HashType hashAlg,
|
|
|
|
HASH_HashType maskHashAlg,
|
|
|
|
const unsigned char *label,
|
|
|
|
unsigned int labelLen,
|
|
|
|
const unsigned char *seed,
|
|
|
|
unsigned int seedLen,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned int inputLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_DecryptOAEP(RSAPrivateKey *key,
|
|
|
|
HASH_HashType hashAlg,
|
|
|
|
HASH_HashType maskHashAlg,
|
|
|
|
const unsigned char *label,
|
|
|
|
unsigned int labelLen,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned int inputLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
** RSAES-PKCS1-v1_5 encryption/decryption, as defined in RFC 3447, Section 7.2.
|
|
|
|
*/
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_EncryptBlock(RSAPublicKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned int inputLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_DecryptBlock(RSAPrivateKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned int inputLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
** 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
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_SignPSS(RSAPrivateKey *key,
|
|
|
|
HASH_HashType hashAlg,
|
|
|
|
HASH_HashType maskHashAlg,
|
|
|
|
const unsigned char *salt,
|
|
|
|
unsigned int saltLen,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input,
|
|
|
|
unsigned int inputLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_CheckSignPSS(RSAPublicKey *key,
|
|
|
|
HASH_HashType hashAlg,
|
|
|
|
HASH_HashType maskHashAlg,
|
|
|
|
unsigned int saltLen,
|
|
|
|
const unsigned char *sig,
|
|
|
|
unsigned int sigLen,
|
|
|
|
const unsigned char *hash,
|
|
|
|
unsigned int hashLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
** 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
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_Sign(RSAPrivateKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *data,
|
|
|
|
unsigned int dataLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_CheckSign(RSAPublicKey *key,
|
|
|
|
const unsigned char *sig,
|
|
|
|
unsigned int sigLen,
|
|
|
|
const unsigned char *data,
|
|
|
|
unsigned int dataLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
RSA_CheckSignRecover(RSAPublicKey *key,
|
|
|
|
unsigned char *output,
|
|
|
|
unsigned int *outputLen,
|
|
|
|
unsigned int maxOutputLen,
|
|
|
|
const unsigned char *sig,
|
|
|
|
unsigned int sigLen);
|
2013-11-26 05:08:17 +04:00
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/********************************************************************
|
|
|
|
** DSA signing algorithm
|
|
|
|
*/
|
|
|
|
|
2010-12-09 14:04:11 +03:00
|
|
|
/* Generate a new random value within the interval [2, q-1].
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DSA_NewRandom(PLArenaPool *arena, const SECItem *q,
|
|
|
|
SECItem *random);
|
2010-12-09 14:04:11 +03:00
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/*
|
|
|
|
** Generate and return a new DSA public and private key pair,
|
2016-08-30 08:58:30 +03:00
|
|
|
** 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.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DSA_NewKey(const PQGParams *params,
|
|
|
|
DSAPrivateKey **privKey);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DSA_SignDigest(DSAPrivateKey *key,
|
|
|
|
SECItem *signature,
|
|
|
|
const SECItem *digest);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DSA_VerifyDigest(DSAPublicKey *key,
|
|
|
|
const SECItem *signature,
|
|
|
|
const SECItem *digest);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/* For FIPS compliance testing. Seed must be exactly 20 bytes long */
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DSA_NewKeyFromSeed(const PQGParams *params,
|
|
|
|
const unsigned char *seed,
|
2008-06-06 16:40:11 +04:00
|
|
|
DSAPrivateKey **privKey);
|
|
|
|
|
|
|
|
/* For FIPS compliance testing. Seed must be exactly 20 bytes. */
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DSA_SignDigestWithSeed(DSAPrivateKey *key,
|
|
|
|
SECItem *signature,
|
|
|
|
const SECItem *digest,
|
|
|
|
const unsigned char *seed);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/******************************************************
|
2016-08-30 08:58:30 +03:00
|
|
|
** Diffie Helman key exchange algorithm
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Generates parameters for Diffie-Helman key generation.
|
2016-08-30 08:58:30 +03:00
|
|
|
** primeLen is the length in bytes of prime P to be generated.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DH_GenParam(int primeLen, DHParams **params);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/* Generates a public and private key, both of which are encoded in a single
|
2016-08-30 08:58:30 +03:00
|
|
|
** DHPrivateKey struct. Params is input, privKey are output.
|
|
|
|
** This is Phase 1 of Diffie Hellman.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DH_NewKey(DHParams *params,
|
|
|
|
DHPrivateKey **privKey);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-08-30 08:58:30 +03:00
|
|
|
/*
|
|
|
|
** DH_Derive does the Diffie-Hellman phase 2 calculation, using the
|
2008-06-06 16:40:11 +04:00
|
|
|
** other party's publicValue, and the prime and our privateValue.
|
2016-08-30 08:58:30 +03:00
|
|
|
** 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
|
2008-06-06 16:40:11 +04:00
|
|
|
** secret, and derivedSecret->len is the size of the secret produced.
|
2012-04-01 03:41:42 +04:00
|
|
|
** 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.
|
2016-08-30 08:58:30 +03:00
|
|
|
** It is the caller's responsibility to free the allocated buffer
|
2008-06-06 16:40:11 +04:00
|
|
|
** containing the derived secret.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DH_Derive(SECItem *publicValue,
|
|
|
|
SECItem *prime,
|
|
|
|
SECItem *privateValue,
|
|
|
|
SECItem *derivedSecret,
|
|
|
|
unsigned int outBytes);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-08-30 08:58:30 +03:00
|
|
|
/*
|
2008-06-06 16:40:11 +04:00
|
|
|
** KEA_CalcKey returns octet string with the private key for a dual
|
|
|
|
** Diffie-Helman key generation as specified for government key exchange.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus KEA_Derive(SECItem *prime,
|
|
|
|
SECItem *public1,
|
|
|
|
SECItem *public2,
|
|
|
|
SECItem *private1,
|
|
|
|
SECItem *private2,
|
|
|
|
SECItem *derivedSecret);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
2010-12-09 14:04:11 +03:00
|
|
|
/****************************************
|
|
|
|
* 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
|
2016-08-30 08:58:30 +03:00
|
|
|
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);
|
2010-12-09 14:04:11 +03:00
|
|
|
|
|
|
|
/* Given gx == g^x, verify the Schnorr zero-knowledge proof (gv, r) for the
|
|
|
|
* value x using the specified hash algorithm and signer ID.
|
|
|
|
*
|
2016-08-30 08:58:30 +03:00
|
|
|
* The arena is *not* optional so do not pass NULL for the arena parameter.
|
2010-12-09 14:04:11 +03:00
|
|
|
*/
|
|
|
|
SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
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);
|
2010-12-09 14:04:11 +03:00
|
|
|
|
|
|
|
/* Call before round 2 with x2, s, and x2s all non-NULL. This will calculate
|
2016-08-30 08:58:30 +03:00
|
|
|
* base = g^(x1+x3+x4) (mod p) and x2s = x2*s (mod q). The values to send in
|
2010-12-09 14:04:11 +03:00
|
|
|
* 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
|
2016-08-30 08:58:30 +03:00
|
|
|
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);
|
2010-12-09 14:04:11 +03:00
|
|
|
|
|
|
|
/* 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
|
2016-08-30 08:58:30 +03:00
|
|
|
JPAKE_Final(PLArenaPool *arena, const SECItem *p, const SECItem *q,
|
|
|
|
const SECItem *x2, const SECItem *gx4, const SECItem *x2s,
|
|
|
|
const SECItem *B, SECItem *K);
|
2010-12-09 14:04:11 +03:00
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/******************************************************
|
|
|
|
** Elliptic Curve algorithms
|
|
|
|
*/
|
|
|
|
|
2016-08-30 08:58:30 +03:00
|
|
|
/* Generates a public and private key, both of which are encoded
|
2008-06-06 16:40:11 +04:00
|
|
|
** in a single ECPrivateKey struct. Params is input, privKey are
|
|
|
|
** output.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus EC_NewKey(ECParams *params,
|
|
|
|
ECPrivateKey **privKey);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus EC_NewKeyFromSeed(ECParams *params,
|
|
|
|
ECPrivateKey **privKey,
|
|
|
|
const unsigned char *seed,
|
|
|
|
int seedlen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus EC_ValidatePublicKey(ECParams *params,
|
|
|
|
SECItem *publicValue);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-08-30 08:58:30 +03:00
|
|
|
/*
|
2008-06-06 16:40:11 +04:00
|
|
|
** 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.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus ECDH_Derive(SECItem *publicValue,
|
|
|
|
ECParams *params,
|
|
|
|
SECItem *privateValue,
|
|
|
|
PRBool withCofactor,
|
|
|
|
SECItem *derivedSecret);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus ECDSA_SignDigest(ECPrivateKey *key,
|
|
|
|
SECItem *signature,
|
2008-06-06 16:40:11 +04:00
|
|
|
const SECItem *digest);
|
|
|
|
|
|
|
|
/* On input, signature->len == size of buffer to hold signature.
|
|
|
|
** digest->len == size of digest.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus ECDSA_VerifyDigest(ECPublicKey *key,
|
|
|
|
const SECItem *signature,
|
2008-06-06 16:40:11 +04:00
|
|
|
const SECItem *digest);
|
|
|
|
|
|
|
|
/* Uses the provided seed. */
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus ECDSA_SignDigestWithSeed(ECPrivateKey *key,
|
|
|
|
SECItem *signature,
|
|
|
|
const SECItem *digest,
|
|
|
|
const unsigned char *seed,
|
|
|
|
const int seedlen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
/*
|
|
|
|
** RC4 symmetric stream cypher
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Create a new RC4 context suitable for RC4 encryption/decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "key" raw key data
|
|
|
|
** "len" the number of bytes of key data
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern RC4Context *RC4_CreateContext(const unsigned char *key, int len);
|
|
|
|
|
|
|
|
extern RC4Context *RC4_AllocateContext(void);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus RC4_InitContext(RC4Context *cx,
|
|
|
|
const unsigned char *key,
|
|
|
|
unsigned int keylen,
|
|
|
|
const unsigned char *,
|
|
|
|
int,
|
|
|
|
unsigned int,
|
|
|
|
unsigned int);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy an RC4 encryption/decryption context.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern void RC4_DestroyContext(RC4Context *cx, PRBool freeit);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform RC4 encryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern SECStatus RC4_Encrypt(RC4Context *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform RC4 decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern SECStatus RC4_Decrypt(RC4Context *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
/*
|
|
|
|
** RC2 symmetric block cypher
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Create a new RC2 context suitable for RC2 encryption/decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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).
|
2008-06-06 16:40:11 +04:00
|
|
|
**
|
|
|
|
** When mode is set to NSS_RC2_CBC the RC2 cipher is run in "cipher block
|
|
|
|
** chaining" mode.
|
|
|
|
*/
|
|
|
|
extern RC2Context *RC2_CreateContext(const unsigned char *key, unsigned int len,
|
2016-08-30 08:58:30 +03:00
|
|
|
const unsigned char *iv, int mode,
|
|
|
|
unsigned effectiveKeyLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern RC2Context *RC2_AllocateContext(void);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus RC2_InitContext(RC2Context *cx,
|
|
|
|
const unsigned char *key,
|
|
|
|
unsigned int keylen,
|
|
|
|
const unsigned char *iv,
|
|
|
|
int mode,
|
|
|
|
unsigned int effectiveKeyLen,
|
|
|
|
unsigned int);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy an RC2 encryption/decryption context.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern void RC2_DestroyContext(RC2Context *cx, PRBool freeit);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform RC2 encryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern SECStatus RC2_Encrypt(RC2Context *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform RC2 decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern SECStatus RC2_Decrypt(RC2Context *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
/*
|
|
|
|
** RC5 symmetric block cypher -- 64-bit block size
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** 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, unsigned int rounds,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int wordSize, const unsigned char *iv, int mode);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern RC5Context *RC5_AllocateContext(void);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus RC5_InitContext(RC5Context *cx,
|
|
|
|
const unsigned char *key,
|
|
|
|
unsigned int keylen,
|
|
|
|
const unsigned char *iv,
|
|
|
|
int mode,
|
|
|
|
unsigned int rounds,
|
|
|
|
unsigned int wordSize);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy an RC5 encryption/decryption context.
|
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
|
|
|
*/
|
|
|
|
extern void 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, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern SECStatus RC5_Decrypt(RC5Context *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
/*
|
|
|
|
** DES symmetric block cypher
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Create a new DES context suitable for DES encryption/decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
**
|
|
|
|
** When mode is set to NSS_DES_CBC or NSS_DES_EDE3_CBC then the DES
|
|
|
|
** cipher is run in "cipher block chaining" mode.
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern DESContext *DES_CreateContext(const unsigned char *key,
|
2008-06-06 16:40:11 +04:00
|
|
|
const unsigned char *iv,
|
2016-08-30 08:58:30 +03:00
|
|
|
int mode, PRBool encrypt);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern DESContext *DES_AllocateContext(void);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus DES_InitContext(DESContext *cx,
|
|
|
|
const unsigned char *key,
|
|
|
|
unsigned int keylen,
|
|
|
|
const unsigned char *iv,
|
|
|
|
int mode,
|
|
|
|
unsigned int encrypt,
|
|
|
|
unsigned int);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy an DES encryption/decryption context.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern void DES_DestroyContext(DESContext *cx, PRBool freeit);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform DES encryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
**
|
|
|
|
** NOTE: the inputLen must be a multiple of DES_KEY_LENGTH
|
|
|
|
*/
|
|
|
|
extern SECStatus DES_Encrypt(DESContext *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform DES decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
**
|
|
|
|
** NOTE: the inputLen must be a multiple of DES_KEY_LENGTH
|
|
|
|
*/
|
|
|
|
extern SECStatus DES_Decrypt(DESContext *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2009-01-21 06:43:31 +03:00
|
|
|
/******************************************/
|
2016-08-30 08:58:30 +03:00
|
|
|
/*
|
|
|
|
** SEED symmetric block cypher
|
2009-01-21 06:43:31 +03:00
|
|
|
*/
|
|
|
|
extern SEEDContext *
|
2016-08-30 08:58:30 +03:00
|
|
|
SEED_CreateContext(const unsigned char *key, const unsigned char *iv,
|
|
|
|
int mode, PRBool encrypt);
|
2009-01-21 06:43:31 +03:00
|
|
|
extern SEEDContext *SEED_AllocateContext(void);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus SEED_InitContext(SEEDContext *cx,
|
|
|
|
const unsigned char *key,
|
|
|
|
unsigned int keylen,
|
|
|
|
const unsigned char *iv,
|
|
|
|
int mode, unsigned int encrypt,
|
|
|
|
unsigned int);
|
2009-01-21 06:43:31 +03:00
|
|
|
extern void SEED_DestroyContext(SEEDContext *cx, PRBool freeit);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus
|
|
|
|
SEED_Encrypt(SEEDContext *cx, unsigned char *output,
|
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
|
|
|
extern SECStatus
|
|
|
|
SEED_Decrypt(SEEDContext *cx, unsigned char *output,
|
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
2009-01-21 06:43:31 +03:00
|
|
|
const unsigned char *input, unsigned int inputLen);
|
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/******************************************/
|
|
|
|
/*
|
|
|
|
** AES symmetric block cypher (Rijndael)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Create a new AES context suitable for AES encryption/decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "key" raw key data
|
|
|
|
** "keylen" the number of bytes of key data (16, 24, or 32)
|
2017-06-13 15:26:51 +03:00
|
|
|
** "blocklen" is the blocksize to use. NOTE: only 16 is supported!
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern AESContext *
|
2016-08-30 08:58:30 +03:00
|
|
|
AES_CreateContext(const unsigned char *key, const unsigned char *iv,
|
2008-06-06 16:40:11 +04:00
|
|
|
int mode, int encrypt,
|
|
|
|
unsigned int keylen, unsigned int blocklen);
|
|
|
|
extern AESContext *AES_AllocateContext(void);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus AES_InitContext(AESContext *cx,
|
|
|
|
const unsigned char *key,
|
|
|
|
unsigned int keylen,
|
|
|
|
const unsigned char *iv,
|
|
|
|
int mode,
|
|
|
|
unsigned int encrypt,
|
|
|
|
unsigned int blocklen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy a AES encryption/decryption context.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern void
|
2008-06-06 16:40:11 +04:00
|
|
|
AES_DestroyContext(AESContext *cx, PRBool freeit);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform AES encryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
AES_Encrypt(AESContext *cx, unsigned char *output,
|
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform AES decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
AES_Decrypt(AESContext *cx, unsigned char *output,
|
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
/*
|
|
|
|
** AES key wrap algorithm, RFC 3394
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Create a new AES context suitable for AES encryption/decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "key" raw key data
|
2008-06-06 16:40:11 +04:00
|
|
|
** "iv" The 8 byte "initial value"
|
|
|
|
** "encrypt", a boolean, true for key wrapping, false for unwrapping.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "keylen" the number of bytes of key data (16, 24, or 32)
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern AESKeyWrapContext *
|
2016-08-30 08:58:30 +03:00
|
|
|
AESKeyWrap_CreateContext(const unsigned char *key, const unsigned char *iv,
|
2008-06-06 16:40:11 +04:00
|
|
|
int encrypt, unsigned int keylen);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern AESKeyWrapContext *AESKeyWrap_AllocateContext(void);
|
|
|
|
extern SECStatus
|
|
|
|
AESKeyWrap_InitContext(AESKeyWrapContext *cx,
|
|
|
|
const unsigned char *key,
|
|
|
|
unsigned int keylen,
|
|
|
|
const unsigned char *iv,
|
|
|
|
int,
|
|
|
|
unsigned int encrypt,
|
|
|
|
unsigned int);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy a AES KeyWrap context.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern void
|
2008-06-06 16:40:11 +04:00
|
|
|
AESKeyWrap_DestroyContext(AESKeyWrapContext *cx, PRBool freeit);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform AES key wrap.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
AESKeyWrap_Encrypt(AESKeyWrapContext *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform AES key unwrap.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
AESKeyWrap_Decrypt(AESKeyWrapContext *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-08-30 08:58:30 +03:00
|
|
|
/******************************************/
|
2008-06-06 16:40:11 +04:00
|
|
|
/*
|
|
|
|
** Camellia symmetric block cypher
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Create a new Camellia context suitable for Camellia encryption/decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "key" raw key data
|
|
|
|
** "keylen" the number of bytes of key data (16, 24, or 32)
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern CamelliaContext *
|
2016-08-30 08:58:30 +03:00
|
|
|
Camellia_CreateContext(const unsigned char *key, const unsigned char *iv,
|
|
|
|
int mode, int encrypt, unsigned int keylen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
extern CamelliaContext *Camellia_AllocateContext(void);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus Camellia_InitContext(CamelliaContext *cx,
|
|
|
|
const unsigned char *key,
|
|
|
|
unsigned int keylen,
|
|
|
|
const unsigned char *iv,
|
|
|
|
int mode,
|
|
|
|
unsigned int encrypt,
|
|
|
|
unsigned int unused);
|
2008-06-06 16:40:11 +04:00
|
|
|
/*
|
|
|
|
** Destroy a Camellia encryption/decryption context.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern void
|
2008-06-06 16:40:11 +04:00
|
|
|
Camellia_DestroyContext(CamelliaContext *cx, PRBool freeit);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform Camellia encryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
Camellia_Encrypt(CamelliaContext *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Perform Camellia decryption.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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
|
2008-06-06 16:40:11 +04:00
|
|
|
Camellia_Decrypt(CamelliaContext *cx, unsigned char *output,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
/******************************************/
|
|
|
|
/*
|
|
|
|
** ChaCha20+Poly1305 AEAD
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern SECStatus ChaCha20Poly1305_InitContext(ChaCha20Poly1305Context *ctx,
|
|
|
|
const unsigned char *key,
|
|
|
|
unsigned int keyLen,
|
|
|
|
unsigned int tagLen);
|
|
|
|
|
|
|
|
extern ChaCha20Poly1305Context *ChaCha20Poly1305_CreateContext(
|
|
|
|
const unsigned char *key, unsigned int keyLen, unsigned int tagLen);
|
|
|
|
|
|
|
|
extern void ChaCha20Poly1305_DestroyContext(ChaCha20Poly1305Context *ctx,
|
|
|
|
PRBool freeit);
|
|
|
|
|
|
|
|
extern SECStatus ChaCha20Poly1305_Seal(
|
|
|
|
const ChaCha20Poly1305Context *ctx, unsigned char *output,
|
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen,
|
|
|
|
const unsigned char *nonce, unsigned int nonceLen,
|
|
|
|
const unsigned char *ad, unsigned int adLen);
|
|
|
|
|
|
|
|
extern SECStatus ChaCha20Poly1305_Open(
|
|
|
|
const ChaCha20Poly1305Context *ctx, unsigned char *output,
|
|
|
|
unsigned int *outputLen, unsigned int maxOutputLen,
|
|
|
|
const unsigned char *input, unsigned int inputLen,
|
|
|
|
const unsigned char *nonce, unsigned int nonceLen,
|
|
|
|
const unsigned char *ad, unsigned int adLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
/*
|
|
|
|
** 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,
|
2016-08-30 08:58:30 +03:00
|
|
|
PRUint32 src_length);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Create a new MD5 context
|
|
|
|
*/
|
|
|
|
extern MD5Context *MD5_NewContext(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy an MD5 secure hash context.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
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.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "input" the data to hash
|
|
|
|
** "inputLen" the amount of data to hash
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern void MD5_Update(MD5Context *cx,
|
2016-08-30 08:58:30 +03:00
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Finish the MD5 hash function. Produce the digested results in "digest"
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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"
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern void MD5_End(MD5Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2013-02-10 04:11:00 +04:00
|
|
|
/*
|
2013-03-13 01:58:12 +04:00
|
|
|
** Export the current state of the MD5 hash without appending the standard
|
|
|
|
** padding and length bytes. Produce the digested results in "digest"
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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"
|
2013-02-10 04:11:00 +04:00
|
|
|
*/
|
|
|
|
extern void MD5_EndRaw(MD5Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2013-02-10 04:11:00 +04:00
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus MD5_Flatten(MD5Context *cx, unsigned char *space);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern MD5Context *MD5_Resurrect(unsigned char *space, void *arg);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern void MD5_Clone(MD5Context *dest, MD5Context *src);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** 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.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
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.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "input" the data to hash
|
|
|
|
** "inputLen" the amount of data to hash
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern void MD2_Update(MD2Context *cx,
|
2016-08-30 08:58:30 +03:00
|
|
|
const unsigned char *input, unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Finish the MD2 hash function. Produce the digested results in "digest"
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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"
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern void MD2_End(MD2Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus MD2_Flatten(MD2Context *cx, unsigned char *space);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern MD2Context *MD2_Resurrect(unsigned char *space, void *arg);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern void 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(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,
|
2016-08-30 08:58:30 +03:00
|
|
|
PRUint32 src_length);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Create a new SHA-1 context
|
|
|
|
*/
|
|
|
|
extern SHA1Context *SHA1_NewContext(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy a SHA-1 secure hash context.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "freeit" if PR_TRUE then free the object as well as its sub-objects
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
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.
|
2016-08-30 08:58:30 +03:00
|
|
|
** "cx" the context
|
|
|
|
** "input" the data to hash
|
|
|
|
** "inputLen" the amount of data to hash
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern void SHA1_Update(SHA1Context *cx, const unsigned char *input,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Finish the SHA-1 hash function. Produce the digested results in "digest"
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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"
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern void SHA1_End(SHA1Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2013-02-10 04:11:00 +04:00
|
|
|
/*
|
|
|
|
** Export the current state of the SHA-1 hash without appending the standard
|
2013-03-13 01:58:12 +04:00
|
|
|
** padding and length bytes. Produce the digested results in "digest"
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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"
|
2013-02-10 04:11:00 +04:00
|
|
|
*/
|
|
|
|
extern void SHA1_EndRaw(SHA1Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2013-02-10 04:11:00 +04:00
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/*
|
|
|
|
** trace the intermediate state info of the SHA1 hash.
|
|
|
|
*/
|
|
|
|
extern void SHA1_TraceState(SHA1Context *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;
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus SHA1_Flatten(SHA1Context *cx, unsigned char *space);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SHA1Context *SHA1_Resurrect(unsigned char *space, void *arg);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern void SHA1_Clone(SHA1Context *dest, SHA1Context *src);
|
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
|
2011-08-19 19:27:10 +04:00
|
|
|
extern SHA224Context *SHA224_NewContext(void);
|
|
|
|
extern void SHA224_DestroyContext(SHA224Context *cx, PRBool freeit);
|
|
|
|
extern void SHA224_Begin(SHA224Context *cx);
|
|
|
|
extern void SHA224_Update(SHA224Context *cx, const unsigned char *input,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int inputLen);
|
2011-08-19 19:27:10 +04:00
|
|
|
extern void SHA224_End(SHA224Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2013-03-13 01:58:12 +04:00
|
|
|
/*
|
|
|
|
** Export the current state of the SHA-224 hash without appending the standard
|
|
|
|
** padding and length bytes. Produce the digested results in "digest"
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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"
|
2013-03-13 01:58:12 +04:00
|
|
|
*/
|
2013-02-10 04:11:00 +04:00
|
|
|
extern void SHA224_EndRaw(SHA224Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2011-08-19 19:27:10 +04:00
|
|
|
extern SECStatus SHA224_HashBuf(unsigned char *dest, const unsigned char *src,
|
2016-08-30 08:58:30 +03:00
|
|
|
PRUint32 src_length);
|
2011-08-19 19:27:10 +04:00
|
|
|
extern SECStatus SHA224_Hash(unsigned char *dest, const char *src);
|
|
|
|
extern void SHA224_TraceState(SHA224Context *cx);
|
|
|
|
extern unsigned int SHA224_FlattenSize(SHA224Context *cx);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus SHA224_Flatten(SHA224Context *cx, unsigned char *space);
|
|
|
|
extern SHA224Context *SHA224_Resurrect(unsigned char *space, void *arg);
|
2011-08-19 19:27:10 +04:00
|
|
|
extern void SHA224_Clone(SHA224Context *dest, SHA224Context *src);
|
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
extern SHA256Context *SHA256_NewContext(void);
|
|
|
|
extern void SHA256_DestroyContext(SHA256Context *cx, PRBool freeit);
|
|
|
|
extern void SHA256_Begin(SHA256Context *cx);
|
|
|
|
extern void SHA256_Update(SHA256Context *cx, const unsigned char *input,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern void SHA256_End(SHA256Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2013-03-13 01:58:12 +04:00
|
|
|
/*
|
|
|
|
** Export the current state of the SHA-256 hash without appending the standard
|
|
|
|
** padding and length bytes. Produce the digested results in "digest"
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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"
|
2013-03-13 01:58:12 +04:00
|
|
|
*/
|
2013-02-10 04:11:00 +04:00
|
|
|
extern void SHA256_EndRaw(SHA256Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern SECStatus SHA256_HashBuf(unsigned char *dest, const unsigned char *src,
|
2016-08-30 08:58:30 +03:00
|
|
|
PRUint32 src_length);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern SECStatus SHA256_Hash(unsigned char *dest, const char *src);
|
|
|
|
extern void SHA256_TraceState(SHA256Context *cx);
|
|
|
|
extern unsigned int SHA256_FlattenSize(SHA256Context *cx);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus SHA256_Flatten(SHA256Context *cx, unsigned char *space);
|
|
|
|
extern SHA256Context *SHA256_Resurrect(unsigned char *space, void *arg);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern void SHA256_Clone(SHA256Context *dest, SHA256Context *src);
|
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
|
|
|
|
extern SHA512Context *SHA512_NewContext(void);
|
|
|
|
extern void SHA512_DestroyContext(SHA512Context *cx, PRBool freeit);
|
|
|
|
extern void SHA512_Begin(SHA512Context *cx);
|
|
|
|
extern void SHA512_Update(SHA512Context *cx, const unsigned char *input,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int inputLen);
|
2013-03-13 01:58:12 +04:00
|
|
|
/*
|
|
|
|
** Export the current state of the SHA-512 hash without appending the standard
|
|
|
|
** padding and length bytes. Produce the digested results in "digest"
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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"
|
2013-03-13 01:58:12 +04:00
|
|
|
*/
|
2013-02-10 04:11:00 +04:00
|
|
|
extern void SHA512_EndRaw(SHA512Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern void SHA512_End(SHA512Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern SECStatus SHA512_HashBuf(unsigned char *dest, const unsigned char *src,
|
2016-08-30 08:58:30 +03:00
|
|
|
PRUint32 src_length);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern SECStatus SHA512_Hash(unsigned char *dest, const char *src);
|
|
|
|
extern void SHA512_TraceState(SHA512Context *cx);
|
|
|
|
extern unsigned int SHA512_FlattenSize(SHA512Context *cx);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus SHA512_Flatten(SHA512Context *cx, unsigned char *space);
|
|
|
|
extern SHA512Context *SHA512_Resurrect(unsigned char *space, void *arg);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern void SHA512_Clone(SHA512Context *dest, SHA512Context *src);
|
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
|
|
|
|
extern SHA384Context *SHA384_NewContext(void);
|
|
|
|
extern void SHA384_DestroyContext(SHA384Context *cx, PRBool freeit);
|
|
|
|
extern void SHA384_Begin(SHA384Context *cx);
|
|
|
|
extern void SHA384_Update(SHA384Context *cx, const unsigned char *input,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int inputLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern void SHA384_End(SHA384Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2013-03-13 01:58:12 +04:00
|
|
|
/*
|
|
|
|
** Export the current state of the SHA-384 hash without appending the standard
|
|
|
|
** padding and length bytes. Produce the digested results in "digest"
|
2016-08-30 08:58:30 +03:00
|
|
|
** "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"
|
2013-03-13 01:58:12 +04:00
|
|
|
*/
|
2013-02-10 04:11:00 +04:00
|
|
|
extern void SHA384_EndRaw(SHA384Context *cx, unsigned char *digest,
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int *digestLen, unsigned int maxDigestLen);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern SECStatus SHA384_HashBuf(unsigned char *dest, const unsigned char *src,
|
2016-08-30 08:58:30 +03:00
|
|
|
PRUint32 src_length);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern SECStatus SHA384_Hash(unsigned char *dest, const char *src);
|
|
|
|
extern void SHA384_TraceState(SHA384Context *cx);
|
|
|
|
extern unsigned int SHA384_FlattenSize(SHA384Context *cx);
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus SHA384_Flatten(SHA384Context *cx, unsigned char *space);
|
|
|
|
extern SHA384Context *SHA384_Resurrect(unsigned char *space, void *arg);
|
2008-06-06 16:40:11 +04:00
|
|
|
extern void SHA384_Clone(SHA384Context *dest, SHA384Context *src);
|
|
|
|
|
|
|
|
/****************************************
|
2011-08-19 19:27:10 +04:00
|
|
|
* implement TLS 1.0 Pseudo Random Function (PRF) and TLS P_hash function
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
TLS_PRF(const SECItem *secret, const char *label, SECItem *seed,
|
|
|
|
SECItem *result, PRBool isFIPS);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2011-08-19 19:27:10 +04:00
|
|
|
extern SECStatus
|
|
|
|
TLS_P_hash(HASH_HashType hashAlg, const SECItem *secret, const char *label,
|
|
|
|
SECItem *seed, SECItem *result, PRBool isFIPS);
|
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/******************************************/
|
|
|
|
/*
|
|
|
|
** 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(const 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()).
|
|
|
|
*/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern void RNG_RNGShutdown(void);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
extern void RNG_SystemInfoForRNG(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIPS 186-2 Change Notice 1 RNG Algorithm 1, used both to
|
|
|
|
* generate the DSA X parameter and as a generic purpose RNG.
|
|
|
|
*
|
|
|
|
* The following two FIPS186Change functions are needed for
|
|
|
|
* NIST RNG Validation System.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2009-04-07 05:36:45 +04:00
|
|
|
* FIPS186Change_GenerateX is now deprecated. It will return SECFailure with
|
|
|
|
* the error set to PR_NOT_IMPLEMENTED_ERROR.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern SECStatus
|
|
|
|
FIPS186Change_GenerateX(unsigned char *XKEY,
|
|
|
|
const unsigned char *XSEEDj,
|
|
|
|
unsigned char *x_j);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When generating the DSA X parameter, we generate 2*GSIZE bytes
|
|
|
|
* of random output and reduce it mod q.
|
|
|
|
*
|
|
|
|
* Input: w, 2*GSIZE bytes
|
|
|
|
* q, DSA_SUBPRIME_LEN bytes
|
|
|
|
* Output: xj, DSA_SUBPRIME_LEN bytes
|
|
|
|
*/
|
|
|
|
extern SECStatus
|
|
|
|
FIPS186Change_ReduceModQForDSA(const unsigned char *w,
|
|
|
|
const unsigned char *q,
|
|
|
|
unsigned char *xj);
|
|
|
|
|
2017-03-08 10:40:46 +03:00
|
|
|
/* To allow NIST KAT tests */
|
|
|
|
extern SECStatus
|
|
|
|
PRNGTEST_Instantiate_Kat(const PRUint8 *entropy, unsigned int entropy_len,
|
|
|
|
const PRUint8 *nonce, unsigned int nonce_len,
|
|
|
|
const PRUint8 *personal_string, unsigned int ps_len);
|
|
|
|
|
2009-04-07 05:36:45 +04:00
|
|
|
/*
|
|
|
|
* The following functions are for FIPS poweron self test and FIPS algorithm
|
|
|
|
* testing.
|
|
|
|
*/
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
PRNGTEST_Instantiate(const PRUint8 *entropy, unsigned int entropy_len,
|
|
|
|
const PRUint8 *nonce, unsigned int nonce_len,
|
|
|
|
const PRUint8 *personal_string, unsigned int ps_len);
|
2009-04-07 05:36:45 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
PRNGTEST_Reseed(const PRUint8 *entropy, unsigned int entropy_len,
|
|
|
|
const PRUint8 *additional, unsigned int additional_len);
|
2009-04-07 05:36:45 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
PRNGTEST_Generate(PRUint8 *bytes, unsigned int bytes_len,
|
|
|
|
const PRUint8 *additional, unsigned int additional_len);
|
2009-04-07 05:36:45 +04:00
|
|
|
|
|
|
|
extern SECStatus
|
|
|
|
PRNGTEST_Uninstantiate(void);
|
|
|
|
|
2012-10-01 22:02:15 +04:00
|
|
|
extern SECStatus
|
|
|
|
PRNGTEST_RunHealthTests(void);
|
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/* Generate PQGParams and PQGVerify structs.
|
2016-08-30 08:58:30 +03:00
|
|
|
* Length of seed and length of h both equal length of P.
|
2008-06-06 16:40:11 +04:00
|
|
|
* All lengths are specified by "j", according to the table above.
|
2012-10-01 22:02:15 +04:00
|
|
|
*
|
|
|
|
* The verify parameters will conform to FIPS186-1.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern SECStatus
|
2016-08-30 08:58:30 +03:00
|
|
|
PQG_ParamGen(unsigned int j, /* input : determines length of P. */
|
|
|
|
PQGParams **pParams, /* output: P Q and G returned here */
|
|
|
|
PQGVerify **pVfy); /* output: counter and seed. */
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/* 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.
|
2012-10-01 22:02:15 +04:00
|
|
|
*
|
|
|
|
* The verify parameters will conform to FIPS186-1.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
extern SECStatus
|
|
|
|
PQG_ParamGenSeedLen(
|
2016-08-30 08:58:30 +03:00
|
|
|
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. */
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2012-10-01 22:02:15 +04:00
|
|
|
/* Generate PQGParams and PQGVerify structs.
|
2016-08-30 08:58:30 +03:00
|
|
|
* Length of P specified by L in bits.
|
|
|
|
* Length of Q specified by N in bits.
|
2012-10-01 22:02:15 +04:00
|
|
|
* Length of SEED in bytes specified in seedBytes.
|
|
|
|
* seedBbytes must be in the range [N..L*2] or an error will result.
|
|
|
|
*
|
|
|
|
* Not that J uses the above table, L is the length exact. L and N must
|
|
|
|
* match the table below or an error will result:
|
|
|
|
*
|
|
|
|
* L N
|
|
|
|
* 1024 160
|
|
|
|
* 2048 224
|
|
|
|
* 2048 256
|
|
|
|
* 3072 256
|
|
|
|
*
|
2012-10-18 22:41:08 +04:00
|
|
|
* If N or seedBytes are set to zero, then PQG_ParamGenSeedLen will
|
|
|
|
* pick a default value (typically the smallest secure value for these
|
|
|
|
* variables).
|
|
|
|
*
|
2016-08-30 08:58:30 +03:00
|
|
|
* The verify parameters will conform to FIPS186-3 using the smallest
|
2012-10-01 22:02:15 +04:00
|
|
|
* permissible hash for the key strength.
|
|
|
|
*/
|
|
|
|
extern SECStatus
|
|
|
|
PQG_ParamGenV2(
|
2016-08-30 08:58:30 +03:00
|
|
|
unsigned int L, /* input : determines length of P. */
|
|
|
|
unsigned int N, /* input : determines length of Q. */
|
|
|
|
unsigned int seedBytes, /* input : length of seed in bytes.*/
|
|
|
|
PQGParams **pParams, /* output: P Q and G returned here */
|
|
|
|
PQGVerify **pVfy); /* output: counter and seed. */
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*
|
2009-04-07 05:36:45 +04:00
|
|
|
* Return value indicates whether Verification operation ran successfully
|
2008-06-06 16:40:11 +04:00
|
|
|
* 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.
|
|
|
|
*
|
2012-10-01 22:02:15 +04:00
|
|
|
* Verify the PQG againts the counter, SEED and h.
|
|
|
|
* These tests are specified in FIPS 186-3 Appendix A.1.1.1, A.1.1.3, and A.2.2
|
|
|
|
* PQG_VerifyParams will automatically choose the appropriate test.
|
2008-06-06 16:40:11 +04:00
|
|
|
*/
|
|
|
|
|
2016-08-30 08:58:30 +03:00
|
|
|
extern SECStatus PQG_VerifyParams(const PQGParams *params,
|
|
|
|
const PQGVerify *vfy, SECStatus *result);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
extern void PQG_DestroyParams(PQGParams *params);
|
|
|
|
|
|
|
|
extern void PQG_DestroyVerify(PQGVerify *vfy);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clean-up any global tables freebl may have allocated after it starts up.
|
|
|
|
* This function is not thread safe and should be called only after the
|
|
|
|
* library has been quiessed.
|
|
|
|
*/
|
|
|
|
extern void BL_Cleanup(void);
|
|
|
|
|
|
|
|
/* unload freebl shared library from memory */
|
|
|
|
extern void BL_Unload(void);
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Verify a given Shared library signature *
|
|
|
|
**************************************************************************/
|
|
|
|
PRBool BLAPI_SHVerify(const char *name, PRFuncPtr addr);
|
|
|
|
|
2011-08-19 19:27:10 +04:00
|
|
|
/**************************************************************************
|
|
|
|
* Verify a given filename's signature *
|
|
|
|
**************************************************************************/
|
|
|
|
PRBool BLAPI_SHVerifyFile(const char *shName);
|
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
/**************************************************************************
|
|
|
|
* Verify Are Own Shared library signature *
|
|
|
|
**************************************************************************/
|
|
|
|
PRBool BLAPI_VerifySelf(const char *name);
|
|
|
|
|
|
|
|
/*********************************************************************/
|
2016-08-30 08:58:30 +03:00
|
|
|
extern const SECHashObject *HASH_GetRawHashObject(HASH_HashType hashType);
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2009-02-10 20:18:32 +03:00
|
|
|
extern void BL_SetForkState(PRBool forked);
|
|
|
|
|
2014-04-25 17:06:01 +04:00
|
|
|
/*
|
|
|
|
** pepare an ECParam structure from DEREncoded params
|
|
|
|
*/
|
|
|
|
extern SECStatus EC_FillParams(PLArenaPool *arena,
|
|
|
|
const SECItem *encodedParams, ECParams *params);
|
|
|
|
extern SECStatus EC_DecodeParams(const SECItem *encodedParams,
|
|
|
|
ECParams **ecparams);
|
|
|
|
extern SECStatus EC_CopyParams(PLArenaPool *arena, ECParams *dstParams,
|
|
|
|
const ECParams *srcParams);
|
2017-02-21 15:55:41 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* use the internal table to get the size in bytes of a single EC point
|
|
|
|
*/
|
|
|
|
extern int EC_GetPointSize(const ECParams *params);
|
2014-04-25 17:06:01 +04:00
|
|
|
|
2008-06-06 16:40:11 +04:00
|
|
|
SEC_END_PROTOS
|
|
|
|
|
|
|
|
#endif /* _BLAPI_H_ */
|