Back to index

lightning-sunbird  0.9+nobinonly
Functions
blapi.h File Reference
#include "blapit.h"
#include "hasht.h"
#include "alghmac.h"

Go to the source code of this file.

Functions

SEC_BEGIN_PROTOS RSAPrivateKey * RSA_NewKey (int keySizeInBits, SECItem *publicExponent)
SECStatus RSA_PublicKeyOp (RSAPublicKey *key, unsigned char *output, const unsigned char *input)
SECStatus RSA_PrivateKeyOp (RSAPrivateKey *key, unsigned char *output, const unsigned char *input)
SECStatus RSA_PrivateKeyOpDoubleChecked (RSAPrivateKey *key, unsigned char *output, const unsigned char *input)
SECStatus RSA_PrivateKeyCheck (RSAPrivateKey *key)
SECStatus DSA_NewKey (const PQGParams *params, DSAPrivateKey **privKey)
SECStatus DSA_SignDigest (DSAPrivateKey *key, SECItem *signature, const SECItem *digest)
SECStatus DSA_VerifyDigest (DSAPublicKey *key, const SECItem *signature, const SECItem *digest)
SECStatus DSA_NewKeyFromSeed (const PQGParams *params, const unsigned char *seed, DSAPrivateKey **privKey)
SECStatus DSA_SignDigestWithSeed (DSAPrivateKey *key, SECItem *signature, const SECItem *digest, const unsigned char *seed)
SECStatus DH_GenParam (int primeLen, DHParams **params)
SECStatus DH_NewKey (DHParams *params, DHPrivateKey **privKey)
SECStatus DH_Derive (SECItem *publicValue, SECItem *prime, SECItem *privateValue, SECItem *derivedSecret, unsigned int maxOutBytes)
SECStatus KEA_Derive (SECItem *prime, SECItem *public1, SECItem *public2, SECItem *private1, SECItem *private2, SECItem *derivedSecret)
PRBool KEA_Verify (SECItem *Y, SECItem *prime, SECItem *subPrime)
SECStatus EC_NewKey (ECParams *params, ECPrivateKey **privKey)
SECStatus EC_NewKeyFromSeed (ECParams *params, ECPrivateKey **privKey, const unsigned char *seed, int seedlen)
SECStatus EC_ValidatePublicKey (ECParams *params, SECItem *publicValue)
SECStatus ECDH_Derive (SECItem *publicValue, ECParams *params, SECItem *privateValue, PRBool withCofactor, SECItem *derivedSecret)
SECStatus ECDSA_SignDigest (ECPrivateKey *key, SECItem *signature, const SECItem *digest)
SECStatus ECDSA_VerifyDigest (ECPublicKey *key, const SECItem *signature, const SECItem *digest)
SECStatus ECDSA_SignDigestWithSeed (ECPrivateKey *key, SECItem *signature, const SECItem *digest, const unsigned char *seed, const int seedlen)
RC4Context * RC4_CreateContext (const unsigned char *key, int len)
RC4Context * RC4_AllocateContext (void)
SECStatus RC4_InitContext (RC4Context *cx, const unsigned char *key, unsigned int keylen, const unsigned char *, int, unsigned int, unsigned int)
void RC4_DestroyContext (RC4Context *cx, PRBool freeit)
SECStatus RC4_Encrypt (RC4Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
SECStatus RC4_Decrypt (RC4Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
RC2Context * RC2_CreateContext (const unsigned char *key, unsigned int len, const unsigned char *iv, int mode, unsigned effectiveKeyLen)
RC2Context * RC2_AllocateContext (void)
SECStatus RC2_InitContext (RC2Context *cx, const unsigned char *key, unsigned int keylen, const unsigned char *iv, int mode, unsigned int effectiveKeyLen, unsigned int)
void RC2_DestroyContext (RC2Context *cx, PRBool freeit)
SECStatus RC2_Encrypt (RC2Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
SECStatus RC2_Decrypt (RC2Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
RC5Context * RC5_CreateContext (const SECItem *key, unsigned int rounds, unsigned int wordSize, const unsigned char *iv, int mode)
RC5Context * RC5_AllocateContext (void)
SECStatus RC5_InitContext (RC5Context *cx, const unsigned char *key, unsigned int keylen, const unsigned char *iv, int mode, unsigned int rounds, unsigned int wordSize)
void RC5_DestroyContext (RC5Context *cx, PRBool freeit)
SECStatus RC5_Encrypt (RC5Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
SECStatus RC5_Decrypt (RC5Context *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
DESContext * DES_CreateContext (const unsigned char *key, const unsigned char *iv, int mode, PRBool encrypt)
DESContext * DES_AllocateContext (void)
SECStatus DES_InitContext (DESContext *cx, const unsigned char *key, unsigned int keylen, const unsigned char *iv, int mode, unsigned int encrypt, unsigned int)
void DES_DestroyContext (DESContext *cx, PRBool freeit)
SECStatus DES_Encrypt (DESContext *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
SECStatus DES_Decrypt (DESContext *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
AESContext * AES_CreateContext (const unsigned char *key, const unsigned char *iv, int mode, int encrypt, unsigned int keylen, unsigned int blocklen)
AESContext * AES_AllocateContext (void)
SECStatus AES_InitContext (AESContext *cx, const unsigned char *key, unsigned int keylen, const unsigned char *iv, int mode, unsigned int encrypt, unsigned int blocklen)
void AES_DestroyContext (AESContext *cx, PRBool freeit)
SECStatus AES_Encrypt (AESContext *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
SECStatus AES_Decrypt (AESContext *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
AESKeyWrapContext * AESKeyWrap_CreateContext (const unsigned char *key, const unsigned char *iv, int encrypt, unsigned int keylen)
AESKeyWrapContext * AESKeyWrap_AllocateContext (void)
SECStatus AESKeyWrap_InitContext (AESKeyWrapContext *cx, const unsigned char *key, unsigned int keylen, const unsigned char *iv, int, unsigned int encrypt, unsigned int)
void AESKeyWrap_DestroyContext (AESKeyWrapContext *cx, PRBool freeit)
SECStatus AESKeyWrap_Encrypt (AESKeyWrapContext *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
SECStatus AESKeyWrap_Decrypt (AESKeyWrapContext *cx, unsigned char *output, unsigned int *outputLen, unsigned int maxOutputLen, const unsigned char *input, unsigned int inputLen)
SECStatus MD5_Hash (unsigned char *dest, const char *src)
SECStatus MD5_HashBuf (unsigned char *dest, const unsigned char *src, uint32 src_length)
MD5ContextMD5_NewContext (void)
void MD5_DestroyContext (MD5Context *cx, PRBool freeit)
void MD5_Begin (MD5Context *cx)
void MD5_Update (MD5Context *cx, const unsigned char *input, unsigned int inputLen)
void MD5_End (MD5Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen)
unsigned int MD5_FlattenSize (MD5Context *cx)
SECStatus MD5_Flatten (MD5Context *cx, unsigned char *space)
MD5ContextMD5_Resurrect (unsigned char *space, void *arg)
void MD5_Clone (MD5Context *dest, MD5Context *src)
void MD5_TraceState (MD5Context *cx)
SECStatus MD2_Hash (unsigned char *dest, const char *src)
MD2Context * MD2_NewContext (void)
void MD2_DestroyContext (MD2Context *cx, PRBool freeit)
void MD2_Begin (MD2Context *cx)
void MD2_Update (MD2Context *cx, const unsigned char *input, unsigned int inputLen)
void MD2_End (MD2Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen)
unsigned int MD2_FlattenSize (MD2Context *cx)
SECStatus MD2_Flatten (MD2Context *cx, unsigned char *space)
MD2Context * MD2_Resurrect (unsigned char *space, void *arg)
void MD2_Clone (MD2Context *dest, MD2Context *src)
SECStatus SHA1_Hash (unsigned char *dest, const char *src)
SECStatus SHA1_HashBuf (unsigned char *dest, const unsigned char *src, uint32 src_length)
SHA1Context * SHA1_NewContext (void)
void SHA1_DestroyContext (SHA1Context *cx, PRBool freeit)
void SHA1_Begin (SHA1Context *cx)
void SHA1_Update (SHA1Context *cx, const unsigned char *input, unsigned int inputLen)
void SHA1_End (SHA1Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen)
void SHA1_TraceState (SHA1Context *cx)
unsigned int SHA1_FlattenSize (SHA1Context *cx)
SECStatus SHA1_Flatten (SHA1Context *cx, unsigned char *space)
SHA1Context * SHA1_Resurrect (unsigned char *space, void *arg)
void SHA1_Clone (SHA1Context *dest, SHA1Context *src)
SHA256Context * SHA256_NewContext (void)
void SHA256_DestroyContext (SHA256Context *cx, PRBool freeit)
void SHA256_Begin (SHA256Context *cx)
void SHA256_Update (SHA256Context *cx, const unsigned char *input, unsigned int inputLen)
void SHA256_End (SHA256Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen)
SECStatus SHA256_HashBuf (unsigned char *dest, const unsigned char *src, uint32 src_length)
SECStatus SHA256_Hash (unsigned char *dest, const char *src)
void SHA256_TraceState (SHA256Context *cx)
unsigned int SHA256_FlattenSize (SHA256Context *cx)
SECStatus SHA256_Flatten (SHA256Context *cx, unsigned char *space)
SHA256Context * SHA256_Resurrect (unsigned char *space, void *arg)
void SHA256_Clone (SHA256Context *dest, SHA256Context *src)
SHA512Context * SHA512_NewContext (void)
void SHA512_DestroyContext (SHA512Context *cx, PRBool freeit)
void SHA512_Begin (SHA512Context *cx)
void SHA512_Update (SHA512Context *cx, const unsigned char *input, unsigned int inputLen)
void SHA512_End (SHA512Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen)
SECStatus SHA512_HashBuf (unsigned char *dest, const unsigned char *src, uint32 src_length)
SECStatus SHA512_Hash (unsigned char *dest, const char *src)
void SHA512_TraceState (SHA512Context *cx)
unsigned int SHA512_FlattenSize (SHA512Context *cx)
SECStatus SHA512_Flatten (SHA512Context *cx, unsigned char *space)
SHA512Context * SHA512_Resurrect (unsigned char *space, void *arg)
void SHA512_Clone (SHA512Context *dest, SHA512Context *src)
SHA384Context * SHA384_NewContext (void)
void SHA384_DestroyContext (SHA384Context *cx, PRBool freeit)
void SHA384_Begin (SHA384Context *cx)
void SHA384_Update (SHA384Context *cx, const unsigned char *input, unsigned int inputLen)
void SHA384_End (SHA384Context *cx, unsigned char *digest, unsigned int *digestLen, unsigned int maxDigestLen)
SECStatus SHA384_HashBuf (unsigned char *dest, const unsigned char *src, uint32 src_length)
SECStatus SHA384_Hash (unsigned char *dest, const char *src)
void SHA384_TraceState (SHA384Context *cx)
unsigned int SHA384_FlattenSize (SHA384Context *cx)
SECStatus SHA384_Flatten (SHA384Context *cx, unsigned char *space)
SHA384Context * SHA384_Resurrect (unsigned char *space, void *arg)
void SHA384_Clone (SHA384Context *dest, SHA384Context *src)
SECStatus TLS_PRF (const SECItem *secret, const char *label, SECItem *seed, SECItem *result, PRBool isFIPS)
SECStatus RNG_RNGInit (void)
SECStatus RNG_RandomUpdate (const void *data, size_t bytes)
SECStatus RNG_GenerateGlobalRandomBytes (void *dest, size_t len)
void RNG_RNGShutdown (void)
void RNG_SystemInfoForRNG (void)
SECStatus FIPS186Change_GenerateX (unsigned char *XKEY, const unsigned char *XSEEDj, unsigned char *x_j)
SECStatus FIPS186Change_ReduceModQForDSA (const unsigned char *w, const unsigned char *q, unsigned char *xj)
SECStatus PQG_ParamGen (unsigned int j, PQGParams **pParams, PQGVerify **pVfy)
SECStatus PQG_ParamGenSeedLen (unsigned int j, unsigned int seedBytes, PQGParams **pParams, PQGVerify **pVfy)
SECStatus PQG_VerifyParams (const PQGParams *params, const PQGVerify *vfy, SECStatus *result)
void BL_Cleanup (void)
void BL_Unload (void)
PRBool BLAPI_SHVerify (const char *name, PRFuncPtr addr)
PRBool BLAPI_VerifySelf (const char *name)
const SECHashObject * HASH_GetRawHashObject (HASH_HashType hashType)

Function Documentation

AESContext* AES_AllocateContext ( void  )

Definition at line 1414 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_AES_AllocateContext)();
}

Here is the call graph for this function:

AESContext* AES_CreateContext ( const unsigned char *  key,
const unsigned char *  iv,
int  mode,
int  encrypt,
unsigned int  keylen,
unsigned int  blocklen 
)

Definition at line 630 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_AES_CreateContext)(key, iv, mode, encrypt, keylen, 
                                   blocklen);
}

Here is the call graph for this function:

SECStatus AES_Decrypt ( AESContext *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 660 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_AES_Decrypt)(cx, output, outputLen, maxOutputLen, 
                             input, inputLen);
}

Here is the call graph for this function:

void AES_DestroyContext ( AESContext *  cx,
PRBool  freeit 
)

Definition at line 641 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_AES_DestroyContext)(cx, freeit);
}

Here is the call graph for this function:

SECStatus AES_Encrypt ( AESContext *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 649 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_AES_Encrypt)(cx, output, outputLen, maxOutputLen, 
                             input, inputLen);
}

Here is the call graph for this function:

SECStatus AES_InitContext ( AESContext *  cx,
const unsigned char *  key,
unsigned int  keylen,
const unsigned char *  iv,
int  mode,
unsigned int  encrypt,
unsigned int  blocklen 
)

Definition at line 1454 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_AES_InitContext)(cx, key, keylen, iv, mode, encrypt, 
                                 blocklen);
}

Here is the call graph for this function:

AESKeyWrapContext* AESKeyWrap_AllocateContext ( void  )

Definition at line 66 of file aeskeywrap.c.

{
    AESKeyWrapContext * cx = PORT_New(AESKeyWrapContext);
    return cx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

AESKeyWrapContext* AESKeyWrap_CreateContext ( const unsigned char *  key,
const unsigned char *  iv,
int  encrypt,
unsigned int  keylen 
)

Definition at line 102 of file aeskeywrap.c.

{
    SECStatus rv;
    AESKeyWrapContext * cx = AESKeyWrap_AllocateContext();
    if (!cx) 
       return NULL;  /* error is already set */
    rv = AESKeyWrap_InitContext(cx, key, keylen, iv, 0, encrypt, 0);
    if (rv != SECSuccess) {
        PORT_Free(cx);
       cx = NULL;    /* error should already be set */
    }
    return cx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus AESKeyWrap_Decrypt ( AESKeyWrapContext *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 322 of file aeskeywrap.c.

{
    PRUint64 *     R          = NULL;
    unsigned int   nBlocks;
    unsigned int   i, j;
    unsigned int   aesLen     = AES_BLOCK_SIZE;
    unsigned int   outLen;
    SECStatus      s          = SECFailure;
    /* These PRUint64s are ALWAYS big endian, regardless of CPU orientation. */
    PRUint64       t;
    PRUint64       B[2];

#define A B[0]

    /* Check args */
    if (inputLen < 3 * AES_KEY_WRAP_BLOCK_SIZE || 
        0 != inputLen % AES_KEY_WRAP_BLOCK_SIZE) {
       PORT_SetError(SEC_ERROR_INPUT_LEN);
       return s;
    }
    outLen = inputLen - AES_KEY_WRAP_BLOCK_SIZE;
#ifdef maybe
    if (!output && pOutputLen) {   /* caller is asking for output size */
       *pOutputLen = outLen;
       return SECSuccess;
    }
#endif
    if (maxOutputLen < outLen) {
       PORT_SetError(SEC_ERROR_OUTPUT_LEN);
       return s;
    }
    if (cx == NULL || output == NULL || input == NULL) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return s;
    }
    nBlocks = inputLen / AES_KEY_WRAP_BLOCK_SIZE;
    R = PORT_NewArray(PRUint64, nBlocks);
    if (!R)
       return s;     /* error is already set. */
    nBlocks--;
    /* 
    ** 1) Initialize variables.
    */
    memcpy(&R[0], input, inputLen);
    A = R[0];
#if BIG_ENDIAN_WITH_64_BIT_REGISTERS
    t = 6UL * nBlocks;
#else
    set_t((unsigned char *)&t, 6UL * nBlocks);
#endif
    /* 
    ** 2) Calculate intermediate values.
    */
    for (j = 0; j < 6; ++j) {
       for (i = nBlocks; i; --i) {
           /* here, XOR A with t (in big endian order) and decrement t; */
#if BIG_ENDIAN_WITH_64_BIT_REGISTERS
           A ^= t--; 
#else
           xor_and_decrement((unsigned char *)&A, (unsigned char *)&t);
#endif
           B[1] = R[i];
           s = AES_Decrypt(&cx->aescx, (unsigned char *)B, &aesLen, 
                           sizeof B,  (unsigned char *)B, sizeof B);
           if (s != SECSuccess) 
               break;
           R[i] = B[1];
       }
    }
    /* 
    ** 3) Output the results.
    */
    if (s == SECSuccess) {
       int bad = memcmp(&A, cx->iv, AES_KEY_WRAP_IV_BYTES);
       if (!bad) {
           memcpy(output, &R[1], outLen);
           if (pOutputLen)
              *pOutputLen = outLen;
       } else {
           PORT_SetError(SEC_ERROR_BAD_DATA);
           if (pOutputLen) 
              *pOutputLen = 0;
       }
    } else if (pOutputLen) {
       *pOutputLen = 0;
    }
    PORT_ZFree(R, inputLen);
    return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AESKeyWrap_DestroyContext ( AESKeyWrapContext *  cx,
PRBool  freeit 
)

Definition at line 123 of file aeskeywrap.c.

{
    if (cx) {
       AES_DestroyContext(&cx->aescx, PR_FALSE);
/*     memset(cx, 0, sizeof *cx); */
       if (freeit)
           PORT_Free(cx);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus AESKeyWrap_Encrypt ( AESKeyWrapContext *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 226 of file aeskeywrap.c.

{
    PRUint64 *     R          = NULL;
    unsigned int   nBlocks;
    unsigned int   i, j;
    unsigned int   aesLen     = AES_BLOCK_SIZE;
    unsigned int   outLen     = inputLen + AES_KEY_WRAP_BLOCK_SIZE;
    SECStatus      s          = SECFailure;
    /* These PRUint64s are ALWAYS big endian, regardless of CPU orientation. */
    PRUint64       t;
    PRUint64       B[2];

#define A B[0]

    /* Check args */
    if (!inputLen || 0 != inputLen % AES_KEY_WRAP_BLOCK_SIZE) {
       PORT_SetError(SEC_ERROR_INPUT_LEN);
       return s;
    }
#ifdef maybe
    if (!output && pOutputLen) {   /* caller is asking for output size */
       *pOutputLen = outLen;
       return SECSuccess;
    }
#endif
    if (maxOutputLen < outLen) {
       PORT_SetError(SEC_ERROR_OUTPUT_LEN);
       return s;
    }
    if (cx == NULL || output == NULL || input == NULL) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return s;
    }
    nBlocks = inputLen / AES_KEY_WRAP_BLOCK_SIZE;
    R = PORT_NewArray(PRUint64, nBlocks + 1);
    if (!R)
       return s;     /* error is already set. */
    /* 
    ** 1) Initialize variables.
    */
    memcpy(&A, cx->iv, AES_KEY_WRAP_IV_BYTES);
    memcpy(&R[1], input, inputLen);
#if BIG_ENDIAN_WITH_64_BIT_REGISTERS
    t = 0;
#else
    memset(&t, 0, sizeof t);
#endif
    /* 
    ** 2) Calculate intermediate values.
    */
    for (j = 0; j < 6; ++j) {
       for (i = 1; i <= nBlocks; ++i) {
           B[1] = R[i];
           s = AES_Encrypt(&cx->aescx, (unsigned char *)B, &aesLen, 
                           sizeof B,  (unsigned char *)B, sizeof B);
           if (s != SECSuccess) 
               break;
           R[i] = B[1];
           /* here, increment t and XOR A with t (in big endian order); */
#if BIG_ENDIAN_WITH_64_BIT_REGISTERS
           A ^= ++t; 
#else
           increment_and_xor((unsigned char *)&A, (unsigned char *)&t);
#endif
       }
    }
    /* 
    ** 3) Output the results.
    */
    if (s == SECSuccess) {
       R[0] =  A;
       memcpy(output, &R[0], outLen);
       if (pOutputLen)
           *pOutputLen = outLen;
    } else if (pOutputLen) {
       *pOutputLen = 0;
    }
    PORT_ZFree(R, outLen);
    return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus AESKeyWrap_InitContext ( AESKeyWrapContext *  cx,
const unsigned char *  key,
unsigned int  keylen,
const unsigned char *  iv,
int  ,
unsigned int  encrypt,
unsigned  int 
)

Definition at line 73 of file aeskeywrap.c.

{
    SECStatus rv = SECFailure;
    if (!cx) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    if (iv) {
       memcpy(cx->iv, iv, sizeof cx->iv);
    } else {
       memset(cx->iv, 0xA6, sizeof cx->iv);
    }
    rv = AES_InitContext(&cx->aescx, key, keylen, NULL, NSS_AES, encrypt, 
                                  AES_BLOCK_SIZE);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 982 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_BL_Cleanup)();
}

Here is the call graph for this function:

Definition at line 990 of file loader.c.

{
  /* 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;
}

Here is the call graph for this function:

PRBool BLAPI_SHVerify ( const char *  name,
PRFuncPtr  addr 
)

Definition at line 1325 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return PR_FALSE;
  return vector->p_BLAPI_SHVerify(name, addr);
}

Here is the call graph for this function:

PRBool BLAPI_VerifySelf ( const char *  name)

Definition at line 1339 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return PR_FALSE;
  return vector->p_BLAPI_VerifySelf(libraryName);
}

Here is the call graph for this function:

DESContext* DES_AllocateContext ( void  )

Definition at line 182 of file desblapi.c.

{
    return PORT_ZNew(DESContext);
}

Here is the call graph for this function:

DESContext* DES_CreateContext ( const unsigned char *  key,
const unsigned char *  iv,
int  mode,
PRBool  encrypt 
)

Definition at line 247 of file desblapi.c.

{
    DESContext *cx = PORT_ZNew(DESContext);
    SECStatus rv   = DES_InitContext(cx, key, 0, iv, mode, encrypt, 0);

    if (rv != SECSuccess) {
       PORT_ZFree(cx, sizeof *cx);
       cx = NULL;
    }
    return cx;
}

Here is the call graph for this function:

SECStatus DES_Decrypt ( DESContext *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 287 of file desblapi.c.

{

    if (inLen < 0 || (inLen % 8) != 0 || maxOutLen < inLen || !cx || 
        cx->direction != DES_DECRYPT) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    cx->worker(cx, out, in, inLen);
    if (outLen)
       *outLen = inLen;
    return SECSuccess;
}

Here is the call graph for this function:

void DES_DestroyContext ( DESContext *  cx,
PRBool  freeit 
)

Definition at line 260 of file desblapi.c.

{
    if (cx) {
       memset(cx, 0, sizeof *cx);
       if (freeit)
           PORT_Free(cx);
    }
}

Here is the call graph for this function:

SECStatus DES_Encrypt ( DESContext *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 270 of file desblapi.c.

{

    if (inLen < 0 || (inLen % 8) != 0 || maxOutLen < inLen || !cx || 
        cx->direction != DES_ENCRYPT) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    cx->worker(cx, out, in, inLen);
    if (outLen)
       *outLen = inLen;
    return SECSuccess;
}

Here is the call graph for this function:

SECStatus DES_InitContext ( DESContext *  cx,
const unsigned char *  key,
unsigned int  keylen,
const unsigned char *  iv,
int  mode,
unsigned int  encrypt,
unsigned  int 
)

Definition at line 188 of file desblapi.c.

{
    DESDirection opposite;
    if (!cx) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    cx->direction = encrypt ? DES_ENCRYPT : DES_DECRYPT;
    opposite      = encrypt ? DES_DECRYPT : DES_ENCRYPT;
    switch (mode) {
    case NSS_DES:    /* DES ECB */
       DES_MakeSchedule( cx->ks0, key, cx->direction);
       cx->worker = &DES_ECB;
       break;

    case NSS_DES_EDE3:      /* DES EDE ECB */
       cx->worker = &DES_EDE3_ECB;
       if (encrypt) {
           DES_MakeSchedule(cx->ks0, key,      cx->direction);
           DES_MakeSchedule(cx->ks1, key +  8, opposite);
           DES_MakeSchedule(cx->ks2, key + 16, cx->direction);
       } else {
           DES_MakeSchedule(cx->ks2, key,      cx->direction);
           DES_MakeSchedule(cx->ks1, key +  8, opposite);
           DES_MakeSchedule(cx->ks0, key + 16, cx->direction);
       }
       break;

    case NSS_DES_CBC:       /* DES CBC */
       COPY8BTOHALF(cx->iv, iv);
       cx->worker = encrypt ? &DES_CBCEn : &DES_CBCDe;
       DES_MakeSchedule(cx->ks0, key, cx->direction);
       break;

    case NSS_DES_EDE3_CBC:  /* DES EDE CBC */
       COPY8BTOHALF(cx->iv, iv);
       if (encrypt) {
           cx->worker = &DES_EDE3CBCEn;
           DES_MakeSchedule(cx->ks0, key,      cx->direction);
           DES_MakeSchedule(cx->ks1, key +  8, opposite);
           DES_MakeSchedule(cx->ks2, key + 16, cx->direction);
       } else {
           cx->worker = &DES_EDE3CBCDe;
           DES_MakeSchedule(cx->ks2, key,      cx->direction);
           DES_MakeSchedule(cx->ks1, key +  8, opposite);
           DES_MakeSchedule(cx->ks0, key + 16, cx->direction);
       }
       break;

    default:
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    return SECSuccess;
}

Here is the call graph for this function:

SECStatus DH_Derive ( SECItem *  publicValue,
SECItem *  prime,
SECItem *  privateValue,
SECItem *  derivedSecret,
unsigned int  maxOutBytes 
)

Definition at line 211 of file dh.c.

{
    mp_int p, Xa, Yb, ZZ;
    mp_err err = MP_OKAY;
    unsigned int len = 0, nb;
    unsigned char *secret = NULL;
    if (!publicValue || !prime || !privateValue || !derivedSecret) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    memset(derivedSecret, 0, sizeof *derivedSecret);
    MP_DIGITS(&p)  = 0;
    MP_DIGITS(&Xa) = 0;
    MP_DIGITS(&Yb) = 0;
    MP_DIGITS(&ZZ) = 0;
    CHECK_MPI_OK( mp_init(&p)  );
    CHECK_MPI_OK( mp_init(&Xa) );
    CHECK_MPI_OK( mp_init(&Yb) );
    CHECK_MPI_OK( mp_init(&ZZ) );
    SECITEM_TO_MPINT(*publicValue,  &Yb);
    SECITEM_TO_MPINT(*privateValue, &Xa);
    SECITEM_TO_MPINT(*prime,        &p);
    /* ZZ = (Yb)**Xa mod p */
    CHECK_MPI_OK( mp_exptmod(&Yb, &Xa, &p, &ZZ) );
    /* number of bytes in the derived secret */
    len = mp_unsigned_octet_size(&ZZ);
    /* allocate a buffer which can hold the entire derived secret. */
    secret = PORT_Alloc(len);
    /* grab the derived secret */
    err = mp_to_unsigned_octets(&ZZ, secret, len);
    if (err >= 0) err = MP_OKAY;
    /* Take minimum of bytes requested and bytes in derived secret,
    ** if maxOutBytes is 0 take all of the bytes from the derived secret.
    */
    if (maxOutBytes > 0)
       nb = PR_MIN(len, maxOutBytes);
    else
       nb = len;
    SECITEM_AllocItem(NULL, derivedSecret, nb);
    memcpy(derivedSecret->data, secret, nb);
cleanup:
    mp_clear(&p);
    mp_clear(&Xa);
    mp_clear(&Yb);
    mp_clear(&ZZ);
    if (secret) {
       /* free the buffer allocated for the full secret. */
       PORT_ZFree(secret, len);
    }
    if (err) {
       MP_TO_SEC_ERROR(err);
       if (derivedSecret->data) 
           PORT_ZFree(derivedSecret->data, derivedSecret->len);
       return SECFailure;
    }
    return SECSuccess;
}

Here is the call graph for this function:

SECStatus DH_GenParam ( int  primeLen,
DHParams **  params 
)

Definition at line 57 of file dh.c.

{
    PRArenaPool *arena;
    DHParams *dhparams;
    unsigned char *pb = NULL;
    unsigned char *ab = NULL;
    unsigned long counter = 0;
    mp_int p, q, a, h, psub1, test;
    mp_err err = MP_OKAY;
    SECStatus rv = SECSuccess;
    if (!params || primeLen < 0) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    arena = PORT_NewArena(NSS_FREEBL_DEFAULT_CHUNKSIZE);
    if (!arena) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       return SECFailure;
    }
    dhparams = (DHParams *)PORT_ArenaZAlloc(arena, sizeof(DHParams));
    if (!dhparams) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       PORT_FreeArena(arena, PR_TRUE);
       return SECFailure;
    }
    dhparams->arena = arena;
    MP_DIGITS(&p) = 0;
    MP_DIGITS(&q) = 0;
    MP_DIGITS(&a) = 0;
    MP_DIGITS(&h) = 0;
    MP_DIGITS(&psub1) = 0;
    MP_DIGITS(&test) = 0;
    CHECK_MPI_OK( mp_init(&p) );
    CHECK_MPI_OK( mp_init(&q) );
    CHECK_MPI_OK( mp_init(&a) );
    CHECK_MPI_OK( mp_init(&h) );
    CHECK_MPI_OK( mp_init(&psub1) );
    CHECK_MPI_OK( mp_init(&test) );
    /* generate prime with MPI, uses Miller-Rabin to generate strong prime. */
    pb = PORT_Alloc(primeLen);
    CHECK_SEC_OK( RNG_GenerateGlobalRandomBytes(pb, primeLen) );
    pb[0]          |= 0x80; /* set high-order bit */
    pb[primeLen-1] |= 0x01; /* set low-order bit  */
    CHECK_MPI_OK( mp_read_unsigned_octets(&p, pb, primeLen) );
    CHECK_MPI_OK( mpp_make_prime(&p, primeLen * 8, PR_TRUE, &counter) );
    /* construct Sophie-Germain prime q = (p-1)/2. */
    CHECK_MPI_OK( mp_sub_d(&p, 1, &psub1) );
    CHECK_MPI_OK( mp_div_2(&psub1, &q)    );
    /* construct a generator from the prime. */
    ab = PORT_Alloc(primeLen);
    /* generate a candidate number a in p's field */
    CHECK_SEC_OK( RNG_GenerateGlobalRandomBytes(ab, primeLen) );
    CHECK_MPI_OK( mp_read_unsigned_octets(&a, ab, primeLen) );
    /* force a < p (note that quot(a/p) <= 1) */
    if ( mp_cmp(&a, &p) > 0 )
       CHECK_MPI_OK( mp_sub(&a, &p, &a) );
    do {
       /* check that a is in the range [2..p-1] */
       if ( mp_cmp_d(&a, 2) < 0 || mp_cmp(&a, &psub1) >= 0) {
           /* a is outside of the allowed range.  Set a=3 and keep going. */
            mp_set(&a, 3);
       }
       /* if a**q mod p != 1 then a is a generator */
       CHECK_MPI_OK( mp_exptmod(&a, &q, &p, &test) );
       if ( mp_cmp_d(&test, 1) != 0 )
           break;
       /* increment the candidate and try again. */
       CHECK_MPI_OK( mp_add_d(&a, 1, &a) );
    } while (PR_TRUE);
    MPINT_TO_SECITEM(&p, &dhparams->prime, arena);
    MPINT_TO_SECITEM(&a, &dhparams->base, arena);
    *params = dhparams;
cleanup:
    mp_clear(&p);
    mp_clear(&q);
    mp_clear(&a);
    mp_clear(&h);
    mp_clear(&psub1);
    mp_clear(&test);
    if (pb) PORT_ZFree(pb, primeLen);
    if (ab) PORT_ZFree(ab, primeLen);
    if (err) {
       MP_TO_SEC_ERROR(err);
       rv = SECFailure;
    }
    if (rv)
       PORT_FreeArena(arena, PR_TRUE);
    return rv;
}

Here is the call graph for this function:

SECStatus DH_NewKey ( DHParams *  params,
DHPrivateKey **  privKey 
)

Definition at line 148 of file dh.c.

{
    PRArenaPool *arena;
    DHPrivateKey *key;
    mp_int g, xa, p, Ya;
    mp_err   err = MP_OKAY;
    SECStatus rv = SECSuccess;
    if (!params || !privKey) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    arena = PORT_NewArena(NSS_FREEBL_DEFAULT_CHUNKSIZE);
    if (!arena) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       return SECFailure;
    }
    key = (DHPrivateKey *)PORT_ArenaZAlloc(arena, sizeof(DHPrivateKey));
    if (!key) {
       PORT_SetError(SEC_ERROR_NO_MEMORY);
       PORT_FreeArena(arena, PR_TRUE);
       return SECFailure;
    }
    key->arena = arena;
    MP_DIGITS(&g)  = 0;
    MP_DIGITS(&xa) = 0;
    MP_DIGITS(&p)  = 0;
    MP_DIGITS(&Ya) = 0;
    CHECK_MPI_OK( mp_init(&g)  );
    CHECK_MPI_OK( mp_init(&xa) );
    CHECK_MPI_OK( mp_init(&p)  );
    CHECK_MPI_OK( mp_init(&Ya) );
    /* Set private key's p */
    CHECK_SEC_OK( SECITEM_CopyItem(arena, &key->prime, &params->prime) );
    SECITEM_TO_MPINT(key->prime, &p);
    /* Set private key's g */
    CHECK_SEC_OK( SECITEM_CopyItem(arena, &key->base, &params->base) );
    SECITEM_TO_MPINT(key->base, &g);
    /* Generate private key xa */
    SECITEM_AllocItem(arena, &key->privateValue, DH_SECRET_KEY_LEN);
    RNG_GenerateGlobalRandomBytes(key->privateValue.data, 
                                  key->privateValue.len);
    SECITEM_TO_MPINT( key->privateValue, &xa );
    /* xa < p */
    CHECK_MPI_OK( mp_mod(&xa, &p, &xa) );
    /* Compute public key Ya = g ** xa mod p */
    CHECK_MPI_OK( mp_exptmod(&g, &xa, &p, &Ya) );
    MPINT_TO_SECITEM(&Ya, &key->publicValue, key->arena);
    *privKey = key;
cleanup:
    mp_clear(&g);
    mp_clear(&xa);
    mp_clear(&p);
    mp_clear(&Ya);
    if (err) {
       MP_TO_SEC_ERROR(err);
       rv = SECFailure;
    }
    if (rv)
       PORT_FreeArena(arena, PR_TRUE);
    return rv;
}

Here is the call graph for this function:

SECStatus DSA_NewKey ( const PQGParams *  params,
DSAPrivateKey **  privKey 
)

Definition at line 139 of file dsa.c.

{
    SECStatus rv;
    unsigned char seed[DSA_SUBPRIME_LEN];
    int retries = 10;
    int i;
    PRBool good;

    do {
       /* Generate seed bytes for x according to FIPS 186-1 appendix 3 */
       if (DSA_GenerateGlobalRandomBytes(seed, DSA_SUBPRIME_LEN,
                                     params->subPrime.data))
           return SECFailure;
       /* Disallow values of 0 and 1 for x. */
       good = PR_FALSE;
       for (i = 0; i < DSA_SUBPRIME_LEN-1; i++) {
           if (seed[i] != 0) {
              good = PR_TRUE;
              break;
           }
       }
       if (!good && seed[i] > 1) {
           good = PR_TRUE;
       }
    } while (!good && --retries > 0);

    if (!good) {
       PORT_SetError(SEC_ERROR_NEED_RANDOM);
       return SECFailure;
    }

    /* Generate a new DSA key using random seed. */
    rv = dsa_NewKey(params, privKey, seed);
    return rv;
}

Here is the call graph for this function:

SECStatus DSA_NewKeyFromSeed ( const PQGParams *  params,
const unsigned char *  seed,
DSAPrivateKey **  privKey 
)

Definition at line 177 of file dsa.c.

{
    SECStatus rv;
    rv = dsa_NewKey(params, privKey, seed);
    return rv;
}

Here is the call graph for this function:

SECStatus DSA_SignDigest ( DSAPrivateKey *  key,
SECItem *  signature,
const SECItem *  digest 
)

Definition at line 288 of file dsa.c.

{
    SECStatus rv;
    int       retries = 10;
    unsigned char kSeed[DSA_SUBPRIME_LEN];
    int       i;
    PRBool    good;

    PORT_SetError(0);
    do {
       rv = DSA_GenerateGlobalRandomBytes(kSeed, DSA_SUBPRIME_LEN, 
                                      key->params.subPrime.data);
       if (rv != SECSuccess) 
           break;
       /* Disallow a value of 0 for k. */
       good = PR_FALSE;
       for (i = 0; i < DSA_SUBPRIME_LEN; i++) {
           if (kSeed[i] != 0) {
              good = PR_TRUE;
              break;
           }
       }
       if (!good) {
           PORT_SetError(SEC_ERROR_NEED_RANDOM);
           rv = SECFailure;
           continue;
       }
       rv = dsa_SignDigest(key, signature, digest, kSeed);
    } while (rv != SECSuccess && PORT_GetError() == SEC_ERROR_NEED_RANDOM &&
            --retries > 0);
    return rv;
}

Here is the call graph for this function:

SECStatus DSA_SignDigestWithSeed ( DSAPrivateKey *  key,
SECItem *  signature,
const SECItem *  digest,
const unsigned char *  seed 
)

Definition at line 323 of file dsa.c.

{
    SECStatus rv;
    rv = dsa_SignDigest(key, signature, digest, seed);
    return rv;
}

Here is the call graph for this function:

SECStatus DSA_VerifyDigest ( DSAPublicKey *  key,
const SECItem *  signature,
const SECItem *  digest 
)

Definition at line 338 of file dsa.c.

{
    /* FIPS-compliance dictates that digest is a SHA1 hash. */
    mp_int p, q, g;      /* PQG parameters */
    mp_int r_, s_;       /* tuple (r', s') is received signature) */
    mp_int u1, u2, v, w; /* intermediate values used in verification */
    mp_int y;            /* public key */
    mp_err err;
    SECStatus verified = SECFailure;

    /* Check args. */
    if (!key || !signature || !digest ||
        (signature->len != DSA_SIGNATURE_LEN) ||
       (digest->len != SHA1_LENGTH)) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    /* Initialize MPI integers. */
    MP_DIGITS(&p)  = 0;
    MP_DIGITS(&q)  = 0;
    MP_DIGITS(&g)  = 0;
    MP_DIGITS(&y)  = 0;
    MP_DIGITS(&r_) = 0;
    MP_DIGITS(&s_) = 0;
    MP_DIGITS(&u1) = 0;
    MP_DIGITS(&u2) = 0;
    MP_DIGITS(&v)  = 0;
    MP_DIGITS(&w)  = 0;
    CHECK_MPI_OK( mp_init(&p)  );
    CHECK_MPI_OK( mp_init(&q)  );
    CHECK_MPI_OK( mp_init(&g)  );
    CHECK_MPI_OK( mp_init(&y)  );
    CHECK_MPI_OK( mp_init(&r_) );
    CHECK_MPI_OK( mp_init(&s_) );
    CHECK_MPI_OK( mp_init(&u1) );
    CHECK_MPI_OK( mp_init(&u2) );
    CHECK_MPI_OK( mp_init(&v)  );
    CHECK_MPI_OK( mp_init(&w)  );
    /*
    ** Convert stored PQG and public key into MPI integers.
    */
    SECITEM_TO_MPINT(key->params.prime,    &p);
    SECITEM_TO_MPINT(key->params.subPrime, &q);
    SECITEM_TO_MPINT(key->params.base,     &g);
    SECITEM_TO_MPINT(key->publicValue,     &y);
    /*
    ** Convert received signature (r', s') into MPI integers.
    */
    OCTETS_TO_MPINT(signature->data, &r_, DSA_SUBPRIME_LEN);
    OCTETS_TO_MPINT(signature->data + DSA_SUBPRIME_LEN, &s_, DSA_SUBPRIME_LEN);
    /*
    ** Verify that 0 < r' < q and 0 < s' < q
    */
    if (mp_cmp_z(&r_) <= 0 || mp_cmp_z(&s_) <= 0 ||
        mp_cmp(&r_, &q) >= 0 || mp_cmp(&s_, &q) >= 0) {
       /* err is zero here. */
       PORT_SetError(SEC_ERROR_BAD_SIGNATURE);
       goto cleanup; /* will return verified == SECFailure */
    }
    /*
    ** FIPS 186-1, Section 6, Step 1
    **
    ** w = (s')**-1 mod q
    */
    CHECK_MPI_OK( mp_invmod(&s_, &q, &w) );      /* w = (s')**-1 mod q */
    /*
    ** FIPS 186-1, Section 6, Step 2
    **
    ** u1 = ((SHA1(M')) * w) mod q
    */
    SECITEM_TO_MPINT(*digest, &u1);              /* u1 = SHA1(M')     */
    CHECK_MPI_OK( mp_mulmod(&u1, &w, &q, &u1) ); /* u1 = u1 * w mod q */
    /*
    ** FIPS 186-1, Section 6, Step 3
    **
    ** u2 = ((r') * w) mod q
    */
    CHECK_MPI_OK( mp_mulmod(&r_, &w, &q, &u2) );
    /*
    ** FIPS 186-1, Section 6, Step 4
    **
    ** v = ((g**u1 * y**u2) mod p) mod q
    */
    CHECK_MPI_OK( mp_exptmod(&g, &u1, &p, &g) ); /* g = g**u1 mod p */
    CHECK_MPI_OK( mp_exptmod(&y, &u2, &p, &y) ); /* y = y**u2 mod p */
    CHECK_MPI_OK(  mp_mulmod(&g, &y, &p, &v)  ); /* v = g * y mod p */
    CHECK_MPI_OK(     mp_mod(&v, &q, &v)      ); /* v = v mod q     */
    /*
    ** Verification:  v == r'
    */
    if (mp_cmp(&v, &r_)) {
       PORT_SetError(SEC_ERROR_BAD_SIGNATURE);
       verified = SECFailure; /* Signature failed to verify. */
    } else {
       verified = SECSuccess; /* Signature verified. */
    }
cleanup:
    mp_clear(&p);
    mp_clear(&q);
    mp_clear(&g);
    mp_clear(&y);
    mp_clear(&r_);
    mp_clear(&s_);
    mp_clear(&u1);
    mp_clear(&u2);
    mp_clear(&v);
    mp_clear(&w);
    if (err) {
       translate_mpi_error(err);
    }
    return verified;
}

Here is the call graph for this function:

SECStatus EC_NewKey ( ECParams *  params,
ECPrivateKey **  privKey 
)

Definition at line 418 of file ec.c.

{
    SECStatus rv = SECFailure;
#ifdef NSS_ENABLE_ECC
    int len;
    unsigned char *privKeyBytes = NULL;

    if (!ecParams) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    len = ecParams->order.len;
    privKeyBytes = ec_GenerateRandomPrivateKey(ecParams->order.data, len);
    if (privKeyBytes == NULL) goto cleanup;
    /* generate public key */
    CHECK_SEC_OK( ec_NewKey(ecParams, privKey, privKeyBytes, len) );

cleanup:
    if (privKeyBytes) {
       PORT_ZFree(privKeyBytes, len);
    }
#if EC_DEBUG
    printf("EC_NewKey returning %s\n", 
       (rv == SECSuccess) ? "success" : "failure");
#endif
#else
    PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG);
#endif /* NSS_ENABLE_ECC */
    
    return rv;
}

Here is the call graph for this function:

SECStatus EC_NewKeyFromSeed ( ECParams *  params,
ECPrivateKey **  privKey,
const unsigned char *  seed,
int  seedlen 
)

Definition at line 345 of file ec.c.

{
    SECStatus rv = SECFailure;
#ifdef NSS_ENABLE_ECC
    rv = ec_NewKey(ecParams, privKey, seed, seedlen);
#else
    PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG);
#endif /* NSS_ENABLE_ECC */
    return rv;
}

Here is the call graph for this function:

SECStatus EC_ValidatePublicKey ( ECParams *  params,
SECItem *  publicValue 
)

Definition at line 458 of file ec.c.

{
#ifdef NSS_ENABLE_ECC
    mp_int Px, Py;
    ECGroup *group = NULL;
    SECStatus rv = SECFailure;
    mp_err err = MP_OKAY;
    int len;

    if (!ecParams || !publicValue) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
       
    /* NOTE: We only support uncompressed points for now */
    len = (ecParams->fieldID.size + 7) >> 3;
    if (publicValue->data[0] != EC_POINT_FORM_UNCOMPRESSED) {
       PORT_SetError(SEC_ERROR_UNSUPPORTED_EC_POINT_FORM);
       return SECFailure;
    } else if (publicValue->len != (2 * len + 1)) {
       PORT_SetError(SEC_ERROR_BAD_KEY);
       return SECFailure;
    }

    MP_DIGITS(&Px) = 0;
    MP_DIGITS(&Py) = 0;
    CHECK_MPI_OK( mp_init(&Px) );
    CHECK_MPI_OK( mp_init(&Py) );

    /* Initialize Px and Py */
    CHECK_MPI_OK( mp_read_unsigned_octets(&Px, publicValue->data + 1, (mp_size) len) );
    CHECK_MPI_OK( mp_read_unsigned_octets(&Py, publicValue->data + 1 + len, (mp_size) len) );

    /* construct from named params */
    group = ECGroup_fromName(ecParams->name);
    if (group == NULL) {
       /*
        * ECGroup_fromName fails if ecParams->name is not a valid
        * ECCurveName value, or if we run out of memory, or perhaps
        * for other reasons.  Unfortunately if ecParams->name is a
        * valid ECCurveName value, we don't know what the right error
        * code should be because ECGroup_fromName doesn't return an
        * error code to the caller.  Set err to MP_UNDEF because
        * that's what ECGroup_fromName uses internally.
        */
       if ((ecParams->name <= ECCurve_noName) ||
           (ecParams->name >= ECCurve_pastLastCurve)) {
           err = MP_BADARG;
       } else {
           err = MP_UNDEF;
       }
       goto cleanup;
    }

    /* validate public point */
    if ((err = ECPoint_validate(group, &Px, &Py)) < MP_YES) {
       if (err == MP_NO) {
           PORT_SetError(SEC_ERROR_BAD_KEY);
           rv = SECFailure;
           err = MP_OKAY;  /* don't change the error code */
       }
       goto cleanup;
    }

    rv = SECSuccess;

cleanup:
    ECGroup_free(group);
    mp_clear(&Px);
    mp_clear(&Py);
    if (err) {
       MP_TO_SEC_ERROR(err);
       rv = SECFailure;
    }
    return rv;
#else
    PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG);
    return SECFailure;
#endif /* NSS_ENABLE_ECC */
}

