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 maps various PKCS #11 Mechanisms to related mechanisms, key | 5 * This file maps various PKCS #11 Mechanisms to related mechanisms, key |
6 * types, and ASN.1 encodings. | 6 * types, and ASN.1 encodings. |
7 */ | 7 */ |
8 #include "seccomon.h" | 8 #include "seccomon.h" |
9 #include "secmod.h" | 9 #include "secmod.h" |
10 #include "secmodi.h" | 10 #include "secmodi.h" |
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 */ | 1377 */ |
1378 SECItem * | 1378 SECItem * |
1379 pk11_GenerateNewParamWithKeyLen(CK_MECHANISM_TYPE type, int keyLen) | 1379 pk11_GenerateNewParamWithKeyLen(CK_MECHANISM_TYPE type, int keyLen) |
1380 { | 1380 { |
1381 CK_RC2_CBC_PARAMS *rc2_params; | 1381 CK_RC2_CBC_PARAMS *rc2_params; |
1382 CK_RC2_PARAMS *rc2_ecb_params; | 1382 CK_RC2_PARAMS *rc2_ecb_params; |
1383 SECItem *mech; | 1383 SECItem *mech; |
1384 SECItem iv; | 1384 SECItem iv; |
1385 SECStatus rv; | 1385 SECStatus rv; |
1386 | 1386 |
1387 | |
1388 mech = (SECItem *) PORT_Alloc(sizeof(SECItem)); | 1387 mech = (SECItem *) PORT_Alloc(sizeof(SECItem)); |
1389 if (mech == NULL) return NULL; | 1388 if (mech == NULL) return NULL; |
1390 | 1389 |
1391 rv = SECSuccess; | 1390 rv = SECSuccess; |
1392 mech->type = siBuffer; | 1391 mech->type = siBuffer; |
| 1392 mech->data = NULL; |
| 1393 mech->len = 0; |
1393 switch (type) { | 1394 switch (type) { |
1394 case CKM_RC4: | 1395 case CKM_RC4: |
1395 case CKM_SEED_ECB: | 1396 case CKM_SEED_ECB: |
1396 case CKM_CAMELLIA_ECB: | 1397 case CKM_CAMELLIA_ECB: |
1397 case CKM_AES_ECB: | 1398 case CKM_AES_ECB: |
1398 case CKM_DES_ECB: | 1399 case CKM_DES_ECB: |
1399 case CKM_DES3_ECB: | 1400 case CKM_DES3_ECB: |
1400 case CKM_IDEA_ECB: | 1401 case CKM_IDEA_ECB: |
1401 case CKM_CDMF_ECB: | 1402 case CKM_CDMF_ECB: |
1402 case CKM_CAST_ECB: | 1403 case CKM_CAST_ECB: |
1403 case CKM_CAST3_ECB: | 1404 case CKM_CAST3_ECB: |
1404 case CKM_CAST5_ECB: | 1405 case CKM_CAST5_ECB: |
1405 mech->data = NULL; | |
1406 mech->len = 0; | |
1407 break; | 1406 break; |
1408 case CKM_RC2_ECB: | 1407 case CKM_RC2_ECB: |
1409 rc2_ecb_params = (CK_RC2_PARAMS *)PORT_Alloc(sizeof(CK_RC2_PARAMS)); | 1408 rc2_ecb_params = (CK_RC2_PARAMS *)PORT_Alloc(sizeof(CK_RC2_PARAMS)); |
1410 if (rc2_ecb_params == NULL) { | 1409 if (rc2_ecb_params == NULL) { |
1411 rv = SECFailure; | 1410 rv = SECFailure; |
1412 break; | 1411 break; |
1413 } | 1412 } |
1414 /* NOTE PK11_GetKeyLength can return -1 if the key isn't and RC2, RC5, | 1413 /* NOTE PK11_GetKeyLength can return -1 if the key isn't and RC2, RC5, |
1415 * or RC4 key. Of course that wouldn't happen here doing RC2:).*/ | 1414 * or RC4 key. Of course that wouldn't happen here doing RC2:).*/ |
1416 *rc2_ecb_params = keyLen ? keyLen*8 : 128; | 1415 *rc2_ecb_params = keyLen ? keyLen*8 : 128; |
(...skipping 27 matching lines...) Expand all Loading... |
1444 case CKM_RC5_CBC: | 1443 case CKM_RC5_CBC: |
1445 case CKM_RC5_CBC_PAD: | 1444 case CKM_RC5_CBC_PAD: |
1446 rv = pk11_GenIV(type,&iv); | 1445 rv = pk11_GenIV(type,&iv); |
1447 if (rv != SECSuccess) { | 1446 if (rv != SECSuccess) { |
1448 break; | 1447 break; |
1449 } | 1448 } |
1450 PORT_Free(mech); | 1449 PORT_Free(mech); |
1451 return PK11_ParamFromIV(type,&iv); | 1450 return PK11_ParamFromIV(type,&iv); |
1452 default: | 1451 default: |
1453 if (pk11_lookup(type)->iv == 0) { | 1452 if (pk11_lookup(type)->iv == 0) { |
1454 mech->data = NULL; | |
1455 mech->len = 0; | |
1456 break; | 1453 break; |
1457 } | 1454 } |
1458 case CKM_SEED_CBC: | 1455 case CKM_SEED_CBC: |
1459 case CKM_CAMELLIA_CBC: | 1456 case CKM_CAMELLIA_CBC: |
1460 case CKM_AES_CBC: | 1457 case CKM_AES_CBC: |
1461 case CKM_DES_CBC: | 1458 case CKM_DES_CBC: |
1462 case CKM_DES3_CBC: | 1459 case CKM_DES3_CBC: |
1463 case CKM_IDEA_CBC: | 1460 case CKM_IDEA_CBC: |
1464 case CKM_CDMF_CBC: | 1461 case CKM_CDMF_CBC: |
1465 case CKM_CAST_CBC: | 1462 case CKM_CAST_CBC: |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1883 case SEC_OID_MISSI_DSS: | 1880 case SEC_OID_MISSI_DSS: |
1884 case SEC_OID_MISSI_DSS_OLD: | 1881 case SEC_OID_MISSI_DSS_OLD: |
1885 case SEC_OID_MISSI_KEA_DSS_OLD: | 1882 case SEC_OID_MISSI_KEA_DSS_OLD: |
1886 case SEC_OID_BOGUS_DSA_SIGNATURE_WITH_SHA1_DIGEST: | 1883 case SEC_OID_BOGUS_DSA_SIGNATURE_WITH_SHA1_DIGEST: |
1887 return SEC_OID_ANSIX9_DSA_SIGNATURE; | 1884 return SEC_OID_ANSIX9_DSA_SIGNATURE; |
1888 default: | 1885 default: |
1889 break; | 1886 break; |
1890 } | 1887 } |
1891 return algTag; | 1888 return algTag; |
1892 } | 1889 } |
OLD | NEW |