aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/asn1
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/asn1')
-rw-r--r--src/lib/asn1/alg_id.cpp14
-rw-r--r--src/lib/asn1/alg_id.h6
-rw-r--r--src/lib/asn1/asn1_alt_name.cpp6
-rw-r--r--src/lib/asn1/asn1_attribute.cpp4
-rw-r--r--src/lib/asn1/asn1_attribute.h6
-rw-r--r--src/lib/asn1/asn1_obj.cpp10
-rw-r--r--src/lib/asn1/asn1_obj.h4
-rw-r--r--src/lib/asn1/asn1_oid.cpp12
-rw-r--r--src/lib/asn1/asn1_oid.h8
-rw-r--r--src/lib/asn1/asn1_str.cpp4
-rw-r--r--src/lib/asn1/asn1_time.cpp8
-rw-r--r--src/lib/asn1/asn1_time.h14
-rw-r--r--src/lib/asn1/ber_dec.cpp40
-rw-r--r--src/lib/asn1/ber_dec.h26
-rw-r--r--src/lib/asn1/der_enc.cpp66
-rw-r--r--src/lib/asn1/der_enc.h42
-rw-r--r--src/lib/asn1/x509_dn.cpp4
-rw-r--r--src/lib/asn1/x509_dn.h4
18 files changed, 139 insertions, 139 deletions
diff --git a/src/lib/asn1/alg_id.cpp b/src/lib/asn1/alg_id.cpp
index 75ea78c18..0b84d2137 100644
--- a/src/lib/asn1/alg_id.cpp
+++ b/src/lib/asn1/alg_id.cpp
@@ -16,14 +16,14 @@ namespace Botan {
* Create an AlgorithmIdentifier
*/
AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
- const std::vector<byte>& param) : oid(alg_id), parameters(param)
+ const std::vector<uint8_t>& param) : oid(alg_id), parameters(param)
{}
/*
* Create an AlgorithmIdentifier
*/
AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
- const std::vector<byte>& param) : oid(OIDS::lookup(alg_id)), parameters(param)
+ const std::vector<uint8_t>& param) : oid(OIDS::lookup(alg_id)), parameters(param)
{}
/*
@@ -32,10 +32,10 @@ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
Encoding_Option option) : oid(alg_id), parameters()
{
- const byte DER_NULL[] = { 0x05, 0x00 };
+ const uint8_t DER_NULL[] = { 0x05, 0x00 };
if(option == USE_NULL_PARAM)
- parameters += std::pair<const byte*, size_t>(DER_NULL, sizeof(DER_NULL));
+ parameters += std::pair<const uint8_t*, size_t>(DER_NULL, sizeof(DER_NULL));
}
/*
@@ -44,10 +44,10 @@ AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id,
AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
Encoding_Option option) : oid(OIDS::lookup(alg_id)), parameters()
{
- const byte DER_NULL[] = { 0x05, 0x00 };
+ const uint8_t DER_NULL[] = { 0x05, 0x00 };
if(option == USE_NULL_PARAM)
- parameters += std::pair<const byte*, size_t>(DER_NULL, sizeof(DER_NULL));
+ parameters += std::pair<const uint8_t*, size_t>(DER_NULL, sizeof(DER_NULL));
}
/*
@@ -55,7 +55,7 @@ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id,
*/
namespace {
-bool param_null_or_empty(const std::vector<byte>& p)
+bool param_null_or_empty(const std::vector<uint8_t>& p)
{
if(p.size() == 2 && (p[0] == 0x05) && (p[1] == 0x00))
return true;
diff --git a/src/lib/asn1/alg_id.h b/src/lib/asn1/alg_id.h
index 3b6c3f7ec..2cd0b350a 100644
--- a/src/lib/asn1/alg_id.h
+++ b/src/lib/asn1/alg_id.h
@@ -29,14 +29,14 @@ class BOTAN_DLL AlgorithmIdentifier final : public ASN1_Object
AlgorithmIdentifier(const OID&, Encoding_Option);
AlgorithmIdentifier(const std::string&, Encoding_Option);
- AlgorithmIdentifier(const OID&, const std::vector<byte>&);
- AlgorithmIdentifier(const std::string&, const std::vector<byte>&);
+ AlgorithmIdentifier(const OID&, const std::vector<uint8_t>&);
+ AlgorithmIdentifier(const std::string&, const std::vector<uint8_t>&);
// public member variable:
OID oid;
// public member variable:
- std::vector<byte> parameters;
+ std::vector<uint8_t> parameters;
};
/*
diff --git a/src/lib/asn1/asn1_alt_name.cpp b/src/lib/asn1/asn1_alt_name.cpp
index bd23bdff1..7bd4cd494 100644
--- a/src/lib/asn1/asn1_alt_name.cpp
+++ b/src/lib/asn1/asn1_alt_name.cpp
@@ -137,8 +137,8 @@ void encode_entries(DER_Encoder& encoder,
}
else if(type == "IP")
{
- const u32bit ip = string_to_ipv4(i->second);
- byte ip_buf[4] = { 0 };
+ const uint32_t ip = string_to_ipv4(i->second);
+ uint8_t ip_buf[4] = { 0 };
store_be(ip, ip_buf);
encoder.add_object(tagging, CONTEXT_SPECIFIC, ip_buf, 4);
}
@@ -230,7 +230,7 @@ void AlternativeName::decode_from(BER_Decoder& source)
{
if(obj.value.size() == 4)
{
- const u32bit ip = load_be<u32bit>(&obj.value[0], 0);
+ const uint32_t ip = load_be<uint32_t>(&obj.value[0], 0);
add_attribute("IP", ipv4_to_string(ip));
}
}
diff --git a/src/lib/asn1/asn1_attribute.cpp b/src/lib/asn1/asn1_attribute.cpp
index bd7e5bf11..3093f5025 100644
--- a/src/lib/asn1/asn1_attribute.cpp
+++ b/src/lib/asn1/asn1_attribute.cpp
@@ -15,14 +15,14 @@ namespace Botan {
/*
* Create an Attribute
*/
-Attribute::Attribute(const OID& attr_oid, const std::vector<byte>& attr_value) : oid(attr_oid), parameters(attr_value)
+Attribute::Attribute(const OID& attr_oid, const std::vector<uint8_t>& attr_value) : oid(attr_oid), parameters(attr_value)
{}
/*
* Create an Attribute
*/
Attribute::Attribute(const std::string& attr_oid,
- const std::vector<byte>& attr_value) : oid(OIDS::lookup(attr_oid)), parameters(attr_value)
+ const std::vector<uint8_t>& attr_value) : oid(OIDS::lookup(attr_oid)), parameters(attr_value)
{}
/*
diff --git a/src/lib/asn1/asn1_attribute.h b/src/lib/asn1/asn1_attribute.h
index 737d84b81..e6bcc5209 100644
--- a/src/lib/asn1/asn1_attribute.h
+++ b/src/lib/asn1/asn1_attribute.h
@@ -27,11 +27,11 @@ class BOTAN_DLL Attribute final : public ASN1_Object
OID oid;
// public member variable:
- std::vector<byte> parameters;
+ std::vector<uint8_t> parameters;
Attribute() {}
- Attribute(const OID&, const std::vector<byte>&);
- Attribute(const std::string&, const std::vector<byte>&);
+ Attribute(const OID&, const std::vector<uint8_t>&);
+ Attribute(const std::string&, const std::vector<uint8_t>&);
};
}
diff --git a/src/lib/asn1/asn1_obj.cpp b/src/lib/asn1/asn1_obj.cpp
index 7bf2d92ca..4ccb11c3f 100644
--- a/src/lib/asn1/asn1_obj.cpp
+++ b/src/lib/asn1/asn1_obj.cpp
@@ -32,7 +32,7 @@ namespace ASN1 {
/*
* Put some arbitrary bytes into a SEQUENCE
*/
-std::vector<byte> put_in_sequence(const std::vector<byte>& contents)
+std::vector<uint8_t> put_in_sequence(const std::vector<uint8_t>& contents)
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -54,14 +54,14 @@ std::string to_string(const BER_Object& obj)
*/
bool maybe_BER(DataSource& source)
{
- byte first_byte;
- if(!source.peek_byte(first_byte))
+ uint8_t first_u8;
+ if(!source.peek_byte(first_u8))
{
- BOTAN_ASSERT_EQUAL(source.read_byte(first_byte), 0, "Expected EOF");
+ BOTAN_ASSERT_EQUAL(source.read_byte(first_u8), 0, "Expected EOF");
throw Stream_IO_Error("ASN1::maybe_BER: Source was empty");
}
- if(first_byte == (SEQUENCE | CONSTRUCTED))
+ if(first_u8 == (SEQUENCE | CONSTRUCTED))
return true;
return false;
}
diff --git a/src/lib/asn1/asn1_obj.h b/src/lib/asn1/asn1_obj.h
index 3e119dc01..5e09da2fd 100644
--- a/src/lib/asn1/asn1_obj.h
+++ b/src/lib/asn1/asn1_obj.h
@@ -88,7 +88,7 @@ class BOTAN_DLL BER_Object
ASN1_Tag type_tag, class_tag;
// public member variable:
- secure_vector<byte> value;
+ secure_vector<uint8_t> value;
};
/*
@@ -98,7 +98,7 @@ class DataSource;
namespace ASN1 {
-std::vector<byte> put_in_sequence(const std::vector<byte>& val);
+std::vector<uint8_t> put_in_sequence(const std::vector<uint8_t>& val);
std::string to_string(const BER_Object& obj);
/**
diff --git a/src/lib/asn1/asn1_oid.cpp b/src/lib/asn1/asn1_oid.cpp
index 5b0a557d2..d9436e6d9 100644
--- a/src/lib/asn1/asn1_oid.cpp
+++ b/src/lib/asn1/asn1_oid.cpp
@@ -75,7 +75,7 @@ bool OID::operator==(const OID& oid) const
/*
* Append another component to the OID
*/
-OID& OID::operator+=(u32bit component)
+OID& OID::operator+=(uint32_t component)
{
m_id.push_back(component);
return (*this);
@@ -84,7 +84,7 @@ OID& OID::operator+=(u32bit component)
/*
* Append another component to the OID
*/
-OID operator+(const OID& oid, u32bit component)
+OID operator+(const OID& oid, uint32_t component)
{
OID new_oid(oid);
new_oid += component;
@@ -104,8 +104,8 @@ bool operator!=(const OID& a, const OID& b)
*/
bool operator<(const OID& a, const OID& b)
{
- const std::vector<u32bit>& oid1 = a.get_id();
- const std::vector<u32bit>& oid2 = b.get_id();
+ const std::vector<uint32_t>& oid1 = a.get_id();
+ const std::vector<uint32_t>& oid2 = b.get_id();
if(oid1.size() < oid2.size())
return true;
@@ -129,7 +129,7 @@ void OID::encode_into(DER_Encoder& der) const
if(m_id.size() < 2)
throw Invalid_Argument("OID::encode_into: OID is invalid");
- std::vector<byte> encoding;
+ std::vector<uint8_t> encoding;
encoding.push_back(40 * m_id[0] + m_id[1]);
for(size_t i = 2; i != m_id.size(); ++i)
@@ -171,7 +171,7 @@ void OID::decode_from(BER_Decoder& decoder)
size_t i = 0;
while(i != obj.value.size() - 1)
{
- u32bit component = 0;
+ uint32_t component = 0;
while(i != obj.value.size() - 1)
{
++i;
diff --git a/src/lib/asn1/asn1_oid.h b/src/lib/asn1/asn1_oid.h
index 6fbd876ec..0275b58a9 100644
--- a/src/lib/asn1/asn1_oid.h
+++ b/src/lib/asn1/asn1_oid.h
@@ -33,7 +33,7 @@ class BOTAN_DLL OID final : public ASN1_Object
* Get this OID as list (vector) of its components.
* @return vector representing this OID
*/
- const std::vector<u32bit>& get_id() const { return m_id; }
+ const std::vector<uint32_t>& get_id() const { return m_id; }
/**
* Get this OID as a string
@@ -57,7 +57,7 @@ class BOTAN_DLL OID final : public ASN1_Object
* @param new_comp the new component to add to the end of this OID
* @return reference to *this
*/
- OID& operator+=(u32bit new_comp);
+ OID& operator+=(uint32_t new_comp);
/**
* Construct an OID from a string.
@@ -65,7 +65,7 @@ class BOTAN_DLL OID final : public ASN1_Object
*/
OID(const std::string& str = "");
private:
- std::vector<u32bit> m_id;
+ std::vector<uint32_t> m_id;
};
/**
@@ -73,7 +73,7 @@ class BOTAN_DLL OID final : public ASN1_Object
* @param oid the OID to add the new component to
* @param new_comp the new component to add
*/
-OID BOTAN_DLL operator+(const OID& oid, u32bit new_comp);
+OID BOTAN_DLL operator+(const OID& oid, uint32_t new_comp);
/**
* Compare two OIDs.
diff --git a/src/lib/asn1/asn1_str.cpp b/src/lib/asn1/asn1_str.cpp
index c378d5dfe..81012f284 100644
--- a/src/lib/asn1/asn1_str.cpp
+++ b/src/lib/asn1/asn1_str.cpp
@@ -21,7 +21,7 @@ namespace {
ASN1_Tag choose_encoding(const std::string& str,
const std::string& type)
{
- static const byte IS_PRINTABLE[256] = {
+ static const uint8_t IS_PRINTABLE[256] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
@@ -47,7 +47,7 @@ ASN1_Tag choose_encoding(const std::string& str,
for(size_t i = 0; i != str.size(); ++i)
{
- if(!IS_PRINTABLE[static_cast<byte>(str[i])])
+ if(!IS_PRINTABLE[static_cast<uint8_t>(str[i])])
{
if(type == "utf8") return UTF8_STRING;
if(type == "latin1") return T61_STRING;
diff --git a/src/lib/asn1/asn1_time.cpp b/src/lib/asn1/asn1_time.cpp
index b091c4160..ef259740b 100644
--- a/src/lib/asn1/asn1_time.cpp
+++ b/src/lib/asn1/asn1_time.cpp
@@ -62,7 +62,7 @@ std::string X509_Time::to_string() const
if(time_is_set() == false)
throw Invalid_State("X509_Time::as_string: No time set");
- u32bit full_year = m_year;
+ uint32_t full_year = m_year;
if(m_tag == UTC_TIME)
{
@@ -86,7 +86,7 @@ std::string X509_Time::to_string() const
factor_i * m_minute +
m_second) + "Z";
- u32bit desired_size = (m_tag == UTC_TIME) ? 13 : 15;
+ uint32_t desired_size = (m_tag == UTC_TIME) ? 13 : 15;
while(repr.size() < desired_size)
repr = "0" + repr;
@@ -117,12 +117,12 @@ bool X509_Time::time_is_set() const
return (m_year != 0);
}
-s32bit X509_Time::cmp(const X509_Time& other) const
+int32_t X509_Time::cmp(const X509_Time& other) const
{
if(time_is_set() == false)
throw Invalid_State("X509_Time::cmp: No time set");
- const s32bit EARLIER = -1, LATER = 1, SAME_TIME = 0;
+ const int32_t EARLIER = -1, LATER = 1, SAME_TIME = 0;
if(m_year < other.m_year) return EARLIER;
if(m_year > other.m_year) return LATER;
diff --git a/src/lib/asn1/asn1_time.h b/src/lib/asn1/asn1_time.h
index ee30221ee..a2a526558 100644
--- a/src/lib/asn1/asn1_time.h
+++ b/src/lib/asn1/asn1_time.h
@@ -35,7 +35,7 @@ class BOTAN_DLL X509_Time final : public ASN1_Object
bool time_is_set() const;
/// Compare this time against another
- s32bit cmp(const X509_Time& other) const;
+ int32_t cmp(const X509_Time& other) const;
/// Create an invalid X509_Time
X509_Time() {}
@@ -53,12 +53,12 @@ class BOTAN_DLL X509_Time final : public ASN1_Object
void set_to(const std::string& t_spec, ASN1_Tag);
bool passes_sanity_check() const;
- u32bit m_year = 0;
- u32bit m_month = 0;
- u32bit m_day = 0;
- u32bit m_hour = 0;
- u32bit m_minute = 0;
- u32bit m_second = 0;
+ uint32_t m_year = 0;
+ uint32_t m_month = 0;
+ uint32_t m_day = 0;
+ uint32_t m_hour = 0;
+ uint32_t m_minute = 0;
+ uint32_t m_second = 0;
ASN1_Tag m_tag = NO_OBJECT;
};
diff --git a/src/lib/asn1/ber_dec.cpp b/src/lib/asn1/ber_dec.cpp
index 81c04aa6a..7b2147600 100644
--- a/src/lib/asn1/ber_dec.cpp
+++ b/src/lib/asn1/ber_dec.cpp
@@ -20,7 +20,7 @@ namespace {
*/
size_t decode_tag(DataSource* ber, ASN1_Tag& type_tag, ASN1_Tag& class_tag)
{
- byte b;
+ uint8_t b;
if(!ber->read_byte(b))
{
class_tag = type_tag = NO_OBJECT;
@@ -62,7 +62,7 @@ size_t find_eoc(DataSource*);
*/
size_t decode_length(DataSource* ber, size_t& field_size)
{
- byte b;
+ uint8_t b;
if(!ber->read_byte(b))
throw BER_Decoding_Error("Length field not found");
field_size = 1;
@@ -101,7 +101,7 @@ size_t decode_length(DataSource* ber)
*/
size_t find_eoc(DataSource* ber)
{
- secure_vector<byte> buffer(DEFAULT_BUFFERSIZE), data;
+ secure_vector<uint8_t> buffer(DEFAULT_BUFFERSIZE), data;
while(true)
{
@@ -175,19 +175,19 @@ BER_Decoder& BER_Decoder::verify_end()
/*
* Save all the bytes remaining in the source
*/
-BER_Decoder& BER_Decoder::raw_bytes(secure_vector<byte>& out)
+BER_Decoder& BER_Decoder::raw_bytes(secure_vector<uint8_t>& out)
{
out.clear();
- byte buf;
+ uint8_t buf;
while(m_source->read_byte(buf))
out.push_back(buf);
return (*this);
}
-BER_Decoder& BER_Decoder::raw_bytes(std::vector<byte>& out)
+BER_Decoder& BER_Decoder::raw_bytes(std::vector<uint8_t>& out)
{
out.clear();
- byte buf;
+ uint8_t buf;
while(m_source->read_byte(buf))
out.push_back(buf);
return (*this);
@@ -198,7 +198,7 @@ BER_Decoder& BER_Decoder::raw_bytes(std::vector<byte>& out)
*/
BER_Decoder& BER_Decoder::discard_remaining()
{
- byte buf;
+ uint8_t buf;
while(m_source->read_byte(buf))
;
return (*this);
@@ -292,7 +292,7 @@ BER_Decoder::BER_Decoder(DataSource& src)
/*
* BER_Decoder Constructor
*/
-BER_Decoder::BER_Decoder(const byte data[], size_t length)
+BER_Decoder::BER_Decoder(const uint8_t data[], size_t length)
{
m_source = new DataSource_Memory(data, length);
m_owns = true;
@@ -303,7 +303,7 @@ BER_Decoder::BER_Decoder(const byte data[], size_t length)
/*
* BER_Decoder Constructor
*/
-BER_Decoder::BER_Decoder(const secure_vector<byte>& data)
+BER_Decoder::BER_Decoder(const secure_vector<uint8_t>& data)
{
m_source = new DataSource_Memory(data);
m_owns = true;
@@ -314,7 +314,7 @@ BER_Decoder::BER_Decoder(const secure_vector<byte>& data)
/*
* BER_Decoder Constructor
*/
-BER_Decoder::BER_Decoder(const std::vector<byte>& data)
+BER_Decoder::BER_Decoder(const std::vector<uint8_t>& data)
{
m_source = new DataSource_Memory(data.data(), data.size());
m_owns = true;
@@ -396,15 +396,15 @@ BER_Decoder& BER_Decoder::decode(BigInt& out)
BER_Decoder& BER_Decoder::decode_octet_string_bigint(BigInt& out)
{
- secure_vector<byte> out_vec;
+ secure_vector<uint8_t> out_vec;
decode(out_vec, OCTET_STRING);
out = BigInt::decode(out_vec.data(), out_vec.size());
return (*this);
}
-std::vector<byte> BER_Decoder::get_next_octet_string()
+std::vector<uint8_t> BER_Decoder::get_next_octet_string()
{
- std::vector<byte> out_vec;
+ std::vector<uint8_t> out_vec;
decode(out_vec, OCTET_STRING);
return out_vec;
}
@@ -447,7 +447,7 @@ BER_Decoder& BER_Decoder::decode(size_t& out,
/*
* Decode a small BER encoded INTEGER
*/
-u64bit BER_Decoder::decode_constrained_integer(ASN1_Tag type_tag,
+uint64_t BER_Decoder::decode_constrained_integer(ASN1_Tag type_tag,
ASN1_Tag class_tag,
size_t T_bytes)
{
@@ -460,7 +460,7 @@ u64bit BER_Decoder::decode_constrained_integer(ASN1_Tag type_tag,
if(integer.bits() > 8*T_bytes)
throw BER_Decoding_Error("Decoded integer value larger than expected");
- u64bit out = 0;
+ uint64_t out = 0;
for(size_t i = 0; i != 8; ++i)
out = (out << 8) | integer.byte_at(7-i);
@@ -503,7 +503,7 @@ BER_Decoder& BER_Decoder::decode(BigInt& out,
/*
* BER decode a BIT STRING or OCTET STRING
*/
-BER_Decoder& BER_Decoder::decode(secure_vector<byte>& out, ASN1_Tag real_type)
+BER_Decoder& BER_Decoder::decode(secure_vector<uint8_t>& out, ASN1_Tag real_type)
{
return decode(out, real_type, real_type, UNIVERSAL);
}
@@ -511,7 +511,7 @@ BER_Decoder& BER_Decoder::decode(secure_vector<byte>& out, ASN1_Tag real_type)
/*
* BER decode a BIT STRING or OCTET STRING
*/
-BER_Decoder& BER_Decoder::decode(std::vector<byte>& out, ASN1_Tag real_type)
+BER_Decoder& BER_Decoder::decode(std::vector<uint8_t>& out, ASN1_Tag real_type)
{
return decode(out, real_type, real_type, UNIVERSAL);
}
@@ -519,7 +519,7 @@ BER_Decoder& BER_Decoder::decode(std::vector<byte>& out, ASN1_Tag real_type)
/*
* BER decode a BIT STRING or OCTET STRING
*/
-BER_Decoder& BER_Decoder::decode(secure_vector<byte>& buffer,
+BER_Decoder& BER_Decoder::decode(secure_vector<uint8_t>& buffer,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -544,7 +544,7 @@ BER_Decoder& BER_Decoder::decode(secure_vector<byte>& buffer,
return (*this);
}
-BER_Decoder& BER_Decoder::decode(std::vector<byte>& buffer,
+BER_Decoder& BER_Decoder::decode(std::vector<uint8_t>& buffer,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
diff --git a/src/lib/asn1/ber_dec.h b/src/lib/asn1/ber_dec.h
index 8c1491851..810896880 100644
--- a/src/lib/asn1/ber_dec.h
+++ b/src/lib/asn1/ber_dec.h
@@ -21,7 +21,7 @@ class BOTAN_DLL BER_Decoder
public:
BER_Object get_next_object();
- std::vector<byte> get_next_octet_string();
+ std::vector<uint8_t> get_next_octet_string();
void push_back(const BER_Object& obj);
@@ -34,15 +34,15 @@ class BOTAN_DLL BER_Decoder
BER_Decoder& get_next(BER_Object& ber);
- BER_Decoder& raw_bytes(secure_vector<byte>& v);
- BER_Decoder& raw_bytes(std::vector<byte>& v);
+ BER_Decoder& raw_bytes(secure_vector<uint8_t>& v);
+ BER_Decoder& raw_bytes(std::vector<uint8_t>& v);
BER_Decoder& decode_null();
BER_Decoder& decode(bool& v);
BER_Decoder& decode(size_t& v);
BER_Decoder& decode(class BigInt& v);
- BER_Decoder& decode(std::vector<byte>& v, ASN1_Tag type_tag);
- BER_Decoder& decode(secure_vector<byte>& v, ASN1_Tag type_tag);
+ BER_Decoder& decode(std::vector<uint8_t>& v, ASN1_Tag type_tag);
+ BER_Decoder& decode(secure_vector<uint8_t>& v, ASN1_Tag type_tag);
BER_Decoder& decode(bool& v,
ASN1_Tag type_tag,
@@ -56,12 +56,12 @@ class BOTAN_DLL BER_Decoder
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- BER_Decoder& decode(std::vector<byte>& v,
+ BER_Decoder& decode(std::vector<uint8_t>& v,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- BER_Decoder& decode(secure_vector<byte>& v,
+ BER_Decoder& decode(secure_vector<uint8_t>& v,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
@@ -72,7 +72,7 @@ class BOTAN_DLL BER_Decoder
BER_Decoder& decode_octet_string_bigint(class BigInt& b);
- u64bit decode_constrained_integer(ASN1_Tag type_tag,
+ uint64_t decode_constrained_integer(ASN1_Tag type_tag,
ASN1_Tag class_tag,
size_t T_bytes);
@@ -127,9 +127,9 @@ class BOTAN_DLL BER_Decoder
* Decode an OPTIONAL string type
*/
template<typename Alloc>
- BER_Decoder& decode_optional_string(std::vector<byte, Alloc>& out,
+ BER_Decoder& decode_optional_string(std::vector<uint8_t, Alloc>& out,
ASN1_Tag real_type,
- u16bit type_no,
+ uint16_t type_no,
ASN1_Tag class_tag = CONTEXT_SPECIFIC)
{
BER_Object obj = get_next_object();
@@ -159,11 +159,11 @@ class BOTAN_DLL BER_Decoder
explicit BER_Decoder(DataSource&);
- BER_Decoder(const byte[], size_t);
+ BER_Decoder(const uint8_t[], size_t);
- explicit BER_Decoder(const secure_vector<byte>&);
+ explicit BER_Decoder(const secure_vector<uint8_t>&);
- explicit BER_Decoder(const std::vector<byte>& vec);
+ explicit BER_Decoder(const std::vector<uint8_t>& vec);
BER_Decoder(const BER_Decoder&);
~BER_Decoder();
diff --git a/src/lib/asn1/der_enc.cpp b/src/lib/asn1/der_enc.cpp
index c5c2b4803..071e330ff 100644
--- a/src/lib/asn1/der_enc.cpp
+++ b/src/lib/asn1/der_enc.cpp
@@ -20,15 +20,15 @@ namespace {
/*
* DER encode an ASN.1 type tag
*/
-secure_vector<byte> encode_tag(ASN1_Tag type_tag, ASN1_Tag class_tag)
+secure_vector<uint8_t> encode_tag(ASN1_Tag type_tag, ASN1_Tag class_tag)
{
if((class_tag | 0xE0) != 0xE0)
throw Encoding_Error("DER_Encoder: Invalid class tag " +
std::to_string(class_tag));
- secure_vector<byte> encoded_tag;
+ secure_vector<uint8_t> encoded_tag;
if(type_tag <= 30)
- encoded_tag.push_back(static_cast<byte>(type_tag | class_tag));
+ encoded_tag.push_back(static_cast<uint8_t>(type_tag | class_tag));
else
{
size_t blocks = high_bit(type_tag) + 6;
@@ -48,18 +48,18 @@ secure_vector<byte> encode_tag(ASN1_Tag type_tag, ASN1_Tag class_tag)
/*
* DER encode an ASN.1 length field
*/
-secure_vector<byte> encode_length(size_t length)
+secure_vector<uint8_t> encode_length(size_t length)
{
- secure_vector<byte> encoded_length;
+ secure_vector<uint8_t> encoded_length;
if(length <= 127)
- encoded_length.push_back(static_cast<byte>(length));
+ encoded_length.push_back(static_cast<uint8_t>(length));
else
{
- const size_t top_byte = significant_bytes(length);
+ const size_t bytes_needed = significant_bytes(length);
- encoded_length.push_back(static_cast<byte>(0x80 | top_byte));
+ encoded_length.push_back(static_cast<uint8_t>(0x80 | bytes_needed));
- for(size_t i = sizeof(length) - top_byte; i != sizeof(length); ++i)
+ for(size_t i = sizeof(length) - bytes_needed; i < sizeof(length); ++i)
encoded_length.push_back(get_byte(i, length));
}
return encoded_length;
@@ -70,7 +70,7 @@ secure_vector<byte> encode_length(size_t length)
/*
* Return the encoded SEQUENCE/SET
*/
-secure_vector<byte> DER_Encoder::DER_Sequence::get_contents()
+secure_vector<uint8_t> DER_Encoder::DER_Sequence::get_contents()
{
const ASN1_Tag real_class_tag = ASN1_Tag(m_class_tag | CONSTRUCTED);
@@ -82,7 +82,7 @@ secure_vector<byte> DER_Encoder::DER_Sequence::get_contents()
m_set_contents.clear();
}
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
result += encode_tag(m_type_tag, real_class_tag);
result += encode_length(m_contents.size());
result += m_contents;
@@ -94,10 +94,10 @@ secure_vector<byte> DER_Encoder::DER_Sequence::get_contents()
/*
* Add an encoded value to the SEQUENCE/SET
*/
-void DER_Encoder::DER_Sequence::add_bytes(const byte data[], size_t length)
+void DER_Encoder::DER_Sequence::add_bytes(const uint8_t data[], size_t length)
{
if(m_type_tag == SET)
- m_set_contents.push_back(secure_vector<byte>(data, data + length));
+ m_set_contents.push_back(secure_vector<uint8_t>(data, data + length));
else
m_contents += std::make_pair(data, length);
}
@@ -121,12 +121,12 @@ DER_Encoder::DER_Sequence::DER_Sequence(ASN1_Tag t1, ASN1_Tag t2) :
/*
* Return the encoded contents
*/
-secure_vector<byte> DER_Encoder::get_contents()
+secure_vector<uint8_t> DER_Encoder::get_contents()
{
if(m_subsequences.size() != 0)
throw Invalid_State("DER_Encoder: Sequence hasn't been marked done");
- secure_vector<byte> output;
+ secure_vector<uint8_t> output;
std::swap(output, m_contents);
return output;
}
@@ -149,7 +149,7 @@ DER_Encoder& DER_Encoder::end_cons()
if(m_subsequences.empty())
throw Invalid_State("DER_Encoder::end_cons: No such sequence");
- secure_vector<byte> seq = m_subsequences[m_subsequences.size()-1].get_contents();
+ secure_vector<uint8_t> seq = m_subsequences[m_subsequences.size()-1].get_contents();
m_subsequences.pop_back();
raw_bytes(seq);
return (*this);
@@ -158,7 +158,7 @@ DER_Encoder& DER_Encoder::end_cons()
/*
* Start a new ASN.1 EXPLICIT encoding
*/
-DER_Encoder& DER_Encoder::start_explicit(u16bit type_no)
+DER_Encoder& DER_Encoder::start_explicit(uint16_t type_no)
{
ASN1_Tag type_tag = static_cast<ASN1_Tag>(type_no);
@@ -179,12 +179,12 @@ DER_Encoder& DER_Encoder::end_explicit()
/*
* Write raw bytes into the stream
*/
-DER_Encoder& DER_Encoder::raw_bytes(const secure_vector<byte>& val)
+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<byte>& val)
+DER_Encoder& DER_Encoder::raw_bytes(const std::vector<uint8_t>& val)
{
return raw_bytes(val.data(), val.size());
}
@@ -192,7 +192,7 @@ DER_Encoder& DER_Encoder::raw_bytes(const std::vector<byte>& val)
/*
* Write raw bytes into the stream
*/
-DER_Encoder& DER_Encoder::raw_bytes(const byte bytes[], size_t length)
+DER_Encoder& DER_Encoder::raw_bytes(const uint8_t bytes[], size_t length)
{
if(m_subsequences.size())
m_subsequences[m_subsequences.size()-1].add_bytes(bytes, length);
@@ -237,7 +237,7 @@ DER_Encoder& DER_Encoder::encode(const BigInt& n)
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const secure_vector<byte>& bytes,
+DER_Encoder& DER_Encoder::encode(const secure_vector<uint8_t>& bytes,
ASN1_Tag real_type)
{
return encode(bytes.data(), bytes.size(),
@@ -247,7 +247,7 @@ DER_Encoder& DER_Encoder::encode(const secure_vector<byte>& bytes,
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const std::vector<byte>& bytes,
+DER_Encoder& DER_Encoder::encode(const std::vector<uint8_t>& bytes,
ASN1_Tag real_type)
{
return encode(bytes.data(), bytes.size(),
@@ -257,7 +257,7 @@ DER_Encoder& DER_Encoder::encode(const std::vector<byte>& bytes,
/*
* Encode this object
*/
-DER_Encoder& DER_Encoder::encode(const byte bytes[], size_t length,
+DER_Encoder& DER_Encoder::encode(const uint8_t bytes[], size_t length,
ASN1_Tag real_type)
{
return encode(bytes, length, real_type, real_type, UNIVERSAL);
@@ -269,7 +269,7 @@ DER_Encoder& DER_Encoder::encode(const byte bytes[], size_t length,
DER_Encoder& DER_Encoder::encode(bool is_true,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
- byte val = is_true ? 0xFF : 0x00;
+ uint8_t val = is_true ? 0xFF : 0x00;
return add_object(type_tag, class_tag, &val, 1);
}
@@ -292,7 +292,7 @@ DER_Encoder& DER_Encoder::encode(const BigInt& n,
return add_object(type_tag, class_tag, 0);
bool extra_zero = (n.bits() % 8 == 0);
- secure_vector<byte> contents(extra_zero + n.bytes());
+ secure_vector<uint8_t> contents(extra_zero + n.bytes());
BigInt::encode(&contents[extra_zero], n);
if(n < 0)
{
@@ -309,7 +309,7 @@ DER_Encoder& DER_Encoder::encode(const BigInt& n,
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const secure_vector<byte>& bytes,
+DER_Encoder& DER_Encoder::encode(const secure_vector<uint8_t>& bytes,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -320,7 +320,7 @@ DER_Encoder& DER_Encoder::encode(const secure_vector<byte>& bytes,
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const std::vector<byte>& bytes,
+DER_Encoder& DER_Encoder::encode(const std::vector<uint8_t>& bytes,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -331,7 +331,7 @@ DER_Encoder& DER_Encoder::encode(const std::vector<byte>& bytes,
/*
* DER encode an OCTET STRING or BIT STRING
*/
-DER_Encoder& DER_Encoder::encode(const byte bytes[], size_t length,
+DER_Encoder& DER_Encoder::encode(const uint8_t bytes[], size_t length,
ASN1_Tag real_type,
ASN1_Tag type_tag, ASN1_Tag class_tag)
{
@@ -340,7 +340,7 @@ DER_Encoder& DER_Encoder::encode(const byte bytes[], size_t length,
if(real_type == BIT_STRING)
{
- secure_vector<byte> encoded;
+ secure_vector<uint8_t> encoded;
encoded.push_back(0);
encoded += std::make_pair(bytes, length);
return add_object(type_tag, class_tag, encoded);
@@ -379,9 +379,9 @@ DER_Encoder& DER_Encoder::encode(const ASN1_Object& obj)
* Write the encoding of the byte(s)
*/
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- const byte rep[], size_t length)
+ const uint8_t rep[], size_t length)
{
- secure_vector<byte> buffer;
+ secure_vector<uint8_t> buffer;
buffer += encode_tag(type_tag, class_tag);
buffer += encode_length(length);
buffer += std::make_pair(rep, length);
@@ -395,7 +395,7 @@ DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
const std::string& rep_str)
{
- const byte* rep = reinterpret_cast<const byte*>(rep_str.data());
+ const uint8_t* rep = reinterpret_cast<const uint8_t*>(rep_str.data());
const size_t rep_len = rep_str.size();
return add_object(type_tag, class_tag, rep, rep_len);
}
@@ -404,7 +404,7 @@ DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
* Write the encoding of the byte
*/
DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag,
- ASN1_Tag class_tag, byte rep)
+ ASN1_Tag class_tag, uint8_t rep)
{
return add_object(type_tag, class_tag, &rep, 1);
}
diff --git a/src/lib/asn1/der_enc.h b/src/lib/asn1/der_enc.h
index 78cb4c38d..22a8741c6 100644
--- a/src/lib/asn1/der_enc.h
+++ b/src/lib/asn1/der_enc.h
@@ -22,29 +22,29 @@ class ASN1_Object;
class BOTAN_DLL DER_Encoder
{
public:
- secure_vector<byte> get_contents();
+ secure_vector<uint8_t> get_contents();
- std::vector<byte> get_contents_unlocked()
+ std::vector<uint8_t> get_contents_unlocked()
{ return unlock(get_contents()); }
DER_Encoder& start_cons(ASN1_Tag type_tag,
ASN1_Tag class_tag = UNIVERSAL);
DER_Encoder& end_cons();
- DER_Encoder& start_explicit(u16bit type_tag);
+ DER_Encoder& start_explicit(uint16_t type_tag);
DER_Encoder& end_explicit();
- DER_Encoder& raw_bytes(const byte val[], size_t len);
- DER_Encoder& raw_bytes(const secure_vector<byte>& val);
- DER_Encoder& raw_bytes(const std::vector<byte>& val);
+ 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);
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<byte>& v, ASN1_Tag real_type);
- DER_Encoder& encode(const std::vector<byte>& v, ASN1_Tag real_type);
- DER_Encoder& encode(const byte val[], size_t len, ASN1_Tag real_type);
+ 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);
DER_Encoder& encode(bool b,
ASN1_Tag type_tag,
@@ -58,17 +58,17 @@ class BOTAN_DLL DER_Encoder
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- DER_Encoder& encode(const std::vector<byte>& v,
+ DER_Encoder& encode(const std::vector<uint8_t>& v,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- DER_Encoder& encode(const secure_vector<byte>& v,
+ DER_Encoder& encode(const secure_vector<uint8_t>& v,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- DER_Encoder& encode(const byte v[], size_t len,
+ DER_Encoder& encode(const uint8_t v[], size_t len,
ASN1_Tag real_type,
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
@@ -94,16 +94,16 @@ class BOTAN_DLL DER_Encoder
DER_Encoder& encode_if(bool pred, const ASN1_Object& obj);
DER_Encoder& add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- const byte rep[], size_t length);
+ const uint8_t rep[], size_t length);
DER_Encoder& add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- const std::vector<byte>& rep)
+ const std::vector<uint8_t>& rep)
{
return add_object(type_tag, class_tag, rep.data(), rep.size());
}
DER_Encoder& add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- const secure_vector<byte>& rep)
+ const secure_vector<uint8_t>& rep)
{
return add_object(type_tag, class_tag, rep.data(), rep.size());
}
@@ -112,23 +112,23 @@ class BOTAN_DLL DER_Encoder
const std::string& str);
DER_Encoder& add_object(ASN1_Tag type_tag, ASN1_Tag class_tag,
- byte val);
+ uint8_t val);
private:
class DER_Sequence
{
public:
ASN1_Tag tag_of() const;
- secure_vector<byte> get_contents();
- void add_bytes(const byte[], size_t);
+ secure_vector<uint8_t> get_contents();
+ void add_bytes(const uint8_t[], size_t);
DER_Sequence(ASN1_Tag, ASN1_Tag);
private:
ASN1_Tag m_type_tag, m_class_tag;
- secure_vector<byte> m_contents;
- std::vector< secure_vector<byte> > m_set_contents;
+ secure_vector<uint8_t> m_contents;
+ std::vector< secure_vector<uint8_t> > m_set_contents;
};
- secure_vector<byte> m_contents;
+ secure_vector<uint8_t> m_contents;
std::vector<DER_Sequence> m_subsequences;
};
diff --git a/src/lib/asn1/x509_dn.cpp b/src/lib/asn1/x509_dn.cpp
index e9a4731b3..e5cd2b8cc 100644
--- a/src/lib/asn1/x509_dn.cpp
+++ b/src/lib/asn1/x509_dn.cpp
@@ -108,7 +108,7 @@ std::vector<std::string> X509_DN::get_attribute(const std::string& attr) const
/*
* Return the BER encoded data, if any
*/
-std::vector<byte> X509_DN::get_bits() const
+std::vector<uint8_t> X509_DN::get_bits() const
{
return m_dn_bits;
}
@@ -249,7 +249,7 @@ void X509_DN::encode_into(DER_Encoder& der) const
*/
void X509_DN::decode_from(BER_Decoder& source)
{
- std::vector<byte> bits;
+ std::vector<uint8_t> bits;
source.start_cons(SEQUENCE)
.raw_bytes(bits)
diff --git a/src/lib/asn1/x509_dn.h b/src/lib/asn1/x509_dn.h
index 92dd7a3d2..8add8d64c 100644
--- a/src/lib/asn1/x509_dn.h
+++ b/src/lib/asn1/x509_dn.h
@@ -35,7 +35,7 @@ class BOTAN_DLL X509_DN final : public ASN1_Object
static std::string deref_info_field(const std::string&);
- std::vector<byte> get_bits() const;
+ std::vector<uint8_t> get_bits() const;
bool empty() const { return m_dn_info.empty(); }
@@ -44,7 +44,7 @@ class BOTAN_DLL X509_DN final : public ASN1_Object
explicit X509_DN(const std::multimap<std::string, std::string>&);
private:
std::multimap<OID, ASN1_String> m_dn_info;
- std::vector<byte> m_dn_bits;
+ std::vector<uint8_t> m_dn_bits;
};
bool BOTAN_DLL operator==(const X509_DN&, const X509_DN&);