diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-02 04:11:19 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-02 04:11:19 +0000 |
commit | f38eee46f190189ff2af4ebddf79254a889613d6 (patch) | |
tree | 9162fcbcd04f22e100b08ba90fee0c1860ad7d94 /net/third_party | |
parent | 71e2b229575aff76dd59d4c0b7ddf7e8a0d57c41 (diff) | |
download | chromium_src-f38eee46f190189ff2af4ebddf79254a889613d6.zip chromium_src-f38eee46f190189ff2af4ebddf79254a889613d6.tar.gz chromium_src-f38eee46f190189ff2af4ebddf79254a889613d6.tar.bz2 |
Build the NSS libSSL with NO_PKCS11_BYPASS defined.
Don't build with NSS_ENABLE_ZLIB defiend because we are no longer
enabling the SSL_ENABLE_DEFLATE option.
Define AES_256_KEY_SIZE in sslsnce.c if the system blapit.h doesn't
define it. We used to work around this in ssl/bodge/blapi.h.
R=agl@chromium.org,rsleevi@chromium.org
BUG=179524
TEST=no compilation errors, especially on Linux.
Review URL: https://chromiumcodereview.appspot.com/12386065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185681 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/third_party')
-rw-r--r-- | net/third_party/nss/README.chromium | 4 | ||||
-rw-r--r-- | net/third_party/nss/patches/aes256keylength.patch | 19 | ||||
-rwxr-xr-x | net/third_party/nss/patches/applypatches.sh | 2 | ||||
-rw-r--r-- | net/third_party/nss/ssl.gyp | 15 | ||||
-rw-r--r-- | net/third_party/nss/ssl/bodge/alghmac.h | 96 | ||||
-rw-r--r-- | net/third_party/nss/ssl/bodge/blapi.h | 1213 | ||||
-rw-r--r-- | net/third_party/nss/ssl/bodge/genload.c | 191 | ||||
-rw-r--r-- | net/third_party/nss/ssl/bodge/loader.c | 1699 | ||||
-rw-r--r-- | net/third_party/nss/ssl/bodge/loader.h | 555 | ||||
-rw-r--r-- | net/third_party/nss/ssl/sslsnce.c | 5 |
10 files changed, 31 insertions, 3768 deletions
diff --git a/net/third_party/nss/README.chromium b/net/third_party/nss/README.chromium index 52dcd63..dedbe12 100644 --- a/net/third_party/nss/README.chromium +++ b/net/third_party/nss/README.chromium @@ -92,6 +92,10 @@ Patches: patches/dtlsinitclist.patch https://bugzilla.mozilla.org/show_bug.cgi?id=822433 (fixed in NSS 3.14.2) + * Define AES_256_KEY_LENGTH if the system blapit.h header doesn't define it. + Remove this patch when all system NSS packages are NSS 3.12.10 or later. + patches/aes256keylength.patch + Apply the patches to NSS by running the patches/applypatches.sh script. Read the comments at the top of patches/applypatches.sh for instructions. diff --git a/net/third_party/nss/patches/aes256keylength.patch b/net/third_party/nss/patches/aes256keylength.patch new file mode 100644 index 0000000..f978c07 --- /dev/null +++ b/net/third_party/nss/patches/aes256keylength.patch @@ -0,0 +1,19 @@ +Index: mozilla/security/nss/lib/ssl/sslsnce.c +=================================================================== +RCS file: /cvsroot/mozilla/security/nss/lib/ssl/sslsnce.c,v +retrieving revision 1.63 +diff -p -u -r1.63 sslsnce.c +--- mozilla/security/nss/lib/ssl/sslsnce.c 14 Jun 2012 19:04:59 -0000 1.63 ++++ mozilla/security/nss/lib/ssl/sslsnce.c 2 Mar 2013 00:31:22 -0000 +@@ -87,6 +87,11 @@ + #include "nspr.h" + #include "sslmutex.h" + ++/* AES_256_KEY_LENGTH was added to blapit.h in NSS 3.12.10. */ ++#ifndef AES_256_KEY_LENGTH ++#define AES_256_KEY_LENGTH 32 /* bytes */ ++#endif ++ + /* + ** Format of a cache entry in the shared memory. + */ diff --git a/net/third_party/nss/patches/applypatches.sh b/net/third_party/nss/patches/applypatches.sh index 624adee..01340a3 100755 --- a/net/third_party/nss/patches/applypatches.sh +++ b/net/third_party/nss/patches/applypatches.sh @@ -45,3 +45,5 @@ patch -p5 < $patches_dir/secretexporterlocks.patch patch -p6 < $patches_dir/cbc.patch patch -p5 < $patches_dir/dtlsinitclist.patch + +patch -p5 < $patches_dir/aes256keylength.patch diff --git a/net/third_party/nss/ssl.gyp b/net/third_party/nss/ssl.gyp index eac82d4..7eaa56b 100644 --- a/net/third_party/nss/ssl.gyp +++ b/net/third_party/nss/ssl.gyp @@ -67,8 +67,6 @@ 'ssl/unix_err.h', 'ssl/win32err.c', 'ssl/win32err.h', - 'ssl/bodge/loader.c', - 'ssl/bodge/loader.h', 'ssl/bodge/secure_memcmp.c', ], 'sources!': [ @@ -76,17 +74,14 @@ 'ssl/os2_err.h', ], 'defines': [ + 'NO_PKCS11_BYPASS', 'NSS_ENABLE_ECC', - 'NSS_ENABLE_ZLIB', 'USE_UTIL_DIRECTLY', ], 'defines!': [ # Regrettably, NSS can't be compiled with NO_NSPR_10_SUPPORT yet. 'NO_NSPR_10_SUPPORT', ], - 'dependencies': [ - '../../../third_party/zlib/zlib.gyp:zlib', - ], 'msvs_disabled_warnings': [4018, 4244, 4267], 'conditions': [ ['component == "shared_library"', { @@ -141,14 +136,6 @@ }, ], [ 'os_posix == 1 and OS != "mac" and OS != "ios"', { - 'defines': [ - # These macros are needed only for compiling the files in - # ssl/bodge. - 'SHLIB_PREFIX="lib"', - 'SHLIB_SUFFIX="so"', - 'SHLIB_VERSION="3"', - 'SOFTOKEN_SHLIB_VERSION="3"', - ], 'include_dirs': [ 'ssl/bodge', ], diff --git a/net/third_party/nss/ssl/bodge/alghmac.h b/net/third_party/nss/ssl/bodge/alghmac.h deleted file mode 100644 index 81c5bfa..0000000 --- a/net/third_party/nss/ssl/bodge/alghmac.h +++ /dev/null @@ -1,96 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape security libraries. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1994-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _ALGHMAC_H_ -#define _ALGHMAC_H_ - -typedef struct HMACContextStr HMACContext; - -SEC_BEGIN_PROTOS - -/* destroy HMAC context */ -extern void -HMAC_Destroy(HMACContext *cx, PRBool freeit); - -/* create HMAC context - * hash_obj hash object from SECRawHashObjects[] - * secret the secret with which the HMAC is performed. - * secret_len the length of the secret. - * isFIPS true if conforming to FIPS 198. - * - * NULL is returned if an error occurs. - */ -extern HMACContext * -HMAC_Create(const SECHashObject *hash_obj, const unsigned char *secret, - unsigned int secret_len, PRBool isFIPS); - -/* like HMAC_Create, except caller allocates HMACContext. */ -SECStatus -HMAC_Init(HMACContext *cx, const SECHashObject *hash_obj, - const unsigned char *secret, unsigned int secret_len, PRBool isFIPS); - -/* reset HMAC for a fresh round */ -extern void -HMAC_Begin(HMACContext *cx); - -/* update HMAC - * cx HMAC Context - * data the data to perform HMAC on - * data_len the length of the data to process - */ -extern void -HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len); - -/* Finish HMAC -- place the results within result - * cx HMAC context - * result buffer for resulting hmac'd data - * result_len where the resultant hmac length is stored - * max_result_len maximum possible length that can be stored in result - */ -extern SECStatus -HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len, - unsigned int max_result_len); - -/* clone a copy of the HMAC state. this is usefult when you would - * need to keep a running hmac but also need to extract portions - * partway through the process. - */ -extern HMACContext * -HMAC_Clone(HMACContext *cx); - -SEC_END_PROTOS - -#endif diff --git a/net/third_party/nss/ssl/bodge/blapi.h b/net/third_party/nss/ssl/bodge/blapi.h deleted file mode 100644 index 17350cf..0000000 --- a/net/third_party/nss/ssl/bodge/blapi.h +++ /dev/null @@ -1,1213 +0,0 @@ -/* - * crypto.h - public data structures and prototypes for the crypto library - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape security libraries. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1994-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* $Id: blapi.h,v 1.33 2009/03/29 03:45:32 wtc%google.com Exp $ */ - -#ifndef _BLAPI_H_ -#define _BLAPI_H_ - -#include "blapit.h" -#include "hasht.h" -#include "alghmac.h" - -#ifndef AES_256_KEY_LENGTH -#define AES_256_KEY_LENGTH 32 /* bytes */ -#endif - -SEC_BEGIN_PROTOS - -/* -** 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, - unsigned char * output, - const unsigned char * 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, - unsigned char * output, - const unsigned char * 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, - unsigned char * output, - const unsigned char * input); - -/* -** Perform a check of private key parameters for consistency. -*/ -extern SECStatus RSA_PrivateKeyCheck(RSAPrivateKey *key); - - -/******************************************************************** -** DSA signing algorithm -*/ - -/* -** 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, - const unsigned char * seed, - DSAPrivateKey **privKey); - -/* For FIPS compliance testing. Seed must be exactly 20 bytes. */ -extern SECStatus DSA_SignDigestWithSeed(DSAPrivateKey * key, - SECItem * signature, - const SECItem * digest, - const unsigned char * seed); - -/****************************************************** -** Diffie Helman key exchange algorithm -*/ - -/* 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 never be larger than the length -** of the prime, and it may be smaller than maxOutBytes. -** 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, - unsigned int maxOutBytes); - -/* -** 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); - -/****************************************************** -** Elliptic Curve algorithms -*/ - -/* 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, - const unsigned char* 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); - -/* Uses the provided seed. */ -extern SECStatus ECDSA_SignDigestWithSeed(ECPrivateKey *key, - SECItem *signature, - const SECItem *digest, - const unsigned char *seed, - const int seedlen); - -/******************************************/ -/* -** RC4 symmetric stream cypher -*/ - -/* -** 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(const unsigned char *key, int len); - -extern RC4Context *RC4_AllocateContext(void); -extern SECStatus RC4_InitContext(RC4Context *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *, - int, - unsigned int , - unsigned int ); - -/* -** Destroy an RC4 encryption/decryption context. -** "cx" the context -** "freeit" if PR_TRUE then free the object as well as its sub-objects -*/ -extern void 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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int 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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - -/******************************************/ -/* -** RC2 symmetric block cypher -*/ - -/* -** 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(const unsigned char *key, unsigned int len, - const unsigned char *iv, int mode, - unsigned effectiveKeyLen); -extern RC2Context *RC2_AllocateContext(void); -extern SECStatus RC2_InitContext(RC2Context *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *iv, - int mode, - unsigned int effectiveKeyLen, - unsigned int ); - -/* -** Destroy an RC2 encryption/decryption context. -** "cx" the context -** "freeit" if PR_TRUE then free the object as well as its sub-objects -*/ -extern void 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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int 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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - -/******************************************/ -/* -** 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, - unsigned int wordSize, const unsigned char *iv, int mode); -extern RC5Context *RC5_AllocateContext(void); -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); - -/* -** 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, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int 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 -*/ - -extern SECStatus RC5_Decrypt(RC5Context *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - - -/******************************************/ -/* -** 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(const unsigned char *key, - const unsigned char *iv, - int mode, PRBool encrypt); -extern DESContext *DES_AllocateContext(void); -extern SECStatus DES_InitContext(DESContext *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *iv, - int mode, - unsigned int encrypt, - unsigned int ); - -/* -** Destroy an DES encryption/decryption context. -** "cx" the context -** "freeit" if PR_TRUE then free the object as well as its sub-objects -*/ -extern void 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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - -/* -** Perform DES decryption. -** "cx" the context -** "output" the output buffer to store the decrypted data. -** "outputLen" how much data is stored in "output". Set by the routine -** after some data is stored in output. -** "maxOutputLen" the maximum amount of data that can ever be -** stored in "output" -** "input" the input data -** "inputLen" the amount of input data -** -** NOTE: the inputLen must be a multiple of DES_KEY_LENGTH -*/ -extern SECStatus DES_Decrypt(DESContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - -/******************************************/ -/* -** SEED symmetric block cypher -*/ -extern SEEDContext * -SEED_CreateContext(const unsigned char *key, const unsigned char *iv, - int mode, PRBool encrypt); -extern SEEDContext *SEED_AllocateContext(void); -extern SECStatus SEED_InitContext(SEEDContext *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *iv, - int mode, unsigned int encrypt, - unsigned int ); -extern void SEED_DestroyContext(SEEDContext *cx, PRBool freeit); -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, - const unsigned char *input, unsigned int inputLen); - -/******************************************/ -/* -** AES symmetric block cypher (Rijndael) -*/ - -/* -** 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 (16, 24, or 32) -** XXX currently only blocksize==16 has been tested! -*/ -extern AESContext * -AES_CreateContext(const unsigned char *key, const unsigned char *iv, - int mode, int encrypt, - unsigned int keylen, unsigned int blocklen); -extern AESContext *AES_AllocateContext(void); -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); - -/* -** Destroy a AES encryption/decryption context. -** "cx" the context -** "freeit" if PR_TRUE then free the object as well as its sub-objects -*/ -extern void -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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int 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, 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. -** "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(const unsigned char *key, const unsigned char *iv, - int encrypt, unsigned int keylen); -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 ); - -/* -** Destroy a AES KeyWrap context. -** "cx" the context -** "freeit" if PR_TRUE then free the object as well as its sub-objects -*/ -extern void -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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int 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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - /******************************************/ -/* -** Camellia symmetric block cypher -*/ - -/* -** 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(const unsigned char *key, const unsigned char *iv, - int mode, int encrypt, unsigned int keylen); - -extern CamelliaContext *Camellia_AllocateContext(void); -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); -/* -** Destroy a Camellia encryption/decryption context. -** "cx" the context -** "freeit" if PR_TRUE then free the object as well as its sub-objects -*/ -extern void -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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int 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, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - -/******************************************/ -/* -** MD5 secure hash function -*/ - -/* -** Hash a null terminated string "src" into "dest" using MD5 -*/ -extern SECStatus MD5_Hash(unsigned char *dest, const char *src); - -/* -** Hash a non-null terminated string "src" into "dest" using MD5 -*/ -extern SECStatus MD5_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length); - -/* -** Create a new MD5 context -*/ -extern MD5Context *MD5_NewContext(void); - - -/* -** Destroy an MD5 secure hash context. -** "cx" the context -** "freeit" if PR_TRUE then free the object as well as its sub-objects -*/ -extern void MD5_DestroyContext(MD5Context *cx, PRBool freeit); - -/* -** Reset an MD5 context, preparing it for a fresh round of hashing -*/ -extern void MD5_Begin(MD5Context *cx); - -/* -** Update the MD5 hash function with more data. -** "cx" the context -** "input" the data to hash -** "inputLen" the amount of data to hash -*/ -extern void MD5_Update(MD5Context *cx, - const unsigned char *input, unsigned int inputLen); - -/* -** Finish the MD5 hash function. Produce the digested results in "digest" -** "cx" the context -** "digest" where the 16 bytes of digest data are stored -** "digestLen" where the digest length (16) is stored -** "maxDigestLen" the maximum amount of data that can ever be -** stored in "digest" -*/ -extern void MD5_End(MD5Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); - -/* - * Return the the size of a buffer needed to flatten the MD5 Context into - * "cx" the context - * returns size; - */ -extern unsigned int MD5_FlattenSize(MD5Context *cx); - -/* - * Flatten the MD5 Context into a buffer: - * "cx" the context - * "space" the buffer to flatten to - * returns status; - */ -extern SECStatus MD5_Flatten(MD5Context *cx,unsigned char *space); - -/* - * Resurrect a flattened context into a MD5 Context - * "space" the buffer of the flattend buffer - * "arg" ptr to void used by cryptographic resurrect - * returns resurected context; - */ -extern MD5Context * MD5_Resurrect(unsigned char *space, void *arg); -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. -** "cx" the context -** "freeit" if PR_TRUE then free the object as well as its sub-objects -*/ -extern void MD2_DestroyContext(MD2Context *cx, PRBool freeit); - -/* -** Reset an MD2 context, preparing it for a fresh round of hashing -*/ -extern void MD2_Begin(MD2Context *cx); - -/* -** Update the MD2 hash function with more data. -** "cx" the context -** "input" the data to hash -** "inputLen" the amount of data to hash -*/ -extern void MD2_Update(MD2Context *cx, - const unsigned char *input, unsigned int inputLen); - -/* -** Finish the MD2 hash function. Produce the digested results in "digest" -** "cx" the context -** "digest" where the 16 bytes of digest data are stored -** "digestLen" where the digest length (16) is stored -** "maxDigestLen" the maximum amount of data that can ever be -** stored in "digest" -*/ -extern void MD2_End(MD2Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); - -/* - * Return the the size of a buffer needed to flatten the MD2 Context into - * "cx" the context - * returns size; - */ -extern unsigned int MD2_FlattenSize(MD2Context *cx); - -/* - * Flatten the MD2 Context into a buffer: - * "cx" the context - * "space" the buffer to flatten to - * returns status; - */ -extern SECStatus MD2_Flatten(MD2Context *cx,unsigned char *space); - -/* - * Resurrect a flattened context into a MD2 Context - * "space" the buffer of the flattend buffer - * "arg" ptr to void used by cryptographic resurrect - * returns resurected context; - */ -extern MD2Context * MD2_Resurrect(unsigned char *space, void *arg); -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, - uint32 src_length); - -/* -** Create a new SHA-1 context -*/ -extern SHA1Context *SHA1_NewContext(void); - - -/* -** Destroy a SHA-1 secure hash context. -** "cx" the context -** "freeit" if PR_TRUE then free the object as well as its sub-objects -*/ -extern void SHA1_DestroyContext(SHA1Context *cx, PRBool freeit); - -/* -** Reset a SHA-1 context, preparing it for a fresh round of hashing -*/ -extern void SHA1_Begin(SHA1Context *cx); - -/* -** Update the SHA-1 hash function with more data. -** "cx" the context -** "input" the data to hash -** "inputLen" the amount of data to hash -*/ -extern void SHA1_Update(SHA1Context *cx, const unsigned char *input, - unsigned int inputLen); - -/* -** Finish the SHA-1 hash function. Produce the digested results in "digest" -** "cx" the context -** "digest" where the 16 bytes of digest data are stored -** "digestLen" where the digest length (20) is stored -** "maxDigestLen" the maximum amount of data that can ever be -** stored in "digest" -*/ -extern void SHA1_End(SHA1Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); - -/* -** trace the intermediate state info of the SHA1 hash. -*/ -extern void SHA1_TraceState(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; - */ -extern SECStatus SHA1_Flatten(SHA1Context *cx,unsigned char *space); - -/* - * Resurrect a flattened context into a SHA-1 Context - * "space" the buffer of the flattend buffer - * "arg" ptr to void used by cryptographic resurrect - * returns resurected context; - */ -extern SHA1Context * SHA1_Resurrect(unsigned char *space, void *arg); -extern void SHA1_Clone(SHA1Context *dest, SHA1Context *src); - -/******************************************/ - -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, - unsigned int inputLen); -extern void SHA256_End(SHA256Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); -extern SECStatus SHA256_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length); -extern SECStatus SHA256_Hash(unsigned char *dest, const char *src); -extern void SHA256_TraceState(SHA256Context *cx); -extern unsigned int SHA256_FlattenSize(SHA256Context *cx); -extern SECStatus SHA256_Flatten(SHA256Context *cx,unsigned char *space); -extern SHA256Context * SHA256_Resurrect(unsigned char *space, void *arg); -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, - unsigned int inputLen); -extern void SHA512_End(SHA512Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); -extern SECStatus SHA512_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length); -extern SECStatus SHA512_Hash(unsigned char *dest, const char *src); -extern void SHA512_TraceState(SHA512Context *cx); -extern unsigned int SHA512_FlattenSize(SHA512Context *cx); -extern SECStatus SHA512_Flatten(SHA512Context *cx,unsigned char *space); -extern SHA512Context * SHA512_Resurrect(unsigned char *space, void *arg); -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, - unsigned int inputLen); -extern void SHA384_End(SHA384Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); -extern SECStatus SHA384_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length); -extern SECStatus SHA384_Hash(unsigned char *dest, const char *src); -extern void SHA384_TraceState(SHA384Context *cx); -extern unsigned int SHA384_FlattenSize(SHA384Context *cx); -extern SECStatus SHA384_Flatten(SHA384Context *cx,unsigned char *space); -extern SHA384Context * SHA384_Resurrect(unsigned char *space, void *arg); -extern void SHA384_Clone(SHA384Context *dest, SHA384Context *src); - -/**************************************** - * implement TLS Pseudo Random Function (PRF) - */ - -extern SECStatus -TLS_PRF(const SECItem *secret, const char *label, SECItem *seed, - SECItem *result, PRBool isFIPS); - -/******************************************/ -/* -** 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()). -*/ -extern void RNG_RNGShutdown(void); - -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. - */ - -/* - * FIPS186Change_GenerateX is now deprecated. It will return SECFailure with - * the error set to PR_NOT_IMPLEMENTED_ERROR. - */ -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); - -/* - * The following functions are for FIPS poweron self test and FIPS algorithm - * testing. - */ -extern SECStatus -PRNGTEST_Instantiate(const PRUint8 *entropy, unsigned int entropy_len, - const PRUint8 *nonce, unsigned int nonce_len, - const PRUint8 *personal_string, unsigned int ps_len); - -extern SECStatus -PRNGTEST_Reseed(const PRUint8 *entropy, unsigned int entropy_len, - const PRUint8 *additional, unsigned int additional_len); - -extern SECStatus -PRNGTEST_Generate(PRUint8 *bytes, unsigned int bytes_len, - const PRUint8 *additional, unsigned int additional_len); - -extern SECStatus -PRNGTEST_Uninstantiate(void); - - -/* Generate PQGParams and PQGVerify structs. - * Length of seed and length of h both equal length of P. - * All lengths are specified by "j", according to the table above. - */ -extern SECStatus -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. */ - -/* Generate PQGParams and PQGVerify structs. - * Length of P specified by j. Length of h will match length of P. - * Length of SEED in bytes specified in seedBytes. - * seedBbytes must be in the range [20..255] or an error will result. - */ -extern SECStatus -PQG_ParamGenSeedLen( - unsigned int j, /* input : determines length of P. */ - unsigned int seedBytes, /* input : length of seed in bytes.*/ - PQGParams **pParams, /* output: P Q and G returned here */ - PQGVerify **pVfy); /* output: counter and seed. */ - - -/* Test PQGParams for validity as DSS PQG values. - * If vfy is non-NULL, test PQGParams to make sure they were generated - * using the specified seed, counter, and h values. - * - * Return value indicates whether Verification operation ran successfully - * to completion, but does not indicate if PQGParams are valid or not. - * If return value is SECSuccess, then *pResult has these meanings: - * SECSuccess: PQGParams are valid. - * SECFailure: PQGParams are invalid. - * - * Verify the following 12 facts about PQG counter SEED g and h - * 1. Q is 160 bits long. - * 2. P is one of the 9 valid lengths. - * 3. G < P - * 4. P % Q == 1 - * 5. Q is prime - * 6. P is prime - * Steps 7-12 are done only if the optional PQGVerify is supplied. - * 7. counter < 4096 - * 8. g >= 160 and g < 2048 (g is length of seed in bits) - * 9. Q generated from SEED matches Q in PQGParams. - * 10. P generated from (L, counter, g, SEED, Q) matches P in PQGParams. - * 11. 1 < h < P-1 - * 12. G generated from h matches G in PQGParams. - */ - -extern SECStatus PQG_VerifyParams(const PQGParams *params, - const PQGVerify *vfy, SECStatus *result); - -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); - -/************************************************************************** - * Verify Are Own Shared library signature * - **************************************************************************/ -PRBool BLAPI_VerifySelf(const char *name); - -/*********************************************************************/ -extern const SECHashObject * HASH_GetRawHashObject(HASH_HashType hashType); - -extern void BL_SetForkState(PRBool forked); - -SEC_END_PROTOS - -#endif /* _BLAPI_H_ */ diff --git a/net/third_party/nss/ssl/bodge/genload.c b/net/third_party/nss/ssl/bodge/genload.c deleted file mode 100644 index fac6e22..0000000 --- a/net/third_party/nss/ssl/bodge/genload.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape security libraries. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories - * Kai Engert <kengert@redhat.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * This file is meant to be included by other .c files. - * This file takes a "parameter", the scope which includes this - * code shall declare this variable: - * const char *NameOfThisSharedLib; - * - * NameOfThisSharedLib: - * The file name of the shared library that shall be used as the - * "reference library". The loader will attempt to load the requested - * library from the same directory as the reference library. - */ - -#ifdef XP_UNIX -#include <unistd.h> -#define BL_MAXSYMLINKS 20 - -/* - * If 'link' is a symbolic link, this function follows the symbolic links - * and returns the pathname of the ultimate source of the symbolic links. - * If 'link' is not a symbolic link, this function returns NULL. - * The caller should call PR_Free to free the string returned by this - * function. - */ -static char* loader_GetOriginalPathname(const char* link) -{ - char* resolved = NULL; - char* input = NULL; - PRUint32 iterations = 0; - PRInt32 len = 0, retlen = 0; - if (!link) { - PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); - return NULL; - } - len = PR_MAX(1024, strlen(link) + 1); - resolved = PR_Malloc(len); - input = PR_Malloc(len); - if (!resolved || !input) { - if (resolved) { - PR_Free(resolved); - } - if (input) { - PR_Free(input); - } - return NULL; - } - strcpy(input, link); - while ( (iterations++ < BL_MAXSYMLINKS) && - ( (retlen = readlink(input, resolved, len - 1)) > 0) ) { - char* tmp = input; - resolved[retlen] = '\0'; /* NULL termination */ - input = resolved; - resolved = tmp; - } - PR_Free(resolved); - if (iterations == 1 && retlen < 0) { - PR_Free(input); - input = NULL; - } - return input; -} -#endif /* XP_UNIX */ - -/* - * Load the library with the file name 'name' residing in the same - * directory as the reference library, whose pathname is 'referencePath'. - */ -static PRLibrary * -loader_LoadLibInReferenceDir(const char *referencePath, const char *name) -{ - PRLibrary *dlh = NULL; - char *fullName = NULL; - char* c; - PRLibSpec libSpec; - - /* Remove the trailing filename from referencePath and add the new one */ - c = strrchr(referencePath, PR_GetDirectorySeparator()); - if (c) { - size_t referencePathSize = 1 + c - referencePath; - fullName = (char*) PORT_Alloc(strlen(name) + referencePathSize + 1); - if (fullName) { - memcpy(fullName, referencePath, referencePathSize); - strcpy(fullName + referencePathSize, name); -#ifdef DEBUG_LOADER - PR_fprintf(PR_STDOUT, "\nAttempting to load fully-qualified %s\n", - fullName); -#endif - libSpec.type = PR_LibSpec_Pathname; - libSpec.value.pathname = fullName; - dlh = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL); - PORT_Free(fullName); - } - } - return dlh; -} - -/* - * We use PR_GetLibraryFilePathname to get the pathname of the loaded - * shared lib that contains this function, and then do a PR_LoadLibrary - * with an absolute pathname for the softoken shared library. - */ - -static PRLibrary * -loader_LoadLibrary(const char *nameToLoad) -{ - PRLibrary *lib = NULL; - char* fullPath = NULL; - PRLibSpec libSpec; - - /* Get the pathname for nameOfAlreadyLoadedLib, i.e. /usr/lib/libnss3.so - * PR_GetLibraryFilePathname works with either the base library name or a - * function pointer, depending on the platform. We can't query an exported - * symbol such as NSC_GetFunctionList, because on some platforms we can't - * find symbols in loaded implicit dependencies. - * But we can just get the address of this function ! - */ - fullPath = PR_GetLibraryFilePathname(NameOfThisSharedLib, - (PRFuncPtr)&loader_LoadLibrary); - - if (fullPath) { - lib = loader_LoadLibInReferenceDir(fullPath, nameToLoad); -#ifdef XP_UNIX - if (!lib) { - /* - * If fullPath is a symbolic link, resolve the symbolic - * link and try again. - */ - char* originalfullPath = loader_GetOriginalPathname(fullPath); - if (originalfullPath) { - PR_Free(fullPath); - fullPath = originalfullPath; - lib = loader_LoadLibInReferenceDir(fullPath, nameToLoad); - } - } -#endif - PR_Free(fullPath); - } - if (!lib) { -#ifdef DEBUG_LOADER - PR_fprintf(PR_STDOUT, "\nAttempting to load %s\n", nameToLoad); -#endif - libSpec.type = PR_LibSpec_Pathname; - libSpec.value.pathname = nameToLoad; - lib = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW | PR_LD_LOCAL); - } - if (NULL == lib) { -#ifdef DEBUG_LOADER - PR_fprintf(PR_STDOUT, "\nLoading failed : %s.\n", nameToLoad); -#endif - } - return lib; -} - diff --git a/net/third_party/nss/ssl/bodge/loader.c b/net/third_party/nss/ssl/bodge/loader.c deleted file mode 100644 index 0e63044..0000000 --- a/net/third_party/nss/ssl/bodge/loader.c +++ /dev/null @@ -1,1699 +0,0 @@ -/* - * loader.c - load platform dependent DSO containing freebl implementation. - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape security libraries. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* $Id: loader.c,v 1.44 2009/03/29 03:45:32 wtc%google.com Exp $ */ - -#include "loader.h" -#include "prmem.h" -#include "prerror.h" -#include "prinit.h" -#include "prenv.h" - -static const char* default_name = - SHLIB_PREFIX"freebl"SHLIB_VERSION"."SHLIB_SUFFIX; - -/* getLibName() returns the name of the library to load. */ - -#if defined(SOLARIS) && defined(__sparc) -#include <stddef.h> -#include <strings.h> -#include <sys/systeminfo.h> - - -#if defined(NSS_USE_64) - -const static char fpu_hybrid_shared_lib[] = "libfreebl_64fpu_3.so"; -const static char int_hybrid_shared_lib[] = "libfreebl_64int_3.so"; -const static char non_hybrid_shared_lib[] = "libfreebl_64fpu_3.so"; - -const static char int_hybrid_isa[] = "sparcv9"; -const static char fpu_hybrid_isa[] = "sparcv9+vis"; - -#else - -const static char fpu_hybrid_shared_lib[] = "libfreebl_32fpu_3.so"; -const static char int_hybrid_shared_lib[] = "libfreebl_32int64_3.so"; -const static char non_hybrid_shared_lib[] = "libfreebl_32int_3.so"; - -const static char int_hybrid_isa[] = "sparcv8plus"; -const static char fpu_hybrid_isa[] = "sparcv8plus+vis"; - -#endif - -static const char * -getLibName(void) -{ - char * found_int_hybrid; - char * found_fpu_hybrid; - long buflen; - char buf[256]; - - buflen = sysinfo(SI_ISALIST, buf, sizeof buf); - if (buflen <= 0) - return NULL; - /* sysinfo output is always supposed to be NUL terminated, but ... */ - if (buflen < sizeof buf) - buf[buflen] = '\0'; - else - buf[(sizeof buf) - 1] = '\0'; - /* The ISA list is a space separated string of names of ISAs and - * ISA extensions, in order of decreasing performance. - * There are two different ISAs with which NSS's crypto code can be - * accelerated. If both are in the list, we take the first one. - * If one is in the list, we use it, and if neither then we use - * the base unaccelerated code. - */ - found_int_hybrid = strstr(buf, int_hybrid_isa); - found_fpu_hybrid = strstr(buf, fpu_hybrid_isa); - if (found_fpu_hybrid && - (!found_int_hybrid || - (found_int_hybrid - found_fpu_hybrid) >= 0)) { - return fpu_hybrid_shared_lib; - } - if (found_int_hybrid) { - return int_hybrid_shared_lib; - } - return non_hybrid_shared_lib; -} - -#elif defined(HPUX) && !defined(NSS_USE_64) && !defined(__ia64) -/* This code tests to see if we're running on a PA2.x CPU. -** It returns true (1) if so, and false (0) otherwise. -*/ -static const char * -getLibName(void) -{ - long cpu = sysconf(_SC_CPU_VERSION); - return (cpu == CPU_PA_RISC2_0) - ? "libfreebl_32fpu_3.sl" - : "libfreebl_32int32_3.sl" ; -} -#else -/* default case, for platforms/ABIs that have only one freebl shared lib. */ -static const char * getLibName(void) { return default_name; } -#endif - -#include "prio.h" -#include "prprf.h" -#include <stdio.h> -#include "prsystem.h" - -static const char *NameOfThisSharedLib = - SHLIB_PREFIX"softokn"SOFTOKEN_SHLIB_VERSION"."SHLIB_SUFFIX; - -static PRLibrary* blLib; - -#define LSB(x) ((x)&0xff) -#define MSB(x) ((x)>>8) - -static const FREEBLVector *vector; -static const char *libraryName = NULL; - -#include "genload.c" - -/* This function must be run only once. */ -/* determine if hybrid platform, then actually load the DSO. */ -static PRStatus -freebl_LoadDSO( void ) -{ - PRLibrary * handle; - const char * name = getLibName(); - - if (!name) { - PR_SetError(PR_LOAD_LIBRARY_ERROR, 0); - return PR_FAILURE; - } - - handle = loader_LoadLibrary(name); - if (handle) { - PRFuncPtr address = PR_FindFunctionSymbol(handle, "FREEBL_GetVector"); - PRStatus status; - if (address) { - FREEBLGetVectorFn * getVector = (FREEBLGetVectorFn *)address; - const FREEBLVector * dsoVector = getVector(); - if (dsoVector) { - unsigned short dsoVersion = dsoVector->version; - unsigned short myVersion = FREEBL_VERSION; - if (MSB(dsoVersion) == MSB(myVersion) && - LSB(dsoVersion) >= LSB(myVersion) && - dsoVector->length >= sizeof(FREEBLVector)) { - vector = dsoVector; - libraryName = name; - blLib = handle; - return PR_SUCCESS; - } - } - } - status = PR_UnloadLibrary(handle); - PORT_Assert(PR_SUCCESS == status); - } - return PR_FAILURE; -} - -static const PRCallOnceType pristineCallOnce; -static PRCallOnceType loadFreeBLOnce; - -static PRStatus -freebl_RunLoaderOnce( void ) -{ - PRStatus status; - - status = PR_CallOnce(&loadFreeBLOnce, &freebl_LoadDSO); - return status; -} - -SECStatus -BL_Init(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_BL_Init)(); -} - -RSAPrivateKey * -RSA_NewKey(int keySizeInBits, SECItem * publicExponent) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_RSA_NewKey)(keySizeInBits, publicExponent); -} - -SECStatus -RSA_PublicKeyOp(RSAPublicKey * key, - unsigned char * output, - const unsigned char * input) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RSA_PublicKeyOp)(key, output, input); -} - -SECStatus -RSA_PrivateKeyOp(RSAPrivateKey * key, - unsigned char * output, - const unsigned char * input) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RSA_PrivateKeyOp)(key, output, input); -} - -SECStatus -RSA_PrivateKeyOpDoubleChecked(RSAPrivateKey *key, - unsigned char *output, - const unsigned char *input) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RSA_PrivateKeyOpDoubleChecked)(key, output, input); -} - -SECStatus -RSA_PrivateKeyCheck(RSAPrivateKey *key) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RSA_PrivateKeyCheck)(key); -} - -SECStatus -DSA_NewKey(const PQGParams * params, DSAPrivateKey ** privKey) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DSA_NewKey)(params, privKey); -} - -SECStatus -DSA_SignDigest(DSAPrivateKey * key, SECItem * signature, const SECItem * digest) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DSA_SignDigest)( key, signature, digest); -} - -SECStatus -DSA_VerifyDigest(DSAPublicKey * key, const SECItem * signature, - const SECItem * digest) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DSA_VerifyDigest)( key, signature, digest); -} - -SECStatus -DSA_NewKeyFromSeed(const PQGParams *params, const unsigned char * seed, - DSAPrivateKey **privKey) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DSA_NewKeyFromSeed)(params, seed, privKey); -} - -SECStatus -DSA_SignDigestWithSeed(DSAPrivateKey * key, SECItem * signature, - const SECItem * digest, const unsigned char * seed) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DSA_SignDigestWithSeed)( key, signature, digest, seed); -} - -SECStatus -DH_GenParam(int primeLen, DHParams ** params) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DH_GenParam)(primeLen, params); -} - -SECStatus -DH_NewKey(DHParams * params, DHPrivateKey ** privKey) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DH_NewKey)( params, privKey); -} - -SECStatus -DH_Derive(SECItem * publicValue, SECItem * prime, SECItem * privateValue, - SECItem * derivedSecret, unsigned int maxOutBytes) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DH_Derive)( publicValue, prime, privateValue, - derivedSecret, maxOutBytes); -} - -SECStatus -KEA_Derive(SECItem *prime, SECItem *public1, SECItem *public2, - SECItem *private1, SECItem *private2, SECItem *derivedSecret) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_KEA_Derive)(prime, public1, public2, - private1, private2, derivedSecret); -} - -PRBool -KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return PR_FALSE; - return (vector->p_KEA_Verify)(Y, prime, subPrime); -} - -RC4Context * -RC4_CreateContext(const unsigned char *key, int len) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_RC4_CreateContext)(key, len); -} - -void -RC4_DestroyContext(RC4Context *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_RC4_DestroyContext)(cx, freeit); -} - -SECStatus -RC4_Encrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RC4_Encrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} - -SECStatus -RC4_Decrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RC4_Decrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} - -RC2Context * -RC2_CreateContext(const unsigned char *key, unsigned int len, - const unsigned char *iv, int mode, unsigned effectiveKeyLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_RC2_CreateContext)(key, len, iv, mode, effectiveKeyLen); -} - -void -RC2_DestroyContext(RC2Context *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_RC2_DestroyContext)(cx, freeit); -} - -SECStatus -RC2_Encrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RC2_Encrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} - -SECStatus -RC2_Decrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RC2_Decrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} - -RC5Context * -RC5_CreateContext(const SECItem *key, unsigned int rounds, - unsigned int wordSize, const unsigned char *iv, int mode) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_RC5_CreateContext)(key, rounds, wordSize, iv, mode); -} - -void -RC5_DestroyContext(RC5Context *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_RC5_DestroyContext)(cx, freeit); -} - -SECStatus -RC5_Encrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RC5_Encrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} - -SECStatus -RC5_Decrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RC5_Decrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} - -DESContext * -DES_CreateContext(const unsigned char *key, const unsigned char *iv, - int mode, PRBool encrypt) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_DES_CreateContext)(key, iv, mode, encrypt); -} - -void -DES_DestroyContext(DESContext *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_DES_DestroyContext)(cx, freeit); -} - -SECStatus -DES_Encrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DES_Encrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} - -SECStatus -DES_Decrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DES_Decrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} -SEEDContext * -SEED_CreateContext(const unsigned char *key, const unsigned char *iv, - int mode, PRBool encrypt) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_SEED_CreateContext)(key, iv, mode, encrypt); -} - -void -SEED_DestroyContext(SEEDContext *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_SEED_DestroyContext)(cx, freeit); -} - -SECStatus -SEED_Encrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SEED_Encrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} - -SECStatus -SEED_Decrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, - unsigned int maxOutputLen, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SEED_Decrypt)(cx, output, outputLen, maxOutputLen, input, - inputLen); -} - -AESContext * -AES_CreateContext(const unsigned char *key, const unsigned char *iv, - int mode, int encrypt, - unsigned int keylen, unsigned int blocklen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_AES_CreateContext)(key, iv, mode, encrypt, keylen, - blocklen); -} - -void -AES_DestroyContext(AESContext *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_AES_DestroyContext)(cx, freeit); -} - -SECStatus -AES_Encrypt(AESContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_AES_Encrypt)(cx, output, outputLen, maxOutputLen, - input, inputLen); -} - -SECStatus -AES_Decrypt(AESContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_AES_Decrypt)(cx, output, outputLen, maxOutputLen, - input, inputLen); -} - -SECStatus -MD5_Hash(unsigned char *dest, const char *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_MD5_Hash)(dest, src); -} - -SECStatus -MD5_HashBuf(unsigned char *dest, const unsigned char *src, uint32 src_length) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_MD5_HashBuf)(dest, src, src_length); -} - -MD5Context * -MD5_NewContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_MD5_NewContext)(); -} - -void -MD5_DestroyContext(MD5Context *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_MD5_DestroyContext)(cx, freeit); -} - -void -MD5_Begin(MD5Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_MD5_Begin)(cx); -} - -void -MD5_Update(MD5Context *cx, const unsigned char *input, unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_MD5_Update)(cx, input, inputLen); -} - -void -MD5_End(MD5Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_MD5_End)(cx, digest, digestLen, maxDigestLen); -} - -unsigned int -MD5_FlattenSize(MD5Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return 0; - return (vector->p_MD5_FlattenSize)(cx); -} - -SECStatus -MD5_Flatten(MD5Context *cx,unsigned char *space) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_MD5_Flatten)(cx, space); -} - -MD5Context * -MD5_Resurrect(unsigned char *space, void *arg) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_MD5_Resurrect)(space, arg); -} - -void -MD5_TraceState(MD5Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_MD5_TraceState)(cx); -} - -SECStatus -MD2_Hash(unsigned char *dest, const char *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_MD2_Hash)(dest, src); -} - -MD2Context * -MD2_NewContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_MD2_NewContext)(); -} - -void -MD2_DestroyContext(MD2Context *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_MD2_DestroyContext)(cx, freeit); -} - -void -MD2_Begin(MD2Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_MD2_Begin)(cx); -} - -void -MD2_Update(MD2Context *cx, const unsigned char *input, unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_MD2_Update)(cx, input, inputLen); -} - -void -MD2_End(MD2Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_MD2_End)(cx, digest, digestLen, maxDigestLen); -} - -unsigned int -MD2_FlattenSize(MD2Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return 0; - return (vector->p_MD2_FlattenSize)(cx); -} - -SECStatus -MD2_Flatten(MD2Context *cx,unsigned char *space) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_MD2_Flatten)(cx, space); -} - -MD2Context * -MD2_Resurrect(unsigned char *space, void *arg) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_MD2_Resurrect)(space, arg); -} - - -SECStatus -SHA1_Hash(unsigned char *dest, const char *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA1_Hash)(dest, src); -} - -SECStatus -SHA1_HashBuf(unsigned char *dest, const unsigned char *src, uint32 src_length) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA1_HashBuf)(dest, src, src_length); -} - -SHA1Context * -SHA1_NewContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_SHA1_NewContext)(); -} - -void -SHA1_DestroyContext(SHA1Context *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA1_DestroyContext)(cx, freeit); -} - -void -SHA1_Begin(SHA1Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA1_Begin)(cx); -} - -void -SHA1_Update(SHA1Context *cx, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA1_Update)(cx, input, inputLen); -} - -void -SHA1_End(SHA1Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA1_End)(cx, digest, digestLen, maxDigestLen); -} - -void -SHA1_TraceState(SHA1Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA1_TraceState)(cx); -} - -unsigned int -SHA1_FlattenSize(SHA1Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return 0; - return (vector->p_SHA1_FlattenSize)(cx); -} - -SECStatus -SHA1_Flatten(SHA1Context *cx,unsigned char *space) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA1_Flatten)(cx, space); -} - -SHA1Context * -SHA1_Resurrect(unsigned char *space, void *arg) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_SHA1_Resurrect)(space, arg); -} - -SECStatus -RNG_RNGInit(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RNG_RNGInit)(); -} - -SECStatus -RNG_RandomUpdate(const void *data, size_t bytes) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RNG_RandomUpdate)(data, bytes); -} - -SECStatus -RNG_GenerateGlobalRandomBytes(void *dest, size_t len) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RNG_GenerateGlobalRandomBytes)(dest, len); -} - -void -RNG_RNGShutdown(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_RNG_RNGShutdown)(); -} - -SECStatus -PQG_ParamGen(unsigned int j, PQGParams **pParams, PQGVerify **pVfy) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_PQG_ParamGen)(j, pParams, pVfy); -} - -SECStatus -PQG_ParamGenSeedLen( unsigned int j, unsigned int seedBytes, - PQGParams **pParams, PQGVerify **pVfy) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_PQG_ParamGenSeedLen)(j, seedBytes, pParams, pVfy); -} - -SECStatus -PQG_VerifyParams(const PQGParams *params, const PQGVerify *vfy, - SECStatus *result) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_PQG_VerifyParams)(params, vfy, result); -} - -void -PQG_DestroyParams(PQGParams *params) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_PQG_DestroyParams)(params); -} - -void -PQG_DestroyVerify(PQGVerify *vfy) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_PQG_DestroyVerify)(vfy); -} - -void -BL_Cleanup(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_BL_Cleanup)(); -} - -void -BL_Unload(void) -{ - /* This function is not thread-safe, but doesn't need to be, because it is - * only called from functions that are also defined as not thread-safe, - * namely C_Finalize in softoken, and the SSL bypass shutdown callback called - * from NSS_Shutdown. */ - char *disableUnload = NULL; - vector = NULL; - /* If an SSL socket is configured with SSL_BYPASS_PKCS11, but the application - * never does a handshake on it, BL_Unload will be called even though freebl - * was never loaded. So, don't assert blLib. */ - if (blLib) { - disableUnload = PR_GetEnv("NSS_DISABLE_UNLOAD"); - if (!disableUnload) { - PRStatus status = PR_UnloadLibrary(blLib); - PORT_Assert(PR_SUCCESS == status); - } - blLib = NULL; - } - loadFreeBLOnce = pristineCallOnce; -} - -/* ============== New for 3.003 =============================== */ - -SECStatus -SHA256_Hash(unsigned char *dest, const char *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA256_Hash)(dest, src); -} - -SECStatus -SHA256_HashBuf(unsigned char *dest, const unsigned char *src, uint32 src_length) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA256_HashBuf)(dest, src, src_length); -} - -SHA256Context * -SHA256_NewContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_SHA256_NewContext)(); -} - -void -SHA256_DestroyContext(SHA256Context *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA256_DestroyContext)(cx, freeit); -} - -void -SHA256_Begin(SHA256Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA256_Begin)(cx); -} - -void -SHA256_Update(SHA256Context *cx, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA256_Update)(cx, input, inputLen); -} - -void -SHA256_End(SHA256Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA256_End)(cx, digest, digestLen, maxDigestLen); -} - -void -SHA256_TraceState(SHA256Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA256_TraceState)(cx); -} - -unsigned int -SHA256_FlattenSize(SHA256Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return 0; - return (vector->p_SHA256_FlattenSize)(cx); -} - -SECStatus -SHA256_Flatten(SHA256Context *cx,unsigned char *space) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA256_Flatten)(cx, space); -} - -SHA256Context * -SHA256_Resurrect(unsigned char *space, void *arg) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_SHA256_Resurrect)(space, arg); -} - -SECStatus -SHA512_Hash(unsigned char *dest, const char *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA512_Hash)(dest, src); -} - -SECStatus -SHA512_HashBuf(unsigned char *dest, const unsigned char *src, uint32 src_length) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA512_HashBuf)(dest, src, src_length); -} - -SHA512Context * -SHA512_NewContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_SHA512_NewContext)(); -} - -void -SHA512_DestroyContext(SHA512Context *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA512_DestroyContext)(cx, freeit); -} - -void -SHA512_Begin(SHA512Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA512_Begin)(cx); -} - -void -SHA512_Update(SHA512Context *cx, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA512_Update)(cx, input, inputLen); -} - -void -SHA512_End(SHA512Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA512_End)(cx, digest, digestLen, maxDigestLen); -} - -void -SHA512_TraceState(SHA512Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA512_TraceState)(cx); -} - -unsigned int -SHA512_FlattenSize(SHA512Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return 0; - return (vector->p_SHA512_FlattenSize)(cx); -} - -SECStatus -SHA512_Flatten(SHA512Context *cx,unsigned char *space) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA512_Flatten)(cx, space); -} - -SHA512Context * -SHA512_Resurrect(unsigned char *space, void *arg) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_SHA512_Resurrect)(space, arg); -} - - -SECStatus -SHA384_Hash(unsigned char *dest, const char *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA384_Hash)(dest, src); -} - -SECStatus -SHA384_HashBuf(unsigned char *dest, const unsigned char *src, uint32 src_length) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA384_HashBuf)(dest, src, src_length); -} - -SHA384Context * -SHA384_NewContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_SHA384_NewContext)(); -} - -void -SHA384_DestroyContext(SHA384Context *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA384_DestroyContext)(cx, freeit); -} - -void -SHA384_Begin(SHA384Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA384_Begin)(cx); -} - -void -SHA384_Update(SHA384Context *cx, const unsigned char *input, - unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA384_Update)(cx, input, inputLen); -} - -void -SHA384_End(SHA384Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA384_End)(cx, digest, digestLen, maxDigestLen); -} - -void -SHA384_TraceState(SHA384Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_SHA384_TraceState)(cx); -} - -unsigned int -SHA384_FlattenSize(SHA384Context *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return 0; - return (vector->p_SHA384_FlattenSize)(cx); -} - -SECStatus -SHA384_Flatten(SHA384Context *cx,unsigned char *space) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SHA384_Flatten)(cx, space); -} - -SHA384Context * -SHA384_Resurrect(unsigned char *space, void *arg) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_SHA384_Resurrect)(space, arg); -} - - -AESKeyWrapContext * -AESKeyWrap_CreateContext(const unsigned char *key, const unsigned char *iv, - int encrypt, unsigned int keylen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return vector->p_AESKeyWrap_CreateContext(key, iv, encrypt, keylen); -} - -void -AESKeyWrap_DestroyContext(AESKeyWrapContext *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - vector->p_AESKeyWrap_DestroyContext(cx, freeit); -} - -SECStatus -AESKeyWrap_Encrypt(AESKeyWrapContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return vector->p_AESKeyWrap_Encrypt(cx, output, outputLen, maxOutputLen, - input, inputLen); -} -SECStatus -AESKeyWrap_Decrypt(AESKeyWrapContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return vector->p_AESKeyWrap_Decrypt(cx, output, outputLen, maxOutputLen, - input, inputLen); -} - -PRBool -BLAPI_SHVerify(const char *name, PRFuncPtr addr) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return PR_FALSE; - return vector->p_BLAPI_SHVerify(name, addr); -} - -/* - * The Caller is expected to pass NULL as the name, which will - * trigger the p_BLAPI_VerifySelf() to return 'TRUE'. If we really loaded - * from a shared library, BLAPI_VerifySelf will get pick up the real name - * from the static set in freebl_LoadDSO( void ) - */ -PRBool -BLAPI_VerifySelf(const char *name) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return PR_FALSE; - return vector->p_BLAPI_VerifySelf(libraryName); -} - -/* ============== New for 3.006 =============================== */ - -SECStatus -EC_NewKey(ECParams * params, ECPrivateKey ** privKey) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_EC_NewKey)( params, privKey ); -} - -SECStatus -EC_NewKeyFromSeed(ECParams * params, ECPrivateKey ** privKey, - const unsigned char *seed, int seedlen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_EC_NewKeyFromSeed)( params, privKey, seed, seedlen ); -} - -SECStatus -EC_ValidatePublicKey(ECParams * params, SECItem * publicValue) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_EC_ValidatePublicKey)( params, publicValue ); -} - -SECStatus -ECDH_Derive(SECItem * publicValue, ECParams * params, SECItem * privateValue, - PRBool withCofactor, SECItem * derivedSecret) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_ECDH_Derive)( publicValue, params, privateValue, - withCofactor, derivedSecret ); -} - -SECStatus -ECDSA_SignDigest(ECPrivateKey * key, SECItem * signature, - const SECItem * digest) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_ECDSA_SignDigest)( key, signature, digest ); -} - -SECStatus -ECDSA_VerifyDigest(ECPublicKey * key, const SECItem * signature, - const SECItem * digest) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_ECDSA_VerifyDigest)( key, signature, digest ); -} - -SECStatus -ECDSA_SignDigestWithSeed(ECPrivateKey * key, SECItem * signature, - const SECItem * digest, const unsigned char *seed, const int seedlen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_ECDSA_SignDigestWithSeed)( key, signature, digest, - seed, seedlen ); -} - -/* ============== New for 3.008 =============================== */ - -AESContext * -AES_AllocateContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_AES_AllocateContext)(); -} - -AESKeyWrapContext * -AESKeyWrap_AllocateContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_AESKeyWrap_AllocateContext)(); -} - -DESContext * -DES_AllocateContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_DES_AllocateContext)(); -} - -RC2Context * -RC2_AllocateContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_RC2_AllocateContext)(); -} - -RC4Context * -RC4_AllocateContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_RC4_AllocateContext)(); -} - -SECStatus -AES_InitContext(AESContext *cx, const unsigned char *key, - unsigned int keylen, const unsigned char *iv, int mode, - unsigned int encrypt, unsigned int blocklen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_AES_InitContext)(cx, key, keylen, iv, mode, encrypt, - blocklen); -} - -SECStatus -AESKeyWrap_InitContext(AESKeyWrapContext *cx, const unsigned char *key, - unsigned int keylen, const unsigned char *iv, int mode, - unsigned int encrypt, unsigned int blocklen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_AESKeyWrap_InitContext)(cx, key, keylen, iv, mode, - encrypt, blocklen); -} - -SECStatus -DES_InitContext(DESContext *cx, const unsigned char *key, - unsigned int keylen, const unsigned char *iv, int mode, - unsigned int encrypt, unsigned int xtra) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_DES_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); -} - -SECStatus -SEED_InitContext(SEEDContext *cx, const unsigned char *key, - unsigned int keylen, const unsigned char *iv, int mode, - unsigned int encrypt, unsigned int xtra) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_SEED_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); -} - -SECStatus -RC2_InitContext(RC2Context *cx, const unsigned char *key, - unsigned int keylen, const unsigned char *iv, int mode, - unsigned int effectiveKeyLen, unsigned int xtra) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RC2_InitContext)(cx, key, keylen, iv, mode, - effectiveKeyLen, xtra); -} - -SECStatus -RC4_InitContext(RC4Context *cx, const unsigned char *key, - unsigned int keylen, const unsigned char *x1, int x2, - unsigned int x3, unsigned int x4) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_RC4_InitContext)(cx, key, keylen, x1, x2, x3, x4); -} - -void -MD2_Clone(MD2Context *dest, MD2Context *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_MD2_Clone)(dest, src); -} - -void -MD5_Clone(MD5Context *dest, MD5Context *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_MD5_Clone)(dest, src); -} - -void -SHA1_Clone(SHA1Context *dest, SHA1Context *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_SHA1_Clone)(dest, src); -} - -void -SHA256_Clone(SHA256Context *dest, SHA256Context *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_SHA256_Clone)(dest, src); -} - -void -SHA384_Clone(SHA384Context *dest, SHA384Context *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_SHA384_Clone)(dest, src); -} - -void -SHA512_Clone(SHA512Context *dest, SHA512Context *src) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_SHA512_Clone)(dest, src); -} - -SECStatus -TLS_PRF(const SECItem *secret, const char *label, - SECItem *seed, SECItem *result, PRBool isFIPS) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_TLS_PRF)(secret, label, seed, result, isFIPS); -} - -const SECHashObject * -HASH_GetRawHashObject(HASH_HashType hashType) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_HASH_GetRawHashObject)(hashType); -} - - -void -HMAC_Destroy(HMACContext *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_HMAC_Destroy)(cx, freeit); -} - -HMACContext * -HMAC_Create(const SECHashObject *hashObj, const unsigned char *secret, - unsigned int secret_len, PRBool isFIPS) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_HMAC_Create)(hashObj, secret, secret_len, isFIPS); -} - -SECStatus -HMAC_Init(HMACContext *cx, const SECHashObject *hashObj, - const unsigned char *secret, unsigned int secret_len, PRBool isFIPS) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_HMAC_Init)(cx, hashObj, secret, secret_len, isFIPS); -} - -void -HMAC_Begin(HMACContext *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_HMAC_Begin)(cx); -} - -void -HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_HMAC_Update)(cx, data, data_len); -} - -SECStatus -HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len, - unsigned int max_result_len) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_HMAC_Finish)(cx, result, result_len, max_result_len); -} - -HMACContext * -HMAC_Clone(HMACContext *cx) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_HMAC_Clone)(cx); -} - -void -RNG_SystemInfoForRNG(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_RNG_SystemInfoForRNG)(); - -} - -SECStatus -FIPS186Change_GenerateX(unsigned char *XKEY, const unsigned char *XSEEDj, - unsigned char *x_j) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_FIPS186Change_GenerateX)(XKEY, XSEEDj, x_j); -} - -SECStatus -FIPS186Change_ReduceModQForDSA(const unsigned char *w, - const unsigned char *q, - unsigned char *xj) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_FIPS186Change_ReduceModQForDSA)(w, q, xj); -} - -/* === new for Camellia === */ -SECStatus -Camellia_InitContext(CamelliaContext *cx, const unsigned char *key, - unsigned int keylen, const unsigned char *iv, int mode, - unsigned int encrypt, unsigned int unused) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_Camellia_InitContext)(cx, key, keylen, iv, mode, encrypt, - unused); -} - -CamelliaContext * -Camellia_AllocateContext(void) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_Camellia_AllocateContext)(); -} - - -CamelliaContext * -Camellia_CreateContext(const unsigned char *key, const unsigned char *iv, - int mode, int encrypt, - unsigned int keylen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return NULL; - return (vector->p_Camellia_CreateContext)(key, iv, mode, encrypt, keylen); -} - -void -Camellia_DestroyContext(CamelliaContext *cx, PRBool freeit) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return ; - (vector->p_Camellia_DestroyContext)(cx, freeit); -} - -SECStatus -Camellia_Encrypt(CamelliaContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_Camellia_Encrypt)(cx, output, outputLen, maxOutputLen, - input, inputLen); -} - -SECStatus -Camellia_Decrypt(CamelliaContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_Camellia_Decrypt)(cx, output, outputLen, maxOutputLen, - input, inputLen); -} - -void BL_SetForkState(PRBool forked) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return; - (vector->p_BL_SetForkState)(forked); -} - -SECStatus -PRNGTEST_Instantiate(const PRUint8 *entropy, unsigned int entropy_len, - const PRUint8 *nonce, unsigned int nonce_len, - const PRUint8 *personal_string, unsigned int ps_len) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_PRNGTEST_Instantiate)(entropy, entropy_len, - nonce, nonce_len, - personal_string, ps_len); -} - -SECStatus -PRNGTEST_Reseed(const PRUint8 *entropy, unsigned int entropy_len, - const PRUint8 *additional, unsigned int additional_len) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_PRNGTEST_Reseed)(entropy, entropy_len, - additional, additional_len); -} - -SECStatus -PRNGTEST_Generate(PRUint8 *bytes, unsigned int bytes_len, - const PRUint8 *additional, unsigned int additional_len) -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_PRNGTEST_Generate)(bytes, bytes_len, - additional, additional_len); -} - -SECStatus -PRNGTEST_Uninstantiate() -{ - if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) - return SECFailure; - return (vector->p_PRNGTEST_Uninstantiate)(); -} - - diff --git a/net/third_party/nss/ssl/bodge/loader.h b/net/third_party/nss/ssl/bodge/loader.h deleted file mode 100644 index 0cf7ba6..0000000 --- a/net/third_party/nss/ssl/bodge/loader.h +++ /dev/null @@ -1,555 +0,0 @@ -/* - * loader.h - load platform dependent DSO containing freebl implementation. - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape security libraries. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* $Id: loader.h,v 1.26 2009/03/29 03:45:32 wtc%google.com Exp $ */ - -#ifndef _LOADER_H_ -#define _LOADER_H_ 1 - -#include "blapi.h" - -#define FREEBL_VERSION 0x030B - -struct FREEBLVectorStr { - - unsigned short length; /* of this struct in bytes */ - unsigned short version; /* of this struct. */ - - RSAPrivateKey * (* p_RSA_NewKey)(int keySizeInBits, - SECItem * publicExponent); - - SECStatus (* p_RSA_PublicKeyOp) (RSAPublicKey * key, - unsigned char * output, - const unsigned char * input); - - SECStatus (* p_RSA_PrivateKeyOp)(RSAPrivateKey * key, - unsigned char * output, - const unsigned char * input); - - SECStatus (* p_DSA_NewKey)(const PQGParams * params, - DSAPrivateKey ** privKey); - - SECStatus (* p_DSA_SignDigest)(DSAPrivateKey * key, - SECItem * signature, - const SECItem * digest); - - SECStatus (* p_DSA_VerifyDigest)(DSAPublicKey * key, - const SECItem * signature, - const SECItem * digest); - - SECStatus (* p_DSA_NewKeyFromSeed)(const PQGParams *params, - const unsigned char * seed, - DSAPrivateKey **privKey); - - SECStatus (* p_DSA_SignDigestWithSeed)(DSAPrivateKey * key, - SECItem * signature, - const SECItem * digest, - const unsigned char * seed); - - SECStatus (* p_DH_GenParam)(int primeLen, DHParams ** params); - - SECStatus (* p_DH_NewKey)(DHParams * params, - DHPrivateKey ** privKey); - - SECStatus (* p_DH_Derive)(SECItem * publicValue, - SECItem * prime, - SECItem * privateValue, - SECItem * derivedSecret, - unsigned int maxOutBytes); - - SECStatus (* p_KEA_Derive)(SECItem *prime, - SECItem *public1, - SECItem *public2, - SECItem *private1, - SECItem *private2, - SECItem *derivedSecret); - - PRBool (* p_KEA_Verify)(SECItem *Y, SECItem *prime, SECItem *subPrime); - - RC4Context * (* p_RC4_CreateContext)(const unsigned char *key, int len); - - void (* p_RC4_DestroyContext)(RC4Context *cx, PRBool freeit); - - SECStatus (* p_RC4_Encrypt)(RC4Context *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - SECStatus (* p_RC4_Decrypt)(RC4Context *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - RC2Context * (* p_RC2_CreateContext)(const unsigned char *key, - unsigned int len, const unsigned char *iv, - int mode, unsigned effectiveKeyLen); - - void (* p_RC2_DestroyContext)(RC2Context *cx, PRBool freeit); - - SECStatus (* p_RC2_Encrypt)(RC2Context *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - SECStatus (* p_RC2_Decrypt)(RC2Context *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - RC5Context *(* p_RC5_CreateContext)(const SECItem *key, unsigned int rounds, - unsigned int wordSize, const unsigned char *iv, int mode); - - void (* p_RC5_DestroyContext)(RC5Context *cx, PRBool freeit); - - SECStatus (* p_RC5_Encrypt)(RC5Context *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - SECStatus (* p_RC5_Decrypt)(RC5Context *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - DESContext *(* p_DES_CreateContext)(const unsigned char *key, - const unsigned char *iv, - int mode, PRBool encrypt); - - void (* p_DES_DestroyContext)(DESContext *cx, PRBool freeit); - - SECStatus (* p_DES_Encrypt)(DESContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - SECStatus (* p_DES_Decrypt)(DESContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - AESContext * (* p_AES_CreateContext)(const unsigned char *key, - const unsigned char *iv, - int mode, int encrypt, unsigned int keylen, - unsigned int blocklen); - - void (* p_AES_DestroyContext)(AESContext *cx, PRBool freeit); - - SECStatus (* p_AES_Encrypt)(AESContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - SECStatus (* p_AES_Decrypt)(AESContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - SECStatus (* p_MD5_Hash)(unsigned char *dest, const char *src); - - SECStatus (* p_MD5_HashBuf)(unsigned char *dest, const unsigned char *src, - uint32 src_length); - - MD5Context *(* p_MD5_NewContext)(void); - - void (* p_MD5_DestroyContext)(MD5Context *cx, PRBool freeit); - - void (* p_MD5_Begin)(MD5Context *cx); - - void (* p_MD5_Update)(MD5Context *cx, - const unsigned char *input, unsigned int inputLen); - - void (* p_MD5_End)(MD5Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); - - unsigned int (* p_MD5_FlattenSize)(MD5Context *cx); - - SECStatus (* p_MD5_Flatten)(MD5Context *cx,unsigned char *space); - - MD5Context * (* p_MD5_Resurrect)(unsigned char *space, void *arg); - - void (* p_MD5_TraceState)(MD5Context *cx); - - SECStatus (* p_MD2_Hash)(unsigned char *dest, const char *src); - - MD2Context *(* p_MD2_NewContext)(void); - - void (* p_MD2_DestroyContext)(MD2Context *cx, PRBool freeit); - - void (* p_MD2_Begin)(MD2Context *cx); - - void (* p_MD2_Update)(MD2Context *cx, - const unsigned char *input, unsigned int inputLen); - - void (* p_MD2_End)(MD2Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); - - unsigned int (* p_MD2_FlattenSize)(MD2Context *cx); - - SECStatus (* p_MD2_Flatten)(MD2Context *cx,unsigned char *space); - - MD2Context * (* p_MD2_Resurrect)(unsigned char *space, void *arg); - - SECStatus (* p_SHA1_Hash)(unsigned char *dest, const char *src); - - SECStatus (* p_SHA1_HashBuf)(unsigned char *dest, const unsigned char *src, - uint32 src_length); - - SHA1Context *(* p_SHA1_NewContext)(void); - - void (* p_SHA1_DestroyContext)(SHA1Context *cx, PRBool freeit); - - void (* p_SHA1_Begin)(SHA1Context *cx); - - void (* p_SHA1_Update)(SHA1Context *cx, const unsigned char *input, - unsigned int inputLen); - - void (* p_SHA1_End)(SHA1Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); - - void (* p_SHA1_TraceState)(SHA1Context *cx); - - unsigned int (* p_SHA1_FlattenSize)(SHA1Context *cx); - - SECStatus (* p_SHA1_Flatten)(SHA1Context *cx,unsigned char *space); - - SHA1Context * (* p_SHA1_Resurrect)(unsigned char *space, void *arg); - - SECStatus (* p_RNG_RNGInit)(void); - - SECStatus (* p_RNG_RandomUpdate)(const void *data, size_t bytes); - - SECStatus (* p_RNG_GenerateGlobalRandomBytes)(void *dest, size_t len); - - void (* p_RNG_RNGShutdown)(void); - - SECStatus (* p_PQG_ParamGen)(unsigned int j, PQGParams **pParams, - PQGVerify **pVfy); - - SECStatus (* p_PQG_ParamGenSeedLen)( unsigned int j, unsigned int seedBytes, - PQGParams **pParams, PQGVerify **pVfy); - - SECStatus (* p_PQG_VerifyParams)(const PQGParams *params, - const PQGVerify *vfy, SECStatus *result); - - /* Version 3.001 came to here */ - - SECStatus (* p_RSA_PrivateKeyOpDoubleChecked)(RSAPrivateKey *key, - unsigned char *output, - const unsigned char *input); - - SECStatus (* p_RSA_PrivateKeyCheck)(RSAPrivateKey *key); - - void (* p_BL_Cleanup)(void); - - /* Version 3.002 came to here */ - - SHA256Context *(* p_SHA256_NewContext)(void); - void (* p_SHA256_DestroyContext)(SHA256Context *cx, PRBool freeit); - void (* p_SHA256_Begin)(SHA256Context *cx); - void (* p_SHA256_Update)(SHA256Context *cx, const unsigned char *input, - unsigned int inputLen); - void (* p_SHA256_End)(SHA256Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); - SECStatus (* p_SHA256_HashBuf)(unsigned char *dest, const unsigned char *src, - uint32 src_length); - SECStatus (* p_SHA256_Hash)(unsigned char *dest, const char *src); - void (* p_SHA256_TraceState)(SHA256Context *cx); - unsigned int (* p_SHA256_FlattenSize)(SHA256Context *cx); - SECStatus (* p_SHA256_Flatten)(SHA256Context *cx,unsigned char *space); - SHA256Context * (* p_SHA256_Resurrect)(unsigned char *space, void *arg); - - SHA512Context *(* p_SHA512_NewContext)(void); - void (* p_SHA512_DestroyContext)(SHA512Context *cx, PRBool freeit); - void (* p_SHA512_Begin)(SHA512Context *cx); - void (* p_SHA512_Update)(SHA512Context *cx, const unsigned char *input, - unsigned int inputLen); - void (* p_SHA512_End)(SHA512Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); - SECStatus (* p_SHA512_HashBuf)(unsigned char *dest, const unsigned char *src, - uint32 src_length); - SECStatus (* p_SHA512_Hash)(unsigned char *dest, const char *src); - void (* p_SHA512_TraceState)(SHA512Context *cx); - unsigned int (* p_SHA512_FlattenSize)(SHA512Context *cx); - SECStatus (* p_SHA512_Flatten)(SHA512Context *cx,unsigned char *space); - SHA512Context * (* p_SHA512_Resurrect)(unsigned char *space, void *arg); - - SHA384Context *(* p_SHA384_NewContext)(void); - void (* p_SHA384_DestroyContext)(SHA384Context *cx, PRBool freeit); - void (* p_SHA384_Begin)(SHA384Context *cx); - void (* p_SHA384_Update)(SHA384Context *cx, const unsigned char *input, - unsigned int inputLen); - void (* p_SHA384_End)(SHA384Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); - SECStatus (* p_SHA384_HashBuf)(unsigned char *dest, const unsigned char *src, - uint32 src_length); - SECStatus (* p_SHA384_Hash)(unsigned char *dest, const char *src); - void (* p_SHA384_TraceState)(SHA384Context *cx); - unsigned int (* p_SHA384_FlattenSize)(SHA384Context *cx); - SECStatus (* p_SHA384_Flatten)(SHA384Context *cx,unsigned char *space); - SHA384Context * (* p_SHA384_Resurrect)(unsigned char *space, void *arg); - - /* Version 3.003 came to here */ - - AESKeyWrapContext * (* p_AESKeyWrap_CreateContext)(const unsigned char *key, - const unsigned char *iv, int encrypt, unsigned int keylen); - - void (* p_AESKeyWrap_DestroyContext)(AESKeyWrapContext *cx, PRBool freeit); - - SECStatus (* p_AESKeyWrap_Encrypt)(AESKeyWrapContext *cx, - unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - SECStatus (* p_AESKeyWrap_Decrypt)(AESKeyWrapContext *cx, - unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - /* Version 3.004 came to here */ - - PRBool (*p_BLAPI_SHVerify)(const char *name, PRFuncPtr addr); - PRBool (*p_BLAPI_VerifySelf)(const char *name); - - /* Version 3.005 came to here */ - - SECStatus (* p_EC_NewKey)(ECParams * params, - ECPrivateKey ** privKey); - - SECStatus (* p_EC_NewKeyFromSeed)(ECParams * params, - ECPrivateKey ** privKey, - const unsigned char * seed, - int seedlen); - - SECStatus (* p_EC_ValidatePublicKey)(ECParams * params, - SECItem * publicValue); - - SECStatus (* p_ECDH_Derive)(SECItem * publicValue, - ECParams * params, - SECItem * privateValue, - PRBool withCofactor, - SECItem * derivedSecret); - - SECStatus (* p_ECDSA_SignDigest)(ECPrivateKey * key, - SECItem * signature, - const SECItem * digest); - - SECStatus (* p_ECDSA_VerifyDigest)(ECPublicKey * key, - const SECItem * signature, - const SECItem * digest); - - SECStatus (* p_ECDSA_SignDigestWithSeed)(ECPrivateKey * key, - SECItem * signature, - const SECItem * digest, - const unsigned char * seed, - const int seedlen); - - /* Version 3.006 came to here */ - - /* no modification to FREEBLVectorStr itself - * but ECParamStr was modified - */ - - /* Version 3.007 came to here */ - - SECStatus (* p_AES_InitContext)(AESContext *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *iv, - int mode, - unsigned int encrypt, - unsigned int blocklen); - SECStatus (* p_AESKeyWrap_InitContext)(AESKeyWrapContext *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *iv, - int mode, - unsigned int encrypt, - unsigned int blocklen); - SECStatus (* p_DES_InitContext)(DESContext *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *iv, - int mode, - unsigned int encrypt, - unsigned int ); - SECStatus (* p_RC2_InitContext)(RC2Context *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *iv, - int mode, - unsigned int effectiveKeyLen, - unsigned int ); - SECStatus (* p_RC4_InitContext)(RC4Context *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *, - int, - unsigned int , - unsigned int ); - - AESContext *(*p_AES_AllocateContext)(void); - AESKeyWrapContext *(*p_AESKeyWrap_AllocateContext)(void); - DESContext *(*p_DES_AllocateContext)(void); - RC2Context *(*p_RC2_AllocateContext)(void); - RC4Context *(*p_RC4_AllocateContext)(void); - - void (* p_MD2_Clone)(MD2Context *dest, MD2Context *src); - void (* p_MD5_Clone)(MD5Context *dest, MD5Context *src); - void (* p_SHA1_Clone)(SHA1Context *dest, SHA1Context *src); - void (* p_SHA256_Clone)(SHA256Context *dest, SHA256Context *src); - void (* p_SHA384_Clone)(SHA384Context *dest, SHA384Context *src); - void (* p_SHA512_Clone)(SHA512Context *dest, SHA512Context *src); - - SECStatus (* p_TLS_PRF)(const SECItem *secret, const char *label, - SECItem *seed, SECItem *result, PRBool isFIPS); - - const SECHashObject *(* p_HASH_GetRawHashObject)(HASH_HashType hashType); - - HMACContext * (* p_HMAC_Create)(const SECHashObject *hashObj, - const unsigned char *secret, - unsigned int secret_len, PRBool isFIPS); - SECStatus (* p_HMAC_Init)(HMACContext *cx, const SECHashObject *hash_obj, - const unsigned char *secret, - unsigned int secret_len, PRBool isFIPS); - void (* p_HMAC_Begin)(HMACContext *cx); - void (* p_HMAC_Update)(HMACContext *cx, const unsigned char *data, - unsigned int data_len); - HMACContext * (* p_HMAC_Clone)(HMACContext *cx); - SECStatus (* p_HMAC_Finish)(HMACContext *cx, unsigned char *result, - unsigned int *result_len, - unsigned int max_result_len); - void (* p_HMAC_Destroy)(HMACContext *cx, PRBool freeit); - - void (* p_RNG_SystemInfoForRNG)(void); - - /* Version 3.008 came to here */ - - SECStatus (* p_FIPS186Change_GenerateX)(unsigned char *XKEY, - const unsigned char *XSEEDj, - unsigned char *x_j); - SECStatus (* p_FIPS186Change_ReduceModQForDSA)(const unsigned char *w, - const unsigned char *q, - unsigned char *xj); - - /* Version 3.009 came to here */ - - SECStatus (* p_Camellia_InitContext)(CamelliaContext *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *iv, - int mode, - unsigned int encrypt, - unsigned int unused); - - CamelliaContext *(*p_Camellia_AllocateContext)(void); - CamelliaContext * (* p_Camellia_CreateContext)(const unsigned char *key, - const unsigned char *iv, - int mode, int encrypt, - unsigned int keylen); - void (* p_Camellia_DestroyContext)(CamelliaContext *cx, PRBool freeit); - - SECStatus (* p_Camellia_Encrypt)(CamelliaContext *cx, unsigned char *output, - unsigned int *outputLen, - unsigned int maxOutputLen, - const unsigned char *input, - unsigned int inputLen); - - SECStatus (* p_Camellia_Decrypt)(CamelliaContext *cx, unsigned char *output, - unsigned int *outputLen, - unsigned int maxOutputLen, - const unsigned char *input, - unsigned int inputLen); - - void (* p_PQG_DestroyParams)(PQGParams *params); - - void (* p_PQG_DestroyVerify)(PQGVerify *vfy); - - /* Version 3.010 came to here */ - - SECStatus (* p_SEED_InitContext)(SEEDContext *cx, - const unsigned char *key, - unsigned int keylen, - const unsigned char *iv, - int mode, - unsigned int encrypt, - unsigned int ); - - SEEDContext *(*p_SEED_AllocateContext)(void); - - SEEDContext *(* p_SEED_CreateContext)(const unsigned char *key, - const unsigned char *iv, - int mode, PRBool encrypt); - - void (* p_SEED_DestroyContext)(SEEDContext *cx, PRBool freeit); - - SECStatus (* p_SEED_Encrypt)(SEEDContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - SECStatus (* p_SEED_Decrypt)(SEEDContext *cx, unsigned char *output, - unsigned int *outputLen, unsigned int maxOutputLen, - const unsigned char *input, unsigned int inputLen); - - - - SECStatus (* p_BL_Init)(void); - void ( * p_BL_SetForkState)(PRBool); - - SECStatus (* p_PRNGTEST_Instantiate)(const PRUint8 *entropy, - unsigned int entropy_len, - const PRUint8 *nonce, - unsigned int nonce_len, - const PRUint8 *personal_string, - unsigned int ps_len); - - SECStatus (* p_PRNGTEST_Reseed)(const PRUint8 *entropy, - unsigned int entropy_len, - const PRUint8 *additional, - unsigned int additional_len); - - SECStatus (* p_PRNGTEST_Generate)(PRUint8 *bytes, - unsigned int bytes_len, - const PRUint8 *additional, - unsigned int additional_len); - - SECStatus (* p_PRNGTEST_Uninstantiate)(void); - /* Version 3.011 came to here */ -}; - -typedef struct FREEBLVectorStr FREEBLVector; - -SEC_BEGIN_PROTOS - -typedef const FREEBLVector * FREEBLGetVectorFn(void); - -extern FREEBLGetVectorFn FREEBL_GetVector; - -SEC_END_PROTOS - -#endif diff --git a/net/third_party/nss/ssl/sslsnce.c b/net/third_party/nss/ssl/sslsnce.c index e132de9..2b0ed08 100644 --- a/net/third_party/nss/ssl/sslsnce.c +++ b/net/third_party/nss/ssl/sslsnce.c @@ -87,6 +87,11 @@ #include "nspr.h" #include "sslmutex.h" +/* AES_256_KEY_LENGTH was added to blapit.h in NSS 3.12.10. */ +#ifndef AES_256_KEY_LENGTH +#define AES_256_KEY_LENGTH 32 /* bytes */ +#endif + /* ** Format of a cache entry in the shared memory. */ |