Back to index

lightning-sunbird  0.9+nobinonly
loader.h
Go to the documentation of this file.
00001 /*
00002  * loader.h - load platform dependent DSO containing freebl implementation.
00003  *
00004  * ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is the Netscape security libraries.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 2000
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 /* $Id: loader.h,v 1.17.2.1 2006/02/01 21:24:45 wtchang%redhat.com Exp $ */
00041 
00042 #ifndef _LOADER_H_
00043 #define _LOADER_H_ 1
00044 
00045 #include "blapi.h"
00046 
00047 #define FREEBL_VERSION 0x0309
00048 
00049 struct FREEBLVectorStr {
00050 
00051   unsigned short length;  /* of this struct in bytes */
00052   unsigned short version; /* of this struct. */
00053 
00054   RSAPrivateKey * (* p_RSA_NewKey)(int         keySizeInBits,
00055                              SECItem *   publicExponent);
00056 
00057   SECStatus (* p_RSA_PublicKeyOp) (RSAPublicKey *   key,
00058                              unsigned char *  output,
00059                              const unsigned char *  input);
00060 
00061   SECStatus (* p_RSA_PrivateKeyOp)(RSAPrivateKey *  key,
00062                               unsigned char *  output,
00063                               const unsigned char *  input);
00064 
00065   SECStatus (* p_DSA_NewKey)(const PQGParams *    params, 
00066                           DSAPrivateKey **      privKey);
00067 
00068   SECStatus (* p_DSA_SignDigest)(DSAPrivateKey *   key,
00069                             SECItem *         signature,
00070                             const SECItem *   digest);
00071 
00072   SECStatus (* p_DSA_VerifyDigest)(DSAPublicKey *  key,
00073                               const SECItem *  signature,
00074                               const SECItem *  digest);
00075 
00076   SECStatus (* p_DSA_NewKeyFromSeed)(const PQGParams *params, 
00077                                  const unsigned char * seed,
00078                                      DSAPrivateKey **privKey);
00079 
00080   SECStatus (* p_DSA_SignDigestWithSeed)(DSAPrivateKey * key,
00081                                     SECItem *             signature,
00082                                     const SECItem *       digest,
00083                                     const unsigned char * seed);
00084 
00085  SECStatus (* p_DH_GenParam)(int primeLen, DHParams ** params);
00086 
00087  SECStatus (* p_DH_NewKey)(DHParams *           params, 
00088                            DHPrivateKey **       privKey);
00089 
00090  SECStatus (* p_DH_Derive)(SECItem *    publicValue, 
00091                          SECItem *    prime, 
00092                         SECItem *    privateValue, 
00093                         SECItem *    derivedSecret,
00094                         unsigned int maxOutBytes);
00095 
00096  SECStatus (* p_KEA_Derive)(SECItem *prime, 
00097                             SECItem *public1, 
00098                             SECItem *public2, 
00099                          SECItem *private1, 
00100                          SECItem *private2,
00101                          SECItem *derivedSecret);
00102 
00103  PRBool (* p_KEA_Verify)(SECItem *Y, SECItem *prime, SECItem *subPrime);
00104 
00105  RC4Context * (* p_RC4_CreateContext)(const unsigned char *key, int len);
00106 
00107  void (* p_RC4_DestroyContext)(RC4Context *cx, PRBool freeit);
00108 
00109  SECStatus (* p_RC4_Encrypt)(RC4Context *cx, unsigned char *output,
00110                          unsigned int *outputLen, unsigned int maxOutputLen,
00111                          const unsigned char *input, unsigned int inputLen);
00112 
00113  SECStatus (* p_RC4_Decrypt)(RC4Context *cx, unsigned char *output,
00114                          unsigned int *outputLen, unsigned int maxOutputLen,
00115                          const unsigned char *input, unsigned int inputLen);
00116 
00117  RC2Context * (* p_RC2_CreateContext)(const unsigned char *key, 
00118                      unsigned int len, const unsigned char *iv, 
00119                    int mode, unsigned effectiveKeyLen);
00120 
00121  void (* p_RC2_DestroyContext)(RC2Context *cx, PRBool freeit);
00122 
00123  SECStatus (* p_RC2_Encrypt)(RC2Context *cx, unsigned char *output,
00124                          unsigned int *outputLen, unsigned int maxOutputLen,
00125                          const unsigned char *input, unsigned int inputLen);
00126 
00127  SECStatus (* p_RC2_Decrypt)(RC2Context *cx, unsigned char *output,
00128                          unsigned int *outputLen, unsigned int maxOutputLen,
00129                          const unsigned char *input, unsigned int inputLen);
00130 
00131  RC5Context *(* p_RC5_CreateContext)(const SECItem *key, unsigned int rounds,
00132                      unsigned int wordSize, const unsigned char *iv, int mode);
00133 
00134  void (* p_RC5_DestroyContext)(RC5Context *cx, PRBool freeit);
00135 
00136  SECStatus (* p_RC5_Encrypt)(RC5Context *cx, unsigned char *output,
00137                             unsigned int *outputLen, unsigned int maxOutputLen,
00138                             const unsigned char *input, unsigned int inputLen);
00139 
00140  SECStatus (* p_RC5_Decrypt)(RC5Context *cx, unsigned char *output,
00141                             unsigned int *outputLen, unsigned int maxOutputLen,
00142                             const unsigned char *input, unsigned int inputLen);
00143 
00144  DESContext *(* p_DES_CreateContext)(const unsigned char *key, 
00145                                      const unsigned char *iv,
00146                                  int mode, PRBool encrypt);
00147 
00148  void (* p_DES_DestroyContext)(DESContext *cx, PRBool freeit);
00149 
00150  SECStatus (* p_DES_Encrypt)(DESContext *cx, unsigned char *output,
00151                          unsigned int *outputLen, unsigned int maxOutputLen,
00152                          const unsigned char *input, unsigned int inputLen);
00153 
00154  SECStatus (* p_DES_Decrypt)(DESContext *cx, unsigned char *output,
00155                          unsigned int *outputLen, unsigned int maxOutputLen,
00156                          const unsigned char *input, unsigned int inputLen);
00157 
00158  AESContext * (* p_AES_CreateContext)(const unsigned char *key, 
00159                             const unsigned char *iv, 
00160                          int mode, int encrypt, unsigned int keylen, 
00161                          unsigned int blocklen);
00162 
00163  void (* p_AES_DestroyContext)(AESContext *cx, PRBool freeit);
00164 
00165  SECStatus (* p_AES_Encrypt)(AESContext *cx, unsigned char *output,
00166                          unsigned int *outputLen, unsigned int maxOutputLen,
00167                          const unsigned char *input, unsigned int inputLen);
00168 
00169  SECStatus (* p_AES_Decrypt)(AESContext *cx, unsigned char *output,
00170                          unsigned int *outputLen, unsigned int maxOutputLen,
00171                          const unsigned char *input, unsigned int inputLen);
00172 
00173  SECStatus (* p_MD5_Hash)(unsigned char *dest, const char *src);
00174 
00175  SECStatus (* p_MD5_HashBuf)(unsigned char *dest, const unsigned char *src,
00176                           uint32 src_length);
00177 
00178  MD5Context *(* p_MD5_NewContext)(void);
00179 
00180  void (* p_MD5_DestroyContext)(MD5Context *cx, PRBool freeit);
00181 
00182  void (* p_MD5_Begin)(MD5Context *cx);
00183 
00184  void (* p_MD5_Update)(MD5Context *cx,
00185                      const unsigned char *input, unsigned int inputLen);
00186 
00187  void (* p_MD5_End)(MD5Context *cx, unsigned char *digest,
00188                   unsigned int *digestLen, unsigned int maxDigestLen);
00189 
00190  unsigned int (* p_MD5_FlattenSize)(MD5Context *cx);
00191 
00192  SECStatus (* p_MD5_Flatten)(MD5Context *cx,unsigned char *space);
00193 
00194  MD5Context * (* p_MD5_Resurrect)(unsigned char *space, void *arg);
00195 
00196  void (* p_MD5_TraceState)(MD5Context *cx);
00197 
00198  SECStatus (* p_MD2_Hash)(unsigned char *dest, const char *src);
00199 
00200  MD2Context *(* p_MD2_NewContext)(void);
00201 
00202  void (* p_MD2_DestroyContext)(MD2Context *cx, PRBool freeit);
00203 
00204  void (* p_MD2_Begin)(MD2Context *cx);
00205 
00206  void (* p_MD2_Update)(MD2Context *cx,
00207                      const unsigned char *input, unsigned int inputLen);
00208 
00209  void (* p_MD2_End)(MD2Context *cx, unsigned char *digest,
00210                   unsigned int *digestLen, unsigned int maxDigestLen);
00211 
00212  unsigned int (* p_MD2_FlattenSize)(MD2Context *cx);
00213 
00214  SECStatus (* p_MD2_Flatten)(MD2Context *cx,unsigned char *space);
00215 
00216  MD2Context * (* p_MD2_Resurrect)(unsigned char *space, void *arg);
00217 
00218  SECStatus (* p_SHA1_Hash)(unsigned char *dest, const char *src);
00219 
00220  SECStatus (* p_SHA1_HashBuf)(unsigned char *dest, const unsigned char *src,
00221                            uint32 src_length);
00222 
00223  SHA1Context *(* p_SHA1_NewContext)(void);
00224 
00225  void (* p_SHA1_DestroyContext)(SHA1Context *cx, PRBool freeit);
00226 
00227  void (* p_SHA1_Begin)(SHA1Context *cx);
00228 
00229  void (* p_SHA1_Update)(SHA1Context *cx, const unsigned char *input,
00230                      unsigned int inputLen);
00231 
00232  void (* p_SHA1_End)(SHA1Context *cx, unsigned char *digest,
00233                    unsigned int *digestLen, unsigned int maxDigestLen);
00234 
00235  void (* p_SHA1_TraceState)(SHA1Context *cx);
00236 
00237  unsigned int (* p_SHA1_FlattenSize)(SHA1Context *cx);
00238 
00239  SECStatus (* p_SHA1_Flatten)(SHA1Context *cx,unsigned char *space);
00240 
00241  SHA1Context * (* p_SHA1_Resurrect)(unsigned char *space, void *arg);
00242 
00243  SECStatus (* p_RNG_RNGInit)(void);
00244 
00245  SECStatus (* p_RNG_RandomUpdate)(const void *data, size_t bytes);
00246 
00247  SECStatus (* p_RNG_GenerateGlobalRandomBytes)(void *dest, size_t len);
00248 
00249  void  (* p_RNG_RNGShutdown)(void);
00250 
00251  SECStatus (* p_PQG_ParamGen)(unsigned int j, PQGParams **pParams,  
00252                              PQGVerify **pVfy);    
00253 
00254  SECStatus (* p_PQG_ParamGenSeedLen)( unsigned int j, unsigned int seedBytes, 
00255                                      PQGParams **pParams, PQGVerify **pVfy); 
00256 
00257  SECStatus (* p_PQG_VerifyParams)(const PQGParams *params, 
00258                                   const PQGVerify *vfy, SECStatus *result);
00259 
00260   /* Version 3.001 came to here */
00261 
00262   SECStatus (* p_RSA_PrivateKeyOpDoubleChecked)(RSAPrivateKey *key,
00263                               unsigned char *output,
00264                               const unsigned char *input);
00265 
00266   SECStatus (* p_RSA_PrivateKeyCheck)(RSAPrivateKey *key);
00267 
00268   void (* p_BL_Cleanup)(void);
00269 
00270   /* Version 3.002 came to here */
00271 
00272  SHA256Context *(* p_SHA256_NewContext)(void);
00273  void (* p_SHA256_DestroyContext)(SHA256Context *cx, PRBool freeit);
00274  void (* p_SHA256_Begin)(SHA256Context *cx);
00275  void (* p_SHA256_Update)(SHA256Context *cx, const unsigned char *input,
00276                      unsigned int inputLen);
00277  void (* p_SHA256_End)(SHA256Context *cx, unsigned char *digest,
00278                    unsigned int *digestLen, unsigned int maxDigestLen);
00279  SECStatus (* p_SHA256_HashBuf)(unsigned char *dest, const unsigned char *src,
00280                            uint32 src_length);
00281  SECStatus (* p_SHA256_Hash)(unsigned char *dest, const char *src);
00282  void (* p_SHA256_TraceState)(SHA256Context *cx);
00283  unsigned int (* p_SHA256_FlattenSize)(SHA256Context *cx);
00284  SECStatus (* p_SHA256_Flatten)(SHA256Context *cx,unsigned char *space);
00285  SHA256Context * (* p_SHA256_Resurrect)(unsigned char *space, void *arg);
00286 
00287  SHA512Context *(* p_SHA512_NewContext)(void);
00288  void (* p_SHA512_DestroyContext)(SHA512Context *cx, PRBool freeit);
00289  void (* p_SHA512_Begin)(SHA512Context *cx);
00290  void (* p_SHA512_Update)(SHA512Context *cx, const unsigned char *input,
00291                      unsigned int inputLen);
00292  void (* p_SHA512_End)(SHA512Context *cx, unsigned char *digest,
00293                    unsigned int *digestLen, unsigned int maxDigestLen);
00294  SECStatus (* p_SHA512_HashBuf)(unsigned char *dest, const unsigned char *src,
00295                            uint32 src_length);
00296  SECStatus (* p_SHA512_Hash)(unsigned char *dest, const char *src);
00297  void (* p_SHA512_TraceState)(SHA512Context *cx);
00298  unsigned int (* p_SHA512_FlattenSize)(SHA512Context *cx);
00299  SECStatus (* p_SHA512_Flatten)(SHA512Context *cx,unsigned char *space);
00300  SHA512Context * (* p_SHA512_Resurrect)(unsigned char *space, void *arg);
00301 
00302  SHA384Context *(* p_SHA384_NewContext)(void);
00303  void (* p_SHA384_DestroyContext)(SHA384Context *cx, PRBool freeit);
00304  void (* p_SHA384_Begin)(SHA384Context *cx);
00305  void (* p_SHA384_Update)(SHA384Context *cx, const unsigned char *input,
00306                      unsigned int inputLen);
00307  void (* p_SHA384_End)(SHA384Context *cx, unsigned char *digest,
00308                    unsigned int *digestLen, unsigned int maxDigestLen);
00309  SECStatus (* p_SHA384_HashBuf)(unsigned char *dest, const unsigned char *src,
00310                            uint32 src_length);
00311  SECStatus (* p_SHA384_Hash)(unsigned char *dest, const char *src);
00312  void (* p_SHA384_TraceState)(SHA384Context *cx);
00313  unsigned int (* p_SHA384_FlattenSize)(SHA384Context *cx);
00314  SECStatus (* p_SHA384_Flatten)(SHA384Context *cx,unsigned char *space);
00315  SHA384Context * (* p_SHA384_Resurrect)(unsigned char *space, void *arg);
00316 
00317   /* Version 3.003 came to here */
00318 
00319  AESKeyWrapContext * (* p_AESKeyWrap_CreateContext)(const unsigned char *key, 
00320                    const unsigned char *iv, int encrypt, unsigned int keylen);
00321 
00322  void (* p_AESKeyWrap_DestroyContext)(AESKeyWrapContext *cx, PRBool freeit);
00323 
00324  SECStatus (* p_AESKeyWrap_Encrypt)(AESKeyWrapContext *cx, 
00325             unsigned char *output,
00326             unsigned int *outputLen, unsigned int maxOutputLen,
00327             const unsigned char *input, unsigned int inputLen);
00328 
00329  SECStatus (* p_AESKeyWrap_Decrypt)(AESKeyWrapContext *cx, 
00330             unsigned char *output,
00331             unsigned int *outputLen, unsigned int maxOutputLen,
00332             const unsigned char *input, unsigned int inputLen);
00333 
00334   /* Version 3.004 came to here */
00335 
00336  PRBool (*p_BLAPI_SHVerify)(const char *name, PRFuncPtr addr);
00337  PRBool (*p_BLAPI_VerifySelf)(const char *name);
00338 
00339   /* Version 3.005 came to here */
00340 
00341  SECStatus (* p_EC_NewKey)(ECParams *           params, 
00342                            ECPrivateKey **       privKey);
00343 
00344  SECStatus (* p_EC_NewKeyFromSeed)(ECParams *   params, 
00345                              ECPrivateKey **     privKey,
00346                              const unsigned char * seed,
00347                              int                seedlen);
00348 
00349  SECStatus (* p_EC_ValidatePublicKey)(ECParams *   params, 
00350                           SECItem *               publicValue);
00351 
00352  SECStatus (* p_ECDH_Derive)(SECItem *          publicValue, 
00353                              ECParams *         params,
00354                              SECItem *          privateValue,
00355                              PRBool             withCofactor,
00356                              SECItem *          derivedSecret);
00357 
00358  SECStatus (* p_ECDSA_SignDigest)(ECPrivateKey * key,
00359                              SECItem *          signature,
00360                              const SECItem *    digest);
00361 
00362  SECStatus (* p_ECDSA_VerifyDigest)(ECPublicKey * key,
00363                              const SECItem *    signature,
00364                              const SECItem *    digest);
00365 
00366  SECStatus (* p_ECDSA_SignDigestWithSeed)(ECPrivateKey * key,
00367                              SECItem *          signature,
00368                              const SECItem *    digest,
00369                              const unsigned char * seed,
00370                              const int          seedlen);
00371 
00372   /* Version 3.006 came to here */
00373 
00374   /* no modification to FREEBLVectorStr itself 
00375    * but ECParamStr was modified 
00376    */
00377 
00378   /* Version 3.007 came to here */
00379 
00380  SECStatus (* p_AES_InitContext)(AESContext *cx,
00381                              const unsigned char *key, 
00382                              unsigned int keylen, 
00383                              const unsigned char *iv, 
00384                              int mode, 
00385                              unsigned int encrypt,
00386                              unsigned int blocklen);
00387  SECStatus (* p_AESKeyWrap_InitContext)(AESKeyWrapContext *cx,
00388                              const unsigned char *key, 
00389                              unsigned int keylen, 
00390                              const unsigned char *iv, 
00391                              int mode, 
00392                              unsigned int encrypt,
00393                              unsigned int blocklen);
00394  SECStatus (* p_DES_InitContext)(DESContext *cx,
00395                              const unsigned char *key, 
00396                              unsigned int keylen,
00397                              const unsigned char *iv, 
00398                              int mode,
00399                              unsigned int encrypt,
00400                              unsigned int );
00401  SECStatus (* p_RC2_InitContext)(RC2Context *cx,
00402                              const unsigned char *key, 
00403                              unsigned int keylen,
00404                              const unsigned char *iv, 
00405                              int mode, 
00406                              unsigned int effectiveKeyLen,
00407                              unsigned int );
00408  SECStatus (* p_RC4_InitContext)(RC4Context *cx, 
00409                              const unsigned char *key, 
00410                              unsigned int keylen,
00411                              const unsigned char *, 
00412                              int, 
00413                              unsigned int ,
00414                              unsigned int );
00415 
00416  AESContext *(*p_AES_AllocateContext)(void);
00417  AESKeyWrapContext *(*p_AESKeyWrap_AllocateContext)(void);
00418  DESContext *(*p_DES_AllocateContext)(void);
00419  RC2Context *(*p_RC2_AllocateContext)(void);
00420  RC4Context *(*p_RC4_AllocateContext)(void);
00421 
00422  void (* p_MD2_Clone)(MD2Context *dest, MD2Context *src);
00423  void (* p_MD5_Clone)(MD5Context *dest, MD5Context *src);
00424  void (* p_SHA1_Clone)(SHA1Context *dest, SHA1Context *src);
00425  void (* p_SHA256_Clone)(SHA256Context *dest, SHA256Context *src);
00426  void (* p_SHA384_Clone)(SHA384Context *dest, SHA384Context *src);
00427  void (* p_SHA512_Clone)(SHA512Context *dest, SHA512Context *src);
00428 
00429  SECStatus (* p_TLS_PRF)(const SECItem *secret, const char *label, 
00430                        SECItem *seed, SECItem *result, PRBool isFIPS);
00431 
00432  const SECHashObject *(* p_HASH_GetRawHashObject)(HASH_HashType hashType);
00433 
00434  HMACContext * (* p_HMAC_Create)(const SECHashObject *hashObj, 
00435                              const unsigned char *secret, 
00436                              unsigned int secret_len, PRBool isFIPS);
00437  SECStatus (* p_HMAC_Init)(HMACContext *cx, const SECHashObject *hash_obj, 
00438                         const unsigned char *secret, 
00439                         unsigned int secret_len, PRBool isFIPS);
00440  void (* p_HMAC_Begin)(HMACContext *cx);
00441  void  (* p_HMAC_Update)(HMACContext *cx, const unsigned char *data, 
00442                       unsigned int data_len);
00443  HMACContext * (* p_HMAC_Clone)(HMACContext *cx);
00444  SECStatus (* p_HMAC_Finish)(HMACContext *cx, unsigned char *result, 
00445                           unsigned int *result_len, 
00446                           unsigned int max_result_len);
00447  void (* p_HMAC_Destroy)(HMACContext *cx, PRBool freeit);
00448 
00449  void (* p_RNG_SystemInfoForRNG)(void);
00450 
00451   /* Version 3.008 came to here */
00452 
00453  SECStatus (* p_FIPS186Change_GenerateX)(unsigned char *XKEY,
00454                                          const unsigned char *XSEEDj,
00455                                          unsigned char *x_j);
00456  SECStatus (* p_FIPS186Change_ReduceModQForDSA)(const unsigned char *w,
00457                                                 const unsigned char *q,
00458                                                 unsigned char *xj);
00459 
00460   /* Version 3.009 came to here */
00461 };
00462 
00463 typedef struct FREEBLVectorStr FREEBLVector;
00464 
00465 SEC_BEGIN_PROTOS
00466 
00467 typedef const FREEBLVector * FREEBLGetVectorFn(void);
00468 
00469 extern FREEBLGetVectorFn FREEBL_GetVector;
00470 
00471 SEC_END_PROTOS
00472 
00473 #endif