Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: nss/lib/pk11wrap/pk11pbe.c

Issue 1843333003: Update NSPR to 4.12 and NSS to 3.23 on iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "plarena.h" 5 #include "plarena.h"
6 6
7 #include "seccomon.h" 7 #include "seccomon.h"
8 #include "secitem.h" 8 #include "secitem.h"
9 #include "secport.h" 9 #include "secport.h"
10 #include "hasht.h" 10 #include "hasht.h"
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 cryptoMech = PK11_AlgtagToMechanism(cipherAlgorithm); 629 cryptoMech = PK11_AlgtagToMechanism(cipherAlgorithm);
630 if (cryptoMech == CKM_INVALID_MECHANISM) { 630 if (cryptoMech == CKM_INVALID_MECHANISM) {
631 goto loser; 631 goto loser;
632 } 632 }
633 keyLength = PK11_GetMaxKeyLength(cryptoMech); 633 keyLength = PK11_GetMaxKeyLength(cryptoMech);
634 } 634 }
635 if (keyLength == 0) { 635 if (keyLength == 0) {
636 goto loser; 636 goto loser;
637 } 637 }
638 } 638 }
639 » /* currently only SEC_OID_HMAC_SHA1 is defined */ 639 » /* currently SEC_OID_HMAC_SHA1 is the default */
640 if (prfAlg == SEC_OID_UNKNOWN) { 640 if (prfAlg == SEC_OID_UNKNOWN) {
641 prfAlg = SEC_OID_HMAC_SHA1; 641 prfAlg = SEC_OID_HMAC_SHA1;
642 } 642 }
643 643
644 /* build the PKCS5v2 cipher algorithm id */ 644 /* build the PKCS5v2 cipher algorithm id */
645 cipherParams = pk11_GenerateNewParamWithKeyLen( 645 cipherParams = pk11_GenerateNewParamWithKeyLen(
646 PK11_AlgtagToMechanism(cipherAlgorithm), keyLength); 646 PK11_AlgtagToMechanism(cipherAlgorithm), keyLength);
647 if (!cipherParams) { 647 if (!cipherParams) {
648 goto loser; 648 goto loser;
649 } 649 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 } 798 }
799 paramData = (unsigned char *)pbeV2_params; 799 paramData = (unsigned char *)pbeV2_params;
800 paramLen = sizeof(CK_PKCS5_PBKD2_PARAMS); 800 paramLen = sizeof(CK_PKCS5_PBKD2_PARAMS);
801 801
802 /* set the prf */ 802 /* set the prf */
803 prfAlgTag = SEC_OID_HMAC_SHA1; 803 prfAlgTag = SEC_OID_HMAC_SHA1;
804 if (p5_param.pPrfAlgId && 804 if (p5_param.pPrfAlgId &&
805 p5_param.pPrfAlgId->algorithm.data != 0) { 805 p5_param.pPrfAlgId->algorithm.data != 0) {
806 prfAlgTag = SECOID_GetAlgorithmTag(p5_param.pPrfAlgId); 806 prfAlgTag = SECOID_GetAlgorithmTag(p5_param.pPrfAlgId);
807 } 807 }
808 » if (prfAlgTag == SEC_OID_HMAC_SHA1) { 808 switch (prfAlgTag) {
809 » pbeV2_params->prf = CKP_PKCS5_PBKD2_HMAC_SHA1; 809 case SEC_OID_HMAC_SHA1:
810 » } else { 810 pbeV2_params->prf = CKP_PKCS5_PBKD2_HMAC_SHA1;
811 » /* only SHA1_HMAC is currently supported by PKCS #11 */ 811 break;
812 » PORT_SetError(SEC_ERROR_INVALID_ALGORITHM); 812 case SEC_OID_HMAC_SHA224:
813 » goto loser; 813 pbeV2_params->prf = CKP_PKCS5_PBKD2_HMAC_SHA224;
814 » } 814 break;
815 case SEC_OID_HMAC_SHA256:
816 pbeV2_params->prf = CKP_PKCS5_PBKD2_HMAC_SHA256;
817 break;
818 case SEC_OID_HMAC_SHA384:
819 pbeV2_params->prf = CKP_PKCS5_PBKD2_HMAC_SHA384;
820 break;
821 case SEC_OID_HMAC_SHA512:
822 pbeV2_params->prf = CKP_PKCS5_PBKD2_HMAC_SHA512;
823 break;
824 default:
825 PORT_SetError(SEC_ERROR_INVALID_ALGORITHM);
826 goto loser;
827 }
815 828
816 /* probably should fetch these from the prfAlgid */ 829 /* probably should fetch these from the prfAlgid */
817 pbeV2_params->pPrfData = NULL; 830 pbeV2_params->pPrfData = NULL;
818 pbeV2_params->ulPrfDataLen = 0; 831 pbeV2_params->ulPrfDataLen = 0;
819 pbeV2_params->saltSource = CKZ_SALT_SPECIFIED; 832 pbeV2_params->saltSource = CKZ_SALT_SPECIFIED;
820 pSalt = ((CK_CHAR_PTR) pbeV2_params)+sizeof(CK_PKCS5_PBKD2_PARAMS); 833 pSalt = ((CK_CHAR_PTR) pbeV2_params)+sizeof(CK_PKCS5_PBKD2_PARAMS);
821 PORT_Memcpy(pSalt, salt->data, salt->len); 834 PORT_Memcpy(pSalt, salt->data, salt->len);
822 pbeV2_params->pSaltSourceData = pSalt; 835 pbeV2_params->pSaltSourceData = pSalt;
823 pbeV2_params->ulSaltSourceDataLen = salt->len; 836 pbeV2_params->ulSaltSourceDataLen = salt->len;
824 pbeV2_params->iterations = iterations; 837 pbeV2_params->iterations = iterations;
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 * 1436 *
1424 * This function returns both the mechanism and the parameter for the mechanism. 1437 * This function returns both the mechanism and the parameter for the mechanism.
1425 * The caller is responsible for freeing the parameter. 1438 * The caller is responsible for freeing the parameter.
1426 */ 1439 */
1427 CK_MECHANISM_TYPE 1440 CK_MECHANISM_TYPE
1428 PK11_GetPBECryptoMechanism(SECAlgorithmID *algid, SECItem **param, 1441 PK11_GetPBECryptoMechanism(SECAlgorithmID *algid, SECItem **param,
1429 SECItem *pbe_pwd) 1442 SECItem *pbe_pwd)
1430 { 1443 {
1431 return pk11_GetPBECryptoMechanism(algid, param, pbe_pwd, PR_FALSE); 1444 return pk11_GetPBECryptoMechanism(algid, param, pbe_pwd, PR_FALSE);
1432 } 1445 }
OLDNEW
« no previous file with comments | « nss/lib/pk11wrap/pk11pars.c ('k') | nss/lib/pk11wrap/pk11pub.h » ('j') | nss/lib/util/secoid.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698