From dab16b79c89e54e9551d30dcf54ca89432932dce Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 19 Mar 2010 17:59:40 +0000 Subject: Add a couple of new helper functions to BER_Decoder: decode_and_check takes an expected value; if the decoded value does not match, a Decoding_Error with a specified string is thrown. Useful for checking embedded version codes. decode_octet_string_bigint is for decoding INTEGER values that are stored as OCTET STRINGs. Totally obnoxious and useless, but common especially in the ECC standards. --- src/pubkey/pkcs8.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/pubkey/pkcs8.cpp') diff --git a/src/pubkey/pkcs8.cpp b/src/pubkey/pkcs8.cpp index 400fdbb48..35ff7f206 100644 --- a/src/pubkey/pkcs8.cpp +++ b/src/pubkey/pkcs8.cpp @@ -105,19 +105,14 @@ SecureVector PKCS8_decode(DataSource& source, const User_Interface& ui, key = decryptor.read_all(); } - u32bit version; - BER_Decoder(key) .start_cons(SEQUENCE) - .decode(version) + .decode_and_check(0, "Unknown PKCS #8 version number") .decode(pk_alg_id) .decode(key, OCTET_STRING) .discard_remaining() .end_cons(); - if(version != 0) - throw Decoding_Error("PKCS #8: Unknown version number"); - break; } catch(Decoding_Error) -- cgit v1.2.3