| OLD | NEW |
| 1 /* | 1 /* |
| 2 * blapit.h - public data structures for the crypto library | 2 * blapit.h - public data structures for the crypto library |
| 3 * | 3 * |
| 4 * This Source Code Form is subject to the terms of the Mozilla Public | 4 * This Source Code Form is subject to the terms of the Mozilla Public |
| 5 * License, v. 2.0. If a copy of the MPL was not distributed with this | 5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 7 /* $Id: blapit.h,v 1.29 2012/06/14 18:55:10 wtc%google.com Exp $ */ | 7 /* $Id: blapit.h,v 1.29 2012/06/14 18:55:10 wtc%google.com Exp $ */ |
| 8 | 8 |
| 9 #ifndef _BLAPIT_H_ | 9 #ifndef _BLAPIT_H_ |
| 10 #define _BLAPIT_H_ | 10 #define _BLAPIT_H_ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #define NSS_AES_CBC 1 | 36 #define NSS_AES_CBC 1 |
| 37 | 37 |
| 38 /* Camellia operation modes */ | 38 /* Camellia operation modes */ |
| 39 #define NSS_CAMELLIA 0 | 39 #define NSS_CAMELLIA 0 |
| 40 #define NSS_CAMELLIA_CBC 1 | 40 #define NSS_CAMELLIA_CBC 1 |
| 41 | 41 |
| 42 /* SEED operation modes */ | 42 /* SEED operation modes */ |
| 43 #define NSS_SEED 0 | 43 #define NSS_SEED 0 |
| 44 #define NSS_SEED_CBC 1 | 44 #define NSS_SEED_CBC 1 |
| 45 | 45 |
| 46 #define DSA_SIGNATURE_LEN » 40» /* Bytes */ | 46 #define DSA1_SUBPRIME_LEN» 20» » » /* Bytes */ |
| 47 #define DSA_SUBPRIME_LEN» 20» /* Bytes */ | 47 #define DSA1_SIGNATURE_LEN » (DSA1_SUBPRIME_LEN*2)» /* Bytes */ |
| 48 #define DSA_MAX_SUBPRIME_LEN» 32» » » /* Bytes */ |
| 49 #define DSA_MAX_SIGNATURE_LEN » (DSA_MAX_SUBPRIME_LEN*2)/* Bytes */ |
| 50 |
| 51 /* |
| 52 * Mark the old defines as deprecated. This will warn code that expected |
| 53 * DSA1 only that they need to change if the are to support DSA2. |
| 54 */ |
| 55 #if defined(__GNUC__) && (__GNUC__ > 3) |
| 56 /* make GCC warn when we use these #defines */ |
| 57 typedef int __BLAPI_DEPRECATED __attribute__((deprecated)); |
| 58 #define DSA_SUBPRIME_LEN ((__BLAPI_DEPRECATED)DSA1_SUBPRIME_LEN) |
| 59 #define DSA_SIGNATURE_LEN ((__BLAPI_DEPRECATED)DSA1_SIGNATURE_LEN) |
| 60 #define DSA_Q_BITS ((__BLAPI_DEPRECATED)(DSA1_SUBPRIME_LEN*8)) |
| 61 #else |
| 62 #ifdef _WIN32 |
| 63 /* This magic gets the windows compiler to give us a deprecation |
| 64 * warning */ |
| 65 #pragma deprecated(DSA_SUBPRIME_LEN, DSA_SIGNATURE_LEN, DSA_QBITS) |
| 66 #endif |
| 67 #define DSA_SUBPRIME_LEN DSA1_SUBPRIME_LEN |
| 68 #define DSA_SIGNATURE_LEN DSA1_SIGNATURE_LEN |
| 69 #define DSA_Q_BITS » (DSA1_SUBPRIME_LEN*8) |
| 70 #endif |
| 71 |
| 48 | 72 |
| 49 /* XXX We shouldn't have to hard code this limit. For | 73 /* XXX We shouldn't have to hard code this limit. For |
| 50 * now, this is the quickest way to support ECDSA signature | 74 * now, this is the quickest way to support ECDSA signature |
| 51 * processing (ECDSA signature lengths depend on curve | 75 * processing (ECDSA signature lengths depend on curve |
| 52 * size). This limit is sufficient for curves upto | 76 * size). This limit is sufficient for curves upto |
| 53 * 576 bits. | 77 * 576 bits. |
| 54 */ | 78 */ |
| 55 #define MAX_ECKEY_LEN 72 /* Bytes */ | 79 #define MAX_ECKEY_LEN 72 /* Bytes */ |
| 56 | 80 |
| 57 /* EC point compression format */ | 81 /* EC point compression format */ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 #define SEED_BLOCK_SIZE 16 /* bytes */ | 122 #define SEED_BLOCK_SIZE 16 /* bytes */ |
| 99 #define SEED_KEY_LENGTH 16 /* bytes */ | 123 #define SEED_KEY_LENGTH 16 /* bytes */ |
| 100 | 124 |
| 101 #define NSS_FREEBL_DEFAULT_CHUNKSIZE 2048 | 125 #define NSS_FREEBL_DEFAULT_CHUNKSIZE 2048 |
| 102 | 126 |
| 103 /* | 127 /* |
| 104 * These values come from the initial key size limits from the PKCS #11 | 128 * These values come from the initial key size limits from the PKCS #11 |
| 105 * module. They may be arbitrarily adjusted to any value freebl supports. | 129 * module. They may be arbitrarily adjusted to any value freebl supports. |
| 106 */ | 130 */ |
| 107 #define RSA_MIN_MODULUS_BITS 128 | 131 #define RSA_MIN_MODULUS_BITS 128 |
| 108 #define RSA_MAX_MODULUS_BITS 8192 | 132 #define RSA_MAX_MODULUS_BITS 16384 |
| 109 #define RSA_MAX_EXPONENT_BITS 64 | 133 #define RSA_MAX_EXPONENT_BITS 64 |
| 110 #define DH_MIN_P_BITS 128 | 134 #define DH_MIN_P_BITS 128 |
| 111 #define DH_MAX_P_BITS 3072 | 135 #define DH_MAX_P_BITS 16384 |
| 112 | 136 |
| 113 /* | 137 /* |
| 114 * The FIPS 186 algorithm for generating primes P and Q allows only 9 | 138 * The FIPS 186-1 algorithm for generating primes P and Q allows only 9 |
| 115 * distinct values for the length of P, and only one value for the | 139 * distinct values for the length of P, and only one value for the |
| 116 * length of Q. | 140 * length of Q. |
| 117 * The algorithm uses a variable j to indicate which of the 9 lengths | 141 * The algorithm uses a variable j to indicate which of the 9 lengths |
| 118 * of P is to be used. | 142 * of P is to be used. |
| 119 * The following table relates j to the lengths of P and Q in bits. | 143 * The following table relates j to the lengths of P and Q in bits. |
| 120 * | 144 * |
| 121 * j bits in P bits in Q | 145 * j bits in P bits in Q |
| 122 * _ _________ _________ | 146 * _ _________ _________ |
| 123 * 0 512 160 | 147 * 0 512 160 |
| 124 * 1 576 160 | 148 * 1 576 160 |
| 125 * 2 640 160 | 149 * 2 640 160 |
| 126 * 3 704 160 | 150 * 3 704 160 |
| 127 * 4 768 160 | 151 * 4 768 160 |
| 128 * 5 832 160 | 152 * 5 832 160 |
| 129 * 6 896 160 | 153 * 6 896 160 |
| 130 * 7 960 160 | 154 * 7 960 160 |
| 131 * 8 1024 160 | 155 * 8 1024 160 |
| 132 * | 156 * |
| 133 * The FIPS-186 compliant PQG generator takes j as an input parameter. | 157 * The FIPS-186-1 compliant PQG generator takes j as an input parameter. |
| 158 * |
| 159 * FIPS 186-3 algorithm specifies 4 distinct P and Q sizes: |
| 160 * |
| 161 * bits in P bits in Q |
| 162 * _________ _________ |
| 163 * 1024 160 |
| 164 * 2048 224 |
| 165 * 2048 256 |
| 166 * 3072 256 |
| 167 * |
| 168 * The FIPS-186-3 complaiant PQG generator (PQG V2) takes arbitrary p and q |
| 169 * lengths as input and returns an error if they aren't in this list. |
| 134 */ | 170 */ |
| 135 | 171 |
| 136 #define DSA_Q_BITS 160 | 172 #define DSA1_Q_BITS 160 |
| 137 #define DSA_MAX_P_BITS» 1024 | 173 #define DSA_MAX_P_BITS» 3072 |
| 138 #define DSA_MIN_P_BITS 512 | 174 #define DSA_MIN_P_BITS 512 |
| 175 #define DSA_MAX_Q_BITS 256 |
| 176 #define DSA_MIN_Q_BITS 160 |
| 177 |
| 178 #if DSA_MAX_Q_BITS != DSA_MAX_SUBPRIME_LEN*8 |
| 179 #error "Inconsistent declaration of DSA SUBPRIME/Q parameters in blapit.h" |
| 180 #endif |
| 181 |
| 139 | 182 |
| 140 /* | 183 /* |
| 141 * function takes desired number of bits in P, | 184 * function takes desired number of bits in P, |
| 142 * returns index (0..8) or -1 if number of bits is invalid. | 185 * returns index (0..8) or -1 if number of bits is invalid. |
| 143 */ | 186 */ |
| 144 #define PQG_PBITS_TO_INDEX(bits) \ | 187 #define PQG_PBITS_TO_INDEX(bits) \ |
| 145 (((bits) < 512 || (bits) > 1024 || (bits) % 64) ? \ | 188 (((bits) < 512 || (bits) > 1024 || (bits) % 64) ? \ |
| 146 -1 : (int)((bits)-512)/64) | 189 -1 : (int)((bits)-512)/64) |
| 147 | 190 |
| 148 /* | 191 /* |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 int, | 403 int, |
| 361 unsigned int , | 404 unsigned int , |
| 362 unsigned int ); | 405 unsigned int ); |
| 363 typedef SECStatus (*BLapiEncrypt)(void *cx, unsigned char *output, | 406 typedef SECStatus (*BLapiEncrypt)(void *cx, unsigned char *output, |
| 364 unsigned int *outputLen, | 407 unsigned int *outputLen, |
| 365 unsigned int maxOutputLen, | 408 unsigned int maxOutputLen, |
| 366 const unsigned char *input, | 409 const unsigned char *input, |
| 367 unsigned int inputLen); | 410 unsigned int inputLen); |
| 368 | 411 |
| 369 #endif /* _BLAPIT_H_ */ | 412 #endif /* _BLAPIT_H_ */ |
| OLD | NEW |