Here is the call graph for this function:

SECStatus ECDH_Derive ( SECItem *  publicValue,
ECParams *  params,
SECItem *  privateValue,
PRBool  withCofactor,
SECItem *  derivedSecret 
)

Definition at line 550 of file ec.c.

{
    SECStatus rv = SECFailure;
#ifdef NSS_ENABLE_ECC
    unsigned int len = 0;
    SECItem pointQ = {siBuffer, NULL, 0};
    mp_int k; /* to hold the private value */
    mp_int cofactor;
    mp_err err = MP_OKAY;
#if EC_DEBUG
    int i;
#endif

    if (!publicValue || !ecParams || !privateValue || 
       !derivedSecret) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    memset(derivedSecret, 0, sizeof *derivedSecret);
    len = (ecParams->fieldID.size + 7) >> 3;  
    pointQ.len = 2*len + 1;
    if ((pointQ.data = PORT_Alloc(2*len + 1)) == NULL) goto cleanup;

    MP_DIGITS(&k) = 0;
    CHECK_MPI_OK( mp_init(&k) );
    CHECK_MPI_OK( mp_read_unsigned_octets(&k, privateValue->data, 
                                         (mp_size) privateValue->len) );

    if (withCofactor && (ecParams->cofactor != 1)) {
           /* multiply k with the cofactor */
           MP_DIGITS(&cofactor) = 0;
           CHECK_MPI_OK( mp_init(&cofactor) );
           mp_set(&cofactor, ecParams->cofactor);
           CHECK_MPI_OK( mp_mul(&k, &cofactor, &k) );
    }

    /* Multiply our private key and peer's public point */
    if ((ec_points_mul(ecParams, NULL, &k, publicValue, &pointQ) != SECSuccess) ||
       ec_point_at_infinity(&pointQ))
       goto cleanup;

    /* Allocate memory for the derived secret and copy
     * the x co-ordinate of pointQ into it.
     */
    SECITEM_AllocItem(NULL, derivedSecret, len);
    memcpy(derivedSecret->data, pointQ.data + 1, len);

    rv = SECSuccess;

#if EC_DEBUG
    printf("derived_secret:\n");
    for (i = 0; i < derivedSecret->len; i++) 
       printf("%02x:", derivedSecret->data[i]);
    printf("\n");
#endif

cleanup:
    mp_clear(&k);

    if (pointQ.data) {
       PORT_ZFree(pointQ.data, 2*len + 1);
    }
#else
    PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG);
