From 0ef2b1764dcac650e886f8b8d3f1b34675e743d5 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sat, 30 Aug 2014 18:00:02 -0700 Subject: [PATCH] Bug 1061021, Part 9: Stop using PLArenaPool for SingleResponse encoding, r=keeler --HG-- extra : rebase_source : a39a5dfec9b7aaa43ee2cffc15021bb404ada1ca --- security/pkix/test/lib/pkixtestutil.cpp | 41 +++++++++++-------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/security/pkix/test/lib/pkixtestutil.cpp b/security/pkix/test/lib/pkixtestutil.cpp index 8a3b0f58be3..5d8911bfd2c 100644 --- a/security/pkix/test/lib/pkixtestutil.cpp +++ b/security/pkix/test/lib/pkixtestutil.cpp @@ -252,7 +252,7 @@ static ByteString BasicOCSPResponse(OCSPResponseContext& context); static SECItem* ResponseData(OCSPResponseContext& context); static ByteString ResponderID(OCSPResponseContext& context); static ByteString KeyHash(OCSPResponseContext& context); -static SECItem* SingleResponse(OCSPResponseContext& context); +static ByteString SingleResponse(OCSPResponseContext& context); static ByteString CertID(OCSPResponseContext& context); static ByteString CertStatus(OCSPResponseContext& context); @@ -1135,13 +1135,12 @@ ResponseData(OCSPResponseContext& context) if (producedAtEncoded == ENCODING_FAILED) { return nullptr; } - SECItem* responses = SingleResponse(context); - if (!responses) { + ByteString response(SingleResponse(context)); + if (response == ENCODING_FAILED) { return nullptr; } - SECItem* responsesNested = EncodeNested(context.arena, der::SEQUENCE, - responses); - if (!responsesNested) { + ByteString responses(TLV(der::SEQUENCE, response)); + if (responses == ENCODING_FAILED) { return nullptr; } SECItem* responseExtensions = nullptr; @@ -1152,9 +1151,7 @@ ResponseData(OCSPResponseContext& context) Output output; output.Add(responderID); output.Add(producedAtEncoded); - if (output.Add(responsesNested) != Success) { - return nullptr; - } + output.Add(responses); if (responseExtensions) { if (output.Add(responseExtensions) != Success) { return nullptr; @@ -1214,42 +1211,40 @@ KeyHash(OCSPResponseContext& context) // thisUpdate GeneralizedTime, // nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, // singleExtensions [1] EXPLICIT Extensions OPTIONAL } -SECItem* +ByteString SingleResponse(OCSPResponseContext& context) { ByteString certID(CertID(context)); if (certID == ENCODING_FAILED) { - return nullptr; + return ENCODING_FAILED; } ByteString certStatus(CertStatus(context)); if (certStatus == ENCODING_FAILED) { - return nullptr; + return ENCODING_FAILED; } ByteString thisUpdateEncoded(TimeToGeneralizedTime(context.thisUpdate)); if (thisUpdateEncoded == ENCODING_FAILED) { - return nullptr; + return ENCODING_FAILED; } ByteString nextUpdateEncodedNested; if (context.includeNextUpdate) { ByteString nextUpdateEncoded(TimeToGeneralizedTime(context.nextUpdate)); if (nextUpdateEncoded == ENCODING_FAILED) { - return nullptr; + return ENCODING_FAILED; } nextUpdateEncodedNested = TLV(der::CONSTRUCTED | der::CONTEXT_SPECIFIC | 0, nextUpdateEncoded); if (nextUpdateEncodedNested == ENCODING_FAILED) { - return nullptr; + return ENCODING_FAILED; } } - Output output; - output.Add(certID); - output.Add(certStatus); - output.Add(thisUpdateEncoded); - if (!nextUpdateEncodedNested.empty()) { - output.Add(nextUpdateEncodedNested); - } - return output.Squash(context.arena, der::SEQUENCE); + ByteString value; + value.append(certID); + value.append(certStatus); + value.append(thisUpdateEncoded); + value.append(nextUpdateEncodedNested); + return TLV(der::SEQUENCE, value); } // CertID ::= SEQUENCE {