diff options
author | lloyd <[email protected]> | 2006-07-22 05:41:09 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-07-22 05:41:09 +0000 |
commit | aa6b69a553ce9b03a2af652e4a96504bff1acdbe (patch) | |
tree | e13581ed553aa145bad801a09661975b346c8eee | |
parent | 0395ad89ca4654ff586d7f80a85a767fd9aa26c7 (diff) |
Add two more constructors to AlgorithmIdentifier, which take a
Encoding_Option enum that can specify various options. Right now the
only one supported/available is USE_NULL_PARAM, to set the parameters
to a DER-encoded NULL object
-rw-r--r-- | include/asn1_obj.h | 5 | ||||
-rw-r--r-- | src/asn1_alg.cpp | 40 |
2 files changed, 41 insertions, 4 deletions
diff --git a/include/asn1_obj.h b/include/asn1_obj.h index 7bb6ac8a3..4397d2fc3 100644 --- a/include/asn1_obj.h +++ b/include/asn1_obj.h @@ -19,10 +19,15 @@ namespace Botan { class AlgorithmIdentifier : public ASN1_Object { public: + enum Encoding_Option { USE_NULL_PARAM }; + void encode_into(class DER_Encoder&) const; void decode_from(class BER_Decoder&); AlgorithmIdentifier() {} + AlgorithmIdentifier(const OID&, Encoding_Option); + AlgorithmIdentifier(const std::string&, Encoding_Option); + AlgorithmIdentifier(const OID&, const MemoryRegion<byte>&); AlgorithmIdentifier(const std::string&, const MemoryRegion<byte>&); diff --git a/src/asn1_alg.cpp b/src/asn1_alg.cpp index 251c8c31f..7f54b2fa5 100644 --- a/src/asn1_alg.cpp +++ b/src/asn1_alg.cpp @@ -14,15 +14,47 @@ namespace Botan { * Create an AlgorithmIdentifier * *************************************************/ AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id, - const MemoryRegion<byte>& param) : - oid(alg_id), parameters(param) { } + 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, - const MemoryRegion<byte>& param) : - oid(OIDS::lookup(alg_id)), parameters(param) { } + 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 * |