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 * pkix_pl_cert.c | 5 * pkix_pl_cert.c |
6 * | 6 * |
7 * Certificate Object Functions | 7 * Certificate Object Functions |
8 * | 8 * |
9 */ | 9 */ |
10 | 10 |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 PKIX_Error * | 1508 PKIX_Error * |
1509 PKIX_PL_Cert_Create( | 1509 PKIX_PL_Cert_Create( |
1510 PKIX_PL_ByteArray *byteArray, | 1510 PKIX_PL_ByteArray *byteArray, |
1511 PKIX_PL_Cert **pCert, | 1511 PKIX_PL_Cert **pCert, |
1512 void *plContext) | 1512 void *plContext) |
1513 { | 1513 { |
1514 CERTCertificate *nssCert = NULL; | 1514 CERTCertificate *nssCert = NULL; |
1515 SECItem *derCertItem = NULL; | 1515 SECItem *derCertItem = NULL; |
1516 void *derBytes = NULL; | 1516 void *derBytes = NULL; |
1517 PKIX_UInt32 derLength; | 1517 PKIX_UInt32 derLength; |
1518 PKIX_Boolean copyDER; | |
1519 PKIX_PL_Cert *cert = NULL; | 1518 PKIX_PL_Cert *cert = NULL; |
1520 CERTCertDBHandle *handle; | 1519 CERTCertDBHandle *handle; |
1521 | 1520 |
1522 PKIX_ENTER(CERT, "PKIX_PL_Cert_Create"); | 1521 PKIX_ENTER(CERT, "PKIX_PL_Cert_Create"); |
1523 PKIX_NULLCHECK_TWO(pCert, byteArray); | 1522 PKIX_NULLCHECK_TWO(pCert, byteArray); |
1524 | 1523 |
1525 PKIX_CHECK(PKIX_PL_ByteArray_GetPointer | 1524 PKIX_CHECK(PKIX_PL_ByteArray_GetPointer |
1526 (byteArray, &derBytes, plContext), | 1525 (byteArray, &derBytes, plContext), |
1527 PKIX_BYTEARRAYGETPOINTERFAILED); | 1526 PKIX_BYTEARRAYGETPOINTERFAILED); |
1528 | 1527 |
1529 PKIX_CHECK(PKIX_PL_ByteArray_GetLength | 1528 PKIX_CHECK(PKIX_PL_ByteArray_GetLength |
1530 (byteArray, &derLength, plContext), | 1529 (byteArray, &derLength, plContext), |
1531 PKIX_BYTEARRAYGETLENGTHFAILED); | 1530 PKIX_BYTEARRAYGETLENGTHFAILED); |
1532 | 1531 |
1533 derCertItem = SECITEM_AllocItem(NULL, NULL, derLength); | 1532 derCertItem = SECITEM_AllocItem(NULL, NULL, derLength); |
1534 if (derCertItem == NULL){ | 1533 if (derCertItem == NULL){ |
1535 PKIX_ERROR(PKIX_OUTOFMEMORY); | 1534 PKIX_ERROR(PKIX_OUTOFMEMORY); |
1536 } | 1535 } |
1537 | 1536 |
1538 (void) PORT_Memcpy(derCertItem->data, derBytes, derLength); | 1537 (void) PORT_Memcpy(derCertItem->data, derBytes, derLength); |
1539 | 1538 |
1540 /* | 1539 /* |
1541 * setting copyDER to true forces NSS to make its own copy of the DER, | 1540 * setting copyDER to true forces NSS to make its own copy of the DER, |
1542 * allowing us to free our copy without worrying about whether NSS | 1541 * allowing us to free our copy without worrying about whether NSS |
1543 * is still using it | 1542 * is still using it |
1544 */ | 1543 */ |
1545 copyDER = PKIX_TRUE; | |
1546 handle = CERT_GetDefaultCertDB(); | 1544 handle = CERT_GetDefaultCertDB(); |
1547 nssCert = CERT_NewTempCertificate(handle, derCertItem, | 1545 nssCert = CERT_NewTempCertificate(handle, derCertItem, |
1548 /* nickname */ NULL, | 1546 /* nickname */ NULL, |
1549 /* isPerm */ PR_FALSE, | 1547 /* isPerm */ PR_FALSE, |
1550 /* copyDer */ PR_TRUE); | 1548 /* copyDer */ PR_TRUE); |
1551 if (!nssCert){ | 1549 if (!nssCert){ |
1552 PKIX_ERROR(PKIX_CERTDECODEDERCERTIFICATEFAILED); | 1550 PKIX_ERROR(PKIX_CERTDECODEDERCERTIFICATEFAILED); |
1553 } | 1551 } |
1554 | 1552 |
1555 PKIX_CHECK(pkix_pl_Cert_CreateWithNSSCert | 1553 PKIX_CHECK(pkix_pl_Cert_CreateWithNSSCert |
(...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3707 CERTCertificate **pnssCert, | 3705 CERTCertificate **pnssCert, |
3708 void *plContext) | 3706 void *plContext) |
3709 { | 3707 { |
3710 PKIX_ENTER(CERT, "PKIX_PL_Cert_GetNssCert"); | 3708 PKIX_ENTER(CERT, "PKIX_PL_Cert_GetNssCert"); |
3711 PKIX_NULLCHECK_TWO(cert, pnssCert); | 3709 PKIX_NULLCHECK_TWO(cert, pnssCert); |
3712 | 3710 |
3713 *pnssCert = CERT_DupCertificate(cert->nssCert); | 3711 *pnssCert = CERT_DupCertificate(cert->nssCert); |
3714 | 3712 |
3715 PKIX_RETURN(CERT); | 3713 PKIX_RETURN(CERT); |
3716 } | 3714 } |
OLD | NEW |