OLD | NEW |
1 /* | 1 /* |
2 * Signature stuff. | 2 * Signature stuff. |
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 #include <stdio.h> | 8 #include <stdio.h> |
9 #include "cryptohi.h" | 9 #include "cryptohi.h" |
10 #include "sechash.h" | 10 #include "sechash.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 }; | 135 }; |
136 | 136 |
137 SECStatus | 137 SECStatus |
138 SGN_End(SGNContext *cx, SECItem *result) | 138 SGN_End(SGNContext *cx, SECItem *result) |
139 { | 139 { |
140 unsigned char digest[HASH_LENGTH_MAX]; | 140 unsigned char digest[HASH_LENGTH_MAX]; |
141 unsigned part1; | 141 unsigned part1; |
142 int signatureLen; | 142 int signatureLen; |
143 SECStatus rv; | 143 SECStatus rv; |
144 SECItem digder, sigitem; | 144 SECItem digder, sigitem; |
145 PRArenaPool *arena = 0; | 145 PLArenaPool *arena = 0; |
146 SECKEYPrivateKey *privKey = cx->key; | 146 SECKEYPrivateKey *privKey = cx->key; |
147 SGNDigestInfo *di = 0; | 147 SGNDigestInfo *di = 0; |
148 | 148 |
149 result->data = 0; | 149 result->data = 0; |
150 digder.data = 0; | 150 digder.data = 0; |
151 | 151 |
152 /* Finish up digest function */ | 152 /* Finish up digest function */ |
153 if (cx->hashcx == NULL) { | 153 if (cx->hashcx == NULL) { |
154 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 154 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
155 return SECFailure; | 155 return SECFailure; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate), }, | 291 SEC_ASN1_SUB(SECOID_AlgorithmIDTemplate), }, |
292 { SEC_ASN1_BIT_STRING, | 292 { SEC_ASN1_BIT_STRING, |
293 offsetof(CERTSignedData,signature), }, | 293 offsetof(CERTSignedData,signature), }, |
294 { 0, } | 294 { 0, } |
295 }; | 295 }; |
296 | 296 |
297 SEC_ASN1_CHOOSER_IMPLEMENT(CERT_SignedDataTemplate) | 297 SEC_ASN1_CHOOSER_IMPLEMENT(CERT_SignedDataTemplate) |
298 | 298 |
299 | 299 |
300 SECStatus | 300 SECStatus |
301 SEC_DerSignData(PRArenaPool *arena, SECItem *result, | 301 SEC_DerSignData(PLArenaPool *arena, SECItem *result, |
302 const unsigned char *buf, int len, SECKEYPrivateKey *pk, | 302 const unsigned char *buf, int len, SECKEYPrivateKey *pk, |
303 SECOidTag algID) | 303 SECOidTag algID) |
304 { | 304 { |
305 SECItem it; | 305 SECItem it; |
306 CERTSignedData sd; | 306 CERTSignedData sd; |
307 SECStatus rv; | 307 SECStatus rv; |
308 | 308 |
309 it.data = 0; | 309 it.data = 0; |
310 | 310 |
311 /* XXX We should probably have some asserts here to make sure the key type | 311 /* XXX We should probably have some asserts here to make sure the key type |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 return rv; | 362 return rv; |
363 } | 363 } |
364 | 364 |
365 SECStatus | 365 SECStatus |
366 SGN_Digest(SECKEYPrivateKey *privKey, | 366 SGN_Digest(SECKEYPrivateKey *privKey, |
367 SECOidTag algtag, SECItem *result, SECItem *digest) | 367 SECOidTag algtag, SECItem *result, SECItem *digest) |
368 { | 368 { |
369 int modulusLen; | 369 int modulusLen; |
370 SECStatus rv; | 370 SECStatus rv; |
371 SECItem digder; | 371 SECItem digder; |
372 PRArenaPool *arena = 0; | 372 PLArenaPool *arena = 0; |
373 SGNDigestInfo *di = 0; | 373 SGNDigestInfo *di = 0; |
374 | 374 |
375 | 375 |
376 result->data = 0; | 376 result->data = 0; |
377 | 377 |
378 if (privKey->keyType == rsaKey) { | 378 if (privKey->keyType == rsaKey) { |
379 | 379 |
380 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); | 380 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); |
381 if ( !arena ) { | 381 if ( !arena ) { |
382 rv = SECFailure; | 382 rv = SECFailure; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 case SEC_OID_SHA512: | 487 case SEC_OID_SHA512: |
488 sigTag = SEC_OID_ANSIX962_ECDSA_SHA512_SIGNATURE; break; | 488 sigTag = SEC_OID_ANSIX962_ECDSA_SHA512_SIGNATURE; break; |
489 default: | 489 default: |
490 break; | 490 break; |
491 } | 491 } |
492 default: | 492 default: |
493 break; | 493 break; |
494 } | 494 } |
495 return sigTag; | 495 return sigTag; |
496 } | 496 } |
OLD | NEW |