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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
985 return crv; | 985 return crv; |
986 } | 986 } |
987 | 987 |
988 return CKR_OK; | 988 return CKR_OK; |
989 } | 989 } |
990 | 990 |
991 static NSSLOWKEYPrivateKey * | 991 static NSSLOWKEYPrivateKey * |
992 sftk_mkPrivKey(SFTKObject *object,CK_KEY_TYPE key, CK_RV *rvp); | 992 sftk_mkPrivKey(SFTKObject *object,CK_KEY_TYPE key, CK_RV *rvp); |
993 | 993 |
994 static SECStatus | 994 static SECStatus |
995 sftk_fillRSAPrivateKey(SFTKObject *object); | 995 sftk_verifyRSAPrivateKey(SFTKObject *object, PRBool fillIfNeeded); |
996 | 996 |
997 /* | 997 /* |
998 * check the consistancy and initialize a Private Key Object | 998 * check the consistancy and initialize a Private Key Object |
999 */ | 999 */ |
1000 static CK_RV | 1000 static CK_RV |
1001 sftk_handlePrivateKeyObject(SFTKSession *session,SFTKObject *object,CK_KEY_TYPE key_type) | 1001 sftk_handlePrivateKeyObject(SFTKSession *session,SFTKObject *object,CK_KEY_TYPE key_type) |
1002 { | 1002 { |
1003 CK_BBOOL cktrue = CK_TRUE; | 1003 CK_BBOOL cktrue = CK_TRUE; |
1004 CK_BBOOL encrypt = CK_TRUE; | 1004 CK_BBOOL encrypt = CK_TRUE; |
1005 CK_BBOOL sign = CK_FALSE; | 1005 CK_BBOOL sign = CK_FALSE; |
1006 CK_BBOOL recover = CK_TRUE; | 1006 CK_BBOOL recover = CK_TRUE; |
1007 CK_BBOOL wrap = CK_TRUE; | 1007 CK_BBOOL wrap = CK_TRUE; |
1008 CK_BBOOL derive = CK_TRUE; | 1008 CK_BBOOL derive = CK_TRUE; |
1009 CK_BBOOL ckfalse = CK_FALSE; | 1009 CK_BBOOL ckfalse = CK_FALSE; |
1010 PRBool createObjectInfo = PR_TRUE; | 1010 PRBool createObjectInfo = PR_TRUE; |
1011 PRBool fillPrivateKey = PR_FALSE; | |
1011 int missing_rsa_mod_component = 0; | 1012 int missing_rsa_mod_component = 0; |
1012 int missing_rsa_exp_component = 0; | 1013 int missing_rsa_exp_component = 0; |
1013 int missing_rsa_crt_component = 0; | 1014 int missing_rsa_crt_component = 0; |
1014 | 1015 |
1015 SECItem mod; | 1016 SECItem mod; |
1016 CK_RV crv; | 1017 CK_RV crv; |
1018 SECStatus rv; | |
1017 | 1019 |
1018 switch (key_type) { | 1020 switch (key_type) { |
1019 case CKK_RSA: | 1021 case CKK_RSA: |
1020 if ( !sftk_hasAttribute(object, CKA_MODULUS)) { | 1022 if ( !sftk_hasAttribute(object, CKA_MODULUS)) { |
1021 missing_rsa_mod_component++; | 1023 missing_rsa_mod_component++; |
1022 } | 1024 } |
1023 if ( !sftk_hasAttribute(object, CKA_PUBLIC_EXPONENT)) { | 1025 if ( !sftk_hasAttribute(object, CKA_PUBLIC_EXPONENT)) { |
1024 missing_rsa_exp_component++; | 1026 missing_rsa_exp_component++; |
1025 } | 1027 } |
1026 if ( !sftk_hasAttribute(object, CKA_PRIVATE_EXPONENT)) { | 1028 if ( !sftk_hasAttribute(object, CKA_PRIVATE_EXPONENT)) { |
(...skipping 14 matching lines...) Expand all Loading... | |
1041 if ( !sftk_hasAttribute(object, CKA_COEFFICIENT)) { | 1043 if ( !sftk_hasAttribute(object, CKA_COEFFICIENT)) { |
1042 missing_rsa_crt_component++; | 1044 missing_rsa_crt_component++; |
1043 } | 1045 } |
1044 if (missing_rsa_mod_component || missing_rsa_exp_component || | 1046 if (missing_rsa_mod_component || missing_rsa_exp_component || |
1045 missing_rsa_crt_component) { | 1047 missing_rsa_crt_component) { |
1046 /* we are missing a component, see if we have enough to rebuild | 1048 /* we are missing a component, see if we have enough to rebuild |
1047 * the rest */ | 1049 * the rest */ |
1048 int have_exp = 2- missing_rsa_exp_component; | 1050 int have_exp = 2- missing_rsa_exp_component; |
1049 int have_component = 5- | 1051 int have_component = 5- |
1050 (missing_rsa_exp_component+missing_rsa_mod_component); | 1052 (missing_rsa_exp_component+missing_rsa_mod_component); |
1051 SECStatus rv; | |
1052 | 1053 |
1053 if ((have_exp == 0) || (have_component < 3)) { | 1054 if ((have_exp == 0) || (have_component < 3)) { |
1054 /* nope, not enough to reconstruct the private key */ | 1055 /* nope, not enough to reconstruct the private key */ |
1055 return CKR_TEMPLATE_INCOMPLETE; | 1056 return CKR_TEMPLATE_INCOMPLETE; |
1056 } | 1057 } |
1057 » /*fill in the missing parameters */ | 1058 » fillPrivateKey = PR_TRUE; |
1058 » rv = sftk_fillRSAPrivateKey(object); | 1059 » } |
1059 » if (rv != SECSuccess) { | 1060 » /*verify the parameters for consistency*/ |
1061 » rv = sftk_verifyRSAPrivateKey(object, fillPrivateKey); | |
1062 » if (rv != SECSuccess) { | |
1060 return CKR_TEMPLATE_INCOMPLETE; | 1063 return CKR_TEMPLATE_INCOMPLETE; |
1061 } | |
1062 } | 1064 } |
1063 » » | 1065 |
1064 /* make sure Netscape DB attribute is set correctly */ | 1066 /* make sure Netscape DB attribute is set correctly */ |
1065 crv = sftk_Attribute2SSecItem(NULL, &mod, object, CKA_MODULUS); | 1067 crv = sftk_Attribute2SSecItem(NULL, &mod, object, CKA_MODULUS); |
1066 if (crv != CKR_OK) return crv; | 1068 if (crv != CKR_OK) return crv; |
1067 crv = sftk_forceAttribute(object, CKA_NETSCAPE_DB, | 1069 crv = sftk_forceAttribute(object, CKA_NETSCAPE_DB, |
1068 sftk_item_expand(&mod)); | 1070 sftk_item_expand(&mod)); |
1069 if (mod.data) PORT_Free(mod.data); | 1071 if (mod.data) PORT_Free(mod.data); |
1070 if (crv != CKR_OK) return crv; | 1072 if (crv != CKR_OK) return crv; |
1071 | 1073 |
1072 sign = CK_TRUE; | 1074 sign = CK_TRUE; |
1073 derive = CK_FALSE; | 1075 derive = CK_FALSE; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1147 if (crv != CKR_OK) return crv; | 1149 if (crv != CKR_OK) return crv; |
1148 crv = sftk_forceAttribute(object,CKA_NEVER_EXTRACTABLE, | 1150 crv = sftk_forceAttribute(object,CKA_NEVER_EXTRACTABLE, |
1149 &ckfalse,sizeof(CK_BBOOL)); | 1151 &ckfalse,sizeof(CK_BBOOL)); |
1150 if (crv != CKR_OK) return crv; | 1152 if (crv != CKR_OK) return crv; |
1151 | 1153 |
1152 /* should we check the non-token RSA private keys? */ | 1154 /* should we check the non-token RSA private keys? */ |
1153 | 1155 |
1154 if (sftk_isTrue(object,CKA_TOKEN)) { | 1156 if (sftk_isTrue(object,CKA_TOKEN)) { |
1155 SFTKSlot *slot = session->slot; | 1157 SFTKSlot *slot = session->slot; |
1156 SFTKDBHandle *keyHandle = sftk_getKeyDB(slot); | 1158 SFTKDBHandle *keyHandle = sftk_getKeyDB(slot); |
1157 CK_RV crv; | |
1158 | 1159 |
1159 if (keyHandle == NULL) { | 1160 if (keyHandle == NULL) { |
1160 return CKR_TOKEN_WRITE_PROTECTED; | 1161 return CKR_TOKEN_WRITE_PROTECTED; |
1161 } | 1162 } |
1162 | 1163 |
1163 crv = sftkdb_write(keyHandle, object, &object->handle); | 1164 crv = sftkdb_write(keyHandle, object, &object->handle); |
1164 sftk_freeDB(keyHandle); | 1165 sftk_freeDB(keyHandle); |
1165 return crv; | 1166 return crv; |
1166 } else if (createObjectInfo) { | 1167 } else if (createObjectInfo) { |
1167 object->objectInfo = sftk_mkPrivKey(object,key_type,&crv); | 1168 object->objectInfo = sftk_mkPrivKey(object,key_type,&crv); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1938 } | 1939 } |
1939 *crvp = crv; | 1940 *crvp = crv; |
1940 if (crv != CKR_OK) { | 1941 if (crv != CKR_OK) { |
1941 PORT_FreeArena(arena,PR_FALSE); | 1942 PORT_FreeArena(arena,PR_FALSE); |
1942 return NULL; | 1943 return NULL; |
1943 } | 1944 } |
1944 return privKey; | 1945 return privKey; |
1945 } | 1946 } |
1946 | 1947 |
1947 /* | 1948 /* |
1948 * we have a partial rsa private key, fill in the rest | 1949 * If a partial RSA private key is present, fill in the rest if necessary, |
1950 * and then verify the parameters are well-formed | |
1949 */ | 1951 */ |
1950 static SECStatus | 1952 static SECStatus |
1951 sftk_fillRSAPrivateKey(SFTKObject *object) | 1953 sftk_verifyRSAPrivateKey(SFTKObject *object, PRBool fillIfNeeded) |
1952 { | 1954 { |
1953 RSAPrivateKey tmpKey = { 0 }; | 1955 RSAPrivateKey tmpKey = { 0 }; |
1954 SFTKAttribute *modulus = NULL; | 1956 SFTKAttribute *modulus = NULL; |
1955 SFTKAttribute *prime1 = NULL; | 1957 SFTKAttribute *prime1 = NULL; |
1956 SFTKAttribute *prime2 = NULL; | 1958 SFTKAttribute *prime2 = NULL; |
1957 SFTKAttribute *privateExponent = NULL; | 1959 SFTKAttribute *privateExponent = NULL; |
1958 SFTKAttribute *publicExponent = NULL; | 1960 SFTKAttribute *publicExponent = NULL; |
1961 SFTKAttribute *exponent1 = NULL; | |
1962 SFTKAttribute *exponent2 = NULL; | |
1963 SFTKAttribute *coefficient = NULL; | |
1959 SECStatus rv; | 1964 SECStatus rv; |
1960 CK_RV crv; | 1965 CK_RV crv; |
1961 | 1966 |
1962 /* first fill in the components that we have. Populate only uses | 1967 /* first fill in the components that we have. Populate only uses |
1963 * the non-crt components, so only fill those in */ | 1968 * the non-crt components, so only fill those in */ |
1964 tmpKey.arena = NULL; | 1969 tmpKey.arena = NULL; |
1965 modulus = sftk_FindAttribute(object, CKA_MODULUS); | 1970 modulus = sftk_FindAttribute(object, CKA_MODULUS); |
1966 if (modulus) { | 1971 if (modulus) { |
1967 tmpKey.modulus.data = modulus->attrib.pValue; | 1972 tmpKey.modulus.data = modulus->attrib.pValue; |
1968 tmpKey.modulus.len = modulus->attrib.ulValueLen; | 1973 tmpKey.modulus.len = modulus->attrib.ulValueLen; |
(...skipping 10 matching lines...) Expand all Loading... | |
1979 } | 1984 } |
1980 privateExponent = sftk_FindAttribute(object, CKA_PRIVATE_EXPONENT); | 1985 privateExponent = sftk_FindAttribute(object, CKA_PRIVATE_EXPONENT); |
1981 if (privateExponent) { | 1986 if (privateExponent) { |
1982 tmpKey.privateExponent.data = privateExponent->attrib.pValue; | 1987 tmpKey.privateExponent.data = privateExponent->attrib.pValue; |
1983 tmpKey.privateExponent.len = privateExponent->attrib.ulValueLen; | 1988 tmpKey.privateExponent.len = privateExponent->attrib.ulValueLen; |
1984 } | 1989 } |
1985 publicExponent = sftk_FindAttribute(object, CKA_PUBLIC_EXPONENT); | 1990 publicExponent = sftk_FindAttribute(object, CKA_PUBLIC_EXPONENT); |
1986 if (publicExponent) { | 1991 if (publicExponent) { |
1987 tmpKey.publicExponent.data = publicExponent->attrib.pValue; | 1992 tmpKey.publicExponent.data = publicExponent->attrib.pValue; |
1988 tmpKey.publicExponent.len = publicExponent->attrib.ulValueLen; | 1993 tmpKey.publicExponent.len = publicExponent->attrib.ulValueLen; |
1989 } | 1994 } |
1995 exponent1 = sftk_FindAttribute(object, CKA_EXPONENT_1); | |
1996 if (exponent1) { | |
1997 » tmpKey.exponent1.data = exponent1->attrib.pValue; | |
1998 » tmpKey.exponent1.len = exponent1->attrib.ulValueLen; | |
1999 } | |
2000 exponent2 = sftk_FindAttribute(object, CKA_EXPONENT_2); | |
2001 if (exponent2) { | |
2002 » tmpKey.exponent2.data = exponent2->attrib.pValue; | |
2003 » tmpKey.exponent2.len = exponent2->attrib.ulValueLen; | |
2004 } | |
2005 coefficient = sftk_FindAttribute(object, CKA_COEFFICIENT); | |
2006 if (coefficient) { | |
2007 » tmpKey.coefficient.data = coefficient->attrib.pValue; | |
2008 » tmpKey.coefficient.len = coefficient->attrib.ulValueLen; | |
2009 } | |
1990 | 2010 |
1991 /* | 2011 if (fillIfNeeded) { |
1992 * populate requires one exponent plus 2 other components to work. | 2012 » /* |
1993 * we expected our caller to check that first. If that didn't happen, | 2013 » * populate requires one exponent plus 2 other components to work. |
1994 * populate will simply return an error here. | 2014 » * we expected our caller to check that first. If that didn't happen, |
1995 */ | 2015 » * populate will simply return an error here. |
1996 rv = RSA_PopulatePrivateKey(&tmpKey); | 2016 » */ |
2017 » rv = RSA_PopulatePrivateKey(&tmpKey); | |
2018 » if (rv != SECSuccess) { | |
2019 » » goto loser; | |
2020 » } | |
2021 } | |
2022 rv = RSA_PrivateKeyCheck(&tmpKey); | |
1997 if (rv != SECSuccess) { | 2023 if (rv != SECSuccess) { |
1998 goto loser; | 2024 goto loser; |
1999 } | 2025 } |
2000 | |
2001 /* now that we have a fully populated key, set all our attribute values */ | 2026 /* now that we have a fully populated key, set all our attribute values */ |
2002 rv = SECFailure; | 2027 rv = SECFailure; |
2003 crv = sftk_forceAttribute(object,CKA_MODULUS, | 2028 if (!modulus || modulus->attrib.pValue != tmpKey.modulus.data) { |
2004 sftk_item_expand(&tmpKey.modulus)); | 2029 crv = sftk_forceAttribute(object,CKA_MODULUS, |
2005 if (crv != CKR_OK) goto loser; | 2030 sftk_item_expand(&tmpKey.modulus)); |
2006 crv = sftk_forceAttribute(object,CKA_PUBLIC_EXPONENT, | 2031 if (crv != CKR_OK) goto loser; |
2007 sftk_item_expand(&tmpKey.publicExponent)); | 2032 } |
2008 if (crv != CKR_OK) goto loser; | 2033 if (!publicExponent || |
2009 crv = sftk_forceAttribute(object,CKA_PRIVATE_EXPONENT, | 2034 publicExponent->attrib.pValue != tmpKey.publicExponent.data) { |
2010 sftk_item_expand(&tmpKey.privateExponent)); | 2035 crv = sftk_forceAttribute(object, CKA_PUBLIC_EXPONENT, |
2011 if (crv != CKR_OK) goto loser; | 2036 sftk_item_expand(&tmpKey.publicExponent)); |
2012 crv = sftk_forceAttribute(object,CKA_PRIME_1, | 2037 if (crv != CKR_OK) goto loser; |
2013 sftk_item_expand(&tmpKey.prime1)); | 2038 } |
2014 if (crv != CKR_OK) goto loser; | 2039 if (!privateExponent || |
2015 crv = sftk_forceAttribute(object,CKA_PRIME_2, | 2040 privateExponent->attrib.pValue != tmpKey.privateExponent.data) { |
2016 sftk_item_expand(&tmpKey.prime2)); | 2041 crv = sftk_forceAttribute(object, CKA_PRIVATE_EXPONENT, |
2017 if (crv != CKR_OK) goto loser; | 2042 sftk_item_expand(&tmpKey.privateExponent)); |
2018 crv = sftk_forceAttribute(object,CKA_EXPONENT_1, | 2043 if (crv != CKR_OK) goto loser; |
2019 sftk_item_expand(&tmpKey.exponent1)); | 2044 } |
2020 if (crv != CKR_OK) goto loser; | 2045 if (!prime1 || prime1->attrib.pValue != tmpKey.prime1.data) { |
2021 crv = sftk_forceAttribute(object,CKA_EXPONENT_2, | 2046 crv = sftk_forceAttribute(object, CKA_PRIME_1, |
2022 sftk_item_expand(&tmpKey.exponent2)); | 2047 sftk_item_expand(&tmpKey.prime1)); |
2023 if (crv != CKR_OK) goto loser; | 2048 if (crv != CKR_OK) goto loser; |
2024 crv = sftk_forceAttribute(object,CKA_COEFFICIENT, | 2049 } |
2025 sftk_item_expand(&tmpKey.coefficient)); | 2050 if (!prime2 || prime2->attrib.pValue != tmpKey.prime2.data) { |
2026 if (crv != CKR_OK) goto loser; | 2051 crv = sftk_forceAttribute(object, CKA_PRIME_2, |
2052 sftk_item_expand(&tmpKey.prime2)); | |
2053 if (crv != CKR_OK) goto loser; | |
2054 } | |
2055 if (!exponent1 || exponent1->attrib.pValue != tmpKey.exponent1.data) { | |
2056 crv = sftk_forceAttribute(object, CKA_EXPONENT_1, | |
2057 sftk_item_expand(&tmpKey.exponent1)); | |
2058 if (crv != CKR_OK) goto loser; | |
2059 } | |
2060 if (!exponent1 || exponent1->attrib.pValue != tmpKey.exponent1.data) { | |
2061 crv = sftk_forceAttribute(object, CKA_EXPONENT_2, | |
2062 sftk_item_expand(&tmpKey.exponent2)); | |
2063 if (crv != CKR_OK) goto loser; | |
2064 } | |
2065 if (!exponent1 || exponent1->attrib.pValue != tmpKey.exponent1.data) { | |
2066 crv = sftk_forceAttribute(object, CKA_COEFFICIENT, | |
2067 sftk_item_expand(&tmpKey.coefficient)); | |
2068 if (crv != CKR_OK) goto loser; | |
2069 } | |
2027 rv = SECSuccess; | 2070 rv = SECSuccess; |
2028 | 2071 |
2029 /* 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 */ |
2030 loser: | 2073 loser: |
2031 if (tmpKey.arena) { | 2074 if (tmpKey.arena) { |
2032 PORT_FreeArena(tmpKey.arena,PR_TRUE); | 2075 PORT_FreeArena(tmpKey.arena,PR_TRUE); |
2033 } | 2076 } |
2034 if (modulus) { | 2077 if (modulus) { |
2035 sftk_FreeAttribute(modulus); | 2078 sftk_FreeAttribute(modulus); |
2036 } | 2079 } |
2037 if (prime1) { | 2080 if (prime1) { |
2038 sftk_FreeAttribute(prime1); | 2081 sftk_FreeAttribute(prime1); |
2039 } | 2082 } |
2040 if (prime2) { | 2083 if (prime2) { |
2041 sftk_FreeAttribute(prime2); | 2084 sftk_FreeAttribute(prime2); |
2042 } | 2085 } |
2043 if (privateExponent) { | 2086 if (privateExponent) { |
2044 sftk_FreeAttribute(privateExponent); | 2087 sftk_FreeAttribute(privateExponent); |
2045 } | 2088 } |
2046 if (publicExponent) { | 2089 if (publicExponent) { |
2047 sftk_FreeAttribute(publicExponent); | 2090 sftk_FreeAttribute(publicExponent); |
2048 } | 2091 } |
2049 return rv; | 2092 return rv; |
2050 } | 2093 } |
2051 | 2094 |
2052 | |
2053 | |
2054 | |
2055 | |
2056 | |
2057 | |
2058 /* Generate a low private key structure from an object */ | 2095 /* Generate a low private key structure from an object */ |
2059 NSSLOWKEYPrivateKey * | 2096 NSSLOWKEYPrivateKey * |
2060 sftk_GetPrivKey(SFTKObject *object,CK_KEY_TYPE key_type, CK_RV *crvp) | 2097 sftk_GetPrivKey(SFTKObject *object,CK_KEY_TYPE key_type, CK_RV *crvp) |
2061 { | 2098 { |
2062 NSSLOWKEYPrivateKey *priv = NULL; | 2099 NSSLOWKEYPrivateKey *priv = NULL; |
2063 | 2100 |
2064 if (object->objclass != CKO_PRIVATE_KEY) { | 2101 if (object->objclass != CKO_PRIVATE_KEY) { |
2065 *crvp = CKR_KEY_TYPE_INCONSISTENT; | 2102 *crvp = CKR_KEY_TYPE_INCONSISTENT; |
2066 return NULL; | 2103 return NULL; |
2067 } | 2104 } |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3126 | 3163 |
3127 /* NSC_GetSlotInfo obtains information about a particular slot in the system. */ | 3164 /* NSC_GetSlotInfo obtains information about a particular slot in the system. */ |
3128 CK_RV NSC_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo) | 3165 CK_RV NSC_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo) |
3129 { | 3166 { |
3130 SFTKSlot *slot = sftk_SlotFromID(slotID, PR_TRUE); | 3167 SFTKSlot *slot = sftk_SlotFromID(slotID, PR_TRUE); |
3131 | 3168 |
3132 CHECK_FORK(); | 3169 CHECK_FORK(); |
3133 | 3170 |
3134 if (slot == NULL) return CKR_SLOT_ID_INVALID; | 3171 if (slot == NULL) return CKR_SLOT_ID_INVALID; |
3135 | 3172 |
3136 pInfo->firmwareVersion.major = 0; | |
3137 pInfo->firmwareVersion.minor = 0; | |
3138 | |
3139 PORT_Memcpy(pInfo->manufacturerID,manufacturerID, | 3173 PORT_Memcpy(pInfo->manufacturerID,manufacturerID, |
3140 sizeof(pInfo->manufacturerID)); | 3174 sizeof(pInfo->manufacturerID)); |
3141 PORT_Memcpy(pInfo->slotDescription,slot->slotDescription, | 3175 PORT_Memcpy(pInfo->slotDescription,slot->slotDescription, |
3142 sizeof(pInfo->slotDescription)); | 3176 sizeof(pInfo->slotDescription)); |
3143 pInfo->flags = (slot->present) ? CKF_TOKEN_PRESENT : 0; | 3177 pInfo->flags = (slot->present) ? CKF_TOKEN_PRESENT : 0; |
3144 | 3178 |
3145 /* all user defined slots are defined as removable */ | 3179 /* all user defined slots are defined as removable */ |
3146 if (slotID >= SFTK_MIN_USER_SLOT_ID) { | 3180 if (slotID >= SFTK_MIN_USER_SLOT_ID) { |
3147 pInfo->flags |= CKF_REMOVABLE_DEVICE; | 3181 pInfo->flags |= CKF_REMOVABLE_DEVICE; |
3148 } else { | 3182 } else { |
3149 /* In the case where we are doing a merge update, we need | 3183 /* In the case where we are doing a merge update, we need |
3150 * the DB slot to be removable so the token name can change | 3184 * the DB slot to be removable so the token name can change |
3151 * appropriately. */ | 3185 * appropriately. */ |
3152 SFTKDBHandle *handle = sftk_getKeyDB(slot); | 3186 SFTKDBHandle *handle = sftk_getKeyDB(slot); |
3153 if (handle) { | 3187 if (handle) { |
3154 if (sftkdb_InUpdateMerge(handle)) { | 3188 if (sftkdb_InUpdateMerge(handle)) { |
3155 pInfo->flags |= CKF_REMOVABLE_DEVICE; | 3189 pInfo->flags |= CKF_REMOVABLE_DEVICE; |
3156 } | 3190 } |
3157 sftk_freeDB(handle); | 3191 sftk_freeDB(handle); |
3158 } | 3192 } |
3159 } | 3193 } |
3160 | 3194 |
3161 /* ok we really should read it out of the keydb file. */ | 3195 /* ok we really should read it out of the keydb file. */ |
3162 /* pInfo->hardwareVersion.major = NSSLOWKEY_DB_FILE_VERSION; */ | 3196 /* pInfo->hardwareVersion.major = NSSLOWKEY_DB_FILE_VERSION; */ |
3163 pInfo->hardwareVersion.major = SOFTOKEN_VMAJOR; | 3197 pInfo->hardwareVersion.major = SOFTOKEN_VMAJOR; |
3164 pInfo->hardwareVersion.minor = SOFTOKEN_VMINOR; | 3198 pInfo->hardwareVersion.minor = SOFTOKEN_VMINOR; |
3199 pInfo->firmwareVersion.major = SOFTOKEN_VPATCH; | |
3200 pInfo->firmwareVersion.minor = SOFTOKEN_VBUILD; | |
wtc
2014/06/04 23:58:11
Are you sure we want to abuse firmwareVersion like
Ryan Sleevi
2014/06/05 00:13:45
I'm not sure your concern - but yes, we do :)
The
wtc
2014/06/05 03:00:10
A firmware version may support multiple hardware v
| |
3165 return CKR_OK; | 3201 return CKR_OK; |
3166 } | 3202 } |
3167 | 3203 |
3168 /* | 3204 /* |
3169 * check the current state of the 'needLogin' flag in case the database has | 3205 * check the current state of the 'needLogin' flag in case the database has |
3170 * been changed underneath us. | 3206 * been changed underneath us. |
3171 */ | 3207 */ |
3172 static PRBool | 3208 static PRBool |
3173 sftk_checkNeedLogin(SFTKSlot *slot, SFTKDBHandle *keyHandle) | 3209 sftk_checkNeedLogin(SFTKSlot *slot, SFTKDBHandle *keyHandle) |
3174 { | 3210 { |
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4727 | 4763 |
4728 | 4764 |
4729 CK_RV NSC_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, | 4765 CK_RV NSC_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, |
4730 CK_VOID_PTR pReserved) | 4766 CK_VOID_PTR pReserved) |
4731 { | 4767 { |
4732 CHECK_FORK(); | 4768 CHECK_FORK(); |
4733 | 4769 |
4734 return CKR_FUNCTION_NOT_SUPPORTED; | 4770 return CKR_FUNCTION_NOT_SUPPORTED; |
4735 } | 4771 } |
4736 | 4772 |
OLD | NEW |