aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/asn1
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-19 00:48:09 -0500
committerJack Lloyd <[email protected]>2017-12-19 00:48:45 -0500
commit395a8ab3b1d38f545e79f4bf169c71037fa6cc18 (patch)
tree54bbea5e71dfa7cd5ae6daaab20598aa55b85f49 /src/lib/asn1
parente886e5942c1117115c72cfa0ed808af37693efab (diff)
Simplify overloads in DER_Encoder
Diffstat (limited to 'src/lib/asn1')
-rw-r--r--src/lib/asn1/der_enc.cpp33
-rw-r--r--src/lib/asn1/der_enc.h19
2 files changed, 15 insertions, 37 deletions
diff --git a/src/lib/asn1/der_enc.cpp b/src/lib/asn1/der_enc.cpp
index 28a9bbc9a..1ed51d593 100644
--- a/src/lib/asn1/der_enc.cpp
+++ b/src/lib/asn1/der_enc.cpp
@@ -178,19 +178,6 @@ DER_Encoder& DER_Encoder::end_explicit()
/*
* Write raw bytes into the stream
*/
-DER_Encoder& DER_Encoder::raw_bytes(const secure_vector<uint8_t>& val)
- {
- return raw_bytes(val.data(), val.size());
- }
-
-DER_Encoder& DER_Encoder::raw_bytes(const std::vector<uint8_t>& val)
- {
- return raw_bytes(val.data(), val.size());
- }
-
-/*
-* Write raw bytes into the stream
-*/
DER_Encoder& DER_Encoder::raw_bytes(const uint8_t bytes[], size_t length)
{
if(m_subsequences.size())
@@ -234,26 +221,6 @@ DER_Encoder& DER_Encoder::encode(const BigInt& n)
}
/*
-* DER encode an OCTET STRING or BIT STRING
-*/
-DER_Encoder& DER_Encoder::encode(const secure_vector<uint8_t>& bytes,
- ASN1_Tag real_type)
- {
- return encode(bytes.data(), bytes.size(),
- real_type, real_type, UNIVERSAL);
- }
-
-/*
-* DER encode an OCTET STRING or BIT STRING
-*/
-DER_Encoder& DER_Encoder::encode(const std::vector<uint8_t>& bytes,
- ASN1_Tag real_type)
- {
- return encode(bytes.data(), bytes.size(),
- real_type, real_type, UNIVERSAL);
- }
-
-/*
* Encode this object
*/
DER_Encoder& DER_Encoder::encode(const uint8_t bytes[], size_t length,
diff --git a/src/lib/asn1/der_enc.h b/src/lib/asn1/der_enc.h
index f1e85101c..f76391ae5 100644
--- a/src/lib/asn1/der_enc.h
+++ b/src/lib/asn1/der_enc.h
@@ -34,18 +34,29 @@ class BOTAN_PUBLIC_API(2,0) DER_Encoder final
DER_Encoder& start_explicit(uint16_t type_tag);
DER_Encoder& end_explicit();
+ /**
+ * Insert raw bytes directly into the output stream
+ */
DER_Encoder& raw_bytes(const uint8_t val[], size_t len);
- DER_Encoder& raw_bytes(const secure_vector<uint8_t>& val);
- DER_Encoder& raw_bytes(const std::vector<uint8_t>& val);
+
+ template<typename Alloc>
+ DER_Encoder& raw_bytes(const std::vector<uint8_t, Alloc>& val)
+ {
+ return raw_bytes(val.data(), val.size());
+ }
DER_Encoder& encode_null();
DER_Encoder& encode(bool b);
DER_Encoder& encode(size_t s);
DER_Encoder& encode(const BigInt& n);
- DER_Encoder& encode(const secure_vector<uint8_t>& v, ASN1_Tag real_type);
- DER_Encoder& encode(const std::vector<uint8_t>& v, ASN1_Tag real_type);
DER_Encoder& encode(const uint8_t val[], size_t len, ASN1_Tag real_type);
+ template<typename Alloc>
+ DER_Encoder& encode(const std::vector<uint8_t, Alloc>& vec, ASN1_Tag real_type)
+ {
+ return encode(vec.data(), vec.size(), real_type);
+ }
+
DER_Encoder& encode(bool b,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);