#endif /* NSS_ENABLE_ECC */

    return rv;
}

Here is the call graph for this function:

SECStatus ECDSA_SignDigest ( ECPrivateKey *  key,
SECItem *  signature,
const SECItem *  digest 
)

Definition at line 831 of file ec.c.

{
    SECStatus rv = SECFailure;
#ifdef NSS_ENABLE_ECC
    int len;
    unsigned char *kBytes= NULL;

    if (!key) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    /* Generate random value k */
    len = key->ecParams.order.len;
    kBytes = ec_GenerateRandomPrivateKey(key->ecParams.order.data, len);
    if (kBytes == NULL) goto cleanup;

    /* Generate ECDSA signature with the specified k value */
    rv = ECDSA_SignDigestWithSeed(key, signature, digest, kBytes, len);

cleanup:    
    if (kBytes) {
       PORT_ZFree(kBytes, len);
    }

#if EC_DEBUG
    printf("ECDSA signing %s\n",
       (rv == SECSuccess) ? "succeeded" : "failed");
#endif
#else
    PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG);
#endif /* NSS_ENABLE_ECC */

    return rv;
}

Here is the call graph for this function:

SECStatus ECDSA_SignDigestWithSeed ( ECPrivateKey *  key,
SECItem *  signature,
const SECItem *  digest,
const unsigned char *  seed,
const int  seedlen 
)

