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

Side by Side Diff: nss/lib/cryptohi/seckey.c

Issue 16132005: Allow NSS to be built with NO_NSPR_10_SUPPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « nss/lib/certhigh/ocspti.h ('k') | nss/lib/cryptohi/secsign.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "cryptohi.h" 4 #include "cryptohi.h"
5 #include "keyhi.h" 5 #include "keyhi.h"
6 #include "secoid.h" 6 #include "secoid.h"
7 #include "secitem.h" 7 #include "secitem.h"
8 #include "secder.h" 8 #include "secder.h"
9 #include "base64.h" 9 #include "base64.h"
10 #include "secasn1.h" 10 #include "secasn1.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 259 }
260 PK11_FreeSlot(pubk->pkcs11Slot); 260 PK11_FreeSlot(pubk->pkcs11Slot);
261 } 261 }
262 if (pubk->arena) { 262 if (pubk->arena) {
263 PORT_FreeArena(pubk->arena, PR_FALSE); 263 PORT_FreeArena(pubk->arena, PR_FALSE);
264 } 264 }
265 } 265 }
266 } 266 }
267 267
268 SECStatus 268 SECStatus
269 SECKEY_CopySubjectPublicKeyInfo(PRArenaPool *arena, 269 SECKEY_CopySubjectPublicKeyInfo(PLArenaPool *arena,
270 CERTSubjectPublicKeyInfo *to, 270 CERTSubjectPublicKeyInfo *to,
271 CERTSubjectPublicKeyInfo *from) 271 CERTSubjectPublicKeyInfo *from)
272 { 272 {
273 SECStatus rv; 273 SECStatus rv;
274 SECItem spk; 274 SECItem spk;
275 275
276 rv = SECOID_CopyAlgorithmID(arena, &to->algorithm, &from->algorithm); 276 rv = SECOID_CopyAlgorithmID(arena, &to->algorithm, &from->algorithm);
277 if (rv == SECSuccess) { 277 if (rv == SECSuccess) {
278 /* 278 /*
279 * subjectPublicKey is a bit string, whose length is in bits. 279 * subjectPublicKey is a bit string, whose length is in bits.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 return seckey_UpdateCertPQGChain(subjectCert,0); 438 return seckey_UpdateCertPQGChain(subjectCert,0);
439 } 439 }
440 440
441 441
442 /* Decode the DSA PQG parameters. The params could be stored in two 442 /* Decode the DSA PQG parameters. The params could be stored in two
443 * possible formats, the old fortezza-only wrapped format or 443 * possible formats, the old fortezza-only wrapped format or
444 * the normal standard format. Store the decoded parameters in 444 * the normal standard format. Store the decoded parameters in
445 * a V3 certificate data structure. */ 445 * a V3 certificate data structure. */
446 446
447 SECStatus 447 SECStatus
448 SECKEY_DSADecodePQG(PRArenaPool *arena, SECKEYPublicKey *pubk, SECItem *params) { 448 SECKEY_DSADecodePQG(PLArenaPool *arena, SECKEYPublicKey *pubk, SECItem *params) {
449 SECStatus rv; 449 SECStatus rv;
450 SECItem newparams; 450 SECItem newparams;
451 451
452 if (params == NULL) return SECFailure; 452 if (params == NULL) return SECFailure;
453 453
454 if (params->data == NULL) return SECFailure; 454 if (params->data == NULL) return SECFailure;
455 455
456 PORT_Assert(arena); 456 PORT_Assert(arena);
457 457
458 /* make a copy of the data into the arena so QuickDER output is valid */ 458 /* make a copy of the data into the arena so QuickDER output is valid */
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 { 543 {
544 return seckey_GetKeyType(SECOID_GetAlgorithmTag(&spki->algorithm)); 544 return seckey_GetKeyType(SECOID_GetAlgorithmTag(&spki->algorithm));
545 } 545 }
546 546
547 static SECKEYPublicKey * 547 static SECKEYPublicKey *
548 seckey_ExtractPublicKey(CERTSubjectPublicKeyInfo *spki) 548 seckey_ExtractPublicKey(CERTSubjectPublicKeyInfo *spki)
549 { 549 {
550 SECKEYPublicKey *pubk; 550 SECKEYPublicKey *pubk;
551 SECItem os, newOs, newParms; 551 SECItem os, newOs, newParms;
552 SECStatus rv; 552 SECStatus rv;
553 PRArenaPool *arena; 553 PLArenaPool *arena;
554 SECOidTag tag; 554 SECOidTag tag;
555 555
556 arena = PORT_NewArena (DER_DEFAULT_CHUNKSIZE); 556 arena = PORT_NewArena (DER_DEFAULT_CHUNKSIZE);
557 if (arena == NULL) 557 if (arena == NULL)
558 return NULL; 558 return NULL;
559 559
560 pubk = (SECKEYPublicKey *) PORT_ArenaZAlloc(arena, sizeof(SECKEYPublicKey)); 560 pubk = (SECKEYPublicKey *) PORT_ArenaZAlloc(arena, sizeof(SECKEYPublicKey));
561 if (pubk == NULL) { 561 if (pubk == NULL) {
562 PORT_FreeArena (arena, PR_FALSE); 562 PORT_FreeArena (arena, PR_FALSE);
563 return NULL; 563 return NULL;
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 break; 1019 break;
1020 } 1020 }
1021 PORT_SetError(SEC_ERROR_INVALID_KEY); 1021 PORT_SetError(SEC_ERROR_INVALID_KEY);
1022 return 0; 1022 return 0;
1023 } 1023 }
1024 1024
1025 SECKEYPrivateKey * 1025 SECKEYPrivateKey *
1026 SECKEY_CopyPrivateKey(const SECKEYPrivateKey *privk) 1026 SECKEY_CopyPrivateKey(const SECKEYPrivateKey *privk)
1027 { 1027 {
1028 SECKEYPrivateKey *copyk; 1028 SECKEYPrivateKey *copyk;
1029 PRArenaPool *arena; 1029 PLArenaPool *arena;
1030 1030
1031 if (!privk || !privk->pkcs11Slot) { 1031 if (!privk || !privk->pkcs11Slot) {
1032 PORT_SetError(SEC_ERROR_INVALID_ARGS); 1032 PORT_SetError(SEC_ERROR_INVALID_ARGS);
1033 return NULL; 1033 return NULL;
1034 } 1034 }
1035 1035
1036 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); 1036 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
1037 if (arena == NULL) { 1037 if (arena == NULL) {
1038 return NULL; 1038 return NULL;
1039 } 1039 }
(...skipping 25 matching lines...) Expand all
1065 1065
1066 fail: 1066 fail:
1067 PORT_FreeArena (arena, PR_FALSE); 1067 PORT_FreeArena (arena, PR_FALSE);
1068 return NULL; 1068 return NULL;
1069 } 1069 }
1070 1070
1071 SECKEYPublicKey * 1071 SECKEYPublicKey *
1072 SECKEY_CopyPublicKey(const SECKEYPublicKey *pubk) 1072 SECKEY_CopyPublicKey(const SECKEYPublicKey *pubk)
1073 { 1073 {
1074 SECKEYPublicKey *copyk; 1074 SECKEYPublicKey *copyk;
1075 PRArenaPool *arena; 1075 PLArenaPool *arena;
1076 SECStatus rv = SECSuccess; 1076 SECStatus rv = SECSuccess;
1077 1077
1078 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); 1078 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
1079 if (arena == NULL) { 1079 if (arena == NULL) {
1080 PORT_SetError (SEC_ERROR_NO_MEMORY); 1080 PORT_SetError (SEC_ERROR_NO_MEMORY);
1081 return NULL; 1081 return NULL;
1082 } 1082 }
1083 1083
1084 copyk = (SECKEYPublicKey *) PORT_ArenaZAlloc (arena, sizeof (SECKEYPublicKey )); 1084 copyk = (SECKEYPublicKey *) PORT_ArenaZAlloc (arena, sizeof (SECKEYPublicKey ));
1085 if (!copyk) { 1085 if (!copyk) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 1150
1151 SECKEY_DestroyPublicKey (copyk); 1151 SECKEY_DestroyPublicKey (copyk);
1152 return NULL; 1152 return NULL;
1153 } 1153 }
1154 1154
1155 1155
1156 SECKEYPublicKey * 1156 SECKEYPublicKey *
1157 SECKEY_ConvertToPublicKey(SECKEYPrivateKey *privk) 1157 SECKEY_ConvertToPublicKey(SECKEYPrivateKey *privk)
1158 { 1158 {
1159 SECKEYPublicKey *pubk; 1159 SECKEYPublicKey *pubk;
1160 PRArenaPool *arena; 1160 PLArenaPool *arena;
1161 CERTCertificate *cert; 1161 CERTCertificate *cert;
1162 SECStatus rv; 1162 SECStatus rv;
1163 1163
1164 /* 1164 /*
1165 * First try to look up the cert. 1165 * First try to look up the cert.
1166 */ 1166 */
1167 cert = PK11_GetCertFromPrivateKey(privk); 1167 cert = PK11_GetCertFromPrivateKey(privk);
1168 if (cert) { 1168 if (cert) {
1169 pubk = CERT_ExtractPublicKey(cert); 1169 pubk = CERT_ExtractPublicKey(cert);
1170 CERT_DestroyCertificate(cert); 1170 CERT_DestroyCertificate(cert);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 } 1209 }
1210 1210
1211 PORT_FreeArena (arena, PR_FALSE); 1211 PORT_FreeArena (arena, PR_FALSE);
1212 return NULL; 1212 return NULL;
1213 } 1213 }
1214 1214
1215 CERTSubjectPublicKeyInfo * 1215 CERTSubjectPublicKeyInfo *
1216 SECKEY_CreateSubjectPublicKeyInfo(SECKEYPublicKey *pubk) 1216 SECKEY_CreateSubjectPublicKeyInfo(SECKEYPublicKey *pubk)
1217 { 1217 {
1218 CERTSubjectPublicKeyInfo *spki; 1218 CERTSubjectPublicKeyInfo *spki;
1219 PRArenaPool *arena; 1219 PLArenaPool *arena;
1220 SECItem params = { siBuffer, NULL, 0 }; 1220 SECItem params = { siBuffer, NULL, 0 };
1221 1221
1222 if (!pubk) { 1222 if (!pubk) {
1223 PORT_SetError(SEC_ERROR_INVALID_ARGS); 1223 PORT_SetError(SEC_ERROR_INVALID_ARGS);
1224 return NULL; 1224 return NULL;
1225 } 1225 }
1226 1226
1227 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); 1227 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
1228 if (arena == NULL) { 1228 if (arena == NULL) {
1229 PORT_SetError(SEC_ERROR_NO_MEMORY); 1229 PORT_SetError(SEC_ERROR_NO_MEMORY);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 } 1339 }
1340 } 1340 }
1341 1341
1342 /* 1342 /*
1343 * this only works for RSA keys... need to do something 1343 * this only works for RSA keys... need to do something
1344 * similiar to CERT_ExtractPublicKey for other key times. 1344 * similiar to CERT_ExtractPublicKey for other key times.
1345 */ 1345 */
1346 SECKEYPublicKey * 1346 SECKEYPublicKey *
1347 SECKEY_DecodeDERPublicKey(SECItem *pubkder) 1347 SECKEY_DecodeDERPublicKey(SECItem *pubkder)
1348 { 1348 {
1349 PRArenaPool *arena; 1349 PLArenaPool *arena;
1350 SECKEYPublicKey *pubk; 1350 SECKEYPublicKey *pubk;
1351 SECStatus rv; 1351 SECStatus rv;
1352 SECItem newPubkder; 1352 SECItem newPubkder;
1353 1353
1354 arena = PORT_NewArena (DER_DEFAULT_CHUNKSIZE); 1354 arena = PORT_NewArena (DER_DEFAULT_CHUNKSIZE);
1355 if (arena == NULL) { 1355 if (arena == NULL) {
1356 PORT_SetError (SEC_ERROR_NO_MEMORY); 1356 PORT_SetError (SEC_ERROR_NO_MEMORY);
1357 return NULL; 1357 return NULL;
1358 } 1358 }
1359 1359
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 SECKEY_DestroySubjectPublicKeyInfo(spki); 1420 SECKEY_DestroySubjectPublicKeyInfo(spki);
1421 1421
1422 finish: 1422 finish:
1423 return spkiDER; 1423 return spkiDER;
1424 } 1424 }
1425 1425
1426 1426
1427 CERTSubjectPublicKeyInfo * 1427 CERTSubjectPublicKeyInfo *
1428 SECKEY_DecodeDERSubjectPublicKeyInfo(SECItem *spkider) 1428 SECKEY_DecodeDERSubjectPublicKeyInfo(SECItem *spkider)
1429 { 1429 {
1430 PRArenaPool *arena; 1430 PLArenaPool *arena;
1431 CERTSubjectPublicKeyInfo *spki; 1431 CERTSubjectPublicKeyInfo *spki;
1432 SECStatus rv; 1432 SECStatus rv;
1433 SECItem newSpkider; 1433 SECItem newSpkider;
1434 1434
1435 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); 1435 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
1436 if (arena == NULL) { 1436 if (arena == NULL) {
1437 PORT_SetError(SEC_ERROR_NO_MEMORY); 1437 PORT_SetError(SEC_ERROR_NO_MEMORY);
1438 return NULL; 1438 return NULL;
1439 } 1439 }
1440 1440
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 * Verify digital signature and make sure challenge matches 1485 * Verify digital signature and make sure challenge matches
1486 */ 1486 */
1487 CERTSubjectPublicKeyInfo * 1487 CERTSubjectPublicKeyInfo *
1488 SECKEY_ConvertAndDecodePublicKeyAndChallenge(char *pkacstr, char *challenge, 1488 SECKEY_ConvertAndDecodePublicKeyAndChallenge(char *pkacstr, char *challenge,
1489 void *wincx) 1489 void *wincx)
1490 { 1490 {
1491 CERTSubjectPublicKeyInfo *spki = NULL; 1491 CERTSubjectPublicKeyInfo *spki = NULL;
1492 CERTPublicKeyAndChallenge pkac; 1492 CERTPublicKeyAndChallenge pkac;
1493 SECStatus rv; 1493 SECStatus rv;
1494 SECItem signedItem; 1494 SECItem signedItem;
1495 PRArenaPool *arena = NULL; 1495 PLArenaPool *arena = NULL;
1496 CERTSignedData sd; 1496 CERTSignedData sd;
1497 SECItem sig; 1497 SECItem sig;
1498 SECKEYPublicKey *pubKey = NULL; 1498 SECKEYPublicKey *pubKey = NULL;
1499 unsigned int len; 1499 unsigned int len;
1500 1500
1501 signedItem.data = NULL; 1501 signedItem.data = NULL;
1502 1502
1503 /* convert the base64 encoded data to binary */ 1503 /* convert the base64 encoded data to binary */
1504 rv = ATOB_ConvertAsciiToItem(&signedItem, pkacstr); 1504 rv = ATOB_ConvertAsciiToItem(&signedItem, pkacstr);
1505 if (rv != SECSuccess) { 1505 if (rv != SECSuccess) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 SECKEY_DestroyPublicKey(pubKey); 1580 SECKEY_DestroyPublicKey(pubKey);
1581 } 1581 }
1582 1582
1583 return spki; 1583 return spki;
1584 } 1584 }
1585 1585
1586 void 1586 void
1587 SECKEY_DestroyPrivateKeyInfo(SECKEYPrivateKeyInfo *pvk, 1587 SECKEY_DestroyPrivateKeyInfo(SECKEYPrivateKeyInfo *pvk,
1588 PRBool freeit) 1588 PRBool freeit)
1589 { 1589 {
1590 PRArenaPool *poolp; 1590 PLArenaPool *poolp;
1591 1591
1592 if(pvk != NULL) { 1592 if(pvk != NULL) {
1593 if(pvk->arena) { 1593 if(pvk->arena) {
1594 poolp = pvk->arena; 1594 poolp = pvk->arena;
1595 /* zero structure since PORT_FreeArena does not support 1595 /* zero structure since PORT_FreeArena does not support
1596 * this yet. 1596 * this yet.
1597 */ 1597 */
1598 PORT_Memset(pvk->privateKey.data, 0, pvk->privateKey.len); 1598 PORT_Memset(pvk->privateKey.data, 0, pvk->privateKey.len);
1599 PORT_Memset((char *)pvk, 0, sizeof(*pvk)); 1599 PORT_Memset((char *)pvk, 0, sizeof(*pvk));
1600 if(freeit == PR_TRUE) { 1600 if(freeit == PR_TRUE) {
(...skipping 10 matching lines...) Expand all
1611 PORT_Free(pvk); 1611 PORT_Free(pvk);
1612 } 1612 }
1613 } 1613 }
1614 } 1614 }
1615 } 1615 }
1616 1616
1617 void 1617 void
1618 SECKEY_DestroyEncryptedPrivateKeyInfo(SECKEYEncryptedPrivateKeyInfo *epki, 1618 SECKEY_DestroyEncryptedPrivateKeyInfo(SECKEYEncryptedPrivateKeyInfo *epki,
1619 PRBool freeit) 1619 PRBool freeit)
1620 { 1620 {
1621 PRArenaPool *poolp; 1621 PLArenaPool *poolp;
1622 1622
1623 if(epki != NULL) { 1623 if(epki != NULL) {
1624 if(epki->arena) { 1624 if(epki->arena) {
1625 poolp = epki->arena; 1625 poolp = epki->arena;
1626 /* zero structure since PORT_FreeArena does not support 1626 /* zero structure since PORT_FreeArena does not support
1627 * this yet. 1627 * this yet.
1628 */ 1628 */
1629 PORT_Memset(epki->encryptedData.data, 0, epki->encryptedData.len); 1629 PORT_Memset(epki->encryptedData.data, 0, epki->encryptedData.len);
1630 PORT_Memset((char *)epki, 0, sizeof(*epki)); 1630 PORT_Memset((char *)epki, 0, sizeof(*epki));
1631 if(freeit == PR_TRUE) { 1631 if(freeit == PR_TRUE) {
1632 PORT_FreeArena(poolp, PR_TRUE); 1632 PORT_FreeArena(poolp, PR_TRUE);
1633 } else { 1633 } else {
1634 epki->arena = poolp; 1634 epki->arena = poolp;
1635 } 1635 }
1636 } else { 1636 } else {
1637 SECITEM_ZfreeItem(&epki->encryptedData, PR_FALSE); 1637 SECITEM_ZfreeItem(&epki->encryptedData, PR_FALSE);
1638 SECOID_DestroyAlgorithmID(&epki->algorithm, PR_FALSE); 1638 SECOID_DestroyAlgorithmID(&epki->algorithm, PR_FALSE);
1639 PORT_Memset((char *)epki, 0, sizeof(*epki)); 1639 PORT_Memset((char *)epki, 0, sizeof(*epki));
1640 if(freeit == PR_TRUE) { 1640 if(freeit == PR_TRUE) {
1641 PORT_Free(epki); 1641 PORT_Free(epki);
1642 } 1642 }
1643 } 1643 }
1644 } 1644 }
1645 } 1645 }
1646 1646
1647 SECStatus 1647 SECStatus
1648 SECKEY_CopyPrivateKeyInfo(PRArenaPool *poolp, 1648 SECKEY_CopyPrivateKeyInfo(PLArenaPool *poolp,
1649 SECKEYPrivateKeyInfo *to, 1649 SECKEYPrivateKeyInfo *to,
1650 SECKEYPrivateKeyInfo *from) 1650 SECKEYPrivateKeyInfo *from)
1651 { 1651 {
1652 SECStatus rv = SECFailure; 1652 SECStatus rv = SECFailure;
1653 1653
1654 if((to == NULL) || (from == NULL)) { 1654 if((to == NULL) || (from == NULL)) {
1655 return SECFailure; 1655 return SECFailure;
1656 } 1656 }
1657 1657
1658 rv = SECOID_CopyAlgorithmID(poolp, &to->algorithm, &from->algorithm); 1658 rv = SECOID_CopyAlgorithmID(poolp, &to->algorithm, &from->algorithm);
1659 if(rv != SECSuccess) { 1659 if(rv != SECSuccess) {
1660 return SECFailure; 1660 return SECFailure;
1661 } 1661 }
1662 rv = SECITEM_CopyItem(poolp, &to->privateKey, &from->privateKey); 1662 rv = SECITEM_CopyItem(poolp, &to->privateKey, &from->privateKey);
1663 if(rv != SECSuccess) { 1663 if(rv != SECSuccess) {
1664 return SECFailure; 1664 return SECFailure;
1665 } 1665 }
1666 rv = SECITEM_CopyItem(poolp, &to->version, &from->version); 1666 rv = SECITEM_CopyItem(poolp, &to->version, &from->version);
1667 1667
1668 return rv; 1668 return rv;
1669 } 1669 }
1670 1670
1671 SECStatus 1671 SECStatus
1672 SECKEY_CopyEncryptedPrivateKeyInfo(PRArenaPool *poolp, 1672 SECKEY_CopyEncryptedPrivateKeyInfo(PLArenaPool *poolp,
1673 SECKEYEncryptedPrivateKeyInfo *to, 1673 SECKEYEncryptedPrivateKeyInfo *to,
1674 SECKEYEncryptedPrivateKeyInfo *from) 1674 SECKEYEncryptedPrivateKeyInfo *from)
1675 { 1675 {
1676 SECStatus rv = SECFailure; 1676 SECStatus rv = SECFailure;
1677 1677
1678 if((to == NULL) || (from == NULL)) { 1678 if((to == NULL) || (from == NULL)) {
1679 return SECFailure; 1679 return SECFailure;
1680 } 1680 }
1681 1681
1682 rv = SECOID_CopyAlgorithmID(poolp, &to->algorithm, &from->algorithm); 1682 rv = SECOID_CopyAlgorithmID(poolp, &to->algorithm, &from->algorithm);
(...skipping 16 matching lines...) Expand all
1699 { 1699 {
1700 return pubKey->keyType; 1700 return pubKey->keyType;
1701 } 1701 }
1702 1702
1703 SECKEYPublicKey* 1703 SECKEYPublicKey*
1704 SECKEY_ImportDERPublicKey(SECItem *derKey, CK_KEY_TYPE type) 1704 SECKEY_ImportDERPublicKey(SECItem *derKey, CK_KEY_TYPE type)
1705 { 1705 {
1706 SECKEYPublicKey *pubk = NULL; 1706 SECKEYPublicKey *pubk = NULL;
1707 SECStatus rv = SECFailure; 1707 SECStatus rv = SECFailure;
1708 SECItem newDerKey; 1708 SECItem newDerKey;
1709 PRArenaPool *arena = NULL; 1709 PLArenaPool *arena = NULL;
1710 1710
1711 if (!derKey) { 1711 if (!derKey) {
1712 return NULL; 1712 return NULL;
1713 } 1713 }
1714 1714
1715 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); 1715 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
1716 if (arena == NULL) { 1716 if (arena == NULL) {
1717 PORT_SetError(SEC_ERROR_NO_MEMORY); 1717 PORT_SetError(SEC_ERROR_NO_MEMORY);
1718 goto finish; 1718 goto finish;
1719 } 1719 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 PORT_FreeArena(arena, PR_TRUE); 1759 PORT_FreeArena(arena, PR_TRUE);
1760 } 1760 }
1761 pubk = NULL; 1761 pubk = NULL;
1762 } 1762 }
1763 return pubk; 1763 return pubk;
1764 } 1764 }
1765 1765
1766 SECKEYPrivateKeyList* 1766 SECKEYPrivateKeyList*
1767 SECKEY_NewPrivateKeyList(void) 1767 SECKEY_NewPrivateKeyList(void)
1768 { 1768 {
1769 PRArenaPool *arena = NULL; 1769 PLArenaPool *arena = NULL;
1770 SECKEYPrivateKeyList *ret = NULL; 1770 SECKEYPrivateKeyList *ret = NULL;
1771 1771
1772 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); 1772 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
1773 if ( arena == NULL ) { 1773 if ( arena == NULL ) {
1774 goto loser; 1774 goto loser;
1775 } 1775 }
1776 1776
1777 ret = (SECKEYPrivateKeyList *)PORT_ArenaZAlloc(arena, 1777 ret = (SECKEYPrivateKeyList *)PORT_ArenaZAlloc(arena,
1778 sizeof(SECKEYPrivateKeyList)); 1778 sizeof(SECKEYPrivateKeyList));
1779 if ( ret == NULL ) { 1779 if ( ret == NULL ) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 return(SECSuccess); 1836 return(SECSuccess);
1837 1837
1838 loser: 1838 loser:
1839 return(SECFailure); 1839 return(SECFailure);
1840 } 1840 }
1841 1841
1842 1842
1843 SECKEYPublicKeyList* 1843 SECKEYPublicKeyList*
1844 SECKEY_NewPublicKeyList(void) 1844 SECKEY_NewPublicKeyList(void)
1845 { 1845 {
1846 PRArenaPool *arena = NULL; 1846 PLArenaPool *arena = NULL;
1847 SECKEYPublicKeyList *ret = NULL; 1847 SECKEYPublicKeyList *ret = NULL;
1848 1848
1849 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); 1849 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
1850 if ( arena == NULL ) { 1850 if ( arena == NULL ) {
1851 goto loser; 1851 goto loser;
1852 } 1852 }
1853 1853
1854 ret = (SECKEYPublicKeyList *)PORT_ArenaZAlloc(arena, 1854 ret = (SECKEYPublicKeyList *)PORT_ArenaZAlloc(arena,
1855 sizeof(SECKEYPublicKeyList)); 1855 sizeof(SECKEYPublicKeyList));
1856 if ( ret == NULL ) { 1856 if ( ret == NULL ) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 { 1928 {
1929 SECStatus rv = SECFailure; 1929 SECStatus rv = SECFailure;
1930 if (key && key->pkcs11Slot && key->pkcs11ID) { 1930 if (key && key->pkcs11Slot && key->pkcs11ID) {
1931 key->staticflags |= SECKEY_Attributes_Cached; 1931 key->staticflags |= SECKEY_Attributes_Cached;
1932 SECKEY_CacheAttribute(key, CKA_PRIVATE); 1932 SECKEY_CacheAttribute(key, CKA_PRIVATE);
1933 SECKEY_CacheAttribute(key, CKA_ALWAYS_AUTHENTICATE); 1933 SECKEY_CacheAttribute(key, CKA_ALWAYS_AUTHENTICATE);
1934 rv = SECSuccess; 1934 rv = SECSuccess;
1935 } 1935 }
1936 return rv; 1936 return rv;
1937 } 1937 }
OLDNEW
« no previous file with comments | « nss/lib/certhigh/ocspti.h ('k') | nss/lib/cryptohi/secsign.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698