OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 /* | 4 /* |
5 * This file implements PKCS 11 on top of our existing security modules | 5 * This file implements PKCS 11 on top of our existing security modules |
6 * | 6 * |
7 * For more information about PKCS 11 See PKCS 11 Token Inteface Standard. | 7 * For more information about PKCS 11 See PKCS 11 Token Inteface Standard. |
8 * This implementation has two slots: | 8 * This implementation has two slots: |
9 * slot 1 is our generic crypto support. It does not require login. | 9 * slot 1 is our generic crypto support. It does not require login. |
10 * It supports Public Key ops, and all they bulk ciphers and hashes. | 10 * It supports Public Key ops, and all they bulk ciphers and hashes. |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 if (crv != CKR_OK) return crv; | 965 if (crv != CKR_OK) return crv; |
966 crv = sftk_defaultAttribute(object,CKA_DERIVE,&derive,sizeof(CK_BBOOL)); | 966 crv = sftk_defaultAttribute(object,CKA_DERIVE,&derive,sizeof(CK_BBOOL)); |
967 if (crv != CKR_OK) return crv; | 967 if (crv != CKR_OK) return crv; |
968 | 968 |
969 object->objectInfo = sftk_GetPubKey(object,key_type, &crv); | 969 object->objectInfo = sftk_GetPubKey(object,key_type, &crv); |
970 if (object->objectInfo == NULL) { | 970 if (object->objectInfo == NULL) { |
971 return crv; | 971 return crv; |
972 } | 972 } |
973 object->infoFree = (SFTKFree) nsslowkey_DestroyPublicKey; | 973 object->infoFree = (SFTKFree) nsslowkey_DestroyPublicKey; |
974 | 974 |
| 975 /* Check that an imported EC key is valid */ |
| 976 if (key_type == CKK_EC) { |
| 977 NSSLOWKEYPublicKey *pubKey = (NSSLOWKEYPublicKey*) object->objectInfo; |
| 978 SECStatus rv = EC_ValidatePublicKey(&pubKey->u.ec.ecParams, |
| 979 &pubKey->u.ec.publicValue); |
| 980 |
| 981 if (rv != SECSuccess) { |
| 982 return CKR_TEMPLATE_INCONSISTENT; |
| 983 } |
| 984 } |
| 985 |
975 if (sftk_isTrue(object,CKA_TOKEN)) { | 986 if (sftk_isTrue(object,CKA_TOKEN)) { |
976 SFTKSlot *slot = session->slot; | 987 SFTKSlot *slot = session->slot; |
977 SFTKDBHandle *certHandle = sftk_getCertDB(slot); | 988 SFTKDBHandle *certHandle = sftk_getCertDB(slot); |
978 | 989 |
979 if (certHandle == NULL) { | 990 if (certHandle == NULL) { |
980 return CKR_TOKEN_WRITE_PROTECTED; | 991 return CKR_TOKEN_WRITE_PROTECTED; |
981 } | 992 } |
982 | 993 |
983 crv = sftkdb_write(certHandle, object, &object->handle); | 994 crv = sftkdb_write(certHandle, object, &object->handle); |
984 sftk_freeDB(certHandle); | 995 sftk_freeDB(certHandle); |
(...skipping 3787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4772 | 4783 |
4773 | 4784 |
4774 CK_RV NSC_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, | 4785 CK_RV NSC_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, |
4775 CK_VOID_PTR pReserved) | 4786 CK_VOID_PTR pReserved) |
4776 { | 4787 { |
4777 CHECK_FORK(); | 4788 CHECK_FORK(); |
4778 | 4789 |
4779 return CKR_FUNCTION_NOT_SUPPORTED; | 4790 return CKR_FUNCTION_NOT_SUPPORTED; |
4780 } | 4791 } |
4781 | 4792 |
OLD | NEW |