Definition at line 629 of file ec.c.

{
    SECStatus rv = SECFailure;
#ifdef NSS_ENABLE_ECC
    mp_int x1;
    mp_int d, k;     /* private key, random integer */
    mp_int r, s;     /* tuple (r, s) is the signature */
    mp_int n;
    mp_err err = MP_OKAY;
    ECParams *ecParams = NULL;
    SECItem kGpoint = { siBuffer, NULL, 0};
    int flen = 0;    /* length in bytes of the field size */
    unsigned olen;   /* length in bytes of the base point order */

#if EC_DEBUG
    char mpstr[256];
#endif

    /* Initialize MPI integers. */
    /* must happen before the first potential call to cleanup */
    MP_DIGITS(&x1) = 0;
    MP_DIGITS(&d) = 0;
    MP_DIGITS(&k) = 0;
    MP_DIGITS(&r) = 0;
    MP_DIGITS(&s) = 0;
    MP_DIGITS(&n) = 0;

    /* Check args */
    if (!key || !signature || !digest || !kb || (kblen < 0)) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       goto cleanup;
    }

    ecParams = &(key->ecParams);
    flen = (ecParams->fieldID.size + 7) >> 3;
    olen = ecParams->order.len;  
    if (signature->data == NULL) {
       /* a call to get the signature length only */
       goto finish;
    }
    if (signature->len < 2*olen) {
       PORT_SetError(SEC_ERROR_OUTPUT_LEN);
       goto cleanup;
    }


    CHECK_MPI_OK( mp_init(&x1) );
    CHECK_MPI_OK( mp_init(&d) );
    CHECK_MPI_OK( mp_init(&k) );
    CHECK_MPI_OK( mp_init(&r) );
    CHECK_MPI_OK( mp_init(&s) );
    CHECK_MPI_OK( mp_init(&n) );

    SECITEM_TO_MPINT( ecParams->order, &n );
    SECITEM_TO_MPINT( key->privateValue, &d );
    CHECK_MPI_OK( mp_read_unsigned_octets(&k, kb, kblen) );
    /* Make sure k is in the interval [1, n-1] */
    if ((mp_cmp_z(&k) <= 0) || (mp_cmp(&k, &n) >= 0)) {
#if EC_DEBUG
        printf("k is outside [1, n-1]\n");
        mp_tohex(&k, mpstr);
       printf("k : %s \n", mpstr);
        mp_tohex(&n, mpstr);
       printf("n : %s \n", mpstr);
#endif
       PORT_SetError(SEC_ERROR_NEED_RANDOM);
       goto cleanup;
    }

    /* 
    ** ANSI X9.62, Section 5.3.2, Step 2
    **
    ** Compute kG
    */
    kGpoint.len = 2*flen + 1;
    kGpoint.data = PORT_Alloc(2*flen + 1);
    if ((kGpoint.data == NULL) ||
       (ec_points_mul(ecParams, &k, NULL, NULL, &kGpoint)
           != SECSuccess))
       goto cleanup;

    /* 
    ** ANSI X9.62, Section 5.3.3, Step 1
    **
    ** Extract the x co-ordinate of kG into x1
    */
    CHECK_MPI_OK( mp_read_unsigned_octets(&x1, kGpoint.data + 1, 
                                         (mp_size) flen) );

    /* 
    ** ANSI X9.62, Section 5.3.3, Step 2
    **
    ** r = x1 mod n  NOTE: n is the order of the curve
    */
    CHECK_MPI_OK( mp_mod(&x1, &n, &r) );

    /*
    ** ANSI X9.62, Section 5.3.3, Step 3
    **
    ** verify r != 0 
    */
    if (mp_cmp_z(&r) == 0) {
       PORT_SetError(SEC_ERROR_NEED_RANDOM);
       goto cleanup;
    }

    /*                                  
    ** ANSI X9.62, Section 5.3.3, Step 4
    **
    ** s = (k**-1 * (HASH(M) + d*r)) mod n 
    */
    SECITEM_TO_MPINT(*digest, &s);        /* s = HASH(M)     */

    /* In the definition of EC signing, digests are truncated
     * to the length of n in bits. 
     * (see SEC 1 "Elliptic Curve Digit Signature Algorithm" section 4.1.*/
    if (digest->len*8 > ecParams->fieldID.size) {
       mpl_rsh(&s,&s,digest->len*8 - ecParams->fieldID.size);
    }

