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 * Deal with PKCS #11 Slots. | 5 * Deal with PKCS #11 Slots. |
6 */ | 6 */ |
7 #include "seccomon.h" | 7 #include "seccomon.h" |
8 #include "secmod.h" | 8 #include "secmod.h" |
9 #include "nssilock.h" | 9 #include "nssilock.h" |
10 #include "secmodi.h" | 10 #include "secmodi.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 /************************************************************* | 23 /************************************************************* |
24 * local static and global data | 24 * local static and global data |
25 *************************************************************/ | 25 *************************************************************/ |
26 | 26 |
27 /* | 27 /* |
28 * This array helps parsing between names, mechanisms, and flags. | 28 * This array helps parsing between names, mechanisms, and flags. |
29 * to make the config files understand more entries, add them | 29 * to make the config files understand more entries, add them |
30 * to this table. | 30 * to this table. |
31 */ | 31 */ |
32 PK11DefaultArrayEntry PK11_DefaultArray[] = { | 32 const PK11DefaultArrayEntry PK11_DefaultArray[] = { |
33 { "RSA", SECMOD_RSA_FLAG, CKM_RSA_PKCS }, | 33 { "RSA", SECMOD_RSA_FLAG, CKM_RSA_PKCS }, |
34 { "DSA", SECMOD_DSA_FLAG, CKM_DSA }, | 34 { "DSA", SECMOD_DSA_FLAG, CKM_DSA }, |
| 35 { "ECC", SECMOD_ECC_FLAG, CKM_ECDSA }, |
35 { "DH", SECMOD_DH_FLAG, CKM_DH_PKCS_DERIVE }, | 36 { "DH", SECMOD_DH_FLAG, CKM_DH_PKCS_DERIVE }, |
36 { "RC2", SECMOD_RC2_FLAG, CKM_RC2_CBC }, | 37 { "RC2", SECMOD_RC2_FLAG, CKM_RC2_CBC }, |
37 { "RC4", SECMOD_RC4_FLAG, CKM_RC4 }, | 38 { "RC4", SECMOD_RC4_FLAG, CKM_RC4 }, |
38 { "DES", SECMOD_DES_FLAG, CKM_DES_CBC }, | 39 { "DES", SECMOD_DES_FLAG, CKM_DES_CBC }, |
39 { "AES", SECMOD_AES_FLAG, CKM_AES_CBC }, | 40 { "AES", SECMOD_AES_FLAG, CKM_AES_CBC }, |
40 { "Camellia", SECMOD_CAMELLIA_FLAG, CKM_CAMELLIA_CBC }, | 41 { "Camellia", SECMOD_CAMELLIA_FLAG, CKM_CAMELLIA_CBC }, |
41 { "SEED", SECMOD_SEED_FLAG, CKM_SEED_CBC }, | 42 { "SEED", SECMOD_SEED_FLAG, CKM_SEED_CBC }, |
42 { "RC5", SECMOD_RC5_FLAG, CKM_RC5_CBC }, | 43 { "RC5", SECMOD_RC5_FLAG, CKM_RC5_CBC }, |
43 { "SHA-1", SECMOD_SHA1_FLAG, CKM_SHA_1 }, | 44 { "SHA-1", SECMOD_SHA1_FLAG, CKM_SHA_1 }, |
44 /* { "SHA224", SECMOD_SHA256_FLAG, CKM_SHA224 }, */ | 45 /* { "SHA224", SECMOD_SHA256_FLAG, CKM_SHA224 }, */ |
45 { "SHA256", SECMOD_SHA256_FLAG, CKM_SHA256 }, | 46 { "SHA256", SECMOD_SHA256_FLAG, CKM_SHA256 }, |
46 /* { "SHA384", SECMOD_SHA512_FLAG, CKM_SHA384 }, */ | 47 /* { "SHA384", SECMOD_SHA512_FLAG, CKM_SHA384 }, */ |
47 { "SHA512", SECMOD_SHA512_FLAG, CKM_SHA512 }, | 48 { "SHA512", SECMOD_SHA512_FLAG, CKM_SHA512 }, |
48 { "MD5", SECMOD_MD5_FLAG, CKM_MD5 }, | 49 { "MD5", SECMOD_MD5_FLAG, CKM_MD5 }, |
49 { "MD2", SECMOD_MD2_FLAG, CKM_MD2 }, | 50 { "MD2", SECMOD_MD2_FLAG, CKM_MD2 }, |
50 { "SSL", SECMOD_SSL_FLAG, CKM_SSL3_PRE_MASTER_KEY_GEN }, | 51 { "SSL", SECMOD_SSL_FLAG, CKM_SSL3_PRE_MASTER_KEY_GEN }, |
51 { "TLS", SECMOD_TLS_FLAG, CKM_TLS_MASTER_KEY_DERIVE }, | 52 { "TLS", SECMOD_TLS_FLAG, CKM_TLS_MASTER_KEY_DERIVE }, |
52 { "SKIPJACK", SECMOD_FORTEZZA_FLAG, CKM_SKIPJACK_CBC64 }, | 53 { "SKIPJACK", SECMOD_FORTEZZA_FLAG, CKM_SKIPJACK_CBC64 }, |
53 { "Publicly-readable certs", SECMOD_FRIENDLY_FLAG, CKM_INVALID_MECHANISM
}, | 54 { "Publicly-readable certs", SECMOD_FRIENDLY_FLAG, CKM_INVALID_MECHANISM
}, |
54 { "Random Num Generator", SECMOD_RANDOM_FLAG, CKM_FAKE_RANDOM }, | 55 { "Random Num Generator", SECMOD_RANDOM_FLAG, CKM_FAKE_RANDOM }, |
55 }; | 56 }; |
56 const int num_pk11_default_mechanisms = | 57 const int num_pk11_default_mechanisms = |
57 sizeof(PK11_DefaultArray) / sizeof(PK11_DefaultArray[0]); | 58 sizeof(PK11_DefaultArray) / sizeof(PK11_DefaultArray[0]); |
58 | 59 |
59 PK11DefaultArrayEntry * | 60 const PK11DefaultArrayEntry * |
60 PK11_GetDefaultArray(int *size) | 61 PK11_GetDefaultArray(int *size) |
61 { | 62 { |
62 if (size) { | 63 if (size) { |
63 *size = num_pk11_default_mechanisms; | 64 *size = num_pk11_default_mechanisms; |
64 } | 65 } |
65 return PK11_DefaultArray; | 66 return PK11_DefaultArray; |
66 } | 67 } |
67 | 68 |
68 /* | 69 /* |
69 * These slotlists are lists of modules which provide default support for | 70 * These slotlists are lists of modules which provide default support for |
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 PK11DisableReasons | 1496 PK11DisableReasons |
1496 PK11_GetDisabledReason(PK11SlotInfo *slot) | 1497 PK11_GetDisabledReason(PK11SlotInfo *slot) |
1497 { | 1498 { |
1498 return slot->reason; | 1499 return slot->reason; |
1499 } | 1500 } |
1500 | 1501 |
1501 /* returns PR_TRUE if successfully disable the slot */ | 1502 /* returns PR_TRUE if successfully disable the slot */ |
1502 /* returns PR_FALSE otherwise */ | 1503 /* returns PR_FALSE otherwise */ |
1503 PRBool PK11_UserDisableSlot(PK11SlotInfo *slot) { | 1504 PRBool PK11_UserDisableSlot(PK11SlotInfo *slot) { |
1504 | 1505 |
| 1506 /* Prevent users from disabling the internal module. */ |
| 1507 if (slot->isInternal) { |
| 1508 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
| 1509 return PR_FALSE; |
| 1510 } |
| 1511 |
1505 slot->defaultFlags |= PK11_DISABLE_FLAG; | 1512 slot->defaultFlags |= PK11_DISABLE_FLAG; |
1506 slot->disabled = PR_TRUE; | 1513 slot->disabled = PR_TRUE; |
1507 slot->reason = PK11_DIS_USER_SELECTED; | 1514 slot->reason = PK11_DIS_USER_SELECTED; |
1508 | 1515 |
1509 return PR_TRUE; | 1516 return PR_TRUE; |
1510 } | 1517 } |
1511 | 1518 |
1512 PRBool PK11_UserEnableSlot(PK11SlotInfo *slot) { | 1519 PRBool PK11_UserEnableSlot(PK11SlotInfo *slot) { |
1513 | 1520 |
1514 slot->defaultFlags &= ~PK11_DISABLE_FLAG; | 1521 slot->defaultFlags &= ~PK11_DISABLE_FLAG; |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2390 first_time_set = PR_TRUE; | 2397 first_time_set = PR_TRUE; |
2391 } | 2398 } |
2392 if ((interval-first_time) > timeout) { | 2399 if ((interval-first_time) > timeout) { |
2393 return waitForRemoval ? PK11TokenPresent : PK11TokenRemoved; | 2400 return waitForRemoval ? PK11TokenPresent : PK11TokenRemoved; |
2394 } | 2401 } |
2395 } | 2402 } |
2396 PR_Sleep(latency); | 2403 PR_Sleep(latency); |
2397 } | 2404 } |
2398 return waitForRemoval ? PK11TokenRemoved : PK11TokenPresent; | 2405 return waitForRemoval ? PK11TokenRemoved : PK11TokenPresent; |
2399 } | 2406 } |
OLD | NEW |