aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-18 16:53:10 -0500
committerJack Lloyd <[email protected]>2016-12-18 16:53:25 -0500
commit5eca80aa3336dc49c721e9c6404f531f2e290537 (patch)
tree645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/tests
parentc1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff)
parentf3cb3edb512bdcab498d825886c3366c341b3f78 (diff)
Merge GH #771 Use cstdint integer types
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_aead.cpp10
-rw-r--r--src/tests/test_bigint.cpp10
-rw-r--r--src/tests/test_block.cpp2
-rw-r--r--src/tests/test_c25519.cpp2
-rw-r--r--src/tests/test_cryptobox.cpp6
-rw-r--r--src/tests/test_dlies.cpp6
-rw-r--r--src/tests/test_ecies.cpp41
-rw-r--r--src/tests/test_entropy.cpp4
-rw-r--r--src/tests/test_ffi.cpp8
-rw-r--r--src/tests/test_filters.cpp6
-rw-r--r--src/tests/test_keywrap.cpp6
-rw-r--r--src/tests/test_mceliece.cpp42
-rw-r--r--src/tests/test_modes.cpp2
-rw-r--r--src/tests/test_newhope.cpp8
-rw-r--r--src/tests/test_ocb.cpp24
-rw-r--r--src/tests/test_passhash.cpp6
-rw-r--r--src/tests/test_pbkdf.cpp2
-rw-r--r--src/tests/test_pk_pad.cpp2
-rw-r--r--src/tests/test_pkcs11_high_level.cpp34
-rw-r--r--src/tests/test_pkcs11_low_level.cpp54
-rw-r--r--src/tests/test_pubkey.cpp2
-rw-r--r--src/tests/test_rng.cpp32
-rw-r--r--src/tests/test_rng.h2
-rw-r--r--src/tests/test_srp6.cpp2
-rw-r--r--src/tests/test_tls_messages.cpp16
-rw-r--r--src/tests/test_tss.cpp4
-rw-r--r--src/tests/test_utils.cpp26
-rw-r--r--src/tests/test_xmss.cpp6
-rw-r--r--src/tests/tests.h6
-rw-r--r--src/tests/unit_ecc.cpp48
-rw-r--r--src/tests/unit_ecdsa.cpp28
-rw-r--r--src/tests/unit_tls.cpp22
-rw-r--r--src/tests/unit_x509.cpp4
33 files changed, 235 insertions, 238 deletions
diff --git a/src/tests/test_aead.cpp b/src/tests/test_aead.cpp
index ed94d75ba..18e4417a8 100644
--- a/src/tests/test_aead.cpp
+++ b/src/tests/test_aead.cpp
@@ -40,7 +40,7 @@ class AEAD_Tests : public Text_Based_Test
enc->set_ad(mutate_vec(ad));
enc->start(mutate_vec(nonce));
- Botan::secure_vector<byte> garbage = Test::rng().random_vec(enc->update_granularity());
+ Botan::secure_vector<uint8_t> garbage = Test::rng().random_vec(enc->update_granularity());
enc->update(garbage);
// reset message specific state
@@ -142,7 +142,7 @@ class AEAD_Tests : public Text_Based_Test
dec->set_ad(mutate_vec(ad));
dec->start(mutate_vec(nonce));
- Botan::secure_vector<byte> garbage = Test::rng().random_vec(dec->update_granularity());
+ Botan::secure_vector<uint8_t> garbage = Test::rng().random_vec(dec->update_granularity());
dec->update(garbage);
// reset message specific state
@@ -225,7 +225,7 @@ class AEAD_Tests : public Text_Based_Test
}
// test decryption with modified ciphertext
- const std::vector<byte> mutated_input = mutate_vec(input, true);
+ const std::vector<uint8_t> mutated_input = mutate_vec(input, true);
buf.assign(mutated_input.begin(), mutated_input.end());
dec->reset();
@@ -251,7 +251,7 @@ class AEAD_Tests : public Text_Based_Test
if(nonce.size() > 0)
{
buf.assign(input.begin(), input.end());
- std::vector<byte> bad_nonce = mutate_vec(nonce);
+ std::vector<uint8_t> bad_nonce = mutate_vec(nonce);
dec->reset();
dec->set_ad(ad);
@@ -273,7 +273,7 @@ class AEAD_Tests : public Text_Based_Test
}
// test decryption with modified associated_data
- const std::vector<byte> bad_ad = mutate_vec(ad, true);
+ const std::vector<uint8_t> bad_ad = mutate_vec(ad, true);
dec->reset();
dec->set_ad(bad_ad);
diff --git a/src/tests/test_bigint.cpp b/src/tests/test_bigint.cpp
index ad837cc91..9cadee998 100644
--- a/src/tests/test_bigint.cpp
+++ b/src/tests/test_bigint.cpp
@@ -152,12 +152,12 @@ class BigInt_Unit_Tests : public Test
const BigInt n1(0xffff);
const BigInt n2(1023);
- Botan::secure_vector<byte> encoded_n1 = BigInt::encode_1363(n1, 256);
- Botan::secure_vector<byte> encoded_n2 = BigInt::encode_1363(n2, 256);
- Botan::secure_vector<byte> expected = encoded_n1;
+ Botan::secure_vector<uint8_t> encoded_n1 = BigInt::encode_1363(n1, 256);
+ Botan::secure_vector<uint8_t> encoded_n2 = BigInt::encode_1363(n2, 256);
+ Botan::secure_vector<uint8_t> expected = encoded_n1;
expected += encoded_n2;
- Botan::secure_vector<byte> encoded_n1_n2 = BigInt::encode_fixed_length_int_pair(n1, n2, 256);
+ Botan::secure_vector<uint8_t> encoded_n1_n2 = BigInt::encode_fixed_length_int_pair(n1, n2, 256);
result.test_eq("encode_fixed_length_int_pair", encoded_n1_n2, expected);
for (size_t i = 0; i < 256 - n1.bytes(); ++i)
@@ -540,7 +540,7 @@ class DSA_ParamGen_Test : public Text_Based_Test
Test::Result run_one_test(const std::string& header, const VarMap& vars) override
{
- const std::vector<byte> seed = get_req_bin(vars, "Seed");
+ const std::vector<uint8_t> seed = get_req_bin(vars, "Seed");
const Botan::BigInt P = get_req_bn(vars, "P");
const Botan::BigInt Q = get_req_bn(vars, "Q");
diff --git a/src/tests/test_block.cpp b/src/tests/test_block.cpp
index 48d6230c3..91e171b09 100644
--- a/src/tests/test_block.cpp
+++ b/src/tests/test_block.cpp
@@ -49,7 +49,7 @@ class Block_Cipher_Tests : public Text_Based_Test
// Test to make sure clear() resets what we need it to
cipher->set_key(Test::rng().random_vec(cipher->key_spec().minimum_keylength()));
- Botan::secure_vector<byte> garbage = Test::rng().random_vec(cipher->block_size());
+ Botan::secure_vector<uint8_t> garbage = Test::rng().random_vec(cipher->block_size());
cipher->encrypt(garbage);
cipher->clear();
diff --git a/src/tests/test_c25519.cpp b/src/tests/test_c25519.cpp
index 48fd52b8b..25e053857 100644
--- a/src/tests/test_c25519.cpp
+++ b/src/tests/test_c25519.cpp
@@ -30,7 +30,7 @@ class Curve25519_Sclarmult_Tests : public Text_Based_Test
const std::vector<uint8_t> basepoint = get_req_bin(vars, "Basepoint");
const std::vector<uint8_t> expected = get_req_bin(vars, "Out");
- std::vector<byte> got(32);
+ std::vector<uint8_t> got(32);
Botan::curve25519_donna(got.data(), secret.data(), basepoint.data());
Test::Result result("Curve25519 scalarmult");
diff --git a/src/tests/test_cryptobox.cpp b/src/tests/test_cryptobox.cpp
index 4eb9cdcdb..ad9ecdd41 100644
--- a/src/tests/test_cryptobox.cpp
+++ b/src/tests/test_cryptobox.cpp
@@ -25,7 +25,7 @@ class Cryptobox_Tests : public Test
std::vector<Test::Result> results;
Test::Result result("cryptobox");
- const std::vector<byte> msg = Botan::hex_decode("AABBCC");
+ const std::vector<uint8_t> msg = Botan::hex_decode("AABBCC");
const std::string password = "secret";
std::string ciphertext = Botan::CryptoBox::encrypt(msg.data(), msg.size(),
@@ -36,9 +36,9 @@ class Cryptobox_Tests : public Test
{
std::string plaintext = Botan::CryptoBox::decrypt(ciphertext, password);
- const byte* pt_b = reinterpret_cast<const byte*>(plaintext.data());
+ const uint8_t* pt_b = reinterpret_cast<const uint8_t*>(plaintext.data());
- std::vector<byte> pt_vec(pt_b, pt_b + plaintext.size());
+ std::vector<uint8_t> pt_vec(pt_b, pt_b + plaintext.size());
result.test_eq("decrypt", pt_vec, msg);
}
diff --git a/src/tests/test_dlies.cpp b/src/tests/test_dlies.cpp
index 94b0caff2..ea7117a43 100644
--- a/src/tests/test_dlies.cpp
+++ b/src/tests/test_dlies.cpp
@@ -136,7 +136,7 @@ Test::Result test_xor()
Botan::DLIES_Encryptor encryptor(alice, Test::rng(), kdf->clone(), mac->clone(), mac_key_len);
// negative test: other pub key not set
- Botan::secure_vector<byte> plaintext = Test::rng().random_vec(32);
+ Botan::secure_vector<uint8_t> plaintext = Test::rng().random_vec(32);
result.test_throws("encrypt not possible without setting other public key", [&encryptor, &plaintext]()
{
@@ -144,14 +144,14 @@ Test::Result test_xor()
});
encryptor.set_other_key(bob.public_value());
- std::vector<byte> ciphertext = encryptor.encrypt(plaintext, Test::rng());
+ std::vector<uint8_t> ciphertext = encryptor.encrypt(plaintext, Test::rng());
Botan::DLIES_Decryptor decryptor(bob, Test::rng(), kdf->clone(), mac->clone(), mac_key_len);
// negative test: ciphertext too short
result.test_throws("ciphertext too short", [ &decryptor ]()
{
- decryptor.decrypt(std::vector<byte>(2));
+ decryptor.decrypt(std::vector<uint8_t>(2));
});
result.test_eq("decryption", decryptor.decrypt(ciphertext), plaintext);
diff --git a/src/tests/test_ecies.cpp b/src/tests/test_ecies.cpp
index 53775eda4..f900eccb0 100644
--- a/src/tests/test_ecies.cpp
+++ b/src/tests/test_ecies.cpp
@@ -19,7 +19,6 @@ namespace {
#if defined(BOTAN_HAS_ECIES)
-using byte = Botan::byte;
using Flags = Botan::ECIES_Flags;
Botan::PointGFp::Compression_Type get_compression_type(const std::string& format)
@@ -51,7 +50,7 @@ void check_encrypt_decrypt(Test::Result& result, const Botan::ECDH_PrivateKey& p
const Botan::ECDH_PrivateKey& other_private_key,
const Botan::ECIES_System_Params& ecies_params,
const Botan::InitializationVector& iv, const std::string& label,
- const std::vector<byte>& plaintext, const std::vector<byte>& ciphertext)
+ const std::vector<uint8_t>& plaintext, const std::vector<uint8_t>& ciphertext)
{
Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, Test::rng());
ecies_enc.set_other_key(other_private_key.public_point());
@@ -69,16 +68,16 @@ void check_encrypt_decrypt(Test::Result& result, const Botan::ECDH_PrivateKey& p
try
{
- const std::vector<byte> encrypted = ecies_enc.encrypt(plaintext, Test::rng());
+ const std::vector<uint8_t> encrypted = ecies_enc.encrypt(plaintext, Test::rng());
if(!ciphertext.empty())
{
result.test_eq("encrypted data", encrypted, ciphertext);
}
- const Botan::secure_vector<byte> decrypted = ecies_dec.decrypt(encrypted);
+ const Botan::secure_vector<uint8_t> decrypted = ecies_dec.decrypt(encrypted);
result.test_eq("decrypted data equals plaintext", decrypted, plaintext);
- std::vector<byte> invalid_encrypted = encrypted;
- byte& last_byte = invalid_encrypted[invalid_encrypted.size() - 1];
+ std::vector<uint8_t> invalid_encrypted = encrypted;
+ uint8_t& last_byte = invalid_encrypted[invalid_encrypted.size() - 1];
last_byte = ~last_byte;
result.test_throws("throw on invalid ciphertext", [&ecies_dec, &invalid_encrypted]
{
@@ -95,9 +94,9 @@ void check_encrypt_decrypt(Test::Result& result, const Botan::ECDH_PrivateKey& p
const Botan::ECDH_PrivateKey& other_private_key,
const Botan::ECIES_System_Params& ecies_params, size_t iv_length = 0)
{
- const std::vector<byte> plaintext { 1, 2, 3 };
- check_encrypt_decrypt(result, private_key, other_private_key, ecies_params, std::vector<byte>(iv_length, 0), "",
- plaintext, std::vector<byte>());
+ const std::vector<uint8_t> plaintext { 1, 2, 3 };
+ check_encrypt_decrypt(result, private_key, other_private_key, ecies_params, std::vector<uint8_t>(iv_length, 0), "",
+ plaintext, std::vector<uint8_t>());
}
#if defined(BOTAN_HAS_KDF1_18033) && defined(BOTAN_HAS_SHA1)
@@ -128,8 +127,8 @@ class ECIES_ISO_Tests : public Text_Based_Test
const Botan::BigInt hy = get_req_bn(vars, "hy"); // y of public point of bob
const Botan::BigInt x = get_req_bn(vars, "x"); // private key of bob
const Botan::BigInt r = get_req_bn(vars, "r"); // (ephemeral) private key of alice
- const std::vector<byte> c0 = get_req_bin(vars, "C0"); // expected encoded (ephemeral) public key
- const std::vector<byte> k = get_req_bin(vars, "K"); // expected derived secret
+ const std::vector<uint8_t> c0 = get_req_bin(vars, "C0"); // expected encoded (ephemeral) public key
+ const std::vector<uint8_t> k = get_req_bin(vars, "K"); // expected derived secret
const Botan::CurveGFp curve(p, a, b);
const Botan::EC_Group domain(curve, Botan::PointGFp(curve, gx, gy), mu, nu);
@@ -142,7 +141,7 @@ class ECIES_ISO_Tests : public Text_Based_Test
// (ephemeral) keys of alice
const Botan::ECDH_PrivateKey eph_private_key(Test::rng(), domain, r);
const Botan::PointGFp eph_public_key_point = eph_private_key.public_point();
- const std::vector<byte> eph_public_key_bin = Botan::unlock(
+ const std::vector<uint8_t> eph_public_key_bin = Botan::unlock(
Botan::EC2OSP(eph_public_key_point, compression_type));
result.test_eq("encoded (ephemeral) public key", eph_public_key_bin, c0);
@@ -220,7 +219,7 @@ class ECIES_Tests : public Text_Based_Test
const std::string kdf = get_req_str(vars, "Kdf");
const std::string dem = get_req_str(vars, "Dem");
const size_t dem_key_len = get_req_sz(vars, "DemKeyLen");
- const std::vector<byte> iv = get_req_bin(vars, "Iv");
+ const std::vector<uint8_t> iv = get_req_bin(vars, "Iv");
const std::string mac = get_req_str(vars, "Mac");
const size_t mac_key_len = get_req_sz(vars, "MacKeyLen");
const Botan::PointGFp::Compression_Type compression_type = get_compression_type(get_req_str(vars, "Format"));
@@ -229,8 +228,8 @@ class ECIES_Tests : public Text_Based_Test
const bool check_mode = get_req_sz(vars, "CheckMode") != 0;
const bool single_hash_mode = get_req_sz(vars, "SingleHashMode") != 0;
const std::string label = get_req_str(vars, "Label");
- const std::vector<byte> plaintext = get_req_bin(vars, "Plaintext");
- const std::vector<byte> ciphertext = get_req_bin(vars, "Ciphertext");
+ const std::vector<uint8_t> plaintext = get_req_bin(vars, "Plaintext");
+ const std::vector<uint8_t> ciphertext = get_req_bin(vars, "Ciphertext");
const Flags flags = ecies_flags(cofactor_mode, old_cofactor_mode, check_mode, single_hash_mode);
const Botan::EC_Group domain(curve);
@@ -269,7 +268,7 @@ Test::Result test_other_key_not_set()
result.test_throws("encrypt not possible without setting other public key", [ &ecies_enc ]()
{
- ecies_enc.encrypt(std::vector<byte>(8), Test::rng());
+ ecies_enc.encrypt(std::vector<uint8_t>(8), Test::rng());
});
return result;
@@ -294,7 +293,7 @@ Test::Result test_kdf_not_found()
result.test_throws("kdf not found", [ &ecies_enc ]()
{
- ecies_enc.encrypt(std::vector<byte>(8), Test::rng());
+ ecies_enc.encrypt(std::vector<uint8_t>(8), Test::rng());
});
return result;
@@ -319,7 +318,7 @@ Test::Result test_mac_not_found()
result.test_throws("mac not found", [ &ecies_enc ]()
{
- ecies_enc.encrypt(std::vector<byte>(8), Test::rng());
+ ecies_enc.encrypt(std::vector<uint8_t>(8), Test::rng());
});
return result;
@@ -344,7 +343,7 @@ Test::Result test_cipher_not_found()
result.test_throws("cipher not found", [ &ecies_enc ]()
{
- ecies_enc.encrypt(std::vector<byte>(8), Test::rng());
+ ecies_enc.encrypt(std::vector<uint8_t>(8), Test::rng());
});
return result;
@@ -372,10 +371,10 @@ Test::Result test_system_params_short_ctor()
const Botan::InitializationVector iv("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
const std::string label = "Test";
- const std::vector<byte> plaintext = Botan::hex_decode("000102030405060708090A0B0C0D0E0F");
+ const std::vector<uint8_t> plaintext = Botan::hex_decode("000102030405060708090A0B0C0D0E0F");
// generated with botan
- const std::vector<byte> ciphertext = Botan::hex_decode("0401519EAA0489FF9D51E98E4C22349463E2001CD06F8CE47D81D4007A"
+ const std::vector<uint8_t> ciphertext = Botan::hex_decode("0401519EAA0489FF9D51E98E4C22349463E2001CD06F8CE47D81D4007A"
"79ACF98E92C814686477CEA666EFC277DC84E15FC95E38AFF8E16D478A"
"44CD5C5F1517F8B1F300000591317F261C3D04A7207F01EAE3EC70F2360"
"0F82C53CC0B85BE7AC9F6CE79EF2AB416E5934D61BA9D346385D7545C57F"
diff --git a/src/tests/test_entropy.cpp b/src/tests/test_entropy.cpp
index 9fe788ed4..0fc757612 100644
--- a/src/tests/test_entropy.cpp
+++ b/src/tests/test_entropy.cpp
@@ -66,7 +66,7 @@ class Entropy_Source_Tests : public Test
try
{
- Botan::secure_vector<byte> compressed;
+ Botan::secure_vector<uint8_t> compressed;
compressed.assign(rng.seed_material().begin(), rng.seed_material().end());
comp->start(9);
comp->finish(compressed);
@@ -89,7 +89,7 @@ class Entropy_Source_Tests : public Test
try
{
- Botan::secure_vector<byte> compressed;
+ Botan::secure_vector<uint8_t> compressed;
compressed.insert(compressed.end(), rng.seed_material().begin(), rng.seed_material().end());
compressed.insert(compressed.end(), rng2.seed_material().begin(), rng2.seed_material().end());
diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp
index 26c76789f..dd066e248 100644
--- a/src/tests/test_ffi.cpp
+++ b/src/tests/test_ffi.cpp
@@ -144,7 +144,7 @@ class FFI_Unit_Tests : public Test
{
result.test_eq("MAC output length", output_len, 32);
- const byte mac_key[] = { 0xAA, 0xBB, 0xCC, 0xDD };
+ const uint8_t mac_key[] = { 0xAA, 0xBB, 0xCC, 0xDD };
outbuf.resize(output_len);
// Test that after clear or final the object can be reused
@@ -684,12 +684,12 @@ class FFI_Unit_Tests : public Test
result.test_eq("algo name", std::string(namebuf), "McEliece");
}
- size_t i = 0;
+ const uint64_t zero_seq = 0;
uint8_t ad[8];
- Botan::store_be(static_cast<Botan::u64bit>(i), ad);
+ Botan::store_be(zero_seq, ad);
const size_t ad_len = sizeof(ad);
- const Botan::secure_vector<byte> plaintext = Test::rng().random_vec(Test::rng().next_byte());
+ const Botan::secure_vector<uint8_t> plaintext = Test::rng().random_vec(Test::rng().next_byte());
size_t plaintext_len = plaintext.size();
size_t ciphertext_len = 0;
diff --git a/src/tests/test_filters.cpp b/src/tests/test_filters.cpp
index 6ce83ccba..b3decb5e2 100644
--- a/src/tests/test_filters.cpp
+++ b/src/tests/test_filters.cpp
@@ -138,7 +138,7 @@ class Filter_Tests : public Test
#if defined(BOTAN_HAS_CRC32)
pipe.prepend(new Botan::Hash_Filter("CRC32"));
pipe.append(new Botan::Hash_Filter("CRC32"));
- pipe.process_msg(std::vector<byte>(1024, 0));
+ pipe.process_msg(std::vector<uint8_t>(1024, 0));
result.test_eq("Expected CRC32d", pipe.read_all(1), "99841F60");
#endif
@@ -171,13 +171,13 @@ class Filter_Tests : public Test
dec_cipher->set_iv(Botan::InitializationVector("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB"));
cipher->set_iv(Botan::InitializationVector("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB"));
- const std::vector<byte> zeros_in(1024);
+ const std::vector<uint8_t> zeros_in(1024);
Botan::DataSource_Memory src(zeros_in);
pipe.start_msg();
pipe.write(src);
pipe.end_msg();
- Botan::secure_vector<byte> zeros_out = pipe.read_all(1);
+ Botan::secure_vector<uint8_t> zeros_out = pipe.read_all(1);
result.test_eq("Cipher roundtrip", zeros_in, zeros_out);
return result;
diff --git a/src/tests/test_keywrap.cpp b/src/tests/test_keywrap.cpp
index f000a8be7..cdc4b2b67 100644
--- a/src/tests/test_keywrap.cpp
+++ b/src/tests/test_keywrap.cpp
@@ -30,9 +30,9 @@ class RFC3394_Keywrap_Tests : public Text_Based_Test
try
{
- const std::vector<byte> expected = get_req_bin(vars, "Output");
- const std::vector<byte> key = get_req_bin(vars, "Key");
- const std::vector<byte> kek = get_req_bin(vars, "KEK");
+ const std::vector<uint8_t> expected = get_req_bin(vars, "Output");
+ const std::vector<uint8_t> key = get_req_bin(vars, "Key");
+ const std::vector<uint8_t> kek = get_req_bin(vars, "KEK");
const Botan::SymmetricKey kek_sym(kek);
const Botan::secure_vector<uint8_t> key_l(key.begin(), key.end());
diff --git a/src/tests/test_mceliece.cpp b/src/tests/test_mceliece.cpp
index 693d7d2c1..05a7448ff 100644
--- a/src/tests/test_mceliece.cpp
+++ b/src/tests/test_mceliece.cpp
@@ -47,12 +47,12 @@ class McEliece_Keygen_Encrypt_Test : public Text_Based_Test
Test::Result run_one_test(const std::string&, const VarMap& vars) override
{
- const std::vector<byte> keygen_seed = get_req_bin(vars, "McElieceSeed");
- const std::vector<byte> fprint_pub = get_req_bin(vars, "PublicKeyFingerprint");
- const std::vector<byte> fprint_priv = get_req_bin(vars, "PrivateKeyFingerprint");
- const std::vector<byte> encrypt_seed = get_req_bin(vars, "EncryptPRNGSeed");
- const std::vector<byte> ciphertext = get_req_bin(vars, "Ciphertext");
- const std::vector<byte> shared_key = get_req_bin(vars, "SharedKey");
+ const std::vector<uint8_t> keygen_seed = get_req_bin(vars, "McElieceSeed");
+ const std::vector<uint8_t> fprint_pub = get_req_bin(vars, "PublicKeyFingerprint");
+ const std::vector<uint8_t> fprint_priv = get_req_bin(vars, "PrivateKeyFingerprint");
+ const std::vector<uint8_t> encrypt_seed = get_req_bin(vars, "EncryptPRNGSeed");
+ const std::vector<uint8_t> ciphertext = get_req_bin(vars, "Ciphertext");
+ const std::vector<uint8_t> shared_key = get_req_bin(vars, "SharedKey");
const size_t keygen_n = get_req_sz(vars, "KeyN");
const size_t keygen_t = get_req_sz(vars, "KeyT");
@@ -73,10 +73,10 @@ class McEliece_Keygen_Encrypt_Test : public Text_Based_Test
Botan::PK_KEM_Encryptor kem_enc(mce_priv, Test::rng(), "KDF1(SHA-512)");
Botan::PK_KEM_Decryptor kem_dec(mce_priv, Test::rng(), "KDF1(SHA-512)");
- Botan::secure_vector<byte> encap_key, prod_shared_key;
+ Botan::secure_vector<uint8_t> encap_key, prod_shared_key;
kem_enc.encrypt(encap_key, prod_shared_key, 64, rng);
- Botan::secure_vector<byte> dec_shared_key = kem_dec.decrypt(encap_key.data(), encap_key.size(), 64);
+ Botan::secure_vector<uint8_t> dec_shared_key = kem_dec.decrypt(encap_key.data(), encap_key.size(), 64);
result.test_eq("ciphertext", encap_key, ciphertext);
result.test_eq("encrypt shared", prod_shared_key, shared_key);
@@ -90,17 +90,17 @@ class McEliece_Keygen_Encrypt_Test : public Text_Based_Test
}
private:
- std::vector<byte> hash_bytes(const byte b[], size_t len, const std::string& hash_fn = "SHA-256")
+ std::vector<uint8_t> hash_bytes(const uint8_t b[], size_t len, const std::string& hash_fn = "SHA-256")
{
std::unique_ptr<Botan::HashFunction> hash(Botan::HashFunction::create(hash_fn));
hash->update(b, len);
- std::vector<byte> r(hash->output_length());
+ std::vector<uint8_t> r(hash->output_length());
hash->final(r.data());
return r;
}
template<typename A>
- std::vector<byte> hash_bytes(const std::vector<byte, A>& v)
+ std::vector<uint8_t> hash_bytes(const std::vector<uint8_t, A>& v)
{
return hash_bytes(v.data(), v.size());
}
@@ -153,8 +153,8 @@ class McEliece_Tests : public Test
Botan::McEliece_PrivateKey sk1(Test::rng(), param_sets[i].code_length, t);
const Botan::McEliece_PublicKey& pk1 = sk1;
- const std::vector<byte> pk_enc = pk1.public_key_bits();
- const Botan::secure_vector<byte> sk_enc = sk1.private_key_bits();
+ const std::vector<uint8_t> pk_enc = pk1.public_key_bits();
+ const Botan::secure_vector<uint8_t> sk_enc = sk1.private_key_bits();
Botan::McEliece_PublicKey pk(pk_enc);
Botan::McEliece_PrivateKey sk(sk_enc);
@@ -191,12 +191,12 @@ class McEliece_Tests : public Test
for(size_t i = 0; i <= Test::soak_level(); i++)
{
- Botan::secure_vector<byte> salt = Test::rng().random_vec(i);
+ Botan::secure_vector<uint8_t> salt = Test::rng().random_vec(i);
- Botan::secure_vector<byte> encap_key, shared_key;
+ Botan::secure_vector<uint8_t> encap_key, shared_key;
enc_op.encrypt(encap_key, shared_key, 64, Test::rng(), salt);
- Botan::secure_vector<byte> shared_key2 = dec_op.decrypt(encap_key, 64, salt);
+ Botan::secure_vector<uint8_t> shared_key2 = dec_op.decrypt(encap_key, 64, salt);
result.test_eq("same key", shared_key, shared_key2);
}
@@ -212,17 +212,17 @@ class McEliece_Tests : public Test
for(size_t i = 0; i <= Test::soak_level(); ++i)
{
uint8_t ad[8];
- Botan::store_be(static_cast<Botan::u64bit>(i), ad);
+ Botan::store_be(static_cast<uint64_t>(i), ad);
const size_t ad_len = sizeof(ad);
- const Botan::secure_vector<byte> pt = Test::rng().random_vec(Test::rng().next_byte());
+ const Botan::secure_vector<uint8_t> pt = Test::rng().random_vec(Test::rng().next_byte());
- const Botan::secure_vector<byte> ct = mceies_encrypt(pk, pt.data(), pt.size(), ad, ad_len, Test::rng());
- const Botan::secure_vector<byte> dec = mceies_decrypt(sk, ct.data(), ct.size(), ad, ad_len);
+ const Botan::secure_vector<uint8_t> ct = mceies_encrypt(pk, pt.data(), pt.size(), ad, ad_len, Test::rng());
+ const Botan::secure_vector<uint8_t> dec = mceies_decrypt(sk, ct.data(), ct.size(), ad, ad_len);
result.test_eq("decrypted ok", dec, pt);
- Botan::secure_vector<byte> bad_ct = ct;
+ Botan::secure_vector<uint8_t> bad_ct = ct;
for(size_t j = 0; j != 3; ++j)
{
bad_ct = mutate_vec(ct, true);
diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp
index 174b2b17e..3926cd4d5 100644
--- a/src/tests/test_modes.cpp
+++ b/src/tests/test_modes.cpp
@@ -47,7 +47,7 @@ class Cipher_Mode_Tests : public Text_Based_Test
// Test to make sure reset() resets what we need it to
enc->set_key(mutate_vec(key));
- Botan::secure_vector<byte> garbage = Test::rng().random_vec(enc->update_granularity());
+ Botan::secure_vector<uint8_t> garbage = Test::rng().random_vec(enc->update_granularity());
enc->start(mutate_vec(nonce));
enc->update(garbage);
diff --git a/src/tests/test_newhope.cpp b/src/tests/test_newhope.cpp
index 95641bcaa..3d470597c 100644
--- a/src/tests/test_newhope.cpp
+++ b/src/tests/test_newhope.cpp
@@ -23,7 +23,7 @@ class NEWHOPE_RNG : public Botan::RandomNumberGenerator
std::string name() const override { return "NEWHOPE_RNG"; }
void clear() override { /* ignored */ }
- void randomize(byte out[], size_t len) override
+ void randomize(uint8_t out[], size_t len) override
{
if(m_first.size() == len)
{
@@ -44,7 +44,7 @@ class NEWHOPE_RNG : public Botan::RandomNumberGenerator
m_calls += 1;
- byte nonce[8] = { 0 };
+ uint8_t nonce[8] = { 0 };
if(m_calls < 3)
{
@@ -60,7 +60,7 @@ class NEWHOPE_RNG : public Botan::RandomNumberGenerator
bool is_seeded() const override { return true; }
- void add_entropy(const byte[], size_t) override { /* ignored */ }
+ void add_entropy(const uint8_t[], size_t) override { /* ignored */ }
NEWHOPE_RNG(const std::vector<uint8_t>& seed)
{
@@ -83,7 +83,7 @@ class NEWHOPE_RNG : public Botan::RandomNumberGenerator
private:
Botan::ChaCha m_chacha;
std::vector<uint8_t> m_first;
- byte m_calls = 0;
+ uint8_t m_calls = 0;
};
class NEWHOPE_Tests : public Text_Based_Test
diff --git a/src/tests/test_ocb.cpp b/src/tests/test_ocb.cpp
index 0e2dcda05..b9195a4e6 100644
--- a/src/tests/test_ocb.cpp
+++ b/src/tests/test_ocb.cpp
@@ -27,7 +27,7 @@ class OCB_Long_KAT_Tests : public Text_Based_Test
{
const size_t keylen = get_req_sz(vars, "Keylen");
const size_t taglen = get_req_sz(vars, "Taglen");
- const std::vector<byte> expected = get_req_bin(vars, "Output");
+ const std::vector<uint8_t> expected = get_req_bin(vars, "Output");
// Test from RFC 7253 Appendix A
@@ -45,19 +45,19 @@ class OCB_Long_KAT_Tests : public Text_Based_Test
Botan::OCB_Encryption enc(aes->clone(), taglen / 8);
Botan::OCB_Decryption dec(aes->clone(), taglen / 8);
- std::vector<byte> key(keylen/8);
+ std::vector<uint8_t> key(keylen/8);
key[keylen/8-1] = taglen;
enc.set_key(key);
dec.set_key(key);
- const std::vector<byte> empty;
- std::vector<byte> N(12);
- std::vector<byte> C;
+ const std::vector<uint8_t> empty;
+ std::vector<uint8_t> N(12);
+ std::vector<uint8_t> C;
for(size_t i = 0; i != 128; ++i)
{
- const std::vector<byte> S(i);
+ const std::vector<uint8_t> S(i);
Botan::store_be(static_cast<uint32_t>(3*i+1), &N[8]);
@@ -69,7 +69,7 @@ class OCB_Long_KAT_Tests : public Text_Based_Test
}
Botan::store_be(static_cast<uint32_t>(385), &N[8]);
- std::vector<byte> final_result;
+ std::vector<uint8_t> final_result;
ocb_encrypt(result, final_result, enc, dec, N, empty, C);
result.test_eq("correct value", final_result, expected);
@@ -78,18 +78,18 @@ class OCB_Long_KAT_Tests : public Text_Based_Test
}
private:
void ocb_encrypt(Test::Result& result,
- std::vector<byte>& output_to,
+ std::vector<uint8_t>& output_to,
Botan::OCB_Encryption& enc,
Botan::OCB_Decryption& dec,
- const std::vector<byte>& nonce,
- const std::vector<byte>& pt,
- const std::vector<byte>& ad)
+ const std::vector<uint8_t>& nonce,
+ const std::vector<uint8_t>& pt,
+ const std::vector<uint8_t>& ad)
{
enc.set_associated_data(ad.data(), ad.size());
enc.start(nonce.data(), nonce.size());
- Botan::secure_vector<byte> buf(pt.begin(), pt.end());
+ Botan::secure_vector<uint8_t> buf(pt.begin(), pt.end());
enc.finish(buf, 0);
output_to.insert(output_to.end(), buf.begin(), buf.end());
diff --git a/src/tests/test_passhash.cpp b/src/tests/test_passhash.cpp
index b8d8bea47..a77fe6532 100644
--- a/src/tests/test_passhash.cpp
+++ b/src/tests/test_passhash.cpp
@@ -27,7 +27,7 @@ class Bcrypt_Tests : public Text_Based_Test
Test::Result run_one_test(const std::string&, const VarMap& vars) override
{
// Encoded as binary so we can test binary inputs
- const std::vector<byte> password_vec = get_req_bin(vars, "Password");
+ const std::vector<uint8_t> password_vec = get_req_bin(vars, "Password");
const std::string password(reinterpret_cast<const char*>(password_vec.data()),
password_vec.size());
@@ -61,7 +61,7 @@ class Passhash9_Tests : public Text_Based_Test
Test::Result run_one_test(const std::string&, const VarMap& vars) override
{
// Encoded as binary so we can test binary inputs
- const std::vector<byte> password_vec = get_req_bin(vars, "Password");
+ const std::vector<uint8_t> password_vec = get_req_bin(vars, "Password");
const std::string password(reinterpret_cast<const char*>(password_vec.data()),
password_vec.size());
@@ -70,7 +70,7 @@ class Passhash9_Tests : public Text_Based_Test
Test::Result result("passhash9");
result.test_eq("correct hash accepted", Botan::check_passhash9(password, passhash), true);
- for(byte alg_id = 0; alg_id <= 4; ++alg_id)
+ for(uint8_t alg_id = 0; alg_id <= 4; ++alg_id)
{
const std::string gen_hash = Botan::generate_passhash9(password, Test::rng(), 2, alg_id);
diff --git a/src/tests/test_pbkdf.cpp b/src/tests/test_pbkdf.cpp
index af2cdd498..0ff502a9a 100644
--- a/src/tests/test_pbkdf.cpp
+++ b/src/tests/test_pbkdf.cpp
@@ -41,7 +41,7 @@ class PBKDF_KAT_Tests : public Text_Based_Test
result.test_eq("Expected name", pbkdf->name(), pbkdf_name);
- const Botan::secure_vector<byte> derived =
+ const Botan::secure_vector<uint8_t> derived =
pbkdf->derive_key(outlen, passphrase, salt.data(), salt.size(), iterations).bits_of();
result.test_eq("derived key", derived, expected);
diff --git a/src/tests/test_pk_pad.cpp b/src/tests/test_pk_pad.cpp
index 85bd53846..d237b7561 100644
--- a/src/tests/test_pk_pad.cpp
+++ b/src/tests/test_pk_pad.cpp
@@ -47,7 +47,7 @@ class EME_Decoding_Tests : public Text_Based_Test
result.test_eq("Plaintext value is empty for invalid EME inputs", plaintext.size(), 0);
uint8_t valid_mask = 0;
- Botan::secure_vector<byte> decoded =
+ Botan::secure_vector<uint8_t> decoded =
eme->unpad(valid_mask, ciphertext.data(), ciphertext.size());
result.confirm("EME valid_mask has expected value", valid_mask == 0x00 || valid_mask == 0xFF);
diff --git a/src/tests/test_pkcs11_high_level.cpp b/src/tests/test_pkcs11_high_level.cpp
index cf3fdac62..b82dbdca7 100644
--- a/src/tests/test_pkcs11_high_level.cpp
+++ b/src/tests/test_pkcs11_high_level.cpp
@@ -404,7 +404,7 @@ Test::Result test_attribute_container()
std::string label("test");
attributes.add_string(AttributeType::Label, label);
- std::vector<byte> bin(4);
+ std::vector<uint8_t> bin(4);
attributes.add_binary(AttributeType::Value, bin);
attributes.add_bool(AttributeType::Sensitive, true);
@@ -423,7 +423,7 @@ Test::Result test_create_destroy_data_object()
TestSession test_session(true);
std::string value_string("test data");
- secure_vector<byte> value(value_string.begin(), value_string.end());
+ secure_vector<uint8_t> value(value_string.begin(), value_string.end());
std::size_t id = 1337;
std::string label = "Botan test data object";
@@ -453,7 +453,7 @@ Test::Result test_get_set_attribute_values()
// create object
std::string value_string("test data");
- secure_vector<byte> value(value_string.begin(), value_string.end());
+ secure_vector<uint8_t> value(value_string.begin(), value_string.end());
std::size_t id = 1337;
std::string label = "Botan test data object";
@@ -468,13 +468,13 @@ Test::Result test_get_set_attribute_values()
Object data_obj(test_session.session(), data_obj_props);
// get attribute
- secure_vector<byte> retrieved_label = data_obj.get_attribute_value(AttributeType::Label);
+ secure_vector<uint8_t> retrieved_label = data_obj.get_attribute_value(AttributeType::Label);
std::string retrieved_label_string(retrieved_label.begin(), retrieved_label.end());
result.test_eq("label was set correctly", retrieved_label_string, label);
// set attribute
std::string new_label = "Botan test modified data object label";
- secure_vector<byte> new_label_secvec(new_label.begin(), new_label.end());
+ secure_vector<uint8_t> new_label_secvec(new_label.begin(), new_label.end());
data_obj.set_attribute_value(AttributeType::Label, new_label_secvec);
// get and check attribute
@@ -494,7 +494,7 @@ Test::Result test_object_finder()
// create object
std::string value_string("test data");
- secure_vector<byte> value(value_string.begin(), value_string.end());
+ secure_vector<uint8_t> value(value_string.begin(), value_string.end());
std::size_t id = 1337;
std::string label = "Botan test data object";
@@ -537,7 +537,7 @@ Test::Result test_object_copy()
// create object
std::string value_string("test data");
- secure_vector<byte> value(value_string.begin(), value_string.end());
+ secure_vector<uint8_t> value(value_string.begin(), value_string.end());
std::size_t id = 1337;
std::string label = "Botan test data object";
@@ -747,7 +747,7 @@ Test::Result test_rsa_encrypt_decrypt()
// generate key pair
PKCS11_RSA_KeyPair keypair = generate_rsa_keypair(test_session);
- auto encrypt_and_decrypt = [&keypair, &result](const std::vector<byte>& plaintext, const std::string& padding) -> void
+ auto encrypt_and_decrypt = [&keypair, &result](const std::vector<uint8_t>& plaintext, const std::string& padding) -> void
{
Botan::PK_Encryptor_EME encryptor(keypair.first, Test::rng(), padding, "pkcs11");
auto encrypted = encryptor.encrypt(plaintext, Test::rng());
@@ -761,7 +761,7 @@ Test::Result test_rsa_encrypt_decrypt()
result.test_eq("RSA PKCS11 encrypt and decrypt: " + padding, decrypted, plaintext);
};
- std::vector<byte> plaintext(256);
+ std::vector<uint8_t> plaintext(256);
std::iota(std::begin(plaintext), std::end(plaintext), 0);
encrypt_and_decrypt(plaintext, "Raw");
@@ -784,13 +784,13 @@ Test::Result test_rsa_sign_verify()
// generate key pair
PKCS11_RSA_KeyPair keypair = generate_rsa_keypair(test_session);
- std::vector<byte> plaintext(256);
+ std::vector<uint8_t> plaintext(256);
std::iota(std::begin(plaintext), std::end(plaintext), 0);
auto sign_and_verify = [&keypair, &plaintext, &result](const std::string& emsa, bool multipart) -> void
{
Botan::PK_Signer signer(keypair.second, Test::rng(), emsa, Botan::IEEE_1363, "pkcs11");
- std::vector<byte> signature;
+ std::vector<uint8_t> signature;
if ( multipart )
{
signer.update(plaintext.data(), plaintext.size() / 2);
@@ -1046,7 +1046,7 @@ Test::Result test_ecdsa_sign_verify()
// generate key pair
PKCS11_ECDSA_KeyPair keypair = generate_ecdsa_keypair(test_session);
- std::vector<byte> plaintext(20, 0x01);
+ std::vector<uint8_t> plaintext(20, 0x01);
auto sign_and_verify = [ &keypair, &plaintext, &result ](const std::string& emsa) -> void
{
@@ -1331,9 +1331,9 @@ Test::Result test_rng_generate_random()
PKCS11_RNG rng(test_session.session());
result.confirm("RNG already seeded", rng.is_seeded());
- std::vector<byte> random(20);
+ std::vector<uint8_t> random(20);
rng.randomize(random.data(), random.size());
- result.test_ne("random data generated", random, std::vector<byte>(20));
+ result.test_ne("random data generated", random, std::vector<uint8_t>(20));
return result;
}
@@ -1364,15 +1364,15 @@ Test::Result test_pkcs11_hmac_drbg()
// result.test_success("HMAC_DRBG(HMAC(SHA512)) instantiated with PKCS11_RNG");
result.test_eq("HMAC_DRBG is not seeded yet.", drbg.is_seeded(), false);
- secure_vector<byte> rnd = drbg.random_vec(64);
+ secure_vector<uint8_t> rnd = drbg.random_vec(64);
result.test_eq("HMAC_DRBG is seeded now", drbg.is_seeded(), true);
std::string personalization_string = "Botan PKCS#11 Tests";
- std::vector<byte> personalization_data(personalization_string.begin(), personalization_string.end());
+ std::vector<uint8_t> personalization_data(personalization_string.begin(), personalization_string.end());
drbg.add_entropy(personalization_data.data(), personalization_data.size());
auto rnd_vec = drbg.random_vec(256);
- result.test_ne("HMAC_DRBG generated a random vector", rnd_vec, std::vector<byte>(256));
+ result.test_ne("HMAC_DRBG generated a random vector", rnd_vec, std::vector<uint8_t>(256));
return result;
}
diff --git a/src/tests/test_pkcs11_low_level.cpp b/src/tests/test_pkcs11_low_level.cpp
index 7b18f6f8b..feb490cd4 100644
--- a/src/tests/test_pkcs11_low_level.cpp
+++ b/src/tests/test_pkcs11_low_level.cpp
@@ -112,7 +112,7 @@ class RAII_LowLevel
m_is_session_open = false;
}
- inline void login(UserType user_type, const secure_vector<byte>& pin)
+ inline void login(UserType user_type, const secure_vector<uint8_t>& pin)
{
if(!m_is_session_open)
{
@@ -395,8 +395,8 @@ Test::Result test_c_init_token()
const std::string label = "Botan PKCS#11 tests";
auto sec_vec_binder = std::bind(
- static_cast< bool (LowLevel::*)(SlotId, const secure_vector<byte>&, const std::string&, ReturnValue*) const>
- (&LowLevel::C_InitToken<secure_allocator<byte>>), *p11_low_level.get(), slot_vec.at(0), std::ref(SO_PIN_SECVEC),
+ static_cast< bool (LowLevel::*)(SlotId, const secure_vector<uint8_t>&, const std::string&, ReturnValue*) const>
+ (&LowLevel::C_InitToken<secure_allocator<uint8_t>>), *p11_low_level.get(), slot_vec.at(0), std::ref(SO_PIN_SECVEC),
std::ref(label), std::placeholders::_1);
return test_function("C_InitToken", sec_vec_binder);
@@ -493,11 +493,11 @@ Test::Result test_c_get_session_info()
Test::Result login_logout_helper(const RAII_LowLevel& p11_low_level, SessionHandle handle, UserType user_type,
const std::string& pin)
{
- secure_vector<byte> pin_as_sec_vec(pin.begin(), pin.end());
+ secure_vector<uint8_t> pin_as_sec_vec(pin.begin(), pin.end());
auto login_secvec_binder = std::bind(static_cast< bool (LowLevel::*)(SessionHandle, UserType,
- const secure_vector<byte>&, ReturnValue*) const>
- (&LowLevel::C_Login<secure_allocator<byte>>), *p11_low_level.get(),
+ const secure_vector<uint8_t>&, ReturnValue*) const>
+ (&LowLevel::C_Login<secure_allocator<uint8_t>>), *p11_low_level.get(),
handle, user_type, std::ref(pin_as_sec_vec), std::placeholders::_1);
auto logout_binder = std::bind(static_cast< bool (LowLevel::*)(SessionHandle, ReturnValue*) const>
@@ -547,8 +547,8 @@ Test::Result test_c_init_pin()
p11_low_level.login(UserType::SO, SO_PIN_SECVEC);
auto sec_vec_binder = std::bind(
- static_cast< bool (LowLevel::*)(SessionHandle, const secure_vector<byte>&, ReturnValue*) const>
- (&LowLevel::C_InitPIN<secure_allocator<byte>>), *p11_low_level.get(), session_handle, std::ref(PIN_SECVEC),
+ static_cast< bool (LowLevel::*)(SessionHandle, const secure_vector<uint8_t>&, ReturnValue*) const>
+ (&LowLevel::C_InitPIN<secure_allocator<uint8_t>>), *p11_low_level.get(), session_handle, std::ref(PIN_SECVEC),
std::placeholders::_1);
return test_function("C_InitPIN", sec_vec_binder);
@@ -564,17 +564,17 @@ Test::Result test_c_set_pin()
// now we are in "R / W Public Session" state: this will change the pin of the user
- auto get_pin_bind = [ &session_handle, &p11_low_level ](const secure_vector<byte>& old_pin,
- const secure_vector<byte>& new_pin) -> PKCS11_BoundTestFunction
+ auto get_pin_bind = [ &session_handle, &p11_low_level ](const secure_vector<uint8_t>& old_pin,
+ const secure_vector<uint8_t>& new_pin) -> PKCS11_BoundTestFunction
{
- return std::bind(static_cast< bool (LowLevel::*)(SessionHandle, const secure_vector<byte>&,
- const secure_vector<byte>&, ReturnValue*) const>
- (&LowLevel::C_SetPIN<secure_allocator<byte>>), *p11_low_level.get(), session_handle,
+ return std::bind(static_cast< bool (LowLevel::*)(SessionHandle, const secure_vector<uint8_t>&,
+ const secure_vector<uint8_t>&, ReturnValue*) const>
+ (&LowLevel::C_SetPIN<secure_allocator<uint8_t>>), *p11_low_level.get(), session_handle,
old_pin, new_pin, std::placeholders::_1);
};
const std::string test_pin("654321");
- const auto test_pin_secvec = secure_vector<byte>(test_pin.begin(), test_pin.end());
+ const auto test_pin_secvec = secure_vector<uint8_t>(test_pin.begin(), test_pin.end());
PKCS11_BoundTestFunction set_pin_bind = get_pin_bind(PIN_SECVEC, test_pin_secvec);
PKCS11_BoundTestFunction revert_pin_bind = get_pin_bind(test_pin_secvec, PIN_SECVEC);
@@ -589,7 +589,7 @@ Test::Result test_c_set_pin()
// change so_pin in "R / W SO Functions" state
const std::string test_so_pin = "87654321";
- secure_vector<byte> test_so_pin_secvec(test_so_pin.begin(), test_so_pin.end());
+ secure_vector<uint8_t> test_so_pin_secvec(test_so_pin.begin(), test_so_pin.end());
p11_low_level.login(UserType::SO, SO_PIN_SECVEC);
PKCS11_BoundTestFunction set_so_pin_bind = get_pin_bind(SO_PIN_SECVEC, test_so_pin_secvec);
@@ -671,15 +671,15 @@ Test::Result test_c_get_attribute_value()
ObjectHandle object_handle = create_simple_data_object(p11_low_level);
- std::map < AttributeType, secure_vector<byte>> getter =
+ std::map < AttributeType, secure_vector<uint8_t>> getter =
{
- { AttributeType::Label, secure_vector<byte>() },
- { AttributeType::Value, secure_vector<byte>() }
+ { AttributeType::Label, secure_vector<uint8_t>() },
+ { AttributeType::Value, secure_vector<uint8_t>() }
};
auto bind = std::bind(static_cast< bool (LowLevel::*)(SessionHandle, ObjectHandle,
- std::map<AttributeType, secure_vector<byte>>&, ReturnValue*) const>
- (&LowLevel::C_GetAttributeValue<secure_allocator<byte>>), *p11_low_level.get(), session_handle,
+ std::map<AttributeType, secure_vector<uint8_t>>&, ReturnValue*) const>
+ (&LowLevel::C_GetAttributeValue<secure_allocator<uint8_t>>), *p11_low_level.get(), session_handle,
object_handle, std::ref(getter), std::placeholders::_1);
Test::Result result = test_function("C_GetAttributeValue", bind);
@@ -695,15 +695,15 @@ Test::Result test_c_get_attribute_value()
return result;
}
-std::map < AttributeType, std::vector<byte>> get_attribute_values(const RAII_LowLevel& p11_low_level,
+std::map < AttributeType, std::vector<uint8_t>> get_attribute_values(const RAII_LowLevel& p11_low_level,
SessionHandle session_handle,
ObjectHandle object_handle, const std::vector<AttributeType>& attribute_types)
{
- std::map < AttributeType, std::vector<byte>> received_attributes;
+ std::map < AttributeType, std::vector<uint8_t>> received_attributes;
for(const auto& type : attribute_types)
{
- received_attributes.emplace(type, std::vector<byte>());
+ received_attributes.emplace(type, std::vector<uint8_t>());
}
p11_low_level.get()->C_GetAttributeValue(session_handle, object_handle, received_attributes);
@@ -724,14 +724,14 @@ Test::Result test_c_set_attribute_value()
std::string new_label = "A modified data object";
- std::map < AttributeType, secure_vector<byte>> new_attributes =
+ std::map < AttributeType, secure_vector<uint8_t>> new_attributes =
{
- { AttributeType::Label, secure_vector<byte>(new_label.begin(), new_label.end()) }
+ { AttributeType::Label, secure_vector<uint8_t>(new_label.begin(), new_label.end()) }
};
auto bind = std::bind(static_cast< bool (LowLevel::*)(SessionHandle, ObjectHandle,
- std::map<AttributeType, secure_vector<byte>>&, ReturnValue*) const>
- (&LowLevel::C_SetAttributeValue<secure_allocator<byte>>), *p11_low_level.get(), session_handle,
+ std::map<AttributeType, secure_vector<uint8_t>>&, ReturnValue*) const>
+ (&LowLevel::C_SetAttributeValue<secure_allocator<uint8_t>>), *p11_low_level.get(), session_handle,
object_handle, std::ref(new_attributes), std::placeholders::_1);
Test::Result result = test_function("C_SetAttributeValue", bind);
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp
index 293756db9..bc20da9d9 100644
--- a/src/tests/test_pubkey.cpp
+++ b/src/tests/test_pubkey.cpp
@@ -301,7 +301,7 @@ Test::Result PK_KEM_Test::run_one_test(const std::string&, const VarMap& vars)
Fixed_Output_RNG fixed_output_rng(get_req_bin(vars, "R"));
- Botan::secure_vector<byte> produced_encap_key, shared_key;
+ Botan::secure_vector<uint8_t> produced_encap_key, shared_key;
enc->encrypt(produced_encap_key,
shared_key,
desired_key_len,
diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp
index 5b2ce0dd0..25640f726 100644
--- a/src/tests/test_rng.cpp
+++ b/src/tests/test_rng.cpp
@@ -42,12 +42,12 @@ class HMAC_DRBG_Tests : public Text_Based_Test
Test::Result run_one_test(const std::string& algo, const VarMap& vars) override
{
- const std::vector<byte> seed_input = get_req_bin(vars, "EntropyInput");
- const std::vector<byte> reseed_input = get_req_bin(vars, "EntropyInputReseed");
- const std::vector<byte> expected = get_req_bin(vars, "Out");
+ const std::vector<uint8_t> seed_input = get_req_bin(vars, "EntropyInput");
+ const std::vector<uint8_t> reseed_input = get_req_bin(vars, "EntropyInputReseed");
+ const std::vector<uint8_t> expected = get_req_bin(vars, "Out");
- const std::vector<byte> ad1 = get_opt_bin(vars, "AdditionalInput1");
- const std::vector<byte> ad2 = get_opt_bin(vars, "AdditionalInput2");
+ const std::vector<uint8_t> ad1 = get_opt_bin(vars, "AdditionalInput1");
+ const std::vector<uint8_t> ad2 = get_opt_bin(vars, "AdditionalInput2");
Test::Result result("HMAC_DRBG(" + algo + ")");
@@ -64,7 +64,7 @@ class HMAC_DRBG_Tests : public Text_Based_Test
// now reseed
rng->add_entropy(reseed_input.data(), reseed_input.size());
- std::vector<byte> out(expected.size());
+ std::vector<uint8_t> out(expected.size());
// first block is discarded
rng->randomize_with_input(out.data(), out.size(), ad1.data(), ad1.size());
rng->randomize_with_input(out.data(), out.size(), ad2.data(), ad2.size());
@@ -114,12 +114,12 @@ class HMAC_DRBG_Unit_Tests : public Test
m_randomize_count = 0;
}
- void randomize(byte[], size_t) override
+ void randomize(uint8_t[], size_t) override
{
m_randomize_count++;
}
- void add_entropy(const byte[], size_t) override {}
+ void add_entropy(const uint8_t[], size_t) override {}
std::string name() const override { return "Request_Counting_RNG"; }
@@ -143,17 +143,17 @@ class HMAC_DRBG_Unit_Tests : public Test
Request_Counting_RNG counting_rng;
Botan::HMAC_DRBG rng(std::move(mac), counting_rng, Botan::Entropy_Sources::global_sources(), 2);
- Botan::secure_vector<Botan::byte> seed_input(
+ Botan::secure_vector<uint8_t> seed_input(
{0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF});
- Botan::secure_vector<Botan::byte> output_after_initialization(
+ Botan::secure_vector<uint8_t> output_after_initialization(
{0x26,0x06,0x95,0xF4,0xB8,0x96,0x0D,0x0B,0x27,0x4E,0xA2,0x9E,0x8D,0x2B,0x5A,0x35});
- Botan::secure_vector<Botan::byte> output_without_reseed(
+ Botan::secure_vector<uint8_t> output_without_reseed(
{0xC4,0x90,0x04,0x5B,0x35,0x4F,0x50,0x09,0x68,0x45,0xF0,0x4B,0x11,0x03,0x58,0xF0});
result.test_eq("is_seeded",rng.is_seeded(),false);
rng.initialize_with(seed_input.data(), seed_input.size());
- Botan::secure_vector<Botan::byte> out(16);
+ Botan::secure_vector<uint8_t> out(16);
rng.randomize(out.data(), out.size());
result.test_eq("underlying RNG calls", counting_rng.randomize_count(), size_t(0));
@@ -347,7 +347,7 @@ class HMAC_DRBG_Unit_Tests : public Test
Botan::HMAC_DRBG rng(std::move(mac));
result.test_eq("not seeded", rng.is_seeded(), false);
- std::vector<Botan::byte> nonce(nonce_size);
+ std::vector<uint8_t> nonce(nonce_size);
rng.initialize_with(nonce.data(), nonce.size());
if(nonce_size < 16)
@@ -415,7 +415,7 @@ class HMAC_DRBG_Unit_Tests : public Test
// fork and request from parent and child, both should output different sequences
size_t count = counting_rng.randomize_count();
- Botan::secure_vector<byte> parent_bytes(16), child_bytes(16);
+ Botan::secure_vector<uint8_t> parent_bytes(16), child_bytes(16);
int fd[2];
int rc = ::pipe(fd);
if(rc != 0)
@@ -506,13 +506,13 @@ class HMAC_DRBG_Unit_Tests : public Test
// and possibly additional data, such as process id
Fixed_Output_RNG fixed_output_rng1(seed);
Botan::HMAC_DRBG rng1(std::move(mac), fixed_output_rng1, reseed_interval);
- Botan::secure_vector<byte> output1(request_bytes);
+ Botan::secure_vector<uint8_t> output1(request_bytes);
rng1.randomize(output1.data(), output1.size());
mac = Botan::MessageAuthenticationCode::create("HMAC(SHA-256)");
Fixed_Output_RNG fixed_output_rng2(seed);
Botan::HMAC_DRBG rng2(std::move(mac), fixed_output_rng2, reseed_interval);
- Botan::secure_vector<byte> output2(request_bytes);
+ Botan::secure_vector<uint8_t> output2(request_bytes);
rng2.randomize(output2.data(), output2.size());
result.test_eq("equal output due to same seed", output1, output2);
diff --git a/src/tests/test_rng.h b/src/tests/test_rng.h
index 0379a2ee9..90ade91c4 100644
--- a/src/tests/test_rng.h
+++ b/src/tests/test_rng.h
@@ -141,7 +141,7 @@ class SeedCapturing_RNG : public Botan::RandomNumberGenerator
void randomize(uint8_t[], size_t) override
{ throw Botan::Exception("SeedCapturing_RNG has no output"); }
- void add_entropy(const byte input[], size_t len) override
+ void add_entropy(const uint8_t input[], size_t len) override
{
m_samples++;
m_seed.insert(m_seed.end(), input, input + len);
diff --git a/src/tests/test_srp6.cpp b/src/tests/test_srp6.cpp
index f03c1edf5..82eea9266 100644
--- a/src/tests/test_srp6.cpp
+++ b/src/tests/test_srp6.cpp
@@ -28,7 +28,7 @@ class SRP6_Unit_Tests : public Test
const std::string group_id = "modp/srp/1024";
const std::string hash_id = "SHA-256";
- const std::vector<byte> salt = unlock(Test::rng().random_vec(16));
+ const std::vector<uint8_t> salt = unlock(Test::rng().random_vec(16));
const Botan::BigInt verifier = Botan::generate_srp6_verifier(username, password, salt, group_id, hash_id);
diff --git a/src/tests/test_tls_messages.cpp b/src/tests/test_tls_messages.cpp
index da6e72f79..250ce23f5 100644
--- a/src/tests/test_tls_messages.cpp
+++ b/src/tests/test_tls_messages.cpp
@@ -24,8 +24,8 @@ Test::Result test_hello_verify_request()
{
Test::Result result("hello_verify_request construction");
- std::vector<byte> test_data;
- std::vector<byte> key_data(32);
+ std::vector<uint8_t> test_data;
+ std::vector<uint8_t> key_data(32);
Botan::SymmetricKey sk(key_data);
// Compute cookie over an empty string with an empty test data
@@ -36,7 +36,7 @@ Test::Result test_hello_verify_request()
hmac->set_key(sk);
hmac->update_be(size_t(0));
hmac->update_be(size_t(0));
- std::vector<byte> test = unlock(hmac->final());
+ std::vector<uint8_t> test = unlock(hmac->final());
result.test_eq("Cookie comparison", hfr.cookie(), test);
return result;
@@ -74,10 +74,10 @@ class TLS_Message_Parsing_Test : public Text_Based_Test
Botan::TLS::Protocol_Version pv(protocol[0], protocol[1]);
Botan::TLS::Client_Hello message(buffer);
result.test_eq("Protocol version", message.version().to_string(), pv.to_string());
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
for(Botan::TLS::Handshake_Extension_Type const& type : message.extension_types())
{
- Botan::u16bit u16type = type;
+ uint16_t u16type = type;
buf.push_back(Botan::get_byte(0, u16type));
buf.push_back(Botan::get_byte(1, u16type));
}
@@ -99,14 +99,14 @@ class TLS_Message_Parsing_Test : public Text_Based_Test
{
const std::string extensions = get_req_str(vars, "AdditionalData");
Botan::TLS::Protocol_Version pv(protocol[0], protocol[1]);
- Botan::TLS::Ciphersuite cs = Botan::TLS::Ciphersuite::by_id(Botan::make_u16bit(ciphersuite[0], ciphersuite[1]));
+ Botan::TLS::Ciphersuite cs = Botan::TLS::Ciphersuite::by_id(Botan::make_uint16(ciphersuite[0], ciphersuite[1]));
Botan::TLS::Server_Hello message(buffer);
result.test_eq("Protocol version", message.version().to_string(), pv.to_string());
result.confirm("Ciphersuite", (message.ciphersuite() == cs.ciphersuite_code()));
- std::vector<byte> buf;
+ std::vector<uint8_t> buf;
for(Botan::TLS::Handshake_Extension_Type const& type : message.extension_types())
{
- Botan::u16bit u16type = type;
+ uint16_t u16type = type;
buf.push_back(Botan::get_byte(0, u16type));
buf.push_back(Botan::get_byte(1, u16type));
}
diff --git a/src/tests/test_tss.cpp b/src/tests/test_tss.cpp
index 96e3fa9ee..aacacd0bc 100644
--- a/src/tests/test_tss.cpp
+++ b/src/tests/test_tss.cpp
@@ -25,11 +25,11 @@ class TSS_Tests : public Test
std::vector<Test::Result> results;
Test::Result result("TSS");
- byte id[16];
+ uint8_t id[16];
for(int i = 0; i != 16; ++i)
id[i] = i;
- const std::vector<byte> S = Botan::hex_decode("7465737400");
+ const std::vector<uint8_t> S = Botan::hex_decode("7465737400");
std::vector<Botan::RTSS_Share> shares =
Botan::RTSS_Share::split(2, 4, S.data(), S.size(), id, Test::rng());
diff --git a/src/tests/test_utils.cpp b/src/tests/test_utils.cpp
index 3d474d605..6edd7fd81 100644
--- a/src/tests/test_utils.cpp
+++ b/src/tests/test_utils.cpp
@@ -83,8 +83,8 @@ class Utility_Function_Tests : public Text_Based_Test
result.test_is_eq<uint8_t>(Botan::get_byte(2, in32), 0xC0);
result.test_is_eq<uint8_t>(Botan::get_byte(3, in32), 0xD0);
- result.test_is_eq<uint16_t>(Botan::make_u16bit(0xAA, 0xBB), 0xAABB);
- result.test_is_eq<uint32_t>(Botan::make_u32bit(0x01, 0x02, 0x03, 0x04), 0x01020304);
+ result.test_is_eq<uint16_t>(Botan::make_uint16(0xAA, 0xBB), 0xAABB);
+ result.test_is_eq<uint32_t>(Botan::make_uint32(0x01, 0x02, 0x03, 0x04), 0x01020304);
result.test_is_eq<uint16_t>(Botan::load_be<uint16_t>(mem, 0), 0x0011);
result.test_is_eq<uint16_t>(Botan::load_be<uint16_t>(mem, 1), 0x2233);
@@ -123,11 +123,11 @@ class Utility_Function_Tests : public Text_Based_Test
result.test_is_eq<uint64_t>(Botan::load_le<uint64_t>(mem + 7, 0), 0xEEDDCCBBAA998877);
result.test_is_eq<uint64_t>(Botan::load_le<uint64_t>(mem + 5, 0), 0xCCBBAA9988776655);
- byte outbuf[16] = { 0 };
+ uint8_t outbuf[16] = { 0 };
for(size_t offset = 0; offset != 7; ++offset)
{
- byte* out = outbuf + offset;
+ uint8_t* out = outbuf + offset;
Botan::store_be(in16, out);
result.test_is_eq<uint8_t>(out[0], 0x12);
@@ -266,7 +266,7 @@ class Base64_Tests : public Text_Based_Test
{
if(is_valid)
{
- const std::vector<byte> binary = get_req_bin(vars, "Binary");
+ const std::vector<uint8_t> binary = get_req_bin(vars, "Binary");
result.test_eq("base64 decoding", Botan::base64_decode(base64), binary);
result.test_eq("base64 encoding", Botan::base64_encode(binary), base64);
}
@@ -341,8 +341,8 @@ class Charset_Tests : public Text_Based_Test
Test::Result result("Charset");
- const std::vector<byte> in = get_req_bin(vars, "In");
- const std::vector<byte> expected = get_req_bin(vars, "Out");
+ const std::vector<uint8_t> in = get_req_bin(vars, "In");
+ const std::vector<uint8_t> expected = get_req_bin(vars, "Out");
std::string converted;
if(type == "UTF16-LATIN1")
@@ -365,7 +365,7 @@ class Charset_Tests : public Text_Based_Test
throw Test_Error("Unexpected header '" + type + "' in charset tests");
}
- result.test_eq("string converted successfully", std::vector<byte>(converted.begin(), converted.end()), expected);
+ result.test_eq("string converted successfully", std::vector<uint8_t>(converted.begin(), converted.end()), expected);
return result;
}
@@ -379,7 +379,7 @@ class Charset_Tests : public Text_Based_Test
result.test_throws("conversion fails for non-Latin1 characters", []()
{
// "abcdefŸabcdef"
- std::vector<byte> input = { 0x00, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x64, 0x00, 0x65, 0x00, 0x66, 0x01,
+ std::vector<uint8_t> input = { 0x00, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x64, 0x00, 0x65, 0x00, 0x66, 0x01,
0x78, 0x00, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x64, 0x00, 0x65, 0x00, 0x66
};
@@ -389,7 +389,7 @@ class Charset_Tests : public Text_Based_Test
result.test_throws("conversion fails for UTF16 string with odd number of bytes", []()
{
- std::vector<byte> input = { 0x00, 0x61, 0x00 };
+ std::vector<uint8_t> input = { 0x00, 0x61, 0x00 };
Charset::transcode(std::string(input.begin(), input.end()),
Character_Set::LATIN1_CHARSET, Character_Set::UCS2_CHARSET);
@@ -407,7 +407,7 @@ class Charset_Tests : public Text_Based_Test
result.test_throws("conversion fails for non-Latin1 characters", []()
{
// "abcdefŸabcdef"
- std::vector<byte> input = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xC5,
+ std::vector<uint8_t> input = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xC5,
0xB8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66
};
@@ -418,7 +418,7 @@ class Charset_Tests : public Text_Based_Test
result.test_throws("invalid utf-8 string", []()
{
// sequence truncated
- std::vector<byte> input = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xC5 };
+ std::vector<uint8_t> input = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xC5 };
Charset::transcode(std::string(input.begin(), input.end()),
Character_Set::LATIN1_CHARSET, Character_Set::UTF8_CHARSET);
@@ -426,7 +426,7 @@ class Charset_Tests : public Text_Based_Test
result.test_throws("invalid utf-8 string", []()
{
- std::vector<byte> input = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xC8, 0xB8, 0x61 };
+ std::vector<uint8_t> input = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0xC8, 0xB8, 0x61 };
Charset::transcode(std::string(input.begin(), input.end()),
Character_Set::LATIN1_CHARSET, Character_Set::UTF8_CHARSET);
diff --git a/src/tests/test_xmss.cpp b/src/tests/test_xmss.cpp
index 8cec72186..4e6483ba1 100644
--- a/src/tests/test_xmss.cpp
+++ b/src/tests/test_xmss.cpp
@@ -35,8 +35,8 @@ class XMSS_Signature_Tests : public PK_Signature_Generation_Test
std::unique_ptr<Botan::Private_Key> load_private_key(const VarMap& vars) override
{
- const std::vector<byte> raw_key = get_req_bin(vars, "PrivateKey");
- const Botan::secure_vector<byte> sec_key(raw_key.begin(), raw_key.end());
+ const std::vector<uint8_t> raw_key = get_req_bin(vars, "PrivateKey");
+ const Botan::secure_vector<uint8_t> sec_key(raw_key.begin(), raw_key.end());
std::unique_ptr<Botan::Private_Key> key(new Botan::XMSS_PrivateKey(sec_key));
return key;
@@ -60,7 +60,7 @@ class XMSS_Signature_Verify_Tests : public PK_Signature_Verification_Test
std::unique_ptr<Botan::Public_Key> load_public_key(const VarMap& vars) override
{
- const std::vector<byte> raw_key = get_req_bin(vars, "PublicKey");
+ const std::vector<uint8_t> raw_key = get_req_bin(vars, "PublicKey");
std::unique_ptr<Botan::Public_Key> key(new Botan::XMSS_PublicKey(raw_key));
return key;
}
diff --git a/src/tests/tests.h b/src/tests/tests.h
index 32aaad0fb..51b59d972 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -34,8 +34,6 @@
namespace Botan_Tests {
-using Botan::byte;
-
#if defined(BOTAN_HAS_BIGINT)
using Botan::BigInt;
#endif
@@ -276,7 +274,7 @@ class Test
const std::vector<uint8_t, Alloc>& produced,
const char* expected_hex)
{
- const std::vector<byte> expected = Botan::hex_decode(expected_hex);
+ const std::vector<uint8_t> expected = Botan::hex_decode(expected_hex);
return test_eq(nullptr, what,
produced.data(), produced.size(),
expected.data(), expected.size());
@@ -351,7 +349,7 @@ class Test
if(r.size() > min_offset)
{
const size_t offset = std::max<size_t>(min_offset, rng.next_byte() % r.size());
- const byte perturb = rng.next_nonzero_byte();
+ const uint8_t perturb = rng.next_nonzero_byte();
r[offset] ^= perturb;
}
diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp
index 2bcf4d3dc..5961ca5e3 100644
--- a/src/tests/unit_ecc.cpp
+++ b/src/tests/unit_ecc.cpp
@@ -359,7 +359,7 @@ Test::Result test_zeropoint_enc_dec()
Botan::PointGFp p(curve);
result.confirm("zero point is zero", p.is_zero());
- std::vector<byte> sv_p = unlock(EC2OSP(p, Botan::PointGFp::UNCOMPRESSED));
+ std::vector<uint8_t> sv_p = unlock(EC2OSP(p, Botan::PointGFp::UNCOMPRESSED));
result.test_eq("encoded/decode rt works", OS2ECP(sv_p, curve), p);
sv_p = unlock(EC2OSP(p, Botan::PointGFp::COMPRESSED));
@@ -509,11 +509,11 @@ Test::Result test_enc_dec_compressed_160()
Botan::EC_Group secp160r1(Botan::OIDS::lookup("secp160r1"));
const Botan::CurveGFp& curve = secp160r1.get_curve();
- const std::vector<byte> G_comp = Botan::hex_decode("024A96B5688EF573284664698968C38BB913CBFC82");
+ const std::vector<uint8_t> G_comp = Botan::hex_decode("024A96B5688EF573284664698968C38BB913CBFC82");
const Botan::PointGFp p = Botan::OS2ECP(G_comp, curve);
- std::vector<byte> sv_result = unlock(Botan::EC2OSP(p, Botan::PointGFp::COMPRESSED));
+ std::vector<uint8_t> sv_result = unlock(Botan::EC2OSP(p, Botan::PointGFp::COMPRESSED));
result.test_eq("result", sv_result, G_comp);
return result;
@@ -529,10 +529,10 @@ Test::Result test_enc_dec_compressed_256()
std::string b_secp = "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B";
std::string G_secp_comp = "036B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296";
- std::vector<byte> sv_p_secp = Botan::hex_decode ( p_secp );
- std::vector<byte> sv_a_secp = Botan::hex_decode ( a_secp );
- std::vector<byte> sv_b_secp = Botan::hex_decode ( b_secp );
- std::vector<byte> sv_G_secp_comp = Botan::hex_decode ( G_secp_comp );
+ std::vector<uint8_t> sv_p_secp = Botan::hex_decode ( p_secp );
+ std::vector<uint8_t> sv_a_secp = Botan::hex_decode ( a_secp );
+ std::vector<uint8_t> sv_b_secp = Botan::hex_decode ( b_secp );
+ std::vector<uint8_t> sv_G_secp_comp = Botan::hex_decode ( G_secp_comp );
Botan::BigInt bi_p_secp = Botan::BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() );
Botan::BigInt bi_a_secp = Botan::BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() );
@@ -541,7 +541,7 @@ Test::Result test_enc_dec_compressed_256()
Botan::CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp);
Botan::PointGFp p_G = OS2ECP ( sv_G_secp_comp, curve );
- std::vector<byte> sv_result = unlock(EC2OSP(p_G, Botan::PointGFp::COMPRESSED));
+ std::vector<uint8_t> sv_result = unlock(EC2OSP(p_G, Botan::PointGFp::COMPRESSED));
result.test_eq("compressed_256", sv_result, sv_G_secp_comp);
return result;
@@ -559,10 +559,10 @@ Test::Result test_enc_dec_uncompressed_112()
std::string b_secp = "51DEF1815DB5ED74FCC34C85D709";
std::string G_secp_uncomp = "044BA30AB5E892B4E1649DD0928643ADCD46F5882E3747DEF36E956E97";
- std::vector<byte> sv_p_secp = Botan::hex_decode ( p_secp );
- std::vector<byte> sv_a_secp = Botan::hex_decode ( a_secp );
- std::vector<byte> sv_b_secp = Botan::hex_decode ( b_secp );
- std::vector<byte> sv_G_secp_uncomp = Botan::hex_decode ( G_secp_uncomp );
+ std::vector<uint8_t> sv_p_secp = Botan::hex_decode ( p_secp );
+ std::vector<uint8_t> sv_a_secp = Botan::hex_decode ( a_secp );
+ std::vector<uint8_t> sv_b_secp = Botan::hex_decode ( b_secp );
+ std::vector<uint8_t> sv_G_secp_uncomp = Botan::hex_decode ( G_secp_uncomp );
Botan::BigInt bi_p_secp = Botan::BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() );
Botan::BigInt bi_a_secp = Botan::BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() );
@@ -571,7 +571,7 @@ Test::Result test_enc_dec_uncompressed_112()
Botan::CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp);
Botan::PointGFp p_G = OS2ECP ( sv_G_secp_uncomp, curve );
- std::vector<byte> sv_result = unlock(EC2OSP(p_G, Botan::PointGFp::UNCOMPRESSED));
+ std::vector<uint8_t> sv_result = unlock(EC2OSP(p_G, Botan::PointGFp::UNCOMPRESSED));
result.test_eq("uncompressed_112", sv_result, sv_G_secp_uncomp);
return result;
@@ -587,10 +587,10 @@ Test::Result test_enc_dec_uncompressed_521()
std::string b_secp = "0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00";
std::string G_secp_uncomp = "0400C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2ffA8DE3348B3C1856A429BF97E7E31C2E5BD66011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650";
- std::vector<byte> sv_p_secp = Botan::hex_decode ( p_secp );
- std::vector<byte> sv_a_secp = Botan::hex_decode ( a_secp );
- std::vector<byte> sv_b_secp = Botan::hex_decode ( b_secp );
- std::vector<byte> sv_G_secp_uncomp = Botan::hex_decode ( G_secp_uncomp );
+ std::vector<uint8_t> sv_p_secp = Botan::hex_decode ( p_secp );
+ std::vector<uint8_t> sv_a_secp = Botan::hex_decode ( a_secp );
+ std::vector<uint8_t> sv_b_secp = Botan::hex_decode ( b_secp );
+ std::vector<uint8_t> sv_G_secp_uncomp = Botan::hex_decode ( G_secp_uncomp );
Botan::BigInt bi_p_secp = Botan::BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() );
Botan::BigInt bi_a_secp = Botan::BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() );
@@ -600,7 +600,7 @@ Test::Result test_enc_dec_uncompressed_521()
Botan::PointGFp p_G = Botan::OS2ECP ( sv_G_secp_uncomp, curve );
- std::vector<byte> sv_result = unlock(EC2OSP(p_G, Botan::PointGFp::UNCOMPRESSED));
+ std::vector<uint8_t> sv_result = unlock(EC2OSP(p_G, Botan::PointGFp::UNCOMPRESSED));
result.test_eq("expected", sv_result, sv_G_secp_uncomp);
return result;
@@ -616,10 +616,10 @@ Test::Result test_enc_dec_uncompressed_521_prime_too_large()
std::string b_secp = "0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00";
std::string G_secp_uncomp = "0400C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2ffA8DE3348B3C1856A429BF97E7E31C2E5BD66011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650";
- std::vector<byte> sv_p_secp = Botan::hex_decode ( p_secp );
- std::vector<byte> sv_a_secp = Botan::hex_decode ( a_secp );
- std::vector<byte> sv_b_secp = Botan::hex_decode ( b_secp );
- std::vector<byte> sv_G_secp_uncomp = Botan::hex_decode ( G_secp_uncomp );
+ std::vector<uint8_t> sv_p_secp = Botan::hex_decode ( p_secp );
+ std::vector<uint8_t> sv_a_secp = Botan::hex_decode ( a_secp );
+ std::vector<uint8_t> sv_b_secp = Botan::hex_decode ( b_secp );
+ std::vector<uint8_t> sv_G_secp_uncomp = Botan::hex_decode ( G_secp_uncomp );
Botan::BigInt bi_p_secp = Botan::BigInt::decode ( sv_p_secp.data(), sv_p_secp.size() );
Botan::BigInt bi_a_secp = Botan::BigInt::decode ( sv_a_secp.data(), sv_a_secp.size() );
@@ -649,7 +649,7 @@ Test::Result test_gfp_store_restore()
Botan::EC_Group dom_pars(Botan::OID("1.3.132.0.8"));
Botan::PointGFp p = dom_pars.get_base_point();
- std::vector<byte> sv_mes = unlock(EC2OSP(p, Botan::PointGFp::COMPRESSED));
+ std::vector<uint8_t> sv_mes = unlock(EC2OSP(p, Botan::PointGFp::COMPRESSED));
Botan::PointGFp new_p = Botan::OS2ECP(sv_mes, dom_pars.get_curve());
result.test_eq("original and restored points are same", p, new_p);
@@ -664,7 +664,7 @@ Test::Result test_cdc_curve_33()
std::string G_secp_uncomp = "04081523d03d4f12cd02879dea4bf6a4f3a7df26ed888f10c5b2235a1274c386a2f218300dee6ed217841164533bcdc903f07a096f9fbf4ee95bac098a111f296f5830fe5c35b3e344d5df3a2256985f64fbe6d0edcc4c61d18bef681dd399df3d0194c5a4315e012e0245ecea56365baa9e8be1f7";
- std::vector<byte> sv_G_uncomp = Botan::hex_decode ( G_secp_uncomp );
+ std::vector<uint8_t> sv_G_uncomp = Botan::hex_decode ( G_secp_uncomp );
Botan::BigInt bi_p_secp = Botan::BigInt("2117607112719756483104013348936480976596328609518055062007450442679169492999007105354629105748524349829824407773719892437896937279095106809");
Botan::BigInt bi_a_secp("0xa377dede6b523333d36c78e9b0eaa3bf48ce93041f6d4fc34014d08f6833807498deedd4290101c5866e8dfb589485d13357b9e78c2d7fbe9fe");
diff --git a/src/tests/unit_ecdsa.cpp b/src/tests/unit_ecdsa.cpp
index d11e019e0..96aa36969 100644
--- a/src/tests/unit_ecdsa.cpp
+++ b/src/tests/unit_ecdsa.cpp
@@ -46,7 +46,7 @@ Test::Result test_hash_larger_than_n()
Botan::ECDSA_PrivateKey priv_key(Test::rng(), dom_pars);
- std::vector<byte> message(20);
+ std::vector<uint8_t> message(20);
for(size_t i = 0; i != message.size(); ++i)
message[i] = i;
@@ -63,12 +63,12 @@ Test::Result test_hash_larger_than_n()
Botan::PK_Verifier pk_verifier_160(priv_key, "EMSA1(SHA-1)");
// Verify we can sign and verify with SHA-160
- std::vector<byte> signature_160 = pk_signer_160.sign_message(message, Test::rng());
+ std::vector<uint8_t> signature_160 = pk_signer_160.sign_message(message, Test::rng());
result.test_eq("message verifies", pk_verifier_160.verify_message(message, signature_160), true);
// Verify we can sign and verify with SHA-224
Botan::PK_Signer pk_signer(priv_key, Test::rng(), "EMSA1(SHA-224)");
- std::vector<byte> signature = pk_signer.sign_message(message, Test::rng());
+ std::vector<uint8_t> signature = pk_signer.sign_message(message, Test::rng());
Botan::PK_Verifier pk_verifier(priv_key, "EMSA1(SHA-224)");
result.test_eq("message verifies", pk_verifier.verify_message(message, signature), true);
@@ -126,7 +126,7 @@ Test::Result test_sign_then_ver()
Botan::PK_Signer signer(ecdsa, Test::rng(), "EMSA1(SHA-256)");
auto msg = Botan::hex_decode("12345678901234567890abcdef12");
- std::vector<byte> sig = signer.sign_message(msg, Test::rng());
+ std::vector<uint8_t> sig = signer.sign_message(msg, Test::rng());
Botan::PK_Verifier verifier(ecdsa, "EMSA1(SHA-256)");
@@ -150,13 +150,13 @@ Test::Result test_ec_sign()
for(size_t i = 0; i != 256; ++i)
{
- signer.update(static_cast<byte>(i));
+ signer.update(static_cast<uint8_t>(i));
}
- std::vector<byte> sig = signer.signature(Test::rng());
+ std::vector<uint8_t> sig = signer.signature(Test::rng());
for(size_t i = 0; i != 256; ++i)
{
- verifier.update(static_cast<byte>(i));
+ verifier.update(static_cast<uint8_t>(i));
}
result.test_eq("ECDSA signature valid", verifier.check_signature(sig), true);
@@ -164,7 +164,7 @@ Test::Result test_ec_sign()
// now check valid signature, different input
for(size_t i = 1; i != 256; ++i) //starting from 1
{
- verifier.update(static_cast<byte>(i));
+ verifier.update(static_cast<uint8_t>(i));
}
result.test_eq("invalid ECDSA signature invalid", verifier.check_signature(sig), false);
@@ -173,7 +173,7 @@ Test::Result test_ec_sign()
sig[sig.size()/2]++;
for(size_t i = 0; i != 256; ++i)
- verifier.update(static_cast<byte>(i));
+ verifier.update(static_cast<uint8_t>(i));
result.test_eq("invalid ECDSA signature invalid", verifier.check_signature(sig), false);
}
@@ -190,8 +190,8 @@ Test::Result test_ecdsa_create_save_load()
Test::Result result("ECDSA Unit");
std::string ecc_private_key_pem;
- const std::vector<byte> msg = Botan::hex_decode("12345678901234567890abcdef12");
- std::vector<byte> msg_signature;
+ const std::vector<uint8_t> msg = Botan::hex_decode("12345678901234567890abcdef12");
+ std::vector<uint8_t> msg_signature;
try
{
@@ -254,7 +254,7 @@ Test::Result test_read_pkcs8()
{
Test::Result result("ECDSA Unit");
- const std::vector<byte> msg = Botan::hex_decode("12345678901234567890abcdef12");
+ const std::vector<uint8_t> msg = Botan::hex_decode("12345678901234567890abcdef12");
try
{
@@ -267,7 +267,7 @@ Test::Result test_read_pkcs8()
Botan::PK_Signer signer(*ecdsa_nodp, Test::rng(), "EMSA1(SHA-256)");
Botan::PK_Verifier verifier(*ecdsa_nodp, "EMSA1(SHA-256)");
- std::vector<byte> signature_nodp = signer.sign_message(msg, Test::rng());
+ std::vector<uint8_t> signature_nodp = signer.sign_message(msg, Test::rng());
result.confirm("signature valid", verifier.verify_message(msg, signature_nodp));
@@ -335,7 +335,7 @@ Test::Result test_curve_registry()
Botan::PK_Verifier verifier(ecdsa, "EMSA1(SHA-256)");
auto msg = Botan::hex_decode("12345678901234567890abcdef12");
- std::vector<byte> sig = signer.sign_message(msg, Test::rng());
+ std::vector<uint8_t> sig = signer.sign_message(msg, Test::rng());
result.confirm("verified signature", verifier.verify_message(msg, sig));
}
diff --git a/src/tests/unit_tls.cpp b/src/tests/unit_tls.cpp
index 9952ea77c..776326596 100644
--- a/src/tests/unit_tls.cpp
+++ b/src/tests/unit_tls.cpp
@@ -193,16 +193,16 @@ create_creds(Botan::RandomNumberGenerator& rng,
return cmt;
}
-std::function<void (const byte[], size_t)> queue_inserter(std::vector<byte>& q)
+std::function<void (const uint8_t[], size_t)> queue_inserter(std::vector<uint8_t>& q)
{
- return [&](const byte buf[], size_t sz) { q.insert(q.end(), buf, buf + sz); };
+ return [&](const uint8_t buf[], size_t sz) { q.insert(q.end(), buf, buf + sz); };
}
void print_alert(Botan::TLS::Alert)
{
}
-void alert_cb_with_data(Botan::TLS::Alert, const byte[], size_t)
+void alert_cb_with_data(Botan::TLS::Alert, const uint8_t[], size_t)
{
}
@@ -259,12 +259,12 @@ Test::Result test_tls_handshake(Botan::TLS::Protocol_Version offer_version,
try
{
- std::vector<byte> c2s_traffic, s2c_traffic, client_recv, server_recv, client_sent, server_sent;
+ std::vector<uint8_t> c2s_traffic, s2c_traffic, client_recv, server_recv, client_sent, server_sent;
std::unique_ptr<Botan::TLS::Callbacks> server_cb(new Botan::TLS::Compat_Callbacks(
queue_inserter(s2c_traffic),
queue_inserter(server_recv),
- std::function<void (Botan::TLS::Alert, const byte[], size_t)>(alert_cb_with_data),
+ std::function<void (Botan::TLS::Alert, const uint8_t[], size_t)>(alert_cb_with_data),
handshake_complete,
nullptr,
next_protocol_chooser));
@@ -281,7 +281,7 @@ Test::Result test_tls_handshake(Botan::TLS::Protocol_Version offer_version,
std::unique_ptr<Botan::TLS::Callbacks> client_cb(new Botan::TLS::Compat_Callbacks(
queue_inserter(c2s_traffic),
queue_inserter(client_recv),
- std::function<void (Botan::TLS::Alert, const byte[], size_t)>(alert_cb_with_data),
+ std::function<void (Botan::TLS::Alert, const uint8_t[], size_t)>(alert_cb_with_data),
handshake_complete));
// TLS::Client object constructed by new constructor using virtual callback interface.
@@ -403,7 +403,7 @@ Test::Result test_tls_handshake(Botan::TLS::Protocol_Version offer_version,
* might end up appending more in response to messages during the
* handshake.
*/
- std::vector<byte> input;
+ std::vector<uint8_t> input;
std::swap(c2s_traffic, input);
if(corrupt_server_data)
@@ -434,7 +434,7 @@ Test::Result test_tls_handshake(Botan::TLS::Protocol_Version offer_version,
if(s2c_traffic.size() > 0)
{
- std::vector<byte> input;
+ std::vector<uint8_t> input;
std::swap(s2c_traffic, input);
if(corrupt_client_data)
@@ -570,7 +570,7 @@ Test::Result test_dtls_handshake(Botan::TLS::Protocol_Version offer_version,
try
{
- std::vector<byte> c2s_traffic, s2c_traffic, client_recv, server_recv, client_sent, server_sent;
+ std::vector<uint8_t> c2s_traffic, s2c_traffic, client_recv, server_recv, client_sent, server_sent;
std::unique_ptr<Botan::TLS::Callbacks> server_cb(new Botan::TLS::Compat_Callbacks(
queue_inserter(s2c_traffic),
@@ -689,7 +689,7 @@ Test::Result test_dtls_handshake(Botan::TLS::Protocol_Version offer_version,
* might end up appending more in response to messages during the
* handshake.
*/
- std::vector<byte> input;
+ std::vector<uint8_t> input;
std::swap(c2s_traffic, input);
if(corrupt_server_data)
@@ -729,7 +729,7 @@ Test::Result test_dtls_handshake(Botan::TLS::Protocol_Version offer_version,
if(s2c_traffic.size() > 0)
{
- std::vector<byte> input;
+ std::vector<uint8_t> input;
std::swap(s2c_traffic, input);
if(corrupt_client_data)
diff --git a/src/tests/unit_x509.cpp b/src/tests/unit_x509.cpp
index 56a6e8b82..26ccfedc0 100644
--- a/src/tests/unit_x509.cpp
+++ b/src/tests/unit_x509.cpp
@@ -731,12 +731,12 @@ class String_Extension : public Botan::Certificate_Extension
void contents_to(Botan::Data_Store&, Botan::Data_Store&) const override {}
- std::vector<byte> encode_inner() const override
+ std::vector<uint8_t> encode_inner() const override
{
return Botan::DER_Encoder().encode(Botan::ASN1_String(m_contents, Botan::UTF8_STRING)).get_contents_unlocked();
}
- void decode_inner(const std::vector<byte>& in) override
+ void decode_inner(const std::vector<uint8_t>& in) override
{
Botan::ASN1_String str;
Botan::BER_Decoder(in).decode(str, Botan::UTF8_STRING).verify_end();