OLD | NEW |
1 /* | 1 /* |
2 * cryptohi.h - public prototypes for the crypto library | 2 * cryptohi.h - public 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 _CRYPTOHI_H_ | 8 #ifndef _CRYPTOHI_H_ |
9 #define _CRYPTOHI_H_ | 9 #define _CRYPTOHI_H_ |
10 | 10 |
11 #include "blapit.h" | 11 #include "blapit.h" |
12 | 12 |
13 #include "seccomon.h" | 13 #include "seccomon.h" |
14 #include "secoidt.h" | 14 #include "secoidt.h" |
15 #include "secdert.h" | 15 #include "secdert.h" |
16 #include "cryptoht.h" | 16 #include "cryptoht.h" |
17 #include "keyt.h" | 17 #include "keyt.h" |
18 #include "certt.h" | 18 #include "certt.h" |
19 | 19 |
20 | |
21 SEC_BEGIN_PROTOS | 20 SEC_BEGIN_PROTOS |
22 | 21 |
23 | |
24 /****************************************/ | 22 /****************************************/ |
25 /* | 23 /* |
26 ** DER encode/decode (EC)DSA signatures | 24 ** DER encode/decode (EC)DSA signatures |
27 */ | 25 */ |
28 | 26 |
29 /* ANSI X9.57 defines DSA signatures as DER encoded data. Our DSA1 code (and | 27 /* ANSI X9.57 defines DSA signatures as DER encoded data. Our DSA1 code (and |
30 * most of the rest of the world) just generates 40 bytes of raw data. These | 28 * most of the rest of the world) just generates 40 bytes of raw data. These |
31 * functions convert between formats. | 29 * functions convert between formats. |
32 */ | 30 */ |
33 extern SECStatus DSAU_EncodeDerSig(SECItem *dest, SECItem *src); | 31 extern SECStatus DSAU_EncodeDerSig(SECItem *dest, SECItem *src); |
34 extern SECItem *DSAU_DecodeDerSig(const SECItem *item); | 32 extern SECItem *DSAU_DecodeDerSig(const SECItem *item); |
35 | 33 |
36 /* | 34 /* |
37 * Unlike DSA1, raw DSA2 and ECDSA signatures do not have a fixed length. | 35 * Unlike DSA1, raw DSA2 and ECDSA signatures do not have a fixed length. |
38 * Rather they contain two integers r and s whose length depends | 36 * Rather they contain two integers r and s whose length depends |
39 * on the size of q or the EC key used for signing. | 37 * on the size of q or the EC key used for signing. |
40 * | 38 * |
41 * We can reuse the DSAU_EncodeDerSig interface to DER encode | 39 * We can reuse the DSAU_EncodeDerSig interface to DER encode |
42 * raw ECDSA signature keeping in mind that the length of r | 40 * raw ECDSA signature keeping in mind that the length of r |
43 * is the same as that of s and exactly half of src->len. | 41 * is the same as that of s and exactly half of src->len. |
44 * | 42 * |
45 * For decoding, we need to pass the length of the desired | 43 * For decoding, we need to pass the length of the desired |
46 * raw signature (twice the key size) explicitly. | 44 * raw signature (twice the key size) explicitly. |
47 */ | 45 */ |
48 extern SECStatus DSAU_EncodeDerSigWithLen(SECItem *dest, SECItem *src, | 46 extern SECStatus DSAU_EncodeDerSigWithLen(SECItem *dest, SECItem *src, |
49 » » » » » unsigned int len); | 47 unsigned int len); |
50 extern SECItem *DSAU_DecodeDerSigToLen(const SECItem *item, unsigned int len); | 48 extern SECItem *DSAU_DecodeDerSigToLen(const SECItem *item, unsigned int len); |
51 | 49 |
52 /****************************************/ | 50 /****************************************/ |
53 /* | 51 /* |
54 ** Signature creation operations | 52 ** Signature creation operations |
55 */ | 53 */ |
56 | 54 |
57 /* | 55 /* |
58 ** Create a new signature context used for signing a data stream. | 56 ** Create a new signature context used for signing a data stream. |
59 ** "alg" the signature algorithm to use (e.g. SEC_OID_PKCS1_MD5_WITH_RSA_EN
CRYPTION) | 57 ** "alg" the signature algorithm to use (e.g. SEC_OID_PKCS1_MD5_WITH_RSA_EN
CRYPTION) |
(...skipping 14 matching lines...) Expand all Loading... |
74 */ | 72 */ |
75 extern SECStatus SGN_Begin(SGNContext *cx); | 73 extern SECStatus SGN_Begin(SGNContext *cx); |
76 | 74 |
77 /* | 75 /* |
78 ** Update the signing context with more data to sign. | 76 ** Update the signing context with more data to sign. |
79 ** "cx" the context | 77 ** "cx" the context |
80 ** "input" the input data to sign | 78 ** "input" the input data to sign |
81 ** "inputLen" the length of the input data | 79 ** "inputLen" the length of the input data |
82 */ | 80 */ |
83 extern SECStatus SGN_Update(SGNContext *cx, const unsigned char *input, | 81 extern SECStatus SGN_Update(SGNContext *cx, const unsigned char *input, |
84 » » » unsigned int inputLen); | 82 unsigned int inputLen); |
85 | 83 |
86 /* | 84 /* |
87 ** Finish the signature process. Use either k0 or k1 to sign the data | 85 ** Finish the signature process. Use either k0 or k1 to sign the data |
88 ** stream that was input using SGN_Update. The resulting signature is | 86 ** stream that was input using SGN_Update. The resulting signature is |
89 ** formatted using PKCS#1 and then encrypted using RSA private or public | 87 ** formatted using PKCS#1 and then encrypted using RSA private or public |
90 ** encryption. | 88 ** encryption. |
91 ** "cx" the context | 89 ** "cx" the context |
92 ** "result" the final signature data (memory is allocated) | 90 ** "result" the final signature data (memory is allocated) |
93 */ | 91 */ |
94 extern SECStatus SGN_End(SGNContext *cx, SECItem *result); | 92 extern SECStatus SGN_End(SGNContext *cx, SECItem *result); |
95 | 93 |
96 /* | 94 /* |
97 ** Sign a single block of data using private key encryption and given | 95 ** Sign a single block of data using private key encryption and given |
98 ** signature/hash algorithm. | 96 ** signature/hash algorithm. |
99 ** "result" the final signature data (memory is allocated) | 97 ** "result" the final signature data (memory is allocated) |
100 ** "buf" the input data to sign | 98 ** "buf" the input data to sign |
101 ** "len" the amount of data to sign | 99 ** "len" the amount of data to sign |
102 ** "pk" the private key to encrypt with | 100 ** "pk" the private key to encrypt with |
103 **» "algid" the signature/hash algorithm to sign with | 101 **» "algid" the signature/hash algorithm to sign with |
104 ** (must be compatible with the key type). | 102 ** (must be compatible with the key type). |
105 */ | 103 */ |
106 extern SECStatus SEC_SignData(SECItem *result, | 104 extern SECStatus SEC_SignData(SECItem *result, |
107 » » » const unsigned char *buf, int len, | 105 const unsigned char *buf, int len, |
108 » » » SECKEYPrivateKey *pk, SECOidTag algid); | 106 SECKEYPrivateKey *pk, SECOidTag algid); |
109 | 107 |
110 /* | 108 /* |
111 ** Sign a pre-digested block of data using private key encryption, encoding | 109 ** Sign a pre-digested block of data using private key encryption, encoding |
112 ** The given signature/hash algorithm. | 110 ** The given signature/hash algorithm. |
113 ** "result" the final signature data (memory is allocated) | 111 ** "result" the final signature data (memory is allocated) |
114 ** "digest" the digest to sign | 112 ** "digest" the digest to sign |
115 ** "privKey" the private key to encrypt with | 113 ** "privKey" the private key to encrypt with |
116 ** "algtag" The algorithm tag to encode (need for RSA only) | 114 ** "algtag" The algorithm tag to encode (need for RSA only) |
117 */ | 115 */ |
118 extern SECStatus SGN_Digest(SECKEYPrivateKey *privKey, | 116 extern SECStatus SGN_Digest(SECKEYPrivateKey *privKey, |
119 SECOidTag algtag, SECItem *result, SECItem *digest); | 117 SECOidTag algtag, SECItem *result, SECItem *digest); |
120 | 118 |
121 /* | 119 /* |
122 ** DER sign a single block of data using private key encryption and the | 120 ** DER sign a single block of data using private key encryption and the |
123 ** MD5 hashing algorithm. This routine first computes a digital signature | 121 ** MD5 hashing algorithm. This routine first computes a digital signature |
124 ** using SEC_SignData, then wraps it with an CERTSignedData and then der | 122 ** using SEC_SignData, then wraps it with an CERTSignedData and then der |
125 ** encodes the result. | 123 ** encodes the result. |
126 ** "arena" is the memory arena to use to allocate data from | 124 ** "arena" is the memory arena to use to allocate data from |
127 ** "result" the final der encoded data (memory is allocated) | 125 ** "result" the final der encoded data (memory is allocated) |
128 ** "buf" the input data to sign | 126 ** "buf" the input data to sign |
129 ** "len" the amount of data to sign | 127 ** "len" the amount of data to sign |
130 ** "pk" the private key to encrypt with | 128 ** "pk" the private key to encrypt with |
131 */ | 129 */ |
132 extern SECStatus SEC_DerSignData(PLArenaPool *arena, SECItem *result, | 130 extern SECStatus SEC_DerSignData(PLArenaPool *arena, SECItem *result, |
133 » » » » const unsigned char *buf, int len, | 131 const unsigned char *buf, int len, |
134 » » » » SECKEYPrivateKey *pk, SECOidTag algid); | 132 SECKEYPrivateKey *pk, SECOidTag algid); |
135 | 133 |
136 /* | 134 /* |
137 ** Destroy a signed-data object. | 135 ** Destroy a signed-data object. |
138 ** "sd" the object | 136 ** "sd" the object |
139 ** "freeit" if PR_TRUE then free the object as well as its sub-objects | 137 ** "freeit" if PR_TRUE then free the object as well as its sub-objects |
140 */ | 138 */ |
141 extern void SEC_DestroySignedData(CERTSignedData *sd, PRBool freeit); | 139 extern void SEC_DestroySignedData(CERTSignedData *sd, PRBool freeit); |
142 | 140 |
143 /* | 141 /* |
144 ** Get the signature algorithm tag number for the given key type and hash | 142 ** Get the signature algorithm tag number for the given key type and hash |
145 ** algorithm tag. Returns SEC_OID_UNKNOWN if key type and hash algorithm | 143 ** algorithm tag. Returns SEC_OID_UNKNOWN if key type and hash algorithm |
146 ** do not match or are not supported. | 144 ** do not match or are not supported. |
147 */ | 145 */ |
148 extern SECOidTag SEC_GetSignatureAlgorithmOidTag(KeyType keyType, | 146 extern SECOidTag SEC_GetSignatureAlgorithmOidTag(KeyType keyType, |
149 SECOidTag hashAlgTag); | 147 SECOidTag hashAlgTag); |
150 | 148 |
151 /****************************************/ | 149 /****************************************/ |
152 /* | 150 /* |
153 ** Signature verification operations | 151 ** Signature verification operations |
154 */ | 152 */ |
155 | 153 |
156 /* | 154 /* |
157 ** Create a signature verification context. This version is deprecated, | 155 ** Create a signature verification context. This version is deprecated, |
158 ** This function is deprecated. Use VFY_CreateContextDirect or | 156 ** This function is deprecated. Use VFY_CreateContextDirect or |
159 ** VFY_CreateContextWithAlgorithmID instead. | 157 ** VFY_CreateContextWithAlgorithmID instead. |
160 ** "key" the public key to verify with | 158 ** "key" the public key to verify with |
161 ** "sig" the encrypted signature data if sig is NULL then | 159 ** "sig" the encrypted signature data if sig is NULL then |
162 ** VFY_EndWithSignature must be called with the correct signature at | 160 ** VFY_EndWithSignature must be called with the correct signature at |
163 ** the end of the processing. | 161 ** the end of the processing. |
164 **» "sigAlg" specifies the signing algorithm to use (including the | 162 **» "sigAlg" specifies the signing algorithm to use (including the |
165 ** hash algorthim). This must match the key type. | 163 ** hash algorthim). This must match the key type. |
166 ** "wincx" void pointer to the window context | 164 ** "wincx" void pointer to the window context |
167 */ | 165 */ |
168 extern VFYContext *VFY_CreateContext(SECKEYPublicKey *key, SECItem *sig, | 166 extern VFYContext *VFY_CreateContext(SECKEYPublicKey *key, SECItem *sig, |
169 » » » » SECOidTag sigAlg, void *wincx); | 167 SECOidTag sigAlg, void *wincx); |
170 /* | 168 /* |
171 ** Create a signature verification context. | 169 ** Create a signature verification context. |
172 ** "key" the public key to verify with | 170 ** "key" the public key to verify with |
173 ** "sig" the encrypted signature data if sig is NULL then | 171 ** "sig" the encrypted signature data if sig is NULL then |
174 ** VFY_EndWithSignature must be called with the correct signature at | 172 ** VFY_EndWithSignature must be called with the correct signature at |
175 ** the end of the processing. | 173 ** the end of the processing. |
176 ** "pubkAlg" specifies the cryptographic signing algorithm to use (the | 174 ** "pubkAlg" specifies the cryptographic signing algorithm to use (the |
177 ** raw algorithm without any hash specified. This must match the key | 175 ** raw algorithm without any hash specified. This must match the key |
178 ** type. | 176 ** type. |
179 **» "hashAlg" specifies the hashing algorithm used. If the key is an | 177 **» "hashAlg" specifies the hashing algorithm used. If the key is an |
180 ** RSA key, and sig is not NULL, then hashAlg can be SEC_OID_UNKNOWN. | 178 ** RSA key, and sig is not NULL, then hashAlg can be SEC_OID_UNKNOWN. |
181 ** the hash is selected from data in the sig. | 179 ** the hash is selected from data in the sig. |
182 ** "hash" optional pointer to return the actual hash algorithm used. | 180 ** "hash" optional pointer to return the actual hash algorithm used. |
183 ** in practice this should always match the passed in hashAlg (the | 181 ** in practice this should always match the passed in hashAlg (the |
184 ** exception is the case where hashAlg is SEC_OID_UNKNOWN above). | 182 ** exception is the case where hashAlg is SEC_OID_UNKNOWN above). |
185 ** If this value is NULL no, hash oid is returned. | 183 ** If this value is NULL no, hash oid is returned. |
186 ** "wincx" void pointer to the window context | 184 ** "wincx" void pointer to the window context |
187 */ | 185 */ |
188 extern VFYContext *VFY_CreateContextDirect(const SECKEYPublicKey *key, | 186 extern VFYContext *VFY_CreateContextDirect(const SECKEYPublicKey *key, |
189 » » » » » const SECItem *sig, | 187 const SECItem *sig, |
190 » » » » » SECOidTag pubkAlg, | 188 SECOidTag pubkAlg, |
191 » » » » » SECOidTag hashAlg, | 189 SECOidTag hashAlg, |
192 » » » » » SECOidTag *hash, void *wincx); | 190 SECOidTag *hash, void *wincx); |
193 /* | 191 /* |
194 ** Create a signature verification context from a algorithm ID. | 192 ** Create a signature verification context from a algorithm ID. |
195 ** "key" the public key to verify with | 193 ** "key" the public key to verify with |
196 ** "sig" the encrypted signature data if sig is NULL then | 194 ** "sig" the encrypted signature data if sig is NULL then |
197 ** VFY_EndWithSignature must be called with the correct signature at | 195 ** VFY_EndWithSignature must be called with the correct signature at |
198 ** the end of the processing. | 196 ** the end of the processing. |
199 ** "algid" specifies the signing algorithm and parameters to use. | 197 ** "algid" specifies the signing algorithm and parameters to use. |
200 ** This must match the key type. | 198 ** This must match the key type. |
201 ** "hash" optional pointer to return the oid of the actual hash used in | 199 ** "hash" optional pointer to return the oid of the actual hash used in |
202 ** the signature. If this value is NULL no, hash oid is returned. | 200 ** the signature. If this value is NULL no, hash oid is returned. |
203 ** "wincx" void pointer to the window context | 201 ** "wincx" void pointer to the window context |
204 */ | 202 */ |
205 extern VFYContext *VFY_CreateContextWithAlgorithmID(const SECKEYPublicKey *key, | 203 extern VFYContext *VFY_CreateContextWithAlgorithmID(const SECKEYPublicKey *key, |
206 » » » » const SECItem *sig, | 204 const SECItem *sig, |
207 » » » » const SECAlgorithmID *algid, | 205 const SECAlgorithmID *algid, |
208 » » » » SECOidTag *hash, | 206 SECOidTag *hash, |
209 » » » » void *wincx); | 207 void *wincx); |
210 | 208 |
211 /* | 209 /* |
212 ** Destroy a verification-context object. | 210 ** Destroy a verification-context object. |
213 ** "cx" the context to destroy | 211 ** "cx" the context to destroy |
214 ** "freeit" if PR_TRUE then free the object as well as its sub-objects | 212 ** "freeit" if PR_TRUE then free the object as well as its sub-objects |
215 */ | 213 */ |
216 extern void VFY_DestroyContext(VFYContext *cx, PRBool freeit); | 214 extern void VFY_DestroyContext(VFYContext *cx, PRBool freeit); |
217 | 215 |
218 extern SECStatus VFY_Begin(VFYContext *cx); | 216 extern SECStatus VFY_Begin(VFYContext *cx); |
219 | 217 |
220 /* | 218 /* |
221 ** Update a verification context with more input data. The input data | 219 ** Update a verification context with more input data. The input data |
222 ** is fed to a secure hash function (depending on what was in the | 220 ** is fed to a secure hash function (depending on what was in the |
223 ** encrypted signature data). | 221 ** encrypted signature data). |
224 ** "cx" the context | 222 ** "cx" the context |
225 ** "input" the input data | 223 ** "input" the input data |
226 ** "inputLen" the amount of input data | 224 ** "inputLen" the amount of input data |
227 */ | 225 */ |
228 extern SECStatus VFY_Update(VFYContext *cx, const unsigned char *input, | 226 extern SECStatus VFY_Update(VFYContext *cx, const unsigned char *input, |
229 » » » unsigned int inputLen); | 227 unsigned int inputLen); |
230 | 228 |
231 /* | 229 /* |
232 ** Finish the verification process. The return value is a status which | 230 ** Finish the verification process. The return value is a status which |
233 ** indicates success or failure. On success, the SECSuccess value is | 231 ** indicates success or failure. On success, the SECSuccess value is |
234 ** returned. Otherwise, SECFailure is returned and the error code found | 232 ** returned. Otherwise, SECFailure is returned and the error code found |
235 ** using PORT_GetError() indicates what failure occurred. | 233 ** using PORT_GetError() indicates what failure occurred. |
236 ** "cx" the context | 234 ** "cx" the context |
237 */ | 235 */ |
238 extern SECStatus VFY_End(VFYContext *cx); | 236 extern SECStatus VFY_End(VFYContext *cx); |
239 | 237 |
240 /* | 238 /* |
241 ** Finish the verification process. The return value is a status which | 239 ** Finish the verification process. The return value is a status which |
242 ** indicates success or failure. On success, the SECSuccess value is | 240 ** indicates success or failure. On success, the SECSuccess value is |
243 ** returned. Otherwise, SECFailure is returned and the error code found | 241 ** returned. Otherwise, SECFailure is returned and the error code found |
244 ** using PORT_GetError() indicates what failure occurred. If signature is | 242 ** using PORT_GetError() indicates what failure occurred. If signature is |
245 ** supplied the verification uses this signature to verify, otherwise the | 243 ** supplied the verification uses this signature to verify, otherwise the |
246 ** signature passed in VFY_CreateContext() is used. | 244 ** signature passed in VFY_CreateContext() is used. |
247 ** VFY_EndWithSignature(cx,NULL); is identical to VFY_End(cx);. | 245 ** VFY_EndWithSignature(cx,NULL); is identical to VFY_End(cx);. |
248 ** "cx" the context | 246 ** "cx" the context |
249 ** "sig" the encrypted signature data | 247 ** "sig" the encrypted signature data |
250 */ | 248 */ |
251 extern SECStatus VFY_EndWithSignature(VFYContext *cx, SECItem *sig); | 249 extern SECStatus VFY_EndWithSignature(VFYContext *cx, SECItem *sig); |
252 | 250 |
253 | |
254 /* | 251 /* |
255 ** Verify the signature on a block of data for which we already have | 252 ** Verify the signature on a block of data for which we already have |
256 ** the digest. The signature data is an RSA private key encrypted | 253 ** the digest. The signature data is an RSA private key encrypted |
257 ** block of data formatted according to PKCS#1. | 254 ** block of data formatted according to PKCS#1. |
258 ** This function is deprecated. Use VFY_VerifyDigestDirect or | 255 ** This function is deprecated. Use VFY_VerifyDigestDirect or |
259 ** VFY_VerifyDigestWithAlgorithmID instead. | 256 ** VFY_VerifyDigestWithAlgorithmID instead. |
260 ** "dig" the digest | 257 ** "dig" the digest |
261 ** "key" the public key to check the signature with | 258 ** "key" the public key to check the signature with |
262 ** "sig" the encrypted signature data | 259 ** "sig" the encrypted signature data |
263 ** "sigAlg" specifies the signing algorithm to use. This must match | 260 ** "sigAlg" specifies the signing algorithm to use. This must match |
264 ** the key type. | 261 ** the key type. |
265 ** "wincx" void pointer to the window context | 262 ** "wincx" void pointer to the window context |
266 **/ | 263 **/ |
267 extern SECStatus VFY_VerifyDigest(SECItem *dig, SECKEYPublicKey *key, | 264 extern SECStatus VFY_VerifyDigest(SECItem *dig, SECKEYPublicKey *key, |
268 » » » » SECItem *sig, SECOidTag sigAlg, void *wincx); | 265 SECItem *sig, SECOidTag sigAlg, void *wincx); |
269 /* | 266 /* |
270 ** Verify the signature on a block of data for which we already have | 267 ** Verify the signature on a block of data for which we already have |
271 ** the digest. The signature data is an RSA private key encrypted | 268 ** the digest. The signature data is an RSA private key encrypted |
272 ** block of data formatted according to PKCS#1. | 269 ** block of data formatted according to PKCS#1. |
273 ** "dig" the digest | 270 ** "dig" the digest |
274 ** "key" the public key to check the signature with | 271 ** "key" the public key to check the signature with |
275 ** "sig" the encrypted signature data | 272 ** "sig" the encrypted signature data |
276 ** "pubkAlg" specifies the cryptographic signing algorithm to use (the | 273 ** "pubkAlg" specifies the cryptographic signing algorithm to use (the |
277 ** raw algorithm without any hash specified. This must match the key | 274 ** raw algorithm without any hash specified. This must match the key |
278 ** type. | 275 ** type. |
279 ** "hashAlg" specifies the hashing algorithm used. | 276 ** "hashAlg" specifies the hashing algorithm used. |
280 ** "wincx" void pointer to the window context | 277 ** "wincx" void pointer to the window context |
281 **/ | 278 **/ |
282 extern SECStatus VFY_VerifyDigestDirect(const SECItem *dig, | 279 extern SECStatus VFY_VerifyDigestDirect(const SECItem *dig, |
283 » » » » » const SECKEYPublicKey *key, | 280 const SECKEYPublicKey *key, |
284 » » » » » const SECItem *sig, SECOidTag pubkAlg, | 281 const SECItem *sig, SECOidTag pubkAlg, |
285 » » » » » SECOidTag hashAlg, void *wincx); | 282 SECOidTag hashAlg, void *wincx); |
286 /* | 283 /* |
287 ** Verify the signature on a block of data for which we already have | 284 ** Verify the signature on a block of data for which we already have |
288 ** the digest. The signature data is an RSA private key encrypted | 285 ** the digest. The signature data is an RSA private key encrypted |
289 ** block of data formatted according to PKCS#1. | 286 ** block of data formatted according to PKCS#1. |
290 ** "key" the public key to verify with | 287 ** "key" the public key to verify with |
291 ** "sig" the encrypted signature data if sig is NULL then | 288 ** "sig" the encrypted signature data if sig is NULL then |
292 ** VFY_EndWithSignature must be called with the correct signature at | 289 ** VFY_EndWithSignature must be called with the correct signature at |
293 ** the end of the processing. | 290 ** the end of the processing. |
294 ** "algid" specifies the signing algorithm and parameters to use. | 291 ** "algid" specifies the signing algorithm and parameters to use. |
295 ** This must match the key type. | 292 ** This must match the key type. |
296 ** "hash" oid of the actual hash used to create digest. If this value is | 293 ** "hash" oid of the actual hash used to create digest. If this value is |
297 ** not set to SEC_OID_UNKNOWN, it must match the hash of the signature. | 294 ** not set to SEC_OID_UNKNOWN, it must match the hash of the signature. |
298 ** "wincx" void pointer to the window context | 295 ** "wincx" void pointer to the window context |
299 */ | 296 */ |
300 extern SECStatus VFY_VerifyDigestWithAlgorithmID(const SECItem *dig, | 297 extern SECStatus VFY_VerifyDigestWithAlgorithmID(const SECItem *dig, |
301 » » » » const SECKEYPublicKey *key, const SECItem *sig, | 298 const SECKEYPublicKey *key, con
st SECItem *sig, |
302 » » » » const SECAlgorithmID *algid, SECOidTag hash, | 299 const SECAlgorithmID *algid, SE
COidTag hash, |
303 » » » » void *wincx); | 300 void *wincx); |
304 | 301 |
305 /* | 302 /* |
306 ** Verify the signature on a block of data. The signature data is an RSA | 303 ** Verify the signature on a block of data. The signature data is an RSA |
307 ** private key encrypted block of data formatted according to PKCS#1. | 304 ** private key encrypted block of data formatted according to PKCS#1. |
308 ** This function is deprecated. Use VFY_VerifyDataDirect or | 305 ** This function is deprecated. Use VFY_VerifyDataDirect or |
309 ** VFY_VerifyDataWithAlgorithmID instead. | 306 ** VFY_VerifyDataWithAlgorithmID instead. |
310 ** "buf" the input data | 307 ** "buf" the input data |
311 ** "len" the length of the input data | 308 ** "len" the length of the input data |
312 ** "key" the public key to check the signature with | 309 ** "key" the public key to check the signature with |
313 ** "sig" the encrypted signature data | 310 ** "sig" the encrypted signature data |
314 ** "sigAlg" specifies the signing algorithm to use. This must match | 311 ** "sigAlg" specifies the signing algorithm to use. This must match |
315 ** the key type. | 312 ** the key type. |
316 ** "wincx" void pointer to the window context | 313 ** "wincx" void pointer to the window context |
317 */ | 314 */ |
318 extern SECStatus VFY_VerifyData(const unsigned char *buf, int len, | 315 extern SECStatus VFY_VerifyData(const unsigned char *buf, int len, |
319 » » » » const SECKEYPublicKey *key, const SECItem *sig, | 316 const SECKEYPublicKey *key, const SECItem *sig, |
320 » » » » SECOidTag sigAlg, void *wincx); | 317 SECOidTag sigAlg, void *wincx); |
321 /* | 318 /* |
322 ** Verify the signature on a block of data. The signature data is an RSA | 319 ** Verify the signature on a block of data. The signature data is an RSA |
323 ** private key encrypted block of data formatted according to PKCS#1. | 320 ** private key encrypted block of data formatted according to PKCS#1. |
324 ** "buf" the input data | 321 ** "buf" the input data |
325 ** "len" the length of the input data | 322 ** "len" the length of the input data |
326 ** "key" the public key to check the signature with | 323 ** "key" the public key to check the signature with |
327 ** "sig" the encrypted signature data | 324 ** "sig" the encrypted signature data |
328 ** "pubkAlg" specifies the cryptographic signing algorithm to use (the | 325 ** "pubkAlg" specifies the cryptographic signing algorithm to use (the |
329 ** raw algorithm without any hash specified. This must match the key | 326 ** raw algorithm without any hash specified. This must match the key |
330 ** type. | 327 ** type. |
331 **» "hashAlg" specifies the hashing algorithm used. If the key is an | 328 **» "hashAlg" specifies the hashing algorithm used. If the key is an |
332 ** RSA key, and sig is not NULL, then hashAlg can be SEC_OID_UNKNOWN. | 329 ** RSA key, and sig is not NULL, then hashAlg can be SEC_OID_UNKNOWN. |
333 ** the hash is selected from data in the sig. | 330 ** the hash is selected from data in the sig. |
334 ** "hash" optional pointer to return the actual hash algorithm used. | 331 ** "hash" optional pointer to return the actual hash algorithm used. |
335 ** in practice this should always match the passed in hashAlg (the | 332 ** in practice this should always match the passed in hashAlg (the |
336 ** exception is the case where hashAlg is SEC_OID_UNKNOWN above). | 333 ** exception is the case where hashAlg is SEC_OID_UNKNOWN above). |
337 ** If this value is NULL no, hash oid is returned. | 334 ** If this value is NULL no, hash oid is returned. |
338 ** "wincx" void pointer to the window context | 335 ** "wincx" void pointer to the window context |
339 */ | 336 */ |
340 extern SECStatus VFY_VerifyDataDirect(const unsigned char *buf, int len, | 337 extern SECStatus VFY_VerifyDataDirect(const unsigned char *buf, int len, |
341 » » » » const SECKEYPublicKey *key, | 338 const SECKEYPublicKey *key, |
342 » » » » const SECItem *sig, | 339 const SECItem *sig, |
343 » » » » SECOidTag pubkAlg, SECOidTag hashAlg, | 340 SECOidTag pubkAlg, SECOidTag hashAlg, |
344 » » » » SECOidTag *hash, void *wincx); | 341 SECOidTag *hash, void *wincx); |
345 | 342 |
346 /* | 343 /* |
347 ** Verify the signature on a block of data. The signature data is an RSA | 344 ** Verify the signature on a block of data. The signature data is an RSA |
348 ** private key encrypted block of data formatted according to PKCS#1. | 345 ** private key encrypted block of data formatted according to PKCS#1. |
349 ** "buf" the input data | 346 ** "buf" the input data |
350 ** "len" the length of the input data | 347 ** "len" the length of the input data |
351 ** "key" the public key to check the signature with | 348 ** "key" the public key to check the signature with |
352 ** "sig" the encrypted signature data | 349 ** "sig" the encrypted signature data |
353 ** "algid" specifies the signing algorithm and parameters to use. | 350 ** "algid" specifies the signing algorithm and parameters to use. |
354 ** This must match the key type. | 351 ** This must match the key type. |
355 ** "hash" optional pointer to return the oid of the actual hash used in | 352 ** "hash" optional pointer to return the oid of the actual hash used in |
356 ** the signature. If this value is NULL no, hash oid is returned. | 353 ** the signature. If this value is NULL no, hash oid is returned. |
357 ** "wincx" void pointer to the window context | 354 ** "wincx" void pointer to the window context |
358 */ | 355 */ |
359 extern SECStatus VFY_VerifyDataWithAlgorithmID(const unsigned char *buf, | 356 extern SECStatus VFY_VerifyDataWithAlgorithmID(const unsigned char *buf, |
360 » » » » int len, const SECKEYPublicKey *key, | 357 int len, const SECKEYPublicKey *k
ey, |
361 » » » » const SECItem *sig, | 358 const SECItem *sig, |
362 » » » » const SECAlgorithmID *algid, SECOidTag *hash, | 359 const SECAlgorithmID *algid, SECO
idTag *hash, |
363 » » » » void *wincx); | 360 void *wincx); |
364 | |
365 | 361 |
366 SEC_END_PROTOS | 362 SEC_END_PROTOS |
367 | 363 |
368 #endif /* _CRYPTOHI_H_ */ | 364 #endif /* _CRYPTOHI_H_ */ |
OLD | NEW |