#if EC_DEBUG
    mp_todecimal(&n, mpstr);
    printf("n : %s (dec)\n", mpstr);
    mp_todecimal(&d, mpstr);
    printf("d : %s (dec)\n", mpstr);
    mp_tohex(&x1, mpstr);
    printf("x1: %s\n", mpstr);
    mp_todecimal(&s, mpstr);
    printf("digest: %s (decimal)\n", mpstr);
    mp_todecimal(&r, mpstr);
    printf("r : %s (dec)\n", mpstr);
    mp_tohex(&r, mpstr);
    printf("r : %s\n", mpstr);
#endif

    CHECK_MPI_OK( mp_invmod(&k, &n, &k) );      /* k = k**-1 mod n */
    CHECK_MPI_OK( mp_mulmod(&d, &r, &n, &d) );  /* d = d * r mod n */
    CHECK_MPI_OK( mp_addmod(&s, &d, &n, &s) );  /* s = s + d mod n */
    CHECK_MPI_OK( mp_mulmod(&s, &k, &n, &s) );  /* s = s * k mod n */

#if EC_DEBUG
    mp_todecimal(&s, mpstr);
    printf("s : %s (dec)\n", mpstr);
    mp_tohex(&s, mpstr);
    printf("s : %s\n", mpstr);
#endif

    /*
    ** ANSI X9.62, Section 5.3.3, Step 5
    **
    ** verify s != 0
    */
    if (mp_cmp_z(&s) == 0) {
       PORT_SetError(SEC_ERROR_NEED_RANDOM);
       goto cleanup;
    }

   /*
    **
    ** Signature is tuple (r, s)
    */
    CHECK_MPI_OK( mp_to_fixlen_octets(&r, signature->data, olen) );
    CHECK_MPI_OK( mp_to_fixlen_octets(&s, signature->data + olen, olen) );
finish:
    signature->len = 2*olen;

    rv = SECSuccess;
    err = MP_OKAY;
cleanup:
    mp_clear(&x1);
    mp_clear(&d);
    mp_clear(&k);
    mp_clear(&r);
    mp_clear(&s);
    mp_clear(&n);

    if (kGpoint.data) {
       PORT_ZFree(kGpoint.data, 2*flen + 1);
    }

    if (err) {
       MP_TO_SEC_ERROR(err);
       rv = SECFailure;
    }

#if EC_DEBUG
    printf("ECDSA signing with seed %s\n",
       (rv == SECSuccess) ? "succeeded" : "failed");
#endif
#else
    PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG);
#endif /* NSS_ENABLE_ECC */

   return rv;
}

Here is the call graph for this function:

SECStatus ECDSA_VerifyDigest ( ECPublicKey *  key,
const SECItem *  signature,
const SECItem *  digest 
)

Definition at line 871 of file ec.c.

{
    SECStatus rv = SECFailure;
#ifdef NSS_ENABLE_ECC
    mp_int r_, s_;           /* tuple (r', s') is received signature) */
    mp_int c, u1, u2, v;     /* intermediate values used in verification */
    mp_int x1;
    mp_int n;
    mp_err err = MP_OKAY;
    ECParams *ecParams = NULL;
    SECItem pointC = { siBuffer, NULL, 0 };
    int slen;       /* length in bytes of a half signature (r or s) */
    int flen;       /* length in bytes of the field size */
    unsigned olen;  /* length in bytes of the base point order */

#if EC_DEBUG
    char mpstr[256];
    printf("ECDSA verification called\n");
#endif

    /* Initialize MPI integers. */
    /* must happen before the first potential call to cleanup */
    MP_DIGITS(&r_) = 0;
    MP_DIGITS(&s_) = 0;
    MP_DIGITS(&c) = 0;
    MP_DIGITS(&u1) = 0;
    MP_DIGITS(&u2) = 0;
    MP_DIGITS(&x1) = 0;
    MP_DIGITS(&v)  = 0;
    MP_DIGITS(&n)  = 0;

    /* Check args */
    if (!key || !signature || !digest) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       goto cleanup;
    }

    ecParams = &(key->ecParams);
    flen = (ecParams->fieldID.size + 7) >> 3;  
    olen = ecParams->order.len;  
    if (signature->len == 0 || signature->len%2 != 0 ||
       signature->len > 2*olen) {
       PORT_SetError(SEC_ERROR_INPUT_LEN);
       goto cleanup;
    }
    slen = signature->len/2;

    SECITEM_AllocItem(NULL, &pointC, 2*flen + 1);
    if (pointC.data == NULL)
       goto cleanup;

    CHECK_MPI_OK( mp_init(&r_) );
    CHECK_MPI_OK( mp_init(&s_) );
    CHECK_MPI_OK( mp_init(&c)  );
    CHECK_MPI_OK( mp_init(&u1) );
    CHECK_MPI_OK( mp_init(&u2) );
    CHECK_MPI_OK( mp_init(&x1)  );
    CHECK_MPI_OK( mp_init(&v)  );
    CHECK_MPI_OK( mp_init(&n)  );

    /*
    ** Convert received signature (r', s') into MPI integers.
    */
    CHECK_MPI_OK( mp_read_unsigned_octets(&r_, signature->data, slen) );
    CHECK_MPI_OK( mp_read_unsigned_octets(&s_, signature->data + slen, slen) );
                                          
    /* 
    ** ANSI X9.62, Section 5.4.2, Steps 1 and 2
    **
    ** Verify that 0 < r' < n and 0 < s' < n
    */
    SECITEM_TO_MPINT(ecParams->order, &n);
    if (mp_cmp_z(&r_) <= 0 || mp_cmp_z(&s_) <= 0 ||
        mp_cmp(&r_, &n) >= 0 || mp_cmp(&s_, &n) >= 0) {
       PORT_SetError(SEC_ERROR_BAD_SIGNATURE);
       goto cleanup; /* will return rv == SECFailure */
    }

    /*
    ** ANSI X9.62, Section 5.4.2, Step 3
    **
    ** c = (s')**-1 mod n
    */
    CHECK_MPI_OK( mp_invmod(&s_, &n, &c) );      /* c = (s')**-1 mod n */

    /*
    ** ANSI X9.62, Section 5.4.2, Step 4
    **
    ** u1 = ((HASH(M')) * c) mod n
    */
    SECITEM_TO_MPINT(*digest, &u1);                  /* u1 = HASH(M)     */

    /* In the definition of EC signing, digests are truncated
     * to the length of n in bits. 
     * (see SEC 1 "Elliptic Curve Digit Signature Algorithm" section 4.1.*/
    if (digest->len*8 > ecParams->fieldID.size) {  /* u1 = HASH(M')     */
       mpl_rsh(&u1,&u1,digest->len*8- ecParams->fieldID.size);
    }

