MCPcopy Create free account
hub / github.com/LUX-Core/lux / BERDecodeBitString

Function BERDecodeBitString

src/cryptopp/asn.cpp:188–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188size_t BERDecodeBitString(BufferedTransformation &bt, SecByteBlock &str, unsigned int &unusedBits)
189{
190 byte b;
191 if (!bt.Get(b) || b != BIT_STRING)
192 BERDecodeError();
193
194 size_t bc;
195 if (!BERLengthDecode(bt, bc))
196 BERDecodeError();
197 if (bc == 0)
198 BERDecodeError();
199 if (bc > bt.MaxRetrievable()) // Issue 346
200 BERDecodeError();
201
202 // X.690, 8.6.2.2: "The number [of unused bits] shall be in the range zero to seven"
203 byte unused;
204 if (!bt.Get(unused) || unused > 7)
205 BERDecodeError();
206 unusedBits = unused;
207 str.resize(bc-1);
208 if ((bc-1) != bt.Get(str, bc-1))
209 BERDecodeError();
210 return bc-1;
211}
212
213void DERReencode(BufferedTransformation &source, BufferedTransformation &dest)
214{

Callers 4

BERDecodePrivateKeyMethod · 0.85
RunASN1TestSetFunction · 0.85
ECPMethod · 0.85
EC2NMethod · 0.85

Calls 5

BERDecodeErrorFunction · 0.85
BERLengthDecodeFunction · 0.85
GetMethod · 0.45
MaxRetrievableMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected