diff options
Diffstat (limited to 'src/asn1_alg.cpp')
-rw-r--r-- | src/asn1_alg.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/asn1_alg.cpp b/src/asn1_alg.cpp index 4dd5af88e..251c8c31f 100644 --- a/src/asn1_alg.cpp +++ b/src/asn1_alg.cpp @@ -4,6 +4,8 @@ *************************************************/ #include <botan/asn1_obj.h> +#include <botan/der_enc.h> +#include <botan/ber_dec.h> #include <botan/oids.h> namespace Botan { @@ -23,17 +25,6 @@ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id, oid(OIDS::lookup(alg_id)), parameters(param) { } /************************************************* -* DER encode an AlgorithmIdentifier * -*************************************************/ -void AlgorithmIdentifier::encode_into(DER_Encoder& der) const - { - der.start_sequence() - .encode(oid) - .add_raw_octets(parameters) - .end_sequence(); - } - -/************************************************* * Compare two AlgorithmIdentifiers * *************************************************/ bool operator==(const AlgorithmIdentifier& a1, const AlgorithmIdentifier& a2) @@ -53,19 +44,26 @@ bool operator!=(const AlgorithmIdentifier& a1, const AlgorithmIdentifier& a2) return !(a1 == a2); } -namespace BER { +/************************************************* +* DER encode an AlgorithmIdentifier * +*************************************************/ +void AlgorithmIdentifier::encode_into(DER_Encoder& codec) const + { + codec.start_cons(SEQUENCE) + .encode(oid) + .raw_bytes(parameters) + .end_cons(); + } /************************************************* * Decode a BER encoded AlgorithmIdentifier * *************************************************/ -void decode(BER_Decoder& source, AlgorithmIdentifier& alg_id) +void AlgorithmIdentifier::decode_from(BER_Decoder& codec) { - BER_Decoder sequence = BER::get_subsequence(source); - BER::decode(sequence, alg_id.oid); - alg_id.parameters = sequence.get_remaining(); - sequence.verify_end(); + codec.start_cons(SEQUENCE) + .decode(oid) + .raw_bytes(parameters) + .end_cons(); } } - -} |