#if EC_DEBUG
    mp_todecimal(&r_, mpstr);
    printf("r_: %s (dec)\n", mpstr);
    mp_todecimal(&s_, mpstr);
    printf("s_: %s (dec)\n", mpstr);
    mp_todecimal(&c, mpstr);
    printf("c : %s (dec)\n", mpstr);
    mp_todecimal(&u1, mpstr);
    printf("digest: %s (dec)\n", mpstr);
#endif

    CHECK_MPI_OK( mp_mulmod(&u1, &c, &n, &u1) );  /* u1 = u1 * c mod n */

    /*
    ** ANSI X9.62, Section 5.4.2, Step 4
    **
    ** u2 = ((r') * c) mod n
    */
    CHECK_MPI_OK( mp_mulmod(&r_, &c, &n, &u2) );

    /*
    ** ANSI X9.62, Section 5.4.3, Step 1
    **
    ** Compute u1*G + u2*Q
    ** Here, A = u1.G     B = u2.Q    and   C = A + B
    ** If the result, C, is the point at infinity, reject the signature
    */
    if (ec_points_mul(ecParams, &u1, &u2, &key->publicValue, &pointC)
       != SECSuccess) {
       rv = SECFailure;
       goto cleanup;
    }
    if (ec_point_at_infinity(&pointC)) {
       PORT_SetError(SEC_ERROR_BAD_SIGNATURE);
       rv = SECFailure;
       goto cleanup;
    }

    CHECK_MPI_OK( mp_read_unsigned_octets(&x1, pointC.data + 1, flen) );

    /*
    ** ANSI X9.62, Section 5.4.4, Step 2
    **
    ** v = x1 mod n
    */
    CHECK_MPI_OK( mp_mod(&x1, &n, &v) );

#if EC_DEBUG
    mp_todecimal(&r_, mpstr);
    printf("r_: %s (dec)\n", mpstr);
    mp_todecimal(&v, mpstr);
    printf("v : %s (dec)\n", mpstr);
#endif

    /*
    ** ANSI X9.62, Section 5.4.4, Step 3
    **
    ** Verification:  v == r'
    */
    if (mp_cmp(&v, &r_)) {
       PORT_SetError(SEC_ERROR_BAD_SIGNATURE);
       rv = SECFailure; /* Signature failed to verify. */
    } else {
       rv = SECSuccess; /* Signature verified. */
    }

#if EC_DEBUG
    mp_todecimal(&u1, mpstr);
    printf("u1: %s (dec)\n", mpstr);
    mp_todecimal(&u2, mpstr);
    printf("u2: %s (dec)\n", mpstr);
    mp_tohex(&x1, mpstr);
    printf("x1: %s\n", mpstr);
    mp_todecimal(&v, mpstr);
    printf("v : %s (dec)\n", mpstr);
#endif

cleanup:
    mp_clear(&r_);
    mp_clear(&s_);
    mp_clear(&c);
    mp_clear(&u1);
    mp_clear(&u2);
    mp_clear(&x1);
    mp_clear(&v);
    mp_clear(&n);

    if (pointC.data) SECITEM_FreeItem(&pointC, PR_FALSE);
    if (err) {
       MP_TO_SEC_ERROR(err);
       rv = SECFailure;
    }

#if EC_DEBUG
    printf("ECDSA verification %s\n",
       (rv == SECSuccess) ? "succeeded" : "failed");
#endif
#else
    PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG);
#endif /* NSS_ENABLE_ECC */

    return rv;
}

Here is the call graph for this function:

SECStatus FIPS186Change_GenerateX ( unsigned char *  XKEY,
const unsigned char *  XSEEDj,
unsigned char *  x_j 
)

Definition at line 1641 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_FIPS186Change_GenerateX)(XKEY, XSEEDj, x_j);
}

Here is the call graph for this function:

SECStatus FIPS186Change_ReduceModQForDSA ( const unsigned char *  w,
const unsigned char *  q,
unsigned char *  xj 
)

Definition at line 1650 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_FIPS186Change_ReduceModQForDSA)(w, q, xj);
}

Here is the call graph for this function:

const SECHashObject* HASH_GetRawHashObject ( HASH_HashType  hashType)

Definition at line 1564 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_HASH_GetRawHashObject)(hashType);
}

Here is the call graph for this function:

SECStatus KEA_Derive ( SECItem *  prime,
SECItem *  public1,
SECItem *  public2,
SECItem *  private1,
SECItem *  private2,
SECItem *  derivedSecret 
)

Definition at line 274 of file dh.c.

{
    mp_int p, Y, R, r, x, t, u, w;
    mp_err err;
    unsigned char *secret = NULL;
    unsigned int len = 0, offset;
    if (!prime || !public1 || !public2 || !private1 || !private2 ||
        !derivedSecret) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    memset(derivedSecret, 0, sizeof *derivedSecret);
    MP_DIGITS(&p) = 0;
    MP_DIGITS(&Y) = 0;
    MP_DIGITS(&R) = 0;
    MP_DIGITS(&r) = 0;
    MP_DIGITS(&x) = 0;
    MP_DIGITS(&t) = 0;
    MP_DIGITS(&u) = 0;
    MP_DIGITS(&w) = 0;
    CHECK_MPI_OK( mp_init(&p) );
    CHECK_MPI_OK( mp_init(&Y) );
    CHECK_MPI_OK( mp_init(&R) );
    CHECK_MPI_OK( mp_init(&r) );
    CHECK_MPI_OK( mp_init(&x) );
    CHECK_MPI_OK( mp_init(&t) );
    CHECK_MPI_OK( mp_init(&u) );
    CHECK_MPI_OK( mp_init(&w) );
    SECITEM_TO_MPINT(*prime,    &p);
    SECITEM_TO_MPINT(*public1,  &Y);
    SECITEM_TO_MPINT(*public2,  &R);
    SECITEM_TO_MPINT(*private1, &r);
    SECITEM_TO_MPINT(*private2, &x);
    /* t = DH(Y, r, p) = Y ** r mod p */
    CHECK_MPI_OK( mp_exptmod(&Y, &r, &p, &t) );
    /* u = DH(R, x, p) = R ** x mod p */
    CHECK_MPI_OK( mp_exptmod(&R, &x, &p, &u) );
    /* w = (t + u) mod p */
    CHECK_MPI_OK( mp_addmod(&t, &u, &p, &w) );
    /* allocate a buffer for the full derived secret */
    len = mp_unsigned_octet_size(&w);
    secret = PORT_Alloc(len);
    /* grab the secret */
    err = mp_to_unsigned_octets(&w, secret, len);
    if (err > 0) err = MP_OKAY;
    /* allocate output buffer */
    SECITEM_AllocItem(NULL, derivedSecret, KEA_DERIVED_SECRET_LEN);
    memset(derivedSecret->data, 0, derivedSecret->len);
    /* copy in the 128 lsb of the secret */
    if (len >= KEA_DERIVED_SECRET_LEN) {
       memcpy(derivedSecret->data, secret + (len - KEA_DERIVED_SECRET_LEN),
              KEA_DERIVED_SECRET_LEN);
    } else {
       offset = KEA_DERIVED_SECRET_LEN - len;
       memcpy(derivedSecret->data + offset, secret, len);
    }
cleanup:
    mp_clear(&p);
    mp_clear(&Y);
    mp_clear(&R);
    mp_clear(&r);
    mp_clear(&x);
    mp_clear(&t);
    mp_clear(&u);
    mp_clear(&w);
    if (secret)
       PORT_ZFree(secret, len);
    if (err) {
       MP_TO_SEC_ERROR(err);
       return SECFailure;
    }
    return SECSuccess;
}

Here is the call graph for this function:

PRBool KEA_Verify ( SECItem *  Y,
SECItem *  prime,
SECItem *  subPrime 
)

Definition at line 354 of file dh.c.

{
    mp_int p, q, y, r;
    mp_err err;
    int cmp = 1;  /* default is false */
    if (!Y || !prime || !subPrime) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    MP_DIGITS(&p) = 0;
    MP_DIGITS(&q) = 0;
    MP_DIGITS(&y) = 0;
    MP_DIGITS(&r) = 0;
    CHECK_MPI_OK( mp_init(&p) );
    CHECK_MPI_OK( mp_init(&q) );
    CHECK_MPI_OK( mp_init(&y) );
    CHECK_MPI_OK( mp_init(&r) );
    SECITEM_TO_MPINT(*prime,    &p);
    SECITEM_TO_MPINT(*subPrime, &q);
    SECITEM_TO_MPINT(*Y,        &y);
    /* compute r = y**q mod p */
    CHECK_MPI_OK( mp_exptmod(&y, &q, &p, &r) );
    /* compare to 1 */
    cmp = mp_cmp_d(&r, 1);
cleanup:
    mp_clear(&p);
    mp_clear(&q);
    mp_clear(&y);
    mp_clear(&r);
    if (err) {
       MP_TO_SEC_ERROR(err);
       return PR_FALSE;
    }
    return (cmp == 0) ? PR_TRUE : PR_FALSE;
}

Here is the call graph for this function:

void MD2_Begin ( MD2Context *  cx)

Definition at line 784 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_MD2_Begin)(cx);
}

Here is the call graph for this function:

void MD2_Clone ( MD2Context *  dest,
MD2Context *  src 
)

Definition at line 1507 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_MD2_Clone)(dest, src);
}

Here is the call graph for this function:

void MD2_DestroyContext ( MD2Context *  cx,
PRBool  freeit 
)

Definition at line 776 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_MD2_DestroyContext)(cx, freeit);
}

Here is the call graph for this function:

void MD2_End ( MD2Context *  cx,
unsigned char *  digest,
unsigned int digestLen,
unsigned int  maxDigestLen 
)

Definition at line 800 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_MD2_End)(cx, digest, digestLen, maxDigestLen);
}

Here is the call graph for this function:

SECStatus MD2_Flatten ( MD2Context *  cx,
unsigned char *  space 
)

Definition at line 817 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_MD2_Flatten)(cx, space);
}

Here is the call graph for this function:

unsigned int MD2_FlattenSize ( MD2Context *  cx)

Definition at line 809 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return 0;
  return (vector->p_MD2_FlattenSize)(cx);
}

Here is the call graph for this function:

SECStatus MD2_Hash ( unsigned char *  dest,
const char *  src 
)

