OLD | NEW |
1 /* | 1 /* |
2 * softoken.h - private data structures and prototypes for the softoken lib | 2 * softoken.h - private data structures and prototypes for the softoken lib |
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 _SOFTOKEN_H_ | 8 #ifndef _SOFTOKEN_H_ |
9 #define _SOFTOKEN_H_ | 9 #define _SOFTOKEN_H_ |
10 | 10 |
11 #include "blapi.h" | 11 #include "blapi.h" |
12 #include "lowkeyti.h" | 12 #include "lowkeyti.h" |
13 #include "softoknt.h" | 13 #include "softoknt.h" |
14 #include "secoidt.h" | 14 #include "secoidt.h" |
15 | 15 |
16 #include "pkcs11t.h" | 16 #include "pkcs11t.h" |
17 | 17 |
18 SEC_BEGIN_PROTOS | 18 SEC_BEGIN_PROTOS |
19 | 19 |
20 /* | 20 /* |
21 ** RSA encryption/decryption. When encrypting/decrypting the output | 21 * Convenience wrapper for doing a single PKCS#1 v1.5 RSA operations where the |
22 ** buffer must be at least the size of the public key modulus. | 22 * encoded digest info is computed internally, rather than by the caller. |
23 */ | 23 * |
| 24 * The HashSign variants expect as input the value of H, the computed hash |
| 25 * from RFC 3447, Section 9.2, Step 1, and will compute the DER-encoded |
| 26 * DigestInfo structure internally prior to signing/verifying. |
| 27 */ |
| 28 extern SECStatus |
| 29 RSA_HashSign(SECOidTag hashOid, NSSLOWKEYPrivateKey *key, |
| 30 unsigned char *sig, unsigned int *sigLen, unsigned int maxLen, |
| 31 const unsigned char *hash, unsigned int hashLen); |
24 | 32 |
25 /* | 33 extern SECStatus |
26 ** Format some data into a PKCS#1 encryption block, preparing the | 34 RSA_HashCheckSign(SECOidTag hashOid, NSSLOWKEYPublicKey *key, |
27 ** data for RSA encryption. | 35 const unsigned char *sig, unsigned int sigLen, |
28 **» "result" where the formatted block is stored (memory is allocated) | 36 const unsigned char *hash, unsigned int hashLen); |
29 **» "modulusLen" the size of the formatted block | |
30 **» "blockType" what block type to use (SEC_RSABlock*) | |
31 **» "data" the data to format | |
32 */ | |
33 extern SECStatus RSA_FormatBlock(SECItem *result, | |
34 » » » » unsigned int modulusLen, | |
35 » » » » RSA_BlockType blockType, | |
36 » » » » SECItem *data); | |
37 /* | |
38 ** Similar, but just returns a pointer to the allocated memory, *and* | |
39 ** will *only* format one block, even if we (in the future) modify | |
40 ** RSA_FormatBlock() to loop over multiples of modulusLen. | |
41 */ | |
42 extern unsigned char *RSA_FormatOneBlock(unsigned int modulusLen, | |
43 » » » » » RSA_BlockType blockType, | |
44 » » » » » SECItem *data); | |
45 | 37 |
46 | |
47 | |
48 /* | |
49 * convenience wrappers for doing single RSA operations. They create the | |
50 * RSA context internally and take care of the formatting | |
51 * requirements. Blinding happens automagically within RSA_Sign and | |
52 * RSA_DecryptBlock. | |
53 */ | |
54 extern | |
55 SECStatus RSA_Sign(NSSLOWKEYPrivateKey *key, unsigned char *output, | |
56 unsigned int *outputLen, unsigned int maxOutputLen, | |
57 unsigned char *input, unsigned int inputLen); | |
58 extern | |
59 SECStatus RSA_HashSign(SECOidTag hashOid, | |
60 NSSLOWKEYPrivateKey *key, unsigned char *sig, | |
61 unsigned int *sigLen, unsigned int maxLen, | |
62 unsigned char *hash, unsigned int hashLen); | |
63 extern | |
64 SECStatus RSA_SignPSS(CK_RSA_PKCS_PSS_PARAMS *pss_params, | |
65 NSSLOWKEYPrivateKey *key, | |
66 unsigned char *output, unsigned int *output_len, | |
67 unsigned int max_output_len, const unsigned char *input, | |
68 unsigned int input_len); | |
69 extern | |
70 SECStatus RSA_CheckSign(NSSLOWKEYPublicKey *key, unsigned char *sign, | |
71 unsigned int signLength, unsigned char *hash, | |
72 unsigned int hashLength); | |
73 extern | |
74 SECStatus RSA_HashCheckSign(SECOidTag hashOid, | |
75 NSSLOWKEYPublicKey *key, unsigned char *sig, | |
76 unsigned int sigLen, unsigned char *digest, | |
77 unsigned int digestLen); | |
78 extern | |
79 SECStatus RSA_CheckSignPSS(CK_RSA_PKCS_PSS_PARAMS *pss_params, | |
80 NSSLOWKEYPublicKey *key, | |
81 const unsigned char *sign, unsigned int sign_len, | |
82 const unsigned char *hash, unsigned int hash_len); | |
83 extern | |
84 SECStatus RSA_CheckSignRecover(NSSLOWKEYPublicKey *key, unsigned char *data, | |
85 unsigned int *data_len,unsigned int max_output_len, | |
86 unsigned char *sign, unsigned int sign_len); | |
87 extern | |
88 SECStatus RSA_EncryptBlock(NSSLOWKEYPublicKey *key, unsigned char *output, | |
89 unsigned int *outputLen, unsigned int maxOutputLen, | |
90 unsigned char *input, unsigned int inputLen); | |
91 extern | |
92 SECStatus RSA_DecryptBlock(NSSLOWKEYPrivateKey *key, unsigned char *output, | |
93 unsigned int *outputLen, unsigned int maxOutputLen, | |
94 unsigned char *input, unsigned int inputLen); | |
95 | |
96 extern | |
97 SECStatus RSA_EncryptOAEP(CK_RSA_PKCS_OAEP_PARAMS *oaepParams, | |
98 NSSLOWKEYPublicKey *key, | |
99 unsigned char *output, unsigned int *outputLen, | |
100 unsigned int maxOutputLen, | |
101 const unsigned char *input, unsigned int inputLen); | |
102 | |
103 extern | |
104 SECStatus RSA_DecryptOAEP(CK_RSA_PKCS_OAEP_PARAMS *oaepParams, | |
105 NSSLOWKEYPrivateKey *key, | |
106 unsigned char *output, unsigned int *outputLen, | |
107 unsigned int maxOutputLen, | |
108 const unsigned char *input, unsigned int inputLen); | |
109 | |
110 /* | |
111 * added to make pkcs #11 happy | |
112 * RAW is RSA_X_509 | |
113 */ | |
114 extern | |
115 SECStatus RSA_SignRaw( NSSLOWKEYPrivateKey *key, unsigned char *output, | |
116 unsigned int *output_len, unsigned int maxOutputLen, | |
117 unsigned char *input, unsigned int input_len); | |
118 extern | |
119 SECStatus RSA_CheckSignRaw( NSSLOWKEYPublicKey *key, unsigned char *sign, | |
120 unsigned int sign_len, unsigned char *hash, | |
121 unsigned int hash_len); | |
122 extern | |
123 SECStatus RSA_CheckSignRecoverRaw( NSSLOWKEYPublicKey *key, unsigned char *data, | |
124 unsigned int *data_len, unsigned int max_output_len, | |
125 unsigned char *sign, unsigned int sign_len); | |
126 extern | |
127 SECStatus RSA_EncryptRaw( NSSLOWKEYPublicKey *key, unsigned char *output, | |
128 unsigned int *output_len, | |
129 unsigned int max_output_len, | |
130 unsigned char *input, unsigned int input_len); | |
131 extern | |
132 SECStatus RSA_DecryptRaw(NSSLOWKEYPrivateKey *key, unsigned char *output, | |
133 unsigned int *output_len, | |
134 unsigned int max_output_len, | |
135 unsigned char *input, unsigned int input_len); | |
136 #ifdef NSS_ENABLE_ECC | 38 #ifdef NSS_ENABLE_ECC |
137 /* | 39 /* |
138 ** pepare an ECParam structure from DEREncoded params | 40 ** pepare an ECParam structure from DEREncoded params |
139 */ | 41 */ |
140 extern SECStatus EC_FillParams(PLArenaPool *arena, | 42 extern SECStatus EC_FillParams(PLArenaPool *arena, |
141 const SECItem *encodedParams, ECParams *params); | 43 const SECItem *encodedParams, ECParams *params); |
142 extern SECStatus EC_DecodeParams(const SECItem *encodedParams, | 44 extern SECStatus EC_DecodeParams(const SECItem *encodedParams, |
143 ECParams **ecparams); | 45 ECParams **ecparams); |
144 extern SECStatus EC_CopyParams(PLArenaPool *arena, ECParams *dstParams, | 46 extern SECStatus EC_CopyParams(PLArenaPool *arena, ECParams *dstParams, |
145 const ECParams *srcParams); | 47 const ECParams *srcParams); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 #ifndef NO_FORK_CHECK | 270 #ifndef NO_FORK_CHECK |
369 #define NO_FORK_CHECK | 271 #define NO_FORK_CHECK |
370 #endif | 272 #endif |
371 | 273 |
372 #endif | 274 #endif |
373 | 275 |
374 | 276 |
375 SEC_END_PROTOS | 277 SEC_END_PROTOS |
376 | 278 |
377 #endif /* _SOFTOKEN_H_ */ | 279 #endif /* _SOFTOKEN_H_ */ |
OLD | NEW |