aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-11-19 11:08:36 -0500
committerJack Lloyd <[email protected]>2018-11-19 11:08:36 -0500
commiteea263e826d1d50dc11004eab2afcc312ed4e7e0 (patch)
tree94ec47998d680eeb2666d54ad7e67d11740d85b8
parentde7262c49dae9de00fdb40c68c8229cf1358188d (diff)
parent71ecbd15c47b136c4a7c712775d86435fa4fc453 (diff)
Merge GH #1743 Avoid memset/memcpy in library code
-rw-r--r--src/cli/tls_client.cpp2
-rw-r--r--src/cli/tls_server.cpp2
-rw-r--r--src/lib/hash/streebog/streebog.cpp4
-rw-r--r--src/lib/prov/bearssl/bearssl_hash.cpp2
-rw-r--r--src/lib/prov/commoncrypto/commoncrypto_mode.cpp4
-rw-r--r--src/lib/prov/commoncrypto/commoncrypto_utils.cpp2
-rw-r--r--src/lib/prov/openssl/openssl_mode.cpp4
-rw-r--r--src/lib/prov/openssl/openssl_rsa.cpp2
-rw-r--r--src/lib/prov/pkcs11/p11_mechanism.h4
-rw-r--r--src/lib/prov/tpm/tpm.cpp6
-rw-r--r--src/lib/pubkey/ed25519/ed25519.cpp4
-rw-r--r--src/lib/pubkey/ed25519/ed25519_fe.h8
-rw-r--r--src/lib/stream/chacha/chacha_avx2/chacha_avx2.cpp1
-rw-r--r--src/lib/utils/loadstor.h34
-rw-r--r--src/lib/utils/mem_ops.h40
-rw-r--r--src/lib/utils/socket/socket.cpp2
-rw-r--r--src/tests/test_block.cpp4
-rw-r--r--src/tests/test_rng.h7
-rw-r--r--src/tests/test_tls.cpp7
-rw-r--r--src/tests/test_utils.cpp3
20 files changed, 84 insertions, 58 deletions
diff --git a/src/cli/tls_client.cpp b/src/cli/tls_client.cpp
index 7834d9328..dfe874313 100644
--- a/src/cli/tls_client.cpp
+++ b/src/cli/tls_client.cpp
@@ -280,7 +280,7 @@ class TLS_Client final : public Command, public Botan::TLS::Callbacks
int connect_to_host(const std::string& host, uint16_t port, bool tcp)
{
addrinfo hints;
- std::memset(&hints, 0, sizeof(hints));
+ Botan::clear_mem(&hints, 1);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = tcp ? SOCK_STREAM : SOCK_DGRAM;
addrinfo* res, *rp = nullptr;
diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp
index 0fd075741..c8e6c58f3 100644
--- a/src/cli/tls_server.cpp
+++ b/src/cli/tls_server.cpp
@@ -213,7 +213,7 @@ class TLS_Server final : public Command, public Botan::TLS::Callbacks
}
sockaddr_in socket_info;
- ::memset(&socket_info, 0, sizeof(socket_info));
+ Botan::clear_mem(&socket_info, 1);
socket_info.sin_family = AF_INET;
socket_info.sin_port = htons(port);
diff --git a/src/lib/hash/streebog/streebog.cpp b/src/lib/hash/streebog/streebog.cpp
index cd67256cb..8bb56ccc9 100644
--- a/src/lib/hash/streebog/streebog.cpp
+++ b/src/lib/hash/streebog/streebog.cpp
@@ -35,9 +35,10 @@ static inline void addm(const uint8_t* m, uint64_t* h)
}
}
-inline void lps(uint64_t* block)
+inline void lps(uint64_t block[8])
{
uint8_t r[64];
+ // FIXME
std::memcpy(r, block, 64);
for(int i = 0; i < 8; ++i)
@@ -171,6 +172,7 @@ void Streebog::final_result(uint8_t output[])
compress(m_buffer.data(), true);
compress(reinterpret_cast<const uint8_t*>(m_S.data()), true);
+ // FIXME
std::memcpy(output, &m_h[8 - output_length() / 8], output_length());
clear();
}
diff --git a/src/lib/prov/bearssl/bearssl_hash.cpp b/src/lib/prov/bearssl/bearssl_hash.cpp
index 564935624..2b837bcf5 100644
--- a/src/lib/prov/bearssl/bearssl_hash.cpp
+++ b/src/lib/prov/bearssl/bearssl_hash.cpp
@@ -37,7 +37,7 @@ class BearSSL_HashFunction final : public HashFunction
std::unique_ptr<HashFunction> copy_state() const override
{
std::unique_ptr<BearSSL_HashFunction> copy(new BearSSL_HashFunction(m_ctx.vtable, m_name));
- memcpy(&copy->m_ctx, &m_ctx, sizeof(m_ctx));
+ std::memcpy(&copy->m_ctx, &m_ctx, sizeof(m_ctx));
return std::move(copy);
}
diff --git a/src/lib/prov/commoncrypto/commoncrypto_mode.cpp b/src/lib/prov/commoncrypto/commoncrypto_mode.cpp
index a3a27637a..cb30b6802 100644
--- a/src/lib/prov/commoncrypto/commoncrypto_mode.cpp
+++ b/src/lib/prov/commoncrypto/commoncrypto_mode.cpp
@@ -111,7 +111,7 @@ size_t CommonCrypto_Cipher_Mode::process(uint8_t msg[], size_t msg_len)
{
throw CommonCrypto_Error("CCCryptorUpdate", status);
}
- memcpy(msg, out.data(), outl);
+ copy_mem(msg, out.data(), outl);
return outl;
}
@@ -143,7 +143,7 @@ void CommonCrypto_Cipher_Mode::finish(secure_vector<uint8_t>& buffer,
{
buffer.resize(new_len);
}
- memcpy(buffer.data() - offset + written, out.data(), outl);
+ copy_mem(buffer.data() - offset + written, out.data(), outl);
written += outl;
}
diff --git a/src/lib/prov/commoncrypto/commoncrypto_utils.cpp b/src/lib/prov/commoncrypto/commoncrypto_utils.cpp
index 9ec9c30ee..97da49496 100644
--- a/src/lib/prov/commoncrypto/commoncrypto_utils.cpp
+++ b/src/lib/prov/commoncrypto/commoncrypto_utils.cpp
@@ -178,7 +178,7 @@ void commoncrypto_adjust_key_size(const uint8_t key[], size_t length,
full_key.resize(length * repeat);
for(int i=0; i<repeat; i++)
{
- memcpy(full_key.data() + i * length, key, length);
+ copy_mem(full_key.data() + i * length, key, length);
}
}
else if(opts.algo == kCCAlgorithm3DES && length == 16)
diff --git a/src/lib/prov/openssl/openssl_mode.cpp b/src/lib/prov/openssl/openssl_mode.cpp
index 5636d008f..d1983949d 100644
--- a/src/lib/prov/openssl/openssl_mode.cpp
+++ b/src/lib/prov/openssl/openssl_mode.cpp
@@ -117,7 +117,7 @@ size_t OpenSSL_Cipher_Mode::process(uint8_t msg[], size_t msg_len)
if(!EVP_CipherUpdate(m_cipher, out.data(), &outl, msg, msg_len))
throw OpenSSL_Error("EVP_CipherUpdate");
- memcpy(msg, out.data(), outl);
+ copy_mem(msg, out.data(), outl);
return outl;
}
@@ -137,7 +137,7 @@ void OpenSSL_Cipher_Mode::finish(secure_vector<uint8_t>& buffer,
if(!EVP_CipherFinal_ex(m_cipher, out.data(), &outl))
throw OpenSSL_Error("EVP_CipherFinal_ex");
- memcpy(buf + written, out.data(), outl);
+ copy_mem(buf + written, out.data(), outl);
written += outl;
buffer.resize(offset + written);
}
diff --git a/src/lib/prov/openssl/openssl_rsa.cpp b/src/lib/prov/openssl/openssl_rsa.cpp
index 98c0734a8..4e9068ce4 100644
--- a/src/lib/prov/openssl/openssl_rsa.cpp
+++ b/src/lib/prov/openssl/openssl_rsa.cpp
@@ -302,7 +302,7 @@ make_openssl_rsa_private_key(RandomNumberGenerator& rng, size_t rsa_bits)
throw OpenSSL_Error("i2d_RSAPrivateKey");
const secure_vector<uint8_t> keydata(der, der + bytes);
- memset(der, 0, bytes);
+ secure_scrub_memory(der, bytes);
std::free(der);
return std::unique_ptr<Botan::RSA_PrivateKey>
(new RSA_PrivateKey(AlgorithmIdentifier(), keydata));
diff --git a/src/lib/prov/pkcs11/p11_mechanism.h b/src/lib/prov/pkcs11/p11_mechanism.h
index 035d1e69a..8947372fd 100644
--- a/src/lib/prov/pkcs11/p11_mechanism.h
+++ b/src/lib/prov/pkcs11/p11_mechanism.h
@@ -92,12 +92,12 @@ class MechanismWrapper final
return m_padding_size;
}
- /// Holds the mechanism parameters for OEAP, PSS and ECDH
+ /// Holds the mechanism parameters for OAEP, PSS and ECDH
union MechanismParameters
{
MechanismParameters()
{
- std::memset(this, 0, sizeof(MechanismParameters));
+ clear_mem(this, 1);
}
RsaPkcsOaepParams oaep_params;
diff --git a/src/lib/prov/tpm/tpm.cpp b/src/lib/prov/tpm/tpm.cpp
index 4847b0df6..5516d41a0 100644
--- a/src/lib/prov/tpm/tpm.cpp
+++ b/src/lib/prov/tpm/tpm.cpp
@@ -113,7 +113,7 @@ TSS_UUID to_tss_uuid(const UUID& uuid)
static_assert(sizeof(TSS_UUID) == 16, "Expected size of packed UUID");
TSS_UUID tss_uuid;
- std::memcpy(&tss_uuid, uuid.binary_value().data(), 16);
+ typecast_copy(tss_uuid, uuid.binary_value().data());
return tss_uuid;
}
@@ -122,7 +122,7 @@ UUID from_tss_uuid(const TSS_UUID& tss_uuid)
static_assert(sizeof(TSS_UUID) == 16, "Expected size of packed UUID");
std::vector<uint8_t> mem(16);
- std::memcpy(mem.data(), &tss_uuid, 16);
+ typecast_copy(mem.data(), tss_uuid);
UUID uuid(std::move(mem));
return uuid;
}
@@ -191,7 +191,7 @@ void TPM_Context::gen_random(uint8_t out[], size_t out_len)
{
BYTE* mem;
TSPI_CHECK_SUCCESS(::Tspi_TPM_GetRandom(m_tpm, out_len, &mem));
- std::memcpy(out, mem, out_len);
+ copy_mem(out, reinterpret_cast<const uint8_t*>(mem), out_len);
TSPI_CHECK_SUCCESS(::Tspi_Context_FreeMemory(m_ctx, mem));
}
diff --git a/src/lib/pubkey/ed25519/ed25519.cpp b/src/lib/pubkey/ed25519/ed25519.cpp
index d959df709..b75028041 100644
--- a/src/lib/pubkey/ed25519/ed25519.cpp
+++ b/src/lib/pubkey/ed25519/ed25519.cpp
@@ -29,8 +29,8 @@ void ed25519_gen_keypair(uint8_t* pk, uint8_t* sk, const uint8_t seed[32])
ge_scalarmult_base(pk, az);
// todo copy_mem
- memmove(sk, seed, 32);
- memmove(sk + 32, pk, 32);
+ copy_mem(sk, seed, 32);
+ copy_mem(sk + 32, pk, 32);
}
void ed25519_sign(uint8_t sig[64],
diff --git a/src/lib/pubkey/ed25519/ed25519_fe.h b/src/lib/pubkey/ed25519/ed25519_fe.h
index af92af46a..bcdc36a5e 100644
--- a/src/lib/pubkey/ed25519/ed25519_fe.h
+++ b/src/lib/pubkey/ed25519/ed25519_fe.h
@@ -30,16 +30,16 @@ class FE_25519
FE_25519(int init = 0)
{
if(init != 0 && init != 1)
- { throw Invalid_Argument("Invalid FE_25519 initial value"); }
- memset(m_fe, 0, 10 * sizeof(int32_t));
+ throw Invalid_Argument("Invalid FE_25519 initial value");
+ clear_mem(m_fe, 10);
m_fe[0] = init;
}
FE_25519(std::initializer_list<int32_t> x)
{
if(x.size() != 10)
- { throw Invalid_Argument("Invalid FE_25519 initializer list"); }
- memcpy(m_fe, x.begin(), 10 * sizeof(int32_t));
+ throw Invalid_Argument("Invalid FE_25519 initializer list");
+ copy_mem(m_fe, x.begin(), 10);
}
FE_25519(int64_t h0, int64_t h1, int64_t h2, int64_t h3, int64_t h4,
diff --git a/src/lib/stream/chacha/chacha_avx2/chacha_avx2.cpp b/src/lib/stream/chacha/chacha_avx2/chacha_avx2.cpp
index e9c3aeb75..8cd2eca7f 100644
--- a/src/lib/stream/chacha/chacha_avx2/chacha_avx2.cpp
+++ b/src/lib/stream/chacha/chacha_avx2/chacha_avx2.cpp
@@ -183,7 +183,6 @@ void ChaCha::chacha_avx2_x8(uint8_t output[64*8], uint32_t state[16], size_t rou
SIMD_8x32::transpose(R08, R09, R10, R11);
SIMD_8x32::transpose(R12, R13, R14, R15);
- memset(output, 0, 16*32);
__m256i* output_mm = reinterpret_cast<__m256i*>(output);
_mm256_storeu_si256(output_mm , _mm256_permute2x128_si256(R00.handle(), R04.handle(), 0 + (2 << 4)));
diff --git a/src/lib/utils/loadstor.h b/src/lib/utils/loadstor.h
index 2fb1543b0..579d05deb 100644
--- a/src/lib/utils/loadstor.h
+++ b/src/lib/utils/loadstor.h
@@ -140,7 +140,7 @@ inline uint16_t load_be<uint16_t>(const uint8_t in[], size_t off)
#if defined(BOTAN_ENDIAN_N2B)
uint16_t x;
- std::memcpy(&x, in, sizeof(x));
+ typecast_copy(x, in);
return BOTAN_ENDIAN_N2B(x);
#else
return make_uint16(in[0], in[1]);
@@ -160,7 +160,7 @@ inline uint16_t load_le<uint16_t>(const uint8_t in[], size_t off)
#if defined(BOTAN_ENDIAN_N2L)
uint16_t x;
- std::memcpy(&x, in, sizeof(x));
+ typecast_copy(x, in);
return BOTAN_ENDIAN_N2L(x);
#else
return make_uint16(in[1], in[0]);
@@ -179,7 +179,7 @@ inline uint32_t load_be<uint32_t>(const uint8_t in[], size_t off)
in += off * sizeof(uint32_t);
#if defined(BOTAN_ENDIAN_N2B)
uint32_t x;
- std::memcpy(&x, in, sizeof(x));
+ typecast_copy(x, in);
return BOTAN_ENDIAN_N2B(x);
#else
return make_uint32(in[0], in[1], in[2], in[3]);
@@ -198,7 +198,7 @@ inline uint32_t load_le<uint32_t>(const uint8_t in[], size_t off)
in += off * sizeof(uint32_t);
#if defined(BOTAN_ENDIAN_N2L)
uint32_t x;
- std::memcpy(&x, in, sizeof(x));
+ typecast_copy(x, in);
return BOTAN_ENDIAN_N2L(x);
#else
return make_uint32(in[3], in[2], in[1], in[0]);
@@ -217,7 +217,7 @@ inline uint64_t load_be<uint64_t>(const uint8_t in[], size_t off)
in += off * sizeof(uint64_t);
#if defined(BOTAN_ENDIAN_N2B)
uint64_t x;
- std::memcpy(&x, in, sizeof(x));
+ typecast_copy(x, in);
return BOTAN_ENDIAN_N2B(x);
#else
return make_uint64(in[0], in[1], in[2], in[3],
@@ -237,7 +237,7 @@ inline uint64_t load_le<uint64_t>(const uint8_t in[], size_t off)
in += off * sizeof(uint64_t);
#if defined(BOTAN_ENDIAN_N2L)
uint64_t x;
- std::memcpy(&x, in, sizeof(x));
+ typecast_copy(x, in);
return BOTAN_ENDIAN_N2L(x);
#else
return make_uint64(in[7], in[6], in[5], in[4],
@@ -317,9 +317,11 @@ inline void load_le(T out[],
if(count > 0)
{
#if defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN)
- std::memcpy(out, in, sizeof(T)*count);
+ typecast_copy(out, in, count);
+
#elif defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
- std::memcpy(out, in, sizeof(T)*count);
+ typecast_copy(out, in, count);
+
const size_t blocks = count - (count % 4);
const size_t left = count - blocks;
@@ -407,10 +409,10 @@ inline void load_be(T out[],
if(count > 0)
{
#if defined(BOTAN_TARGET_CPU_IS_BIG_ENDIAN)
- std::memcpy(out, in, sizeof(T)*count);
+ typecast_copy(out, in, count);
#elif defined(BOTAN_TARGET_CPU_IS_LITTLE_ENDIAN)
- std::memcpy(out, in, sizeof(T)*count);
+ typecast_copy(out, in, count);
const size_t blocks = count - (count % 4);
const size_t left = count - blocks;
@@ -435,7 +437,7 @@ inline void store_be(uint16_t in, uint8_t out[2])
{
#if defined(BOTAN_ENDIAN_N2B)
uint16_t o = BOTAN_ENDIAN_N2B(in);
- std::memcpy(out, &o, sizeof(o));
+ typecast_copy(out, o);
#else
out[0] = get_byte(0, in);
out[1] = get_byte(1, in);
@@ -451,7 +453,7 @@ inline void store_le(uint16_t in, uint8_t out[2])
{
#if defined(BOTAN_ENDIAN_N2L)
uint16_t o = BOTAN_ENDIAN_N2L(in);
- std::memcpy(out, &o, sizeof(o));
+ typecast_copy(out, o);
#else
out[0] = get_byte(1, in);
out[1] = get_byte(0, in);
@@ -467,7 +469,7 @@ inline void store_be(uint32_t in, uint8_t out[4])
{
#if defined(BOTAN_ENDIAN_B2N)
uint32_t o = BOTAN_ENDIAN_B2N(in);
- std::memcpy(out, &o, sizeof(o));
+ typecast_copy(out, o);
#else
out[0] = get_byte(0, in);
out[1] = get_byte(1, in);
@@ -485,7 +487,7 @@ inline void store_le(uint32_t in, uint8_t out[4])
{
#if defined(BOTAN_ENDIAN_L2N)
uint32_t o = BOTAN_ENDIAN_L2N(in);
- std::memcpy(out, &o, sizeof(o));
+ typecast_copy(out, o);
#else
out[0] = get_byte(3, in);
out[1] = get_byte(2, in);
@@ -503,7 +505,7 @@ inline void store_be(uint64_t in, uint8_t out[8])
{
#if defined(BOTAN_ENDIAN_B2N)
uint64_t o = BOTAN_ENDIAN_B2N(in);
- std::memcpy(out, &o, sizeof(o));
+ typecast_copy(out, o);
#else
out[0] = get_byte(0, in);
out[1] = get_byte(1, in);
@@ -525,7 +527,7 @@ inline void store_le(uint64_t in, uint8_t out[8])
{
#if defined(BOTAN_ENDIAN_L2N)
uint64_t o = BOTAN_ENDIAN_L2N(in);
- std::memcpy(out, &o, sizeof(o));
+ typecast_copy(out, o);
#else
out[0] = get_byte(7, in);
out[1] = get_byte(6, in);
diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h
index c59c02d5a..f0599c8b2 100644
--- a/src/lib/utils/mem_ops.h
+++ b/src/lib/utils/mem_ops.h
@@ -113,6 +113,21 @@ template<typename T> inline void copy_mem(T* out, const T* in, size_t n)
}
}
+template<typename T> inline void typecast_copy(uint8_t out[], T in)
+ {
+ std::memcpy(out, &in, sizeof(T));
+ }
+
+template<typename T> inline void typecast_copy(T& out, const uint8_t in[])
+ {
+ std::memcpy(&out, in, sizeof(T));
+ }
+
+template<typename T> inline void typecast_copy(T out[], const uint8_t in[], size_t N)
+ {
+ std::memcpy(out, in, sizeof(T)*N);
+ }
+
/**
* Set memory to a fixed value
* @param ptr a pointer to an array
@@ -178,15 +193,16 @@ inline void xor_buf(uint8_t out[],
while(length >= 16)
{
uint64_t x0, x1, y0, y1;
- std::memcpy(&x0, in, 8);
- std::memcpy(&x1, in + 8, 8);
- std::memcpy(&y0, out, 8);
- std::memcpy(&y1, out + 8, 8);
+
+ typecast_copy(x0, in);
+ typecast_copy(x1, in + 8);
+ typecast_copy(y0, out);
+ typecast_copy(y1, out + 8);
y0 ^= x0;
y1 ^= x1;
- std::memcpy(out, &y0, 8);
- std::memcpy(out + 8, &y1, 8);
+ typecast_copy(out, y0);
+ typecast_copy(out + 8, y1);
out += 16; in += 16; length -= 16;
}
@@ -214,15 +230,15 @@ inline void xor_buf(uint8_t out[],
while(length >= 16)
{
uint64_t x0, x1, y0, y1;
- std::memcpy(&x0, in, 8);
- std::memcpy(&x1, in + 8, 8);
- std::memcpy(&y0, in2, 8);
- std::memcpy(&y1, in2 + 8, 8);
+ typecast_copy(x0, in);
+ typecast_copy(x1, in + 8);
+ typecast_copy(y0, in2);
+ typecast_copy(y1, in2 + 8);
x0 ^= y0;
x1 ^= y1;
- std::memcpy(out, &x0, 8);
- std::memcpy(out + 8, &x1, 8);
+ typecast_copy(out, x0);
+ typecast_copy(out + 8, x1);
out += 16; in += 16; in2 += 16; length -= 16;
}
diff --git a/src/lib/utils/socket/socket.cpp b/src/lib/utils/socket/socket.cpp
index 1caeb2413..39ffc7951 100644
--- a/src/lib/utils/socket/socket.cpp
+++ b/src/lib/utils/socket/socket.cpp
@@ -207,7 +207,7 @@ class BSD_Socket final : public OS::Socket
m_socket = invalid_socket();
addrinfo hints;
- ::memset(&hints, 0, sizeof(addrinfo));
+ clear_mem(&hints, 1);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
addrinfo* res;
diff --git a/src/tests/test_block.cpp b/src/tests/test_block.cpp
index a53ff2633..ceda8ca07 100644
--- a/src/tests/test_block.cpp
+++ b/src/tests/test_block.cpp
@@ -137,7 +137,7 @@ class Block_Cipher_Tests final : public Text_Based_Test
// Now test misaligned buffers
const size_t blocks = input.size() / cipher->block_size();
buf.resize(input.size() + 1);
- std::memcpy(buf.data() + 1, input.data(), input.size());
+ Botan::copy_mem(buf.data() + 1, input.data(), input.size());
for(size_t i = 0; i != iterations; ++i)
{
@@ -149,7 +149,7 @@ class Block_Cipher_Tests final : public Text_Based_Test
expected.data(), expected.size());
// always decrypt expected ciphertext vs what we produced above
- std::memcpy(buf.data() + 1, expected.data(), expected.size());
+ Botan::copy_mem(buf.data() + 1, expected.data(), expected.size());
for(size_t i = 0; i != iterations; ++i)
{
diff --git a/src/tests/test_rng.h b/src/tests/test_rng.h
index 37501da2e..822536971 100644
--- a/src/tests/test_rng.h
+++ b/src/tests/test_rng.h
@@ -212,7 +212,12 @@ class Request_Counting_RNG final : public Botan::RandomNumberGenerator
void randomize(uint8_t out[], size_t out_len) override
{
- std::memset(out, 0x80, out_len);
+ /*
+ The HMAC_DRBG and ChaCha reseed KATs assume this RNG type
+ outputs all 0x80
+ */
+ for(size_t i = 0; i != out_len; ++i)
+ out[i] = 0x80;
m_randomize_count++;
}
diff --git a/src/tests/test_tls.cpp b/src/tests/test_tls.cpp
index af13a83b8..8a327b652 100644
--- a/src/tests/test_tls.cpp
+++ b/src/tests/test_tls.cpp
@@ -110,7 +110,8 @@ class TLS_CBC_Tests final : public Text_Based_Test
void final_result(uint8_t out[]) override
{
- std::memset(out, 0, m_mac_len);
+ for(size_t i = 0; i != m_mac_len; ++i)
+ out[i] = 0;
}
Botan::Key_Length_Specification key_spec() const override
@@ -133,12 +134,12 @@ class TLS_CBC_Tests final : public Text_Based_Test
void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
{
- std::memmove(out, in, blocks * m_bs);
+ Botan::copy_mem(out, in, blocks * m_bs);
}
void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
{
- std::memmove(out, in, blocks * m_bs);
+ Botan::copy_mem(out, in, blocks * m_bs);
}
size_t block_size() const override { return m_bs; }
diff --git a/src/tests/test_utils.cpp b/src/tests/test_utils.cpp
index b6eb4bbc7..7bbe3745c 100644
--- a/src/tests/test_utils.cpp
+++ b/src/tests/test_utils.cpp
@@ -843,7 +843,8 @@ class UUID_Tests : public Test
void randomize(uint8_t out[], size_t len) override
{
- std::memset(out, m_val, len);
+ for(size_t i = 0; i != len; ++i)
+ out[i] = m_val;
}
std::string name() const override { return "zeros"; }