Definition at line 760 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_MD2_Hash)(dest, src);
}

Here is the call graph for this function:

MD2Context* MD2_NewContext ( void  )

Definition at line 768 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_MD2_NewContext)();
}

Here is the call graph for this function:

MD2Context* MD2_Resurrect ( unsigned char *  space,
void arg 
)

Definition at line 825 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_MD2_Resurrect)(space, arg);
}

Here is the call graph for this function:

void MD2_Update ( MD2Context *  cx,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 792 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_MD2_Update)(cx, input, inputLen);
}

Here is the call graph for this function:

Definition at line 703 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_MD5_Begin)(cx);
}

Here is the call graph for this function:

void MD5_Clone ( MD5Context dest,
MD5Context src 
)

Definition at line 1515 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_MD5_Clone)(dest, src);
}

Here is the call graph for this function:

void MD5_DestroyContext ( MD5Context cx,
PRBool  freeit 
)

Definition at line 695 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_MD5_DestroyContext)(cx, freeit);
}

Here is the call graph for this function:

void MD5_End ( MD5Context cx,
unsigned char *  digest,
unsigned int digestLen,
unsigned int  maxDigestLen 
)

Definition at line 719 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_MD5_End)(cx, digest, digestLen, maxDigestLen);
}

Here is the call graph for this function:

SECStatus MD5_Flatten ( MD5Context cx,
unsigned char *  space 
)

Definition at line 736 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_MD5_Flatten)(cx, space);
}

Here is the call graph for this function:

unsigned int MD5_FlattenSize ( MD5Context cx)

Definition at line 728 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return 0;
  return (vector->p_MD5_FlattenSize)(cx);
}

Here is the call graph for this function:

SECStatus MD5_Hash ( unsigned char *  dest,
const char *  src 
)

Definition at line 671 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_MD5_Hash)(dest, src);
}

Here is the call graph for this function:

SECStatus MD5_HashBuf ( unsigned char *  dest,
const unsigned char *  src,
uint32  src_length 
)

Definition at line 679 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_MD5_HashBuf)(dest, src, src_length);
}

Here is the call graph for this function:

Definition at line 687 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_MD5_NewContext)();
}

Here is the call graph for this function:

MD5Context* MD5_Resurrect ( unsigned char *  space,
void arg 
)

Definition at line 744 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_MD5_Resurrect)(space, arg);
}

Here is the call graph for this function:

Definition at line 752 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_MD5_TraceState)(cx);
}

Here is the call graph for this function:

void MD5_Update ( MD5Context cx,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 711 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_MD5_Update)(cx, input, inputLen);
}

Here is the call graph for this function:

SECStatus PQG_ParamGen ( unsigned int  j,
PQGParams **  pParams,
PQGVerify **  pVfy 
)

Definition at line 956 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_PQG_ParamGen)(j, pParams, pVfy); 
}

Here is the call graph for this function:

SECStatus PQG_ParamGenSeedLen ( unsigned int  j,
unsigned int  seedBytes,
PQGParams **  pParams,
PQGVerify **  pVfy 
)

Definition at line 964 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_PQG_ParamGenSeedLen)(j, seedBytes, pParams, pVfy);
}

Here is the call graph for this function:

SECStatus PQG_VerifyParams ( const PQGParams *  params,
const PQGVerify *  vfy,
SECStatus result 
)

Definition at line 973 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_PQG_VerifyParams)(params, vfy, result);
}

Here is the call graph for this function:

RC2Context* RC2_AllocateContext ( void  )

Definition at line 134 of file alg2268.c.

{
    return PORT_ZNew(RC2Context);
}

Here is the call graph for this function:

RC2Context* RC2_CreateContext ( const unsigned char *  key,
unsigned int  len,
const unsigned char *  iv,
int  mode,
unsigned  effectiveKeyLen 
)

Definition at line 218 of file alg2268.c.

{
    RC2Context *cx = PORT_ZNew(RC2Context);
    if (cx) {
       SECStatus rv = RC2_InitContext(cx, key, len, iv, mode, efLen8, 0);
       if (rv != SECSuccess) {
           RC2_DestroyContext(cx, PR_TRUE);
           cx = NULL;
       }
    }
    return cx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus RC2_Decrypt ( RC2Context *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 494 of file alg2268.c.

{
    SECStatus rv = SECSuccess;
    if (inputLen) {
       if (inputLen % RC2_BLOCK_SIZE) {
           PORT_SetError(SEC_ERROR_INPUT_LEN);
           return SECFailure;
       }
       if (maxOutputLen < inputLen) {
           PORT_SetError(SEC_ERROR_OUTPUT_LEN);
           return SECFailure;
       }
       rv = (*cx->dec)(cx, output, input, inputLen);
    }
    if (rv == SECSuccess) {
       *outputLen = inputLen;
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void RC2_DestroyContext ( RC2Context *  cx,
PRBool  freeit 
)

Definition at line 238 of file alg2268.c.

{
    if (cx) {
       memset(cx, 0, sizeof *cx);
       if (freeit) {
           PORT_Free(cx);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus RC2_Encrypt ( RC2Context *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 461 of file alg2268.c.

{
    SECStatus rv = SECSuccess;
    if (inputLen) {
       if (inputLen % RC2_BLOCK_SIZE) {
           PORT_SetError(SEC_ERROR_INPUT_LEN);
           return SECFailure;
       }
       if (maxOutputLen < inputLen) {
           PORT_SetError(SEC_ERROR_OUTPUT_LEN);
           return SECFailure;
       }
       rv = (*cx->enc)(cx, output, input, inputLen);
    }
    if (rv == SECSuccess) {
       *outputLen = inputLen;
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus RC2_InitContext ( RC2Context *  cx,
const unsigned char *  key,
unsigned int  keylen,
const unsigned char *  iv,
int  mode,
unsigned int  effectiveKeyLen,
unsigned  int 
)

Definition at line 139 of file alg2268.c.

{
    PRUint8    *L,*L2;
    int         i;
#if !defined(IS_LITTLE_ENDIAN)
    PRUint16    tmpS;
#endif
    PRUint8     tmpB;

    if (!key || !cx || !len || len > (sizeof cx->B) || 
       efLen8 > (sizeof cx->B)) {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }
    if (mode == NSS_RC2) {
       /* groovy */
    } else if (mode == NSS_RC2_CBC) {
       if (!input) {
           PORT_SetError(SEC_ERROR_INVALID_ARGS);
           return SECFailure;
       }
    } else {
       PORT_SetError(SEC_ERROR_INVALID_ARGS);
       return SECFailure;
    }

    if (mode == NSS_RC2_CBC) {
       cx->enc = & rc2_EncryptCBC;
       cx->dec = & rc2_DecryptCBC;
       LOAD(cx->iv.s);
    } else {
       cx->enc = & rc2_EncryptECB;
       cx->dec = & rc2_DecryptECB;
    }

    /* Step 0. Copy key into table. */
    memcpy(cx->B, key, len);

    /* Step 1. Compute all values to the right of the key. */
    L2 = cx->B;
    L = L2 + len;
    tmpB = L[-1];
    for (i = (sizeof cx->B) - len; i > 0; --i) {
       *L++ = tmpB = S[ (PRUint8)(tmpB + *L2++) ];
    }

    /* step 2. Adjust left most byte of effective key. */
    i = (sizeof cx->B) - efLen8;
    L = cx->B + i;
    *L = tmpB = S[*L];                           /* mask is always 0xff */

    /* step 3. Recompute all values to the left of effective key. */
    L2 = --L + efLen8;
    while(L >= cx->B) {
       *L-- = tmpB = S[ tmpB ^ *L2-- ];
    }

#if !defined(IS_LITTLE_ENDIAN)
    for (i = 63; i >= 0; --i) {
        SWAPK(i);           /* candidate for unrolling */
    }
#endif
    return SECSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function:

RC4Context* RC4_AllocateContext ( void  )

Definition at line 144 of file arcfour.c.

{
    return PORT_ZNew(RC4Context);
}

Here is the call graph for this function:

Here is the caller graph for this function:

RC4Context* RC4_CreateContext ( const unsigned char *  key,
int  len 
)

Definition at line 198 of file arcfour.c.

{
    RC4Context *cx = RC4_AllocateContext();
    if (cx) {
       SECStatus rv = RC4_InitContext(cx, key, len, NULL, 0, 0, 0);
       if (rv != SECSuccess) {
           PORT_ZFree(cx, sizeof(*cx));
           cx = NULL;
       }
    }
    return cx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus RC4_Decrypt ( RC4Context *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 615 of file arcfour.c.

{
       PORT_Assert(maxOutputLen >= inputLen);
       if (maxOutputLen < inputLen) {
              PORT_SetError(SEC_ERROR_INVALID_ARGS);
              return SECFailure;
       }
       /* decrypt and encrypt are same operation. */
#if defined(NSS_BEVAND_ARCFOUR)
       ARCFOUR(cx, inputLen, input, output);
        *outputLen = inputLen;
       return SECSuccess;
#elif defined( CONVERT_TO_WORDS )
       /* Convert the byte-stream to a word-stream */
       return rc4_wordconv(cx, output, outputLen, maxOutputLen, input, inputLen);
#else
       /* Operate on bytes, but unroll the main loop */
       return rc4_unrolled(cx, output, outputLen, maxOutputLen, input, inputLen);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void RC4_DestroyContext ( RC4Context *  cx,
PRBool  freeit 
)

Definition at line 212 of file arcfour.c.

{
       if (freeit)
              PORT_ZFree(cx, sizeof(*cx));
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus RC4_Encrypt ( RC4Context *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 593 of file arcfour.c.

{
       PORT_Assert(maxOutputLen >= inputLen);
       if (maxOutputLen < inputLen) {
              PORT_SetError(SEC_ERROR_INVALID_ARGS);
              return SECFailure;
       }
#if defined(NSS_BEVAND_ARCFOUR)
       ARCFOUR(cx, inputLen, input, output);
        *outputLen = inputLen;
       return SECSuccess;
#elif defined( CONVERT_TO_WORDS )
       /* Convert the byte-stream to a word-stream */
       return rc4_wordconv(cx, output, outputLen, maxOutputLen, input, inputLen);
#else
       /* Operate on bytes, but unroll the main loop */
       return rc4_unrolled(cx, output, outputLen, maxOutputLen, input, inputLen);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus RC4_InitContext ( RC4Context *  cx,
const unsigned char *  key,
unsigned int  keylen,
const unsigned char *  ,
int  ,
unsigned  int,
unsigned  int 
)

Definition at line 150 of file arcfour.c.

{
       int i;
       PRUint8 j, tmp;
       PRUint8 K[256];
       PRUint8 *L;
       /* verify the key length. */
       PORT_Assert(len > 0 && len < ARCFOUR_STATE_SIZE);
       if (len < 0 || len >= ARCFOUR_STATE_SIZE) {
              PORT_SetError(SEC_ERROR_INVALID_ARGS);
              return SECFailure;
       }
       if (cx == NULL) {
           PORT_SetError(SEC_ERROR_INVALID_ARGS);
           return SECFailure;
       }
       /* Initialize the state using array indices. */
       memcpy(cx->S, Kinit, sizeof cx->S);
       /* Fill in K repeatedly with values from key. */
       L = K;
       for (i = sizeof K; i > len; i-= len) {
              memcpy(L, key, len);
              L += len;
       }
       memcpy(L, key, i);
       /* Stir the state of the generator.  At this point it is assumed
        * that the key is the size of the state buffer.  If this is not
        * the case, the key bytes are repeated to fill the buffer.
        */
       j = 0;
#define ARCFOUR_STATE_STIR(ii) \
       j = j + cx->S[ii] + K[ii]; \
       SWAP(cx->S[ii], cx->S[j]);
       for (i=0; i<ARCFOUR_STATE_SIZE; i++) {
              ARCFOUR_STATE_STIR(i);
       }
       cx->i = 0;
       cx->j = 0;
       return SECSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function:

RC5Context* RC5_AllocateContext ( void  )
RC5Context* RC5_CreateContext ( const SECItem *  key,
unsigned int  rounds,
unsigned int  wordSize,
const unsigned char *  iv,
int  mode 
)

Definition at line 60 of file arcfive.c.

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus RC5_Decrypt ( RC5Context *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 110 of file arcfive.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void RC5_DestroyContext ( RC5Context *  cx,
PRBool  freeit 
)

Definition at line 73 of file arcfive.c.

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus RC5_Encrypt ( RC5Context *  cx,
unsigned char *  output,
unsigned int outputLen,
unsigned int  maxOutputLen,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 90 of file arcfive.c.

Here is the call graph for this function:

Here is the caller graph for this function:

SECStatus RC5_InitContext ( RC5Context *  cx,
const unsigned char *  key,
unsigned int  keylen,
const unsigned char *  iv,
int  mode,
unsigned int  rounds,
unsigned int  wordSize 
)
SECStatus RNG_GenerateGlobalRandomBytes ( void dest,
size_t  len 
)

Definition at line 940 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_RNG_GenerateGlobalRandomBytes)(dest, len);
}

Here is the call graph for this function:

SECStatus RNG_RandomUpdate ( const void data,
size_t  bytes 
)

Definition at line 932 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_RNG_RandomUpdate)(data, bytes);
}

Here is the call graph for this function:

Definition at line 924 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_RNG_RNGInit)();
}

Here is the call graph for this function:

Definition at line 948 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_RNG_RNGShutdown)();
}

Here is the call graph for this function:

Definition at line 1632 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_RNG_SystemInfoForRNG)();

}
SEC_BEGIN_PROTOS RSAPrivateKey* RSA_NewKey ( int  keySizeInBits,
SECItem *  publicExponent 
)

Definition at line 342 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_RSA_NewKey)(keySizeInBits, publicExponent);
}

Here is the call graph for this function:

SECStatus RSA_PrivateKeyCheck ( RSAPrivateKey *  key)

Definition at line 380 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_RSA_PrivateKeyCheck)(key);
}

Here is the call graph for this function:

SECStatus RSA_PrivateKeyOp ( RSAPrivateKey *  key,
unsigned char *  output,
const unsigned char *  input 
)

Definition at line 360 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_RSA_PrivateKeyOp)(key, output, input);
}

Here is the call graph for this function:

SECStatus RSA_PrivateKeyOpDoubleChecked ( RSAPrivateKey *  key,
unsigned char *  output,
const unsigned char *  input 
)

Definition at line 370 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_RSA_PrivateKeyOpDoubleChecked)(key, output, input);
}

Here is the call graph for this function:

SECStatus RSA_PublicKeyOp ( RSAPublicKey *  key,
unsigned char *  output,
const unsigned char *  input 
)

Definition at line 350 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_RSA_PublicKeyOp)(key, output, input);
}

