MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / DERLengthEncode

Function DERLengthEncode

src/cryptlib/asn.cpp:9–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <stdio.h>
8
9unsigned int DERLengthEncode(unsigned int length, byte *output)
10{
11 unsigned int i=0;
12 if (length <= 0x7f)
13 {
14 output[i++] = byte(length);
15 }
16 else
17 {
18 output[i++] = byte(BytePrecision(length) | 0x80);
19 for (int j=BytePrecision(length); j; --j)
20 {
21 output[i++] = byte (length >> (j-1)*8);
22 }
23 }
24 return i;
25}
26
27unsigned int DERLengthEncode(unsigned int length, BufferedTransformation &bt)
28{

Callers 2

DEREncodeMethod · 0.85
~DERSequenceEncoderMethod · 0.85

Calls 2

BytePrecisionFunction · 0.85
PutMethod · 0.45

Tested by

no test coverage detected