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 19 matching lines...) Expand all Loading... |
30 SGNContext *cx; | 30 SGNContext *cx; |
31 SECOidTag hashalg, signalg; | 31 SECOidTag hashalg, signalg; |
32 KeyType keyType; | 32 KeyType keyType; |
33 SECStatus rv; | 33 SECStatus rv; |
34 | 34 |
35 /* OK, map a PKCS #7 hash and encrypt algorithm into | 35 /* OK, map a PKCS #7 hash and encrypt algorithm into |
36 * a standard hashing algorithm. Why did we pass in the whole | 36 * a standard hashing algorithm. Why did we pass in the whole |
37 * PKCS #7 algTag if we were just going to change here you might | 37 * PKCS #7 algTag if we were just going to change here you might |
38 * ask. Well the answer is for some cards we may have to do the | 38 * ask. Well the answer is for some cards we may have to do the |
39 * hashing on card. It may not support CKM_RSA_PKCS sign algorithm, | 39 * hashing on card. It may not support CKM_RSA_PKCS sign algorithm, |
40 * it may just support CKM_RSA_PKCS_WITH_SHA1 and/or CKM_RSA_PKCS_WITH_MD5. | 40 * it may just support CKM_SHA1_RSA_PKCS and/or CKM_MD5_RSA_PKCS. |
41 */ | 41 */ |
42 /* we have a private key, not a public key, so don't pass it in */ | 42 /* we have a private key, not a public key, so don't pass it in */ |
43 rv = sec_DecodeSigAlg(NULL, alg, NULL, &signalg, &hashalg); | 43 rv = sec_DecodeSigAlg(NULL, alg, NULL, &signalg, &hashalg); |
44 if (rv != SECSuccess) { | 44 if (rv != SECSuccess) { |
45 PORT_SetError(SEC_ERROR_INVALID_ALGORITHM); | 45 PORT_SetError(SEC_ERROR_INVALID_ALGORITHM); |
46 return 0; | 46 return 0; |
47 } | 47 } |
48 keyType = seckey_GetKeyType(signalg); | 48 keyType = seckey_GetKeyType(signalg); |
49 | 49 |
50 /* verify our key type */ | 50 /* verify our key type */ |
(...skipping 436 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 |