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 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 if (!prime2 || prime2->attrib.pValue != tmpKey.prime2.data) { | 2050 if (!prime2 || prime2->attrib.pValue != tmpKey.prime2.data) { |
2051 crv = sftk_forceAttribute(object, CKA_PRIME_2, | 2051 crv = sftk_forceAttribute(object, CKA_PRIME_2, |
2052 sftk_item_expand(&tmpKey.prime2)); | 2052 sftk_item_expand(&tmpKey.prime2)); |
2053 if (crv != CKR_OK) goto loser; | 2053 if (crv != CKR_OK) goto loser; |
2054 } | 2054 } |
2055 if (!exponent1 || exponent1->attrib.pValue != tmpKey.exponent1.data) { | 2055 if (!exponent1 || exponent1->attrib.pValue != tmpKey.exponent1.data) { |
2056 crv = sftk_forceAttribute(object, CKA_EXPONENT_1, | 2056 crv = sftk_forceAttribute(object, CKA_EXPONENT_1, |
2057 sftk_item_expand(&tmpKey.exponent1)); | 2057 sftk_item_expand(&tmpKey.exponent1)); |
2058 if (crv != CKR_OK) goto loser; | 2058 if (crv != CKR_OK) goto loser; |
2059 } | 2059 } |
2060 if (!exponent1 || exponent1->attrib.pValue != tmpKey.exponent1.data) { | 2060 if (!exponent2 || exponent2->attrib.pValue != tmpKey.exponent2.data) { |
2061 crv = sftk_forceAttribute(object, CKA_EXPONENT_2, | 2061 crv = sftk_forceAttribute(object, CKA_EXPONENT_2, |
2062 sftk_item_expand(&tmpKey.exponent2)); | 2062 sftk_item_expand(&tmpKey.exponent2)); |
2063 if (crv != CKR_OK) goto loser; | 2063 if (crv != CKR_OK) goto loser; |
2064 } | 2064 } |
2065 if (!exponent1 || exponent1->attrib.pValue != tmpKey.exponent1.data) { | 2065 if (!coefficient || coefficient->attrib.pValue != tmpKey.coefficient.data) { |
2066 crv = sftk_forceAttribute(object, CKA_COEFFICIENT, | 2066 crv = sftk_forceAttribute(object, CKA_COEFFICIENT, |
2067 sftk_item_expand(&tmpKey.coefficient)); | 2067 sftk_item_expand(&tmpKey.coefficient)); |
2068 if (crv != CKR_OK) goto loser; | 2068 if (crv != CKR_OK) goto loser; |
2069 } | 2069 } |
2070 rv = SECSuccess; | 2070 rv = SECSuccess; |
2071 | 2071 |
2072 /* we're done (one way or the other), clean up all our stuff */ | 2072 /* we're done (one way or the other), clean up all our stuff */ |
2073 loser: | 2073 loser: |
2074 if (tmpKey.arena) { | 2074 if (tmpKey.arena) { |
2075 PORT_FreeArena(tmpKey.arena,PR_TRUE); | 2075 PORT_FreeArena(tmpKey.arena,PR_TRUE); |
2076 } | 2076 } |
2077 if (modulus) { | 2077 if (modulus) { |
2078 sftk_FreeAttribute(modulus); | 2078 sftk_FreeAttribute(modulus); |
2079 } | 2079 } |
2080 if (prime1) { | 2080 if (prime1) { |
2081 sftk_FreeAttribute(prime1); | 2081 sftk_FreeAttribute(prime1); |
2082 } | 2082 } |
2083 if (prime2) { | 2083 if (prime2) { |
2084 sftk_FreeAttribute(prime2); | 2084 sftk_FreeAttribute(prime2); |
2085 } | 2085 } |
2086 if (privateExponent) { | 2086 if (privateExponent) { |
2087 sftk_FreeAttribute(privateExponent); | 2087 sftk_FreeAttribute(privateExponent); |
2088 } | 2088 } |
2089 if (publicExponent) { | 2089 if (publicExponent) { |
2090 sftk_FreeAttribute(publicExponent); | 2090 sftk_FreeAttribute(publicExponent); |
2091 } | 2091 } |
| 2092 if (exponent1) { |
| 2093 sftk_FreeAttribute(exponent1); |
| 2094 } |
| 2095 if (exponent2) { |
| 2096 sftk_FreeAttribute(exponent2); |
| 2097 } |
| 2098 if (coefficient) { |
| 2099 sftk_FreeAttribute(coefficient); |
| 2100 } |
2092 return rv; | 2101 return rv; |
2093 } | 2102 } |
2094 | 2103 |
2095 /* Generate a low private key structure from an object */ | 2104 /* Generate a low private key structure from an object */ |
2096 NSSLOWKEYPrivateKey * | 2105 NSSLOWKEYPrivateKey * |
2097 sftk_GetPrivKey(SFTKObject *object,CK_KEY_TYPE key_type, CK_RV *crvp) | 2106 sftk_GetPrivKey(SFTKObject *object,CK_KEY_TYPE key_type, CK_RV *crvp) |
2098 { | 2107 { |
2099 NSSLOWKEYPrivateKey *priv = NULL; | 2108 NSSLOWKEYPrivateKey *priv = NULL; |
2100 | 2109 |
2101 if (object->objclass != CKO_PRIVATE_KEY) { | 2110 if (object->objclass != CKO_PRIVATE_KEY) { |
(...skipping 2661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4763 | 4772 |
4764 | 4773 |
4765 CK_RV NSC_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, | 4774 CK_RV NSC_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, |
4766 CK_VOID_PTR pReserved) | 4775 CK_VOID_PTR pReserved) |
4767 { | 4776 { |
4768 CHECK_FORK(); | 4777 CHECK_FORK(); |
4769 | 4778 |
4770 return CKR_FUNCTION_NOT_SUPPORTED; | 4779 return CKR_FUNCTION_NOT_SUPPORTED; |
4771 } | 4780 } |
4772 | 4781 |
OLD | NEW |