RSA BSAFE Crypto-C

Cryptographic Components for C

Search

atypes.h

Go to the documentation of this file.
00001 /* $Id: atypes.h,v 1.34 2004/12/14 04:38:27 sparki Exp $ */
00002 /*
00003  * Copyright (C) 1998-2004 RSA Security Inc. All rights reserved.
00004  *
00005  * This work contains proprietary information of RSA Security.
00006  * Distribution is limited to authorized licensees of RSA
00007  * Security. Any unauthorized reproduction, distribution or
00008  * modification of this work is strictly prohibited.
00009  */
00010 
00016 #ifndef _ATYPES_H_
00017 #define _ATYPES_H_ 1
00018 
00019 #include "bsfmacro.h"
00020 #include "bsfplatf.h"
00021 
00022 #include "aglobal.h"
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00029 typedef struct {
00030   unsigned char *key;              /* An 8-Byte Data
00031                                     * Encryption Standard (DES) key
00032                                     */
00033   unsigned char *inputWhitener;    /* An 8-Byte input whitener */
00034   unsigned char *outputWhitener;   /* An eight-Byte output whitener */
00035 } A_DESX_KEY;
00036 
00038 typedef struct {
00039   ITEM prime;                        /* The prime */
00040   ITEM base;                         /* The base */
00041   unsigned int exponentBits;
00042 } A_DH_KEY_AGREE_PARAMS;
00043 
00045 typedef struct {
00046   unsigned int primeBits;
00047   unsigned int exponentBits;
00048 } A_DH_PARAM_GEN_PARAMS;
00049 
00050 typedef struct {
00051   unsigned int primeBits;
00052   unsigned int subPrimeBits;
00053   unsigned int seedBytesLen;
00054 } A_PQG_PARAM_GEN_PARAMS;
00055 
00056 
00057 typedef struct {
00058   ITEM prime;                           /* The prime (p) */
00059   ITEM subPrime;                        /* The sub prime (q) */
00060   ITEM base;                            /* The base (g) */
00061   ITEM seed;                                     /* As per FIPS 186 standard */
00062   unsigned int counterValue;            /* As per FIPS 186 standard  */
00063 } A_PQG_PARAMS;
00064 
00066 typedef A_PQG_PARAMS A_DSA_PARAMS;
00067 
00068 /* Note that fieldElementBits is not contained in A_EC_PARAMS,
00069      but can be easily recovered from fieldInfo. */
00070 
00071 /* The following #define's are for fieldType.
00072      FT_FP is odd prime characteristic
00073      FT_F2_ONB is characteristic 2, optimal normal basis
00074      FT_F2_POLYNOMIAL is characteristic 2, polynomial basis
00075  */
00076 #define FT_FP             0
00077 #define FT_F2_ONB         1
00078 #define FT_F2_POLYNOMIAL  2
00079 
00080 /* The following definitions are extensions to overload curve
00081     names over field type.  Field type is implicit in the curve name.
00082     The curve name is used to look up the curve parameters
00083     and a valid field type FT_FP, FT_F2 ... is substituted.
00084  */
00085 typedef enum {
00086     FT_NULL_CURVE=0x2FAB,
00087     FT_C2PNB163V1=0x1000, /* Prevent definition overlap */
00088     FT_C2PNB163V2,
00089     FT_C2PNB163V3,
00090     FT_C2PNB176W1,
00091     FT_C2TNB191V1,
00092     FT_C2TNB191V2,
00093     FT_C2TNB191V3,
00094     FT_C2ONB191V4,
00095     FT_C2ONB191V5,
00096     FT_C2PNB208W1,
00097     FT_C2TNB239V1,
00098     FT_C2TNB239V2,
00099     FT_C2TNB239V3,
00100     FT_C2ONB239V4,
00101     FT_C2ONB239V5,
00102     FT_C2PNB272W1,
00103     FT_C2PNB304W1,
00104     FT_C2TNB359V1,
00105     FT_C2PNB368W1,
00106     FT_C2TNB431R1,
00107     FT_PRIME192V1,
00108     FT_PRIME192V2,
00109     FT_PRIME192V3,
00110     FT_PRIME239V1,
00111     FT_PRIME239V2,
00112     FT_PRIME239V3,
00113     FT_PRIME256V1,
00114     FT_NIST_PRIME224,
00115     FT_NIST_PRIME384,
00116     FT_NIST_PRIME521,
00117     FT_X962_K2PNB163,
00118     FT_X962_K2ONB163,
00119     FT_X962_B2PNB163,
00120     FT_X962_B2ONB163,
00121     FT_X962_K2TNB233,
00122     FT_X962_K2ONB233,
00123     FT_X962_B2TNB233,
00124     FT_X962_B2ONB233,
00125     FT_X962_K2PNB283,
00126     FT_X962_K2ONB283,
00127     FT_X962_B2PNB283,
00128     FT_X962_B2ONB283,
00129     FT_X962_K2TNB409,
00130     FT_X962_K2ONB409,
00131     FT_X962_B2TNB409,
00132     FT_X962_B2ONB409,
00133     FT_X962_K2TNB571,
00134     FT_X962_K2ONB571,
00135     FT_X962_B2TNB571,
00136     FT_X962_B2ONB571,
00137     FT_PRIME192QV1,
00138     FT_NIST_PRIME224Q,
00139     FT_PRIME256QV1,
00140     FT_NIST_PRIME384Q,
00141     FT_NIST_PRIME521Q
00142 } FT_X962_NAMED_CURVE_TYPE;
00143 
00144 #define FT_PRIME_BASE FT_PRIME192V1
00145 /*
00146  * Used to retrieve the BER encoded name from the curve type.
00147  */
00148 #define FT_LAST_X962_CURVE FT_PRIME256V1
00149 #define FT_FIRST_NAMED_CURVE FT_C2PNB163V1
00150 #define FT_LAST_NAMED_CURVE FT_NIST_PRIME521
00151 
00152 
00153 /* The following #define's are for pointRepresentation which is always
00154      CI_NO_COMPRESS.  X9.62 compression is explicitly avoided.
00155      X9.62 ASN.1 encoding is maintained so that a HYBRID point
00156      can be read.  The "Compressed ~y value" on a hybrid point is
00157      completely ignored, since such values cannot be universally
00158      implemented across networks.
00159  */
00160 #define CI_NO_COMPRESS  0
00161 #define CI_HYBRID 1
00162 
00163 /* compressIndicator is deprecated as of Crypto-C Version 4.3 */
00164 #define compressIndicator pointRepresentation
00165 
00166 typedef struct {
00167   unsigned int version;
00168   unsigned int fieldType;         /* The base field for elliptic curve           */
00169   unsigned int fieldElementBits;  /* The length of field element in bits.        */                                  /* element.                                     */
00170   unsigned int minOrderBits;      /* The minimum size of group generated by base */
00171   unsigned int trialDivBound;     /* The maximum size of second largest prime    */
00172                                                   /* subgroup of group generated by base     */
00173   unsigned int pointRepresentation; /* Reserved for future use */
00174   unsigned int tableLookup; /* The tableLookup option available for F_{2^m} only */
00175 
00176 } A_EC_GEN_PARAMS;
00177 
00179 typedef struct {
00180   unsigned int version;
00181   unsigned int fieldType;
00182   ITEM fieldInfo;
00183   ITEM coeffA;
00184   ITEM coeffB;
00185 #if 1
00186   ITEM base;
00187 #else
00188   ITEM base_P;    /* 1 Byte compression (4 == no compression), 2*((len-1)/2 Bytes) X,Y */
00189   ITEM base_Q;    /* 1 Byte compression (4 == no compression), 2*((len-1)/2 Bytes) X,Y */
00190 #endif
00191   ITEM order;
00192   ITEM cofactor;                     /* The cofactor * order = # points on curve */
00193   unsigned int pointRepresentation; /* Reserved for future use */
00194   unsigned int fieldElementBits;
00195 } A_EC_PARAMS;
00196 
00198 typedef struct {
00199   A_EC_PARAMS curveParams; /* Must be first field to support pointer casting */
00200   ITEM publicKey;
00201 } A_EC_PUBLIC_KEY;
00202 
00203 typedef struct {
00204   A_EC_PUBLIC_KEY key; /* Must be first field to support pointer casting */
00205   FT_X962_NAMED_CURVE_TYPE namedCurveType;
00206   POINTER ecInfo;                 /* If available, store EC_FP_INFO here. */
00207 } A_EC_PUBLIC_KEY_EXTEND;
00208 
00210 typedef struct {
00211   A_EC_PARAMS curveParams; /* Must be first field to support pointer casting */
00212   ITEM privateKey;
00213 } A_EC_PRIVATE_KEY;
00214 
00215 typedef struct {
00216   A_EC_PRIVATE_KEY key; /* Must be first field to support pointer casting */
00217   FT_X962_NAMED_CURVE_TYPE namedCurveType;
00218   POINTER ecInfo;                 /* If available, store EC_FP_INFO here. */
00219 } A_EC_PRIVATE_KEY_EXTEND;
00220 
00222 typedef struct {
00223   ITEM modulus;
00224   ITEM publicExponent;
00225   ITEM privateExponent;
00226   ITEM prime[2];                       /* The prime factors */
00227   ITEM primeExponent[2];               /* The exponents for prime factors */
00228   ITEM coefficient;                    /* The CRT coefficient */
00229 } A_PKCS_RSA_PRIVATE_KEY;
00230 
00232 typedef struct {
00233   ITEM modulus;
00234   ITEM publicExponent;
00235   ITEM privateExponent;
00236   unsigned int numberOfPrimes;
00237   ITEM *primes;                           /* The prime factors */
00238   ITEM *primeExponents;                   /* The exponents for prime factors */
00239   ITEM *coefficients;                     /* The CRT coefficient */
00240 } A_PKCS_RSA_MULTI_PRIME_PRIVATE_KEY;
00241 
00243 typedef struct {
00244   unsigned int effectiveKeyBits;
00245   unsigned char *iv;
00246 } A_RC2_CBC_PARAMS;
00247 
00249 typedef struct {
00250   unsigned int effectiveKeyBits;
00251 } A_RC2_PARAMS;
00252 
00254 typedef struct {
00255   unsigned int version;
00256   unsigned int rounds;
00257   unsigned int wordSizeInBits;
00258   unsigned char *iv;
00259 } A_RC5_CBC_PARAMS;
00260 
00262 typedef struct {
00263   unsigned int version;
00264   unsigned int rounds;
00265   unsigned int wordSizeInBits;
00266 } A_RC5_PARAMS;
00267 
00268 typedef struct {
00269   A_RC5_CBC_PARAMS rc5Params;
00270   ITEM encryptingKey;
00271 } A_RC5_KEY_ENCRYPTING_PARAMS;
00272 
00273 
00275 typedef struct {
00276   ITEM modulus;
00277   ITEM prime[2];                             /* The prime factors */
00278   ITEM primeExponent[2];                     /* The exponents for prime factors */
00279   ITEM coefficient;                          /* The CRT coefficient */
00280 } A_RSA_CRT_KEY;
00281 
00283 typedef struct {
00284   ITEM modulus;                              /* The modulus */
00285   ITEM exponent;                             /* The exponent */
00286 } A_RSA_KEY;
00287 
00289 typedef struct {
00290   unsigned int modulusBits;
00291   ITEM publicExponent;
00292 } A_RSA_KEY_GEN_PARAMS;
00293 
00295 typedef struct {
00296   unsigned int modulusBits;
00297   unsigned int numberOfPrimes;
00298   ITEM publicExponent;
00299 } A_RSA_MULTI_PRIME_KEY_GEN_PARAMS;
00300 
00301 typedef struct {
00302   A_RSA_KEY_GEN_PARAMS keySpecs;
00303   unsigned int publicKeyUsage;
00304   unsigned int privateKeyUsage;
00305   UINT4 publicLifeTime;
00306   UINT4 privateLifeTime;
00307   unsigned int protectFlag;
00308 } A_TOKEN_RSA_KEY_GEN_PARAMS;
00309 
00311 typedef struct {
00312   ITEM y;                                  /* The public component */
00313   A_DSA_PARAMS params;                     /* The parameters (p, q, g) */
00314 } A_DSA_PUBLIC_KEY;
00315 
00317 typedef struct {
00318   ITEM x;                                  /* The private component */
00319   A_DSA_PARAMS params;                     /* The parameters (p, q, g) */
00320 } A_DSA_PRIVATE_KEY;
00321 
00322 typedef struct {
00323   unsigned int numMatchBits;
00324   unsigned int numIndexBits;
00325 } A_LZ77_COMPRESS_PARAMS;
00326 
00327 typedef struct {
00328   unsigned int encryptionBlockLen;
00329 } A_PKCS_PARAMS;
00330 
00331 /* Information data structure used by FIPS Secure Hash Algorithm (SHA) random
00332    number generator */
00334 typedef struct {
00335 ITEM prime;
00336 ITEM seed;
00337 } A_SHA_RANDOM_PARAMS;
00338 
00339 /* Information data structure used by the X9.31 SHA Random number generator */
00341 typedef struct {
00342 unsigned int numberOfStreams;
00343 ITEM seed;
00344 /* ITEM q;  Left off unless it's seen to be important. */
00345 } A_X931_RANDOM_PARAMS;
00346 
00358 #define EC_RAND_STRENGTH_DEFAULT     128
00359 
00362 #define EC_RAND_STRENGTH_MAX         256
00363 
00377 #define EC_RAND_PRED_RESIST_OFF     0
00378 
00381 #define EC_RAND_PRED_RESIST_ON      1
00382 
00396 #define EC_CT_PRIME_FIELD       0
00397 
00400 #define EC_CT_RANDOM_BINARY     1
00401 
00404 #define EC_CT_KOBLITZ           2
00405 
00420 #define EC_RAND_MODE_NORMAL     0
00421 
00424 #define EC_RAND_MODE_TEST       1
00425 
00429 /* Information data structure used by the X9.82 Part 3 Dual EC Deterministic
00430  * Random Bit Generator.
00431  */
00442 typedef struct {
00446   unsigned int strength;
00450   int prediction_resistance;
00456   ITEM string;
00460   unsigned int curve_type;
00465   int (RSA_CALLING_CONV *hashAlgorithm) PROTO_LIST ((POINTER *));
00470   POINTER hashAlgParams;
00474   int mode;
00475 } A_EC_RANDOM_PARAMS;
00492 #define EC_RAND_CTX_STRENGTH_DEFAULT     0
00493 
00498 #define EC_RAND_CTX_PRED_RESIST_DEFAULT  2
00499 
00503 #define EC_RAND_CTX_MODE_DEFAULT         2
00504 
00518 typedef struct {
00522   unsigned int strength;
00526   int prediction_resistance;
00531   ITEM additional_input;
00535   unsigned int mode;
00536 } A_EC_RANDOM_CTX_PARAMS;
00562 typedef int A_ENTROPY_CB_FUNCTION(POINTER data, unsigned char *buffer,
00563   unsigned int len, unsigned int *num, unsigned int *entropy);
00568 /* Information data structure used by the Entropy Gathering functions. */
00578 typedef struct {
00582   A_ENTROPY_CB_FUNCTION *cb;
00586   POINTER cb_data;
00587 } A_ENTROPY_PARAMS;
00602 #define ENTROPY_CTX_STRENGTH_DEFAULT     0
00603 
00607 #define ENTROPY_CTX_MODE_DEFAULT         3
00608 
00621 #define ENTROPY_MODE_NORMAL         EC_RAND_MODE_NORMAL
00622 
00625 #define ENTROPY_MODE_TEST           EC_RAND_MODE_TEST
00626 
00630 #define ENTROPY_MODE_TEST_SOURCE    2
00631 
00644 typedef struct {
00648   unsigned int strength;
00653   unsigned int mode;
00654 } A_ENTROPY_CTX_PARAMS;
00660 typedef struct {
00661   unsigned int blockLen;   /* Must go first to be compatible with ahchform.c */
00662   unsigned int oidNum;     /* Reserved for future use */
00663   ITEM OID;                /* Object Identifier for BER Encoding */
00664   } A_X931_PARAMS;
00665 
00667 typedef struct {
00668   unsigned int keyUsage;
00669   unsigned int keyLengthInBytes;
00670   UINT4 lifeTime;
00671   unsigned int protectFlag;
00672   unsigned char *cipherName;
00673 } A_SYMMETRIC_KEY_SPECIFIER;
00674 
00676 typedef struct {
00677   unsigned int keyUsage;
00678   unsigned int keyLengthInBytes;
00679   UINT4 lifeTime;
00680   unsigned int protectFlag;
00681 } A_SYMMETRIC_KEY_DEFINER;
00682 
00684 typedef struct {
00685   A_SYMMETRIC_KEY_DEFINER externalSpecs;
00686   unsigned char *keyOID;
00687   unsigned int keyOIDLen;
00688   UINT4 dateOfBirth;
00689 } A_X509_ATTRIB_INFO;
00690 
00691 
00693 typedef struct {
00694   unsigned int keyUsage;
00695   UINT4 lifeTime;
00696   unsigned int protectFlag;
00697 } A_KEYPAIR_DEFINER;
00698 
00700 typedef struct {
00701   A_KEYPAIR_DEFINER privateKeyDef;
00702   A_KEYPAIR_DEFINER publicKeyDef;
00703   POINTER keyParams;
00704   unsigned char *cipherName;
00705 } A_KEYPAIR_SPECIFIER;
00706 
00708 typedef struct {
00709   A_KEYPAIR_DEFINER externalSpecs;
00710   UINT4 dateOfBirth;
00711 } A_X509_KEYPAIR_ATTRIB_INFO;
00712 
00723 typedef struct {
00724     UINT4   errorCode;
00725     char    errorMsg[128];
00726 } A_RSA_EXTENDED_ERROR;
00727 
00728 
00729 #ifdef __cplusplus
00730 }
00731 #endif
00732 
00733 #endif /* _ATYPES_H_ */

Copyright (c) 1999-2005 RSA Security Inc. All rights reserved. 068-001001-6210-001-000 - 6.2.1