Bug 1061021, Part 13: Remove Output class, r=keeler

--HG--
extra : rebase_source : 9d768451f2f1d6ad0db3cb75401494d6409fd818
This commit is contained in:
Brian Smith 2014-08-30 20:47:58 -07:00
Родитель 5419f381e4
Коммит c7a8deb8a0
1 изменённых файлов: 0 добавлений и 67 удалений

Просмотреть файл

@ -160,73 +160,6 @@ ArenaDupByteString(PLArenaPool* arena, const ByteString& value)
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)