diff options
author | lloyd <[email protected]> | 2008-09-28 22:14:54 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-28 22:14:54 +0000 |
commit | 31204986023619c385d378e79a6511bb81ef7b78 (patch) | |
tree | ce272a6585dc070f750f6875b0450d53145b935d /src/alg_id.cpp | |
parent | 42c0fe76ab6d9625d0e51c68b8dd187322c991bd (diff) |
Move almost all of the ASN.1, BER, and DER codec related code into new
module asn1
Move hex and base64 codecs into new codecs directory. Also move zlib and
bzip2 to codecs from compress.
Diffstat (limited to 'src/alg_id.cpp')
-rw-r--r-- | src/alg_id.cpp | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/src/alg_id.cpp b/src/alg_id.cpp deleted file mode 100644 index 5e5db73b3..000000000 --- a/src/alg_id.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************* -* Algorithm Identifier Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#include <botan/alg_id.h> -#include <botan/der_enc.h> -#include <botan/ber_dec.h> -#include <botan/oids.h> - -namespace Botan { - -/************************************************* -* Create an AlgorithmIdentifier * -*************************************************/ -AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id, - const MemoryRegion<byte>& param) - { - oid = alg_id; - parameters = param; - } - -/************************************************* -* Create an AlgorithmIdentifier * -*************************************************/ -AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id, - const MemoryRegion<byte>& param) - { - oid = OIDS::lookup(alg_id); - parameters = param; - } - -/************************************************* -* Create an AlgorithmIdentifier * -*************************************************/ -AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id, - Encoding_Option option) - { - const byte DER_NULL[] = { 0x05, 0x00 }; - - oid = alg_id; - if(option == USE_NULL_PARAM) - parameters.append(DER_NULL, sizeof(DER_NULL)); - } - -/************************************************* -* Create an AlgorithmIdentifier * -*************************************************/ -AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id, - Encoding_Option option) - { - const byte DER_NULL[] = { 0x05, 0x00 }; - - oid = OIDS::lookup(alg_id); - if(option == USE_NULL_PARAM) - parameters.append(DER_NULL, sizeof(DER_NULL)); - } - -/************************************************* -* Compare two AlgorithmIdentifiers * -*************************************************/ -bool operator==(const AlgorithmIdentifier& a1, const AlgorithmIdentifier& a2) - { - if(a1.oid != a2.oid) - return false; - if(a1.parameters != a2.parameters) - return false; - return true; - } - -/************************************************* -* Compare two AlgorithmIdentifiers * -*************************************************/ -bool operator!=(const AlgorithmIdentifier& a1, const AlgorithmIdentifier& a2) - { - return !(a1 == a2); - } - -/************************************************* -* 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 AlgorithmIdentifier::decode_from(BER_Decoder& codec) - { - codec.start_cons(SEQUENCE) - .decode(oid) - .raw_bytes(parameters) - .end_cons(); - } - -} |