Here is the call graph for this function:

void SHA1_Begin ( SHA1Context *  cx)

Definition at line 866 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA1_Begin)(cx);
}

Here is the call graph for this function:

void SHA1_Clone ( SHA1Context *  dest,
SHA1Context *  src 
)

Definition at line 1523 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_SHA1_Clone)(dest, src);
}

Here is the call graph for this function:

void SHA1_DestroyContext ( SHA1Context *  cx,
PRBool  freeit 
)

Definition at line 858 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA1_DestroyContext)(cx, freeit);
}

Here is the call graph for this function:

void SHA1_End ( SHA1Context *  cx,
unsigned char *  digest,
unsigned int digestLen,
unsigned int  maxDigestLen 
)

Definition at line 883 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA1_End)(cx, digest, digestLen, maxDigestLen);
}

Here is the call graph for this function:

SECStatus SHA1_Flatten ( SHA1Context *  cx,
unsigned char *  space 
)

Definition at line 908 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA1_Flatten)(cx, space);
}

Here is the call graph for this function:

unsigned int SHA1_FlattenSize ( SHA1Context *  cx)

Definition at line 900 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return 0;
  return (vector->p_SHA1_FlattenSize)(cx);
}

Here is the call graph for this function:

SECStatus SHA1_Hash ( unsigned char *  dest,
const char *  src 
)

Definition at line 834 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA1_Hash)(dest, src);
}

Here is the call graph for this function:

SECStatus SHA1_HashBuf ( unsigned char *  dest,
const unsigned char *  src,
uint32  src_length 
)

Definition at line 842 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA1_HashBuf)(dest, src, src_length);
}

Here is the call graph for this function:

SHA1Context* SHA1_NewContext ( void  )

Definition at line 850 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_SHA1_NewContext)();
}

Here is the call graph for this function:

SHA1Context* SHA1_Resurrect ( unsigned char *  space,
void arg 
)

Definition at line 916 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_SHA1_Resurrect)(space, arg);
}

Here is the call graph for this function:

void SHA1_TraceState ( SHA1Context *  cx)

Definition at line 892 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA1_TraceState)(cx);
}

Here is the call graph for this function:

void SHA1_Update ( SHA1Context *  cx,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 874 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA1_Update)(cx, input, inputLen);
}

Here is the call graph for this function:

void SHA256_Begin ( SHA256Context *  cx)

Definition at line 1047 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA256_Begin)(cx);
}

Here is the call graph for this function:

void SHA256_Clone ( SHA256Context *  dest,
SHA256Context *  src 
)

Definition at line 1531 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_SHA256_Clone)(dest, src);
}

Here is the call graph for this function:

void SHA256_DestroyContext ( SHA256Context *  cx,
PRBool  freeit 
)

Definition at line 1039 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA256_DestroyContext)(cx, freeit);
}

Here is the call graph for this function:

void SHA256_End ( SHA256Context *  cx,
unsigned char *  digest,
unsigned int digestLen,
unsigned int  maxDigestLen 
)

Definition at line 1064 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA256_End)(cx, digest, digestLen, maxDigestLen);
}

Here is the call graph for this function:

SECStatus SHA256_Flatten ( SHA256Context *  cx,
unsigned char *  space 
)

Definition at line 1089 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA256_Flatten)(cx, space);
}

Here is the call graph for this function:

unsigned int SHA256_FlattenSize ( SHA256Context *  cx)

Definition at line 1081 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return 0;
  return (vector->p_SHA256_FlattenSize)(cx);
}

Here is the call graph for this function:

SECStatus SHA256_Hash ( unsigned char *  dest,
const char *  src 
)

Definition at line 1015 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA256_Hash)(dest, src);
}

Here is the call graph for this function:

SECStatus SHA256_HashBuf ( unsigned char *  dest,
const unsigned char *  src,
uint32  src_length 
)

Definition at line 1023 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA256_HashBuf)(dest, src, src_length);
}

Here is the call graph for this function:

SHA256Context* SHA256_NewContext ( void  )

Definition at line 1031 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_SHA256_NewContext)();
}

Here is the call graph for this function:

SHA256Context* SHA256_Resurrect ( unsigned char *  space,
void arg 
)

Definition at line 1097 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_SHA256_Resurrect)(space, arg);
}

Here is the call graph for this function:

void SHA256_TraceState ( SHA256Context *  cx)

Definition at line 1073 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA256_TraceState)(cx);
}

Here is the call graph for this function:

void SHA256_Update ( SHA256Context *  cx,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 1055 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA256_Update)(cx, input, inputLen);
}

Here is the call graph for this function:

void SHA384_Begin ( SHA384Context *  cx)

Definition at line 1228 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA384_Begin)(cx);
}

Here is the call graph for this function:

void SHA384_Clone ( SHA384Context *  dest,
SHA384Context *  src 
)

Definition at line 1539 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_SHA384_Clone)(dest, src);
}

Here is the call graph for this function:

void SHA384_DestroyContext ( SHA384Context *  cx,
PRBool  freeit 
)

Definition at line 1220 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA384_DestroyContext)(cx, freeit);
}

Here is the call graph for this function:

void SHA384_End ( SHA384Context *  cx,
unsigned char *  digest,
unsigned int digestLen,
unsigned int  maxDigestLen 
)

Definition at line 1245 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA384_End)(cx, digest, digestLen, maxDigestLen);
}

Here is the call graph for this function:

SECStatus SHA384_Flatten ( SHA384Context *  cx,
unsigned char *  space 
)

Definition at line 1270 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA384_Flatten)(cx, space);
}

Here is the call graph for this function:

unsigned int SHA384_FlattenSize ( SHA384Context *  cx)

Definition at line 1262 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return 0;
  return (vector->p_SHA384_FlattenSize)(cx);
}

Here is the call graph for this function:

SECStatus SHA384_Hash ( unsigned char *  dest,
const char *  src 
)

Definition at line 1196 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA384_Hash)(dest, src);
}

Here is the call graph for this function:

SECStatus SHA384_HashBuf ( unsigned char *  dest,
const unsigned char *  src,
uint32  src_length 
)

Definition at line 1204 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA384_HashBuf)(dest, src, src_length);
}

Here is the call graph for this function:

SHA384Context* SHA384_NewContext ( void  )

Definition at line 1212 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_SHA384_NewContext)();
}

Here is the call graph for this function:

SHA384Context* SHA384_Resurrect ( unsigned char *  space,
void arg 
)

Definition at line 1278 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_SHA384_Resurrect)(space, arg);
}

Here is the call graph for this function:

void SHA384_TraceState ( SHA384Context *  cx)

Definition at line 1254 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA384_TraceState)(cx);
}

Here is the call graph for this function:

void SHA384_Update ( SHA384Context *  cx,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 1236 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA384_Update)(cx, input, inputLen);
}

Here is the call graph for this function:

void SHA512_Begin ( SHA512Context *  cx)

Definition at line 1137 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA512_Begin)(cx);
}

Here is the call graph for this function:

void SHA512_Clone ( SHA512Context *  dest,
SHA512Context *  src 
)

Definition at line 1547 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return;
  (vector->p_SHA512_Clone)(dest, src);
}

Here is the call graph for this function:

void SHA512_DestroyContext ( SHA512Context *  cx,
PRBool  freeit 
)

Definition at line 1129 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA512_DestroyContext)(cx, freeit);
}

Here is the call graph for this function:

void SHA512_End ( SHA512Context *  cx,
unsigned char *  digest,
unsigned int digestLen,
unsigned int  maxDigestLen 
)

Definition at line 1154 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA512_End)(cx, digest, digestLen, maxDigestLen);
}

Here is the call graph for this function:

SECStatus SHA512_Flatten ( SHA512Context *  cx,
unsigned char *  space 
)

Definition at line 1179 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA512_Flatten)(cx, space);
}

Here is the call graph for this function:

unsigned int SHA512_FlattenSize ( SHA512Context *  cx)

Definition at line 1171 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return 0;
  return (vector->p_SHA512_FlattenSize)(cx);
}

Here is the call graph for this function:

SECStatus SHA512_Hash ( unsigned char *  dest,
const char *  src 
)

Definition at line 1105 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA512_Hash)(dest, src);
}

Here is the call graph for this function:

SECStatus SHA512_HashBuf ( unsigned char *  dest,
const unsigned char *  src,
uint32  src_length 
)

Definition at line 1113 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_SHA512_HashBuf)(dest, src, src_length);
}

Here is the call graph for this function:

SHA512Context* SHA512_NewContext ( void  )

Definition at line 1121 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_SHA512_NewContext)();
}

Here is the call graph for this function:

SHA512Context* SHA512_Resurrect ( unsigned char *  space,
void arg 
)

Definition at line 1187 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return NULL;
  return (vector->p_SHA512_Resurrect)(space, arg);
}

Here is the call graph for this function:

void SHA512_TraceState ( SHA512Context *  cx)

Definition at line 1163 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA512_TraceState)(cx);
}

Here is the call graph for this function:

void SHA512_Update ( SHA512Context *  cx,
const unsigned char *  input,
unsigned int  inputLen 
)

Definition at line 1145 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return ;
  (vector->p_SHA512_Update)(cx, input, inputLen);
}

Here is the call graph for this function:

SECStatus TLS_PRF ( const SECItem *  secret,
const char *  label,
SECItem *  seed,
SECItem *  result,
PRBool  isFIPS 
)

Definition at line 1555 of file loader.c.

{
  if (!vector && PR_SUCCESS != freebl_RunLoaderOnce())
      return SECFailure;
  return (vector->p_TLS_PRF)(secret, label, seed, result, isFIPS);
}

Here is the call graph for this function: