Bug 1061021, Part 13: Remove Output class, r=keeler
authorBrian Smith <brian@briansmith.org>
Sat, 30 Aug 2014 20:47:58 -0700
changeset 14684 1fd4a7e00bd180cf93d16905190eb62e46ac48e7
parent 14683 07b910800d29a8bd7552cfdca10b200eec54283f
child 14685 8743adefe38aa1f100d74405ab7fc76caec1ceaf
push id3202
push userfranziskuskiefer@gmail.com
push dateMon, 01 Oct 2018 08:30:12 +0000
reviewerskeeler
bugs1061021
Bug 1061021, Part 13: Remove Output class, r=keeler
lib/mozpkix/test/lib/pkixtestutil.cpp
--- a/lib/mozpkix/test/lib/pkixtestutil.cpp
+++ b/lib/mozpkix/test/lib/pkixtestutil.cpp
@@ -155,83 +155,16 @@ ArenaDupByteString(PLArenaPool* arena, c
   SECItem* result = SECITEM_AllocItem(arena, nullptr, value.length());
   if (!result) {
     return nullptr;
   }
   memcpy(result->data, value.data(), value.length());
   return result;
 }
 
-class Output
-{
-public:
-  Output()
-  {
-  }
-
-  // Makes a shallow copy of the input item. All input items must have a
-  // lifetime that extends at least to where Squash is called.
-  Result Add(const SECItem* item)
-  {
-    assert(item);
-    assert(item->data);
-    contents.append(item->data, item->len);
-    return Success; // XXX: return type should be void
-  }
-
-  void Add(const ByteString& item)
-  {
-    contents.append(item);
-  }
-
-  SECItem* Squash(PLArenaPool* arena, uint8_t tag)
-  {
-    assert(arena);
-
-    size_t lengthLength = contents.length() < 128 ? 1
-                        : contents.length() < 256 ? 2
-                        : 3;
-    size_t totalLength = 1 + lengthLength + contents.length();
-    SECItem* output = SECITEM_AllocItem(arena, nullptr, totalLength);
-    if (!output) {
-      return nullptr;
-    }
-    uint8_t* d = output->data;
-    *d++ = tag;
-    EncodeLength(d, contents.length(), lengthLength);
-    d += lengthLength;
-    memcpy(d, contents.data(), contents.length());
-    return output;
-  }
-
-private:
-  void
-  EncodeLength(uint8_t* data, size_t length, size_t lengthLength)
-  {
-    switch (lengthLength) {
-      case 1:
-        data[0] = length;
-        break;
-      case 2:
-        data[0] = 0x81;
-        data[1] = length;
-        break;
-      case 3:
-        data[0] = 0x82;
-        data[1] = length / 256;
-        data[2] = length % 256;
-        break;
-      default:
-        abort();
-    }
-  }
-
-  ByteString contents;
-};
-
 OCSPResponseContext::OCSPResponseContext(PLArenaPool* arena,
                                          const CertID& certID, time_t time)
   : arena(arena)
   , certID(certID)
   , responseStatus(successful)
   , skipResponseBytes(false)
   , producedAt(time)
   , extensions(nullptr)