aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/modes/aead/ccm/ccm.cpp4
-rw-r--r--src/lib/tls/msg_certificate.cpp4
-rw-r--r--src/lib/tls/tls_channel.cpp4
-rw-r--r--src/lib/tls/tls_extensions.cpp24
-rw-r--r--src/lib/tls/tls_handshake_io.cpp6
-rw-r--r--src/lib/tls/tls_record.cpp12
-rw-r--r--src/lib/utils/loadstor.h2
7 files changed, 28 insertions, 28 deletions
diff --git a/src/lib/modes/aead/ccm/ccm.cpp b/src/lib/modes/aead/ccm/ccm.cpp
index df33685f3..1f528769e 100644
--- a/src/lib/modes/aead/ccm/ccm.cpp
+++ b/src/lib/modes/aead/ccm/ccm.cpp
@@ -81,8 +81,8 @@ void CCM_Mode::set_associated_data(const byte ad[], size_t length)
// FIXME: support larger AD using length encoding rules
BOTAN_ASSERT(length < (0xFFFF - 0xFF), "Supported CCM AD length");
- m_ad_buf.push_back(get_byte<u16bit>(0, length));
- m_ad_buf.push_back(get_byte<u16bit>(1, length));
+ m_ad_buf.push_back(get_byte(0, static_cast<u16bit>(length)));
+ m_ad_buf.push_back(get_byte(1, static_cast<u16bit>(length)));
m_ad_buf += std::make_pair(ad, length);
while(m_ad_buf.size() % BS)
m_ad_buf.push_back(0); // pad with zeros to full block size
diff --git a/src/lib/tls/msg_certificate.cpp b/src/lib/tls/msg_certificate.cpp
index 5be9379bd..32e3e17f0 100644
--- a/src/lib/tls/msg_certificate.cpp
+++ b/src/lib/tls/msg_certificate.cpp
@@ -73,14 +73,14 @@ std::vector<byte> Certificate::serialize() const
const size_t cert_size = raw_cert.size();
for(size_t j = 0; j != 3; ++j)
{
- buf.push_back(get_byte<u32bit>(j+1, cert_size));
+ buf.push_back(get_byte(j+1, static_cast<u32bit>(cert_size)));
}
buf += raw_cert;
}
const size_t buf_size = buf.size() - 3;
for(size_t i = 0; i != 3; ++i)
- buf[i] = get_byte<u32bit>(i+1, buf_size);
+ buf[i] = get_byte(i+1, static_cast<u32bit>(buf_size));
return buf;
}
diff --git a/src/lib/tls/tls_channel.cpp b/src/lib/tls/tls_channel.cpp
index 2cf351c80..131196ce5 100644
--- a/src/lib/tls/tls_channel.cpp
+++ b/src/lib/tls/tls_channel.cpp
@@ -630,8 +630,8 @@ SymmetricKey Channel::key_material_export(const std::string& label,
size_t context_size = context.length();
if(context_size > 0xFFFF)
throw Exception("key_material_export context is too long");
- salt.push_back(get_byte<u16bit>(0, context_size));
- salt.push_back(get_byte<u16bit>(1, context_size));
+ salt.push_back(get_byte(0, static_cast<u16bit>(context_size)));
+ salt.push_back(get_byte(1, static_cast<u16bit>(context_size)));
salt += to_byte_vector(context);
}
diff --git a/src/lib/tls/tls_extensions.cpp b/src/lib/tls/tls_extensions.cpp
index 8befb2fbc..fc442ab14 100644
--- a/src/lib/tls/tls_extensions.cpp
+++ b/src/lib/tls/tls_extensions.cpp
@@ -99,8 +99,8 @@ std::vector<byte> Extensions::serialize() const
buf.push_back(get_byte(0, extn_code));
buf.push_back(get_byte(1, extn_code));
- buf.push_back(get_byte<u16bit>(0, extn_val.size()));
- buf.push_back(get_byte<u16bit>(1, extn_val.size()));
+ buf.push_back(get_byte(0, static_cast<u16bit>(extn_val.size())));
+ buf.push_back(get_byte(1, static_cast<u16bit>(extn_val.size())));
buf += extn_val;
}
@@ -163,12 +163,12 @@ std::vector<byte> Server_Name_Indicator::serialize() const
size_t name_len = m_sni_host_name.size();
- buf.push_back(get_byte<u16bit>(0, name_len+3));
- buf.push_back(get_byte<u16bit>(1, name_len+3));
+ buf.push_back(get_byte(0, static_cast<u16bit>(name_len+3)));
+ buf.push_back(get_byte(1, static_cast<u16bit>(name_len+3)));
buf.push_back(0); // DNS
- buf.push_back(get_byte<u16bit>(0, name_len));
- buf.push_back(get_byte<u16bit>(1, name_len));
+ buf.push_back(get_byte(0, static_cast<u16bit>(name_len)));
+ buf.push_back(get_byte(1, static_cast<u16bit>(name_len)));
buf += std::make_pair(
reinterpret_cast<const byte*>(m_sni_host_name.data()),
@@ -264,8 +264,8 @@ std::vector<byte> Application_Layer_Protocol_Notification::serialize() const
1);
}
- buf[0] = get_byte<u16bit>(0, buf.size()-2);
- buf[1] = get_byte<u16bit>(1, buf.size()-2);
+ buf[0] = get_byte(0, static_cast<u16bit>(buf.size()-2));
+ buf[1] = get_byte(1, static_cast<u16bit>(buf.size()-2));
return buf;
}
@@ -320,8 +320,8 @@ std::vector<byte> Supported_Elliptic_Curves::serialize() const
buf.push_back(get_byte(1, id));
}
- buf[0] = get_byte<u16bit>(0, buf.size()-2);
- buf[1] = get_byte<u16bit>(1, buf.size()-2);
+ buf[0] = get_byte(0, static_cast<u16bit>(buf.size()-2));
+ buf[1] = get_byte(1, static_cast<u16bit>(buf.size()-2));
return buf;
}
@@ -435,8 +435,8 @@ std::vector<byte> Signature_Algorithms::serialize() const
{}
}
- buf[0] = get_byte<u16bit>(0, buf.size()-2);
- buf[1] = get_byte<u16bit>(1, buf.size()-2);
+ buf[0] = get_byte(0, static_cast<u16bit>(buf.size()-2));
+ buf[1] = get_byte(1, static_cast<u16bit>(buf.size()-2));
return buf;
}
diff --git a/src/lib/tls/tls_handshake_io.cpp b/src/lib/tls/tls_handshake_io.cpp
index f39c9f84e..720e4459f 100644
--- a/src/lib/tls/tls_handshake_io.cpp
+++ b/src/lib/tls/tls_handshake_io.cpp
@@ -28,9 +28,9 @@ inline size_t load_be24(const byte q[3])
void store_be24(byte out[3], size_t val)
{
- out[0] = get_byte<u32bit>(1, val);
- out[1] = get_byte<u32bit>(2, val);
- out[2] = get_byte<u32bit>(3, val);
+ out[0] = get_byte(1, static_cast<u32bit>(val));
+ out[1] = get_byte(2, static_cast<u32bit>(val));
+ out[2] = get_byte(3, static_cast<u32bit>(val));
}
u64bit steady_clock_ms()
diff --git a/src/lib/tls/tls_record.cpp b/src/lib/tls/tls_record.cpp
index 8af6587e3..16ba42ce6 100644
--- a/src/lib/tls/tls_record.cpp
+++ b/src/lib/tls/tls_record.cpp
@@ -172,8 +172,8 @@ void write_record(secure_vector<byte>& output,
if(!cs) // initial unencrypted handshake records
{
- output.push_back(get_byte<u16bit>(0, msg_length));
- output.push_back(get_byte<u16bit>(1, msg_length));
+ output.push_back(get_byte(0, static_cast<u16bit>(msg_length)));
+ output.push_back(get_byte(1, static_cast<u16bit>(msg_length)));
output.insert(output.end(), msg, msg + msg_length);
@@ -190,8 +190,8 @@ void write_record(secure_vector<byte>& output,
const size_t rec_size = ctext_size + cs->nonce_bytes_from_record();
BOTAN_ASSERT(rec_size <= 0xFFFF, "Ciphertext length fits in field");
- output.push_back(get_byte<u16bit>(0, rec_size));
- output.push_back(get_byte<u16bit>(1, rec_size));
+ output.push_back(get_byte(0, static_cast<u16bit>(rec_size)));
+ output.push_back(get_byte(1, static_cast<u16bit>(rec_size)));
aead->set_ad(cs->format_ad(seq, msg_type, version, msg_length));
@@ -228,8 +228,8 @@ void write_record(secure_vector<byte>& output,
if(buf_size > MAX_CIPHERTEXT_SIZE)
throw Internal_Error("Output record is larger than allowed by protocol");
- output.push_back(get_byte<u16bit>(0, buf_size));
- output.push_back(get_byte<u16bit>(1, buf_size));
+ output.push_back(get_byte(0, static_cast<u16bit>(buf_size)));
+ output.push_back(get_byte(1, static_cast<u16bit>(buf_size)));
const size_t header_size = output.size();
diff --git a/src/lib/utils/loadstor.h b/src/lib/utils/loadstor.h
index a6c2b7969..9ae9fda0e 100644
--- a/src/lib/utils/loadstor.h
+++ b/src/lib/utils/loadstor.h
@@ -47,7 +47,7 @@ namespace Botan {
template<typename T> inline byte get_byte(size_t byte_num, T input)
{
return static_cast<byte>(
- input >> ((sizeof(T)-1-(byte_num&(sizeof(T)-1))) << 3)
+ input >> (((~byte_num)&(sizeof(T)-1)) << 3)
);
}