diff options
author | Jack Lloyd <[email protected]> | 2019-08-04 08:26:06 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-08-04 16:26:50 -0400 |
commit | 0006bd1db9a96c294f2da852218d3f8579f422a9 (patch) | |
tree | 15600a4e8369eb167be052e8343c58dcb6693a3a /src/lib/kdf/prf_x942 | |
parent | 247df8cae3fbec8d9b608c5dc8b42a4f6bdeef8b (diff) |
Reduce usage of oids.h with the addition of some helpers on OID
Diffstat (limited to 'src/lib/kdf/prf_x942')
-rw-r--r-- | src/lib/kdf/prf_x942/prf_x942.cpp | 14 | ||||
-rw-r--r-- | src/lib/kdf/prf_x942/prf_x942.h | 9 |
2 files changed, 9 insertions, 14 deletions
diff --git a/src/lib/kdf/prf_x942/prf_x942.cpp b/src/lib/kdf/prf_x942/prf_x942.cpp index 3fe0a682f..f4437b10b 100644 --- a/src/lib/kdf/prf_x942/prf_x942.cpp +++ b/src/lib/kdf/prf_x942/prf_x942.cpp @@ -7,7 +7,6 @@ #include <botan/prf_x942.h> #include <botan/der_enc.h> -#include <botan/oids.h> #include <botan/hash.h> #include <botan/loadstor.h> #include <algorithm> @@ -37,7 +36,6 @@ size_t X942_PRF::kdf(uint8_t key[], size_t key_len, const uint8_t label[], size_t label_len) const { std::unique_ptr<HashFunction> hash(HashFunction::create("SHA-160")); - const OID kek_algo(m_key_wrap_oid); secure_vector<uint8_t> h; secure_vector<uint8_t> in; @@ -56,7 +54,7 @@ size_t X942_PRF::kdf(uint8_t key[], size_t key_len, DER_Encoder().start_cons(SEQUENCE) .start_cons(SEQUENCE) - .encode(kek_algo) + .encode(m_key_wrap_oid) .raw_bytes(encode_x942_int(counter)) .end_cons() @@ -85,15 +83,9 @@ size_t X942_PRF::kdf(uint8_t key[], size_t key_len, return offset; } -/* -* X9.42 Constructor -*/ -X942_PRF::X942_PRF(const std::string& oid) +std::string X942_PRF::name() const { - if(OIDS::have_oid(oid)) - m_key_wrap_oid = OIDS::str2oid_or_empty(oid).to_string(); - else - m_key_wrap_oid = oid; + return "X9.42-PRF(" + m_key_wrap_oid.to_formatted_string() + ")"; } } diff --git a/src/lib/kdf/prf_x942/prf_x942.h b/src/lib/kdf/prf_x942/prf_x942.h index ebf9839f5..4b93d5966 100644 --- a/src/lib/kdf/prf_x942/prf_x942.h +++ b/src/lib/kdf/prf_x942/prf_x942.h @@ -9,6 +9,7 @@ #define BOTAN_ANSI_X942_PRF_H_ #include <botan/kdf.h> +#include <botan/asn1_oid.h> namespace Botan { @@ -18,7 +19,7 @@ namespace Botan { class BOTAN_PUBLIC_API(2,0) X942_PRF final : public KDF { public: - std::string name() const override { return "X9.42-PRF(" + m_key_wrap_oid + ")"; } + std::string name() const override; KDF* clone() const override { return new X942_PRF(m_key_wrap_oid); } @@ -27,9 +28,11 @@ class BOTAN_PUBLIC_API(2,0) X942_PRF final : public KDF const uint8_t salt[], size_t salt_len, const uint8_t label[], size_t label_len) const override; - explicit X942_PRF(const std::string& oid); + explicit X942_PRF(const std::string& oid) : m_key_wrap_oid(OID::from_string(oid)) {} + + explicit X942_PRF(const OID& oid) : m_key_wrap_oid(oid) {} private: - std::string m_key_wrap_oid; + OID m_key_wrap_oid; }; } |