Bug 1061021, Part 5: Remove InitInputFromSECItem, r=keeler
authorBrian Smith <brian@briansmith.org>
Sat, 30 Aug 2014 16:49:49 -0700
changeset 14676 acf8ecaeeb3336ab54207393706a87e61c4ef2b0
parent 14675 5754cdc8fa0a43f1b1db36ffec8bfa8974d948eb
child 14677 90d09ed5c83b018b9f953e6697cf73a6b5452141
push id3202
push userfranziskuskiefer@gmail.com
push dateMon, 01 Oct 2018 08:30:12 +0000
reviewerskeeler
bugs1061021
Bug 1061021, Part 5: Remove InitInputFromSECItem, r=keeler
lib/mozpkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp
lib/mozpkix/test/lib/pkixtestutil.cpp
lib/mozpkix/test/lib/pkixtestutil.h
--- a/lib/mozpkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp
+++ b/lib/mozpkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp
@@ -106,21 +106,22 @@ class pkixocsp_VerifyEncodedResponse : p
 {
 public:
   static bool SetUpTestCaseInner()
   {
     ScopedSECKEYPublicKey rootPublicKey;
     if (GenerateKeyPair(rootPublicKey, rootPrivateKey) != Success) {
       return false;
     }
-    rootSPKI = SECKEY_EncodeDERSubjectPublicKeyInfo(rootPublicKey.get());
-    if (!rootSPKI) {
+    ScopedSECItem rootSPKIItem(
+      SECKEY_EncodeDERSubjectPublicKeyInfo(rootPublicKey.get()));
+    if (!rootSPKIItem) {
       return false;
     }
-
+    rootSPKI.assign(rootSPKIItem->data, rootSPKIItem->len);
     return true;
   }
 
   static void SetUpTestCase()
   {
     NSSTest::SetUpTestCase();
     if (!SetUpTestCaseInner()) {
       abort();
@@ -147,40 +148,40 @@ public:
     }
     Input serialNumberDERInput;
     if (serialNumberDERInput.Init(serialNumberDER.data(),
                                   serialNumberDER.length()) != Success) {
       abort();
     }
 
     Input rootSPKIDER;
-    if (InitInputFromSECItem(rootSPKI.get(), rootSPKIDER) != Success) {
+    if (rootSPKIDER.Init(rootSPKI.data(), rootSPKI.length()) != Success) {
       abort();
     }
     endEntityCertID = new (std::nothrow) CertID(rootNameDERInput, rootSPKIDER,
                                                 serialNumberDERInput);
     if (!endEntityCertID) {
       abort();
     }
   }
 
   static ScopedSECKEYPrivateKey rootPrivateKey;
-  static ScopedSECItem rootSPKI;
+  static ByteString rootSPKI;
   static long rootIssuedCount;
   OCSPTestTrustDomain trustDomain;
 
   ByteString rootNameDER;
   ByteString serialNumberDER;
   // endEntityCertID references rootSPKI, rootNameDER, and serialNumberDER.
   ScopedPtr<CertID, deleteCertID> endEntityCertID;
 };
 
 /*static*/ ScopedSECKEYPrivateKey
               pkixocsp_VerifyEncodedResponse::rootPrivateKey;
-/*static*/ ScopedSECItem pkixocsp_VerifyEncodedResponse::rootSPKI;
+/*static*/ ByteString pkixocsp_VerifyEncodedResponse::rootSPKI;
 /*static*/ long pkixocsp_VerifyEncodedResponse::rootIssuedCount = 0;
 
 ///////////////////////////////////////////////////////////////////////////////
 // responseStatus
 
 struct WithoutResponseBytes
 {
   uint8_t responseStatus;
--- a/lib/mozpkix/test/lib/pkixtestutil.cpp
+++ b/lib/mozpkix/test/lib/pkixtestutil.cpp
@@ -144,25 +144,16 @@ TLV(uint8_t tag, const ByteString& value
   } else {
     assert(false);
     return ENCODING_FAILED;
   }
   result.append(value);
   return result;
 }
 
-Result
-InitInputFromSECItem(const SECItem* secItem, /*out*/ Input& input)
-{
-  if (!secItem) {
-    return Result::FATAL_ERROR_INVALID_ARGS;
-  }
-  return input.Init(secItem->data, secItem->len);
-}
-
 class Output
 {
 public:
   Output()
   {
   }
 
   // Makes a shallow copy of the input item. All input items must have a
--- a/lib/mozpkix/test/lib/pkixtestutil.h
+++ b/lib/mozpkix/test/lib/pkixtestutil.h
@@ -108,18 +108,16 @@ ByteString CNToDERName(const char* cn);
 // "only once" restriction is helpful for avoiding making accidental changes.
 //
 // The string to search for must be 8 or more bytes long so that it is
 // extremely unlikely that there will ever be any false positive matches
 // in digital signatures, keys, hashes, etc.
 Result TamperOnce(/*in/out*/ ByteString& item, const ByteString& from,
                   const ByteString& to);
 
-Result InitInputFromSECItem(const SECItem* secItem, /*out*/ Input& input);
-
 ///////////////////////////////////////////////////////////////////////////////
 // Encode Certificates
 
 enum Version { v1 = 0, v2 = 1, v3 = 2 };
 
 // signature is assumed to be the DER encoding of an AlgorithmIdentifer.
 // serialNumber is assumed to be the DER encoding of an INTEGER.
 //