OLD | NEW |
1 /* | 1 /* |
2 * crypto.h - public data structures and prototypes for the crypto library | 2 * crypto.h - public data structures and prototypes 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 | 7 |
8 #ifndef _BLAPI_H_ | 8 #ifndef _BLAPI_H_ |
9 #define _BLAPI_H_ | 9 #define _BLAPI_H_ |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 ** smaller prime as prime1 or the larger prime as prime2). The parameters are | 101 ** smaller prime as prime1 or the larger prime as prime2). The parameters are |
102 ** not overwritten on failure. | 102 ** not overwritten on failure. |
103 ** | 103 ** |
104 ** While the remaining Chinese remainder theorem parameters (dp,dp, and qinv) | 104 ** While the remaining Chinese remainder theorem parameters (dp,dp, and qinv) |
105 ** can also be used in reconstructing the private key, they are currently | 105 ** can also be used in reconstructing the private key, they are currently |
106 ** ignored in this implementation. | 106 ** ignored in this implementation. |
107 */ | 107 */ |
108 extern SECStatus RSA_PopulatePrivateKey(RSAPrivateKey *key); | 108 extern SECStatus RSA_PopulatePrivateKey(RSAPrivateKey *key); |
109 | 109 |
110 /******************************************************************** | 110 /******************************************************************** |
| 111 ** RSA algorithm |
| 112 */ |
| 113 |
| 114 /******************************************************************** |
| 115 ** Raw signing/encryption/decryption operations. |
| 116 ** |
| 117 ** No padding or formatting will be applied. |
| 118 ** inputLen MUST be equivalent to the modulus size (in bytes). |
| 119 */ |
| 120 extern SECStatus |
| 121 RSA_SignRaw(RSAPrivateKey * key, |
| 122 unsigned char * output, |
| 123 unsigned int * outputLen, |
| 124 unsigned int maxOutputLen, |
| 125 const unsigned char * input, |
| 126 unsigned int inputLen); |
| 127 |
| 128 extern SECStatus |
| 129 RSA_CheckSignRaw(RSAPublicKey * key, |
| 130 const unsigned char * sig, |
| 131 unsigned int sigLen, |
| 132 const unsigned char * hash, |
| 133 unsigned int hashLen); |
| 134 |
| 135 extern SECStatus |
| 136 RSA_CheckSignRecoverRaw(RSAPublicKey * key, |
| 137 unsigned char * data, |
| 138 unsigned int * dataLen, |
| 139 unsigned int maxDataLen, |
| 140 const unsigned char * sig, |
| 141 unsigned int sigLen); |
| 142 |
| 143 extern SECStatus |
| 144 RSA_EncryptRaw(RSAPublicKey * key, |
| 145 unsigned char * output, |
| 146 unsigned int * outputLen, |
| 147 unsigned int maxOutputLen, |
| 148 const unsigned char * input, |
| 149 unsigned int inputLen); |
| 150 |
| 151 extern SECStatus |
| 152 RSA_DecryptRaw(RSAPrivateKey * key, |
| 153 unsigned char * output, |
| 154 unsigned int * outputLen, |
| 155 unsigned int maxOutputLen, |
| 156 const unsigned char * input, |
| 157 unsigned int inputLen); |
| 158 |
| 159 /******************************************************************** |
| 160 ** RSAES-OAEP encryption/decryption, as defined in RFC 3447, Section 7.1. |
| 161 ** |
| 162 ** Note: Only MGF1 is supported as the mask generation function. It will be |
| 163 ** used with maskHashAlg as the inner hash function. |
| 164 ** |
| 165 ** Unless performing Known Answer Tests, "seed" should be NULL, indicating that |
| 166 ** freebl should generate a random value. Otherwise, it should be an octet |
| 167 ** string of seedLen bytes, which should be the same size as the output of |
| 168 ** hashAlg. |
| 169 */ |
| 170 extern SECStatus |
| 171 RSA_EncryptOAEP(RSAPublicKey * key, |
| 172 HASH_HashType hashAlg, |
| 173 HASH_HashType maskHashAlg, |
| 174 const unsigned char * label, |
| 175 unsigned int labelLen, |
| 176 const unsigned char * seed, |
| 177 unsigned int seedLen, |
| 178 unsigned char * output, |
| 179 unsigned int * outputLen, |
| 180 unsigned int maxOutputLen, |
| 181 const unsigned char * input, |
| 182 unsigned int inputLen); |
| 183 |
| 184 extern SECStatus |
| 185 RSA_DecryptOAEP(RSAPrivateKey * key, |
| 186 HASH_HashType hashAlg, |
| 187 HASH_HashType maskHashAlg, |
| 188 const unsigned char * label, |
| 189 unsigned int labelLen, |
| 190 unsigned char * output, |
| 191 unsigned int * outputLen, |
| 192 unsigned int maxOutputLen, |
| 193 const unsigned char * input, |
| 194 unsigned int inputLen); |
| 195 |
| 196 /******************************************************************** |
| 197 ** RSAES-PKCS1-v1_5 encryption/decryption, as defined in RFC 3447, Section 7.2. |
| 198 */ |
| 199 extern SECStatus |
| 200 RSA_EncryptBlock(RSAPublicKey * key, |
| 201 unsigned char * output, |
| 202 unsigned int * outputLen, |
| 203 unsigned int maxOutputLen, |
| 204 const unsigned char * input, |
| 205 unsigned int inputLen); |
| 206 |
| 207 extern SECStatus |
| 208 RSA_DecryptBlock(RSAPrivateKey * key, |
| 209 unsigned char * output, |
| 210 unsigned int * outputLen, |
| 211 unsigned int maxOutputLen, |
| 212 const unsigned char * input, |
| 213 unsigned int inputLen); |
| 214 |
| 215 /******************************************************************** |
| 216 ** RSASSA-PSS signing/verifying, as defined in RFC 3447, Section 8.1. |
| 217 ** |
| 218 ** Note: Only MGF1 is supported as the mask generation function. It will be |
| 219 ** used with maskHashAlg as the inner hash function. |
| 220 ** |
| 221 ** Unless performing Known Answer Tests, "salt" should be NULL, indicating that |
| 222 ** freebl should generate a random value. |
| 223 */ |
| 224 extern SECStatus |
| 225 RSA_SignPSS(RSAPrivateKey * key, |
| 226 HASH_HashType hashAlg, |
| 227 HASH_HashType maskHashAlg, |
| 228 const unsigned char * salt, |
| 229 unsigned int saltLen, |
| 230 unsigned char * output, |
| 231 unsigned int * outputLen, |
| 232 unsigned int maxOutputLen, |
| 233 const unsigned char * input, |
| 234 unsigned int inputLen); |
| 235 |
| 236 extern SECStatus |
| 237 RSA_CheckSignPSS(RSAPublicKey * key, |
| 238 HASH_HashType hashAlg, |
| 239 HASH_HashType maskHashAlg, |
| 240 unsigned int saltLen, |
| 241 const unsigned char * sig, |
| 242 unsigned int sigLen, |
| 243 const unsigned char * hash, |
| 244 unsigned int hashLen); |
| 245 |
| 246 /******************************************************************** |
| 247 ** RSASSA-PKCS1-v1_5 signing/verifying, as defined in RFC 3447, Section 8.2. |
| 248 ** |
| 249 ** These functions expect as input to be the raw value to be signed. For most |
| 250 ** cases using PKCS1-v1_5, this should be the value of T, the DER-encoded |
| 251 ** DigestInfo structure defined in Section 9.2, Step 2. |
| 252 ** Note: This can also be used for signatures that use PKCS1-v1_5 padding, such |
| 253 ** as the signatures used in SSL/TLS, which sign a raw hash. |
| 254 */ |
| 255 extern SECStatus |
| 256 RSA_Sign(RSAPrivateKey * key, |
| 257 unsigned char * output, |
| 258 unsigned int * outputLen, |
| 259 unsigned int maxOutputLen, |
| 260 const unsigned char * data, |
| 261 unsigned int dataLen); |
| 262 |
| 263 extern SECStatus |
| 264 RSA_CheckSign(RSAPublicKey * key, |
| 265 const unsigned char * sig, |
| 266 unsigned int sigLen, |
| 267 const unsigned char * data, |
| 268 unsigned int dataLen); |
| 269 |
| 270 extern SECStatus |
| 271 RSA_CheckSignRecover(RSAPublicKey * key, |
| 272 unsigned char * output, |
| 273 unsigned int * outputLen, |
| 274 unsigned int maxOutputLen, |
| 275 const unsigned char * sig, |
| 276 unsigned int sigLen); |
| 277 |
| 278 /******************************************************************** |
111 ** DSA signing algorithm | 279 ** DSA signing algorithm |
112 */ | 280 */ |
113 | 281 |
114 /* Generate a new random value within the interval [2, q-1]. | 282 /* Generate a new random value within the interval [2, q-1]. |
115 */ | 283 */ |
116 extern SECStatus DSA_NewRandom(PLArenaPool * arena, const SECItem * q, | 284 extern SECStatus DSA_NewRandom(PLArenaPool * arena, const SECItem * q, |
117 SECItem * random); | 285 SECItem * random); |
118 | 286 |
119 /* | 287 /* |
120 ** Generate and return a new DSA public and private key pair, | 288 ** Generate and return a new DSA public and private key pair, |
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 PRBool BLAPI_VerifySelf(const char *name); | 1604 PRBool BLAPI_VerifySelf(const char *name); |
1437 | 1605 |
1438 /*********************************************************************/ | 1606 /*********************************************************************/ |
1439 extern const SECHashObject * HASH_GetRawHashObject(HASH_HashType hashType); | 1607 extern const SECHashObject * HASH_GetRawHashObject(HASH_HashType hashType); |
1440 | 1608 |
1441 extern void BL_SetForkState(PRBool forked); | 1609 extern void BL_SetForkState(PRBool forked); |
1442 | 1610 |
1443 SEC_END_PROTOS | 1611 SEC_END_PROTOS |
1444 | 1612 |
1445 #endif /* _BLAPI_H_ */ | 1613 #endif /* _BLAPI_H_ */ |
OLD | NEW |