Backed out changeset ace6aa02d442 (bug 1034856)

This commit is contained in:
Tim Taubert 2014-10-17 14:58:33 +02:00
parent 9ed2e3727d
commit 9dfd70643f

View File

@ -501,15 +501,16 @@ CryptoKey::PublicKeyToSpki(SECKEYPublicKey* aPubKey,
CryptoBuffer& aRetVal,
const nsNSSShutDownPreventionLock& /*proofOfLock*/)
{
ScopedPLArenaPool arena;
ScopedCERTSubjectPublicKeyInfo spki;
ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE));
// NSS doesn't support exporting DH public keys.
if (aPubKey->keyType == dhKey) {
arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
if (!arena) {
return NS_ERROR_DOM_OPERATION_ERR;
}
// NSS doesn't support exporting DH public keys.
if (aPubKey->keyType == dhKey) {
// It's alright to assign the result of PORT_ArenaZNew(ScopedPLArenaPool)
// to a ScopedCERTSubjectPublicKeyInfo as long as we don't set |spki->arena|
// as that's what would be freed when |spki| goes out of scope.
@ -541,16 +542,17 @@ CryptoKey::PublicKeyToSpki(SECKEYPublicKey* aPubKey,
MOZ_ASSERT(false);
}
SECStatus rv = SECITEM_CopyItem(arena, &spki->algorithm.algorithm, oidData);
SECStatus rv = SECITEM_CopyItem(spki->arena, &spki->algorithm.algorithm,
oidData);
if (rv != SECSuccess) {
return NS_ERROR_DOM_OPERATION_ERR;
}
}
const SEC_ASN1Template* tpl = SEC_ASN1_GET(CERT_SubjectPublicKeyInfoTemplate);
SECItem* spkiItem(SEC_ASN1EncodeItem(arena, nullptr, spki, tpl));
ScopedSECItem spkiItem(SEC_ASN1EncodeItem(nullptr, nullptr, spki, tpl));
aRetVal.Assign(spkiItem);
aRetVal.Assign(spkiItem.get());
return NS_OK;
}