| 186 | } |
| 187 | |
| 188 | size_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 | |
| 213 | void DERReencode(BufferedTransformation &source, BufferedTransformation &dest) |
| 214 | { |
no test coverage detected