aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-11 15:28:38 -0500
committerJack Lloyd <[email protected]>2016-12-18 16:48:24 -0500
commitf3cb3edb512bdcab498d825886c3366c341b3f78 (patch)
tree645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/pubkey
parentc1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff)
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r--src/lib/pubkey/cecpq1/cecpq1.cpp2
-rw-r--r--src/lib/pubkey/curve25519/curve25519.cpp20
-rw-r--r--src/lib/pubkey/curve25519/curve25519.h26
-rw-r--r--src/lib/pubkey/curve25519/donna.cpp6
-rw-r--r--src/lib/pubkey/dh/dh.cpp10
-rw-r--r--src/lib/pubkey/dh/dh.h8
-rw-r--r--src/lib/pubkey/dl_algo/dl_algo.cpp8
-rw-r--r--src/lib/pubkey/dl_algo/dl_algo.h8
-rw-r--r--src/lib/pubkey/dl_group/dl_group.cpp8
-rw-r--r--src/lib/pubkey/dl_group/dl_group.h6
-rw-r--r--src/lib/pubkey/dlies/dlies.cpp28
-rw-r--r--src/lib/pubkey/dlies/dlies.h12
-rw-r--r--src/lib/pubkey/dsa/dsa.cpp16
-rw-r--r--src/lib/pubkey/dsa/dsa.h4
-rw-r--r--src/lib/pubkey/ec_group/ec_group.cpp10
-rw-r--r--src/lib/pubkey/ec_group/ec_group.h4
-rw-r--r--src/lib/pubkey/ecc_key/ecc_key.cpp10
-rw-r--r--src/lib/pubkey/ecc_key/ecc_key.h10
-rw-r--r--src/lib/pubkey/ecdh/ecdh.cpp2
-rw-r--r--src/lib/pubkey/ecdh/ecdh.h12
-rw-r--r--src/lib/pubkey/ecdsa/ecdsa.cpp14
-rw-r--r--src/lib/pubkey/ecdsa/ecdsa.h4
-rw-r--r--src/lib/pubkey/ecgdsa/ecgdsa.cpp14
-rw-r--r--src/lib/pubkey/ecgdsa/ecgdsa.h4
-rw-r--r--src/lib/pubkey/ecies/ecies.cpp34
-rw-r--r--src/lib/pubkey/ecies/ecies.h16
-rw-r--r--src/lib/pubkey/eckcdsa/eckcdsa.cpp36
-rw-r--r--src/lib/pubkey/eckcdsa/eckcdsa.h4
-rw-r--r--src/lib/pubkey/elgamal/elgamal.cpp16
-rw-r--r--src/lib/pubkey/elgamal/elgamal.h4
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.cpp30
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.h6
-rw-r--r--src/lib/pubkey/keypair/keypair.cpp10
-rw-r--r--src/lib/pubkey/mce/code_based_key_gen.cpp56
-rw-r--r--src/lib/pubkey/mce/code_based_util.h8
-rw-r--r--src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp48
-rw-r--r--src/lib/pubkey/mce/gf2m_small_m.cpp10
-rw-r--r--src/lib/pubkey/mce/gf2m_small_m.h8
-rw-r--r--src/lib/pubkey/mce/goppa_code.cpp62
-rw-r--r--src/lib/pubkey/mce/mce_internal.h28
-rw-r--r--src/lib/pubkey/mce/mceliece.cpp52
-rw-r--r--src/lib/pubkey/mce/mceliece.h42
-rw-r--r--src/lib/pubkey/mce/mceliece_key.cpp82
-rw-r--r--src/lib/pubkey/mce/polyn_gf2m.cpp70
-rw-r--r--src/lib/pubkey/mce/polyn_gf2m.h22
-rw-r--r--src/lib/pubkey/mceies/mceies.cpp26
-rw-r--r--src/lib/pubkey/mceies/mceies.h12
-rw-r--r--src/lib/pubkey/newhope/newhope.cpp2
-rw-r--r--src/lib/pubkey/pbes2/pbes2.cpp28
-rw-r--r--src/lib/pubkey/pbes2/pbes2.h10
-rw-r--r--src/lib/pubkey/pem/pem.cpp20
-rw-r--r--src/lib/pubkey/pem/pem.h14
-rw-r--r--src/lib/pubkey/pk_algs.cpp4
-rw-r--r--src/lib/pubkey/pk_algs.h4
-rw-r--r--src/lib/pubkey/pk_keys.cpp6
-rw-r--r--src/lib/pubkey/pk_keys.h10
-rw-r--r--src/lib/pubkey/pk_ops.cpp52
-rw-r--r--src/lib/pubkey/pk_ops.h26
-rw-r--r--src/lib/pubkey/pk_ops_impl.h60
-rw-r--r--src/lib/pubkey/pkcs8.cpp18
-rw-r--r--src/lib/pubkey/pkcs8.h4
-rw-r--r--src/lib/pubkey/pubkey.cpp62
-rw-r--r--src/lib/pubkey/pubkey.h104
-rw-r--r--src/lib/pubkey/rfc6979/rfc6979.h2
-rw-r--r--src/lib/pubkey/rsa/rsa.cpp24
-rw-r--r--src/lib/pubkey/rsa/rsa.h8
-rw-r--r--src/lib/pubkey/x509_key.cpp6
-rw-r--r--src/lib/pubkey/x509_key.h4
-rw-r--r--src/lib/pubkey/xmss/xmss_address.h14
-rw-r--r--src/lib/pubkey/xmss/xmss_common_ops.cpp20
-rw-r--r--src/lib/pubkey/xmss/xmss_common_ops.h14
-rw-r--r--src/lib/pubkey/xmss/xmss_hash.cpp28
-rw-r--r--src/lib/pubkey/xmss/xmss_hash.h52
-rw-r--r--src/lib/pubkey/xmss/xmss_index_registry.cpp10
-rw-r--r--src/lib/pubkey/xmss/xmss_index_registry.h8
-rw-r--r--src/lib/pubkey/xmss/xmss_privatekey.cpp24
-rw-r--r--src/lib/pubkey/xmss/xmss_privatekey.h28
-rw-r--r--src/lib/pubkey/xmss/xmss_publickey.cpp16
-rw-r--r--src/lib/pubkey/xmss/xmss_publickey.h38
-rw-r--r--src/lib/pubkey/xmss/xmss_signature.cpp26
-rw-r--r--src/lib/pubkey/xmss/xmss_signature.h20
-rw-r--r--src/lib/pubkey/xmss/xmss_signature_operation.cpp12
-rw-r--r--src/lib/pubkey/xmss/xmss_signature_operation.h10
-rw-r--r--src/lib/pubkey/xmss/xmss_tools.h12
-rw-r--r--src/lib/pubkey/xmss/xmss_verification_operation.cpp22
-rw-r--r--src/lib/pubkey/xmss/xmss_verification_operation.h14
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h2
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h2
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_common_ops.cpp4
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_common_ops.h4
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_parameters.cpp16
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_parameters.h6
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_privatekey.cpp8
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_privatekey.h28
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_publickey.cpp10
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_publickey.h36
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp6
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_signature_operation.h10
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp6
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_verification_operation.h6
100 files changed, 954 insertions, 954 deletions
diff --git a/src/lib/pubkey/cecpq1/cecpq1.cpp b/src/lib/pubkey/cecpq1/cecpq1.cpp
index d5b6ae702..83c0a383c 100644
--- a/src/lib/pubkey/cecpq1/cecpq1.cpp
+++ b/src/lib/pubkey/cecpq1/cecpq1.cpp
@@ -27,7 +27,7 @@ void CECPQ1_accept(uint8_t shared_key[CECPQ1_SHARED_KEY_BYTES],
const uint8_t received[CECPQ1_OFFER_BYTES],
RandomNumberGenerator& rng)
{
- secure_vector<byte> x25519_key = rng.random_vec(32);
+ secure_vector<uint8_t> x25519_key = rng.random_vec(32);
curve25519_basepoint(send, x25519_key.data());
diff --git a/src/lib/pubkey/curve25519/curve25519.cpp b/src/lib/pubkey/curve25519/curve25519.cpp
index 7c3dea0f3..4908bf46f 100644
--- a/src/lib/pubkey/curve25519/curve25519.cpp
+++ b/src/lib/pubkey/curve25519/curve25519.cpp
@@ -14,7 +14,7 @@ namespace Botan {
void curve25519_basepoint(uint8_t mypublic[32], const uint8_t secret[32])
{
- const byte basepoint[32] = { 9 };
+ const uint8_t basepoint[32] = { 9 };
curve25519_donna(mypublic, secret, basepoint);
}
@@ -26,10 +26,10 @@ void size_check(size_t size, const char* thing)
throw Decoding_Error("Invalid size " + std::to_string(size) + " for Curve25519 " + thing);
}
-secure_vector<byte> curve25519(const secure_vector<byte>& secret,
- const byte pubval[32])
+secure_vector<uint8_t> curve25519(const secure_vector<uint8_t>& secret,
+ const uint8_t pubval[32])
{
- secure_vector<byte> out(32);
+ secure_vector<uint8_t> out(32);
curve25519_donna(out.data(), secret.data(), pubval);
return out;
}
@@ -47,7 +47,7 @@ bool Curve25519_PublicKey::check_key(RandomNumberGenerator&, bool) const
}
Curve25519_PublicKey::Curve25519_PublicKey(const AlgorithmIdentifier&,
- const std::vector<byte>& key_bits)
+ const std::vector<uint8_t>& key_bits)
{
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
@@ -58,7 +58,7 @@ Curve25519_PublicKey::Curve25519_PublicKey(const AlgorithmIdentifier&,
size_check(m_public.size(), "public key");
}
-std::vector<byte> Curve25519_PublicKey::public_key_bits() const
+std::vector<uint8_t> Curve25519_PublicKey::public_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -75,7 +75,7 @@ Curve25519_PrivateKey::Curve25519_PrivateKey(RandomNumberGenerator& rng)
}
Curve25519_PrivateKey::Curve25519_PrivateKey(const AlgorithmIdentifier&,
- const secure_vector<byte>& key_bits)
+ const secure_vector<uint8_t>& key_bits)
{
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
@@ -88,7 +88,7 @@ Curve25519_PrivateKey::Curve25519_PrivateKey(const AlgorithmIdentifier&,
size_check(m_private.size(), "private key");
}
-secure_vector<byte> Curve25519_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> Curve25519_PrivateKey::private_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -105,7 +105,7 @@ bool Curve25519_PrivateKey::check_key(RandomNumberGenerator&, bool) const
return public_point == m_public;
}
-secure_vector<byte> Curve25519_PrivateKey::agree(const byte w[], size_t w_len) const
+secure_vector<uint8_t> Curve25519_PrivateKey::agree(const uint8_t w[], size_t w_len) const
{
size_check(w_len, "public value");
return curve25519(m_private, w);
@@ -124,7 +124,7 @@ class Curve25519_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
PK_Ops::Key_Agreement_with_KDF(kdf),
m_key(key) {}
- secure_vector<byte> raw_agree(const byte w[], size_t w_len) override
+ secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override
{
return m_key.agree(w, w_len);
}
diff --git a/src/lib/pubkey/curve25519/curve25519.h b/src/lib/pubkey/curve25519/curve25519.h
index 68f3cb387..43e998df6 100644
--- a/src/lib/pubkey/curve25519/curve25519.h
+++ b/src/lib/pubkey/curve25519/curve25519.h
@@ -25,9 +25,9 @@ class BOTAN_DLL Curve25519_PublicKey : public virtual Public_Key
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
- std::vector<byte> public_value() const { return m_public; }
+ std::vector<uint8_t> public_value() const { return m_public; }
/**
* Create a Curve25519 Public Key.
@@ -35,24 +35,24 @@ class BOTAN_DLL Curve25519_PublicKey : public virtual Public_Key
* @param key_bits DER encoded public key bits
*/
Curve25519_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
/**
* Create a Curve25519 Public Key.
* @param pub 32-byte raw public key
*/
- explicit Curve25519_PublicKey(const std::vector<byte>& pub) : m_public(pub) {}
+ explicit Curve25519_PublicKey(const std::vector<uint8_t>& pub) : m_public(pub) {}
/**
* Create a Curve25519 Public Key.
* @param pub 32-byte raw public key
*/
- explicit Curve25519_PublicKey(const secure_vector<byte>& pub) :
+ explicit Curve25519_PublicKey(const secure_vector<uint8_t>& pub) :
m_public(pub.begin(), pub.end()) {}
protected:
Curve25519_PublicKey() {}
- std::vector<byte> m_public;
+ std::vector<uint8_t> m_public;
};
class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey,
@@ -66,7 +66,7 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey,
* @param key_bits PKCS #8 structure
*/
Curve25519_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Generate a private key.
@@ -78,15 +78,15 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey,
* Construct a private key from the specified parameters.
* @param secret_key DER encoded private key bits
*/
- explicit Curve25519_PrivateKey(const secure_vector<byte>& secret_key);
+ explicit Curve25519_PrivateKey(const secure_vector<uint8_t>& secret_key);
- std::vector<byte> public_value() const override { return Curve25519_PublicKey::public_value(); }
+ std::vector<uint8_t> public_value() const override { return Curve25519_PublicKey::public_value(); }
- secure_vector<byte> agree(const byte w[], size_t w_len) const;
+ secure_vector<uint8_t> agree(const uint8_t w[], size_t w_len) const;
- const secure_vector<byte>& get_x() const { return m_private; }
+ const secure_vector<uint8_t>& get_x() const { return m_private; }
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
bool check_key(RandomNumberGenerator& rng, bool strong) const override;
@@ -96,7 +96,7 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey,
const std::string& provider) const override;
private:
- secure_vector<byte> m_private;
+ secure_vector<uint8_t> m_private;
};
/*
diff --git a/src/lib/pubkey/curve25519/donna.cpp b/src/lib/pubkey/curve25519/donna.cpp
index 22400015f..89f3fbc4a 100644
--- a/src/lib/pubkey/curve25519/donna.cpp
+++ b/src/lib/pubkey/curve25519/donna.cpp
@@ -35,8 +35,8 @@
namespace Botan {
-typedef byte u8;
-typedef u64bit limb;
+typedef uint8_t u8;
+typedef uint64_t limb;
typedef limb felem[5];
typedef struct
@@ -214,7 +214,7 @@ static inline void fsquare_times(felem output, const felem in, limb count) {
/* Load a little-endian 64-bit number */
static limb
load_limb(const u8 *in) {
- return load_le<u64bit>(in, 0);
+ return load_le<uint64_t>(in, 0);
}
static void
diff --git a/src/lib/pubkey/dh/dh.cpp b/src/lib/pubkey/dh/dh.cpp
index 8c7fdd289..25c5f5cf4 100644
--- a/src/lib/pubkey/dh/dh.cpp
+++ b/src/lib/pubkey/dh/dh.cpp
@@ -25,7 +25,7 @@ DH_PublicKey::DH_PublicKey(const DL_Group& grp, const BigInt& y1)
/*
* Return the public value for key agreement
*/
-std::vector<byte> DH_PublicKey::public_value() const
+std::vector<uint8_t> DH_PublicKey::public_value() const
{
return unlock(BigInt::encode_1363(m_y, group_p().bytes()));
}
@@ -59,7 +59,7 @@ DH_PrivateKey::DH_PrivateKey(RandomNumberGenerator& rng,
* Load a DH private key
*/
DH_PrivateKey::DH_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
{
if(m_y == 0)
@@ -69,7 +69,7 @@ DH_PrivateKey::DH_PrivateKey(const AlgorithmIdentifier& alg_id,
/*
* Return the public value for key agreement
*/
-std::vector<byte> DH_PrivateKey::public_value() const
+std::vector<uint8_t> DH_PrivateKey::public_value() const
{
return DH_PublicKey::public_value();
}
@@ -93,7 +93,7 @@ class DH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
[this](const BigInt& k) { return m_powermod_x_p(inverse_mod(k, m_p)); })
{}
- secure_vector<byte> raw_agree(const byte w[], size_t w_len) override;
+ secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override;
private:
const BigInt& m_p;
@@ -101,7 +101,7 @@ class DH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
Blinder m_blinder;
};
-secure_vector<byte> DH_KA_Operation::raw_agree(const byte w[], size_t w_len)
+secure_vector<uint8_t> DH_KA_Operation::raw_agree(const uint8_t w[], size_t w_len)
{
BigInt input = BigInt::decode(w, w_len);
diff --git a/src/lib/pubkey/dh/dh.h b/src/lib/pubkey/dh/dh.h
index 3b70d7149..d5e86d154 100644
--- a/src/lib/pubkey/dh/dh.h
+++ b/src/lib/pubkey/dh/dh.h
@@ -20,7 +20,7 @@ class BOTAN_DLL DH_PublicKey : public virtual DL_Scheme_PublicKey
public:
std::string algo_name() const override { return "DH"; }
- std::vector<byte> public_value() const;
+ std::vector<uint8_t> public_value() const;
DL_Group::Format group_format() const override { return DL_Group::ANSI_X9_42; }
@@ -30,7 +30,7 @@ class BOTAN_DLL DH_PublicKey : public virtual DL_Scheme_PublicKey
* @param key_bits DER encoded public key bits
*/
DH_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_42) {}
/**
@@ -51,7 +51,7 @@ class BOTAN_DLL DH_PrivateKey : public DH_PublicKey,
public virtual DL_Scheme_PrivateKey
{
public:
- std::vector<byte> public_value() const override;
+ std::vector<uint8_t> public_value() const override;
/**
* Load a private key.
@@ -59,7 +59,7 @@ class BOTAN_DLL DH_PrivateKey : public DH_PublicKey,
* @param key_bits PKCS #8 structure
*/
DH_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Create a private key.
diff --git a/src/lib/pubkey/dl_algo/dl_algo.cpp b/src/lib/pubkey/dl_algo/dl_algo.cpp
index 8e885d318..ac6637e29 100644
--- a/src/lib/pubkey/dl_algo/dl_algo.cpp
+++ b/src/lib/pubkey/dl_algo/dl_algo.cpp
@@ -29,13 +29,13 @@ AlgorithmIdentifier DL_Scheme_PublicKey::algorithm_identifier() const
m_group.DER_encode(group_format()));
}
-std::vector<byte> DL_Scheme_PublicKey::public_key_bits() const
+std::vector<uint8_t> DL_Scheme_PublicKey::public_key_bits() const
{
return DER_Encoder().encode(m_y).get_contents_unlocked();
}
DL_Scheme_PublicKey::DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits,
+ const std::vector<uint8_t>& key_bits,
DL_Group::Format format)
{
m_group.BER_decode(alg_id.parameters, format);
@@ -43,13 +43,13 @@ DL_Scheme_PublicKey::DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
BER_Decoder(key_bits).decode(m_y);
}
-secure_vector<byte> DL_Scheme_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> DL_Scheme_PrivateKey::private_key_bits() const
{
return DER_Encoder().encode(m_x).get_contents();
}
DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits,
+ const secure_vector<uint8_t>& key_bits,
DL_Group::Format format)
{
m_group.BER_decode(alg_id.parameters, format);
diff --git a/src/lib/pubkey/dl_algo/dl_algo.h b/src/lib/pubkey/dl_algo/dl_algo.h
index 40c4a1fab..044aae2e6 100644
--- a/src/lib/pubkey/dl_algo/dl_algo.h
+++ b/src/lib/pubkey/dl_algo/dl_algo.h
@@ -23,7 +23,7 @@ class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
/**
* Get the DL domain parameters of this key.
@@ -70,7 +70,7 @@ class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key
* @param group_format the underlying groups encoding format
*/
DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits,
+ const std::vector<uint8_t>& key_bits,
DL_Group::Format group_format);
protected:
@@ -102,7 +102,7 @@ class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
*/
const BigInt& get_x() const { return m_x; }
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
/**
* Create a private key.
@@ -111,7 +111,7 @@ class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
* @param group_format the underlying groups encoding format
*/
DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits,
+ const secure_vector<uint8_t>& key_bits,
DL_Group::Format group_format);
protected:
diff --git a/src/lib/pubkey/dl_group/dl_group.cpp b/src/lib/pubkey/dl_group/dl_group.cpp
index 40660e62a..0f4985eb9 100644
--- a/src/lib/pubkey/dl_group/dl_group.cpp
+++ b/src/lib/pubkey/dl_group/dl_group.cpp
@@ -83,7 +83,7 @@ DL_Group::DL_Group(RandomNumberGenerator& rng,
* DL_Group Constructor
*/
DL_Group::DL_Group(RandomNumberGenerator& rng,
- const std::vector<byte>& seed,
+ const std::vector<uint8_t>& seed,
size_t pbits, size_t qbits)
{
if(!generate_dsa_primes(rng, m_p, m_q, pbits, qbits, seed))
@@ -193,7 +193,7 @@ const BigInt& DL_Group::get_q() const
/*
* DER encode the parameters
*/
-std::vector<byte> DL_Group::DER_encode(Format format) const
+std::vector<uint8_t> DL_Group::DER_encode(Format format) const
{
init_check();
@@ -238,7 +238,7 @@ std::vector<byte> DL_Group::DER_encode(Format format) const
*/
std::string DL_Group::PEM_encode(Format format) const
{
- const std::vector<byte> encoding = DER_encode(format);
+ const std::vector<uint8_t> encoding = DER_encode(format);
if(format == PKCS_3)
return PEM_Code::encode(encoding, "DH PARAMETERS");
@@ -253,7 +253,7 @@ std::string DL_Group::PEM_encode(Format format) const
/*
* Decode BER encoded parameters
*/
-void DL_Group::BER_decode(const std::vector<byte>& data,
+void DL_Group::BER_decode(const std::vector<uint8_t>& data,
Format format)
{
BigInt new_p, new_q, new_g;
diff --git a/src/lib/pubkey/dl_group/dl_group.h b/src/lib/pubkey/dl_group/dl_group.h
index 8bdd205da..39ad9b954 100644
--- a/src/lib/pubkey/dl_group/dl_group.h
+++ b/src/lib/pubkey/dl_group/dl_group.h
@@ -78,14 +78,14 @@ class BOTAN_DLL DL_Group
* @param format the encoding format
* @return string holding the DER encoded group
*/
- std::vector<byte> DER_encode(Format format) const;
+ std::vector<uint8_t> DER_encode(Format format) const;
/**
* Decode a DER/BER encoded group into this instance.
* @param ber a vector containing the DER/BER encoded group
* @param format the format of the encoded group
*/
- void BER_decode(const std::vector<byte>& ber,
+ void BER_decode(const std::vector<uint8_t>& ber,
Format format);
/**
@@ -134,7 +134,7 @@ class BOTAN_DLL DL_Group
* @param qbits the desired bit size of the prime q.
*/
DL_Group(RandomNumberGenerator& rng,
- const std::vector<byte>& seed,
+ const std::vector<uint8_t>& seed,
size_t pbits = 1024, size_t qbits = 0);
/**
diff --git a/src/lib/pubkey/dlies/dlies.cpp b/src/lib/pubkey/dlies/dlies.cpp
index 09f24adb7..ca91a0fd4 100644
--- a/src/lib/pubkey/dlies/dlies.cpp
+++ b/src/lib/pubkey/dlies/dlies.cpp
@@ -41,7 +41,7 @@ DLIES_Encryptor::DLIES_Encryptor(const DH_PrivateKey& own_priv_key,
BOTAN_ASSERT_NONNULL(mac);
}
-std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length,
+std::vector<uint8_t> DLIES_Encryptor::enc(const uint8_t in[], size_t length,
RandomNumberGenerator&) const
{
if(m_other_pub_key.empty())
@@ -54,14 +54,14 @@ std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length,
// derive secret key from secret value
const size_t required_key_length = m_cipher ? m_cipher_key_len + m_mac_keylen : length + m_mac_keylen;
- const secure_vector<byte> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of());
+ const secure_vector<uint8_t> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of());
if(secret_keys.size() != required_key_length)
{
throw Encoding_Error("DLIES: KDF did not provide sufficient output");
}
- secure_vector<byte> ciphertext(in, in + length);
+ secure_vector<uint8_t> ciphertext(in, in + length);
const size_t cipher_key_len = m_cipher ? m_cipher_key_len : length;
if(m_cipher)
@@ -83,10 +83,10 @@ std::vector<byte> DLIES_Encryptor::enc(const byte in[], size_t length,
// calculate MAC
m_mac->set_key(secret_keys.data() + cipher_key_len, m_mac_keylen);
- secure_vector<byte> tag = m_mac->process(ciphertext);
+ secure_vector<uint8_t> tag = m_mac->process(ciphertext);
// out = (ephemeral) public key + ciphertext + tag
- secure_vector<byte> out(m_own_pub_key.size() + ciphertext.size() + tag.size());
+ secure_vector<uint8_t> out(m_own_pub_key.size() + ciphertext.size() + tag.size());
buffer_insert(out, 0, m_own_pub_key);
buffer_insert(out, 0 + m_own_pub_key.size(), ciphertext);
buffer_insert(out, 0 + m_own_pub_key.size() + ciphertext.size(), tag);
@@ -140,8 +140,8 @@ DLIES_Decryptor::DLIES_Decryptor(const DH_PrivateKey& own_priv_key,
DLIES_Decryptor(own_priv_key, rng, kdf, nullptr, 0, mac, mac_key_length)
{}
-secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask,
- const byte msg[], size_t length) const
+secure_vector<uint8_t> DLIES_Decryptor::do_decrypt(uint8_t& valid_mask,
+ const uint8_t msg[], size_t length) const
{
if(length < m_pub_key_size + m_mac->output_length())
{
@@ -149,7 +149,7 @@ secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask,
}
// calculate secret value
- std::vector<byte> other_pub_key(msg, msg + m_pub_key_size);
+ std::vector<uint8_t> other_pub_key(msg, msg + m_pub_key_size);
const SymmetricKey secret_value = m_ka.derive_key(0, other_pub_key);
const size_t ciphertext_len = length - m_pub_key_size - m_mac->output_length();
@@ -157,24 +157,24 @@ secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask,
// derive secret key from secret value
const size_t required_key_length = cipher_key_len + m_mac_keylen;
- secure_vector<byte> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of());
+ secure_vector<uint8_t> secret_keys = m_kdf->derive_key(required_key_length, secret_value.bits_of());
if(secret_keys.size() != required_key_length)
{
throw Encoding_Error("DLIES: KDF did not provide sufficient output");
}
- secure_vector<byte> ciphertext(msg + m_pub_key_size, msg + m_pub_key_size + ciphertext_len);
+ secure_vector<uint8_t> ciphertext(msg + m_pub_key_size, msg + m_pub_key_size + ciphertext_len);
// calculate MAC
m_mac->set_key(secret_keys.data() + cipher_key_len, m_mac_keylen);
- secure_vector<byte> calculated_tag = m_mac->process(ciphertext);
+ secure_vector<uint8_t> calculated_tag = m_mac->process(ciphertext);
// calculated tag == received tag ?
- secure_vector<byte> tag(msg + m_pub_key_size + ciphertext_len,
+ secure_vector<uint8_t> tag(msg + m_pub_key_size + ciphertext_len,
msg + m_pub_key_size + ciphertext_len + m_mac->output_length());
- valid_mask = CT::expand_mask<byte>(same_mem(tag.data(), calculated_tag.data(), tag.size()));
+ valid_mask = CT::expand_mask<uint8_t>(same_mem(tag.data(), calculated_tag.data(), tag.size()));
// decrypt
if(m_cipher)
@@ -204,7 +204,7 @@ secure_vector<byte> DLIES_Decryptor::do_decrypt(byte& valid_mask,
}
else
{
- return secure_vector<byte>();
+ return secure_vector<uint8_t>();
}
}
else
diff --git a/src/lib/pubkey/dlies/dlies.h b/src/lib/pubkey/dlies/dlies.h
index 6e56c3da5..54b8f3f48 100644
--- a/src/lib/pubkey/dlies/dlies.h
+++ b/src/lib/pubkey/dlies/dlies.h
@@ -62,7 +62,7 @@ class BOTAN_DLL DLIES_Encryptor : public PK_Encryptor
size_t mac_key_len = 20);
// Set the other parties public key
- inline void set_other_key(const std::vector<byte>& other_pub_key)
+ inline void set_other_key(const std::vector<uint8_t>& other_pub_key)
{
m_other_pub_key = other_pub_key;
}
@@ -74,13 +74,13 @@ class BOTAN_DLL DLIES_Encryptor : public PK_Encryptor
}
private:
- std::vector<byte> enc(const byte[], size_t,
+ std::vector<uint8_t> enc(const uint8_t[], size_t,
RandomNumberGenerator&) const override;
size_t maximum_input_size() const override;
- std::vector<byte> m_other_pub_key;
- std::vector<byte> m_own_pub_key;
+ std::vector<uint8_t> m_other_pub_key;
+ std::vector<uint8_t> m_own_pub_key;
PK_Key_Agreement m_ka;
std::unique_ptr<KDF> m_kdf;
std::unique_ptr<Cipher_Mode> m_cipher;
@@ -141,8 +141,8 @@ class BOTAN_DLL DLIES_Decryptor : public PK_Decryptor
}
private:
- secure_vector<byte> do_decrypt(byte& valid_mask,
- const byte in[], size_t in_len) const override;
+ secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_len) const override;
const size_t m_pub_key_size;
PK_Key_Agreement m_ka;
diff --git a/src/lib/pubkey/dsa/dsa.cpp b/src/lib/pubkey/dsa/dsa.cpp
index f6c5989db..c419eec97 100644
--- a/src/lib/pubkey/dsa/dsa.cpp
+++ b/src/lib/pubkey/dsa/dsa.cpp
@@ -50,7 +50,7 @@ DSA_PrivateKey::DSA_PrivateKey(RandomNumberGenerator& rng,
}
DSA_PrivateKey::DSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_57)
{
m_y = power_mod(group_g(), m_x, group_p());
@@ -90,7 +90,7 @@ class DSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
size_t max_input_bits() const override { return m_q.bits(); }
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
const BigInt& m_q;
@@ -100,8 +100,8 @@ class DSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
std::string m_emsa;
};
-secure_vector<byte>
-DSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+DSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
BigInt i(msg, msg_len);
@@ -154,8 +154,8 @@ class DSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const BigInt& m_q;
const BigInt& m_y;
@@ -164,8 +164,8 @@ class DSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
Modular_Reducer m_mod_p, m_mod_q;
};
-bool DSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len)
+bool DSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len)
{
if(sig_len != 2*m_q.bytes() || msg_len > m_q.bytes())
return false;
diff --git a/src/lib/pubkey/dsa/dsa.h b/src/lib/pubkey/dsa/dsa.h
index d26642ed4..117853907 100644
--- a/src/lib/pubkey/dsa/dsa.h
+++ b/src/lib/pubkey/dsa/dsa.h
@@ -30,7 +30,7 @@ class BOTAN_DLL DSA_PublicKey : public virtual DL_Scheme_PublicKey
* @param key_bits DER encoded public key bits
*/
DSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_57)
{
}
@@ -62,7 +62,7 @@ class BOTAN_DLL DSA_PrivateKey : public DSA_PublicKey,
* @param key_bits PKCS#8 structure
*/
DSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Create a private key.
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp
index c264d7314..a5262fd5e 100644
--- a/src/lib/pubkey/ec_group/ec_group.cpp
+++ b/src/lib/pubkey/ec_group/ec_group.cpp
@@ -33,7 +33,7 @@ EC_Group::EC_Group(const std::string& str)
try
{
- std::vector<byte> ber =
+ std::vector<uint8_t> ber =
unlock(PEM_Code::decode_check_label(str, "EC PARAMETERS"));
*this = EC_Group(ber);
@@ -44,7 +44,7 @@ EC_Group::EC_Group(const std::string& str)
}
}
-EC_Group::EC_Group(const std::vector<byte>& ber_data)
+EC_Group::EC_Group(const std::vector<uint8_t>& ber_data)
{
BER_Decoder ber(ber_data);
BER_Object obj = ber.get_next_object();
@@ -60,7 +60,7 @@ EC_Group::EC_Group(const std::vector<byte>& ber_data)
else if(obj.type_tag == SEQUENCE)
{
BigInt p, a, b;
- std::vector<byte> sv_base_point;
+ std::vector<uint8_t> sv_base_point;
BER_Decoder(ber_data)
.start_cons(SEQUENCE)
@@ -87,7 +87,7 @@ EC_Group::EC_Group(const std::vector<byte>& ber_data)
throw Decoding_Error("Unexpected tag while decoding ECC domain params");
}
-std::vector<byte>
+std::vector<uint8_t>
EC_Group::DER_encode(EC_Group_Encoding form) const
{
if(form == EC_DOMPAR_ENC_EXPLICIT)
@@ -126,7 +126,7 @@ EC_Group::DER_encode(EC_Group_Encoding form) const
std::string EC_Group::PEM_encode() const
{
- const std::vector<byte> der = DER_encode(EC_DOMPAR_ENC_EXPLICIT);
+ const std::vector<uint8_t> der = DER_encode(EC_DOMPAR_ENC_EXPLICIT);
return PEM_Code::encode(der, "EC PARAMETERS");
}
diff --git a/src/lib/pubkey/ec_group/ec_group.h b/src/lib/pubkey/ec_group/ec_group.h
index a03b97a68..b623a876d 100644
--- a/src/lib/pubkey/ec_group/ec_group.h
+++ b/src/lib/pubkey/ec_group/ec_group.h
@@ -54,7 +54,7 @@ class BOTAN_DLL EC_Group
* Decode a BER encoded ECC domain parameter set
* @param ber_encoding the bytes of the BER encoding
*/
- explicit EC_Group(const std::vector<byte>& ber_encoding);
+ explicit EC_Group(const std::vector<uint8_t>& ber_encoding);
/**
* Create an EC domain by OID (or throw if unknown)
@@ -74,7 +74,7 @@ class BOTAN_DLL EC_Group
* @param form of encoding to use
* @returns bytes encododed as DER
*/
- std::vector<byte> DER_encode(EC_Group_Encoding form) const;
+ std::vector<uint8_t> DER_encode(EC_Group_Encoding form) const;
/**
* Return the PEM encoding (always in explicit form)
diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp
index 00ddddda1..cb0af42eb 100644
--- a/src/lib/pubkey/ecc_key/ecc_key.cpp
+++ b/src/lib/pubkey/ecc_key/ecc_key.cpp
@@ -38,7 +38,7 @@ EC_PublicKey::EC_PublicKey(const EC_Group& dom_par,
}
EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
m_domain_params{EC_Group(alg_id.parameters)},
m_public_key{OS2ECP(key_bits, domain().get_curve())},
m_domain_encoding{EC_DOMPAR_ENC_EXPLICIT}
@@ -55,7 +55,7 @@ AlgorithmIdentifier EC_PublicKey::algorithm_identifier() const
return AlgorithmIdentifier(get_oid(), DER_domain());
}
-std::vector<byte> EC_PublicKey::public_key_bits() const
+std::vector<uint8_t> EC_PublicKey::public_key_bits() const
{
return unlock(EC2OSP(public_point(), PointGFp::COMPRESSED));
}
@@ -110,7 +110,7 @@ EC_PrivateKey::EC_PrivateKey(RandomNumberGenerator& rng,
"Generated public key point was on the curve");
}
-secure_vector<byte> EC_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> EC_PrivateKey::private_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -122,14 +122,14 @@ secure_vector<byte> EC_PrivateKey::private_key_bits() const
}
EC_PrivateKey::EC_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits,
+ const secure_vector<uint8_t>& key_bits,
bool with_modular_inverse)
{
m_domain_params = EC_Group(alg_id.parameters);
m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT;
OID key_parameters;
- secure_vector<byte> public_key_bits;
+ secure_vector<uint8_t> public_key_bits;
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
diff --git a/src/lib/pubkey/ecc_key/ecc_key.h b/src/lib/pubkey/ecc_key/ecc_key.h
index 06f100c1c..d4ce6c0e7 100644
--- a/src/lib/pubkey/ecc_key/ecc_key.h
+++ b/src/lib/pubkey/ecc_key/ecc_key.h
@@ -43,7 +43,7 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
* @param key_bits DER encoded public key bits
*/
EC_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
/**
* Get the public point of this key.
@@ -55,7 +55,7 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
bool check_key(RandomNumberGenerator& rng,
bool strong) const override;
@@ -78,7 +78,7 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
* Return the DER encoding of this keys domain in whatever format
* is preset for this particular key
*/
- std::vector<byte> DER_domain() const
+ std::vector<uint8_t> DER_domain() const
{ return domain().DER_encode(domain_format()); }
/**
@@ -129,10 +129,10 @@ class BOTAN_DLL EC_PrivateKey : public virtual EC_PublicKey,
* multiplying directly with x (as in ECDSA).
*/
EC_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits,
+ const secure_vector<uint8_t>& key_bits,
bool with_modular_inverse=false);
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
/**
* Get the private key value of this key object.
diff --git a/src/lib/pubkey/ecdh/ecdh.cpp b/src/lib/pubkey/ecdh/ecdh.cpp
index 1bdf2c209..32914be2e 100644
--- a/src/lib/pubkey/ecdh/ecdh.cpp
+++ b/src/lib/pubkey/ecdh/ecdh.cpp
@@ -35,7 +35,7 @@ class ECDH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
m_l_times_priv = inverse_mod(m_cofactor, key.domain().get_order()) * key.private_value();
}
- secure_vector<byte> raw_agree(const byte w[], size_t w_len) override
+ secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override
{
PointGFp point = OS2ECP(w, w_len, m_curve);
// TODO: add blinding
diff --git a/src/lib/pubkey/ecdh/ecdh.h b/src/lib/pubkey/ecdh/ecdh.h
index 09c3fc721..7524a80ff 100644
--- a/src/lib/pubkey/ecdh/ecdh.h
+++ b/src/lib/pubkey/ecdh/ecdh.h
@@ -26,7 +26,7 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
ECDH_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
EC_PublicKey(alg_id, key_bits) {}
/**
@@ -47,13 +47,13 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey
/**
* @return public point value
*/
- std::vector<byte> public_value() const
+ std::vector<uint8_t> public_value() const
{ return unlock(EC2OSP(public_point(), PointGFp::UNCOMPRESSED)); }
/**
* @return public point value
*/
- std::vector<byte> public_value(PointGFp::Compression_Type type) const
+ std::vector<uint8_t> public_value(PointGFp::Compression_Type type) const
{ return unlock(EC2OSP(public_point(), type)); }
protected:
@@ -75,7 +75,7 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey,
* @param key_bits X.509 subject public key info structure
*/
ECDH_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits) {}
/**
@@ -89,10 +89,10 @@ class BOTAN_DLL ECDH_PrivateKey : public ECDH_PublicKey,
const BigInt& x = 0) :
EC_PrivateKey(rng, domain, x) {}
- std::vector<byte> public_value() const override
+ std::vector<uint8_t> public_value() const override
{ return ECDH_PublicKey::public_value(PointGFp::UNCOMPRESSED); }
- std::vector<byte> public_value(PointGFp::Compression_Type type) const
+ std::vector<uint8_t> public_value(PointGFp::Compression_Type type) const
{ return ECDH_PublicKey::public_value(type); }
std::unique_ptr<PK_Ops::Key_Agreement>
diff --git a/src/lib/pubkey/ecdsa/ecdsa.cpp b/src/lib/pubkey/ecdsa/ecdsa.cpp
index 8a6dd840b..bb65fb138 100644
--- a/src/lib/pubkey/ecdsa/ecdsa.cpp
+++ b/src/lib/pubkey/ecdsa/ecdsa.cpp
@@ -58,7 +58,7 @@ class ECDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
size_t max_input_bits() const override { return m_order.bits(); }
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
@@ -69,8 +69,8 @@ class ECDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
std::string m_emsa;
};
-secure_vector<byte>
-ECDSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+ECDSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
const BigInt m(msg, msg_len);
@@ -113,8 +113,8 @@ class ECDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const PointGFp& m_base_point;
const PointGFp& m_public_point;
@@ -123,8 +123,8 @@ class ECDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
Modular_Reducer m_mod_order;
};
-bool ECDSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len)
+bool ECDSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len)
{
if(sig_len != m_order.bytes()*2)
return false;
diff --git a/src/lib/pubkey/ecdsa/ecdsa.h b/src/lib/pubkey/ecdsa/ecdsa.h
index d6e08c42f..21535a2f4 100644
--- a/src/lib/pubkey/ecdsa/ecdsa.h
+++ b/src/lib/pubkey/ecdsa/ecdsa.h
@@ -36,7 +36,7 @@ class BOTAN_DLL ECDSA_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
ECDSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
EC_PublicKey(alg_id, key_bits) {}
/**
@@ -71,7 +71,7 @@ class BOTAN_DLL ECDSA_PrivateKey : public ECDSA_PublicKey,
* @param key_bits PKCS #8 structure
*/
ECDSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits) {}
/**
diff --git a/src/lib/pubkey/ecgdsa/ecgdsa.cpp b/src/lib/pubkey/ecgdsa/ecgdsa.cpp
index 3740c3583..eb979cc1c 100644
--- a/src/lib/pubkey/ecgdsa/ecgdsa.cpp
+++ b/src/lib/pubkey/ecgdsa/ecgdsa.cpp
@@ -43,7 +43,7 @@ class ECGDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
{
}
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
size_t max_input_bits() const override { return m_order.bits(); }
@@ -55,8 +55,8 @@ class ECGDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
Modular_Reducer m_mod_order;
};
-secure_vector<byte>
-ECGDSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+ECGDSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
const BigInt m(msg, msg_len);
@@ -95,8 +95,8 @@ class ECGDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const PointGFp& m_base_point;
const PointGFp& m_public_point;
@@ -105,8 +105,8 @@ class ECGDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
Modular_Reducer m_mod_order;
};
-bool ECGDSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len)
+bool ECGDSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len)
{
if(sig_len != m_order.bytes()*2)
return false;
diff --git a/src/lib/pubkey/ecgdsa/ecgdsa.h b/src/lib/pubkey/ecgdsa/ecgdsa.h
index 5e0040fca..1d079bf38 100644
--- a/src/lib/pubkey/ecgdsa/ecgdsa.h
+++ b/src/lib/pubkey/ecgdsa/ecgdsa.h
@@ -34,7 +34,7 @@ class BOTAN_DLL ECGDSA_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
ECGDSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
EC_PublicKey(alg_id, key_bits) {}
/**
@@ -69,7 +69,7 @@ class BOTAN_DLL ECGDSA_PrivateKey : public ECGDSA_PublicKey,
* @param key_bits PKCS #8 structure
*/
ECGDSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits, true) {}
/**
diff --git a/src/lib/pubkey/ecies/ecies.cpp b/src/lib/pubkey/ecies/ecies.cpp
index b40d21251..84c1a8f3f 100644
--- a/src/lib/pubkey/ecies/ecies.cpp
+++ b/src/lib/pubkey/ecies/ecies.cpp
@@ -30,7 +30,7 @@ class ECIES_PrivateKey : public EC_PrivateKey, public PK_Key_Agreement_Key
{
}
- std::vector<byte> public_value() const override
+ std::vector<uint8_t> public_value() const override
{
return m_key.public_value();
}
@@ -61,7 +61,7 @@ class ECIES_ECDH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
{
}
- secure_vector<byte> raw_agree(const byte w[], size_t w_len) override
+ secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override
{
const CurveGFp& curve = m_key.domain().get_curve();
PointGFp point = OS2ECP(w, w_len, curve);
@@ -130,7 +130,7 @@ ECIES_KA_Operation::ECIES_KA_Operation(const PK_Key_Agreement_Key& private_key,
/**
* ECIES secret derivation according to ISO 18033-2
*/
-SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<byte>& eph_public_key_bin,
+SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<uint8_t>& eph_public_key_bin,
const PointGFp& other_public_key_point) const
{
if(other_public_key_point.is_zero())
@@ -148,7 +148,7 @@ SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<byte>& eph_publ
other_point *= m_params.domain().get_cofactor();
}
- secure_vector<byte> derivation_input;
+ secure_vector<uint8_t> derivation_input;
// ISO 18033: encryption step e / decryption step g
if(!m_params.single_hash_mode())
@@ -157,7 +157,7 @@ SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<byte>& eph_publ
}
// ISO 18033: encryption step f / decryption step h
- secure_vector<byte> other_public_key_bin = EC2OSP(other_point, static_cast<byte>(m_params.compression_type()));
+ secure_vector<uint8_t> other_public_key_bin = EC2OSP(other_point, static_cast<uint8_t>(m_params.compression_type()));
// Note: the argument `m_params.secret_length()` passed for `key_len` will only be used by providers because
// "Raw" is passed to the `PK_Key_Agreement` if the implementation of botan is used.
const SymmetricKey peh = m_ka.derive_key(m_params.domain().get_order().bytes(), other_public_key_bin.data(), other_public_key_bin.size());
@@ -237,7 +237,7 @@ ECIES_Encryptor::ECIES_Encryptor(const PK_Key_Agreement_Key& private_key,
// ISO 18033: step d
// convert only if necessary; m_eph_public_key_bin has been initialized with the uncompressed format
m_eph_public_key_bin = unlock(EC2OSP(OS2ECP(m_eph_public_key_bin, m_params.domain().get_curve()),
- static_cast<byte>(ecies_params.compression_type())));
+ static_cast<uint8_t>(ecies_params.compression_type())));
}
}
@@ -253,7 +253,7 @@ ECIES_Encryptor::ECIES_Encryptor(RandomNumberGenerator& rng, const ECIES_System_
/*
* ECIES Encryption according to ISO 18033-2
*/
-std::vector<byte> ECIES_Encryptor::enc(const byte data[], size_t length, RandomNumberGenerator&) const
+std::vector<uint8_t> ECIES_Encryptor::enc(const uint8_t data[], size_t length, RandomNumberGenerator&) const
{
if(m_other_point.is_zero())
{
@@ -271,14 +271,14 @@ std::vector<byte> ECIES_Encryptor::enc(const byte data[], size_t length, RandomN
{
cipher->start(m_iv.bits_of());
}
- secure_vector<byte> encrypted_data(data, data + length);
+ secure_vector<uint8_t> encrypted_data(data, data + length);
cipher->finish(encrypted_data);
// concat elements
std::unique_ptr<MessageAuthenticationCode> mac = m_params.create_mac();
BOTAN_ASSERT(mac != nullptr, "MAC is found");
- secure_vector<byte> out(m_eph_public_key_bin.size() + encrypted_data.size() + mac->output_length());
+ secure_vector<uint8_t> out(m_eph_public_key_bin.size() + encrypted_data.size() + mac->output_length());
buffer_insert(out, 0, m_eph_public_key_bin);
buffer_insert(out, m_eph_public_key_bin.size(), encrypted_data);
@@ -317,7 +317,7 @@ ECIES_Decryptor::ECIES_Decryptor(const PK_Key_Agreement_Key& key,
/**
* ECIES Decryption according to ISO 18033-2
*/
-secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[], size_t in_len) const
+secure_vector<uint8_t> ECIES_Decryptor::do_decrypt(uint8_t& valid_mask, const uint8_t in[], size_t in_len) const
{
size_t point_size = m_params.domain().get_curve().get_p().bytes();
if(m_params.compression_type() != PointGFp::COMPRESSED)
@@ -335,9 +335,9 @@ secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[
}
// extract data
- const std::vector<byte> other_public_key_bin(in, in + point_size); // the received (ephemeral) public key
- const std::vector<byte> encrypted_data(in + point_size, in + in_len - mac->output_length());
- const std::vector<byte> mac_data(in + in_len - mac->output_length(), in + in_len);
+ const std::vector<uint8_t> other_public_key_bin(in, in + point_size); // the received (ephemeral) public key
+ const std::vector<uint8_t> encrypted_data(in + point_size, in + in_len - mac->output_length());
+ const std::vector<uint8_t> mac_data(in + in_len - mac->output_length(), in + in_len);
// ISO 18033: step a
PointGFp other_public_key = OS2ECP(other_public_key_bin, m_params.domain().get_curve());
@@ -359,8 +359,8 @@ secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[
{
mac->update(m_label);
}
- const secure_vector<byte> calculated_mac = mac->final();
- valid_mask = CT::expand_mask<byte>(same_mem(mac_data.data(), calculated_mac.data(), mac_data.size()));
+ const secure_vector<uint8_t> calculated_mac = mac->final();
+ valid_mask = CT::expand_mask<uint8_t>(same_mem(mac_data.data(), calculated_mac.data(), mac_data.size()));
if(valid_mask)
{
@@ -378,7 +378,7 @@ secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[
{
// the decryption can fail:
// e.g. Integrity_Failure is thrown if GCM is used and the message does not have a valid tag
- secure_vector<byte> decrypted_data(encrypted_data.begin(), encrypted_data.end());
+ secure_vector<uint8_t> decrypted_data(encrypted_data.begin(), encrypted_data.end());
cipher->finish(decrypted_data);
return decrypted_data;
}
@@ -387,7 +387,7 @@ secure_vector<byte> ECIES_Decryptor::do_decrypt(byte& valid_mask, const byte in[
valid_mask = 0;
}
}
- return secure_vector<byte>();
+ return secure_vector<uint8_t>();
}
}
diff --git a/src/lib/pubkey/ecies/ecies.h b/src/lib/pubkey/ecies/ecies.h
index 3f7a2e48b..6daf5a641 100644
--- a/src/lib/pubkey/ecies/ecies.h
+++ b/src/lib/pubkey/ecies/ecies.h
@@ -198,7 +198,7 @@ class BOTAN_DLL ECIES_KA_Operation
* @param eph_public_key_bin the encoded (ephemeral) public key which belongs to the used (ephemeral) private key
* @param other_public_key_point public key point of the other party
*/
- SymmetricKey derive_secret(const std::vector<byte>& eph_public_key_bin,
+ SymmetricKey derive_secret(const std::vector<uint8_t>& eph_public_key_bin,
const PointGFp& other_public_key_point) const;
private:
@@ -244,11 +244,11 @@ class BOTAN_DLL ECIES_Encryptor : public PK_Encryptor
/// Set the label which is appended to the input for the message authentication code
inline void set_label(const std::string& label)
{
- m_label = std::vector<byte>(label.begin(), label.end());
+ m_label = std::vector<uint8_t>(label.begin(), label.end());
}
private:
- std::vector<byte> enc(const byte data[], size_t length, RandomNumberGenerator&) const override;
+ std::vector<uint8_t> enc(const uint8_t data[], size_t length, RandomNumberGenerator&) const override;
inline size_t maximum_input_size() const override
{
@@ -257,10 +257,10 @@ class BOTAN_DLL ECIES_Encryptor : public PK_Encryptor
const ECIES_KA_Operation m_ka;
const ECIES_System_Params m_params;
- std::vector<byte> m_eph_public_key_bin;
+ std::vector<uint8_t> m_eph_public_key_bin;
InitializationVector m_iv;
PointGFp m_other_point;
- std::vector<byte> m_label;
+ std::vector<uint8_t> m_label;
};
@@ -288,16 +288,16 @@ class BOTAN_DLL ECIES_Decryptor : public PK_Decryptor
/// Set the label which is appended to the input for the message authentication code
inline void set_label(const std::string& label)
{
- m_label = std::vector<byte>(label.begin(), label.end());
+ m_label = std::vector<uint8_t>(label.begin(), label.end());
}
private:
- secure_vector<byte> do_decrypt(byte& valid_mask, const byte in[], size_t in_len) const override;
+ secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask, const uint8_t in[], size_t in_len) const override;
const ECIES_KA_Operation m_ka;
const ECIES_System_Params m_params;
InitializationVector m_iv;
- std::vector<byte> m_label;
+ std::vector<uint8_t> m_label;
};
}
diff --git a/src/lib/pubkey/eckcdsa/eckcdsa.cpp b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
index 89b5925a2..778c0f833 100644
--- a/src/lib/pubkey/eckcdsa/eckcdsa.cpp
+++ b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
@@ -57,36 +57,36 @@ class ECKCDSA_Signature_Operation : public PK_Ops::Signature_with_EMSA
m_prefix.resize(HashFunction::create(hash_for_signature())->hash_block_size()); // use only the "hash input block size" leftmost bits
}
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
size_t max_input_bits() const override { return m_order.bits(); }
bool has_prefix() override { return true; }
- secure_vector<byte> message_prefix() const override { return m_prefix; }
+ secure_vector<uint8_t> message_prefix() const override { return m_prefix; }
private:
const BigInt& m_order;
Blinded_Point_Multiply m_base_point;
const BigInt& m_x;
Modular_Reducer m_mod_order;
- secure_vector<byte> m_prefix;
+ secure_vector<uint8_t> m_prefix;
};
-secure_vector<byte>
-ECKCDSA_Signature_Operation::raw_sign(const byte msg[], size_t,
+secure_vector<uint8_t>
+ECKCDSA_Signature_Operation::raw_sign(const uint8_t msg[], size_t,
RandomNumberGenerator& rng)
{
const BigInt k = BigInt::random_integer(rng, 1, m_order);
const PointGFp k_times_P = m_base_point.blinded_multiply(k, rng);
const BigInt k_times_P_x = k_times_P.get_affine_x();
- secure_vector<byte> to_be_hashed(k_times_P_x.bytes());
+ secure_vector<uint8_t> to_be_hashed(k_times_P_x.bytes());
k_times_P_x.binary_encode(to_be_hashed.data());
std::unique_ptr<EMSA> emsa(m_emsa->clone());
emsa->update(to_be_hashed.data(), to_be_hashed.size());
- secure_vector<byte> c = emsa->raw_data();
+ secure_vector<uint8_t> c = emsa->raw_data();
c = emsa->encoding_of(c, max_input_bits(), rng);
const BigInt r(c.data(), c.size());
@@ -98,7 +98,7 @@ ECKCDSA_Signature_Operation::raw_sign(const byte msg[], size_t,
const BigInt s = m_mod_order.multiply(m_x, k - w);
BOTAN_ASSERT(s != 0, "invalid s");
- secure_vector<byte> output = BigInt::encode_1363(r, c.size());
+ secure_vector<uint8_t> output = BigInt::encode_1363(r, c.size());
output += BigInt::encode_1363(s, m_order.bytes());
return output;
}
@@ -129,25 +129,25 @@ class ECKCDSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
}
bool has_prefix() override { return true; }
- secure_vector<byte> message_prefix() const override { return m_prefix; }
+ secure_vector<uint8_t> message_prefix() const override { return m_prefix; }
size_t max_input_bits() const override { return m_order.bits(); }
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const PointGFp& m_base_point;
const PointGFp& m_public_point;
const BigInt& m_order;
// FIXME: should be offered by curve
Modular_Reducer m_mod_order;
- secure_vector<byte> m_prefix;
+ secure_vector<uint8_t> m_prefix;
};
-bool ECKCDSA_Verification_Operation::verify(const byte msg[], size_t,
- const byte sig[], size_t sig_len)
+bool ECKCDSA_Verification_Operation::verify(const uint8_t msg[], size_t,
+ const uint8_t sig[], size_t sig_len)
{
const std::unique_ptr<HashFunction> hash = HashFunction::create(hash_for_signature());
//calculate size of r
@@ -157,7 +157,7 @@ bool ECKCDSA_Verification_Operation::verify(const byte msg[], size_t,
return false;
}
- secure_vector<byte> r(sig, sig + size_r);
+ secure_vector<uint8_t> r(sig, sig + size_r);
// check that 0 < s < q
const BigInt s(sig + size_r, m_order.bytes());
@@ -167,18 +167,18 @@ bool ECKCDSA_Verification_Operation::verify(const byte msg[], size_t,
return false;
}
- secure_vector<byte> r_xor_e(r);
+ secure_vector<uint8_t> r_xor_e(r);
xor_buf(r_xor_e, msg, r.size());
BigInt w(r_xor_e.data(), r_xor_e.size());
w = m_mod_order.reduce(w);
const PointGFp q = multi_exponentiate(m_base_point, w, m_public_point, s);
const BigInt q_x = q.get_affine_x();
- secure_vector<byte> c(q_x.bytes());
+ secure_vector<uint8_t> c(q_x.bytes());
q_x.binary_encode(c.data());
std::unique_ptr<EMSA> emsa(m_emsa->clone());
emsa->update(c.data(), c.size());
- secure_vector<byte> v = emsa->raw_data();
+ secure_vector<uint8_t> v = emsa->raw_data();
Null_RNG rng;
v = emsa->encoding_of(v, max_input_bits(), rng);
diff --git a/src/lib/pubkey/eckcdsa/eckcdsa.h b/src/lib/pubkey/eckcdsa/eckcdsa.h
index e29ff610c..21bfbdc3c 100644
--- a/src/lib/pubkey/eckcdsa/eckcdsa.h
+++ b/src/lib/pubkey/eckcdsa/eckcdsa.h
@@ -34,7 +34,7 @@ class BOTAN_DLL ECKCDSA_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
ECKCDSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
EC_PublicKey(alg_id, key_bits) {}
/**
@@ -69,7 +69,7 @@ class BOTAN_DLL ECKCDSA_PrivateKey : public ECKCDSA_PublicKey,
* @param key_bits PKCS #8 structure
*/
ECKCDSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits, true) {}
/**
diff --git a/src/lib/pubkey/elgamal/elgamal.cpp b/src/lib/pubkey/elgamal/elgamal.cpp
index 90534a430..b7ce643f1 100644
--- a/src/lib/pubkey/elgamal/elgamal.cpp
+++ b/src/lib/pubkey/elgamal/elgamal.cpp
@@ -40,7 +40,7 @@ ElGamal_PrivateKey::ElGamal_PrivateKey(RandomNumberGenerator& rng,
}
ElGamal_PrivateKey::ElGamal_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
{
m_y = power_mod(group_g(), m_x, group_p());
@@ -74,7 +74,7 @@ class ElGamal_Encryption_Operation : public PK_Ops::Encryption_with_EME
ElGamal_Encryption_Operation(const ElGamal_PublicKey& key, const std::string& eme);
- secure_vector<byte> raw_encrypt(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
@@ -93,8 +93,8 @@ ElGamal_Encryption_Operation::ElGamal_Encryption_Operation(const ElGamal_PublicK
m_mod_p = Modular_Reducer(p);
}
-secure_vector<byte>
-ElGamal_Encryption_Operation::raw_encrypt(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+ElGamal_Encryption_Operation::raw_encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
const BigInt& p = m_mod_p.get_modulus();
@@ -109,7 +109,7 @@ ElGamal_Encryption_Operation::raw_encrypt(const byte msg[], size_t msg_len,
BigInt a = m_powermod_g_p(k);
BigInt b = m_mod_p.multiply(m, m_powermod_y_p(k));
- secure_vector<byte> output(2*p.bytes());
+ secure_vector<uint8_t> output(2*p.bytes());
a.binary_encode(&output[p.bytes() - a.bytes()]);
b.binary_encode(&output[output.size() / 2 + (p.bytes() - b.bytes())]);
return output;
@@ -129,7 +129,7 @@ class ElGamal_Decryption_Operation : public PK_Ops::Decryption_with_EME
const std::string& eme,
RandomNumberGenerator& rng);
- secure_vector<byte> raw_decrypt(const byte msg[], size_t msg_len) override;
+ secure_vector<uint8_t> raw_decrypt(const uint8_t msg[], size_t msg_len) override;
private:
Fixed_Exponent_Power_Mod m_powermod_x_p;
Modular_Reducer m_mod_p;
@@ -149,8 +149,8 @@ ElGamal_Decryption_Operation::ElGamal_Decryption_Operation(const ElGamal_Private
{
}
-secure_vector<byte>
-ElGamal_Decryption_Operation::raw_decrypt(const byte msg[], size_t msg_len)
+secure_vector<uint8_t>
+ElGamal_Decryption_Operation::raw_decrypt(const uint8_t msg[], size_t msg_len)
{
const BigInt& p = m_mod_p.get_modulus();
diff --git a/src/lib/pubkey/elgamal/elgamal.h b/src/lib/pubkey/elgamal/elgamal.h
index 9ac4ea949..688232631 100644
--- a/src/lib/pubkey/elgamal/elgamal.h
+++ b/src/lib/pubkey/elgamal/elgamal.h
@@ -27,7 +27,7 @@ class BOTAN_DLL ElGamal_PublicKey : public virtual DL_Scheme_PublicKey
* @param key_bits DER encoded public key bits
*/
ElGamal_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits) :
+ const std::vector<uint8_t>& key_bits) :
DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
{}
@@ -62,7 +62,7 @@ class BOTAN_DLL ElGamal_PrivateKey : public ElGamal_PublicKey,
* @param key_bits PKCS #8 structure
*/
ElGamal_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Create a private key.
diff --git a/src/lib/pubkey/gost_3410/gost_3410.cpp b/src/lib/pubkey/gost_3410/gost_3410.cpp
index e8923c71a..ee263bb96 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.cpp
+++ b/src/lib/pubkey/gost_3410/gost_3410.cpp
@@ -15,14 +15,14 @@
namespace Botan {
-std::vector<byte> GOST_3410_PublicKey::public_key_bits() const
+std::vector<uint8_t> GOST_3410_PublicKey::public_key_bits() const
{
const BigInt x = public_point().get_affine_x();
const BigInt y = public_point().get_affine_y();
size_t part_size = std::max(x.bytes(), y.bytes());
- std::vector<byte> bits(2*part_size);
+ std::vector<uint8_t> bits(2*part_size);
x.binary_encode(&bits[part_size - x.bytes()]);
y.binary_encode(&bits[2*part_size - y.bytes()]);
@@ -39,7 +39,7 @@ std::vector<byte> GOST_3410_PublicKey::public_key_bits() const
AlgorithmIdentifier GOST_3410_PublicKey::algorithm_identifier() const
{
- std::vector<byte> params =
+ std::vector<uint8_t> params =
DER_Encoder().start_cons(SEQUENCE)
.encode(OID(domain().get_oid()))
.end_cons()
@@ -49,7 +49,7 @@ AlgorithmIdentifier GOST_3410_PublicKey::algorithm_identifier() const
}
GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits)
+ const std::vector<uint8_t>& key_bits)
{
OID ecc_param_id;
@@ -58,7 +58,7 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
m_domain_params = EC_Group(ecc_param_id);
- secure_vector<byte> bits;
+ secure_vector<uint8_t> bits;
BER_Decoder(key_bits).decode(bits, OCTET_STRING);
const size_t part_size = bits.size() / 2;
@@ -81,9 +81,9 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
namespace {
-BigInt decode_le(const byte msg[], size_t msg_len)
+BigInt decode_le(const uint8_t msg[], size_t msg_len)
{
- secure_vector<byte> msg_le(msg, msg + msg_len);
+ secure_vector<uint8_t> msg_le(msg, msg + msg_len);
for(size_t i = 0; i != msg_le.size() / 2; ++i)
std::swap(msg_le[i], msg_le[msg_le.size()-1-i]);
@@ -107,7 +107,7 @@ class GOST_3410_Signature_Operation : public PK_Ops::Signature_with_EMSA
size_t max_input_bits() const override { return m_order.bits(); }
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
@@ -117,8 +117,8 @@ class GOST_3410_Signature_Operation : public PK_Ops::Signature_with_EMSA
const BigInt& m_x;
};
-secure_vector<byte>
-GOST_3410_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+GOST_3410_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
BigInt k;
@@ -141,7 +141,7 @@ GOST_3410_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
if(r == 0 || s == 0)
throw Invalid_State("GOST 34.10: r == 0 || s == 0");
- secure_vector<byte> output(2*m_order.bytes());
+ secure_vector<uint8_t> output(2*m_order.bytes());
s.binary_encode(&output[output.size() / 2 - s.bytes()]);
r.binary_encode(&output[output.size() - r.bytes()]);
return output;
@@ -165,16 +165,16 @@ class GOST_3410_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const PointGFp& m_base_point;
const PointGFp& m_public_point;
const BigInt& m_order;
};
-bool GOST_3410_Verification_Operation::verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len)
+bool GOST_3410_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len)
{
if(sig_len != m_order.bytes()*2)
return false;
diff --git a/src/lib/pubkey/gost_3410/gost_3410.h b/src/lib/pubkey/gost_3410/gost_3410.h
index 49f328d56..dbaf68ada 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.h
+++ b/src/lib/pubkey/gost_3410/gost_3410.h
@@ -36,7 +36,7 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
/**
* Get this keys algorithm name.
@@ -46,7 +46,7 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
size_t message_parts() const override { return 2; }
@@ -74,7 +74,7 @@ class BOTAN_DLL GOST_3410_PrivateKey : public GOST_3410_PublicKey,
* @param key_bits PKCS #8 structure
*/
GOST_3410_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits) {}
/**
diff --git a/src/lib/pubkey/keypair/keypair.cpp b/src/lib/pubkey/keypair/keypair.cpp
index 5667bde4a..70bdf05fc 100644
--- a/src/lib/pubkey/keypair/keypair.cpp
+++ b/src/lib/pubkey/keypair/keypair.cpp
@@ -30,14 +30,14 @@ bool encryption_consistency_check(RandomNumberGenerator& rng,
if(encryptor.maximum_input_size() == 0)
return true;
- std::vector<byte> plaintext =
+ std::vector<uint8_t> plaintext =
unlock(rng.random_vec(encryptor.maximum_input_size() - 1));
- std::vector<byte> ciphertext = encryptor.encrypt(plaintext, rng);
+ std::vector<uint8_t> ciphertext = encryptor.encrypt(plaintext, rng);
if(ciphertext == plaintext)
return false;
- std::vector<byte> decrypted = unlock(decryptor.decrypt(ciphertext));
+ std::vector<uint8_t> decrypted = unlock(decryptor.decrypt(ciphertext));
return (plaintext == decrypted);
}
@@ -53,10 +53,10 @@ bool signature_consistency_check(RandomNumberGenerator& rng,
PK_Signer signer(private_key, rng, padding);
PK_Verifier verifier(public_key, padding);
- std::vector<byte> message(32);
+ std::vector<uint8_t> message(32);
rng.randomize(message.data(), message.size());
- std::vector<byte> signature;
+ std::vector<uint8_t> signature;
try
{
diff --git a/src/lib/pubkey/mce/code_based_key_gen.cpp b/src/lib/pubkey/mce/code_based_key_gen.cpp
index 839ebc977..4d68c875a 100644
--- a/src/lib/pubkey/mce/code_based_key_gen.cpp
+++ b/src/lib/pubkey/mce/code_based_key_gen.cpp
@@ -22,27 +22,27 @@ namespace {
struct binary_matrix
{
public:
- binary_matrix(u32bit m_rown, u32bit m_coln);
+ binary_matrix(uint32_t m_rown, uint32_t m_coln);
- void row_xor(u32bit a, u32bit b);
+ void row_xor(uint32_t a, uint32_t b);
secure_vector<int> row_reduced_echelon_form();
/**
* return the coefficient out of F_2
*/
- u32bit coef(u32bit i, u32bit j)
+ uint32_t coef(uint32_t i, uint32_t j)
{
return (m_elem[(i) * m_rwdcnt + (j) / 32] >> (j % 32)) & 1;
};
- void set_coef_to_one(u32bit i, u32bit j)
+ void set_coef_to_one(uint32_t i, uint32_t j)
{
- m_elem[(i) * m_rwdcnt + (j) / 32] |= (static_cast<u32bit>(1) << ((j) % 32)) ;
+ m_elem[(i) * m_rwdcnt + (j) / 32] |= (static_cast<uint32_t>(1) << ((j) % 32)) ;
};
- void toggle_coeff(u32bit i, u32bit j)
+ void toggle_coeff(uint32_t i, uint32_t j)
{
- m_elem[(i) * m_rwdcnt + (j) / 32] ^= (static_cast<u32bit>(1) << ((j) % 32)) ;
+ m_elem[(i) * m_rwdcnt + (j) / 32] ^= (static_cast<uint32_t>(1) << ((j) % 32)) ;
}
void set_to_zero()
@@ -51,23 +51,23 @@ struct binary_matrix
}
//private:
- u32bit m_rown; // number of rows.
- u32bit m_coln; // number of columns.
- u32bit m_rwdcnt; // number of words in a row
- std::vector<u32bit> m_elem;
+ uint32_t m_rown; // number of rows.
+ uint32_t m_coln; // number of columns.
+ uint32_t m_rwdcnt; // number of words in a row
+ std::vector<uint32_t> m_elem;
};
-binary_matrix::binary_matrix (u32bit rown, u32bit coln)
+binary_matrix::binary_matrix (uint32_t rown, uint32_t coln)
{
m_coln = coln;
m_rown = rown;
m_rwdcnt = 1 + ((m_coln - 1) / 32);
- m_elem = std::vector<u32bit>(m_rown * m_rwdcnt);
+ m_elem = std::vector<uint32_t>(m_rown * m_rwdcnt);
}
-void binary_matrix::row_xor(u32bit a, u32bit b)
+void binary_matrix::row_xor(uint32_t a, uint32_t b)
{
- u32bit i;
+ uint32_t i;
for(i=0;i<m_rwdcnt;i++)
{
m_elem[a*m_rwdcnt+i]^=m_elem[b*m_rwdcnt+i];
@@ -77,7 +77,7 @@ void binary_matrix::row_xor(u32bit a, u32bit b)
//the matrix is reduced from LSB...(from right)
secure_vector<int> binary_matrix::row_reduced_echelon_form()
{
- u32bit i, failcnt, findrow, max=m_coln - 1;
+ uint32_t i, failcnt, findrow, max=m_coln - 1;
secure_vector<int> perm(m_coln);
for(i=0;i<m_coln;i++)
@@ -89,7 +89,7 @@ secure_vector<int> binary_matrix::row_reduced_echelon_form()
for(i=0;i<m_rown;i++,max--)
{
findrow=0;
- for(u32bit j=i;j<m_rown;j++)
+ for(uint32_t j=i;j<m_rown;j++)
{
if(coef(j,max))
{
@@ -115,7 +115,7 @@ secure_vector<int> binary_matrix::row_reduced_echelon_form()
else
{
perm[i+m_coln - m_rown] = max;
- for(u32bit j=i+1;j<m_rown;j++)//fill the column downwards with 0's
+ for(uint32_t j=i+1;j<m_rown;j++)//fill the column downwards with 0's
{
if(coef(j,(max)))
{
@@ -137,7 +137,7 @@ secure_vector<int> binary_matrix::row_reduced_echelon_form()
void randomize_support(std::vector<gf2m>& L, RandomNumberGenerator& rng)
{
- for(u32bit i = 0; i != L.size(); ++i)
+ for(uint32_t i = 0; i != L.size(); ++i)
{
gf2m rnd = random_gf2m(rng);
@@ -146,7 +146,7 @@ void randomize_support(std::vector<gf2m>& L, RandomNumberGenerator& rng)
}
}
-std::unique_ptr<binary_matrix> generate_R(std::vector<gf2m> &L, polyn_gf2m* g, std::shared_ptr<GF2m_Field> sp_field, u32bit code_length, u32bit t )
+std::unique_ptr<binary_matrix> generate_R(std::vector<gf2m> &L, polyn_gf2m* g, std::shared_ptr<GF2m_Field> sp_field, uint32_t code_length, uint32_t t )
{
//L- Support
//t- Number of errors
@@ -154,7 +154,7 @@ std::unique_ptr<binary_matrix> generate_R(std::vector<gf2m> &L, polyn_gf2m* g, s
//m- The extension degree of the GF
//g- The generator polynomial.
gf2m x,y;
- u32bit i,j,k,r,n;
+ uint32_t i,j,k,r,n;
std::vector<int> Laux(code_length);
n=code_length;
r=t*sp_field->get_extension_degree();
@@ -210,12 +210,12 @@ std::unique_ptr<binary_matrix> generate_R(std::vector<gf2m> &L, polyn_gf2m* g, s
}
}
-McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, u32bit ext_deg, u32bit code_length, u32bit t)
+McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, uint32_t ext_deg, uint32_t code_length, uint32_t t)
{
- u32bit i, j, k, l;
+ uint32_t i, j, k, l;
std::unique_ptr<binary_matrix> R;
- u32bit codimension = t * ext_deg;
+ uint32_t codimension = t * ext_deg;
if(code_length <= codimension)
{
throw Invalid_Argument("invalid McEliece parameters");
@@ -256,15 +256,15 @@ McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, u32bit e
// speed up the syndrome computation)
//
//
- std::vector<u32bit> H(bit_size_to_32bit_size(codimension) * code_length );
- u32bit* sk = H.data();
+ std::vector<uint32_t> H(bit_size_to_32bit_size(codimension) * code_length );
+ uint32_t* sk = H.data();
for (i = 0; i < code_length; ++i)
{
for (l = 0; l < t; ++l)
{
k = (l * ext_deg) / 32;
j = (l * ext_deg) % 32;
- sk[k] ^= static_cast<u32bit>(F[i].get_coef(l)) << j;
+ sk[k] ^= static_cast<uint32_t>(F[i].get_coef(l)) << j;
if (j + ext_deg > 32)
{
sk[k + 1] ^= F[i].get_coef( l) >> (32 - j);
@@ -281,7 +281,7 @@ McEliece_PrivateKey generate_mceliece_key( RandomNumberGenerator & rng, u32bit e
{
Linv[L[i]] = i;
}
- std::vector<byte> pubmat (R->m_elem.size() * 4);
+ std::vector<uint8_t> pubmat (R->m_elem.size() * 4);
for(i = 0; i < R->m_elem.size(); i++)
{
store_le(R->m_elem[i], &pubmat[i*4]);
diff --git a/src/lib/pubkey/mce/code_based_util.h b/src/lib/pubkey/mce/code_based_util.h
index 9b5395f41..ccc94c91b 100644
--- a/src/lib/pubkey/mce/code_based_util.h
+++ b/src/lib/pubkey/mce/code_based_util.h
@@ -22,9 +22,9 @@ namespace Botan {
* @return the mask 0xFFFF if tst is non-zero and 0 otherwise
*/
template<typename T>
-u16bit expand_mask_16bit(T tst)
+uint16_t expand_mask_16bit(T tst)
{
- const u16bit result = (tst != 0);
+ const uint16_t result = (tst != 0);
return ~(result - 1);
}
@@ -42,12 +42,12 @@ inline gf2m lex_to_gray(gf2m lex)
return (lex >> 1) ^ lex;
}
-inline u32bit bit_size_to_byte_size(u32bit bit_size)
+inline uint32_t bit_size_to_byte_size(uint32_t bit_size)
{
return (bit_size - 1) / 8 + 1;
}
-inline u32bit bit_size_to_32bit_size(u32bit bit_size)
+inline uint32_t bit_size_to_32bit_size(uint32_t bit_size)
{
return (bit_size - 1) / 32 + 1;
}
diff --git a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
index 74cb1c64b..a35fc7458 100644
--- a/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
+++ b/src/lib/pubkey/mce/gf2m_rootfind_dcmp.cpp
@@ -15,11 +15,11 @@ namespace Botan {
namespace {
-u32bit patch_root_array(gf2m* res_root_arr,
- u32bit res_root_arr_len,
- u32bit root_pos)
+uint32_t patch_root_array(gf2m* res_root_arr,
+ uint32_t res_root_arr_len,
+ uint32_t root_pos)
{
- volatile u32bit i;
+ volatile uint32_t i;
volatile gf2m patch_elem = 0x01;
volatile gf2m cond_mask = (root_pos == res_root_arr_len);
cond_mask = expand_mask_16bit(cond_mask);
@@ -37,18 +37,18 @@ u32bit patch_root_array(gf2m* res_root_arr,
class gf2m_decomp_rootfind_state
{
public:
- gf2m_decomp_rootfind_state(const polyn_gf2m & p_polyn, u32bit code_length);
+ gf2m_decomp_rootfind_state(const polyn_gf2m & p_polyn, uint32_t code_length);
void calc_LiK(const polyn_gf2m & sigma);
gf2m calc_Fxj_j_neq_0( const polyn_gf2m & sigma, gf2m j_gray);
void calc_next_Aij();
void calc_Ai_zero(const polyn_gf2m & sigma);
secure_vector<gf2m> find_roots(const polyn_gf2m & sigma);
- u32bit get_code_length() const { return code_length; };
- u32bit code_length;
+ uint32_t get_code_length() const { return code_length; };
+ uint32_t code_length;
secure_vector<gf2m> m_Lik; // size is outer_summands * m
secure_vector<gf2m> m_Aij; // ...
- u32bit m_outer_summands;
+ uint32_t m_outer_summands;
gf2m m_j;
gf2m m_j_gray;
gf2m m_sigma_3_l;
@@ -73,9 +73,9 @@ gf2m brootf_decomp__gray_to_lex(gf2m gray)
/**
* calculates ceil((t-4)/5) = outer_summands - 1
*/
-u32bit brootf_decomp__calc_sum_limit(u32bit t)
+uint32_t brootf_decomp__calc_sum_limit(uint32_t t)
{
- u32bit result;
+ uint32_t result;
if(t < 4)
{
return 0;
@@ -86,7 +86,7 @@ u32bit brootf_decomp__calc_sum_limit(u32bit t)
return result;
}
-gf2m_decomp_rootfind_state::gf2m_decomp_rootfind_state(const polyn_gf2m & polyn, u32bit the_code_length) :
+gf2m_decomp_rootfind_state::gf2m_decomp_rootfind_state(const polyn_gf2m & polyn, uint32_t the_code_length) :
code_length(the_code_length), m_j(0), m_j_gray(0)
{
gf2m coeff_3;
@@ -119,7 +119,7 @@ gf2m_decomp_rootfind_state::gf2m_decomp_rootfind_state(const polyn_gf2m & polyn,
void gf2m_decomp_rootfind_state::calc_Ai_zero(const polyn_gf2m & sigma)
{
- u32bit i;
+ uint32_t i;
/*
* this function assumes this the first gray code element is zero
*/
@@ -138,9 +138,9 @@ void gf2m_decomp_rootfind_state::calc_next_Aij()
* first thing, we declare Aij Aij_minusone and increase j.
* Case j=0 upon function entry also included, then Aij contains A_{i,j=0}.
*/
- u32bit i;
+ uint32_t i;
gf2m diff, new_j_gray;
- u32bit Lik_pos_base;
+ uint32_t Lik_pos_base;
this->m_j++;
@@ -190,11 +190,11 @@ void gf2m_decomp_rootfind_state::calc_next_Aij()
void gf2m_decomp_rootfind_state::calc_LiK(const polyn_gf2m & sigma)
{
std::shared_ptr<GF2m_Field> sp_field = sigma.get_sp_field();
- u32bit i, k, d;
+ uint32_t i, k, d;
d = sigma.get_degree();
for(k = 0; k < sp_field->get_extension_degree(); k++)
{
- u32bit Lik_pos_base = k * this->m_outer_summands;
+ uint32_t Lik_pos_base = k * this->m_outer_summands;
gf2m alpha_l_k_tt2_ttj[4];
alpha_l_k_tt2_ttj[0] = sp_field->gf_l_from_n(static_cast<gf2m>(1) << k);
alpha_l_k_tt2_ttj[1] = sp_field->gf_mul_rrr(alpha_l_k_tt2_ttj[0], alpha_l_k_tt2_ttj[0]);
@@ -203,14 +203,14 @@ void gf2m_decomp_rootfind_state::calc_LiK(const polyn_gf2m & sigma)
alpha_l_k_tt2_ttj[3] = sp_field->gf_mul_rrr(alpha_l_k_tt2_ttj[2], alpha_l_k_tt2_ttj[2]);
for(i = 0; i < this->m_outer_summands; i++)
{
- u32bit j;
- u32bit five_i = 5*i;
- u32bit Lik_pos = Lik_pos_base + i;
+ uint32_t j;
+ uint32_t five_i = 5*i;
+ uint32_t Lik_pos = Lik_pos_base + i;
this->m_Lik[Lik_pos] = 0;
for(j = 0; j <= 3; j++)
{
gf2m f, x;
- u32bit f_ind = five_i + (static_cast<u32bit>(1) << j);
+ uint32_t f_ind = five_i + (static_cast<uint32_t>(1) << j);
if(f_ind > d)
{
break;
@@ -228,7 +228,7 @@ gf2m gf2m_decomp_rootfind_state::calc_Fxj_j_neq_0( const polyn_gf2m & sigma, gf2
{
//needs the A_{ij} to compute F(x)_j
gf2m sum = 0;
- u32bit i;
+ uint32_t i;
std::shared_ptr<GF2m_Field> sp_field = sigma.get_sp_field();
const gf2m jl_gray = sp_field->gf_l_from_n(j_gray);
gf2m xl_j_tt_5 = sp_field->gf_square_rr(jl_gray);
@@ -270,7 +270,7 @@ secure_vector<gf2m> gf2m_decomp_rootfind_state::find_roots(const polyn_gf2m & si
const int sigma_degree = sigma.get_degree();
BOTAN_ASSERT(sigma_degree > 0, "Valid sigma");
secure_vector<gf2m> result(sigma_degree);
- u32bit root_pos = 0;
+ uint32_t root_pos = 0;
this->calc_Ai_zero(sigma);
this->calc_LiK(sigma);
@@ -293,7 +293,7 @@ secure_vector<gf2m> gf2m_decomp_rootfind_state::find_roots(const polyn_gf2m & si
root_pos++;
}
- if(this->m_j + static_cast<u32bit>(1) == this->get_code_length())
+ if(this->m_j + static_cast<uint32_t>(1) == this->get_code_length())
{
break;
}
@@ -308,7 +308,7 @@ secure_vector<gf2m> gf2m_decomp_rootfind_state::find_roots(const polyn_gf2m & si
} // end anonymous namespace
-secure_vector<gf2m> find_roots_gf2m_decomp(const polyn_gf2m & polyn, u32bit code_length)
+secure_vector<gf2m> find_roots_gf2m_decomp(const polyn_gf2m & polyn, uint32_t code_length)
{
gf2m_decomp_rootfind_state state(polyn, code_length);
return state.find_roots(polyn);
diff --git a/src/lib/pubkey/mce/gf2m_small_m.cpp b/src/lib/pubkey/mce/gf2m_small_m.cpp
index e74e5c71f..95187c7af 100644
--- a/src/lib/pubkey/mce/gf2m_small_m.cpp
+++ b/src/lib/pubkey/mce/gf2m_small_m.cpp
@@ -94,14 +94,14 @@ const std::vector<gf2m>& log_table(size_t deg)
}
-u32bit encode_gf2m(gf2m to_enc, byte* mem)
+uint32_t encode_gf2m(gf2m to_enc, uint8_t* mem)
{
mem[0] = to_enc >> 8;
mem[1] = to_enc & 0xFF;
return sizeof(to_enc);
}
-gf2m decode_gf2m(const byte* mem)
+gf2m decode_gf2m(const uint8_t* mem)
{
gf2m result;
result = mem[0] << 8;
@@ -118,9 +118,9 @@ GF2m_Field::GF2m_Field(size_t extdeg) : m_gf_extension_degree(extdeg),
gf2m GF2m_Field::gf_div(gf2m x, gf2m y) const
{
- const s32bit sub_res = static_cast<s32bit>(gf_log(x) - static_cast<s32bit>(gf_log(y)));
- const s32bit modq_res = static_cast<s32bit>(_gf_modq_1(sub_res));
- const s32bit div_res = static_cast<s32bit>(x) ? static_cast<s32bit>(gf_exp(modq_res)) : 0;
+ const int32_t sub_res = static_cast<int32_t>(gf_log(x) - static_cast<int32_t>(gf_log(y)));
+ const int32_t modq_res = static_cast<int32_t>(_gf_modq_1(sub_res));
+ const int32_t div_res = static_cast<int32_t>(x) ? static_cast<int32_t>(gf_exp(modq_res)) : 0;
return static_cast<gf2m>(div_res);
}
diff --git a/src/lib/pubkey/mce/gf2m_small_m.h b/src/lib/pubkey/mce/gf2m_small_m.h
index 595ef3999..d49325def 100644
--- a/src/lib/pubkey/mce/gf2m_small_m.h
+++ b/src/lib/pubkey/mce/gf2m_small_m.h
@@ -17,7 +17,7 @@
namespace Botan {
-typedef u16bit gf2m;
+typedef uint16_t gf2m;
/**
* GF(2^m) field for m = [2...16]
@@ -196,7 +196,7 @@ class BOTAN_DLL GF2m_Field
}
private:
- gf2m _gf_modq_1(s32bit d) const
+ gf2m _gf_modq_1(int32_t d) const
{
/* residual modulo q-1
when -q < d < 0, we get (q-1+d)
@@ -211,9 +211,9 @@ class BOTAN_DLL GF2m_Field
const std::vector<gf2m>& m_gf_exp_table;
};
-u32bit encode_gf2m(gf2m to_enc, byte* mem);
+uint32_t encode_gf2m(gf2m to_enc, uint8_t* mem);
-gf2m decode_gf2m(const byte* mem);
+gf2m decode_gf2m(const uint8_t* mem);
}
diff --git a/src/lib/pubkey/mce/goppa_code.cpp b/src/lib/pubkey/mce/goppa_code.cpp
index cbec6302a..97cdf947e 100644
--- a/src/lib/pubkey/mce/goppa_code.cpp
+++ b/src/lib/pubkey/mce/goppa_code.cpp
@@ -16,11 +16,11 @@ namespace Botan {
namespace {
-void matrix_arr_mul(std::vector<u32bit> matrix,
- u32bit numo_rows,
- u32bit words_per_row,
- const byte* input_vec,
- u32bit* output_vec, u32bit output_vec_len)
+void matrix_arr_mul(std::vector<uint32_t> matrix,
+ uint32_t numo_rows,
+ uint32_t words_per_row,
+ const uint8_t* input_vec,
+ uint32_t* output_vec, uint32_t output_vec_len)
{
for(size_t j = 0; j < numo_rows; j++)
{
@@ -43,8 +43,8 @@ secure_vector<gf2m> goppa_decode(const polyn_gf2m & syndrom_polyn,
const std::vector<gf2m> & Linv)
{
gf2m a;
- u32bit code_length = Linv.size();
- u32bit t = g.get_degree();
+ uint32_t code_length = Linv.size();
+ uint32_t t = g.get_degree();
std::shared_ptr<GF2m_Field> sp_field = g.get_sp_field();
@@ -63,13 +63,13 @@ secure_vector<gf2m> goppa_decode(const polyn_gf2m & syndrom_polyn,
// compute S square root of h (using sqrtmod)
polyn_gf2m S(t - 1, g.get_sp_field());
- for(u32bit i=0;i<t;i++)
+ for(uint32_t i=0;i<t;i++)
{
a = sp_field->gf_sqrt(h.get_coef(i));
if(i & 1)
{
- for(u32bit j=0;j<t;j++)
+ for(uint32_t j=0;j<t;j++)
{
S.add_to_coef( j, sp_field->gf_mul(a, sqrtmod[i/2].get_coef(j)));
}
@@ -107,7 +107,7 @@ secure_vector<gf2m> goppa_decode(const polyn_gf2m & syndrom_polyn,
size_t d = res.size();
secure_vector<gf2m> result(d);
- for(u32bit i = 0; i < d; ++i)
+ for(uint32_t i = 0; i < d; ++i)
{
gf2m current = res[i];
@@ -124,18 +124,18 @@ secure_vector<gf2m> goppa_decode(const polyn_gf2m & syndrom_polyn,
}
}
-void mceliece_decrypt(secure_vector<byte>& plaintext_out,
- secure_vector<byte>& error_mask_out,
- const secure_vector<byte>& ciphertext,
+void mceliece_decrypt(secure_vector<uint8_t>& plaintext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const secure_vector<uint8_t>& ciphertext,
const McEliece_PrivateKey& key)
{
mceliece_decrypt(plaintext_out, error_mask_out, ciphertext.data(), ciphertext.size(), key);
}
void mceliece_decrypt(
- secure_vector<byte>& plaintext,
- secure_vector<byte> & error_mask,
- const byte ciphertext[],
+ secure_vector<uint8_t>& plaintext,
+ secure_vector<uint8_t> & error_mask,
+ const uint8_t ciphertext[],
size_t ciphertext_len,
const McEliece_PrivateKey & key)
{
@@ -143,7 +143,7 @@ void mceliece_decrypt(
plaintext = mceliece_decrypt(error_pos, ciphertext, ciphertext_len, key);
const size_t code_length = key.get_code_length();
- secure_vector<byte> result((code_length+7)/8);
+ secure_vector<uint8_t> result((code_length+7)/8);
for(auto&& pos : error_pos)
{
if(pos > code_length)
@@ -160,40 +160,40 @@ void mceliece_decrypt(
* @p p_err_pos_len must point to the available length of @p error_pos on input, the
* function will set it to the actual number of errors returned in the @p error_pos
* array */
-secure_vector<byte> mceliece_decrypt(
+secure_vector<uint8_t> mceliece_decrypt(
secure_vector<gf2m> & error_pos,
- const byte *ciphertext, u32bit ciphertext_len,
+ const uint8_t *ciphertext, uint32_t ciphertext_len,
const McEliece_PrivateKey & key)
{
- u32bit dimension = key.get_dimension();
- u32bit codimension = key.get_codimension();
- u32bit t = key.get_goppa_polyn().get_degree();
+ uint32_t dimension = key.get_dimension();
+ uint32_t codimension = key.get_codimension();
+ uint32_t t = key.get_goppa_polyn().get_degree();
polyn_gf2m syndrome_polyn(key.get_goppa_polyn().get_sp_field()); // init as zero polyn
const unsigned unused_pt_bits = dimension % 8;
- const byte unused_pt_bits_mask = (1 << unused_pt_bits) - 1;
+ const uint8_t unused_pt_bits_mask = (1 << unused_pt_bits) - 1;
if(ciphertext_len != (key.get_code_length()+7)/8)
{
throw Invalid_Argument("wrong size of McEliece ciphertext");
}
- u32bit cleartext_len = (key.get_message_word_bit_length()+7)/8;
+ uint32_t cleartext_len = (key.get_message_word_bit_length()+7)/8;
if(cleartext_len != bit_size_to_byte_size(dimension))
{
throw Invalid_Argument("mce-decryption: wrong length of cleartext buffer");
}
- secure_vector<u32bit> syndrome_vec(bit_size_to_32bit_size(codimension));
+ secure_vector<uint32_t> syndrome_vec(bit_size_to_32bit_size(codimension));
matrix_arr_mul(key.get_H_coeffs(),
key.get_code_length(),
bit_size_to_32bit_size(codimension),
ciphertext,
syndrome_vec.data(), syndrome_vec.size());
- secure_vector<byte> syndrome_byte_vec(bit_size_to_byte_size(codimension));
- u32bit syndrome_byte_vec_size = syndrome_byte_vec.size();
- for(u32bit i = 0; i < syndrome_byte_vec_size; i++)
+ secure_vector<uint8_t> syndrome_byte_vec(bit_size_to_byte_size(codimension));
+ uint32_t syndrome_byte_vec_size = syndrome_byte_vec.size();
+ for(uint32_t i = 0; i < syndrome_byte_vec_size; i++)
{
syndrome_byte_vec[i] = syndrome_vec[i/4] >> (8* (i % 4));
}
@@ -203,12 +203,12 @@ secure_vector<byte> mceliece_decrypt(
syndrome_polyn.get_degree();
error_pos = goppa_decode(syndrome_polyn, key.get_goppa_polyn(), key.get_sqrtmod(), key.get_Linv());
- u32bit nb_err = error_pos.size();
+ uint32_t nb_err = error_pos.size();
- secure_vector<byte> cleartext(cleartext_len);
+ secure_vector<uint8_t> cleartext(cleartext_len);
copy_mem(cleartext.data(), ciphertext, cleartext_len);
- for(u32bit i = 0; i < nb_err; i++)
+ for(uint32_t i = 0; i < nb_err; i++)
{
gf2m current = error_pos[i];
diff --git a/src/lib/pubkey/mce/mce_internal.h b/src/lib/pubkey/mce/mce_internal.h
index fb995e758..81fa970bb 100644
--- a/src/lib/pubkey/mce/mce_internal.h
+++ b/src/lib/pubkey/mce/mce_internal.h
@@ -19,32 +19,32 @@
namespace Botan {
-void mceliece_decrypt(secure_vector<byte>& plaintext_out,
- secure_vector<byte>& error_mask_out,
- const byte ciphertext[],
+void mceliece_decrypt(secure_vector<uint8_t>& plaintext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const uint8_t ciphertext[],
size_t ciphertext_len,
const McEliece_PrivateKey& key);
-void mceliece_decrypt(secure_vector<byte>& plaintext_out,
- secure_vector<byte>& error_mask_out,
- const secure_vector<byte>& ciphertext,
+void mceliece_decrypt(secure_vector<uint8_t>& plaintext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const secure_vector<uint8_t>& ciphertext,
const McEliece_PrivateKey& key);
-secure_vector<byte> mceliece_decrypt(
+secure_vector<uint8_t> mceliece_decrypt(
secure_vector<gf2m> & error_pos,
- const byte *ciphertext, u32bit ciphertext_len,
+ const uint8_t *ciphertext, uint32_t ciphertext_len,
const McEliece_PrivateKey & key);
-void mceliece_encrypt(secure_vector<byte>& ciphertext_out,
- secure_vector<byte>& error_mask_out,
- const secure_vector<byte>& plaintext,
+void mceliece_encrypt(secure_vector<uint8_t>& ciphertext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const secure_vector<uint8_t>& plaintext,
const McEliece_PublicKey& key,
RandomNumberGenerator& rng);
McEliece_PrivateKey generate_mceliece_key(RandomNumberGenerator &rng,
- u32bit ext_deg,
- u32bit code_length,
- u32bit t);
+ uint32_t ext_deg,
+ uint32_t code_length,
+ uint32_t t);
}
diff --git a/src/lib/pubkey/mce/mceliece.cpp b/src/lib/pubkey/mce/mceliece.cpp
index 7617ff11f..fd985c032 100644
--- a/src/lib/pubkey/mce/mceliece.cpp
+++ b/src/lib/pubkey/mce/mceliece.cpp
@@ -19,10 +19,10 @@ namespace Botan {
namespace {
-secure_vector<byte> concat_vectors(const secure_vector<byte>& a, const secure_vector<byte>& b,
- u32bit dimension, u32bit codimension)
+secure_vector<uint8_t> concat_vectors(const secure_vector<uint8_t>& a, const secure_vector<uint8_t>& b,
+ uint32_t dimension, uint32_t codimension)
{
- secure_vector<byte> x(bit_size_to_byte_size(dimension) + bit_size_to_byte_size(codimension));
+ secure_vector<uint8_t> x(bit_size_to_byte_size(dimension) + bit_size_to_byte_size(codimension));
const size_t final_bits = dimension % 8;
@@ -35,31 +35,31 @@ secure_vector<byte> concat_vectors(const secure_vector<byte>& a, const secure_ve
else
{
copy_mem(&x[0], a.data(), (dimension / 8));
- u32bit l = dimension / 8;
- x[l] = static_cast<byte>(a[l] & ((1 << final_bits) - 1));
+ uint32_t l = dimension / 8;
+ x[l] = static_cast<uint8_t>(a[l] & ((1 << final_bits) - 1));
- for(u32bit k = 0; k < codimension / 8; ++k)
+ for(uint32_t k = 0; k < codimension / 8; ++k)
{
- x[l] ^= static_cast<byte>(b[k] << final_bits);
+ x[l] ^= static_cast<uint8_t>(b[k] << final_bits);
++l;
- x[l] = static_cast<byte>(b[k] >> (8 - final_bits));
+ x[l] = static_cast<uint8_t>(b[k] >> (8 - final_bits));
}
- x[l] ^= static_cast<byte>(b[codimension/8] << final_bits);
+ x[l] ^= static_cast<uint8_t>(b[codimension/8] << final_bits);
}
return x;
}
-secure_vector<byte> mult_by_pubkey(const secure_vector<byte>& cleartext,
- std::vector<byte> const& public_matrix,
- u32bit code_length, u32bit t)
+secure_vector<uint8_t> mult_by_pubkey(const secure_vector<uint8_t>& cleartext,
+ std::vector<uint8_t> const& public_matrix,
+ uint32_t code_length, uint32_t t)
{
- const u32bit ext_deg = ceil_log2(code_length);
- const u32bit codimension = ext_deg * t;
- const u32bit dimension = code_length - codimension;
- secure_vector<byte> cR(bit_size_to_32bit_size(codimension) * sizeof(u32bit));
+ const uint32_t ext_deg = ceil_log2(code_length);
+ const uint32_t codimension = ext_deg * t;
+ const uint32_t dimension = code_length - codimension;
+ secure_vector<uint8_t> cR(bit_size_to_32bit_size(codimension) * sizeof(uint32_t));
- const byte* pt = public_matrix.data();
+ const uint8_t* pt = public_matrix.data();
for(size_t i = 0; i < dimension / 8; ++i)
{
@@ -82,16 +82,16 @@ secure_vector<byte> mult_by_pubkey(const secure_vector<byte>& cleartext,
pt += cR.size();
}
- secure_vector<byte> ciphertext = concat_vectors(cleartext, cR, dimension, codimension);
+ secure_vector<uint8_t> ciphertext = concat_vectors(cleartext, cR, dimension, codimension);
ciphertext.resize((code_length+7)/8);
return ciphertext;
}
-secure_vector<byte> create_random_error_vector(unsigned code_length,
+secure_vector<uint8_t> create_random_error_vector(unsigned code_length,
unsigned error_weight,
RandomNumberGenerator& rng)
{
- secure_vector<byte> result((code_length+7)/8);
+ secure_vector<uint8_t> result((code_length+7)/8);
size_t bits_set = 0;
@@ -101,7 +101,7 @@ secure_vector<byte> create_random_error_vector(unsigned code_length,
const size_t byte_pos = x / 8, bit_pos = x % 8;
- const byte mask = (1 << bit_pos);
+ const uint8_t mask = (1 << bit_pos);
if(result[byte_pos] & mask)
continue; // already set this bit
@@ -115,15 +115,15 @@ secure_vector<byte> create_random_error_vector(unsigned code_length,
}
-void mceliece_encrypt(secure_vector<byte>& ciphertext_out,
- secure_vector<byte>& error_mask_out,
- const secure_vector<byte>& plaintext,
+void mceliece_encrypt(secure_vector<uint8_t>& ciphertext_out,
+ secure_vector<uint8_t>& error_mask_out,
+ const secure_vector<uint8_t>& plaintext,
const McEliece_PublicKey& key,
RandomNumberGenerator& rng)
{
- secure_vector<byte> error_mask = create_random_error_vector(key.get_code_length(), key.get_t(), rng);
+ secure_vector<uint8_t> error_mask = create_random_error_vector(key.get_code_length(), key.get_t(), rng);
- secure_vector<byte> ciphertext = mult_by_pubkey(plaintext, key.get_public_matrix(),
+ secure_vector<uint8_t> ciphertext = mult_by_pubkey(plaintext, key.get_public_matrix(),
key.get_code_length(), key.get_t());
ciphertext ^= error_mask;
diff --git a/src/lib/pubkey/mce/mceliece.h b/src/lib/pubkey/mce/mceliece.h
index 0731e0c68..58c242360 100644
--- a/src/lib/pubkey/mce/mceliece.h
+++ b/src/lib/pubkey/mce/mceliece.h
@@ -21,9 +21,9 @@ namespace Botan {
class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key
{
public:
- explicit McEliece_PublicKey(const std::vector<byte>& key_bits);
+ explicit McEliece_PublicKey(const std::vector<uint8_t>& key_bits);
- McEliece_PublicKey(std::vector<byte> const& pub_matrix, u32bit the_t, u32bit the_code_length) :
+ McEliece_PublicKey(std::vector<uint8_t> const& pub_matrix, uint32_t the_t, uint32_t the_code_length) :
m_public_matrix(pub_matrix),
m_t(the_t),
m_code_length(the_code_length)
@@ -31,7 +31,7 @@ class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key
McEliece_PublicKey(const McEliece_PublicKey& other);
- secure_vector<byte> random_plaintext_element(RandomNumberGenerator& rng) const;
+ secure_vector<uint8_t> random_plaintext_element(RandomNumberGenerator& rng) const;
std::string algo_name() const override { return "McEliece"; }
@@ -40,15 +40,15 @@ class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key
size_t key_length() const override;
size_t estimated_strength() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
bool check_key(RandomNumberGenerator&, bool) const override
{ return true; }
- u32bit get_t() const { return m_t; }
- u32bit get_code_length() const { return m_code_length; }
- u32bit get_message_word_bit_length() const;
- const std::vector<byte>& get_public_matrix() const { return m_public_matrix; }
+ uint32_t get_t() const { return m_t; }
+ uint32_t get_code_length() const { return m_code_length; }
+ uint32_t get_message_word_bit_length() const;
+ const std::vector<uint8_t>& get_public_matrix() const { return m_public_matrix; }
bool operator==(const McEliece_PublicKey& other) const;
bool operator!=(const McEliece_PublicKey& other) const { return !(*this == other); }
@@ -61,9 +61,9 @@ class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key
protected:
McEliece_PublicKey() : m_t(0), m_code_length(0) {}
- std::vector<byte> m_public_matrix;
- u32bit m_t;
- u32bit m_code_length;
+ std::vector<uint8_t> m_public_matrix;
+ uint32_t m_t;
+ uint32_t m_code_length;
};
class BOTAN_DLL McEliece_PrivateKey : public virtual McEliece_PublicKey,
@@ -85,26 +85,26 @@ class BOTAN_DLL McEliece_PrivateKey : public virtual McEliece_PublicKey,
*/
McEliece_PrivateKey(RandomNumberGenerator& rng, size_t code_length, size_t t);
- explicit McEliece_PrivateKey(const secure_vector<byte>& key_bits);
+ explicit McEliece_PrivateKey(const secure_vector<uint8_t>& key_bits);
McEliece_PrivateKey(polyn_gf2m const& goppa_polyn,
- std::vector<u32bit> const& parity_check_matrix_coeffs,
+ std::vector<uint32_t> const& parity_check_matrix_coeffs,
std::vector<polyn_gf2m> const& square_root_matrix,
std::vector<gf2m> const& inverse_support,
- std::vector<byte> const& public_matrix );
+ std::vector<uint8_t> const& public_matrix );
bool check_key(RandomNumberGenerator& rng, bool strong) const override;
polyn_gf2m const& get_goppa_polyn() const { return m_g; }
- std::vector<u32bit> const& get_H_coeffs() const { return m_coeffs; }
+ std::vector<uint32_t> const& get_H_coeffs() const { return m_coeffs; }
std::vector<gf2m> const& get_Linv() const { return m_Linv; }
std::vector<polyn_gf2m> const& get_sqrtmod() const { return m_sqrtmod; }
- inline u32bit get_dimension() const { return m_dimension; }
+ inline uint32_t get_dimension() const { return m_dimension; }
- inline u32bit get_codimension() const { return m_codimension; }
+ inline uint32_t get_codimension() const { return m_codimension; }
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
bool operator==(const McEliece_PrivateKey & other) const;
@@ -118,10 +118,10 @@ class BOTAN_DLL McEliece_PrivateKey : public virtual McEliece_PublicKey,
polyn_gf2m m_g;
std::vector<polyn_gf2m> m_sqrtmod;
std::vector<gf2m> m_Linv;
- std::vector<u32bit> m_coeffs;
+ std::vector<uint32_t> m_coeffs;
- u32bit m_codimension;
- u32bit m_dimension;
+ uint32_t m_codimension;
+ uint32_t m_dimension;
};
/**
diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp
index 409688153..798f7a91f 100644
--- a/src/lib/pubkey/mce/mceliece_key.cpp
+++ b/src/lib/pubkey/mce/mceliece_key.cpp
@@ -21,10 +21,10 @@
namespace Botan {
McEliece_PrivateKey::McEliece_PrivateKey(polyn_gf2m const& goppa_polyn,
- std::vector<u32bit> const& parity_check_matrix_coeffs,
+ std::vector<uint32_t> const& parity_check_matrix_coeffs,
std::vector<polyn_gf2m> const& square_root_matrix,
std::vector<gf2m> const& inverse_support,
- std::vector<byte> const& public_matrix) :
+ std::vector<uint8_t> const& public_matrix) :
McEliece_PublicKey(public_matrix, goppa_polyn.get_degree(), inverse_support.size()),
m_g(goppa_polyn),
m_sqrtmod(square_root_matrix),
@@ -37,27 +37,27 @@ McEliece_PrivateKey::McEliece_PrivateKey(polyn_gf2m const& goppa_polyn,
McEliece_PrivateKey::McEliece_PrivateKey(RandomNumberGenerator& rng, size_t code_length, size_t t)
{
- u32bit ext_deg = ceil_log2(code_length);
+ uint32_t ext_deg = ceil_log2(code_length);
*this = generate_mceliece_key(rng, ext_deg, code_length, t);
}
-u32bit McEliece_PublicKey::get_message_word_bit_length() const
+uint32_t McEliece_PublicKey::get_message_word_bit_length() const
{
- u32bit codimension = ceil_log2(m_code_length) * m_t;
+ uint32_t codimension = ceil_log2(m_code_length) * m_t;
return m_code_length - codimension;
}
-secure_vector<byte> McEliece_PublicKey::random_plaintext_element(RandomNumberGenerator& rng) const
+secure_vector<uint8_t> McEliece_PublicKey::random_plaintext_element(RandomNumberGenerator& rng) const
{
const size_t bits = get_message_word_bit_length();
- secure_vector<byte> plaintext((bits+7)/8);
+ secure_vector<uint8_t> plaintext((bits+7)/8);
rng.randomize(plaintext.data(), plaintext.size());
// unset unused bits in the last plaintext byte
- if(u32bit used = bits % 8)
+ if(uint32_t used = bits % 8)
{
- const byte mask = (1 << used) - 1;
+ const uint8_t mask = (1 << used) - 1;
plaintext[plaintext.size() - 1] &= mask;
}
@@ -66,10 +66,10 @@ secure_vector<byte> McEliece_PublicKey::random_plaintext_element(RandomNumberGen
AlgorithmIdentifier McEliece_PublicKey::algorithm_identifier() const
{
- return AlgorithmIdentifier(get_oid(), std::vector<byte>());
+ return AlgorithmIdentifier(get_oid(), std::vector<uint8_t>());
}
-std::vector<byte> McEliece_PublicKey::public_key_bits() const
+std::vector<uint8_t> McEliece_PublicKey::public_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -99,7 +99,7 @@ size_t McEliece_PublicKey::estimated_strength() const
return mceliece_work_factor(m_code_length, m_t);
}
-McEliece_PublicKey::McEliece_PublicKey(const std::vector<byte>& key_bits)
+McEliece_PublicKey::McEliece_PublicKey(const std::vector<uint8_t>& key_bits)
{
BER_Decoder dec(key_bits);
size_t n;
@@ -115,7 +115,7 @@ McEliece_PublicKey::McEliece_PublicKey(const std::vector<byte>& key_bits)
m_code_length = n;
}
-secure_vector<byte> McEliece_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> McEliece_PrivateKey::private_key_bits() const
{
DER_Encoder enc;
enc.start_cons(SEQUENCE)
@@ -126,20 +126,20 @@ secure_vector<byte> McEliece_PrivateKey::private_key_bits() const
.encode(m_public_matrix, OCTET_STRING)
.encode(m_g.encode(), OCTET_STRING); // g as octet string
enc.start_cons(SEQUENCE);
- for(u32bit i = 0; i < m_sqrtmod.size(); i++)
+ for(uint32_t i = 0; i < m_sqrtmod.size(); i++)
{
enc.encode(m_sqrtmod[i].encode(), OCTET_STRING);
}
enc.end_cons();
- secure_vector<byte> enc_support;
- for(u32bit i = 0; i < m_Linv.size(); i++)
+ secure_vector<uint8_t> enc_support;
+ for(uint32_t i = 0; i < m_Linv.size(); i++)
{
enc_support.push_back(m_Linv[i] >> 8);
enc_support.push_back(m_Linv[i]);
}
enc.encode(enc_support, OCTET_STRING);
- secure_vector<byte> enc_H;
- for(u32bit i = 0; i < m_coeffs.size(); i++)
+ secure_vector<uint8_t> enc_H;
+ for(uint32_t i = 0; i < m_coeffs.size(); i++)
{
enc_H.push_back(m_coeffs[i] >> 24);
enc_H.push_back(m_coeffs[i] >> 16);
@@ -153,14 +153,14 @@ secure_vector<byte> McEliece_PrivateKey::private_key_bits() const
bool McEliece_PrivateKey::check_key(RandomNumberGenerator& rng, bool) const
{
- const secure_vector<byte> plaintext = this->random_plaintext_element(rng);
+ const secure_vector<uint8_t> plaintext = this->random_plaintext_element(rng);
- secure_vector<byte> ciphertext;
- secure_vector<byte> errors;
+ secure_vector<uint8_t> ciphertext;
+ secure_vector<uint8_t> errors;
mceliece_encrypt(ciphertext, errors, plaintext, *this, rng);
- secure_vector<byte> plaintext_out;
- secure_vector<byte> errors_out;
+ secure_vector<uint8_t> plaintext_out;
+ secure_vector<uint8_t> errors_out;
mceliece_decrypt(plaintext_out, errors_out, ciphertext, *this);
if(errors != errors_out || plaintext != plaintext_out)
@@ -169,10 +169,10 @@ bool McEliece_PrivateKey::check_key(RandomNumberGenerator& rng, bool) const
return true;
}
-McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
+McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<uint8_t>& key_bits)
{
size_t n, t;
- secure_vector<byte> g_enc;
+ secure_vector<uint8_t> g_enc;
BER_Decoder dec_base(key_bits);
BER_Decoder dec = dec_base.start_cons(SEQUENCE)
.start_cons(SEQUENCE)
@@ -185,7 +185,7 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
if(t == 0 || n == 0)
throw Decoding_Error("invalid McEliece parameters");
- u32bit ext_deg = ceil_log2(n);
+ uint32_t ext_deg = ceil_log2(n);
m_code_length = n;
m_t = t;
m_codimension = (ext_deg * t);
@@ -198,9 +198,9 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
throw Decoding_Error("degree of decoded Goppa polynomial is incorrect");
}
BER_Decoder dec2 = dec.start_cons(SEQUENCE);
- for(u32bit i = 0; i < t/2; i++)
+ for(uint32_t i = 0; i < t/2; i++)
{
- secure_vector<byte> sqrt_enc;
+ secure_vector<uint8_t> sqrt_enc;
dec2.decode(sqrt_enc, OCTET_STRING);
while(sqrt_enc.size() < (t*2))
{
@@ -214,7 +214,7 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
}
m_sqrtmod.push_back(polyn_gf2m(sqrt_enc, sp_field));
}
- secure_vector<byte> enc_support;
+ secure_vector<uint8_t> enc_support;
BER_Decoder dec3 = dec2.end_cons()
.decode(enc_support, OCTET_STRING);
if(enc_support.size() % 2)
@@ -225,12 +225,12 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
{
throw Decoding_Error("encoded support has length different from code length");
}
- for(u32bit i = 0; i < n*2; i+=2)
+ for(uint32_t i = 0; i < n*2; i+=2)
{
gf2m el = (enc_support[i] << 8) | enc_support[i+1];
m_Linv.push_back(el);
}
- secure_vector<byte> enc_H;
+ secure_vector<uint8_t> enc_H;
dec3.decode(enc_H, OCTET_STRING)
.end_cons();
if(enc_H.size() % 4)
@@ -242,9 +242,9 @@ McEliece_PrivateKey::McEliece_PrivateKey(const secure_vector<byte>& key_bits)
throw Decoding_Error("encoded parity check matrix has wrong length");
}
- for(u32bit i = 0; i < enc_H.size(); i+=4)
+ for(uint32_t i = 0; i < enc_H.size(); i+=4)
{
- u32bit coeff = (enc_H[i] << 24) | (enc_H[i+1] << 16) | (enc_H[i+2] << 8) | enc_H[i+3];
+ uint32_t coeff = (enc_H[i] << 24) | (enc_H[i+1] << 16) | (enc_H[i+2] << 8) | enc_H[i+3];
m_coeffs.push_back(coeff);
}
@@ -310,13 +310,13 @@ class MCE_KEM_Encryptor : public PK_Ops::KEM_Encryption_with_KDF
KEM_Encryption_with_KDF(kdf), m_key(key) {}
private:
- void raw_kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& raw_shared_key,
+ void raw_kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& raw_shared_key,
Botan::RandomNumberGenerator& rng) override
{
- secure_vector<byte> plaintext = m_key.random_plaintext_element(rng);
+ secure_vector<uint8_t> plaintext = m_key.random_plaintext_element(rng);
- secure_vector<byte> ciphertext, error_mask;
+ secure_vector<uint8_t> ciphertext, error_mask;
mceliece_encrypt(ciphertext, error_mask, plaintext, m_key, rng);
raw_shared_key.clear();
@@ -338,13 +338,13 @@ class MCE_KEM_Decryptor : public PK_Ops::KEM_Decryption_with_KDF
KEM_Decryption_with_KDF(kdf), m_key(key) {}
private:
- secure_vector<byte>
- raw_kem_decrypt(const byte encap_key[], size_t len) override
+ secure_vector<uint8_t>
+ raw_kem_decrypt(const uint8_t encap_key[], size_t len) override
{
- secure_vector<byte> plaintext, error_mask;
+ secure_vector<uint8_t> plaintext, error_mask;
mceliece_decrypt(plaintext, error_mask, encap_key, len, m_key);
- secure_vector<byte> output;
+ secure_vector<uint8_t> output;
output.reserve(plaintext.size() + error_mask.size());
output.insert(output.end(), plaintext.begin(), plaintext.end());
output.insert(output.end(), error_mask.begin(), error_mask.end());
diff --git a/src/lib/pubkey/mce/polyn_gf2m.cpp b/src/lib/pubkey/mce/polyn_gf2m.cpp
index 2815181c1..f4fd88f5d 100644
--- a/src/lib/pubkey/mce/polyn_gf2m.cpp
+++ b/src/lib/pubkey/mce/polyn_gf2m.cpp
@@ -30,7 +30,7 @@ gf2m generate_gf2m_mask(gf2m a)
/**
* number of leading zeros
*/
-unsigned nlz_16bit(u16bit x)
+unsigned nlz_16bit(uint16_t x)
{
unsigned n;
if(x == 0) return 16;
@@ -47,8 +47,8 @@ int polyn_gf2m::calc_degree_secure() const
{
int i = this->coeff.size() - 1;
int result = 0;
- u32bit found_mask = 0;
- u32bit tracker_mask = 0xffff;
+ uint32_t found_mask = 0;
+ uint32_t tracker_mask = 0xffff;
for( ; i >= 0; i--)
{
found_mask = expand_mask_16bit(this->coeff[i]);
@@ -63,9 +63,9 @@ int polyn_gf2m::calc_degree_secure() const
gf2m random_gf2m(RandomNumberGenerator& rng)
{
- byte b[2];
+ uint8_t b[2];
rng.randomize(b, sizeof(b));
- return make_u16bit(b[1], b[0]);
+ return make_uint16(b[1], b[0]);
}
gf2m random_code_element(unsigned code_length, RandomNumberGenerator& rng)
@@ -118,12 +118,12 @@ std::string polyn_gf2m::to_string() const
/**
* doesn't save coefficients:
*/
-void polyn_gf2m::realloc(u32bit new_size)
+void polyn_gf2m::realloc(uint32_t new_size)
{
this->coeff = secure_vector<gf2m>(new_size);
}
-polyn_gf2m::polyn_gf2m(const byte* mem, u32bit mem_len, std::shared_ptr<GF2m_Field> sp_field)
+polyn_gf2m::polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2m_Field> sp_field)
:msp_field(sp_field)
{
if(mem_len % sizeof(gf2m))
@@ -131,15 +131,15 @@ polyn_gf2m::polyn_gf2m(const byte* mem, u32bit mem_len, std::shared_ptr<GF2m_Fie
throw new Botan::Decoding_Error("illegal length of memory to decode ");
}
- u32bit size = (mem_len / sizeof(this->coeff[0])) ;
+ uint32_t size = (mem_len / sizeof(this->coeff[0])) ;
this->coeff = secure_vector<gf2m>(size);
this->m_deg = -1;
- for(u32bit i = 0; i < size; i++)
+ for(uint32_t i = 0; i < size; i++)
{
this->coeff[i] = decode_gf2m(mem);
mem += sizeof(this->coeff[0]);
}
- for(u32bit i = 0; i < size; i++)
+ for(uint32_t i = 0; i < size; i++)
{
if(this->coeff[i] >= (1 << sp_field->get_extension_degree()))
{
@@ -156,12 +156,12 @@ polyn_gf2m::polyn_gf2m( std::shared_ptr<GF2m_Field> sp_field )
msp_field(sp_field)
{}
-polyn_gf2m::polyn_gf2m(int degree, const unsigned char* mem, u32bit mem_byte_len, std::shared_ptr<GF2m_Field> sp_field)
+polyn_gf2m::polyn_gf2m(int degree, const unsigned char* mem, uint32_t mem_byte_len, std::shared_ptr<GF2m_Field> sp_field)
:msp_field(sp_field)
{
- u32bit j, k, l;
+ uint32_t j, k, l;
gf2m a;
- u32bit polyn_size;
+ uint32_t polyn_size;
polyn_size = degree + 1;
if(polyn_size * sp_field->get_extension_degree() > 8 * mem_byte_len)
{
@@ -191,12 +191,12 @@ polyn_gf2m::polyn_gf2m(int degree, const unsigned char* mem, u32bit mem_byte_le
}
#if 0
-void polyn_gf2m::encode(u32bit min_numo_coeffs, byte* mem, u32bit mem_len) const
+void polyn_gf2m::encode(uint32_t min_numo_coeffs, uint8_t* mem, uint32_t mem_len) const
{
- u32bit i;
- u32bit numo_coeffs, needed_size;
+ uint32_t i;
+ uint32_t numo_coeffs, needed_size;
this->get_degree();
- numo_coeffs = (min_numo_coeffs > static_cast<u32bit>(this->m_deg+1)) ? min_numo_coeffs : this->m_deg+1;
+ numo_coeffs = (min_numo_coeffs > static_cast<uint32_t>(this->m_deg+1)) ? min_numo_coeffs : this->m_deg+1;
needed_size = sizeof(this->coeff[0]) * numo_coeffs;
if(mem_len < needed_size)
{
@@ -206,7 +206,7 @@ void polyn_gf2m::encode(u32bit min_numo_coeffs, byte* mem, u32bit mem_len) const
for(i = 0; i < numo_coeffs; i++)
{
gf2m to_enc;
- if(i >= static_cast<u32bit>(this->m_deg+1))
+ if(i >= static_cast<uint32_t>(this->m_deg+1))
{
/* encode a zero */
to_enc = 0;
@@ -295,10 +295,10 @@ std::vector<polyn_gf2m> polyn_gf2m::sqmod_init(const polyn_gf2m & g)
if(signed_deg <= 0)
throw Invalid_Argument("cannot compute sqmod for such low degree");
- const u32bit d = static_cast<u32bit>(signed_deg);
- u32bit t = g.m_deg;
+ const uint32_t d = static_cast<uint32_t>(signed_deg);
+ uint32_t t = g.m_deg;
// create t zero polynomials
- u32bit i;
+ uint32_t i;
for (i = 0; i < t; ++i)
{
sq.push_back(polyn_gf2m(t+1, g.get_sp_field()));
@@ -428,16 +428,16 @@ void polyn_gf2m::degppf(const polyn_gf2m & g, int* p_result)
}
-void polyn_gf2m::patchup_deg_secure( u32bit trgt_deg, volatile gf2m patch_elem)
+void polyn_gf2m::patchup_deg_secure( uint32_t trgt_deg, volatile gf2m patch_elem)
{
- u32bit i;
+ uint32_t i;
if(this->coeff.size() < trgt_deg)
{
return;
}
for(i = 0; i < this->coeff.size(); i++)
{
- u32bit equal, equal_mask;
+ uint32_t equal, equal_mask;
this->coeff[i] |= patch_elem;
equal = (i == trgt_deg);
equal_mask = expand_mask_16bit(equal);
@@ -539,7 +539,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
if(break_deg == 1) /* syndrome inversion */
{
volatile gf2m fake_elem = 0x00;
- volatile u32bit trgt_deg = 0;
+ volatile uint32_t trgt_deg = 0;
r0.calc_degree_secure();
u0.calc_degree_secure();
/**
@@ -559,7 +559,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
*/
if(u0.get_degree() == 4)
{
- u32bit mask = 0;
+ uint32_t mask = 0;
/**
* Condition that the EEA would break now
*/
@@ -587,7 +587,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
}
else if(u0.get_degree() == 6)
{
- u32bit mask = 0;
+ uint32_t mask = 0;
int cond_r= r0.get_degree() == 0;
int cond_u1 = msp_field->gf_mul(u0.coeff[1], msp_field->gf_inv(r0.coeff[0])) == 1;
int cond_u3 = u0.coeff[3] == 0;
@@ -601,7 +601,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
}
else if(u0.get_degree() == 8)
{
- u32bit mask = 0;
+ uint32_t mask = 0;
int cond_r= r0.get_degree() == 0;
int cond_u1 = msp_field->gf_mul(u0[1], msp_field->gf_inv(r0[0])) == 1;
int cond_u3 = u0.coeff[3] == 0;
@@ -677,8 +677,8 @@ void polyn_gf2m::poly_shiftmod( const polyn_gf2m & g)
std::vector<polyn_gf2m> polyn_gf2m::sqrt_mod_init(const polyn_gf2m & g)
{
- u32bit i, t;
- u32bit nb_polyn_sqrt_mat;
+ uint32_t i, t;
+ uint32_t nb_polyn_sqrt_mat;
std::shared_ptr<GF2m_Field> msp_field = g.msp_field;
std::vector<polyn_gf2m> result;
t = g.get_degree();
@@ -753,14 +753,14 @@ std::vector<polyn_gf2m> syndrome_init(polyn_gf2m const& generator, std::vector<g
return result;
}
-polyn_gf2m::polyn_gf2m(const secure_vector<byte>& encoded, std::shared_ptr<GF2m_Field> sp_field )
+polyn_gf2m::polyn_gf2m(const secure_vector<uint8_t>& encoded, std::shared_ptr<GF2m_Field> sp_field )
:msp_field(sp_field)
{
if(encoded.size() % 2)
{
throw Decoding_Error("encoded polynomial has odd length");
}
- for(u32bit i = 0; i < encoded.size(); i += 2)
+ for(uint32_t i = 0; i < encoded.size(); i += 2)
{
gf2m el = (encoded[i] << 8) | encoded[i + 1];
coeff.push_back(el);
@@ -768,9 +768,9 @@ polyn_gf2m::polyn_gf2m(const secure_vector<byte>& encoded, std::shared_ptr<GF2m_
get_degree();
}
-secure_vector<byte> polyn_gf2m::encode() const
+secure_vector<uint8_t> polyn_gf2m::encode() const
{
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
if(m_deg < 1)
{
@@ -779,7 +779,7 @@ secure_vector<byte> polyn_gf2m::encode() const
return result;
}
- u32bit len = m_deg+1;
+ uint32_t len = m_deg+1;
for(unsigned i = 0; i < len; i++)
{
// "big endian" encoding of the GF(2^m) elements
diff --git a/src/lib/pubkey/mce/polyn_gf2m.h b/src/lib/pubkey/mce/polyn_gf2m.h
index 73e495fba..0782406ea 100644
--- a/src/lib/pubkey/mce/polyn_gf2m.h
+++ b/src/lib/pubkey/mce/polyn_gf2m.h
@@ -33,7 +33,7 @@ struct polyn_gf2m
:m_deg(-1)
{};
- polyn_gf2m(const secure_vector<byte>& encoded, std::shared_ptr<GF2m_Field> sp_field );
+ polyn_gf2m(const secure_vector<uint8_t>& encoded, std::shared_ptr<GF2m_Field> sp_field );
polyn_gf2m& operator=(const polyn_gf2m&) = default;
@@ -57,7 +57,7 @@ struct polyn_gf2m
void swap(polyn_gf2m& other);
- secure_vector<byte> encode() const;
+ secure_vector<uint8_t> encode() const;
/**
* create zero polynomial with reservation of space for a degree d polynomial
*/
@@ -82,14 +82,14 @@ struct polyn_gf2m
gf2m get_lead_coef() const { return coeff[m_deg]; }
- gf2m get_coef(u32bit i) const { return coeff[i]; }
+ gf2m get_coef(uint32_t i) const { return coeff[i]; }
- inline void set_coef(u32bit i, gf2m v)
+ inline void set_coef(uint32_t i, gf2m v)
{
coeff[i] = v;
};
- inline void add_to_coef(u32bit i, gf2m v)
+ inline void add_to_coef(uint32_t i, gf2m v)
{
coeff[i] = coeff[i] ^ v;
}
@@ -97,14 +97,14 @@ struct polyn_gf2m
std::string to_string() const;
/** decode a polynomial from memory: **/
- polyn_gf2m(const byte* mem, u32bit mem_len, std::shared_ptr<GF2m_Field> sp_field);
+ polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2m_Field> sp_field);
// remove one! ^v!
/**
* create a polynomial from memory area (encoded)
*/
- polyn_gf2m(int degree, const unsigned char* mem, u32bit mem_byte_len, std::shared_ptr<GF2m_Field> sp_field);
+ polyn_gf2m(int degree, const unsigned char* mem, uint32_t mem_byte_len, std::shared_ptr<GF2m_Field> sp_field);
- void encode(u32bit min_numo_coeffs, byte* mem, u32bit mem_len) const;
+ void encode(uint32_t min_numo_coeffs, uint8_t* mem, uint32_t mem_len) const;
int get_degree() const;
@@ -130,14 +130,14 @@ struct polyn_gf2m
const polyn_gf2m & g,
int break_deg);
- void patchup_deg_secure( u32bit trgt_deg, volatile gf2m patch_elem);
+ void patchup_deg_secure( uint32_t trgt_deg, volatile gf2m patch_elem);
private:
void set_degree(int d) { m_deg = d; }
void poly_shiftmod( const polyn_gf2m & g);
- void realloc(u32bit new_size);
+ void realloc(uint32_t new_size);
static polyn_gf2m gcd(polyn_gf2m const& p1, polyn_gf2m const& p2);
/**
@@ -166,7 +166,7 @@ std::vector<polyn_gf2m> syndrome_init(polyn_gf2m const& generator, std::vector<g
* Find the roots of a polynomial over GF(2^m) using the method by Federenko
* et al.
*/
-secure_vector<gf2m> find_roots_gf2m_decomp(const polyn_gf2m & polyn, u32bit code_length);
+secure_vector<gf2m> find_roots_gf2m_decomp(const polyn_gf2m & polyn, uint32_t code_length);
}
diff --git a/src/lib/pubkey/mceies/mceies.cpp b/src/lib/pubkey/mceies/mceies.cpp
index 253e9ddee..e50df3156 100644
--- a/src/lib/pubkey/mceies/mceies.cpp
+++ b/src/lib/pubkey/mceies/mceies.cpp
@@ -14,14 +14,14 @@ namespace Botan {
namespace {
-secure_vector<byte> aead_key(const secure_vector<byte>& mk,
+secure_vector<uint8_t> aead_key(const secure_vector<uint8_t>& mk,
const AEAD_Mode& aead)
{
// Fold the key as required for the AEAD mode in use
if(aead.valid_keylength(mk.size()))
return mk;
- secure_vector<byte> r(aead.key_spec().maximum_keylength());
+ secure_vector<uint8_t> r(aead.key_spec().maximum_keylength());
for(size_t i = 0; i != mk.size(); ++i)
r[i % r.size()] ^= mk[i];
return r;
@@ -29,16 +29,16 @@ secure_vector<byte> aead_key(const secure_vector<byte>& mk,
}
-secure_vector<byte>
+secure_vector<uint8_t>
mceies_encrypt(const McEliece_PublicKey& pubkey,
- const byte pt[], size_t pt_len,
- const byte ad[], size_t ad_len,
+ const uint8_t pt[], size_t pt_len,
+ const uint8_t ad[], size_t ad_len,
RandomNumberGenerator& rng,
const std::string& algo)
{
PK_KEM_Encryptor kem_op(pubkey, rng, "KDF1(SHA-512)");
- secure_vector<byte> mce_ciphertext, mce_key;
+ secure_vector<uint8_t> mce_ciphertext, mce_key;
kem_op.encrypt(mce_ciphertext, mce_key, 64, rng);
const size_t mce_code_bytes = (pubkey.get_code_length() + 7) / 8;
@@ -54,9 +54,9 @@ mceies_encrypt(const McEliece_PublicKey& pubkey,
aead->set_key(aead_key(mce_key, *aead));
aead->set_associated_data(ad, ad_len);
- const secure_vector<byte> nonce = rng.random_vec(nonce_len);
+ const secure_vector<uint8_t> nonce = rng.random_vec(nonce_len);
- secure_vector<byte> msg(mce_ciphertext.size() + nonce.size() + pt_len);
+ secure_vector<uint8_t> msg(mce_ciphertext.size() + nonce.size() + pt_len);
copy_mem(msg.data(), mce_ciphertext.data(), mce_ciphertext.size());
copy_mem(msg.data() + mce_ciphertext.size(), nonce.data(), nonce.size());
copy_mem(msg.data() + mce_ciphertext.size() + nonce.size(), pt, pt_len);
@@ -66,10 +66,10 @@ mceies_encrypt(const McEliece_PublicKey& pubkey,
return msg;
}
-secure_vector<byte>
+secure_vector<uint8_t>
mceies_decrypt(const McEliece_PrivateKey& privkey,
- const byte ct[], size_t ct_len,
- const byte ad[], size_t ad_len,
+ const uint8_t ct[], size_t ct_len,
+ const uint8_t ad[], size_t ad_len,
const std::string& algo)
{
try
@@ -88,12 +88,12 @@ mceies_decrypt(const McEliece_PrivateKey& privkey,
if(ct_len < mce_code_bytes + nonce_len + aead->tag_size())
throw Exception("Input message too small to be valid");
- const secure_vector<byte> mce_key = kem_op.decrypt(ct, mce_code_bytes, 64);
+ const secure_vector<uint8_t> mce_key = kem_op.decrypt(ct, mce_code_bytes, 64);
aead->set_key(aead_key(mce_key, *aead));
aead->set_associated_data(ad, ad_len);
- secure_vector<byte> pt(ct + mce_code_bytes + nonce_len, ct + ct_len);
+ secure_vector<uint8_t> pt(ct + mce_code_bytes + nonce_len, ct + ct_len);
aead->start(&ct[mce_code_bytes], nonce_len);
aead->finish(pt, 0);
diff --git a/src/lib/pubkey/mceies/mceies.h b/src/lib/pubkey/mceies/mceies.h
index b43e2065f..372404cc1 100644
--- a/src/lib/pubkey/mceies/mceies.h
+++ b/src/lib/pubkey/mceies/mceies.h
@@ -21,10 +21,10 @@ class McEliece_PrivateKey;
* Derive a shared key using MCE KEM and encrypt/authenticate the
* plaintext and AD using AES-256 in OCB mode.
*/
-secure_vector<byte>
+secure_vector<uint8_t>
BOTAN_DLL mceies_encrypt(const McEliece_PublicKey& pubkey,
- const byte pt[], size_t pt_len,
- const byte ad[], size_t ad_len,
+ const uint8_t pt[], size_t pt_len,
+ const uint8_t ad[], size_t ad_len,
RandomNumberGenerator& rng,
const std::string& aead = "AES-256/OCB");
@@ -33,10 +33,10 @@ BOTAN_DLL mceies_encrypt(const McEliece_PublicKey& pubkey,
* Derive a shared key using MCE KEM and decrypt/authenticate the
* ciphertext and AD using AES-256 in OCB mode.
*/
-secure_vector<byte>
+secure_vector<uint8_t>
BOTAN_DLL mceies_decrypt(const McEliece_PrivateKey& privkey,
- const byte ct[], size_t ct_len,
- const byte ad[], size_t ad_len,
+ const uint8_t ct[], size_t ct_len,
+ const uint8_t ad[], size_t ad_len,
const std::string& aead = "AES-256/OCB");
diff --git a/src/lib/pubkey/newhope/newhope.cpp b/src/lib/pubkey/newhope/newhope.cpp
index 77194207e..2a48a4638 100644
--- a/src/lib/pubkey/newhope/newhope.cpp
+++ b/src/lib/pubkey/newhope/newhope.cpp
@@ -155,7 +155,7 @@ inline void poly_getnoise(Botan::RandomNumberGenerator& rng, poly *r)
for(size_t i=0;i<PARAM_N;i++)
{
- uint32_t t = load_le<u32bit>(buf, i);
+ uint32_t t = load_le<uint32_t>(buf, i);
uint32_t d = 0;
for(int j=0;j<8;j++)
d += (t >> j) & 0x01010101;
diff --git a/src/lib/pubkey/pbes2/pbes2.cpp b/src/lib/pubkey/pbes2/pbes2.cpp
index c66b293e8..3f1000170 100644
--- a/src/lib/pubkey/pbes2/pbes2.cpp
+++ b/src/lib/pubkey/pbes2/pbes2.cpp
@@ -23,10 +23,10 @@ namespace {
/*
* Encode PKCS#5 PBES2 parameters
*/
-std::vector<byte> encode_pbes2_params(const std::string& cipher,
+std::vector<uint8_t> encode_pbes2_params(const std::string& cipher,
const std::string& prf,
- const secure_vector<byte>& salt,
- const secure_vector<byte>& iv,
+ const secure_vector<uint8_t>& salt,
+ const secure_vector<uint8_t>& iv,
size_t iterations,
size_t key_length)
{
@@ -60,8 +60,8 @@ std::vector<byte> encode_pbes2_params(const std::string& cipher,
/*
* PKCS#5 v2.0 PBE Constructor
*/
-std::pair<AlgorithmIdentifier, std::vector<byte>>
-pbes2_encrypt(const secure_vector<byte>& key_bits,
+std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
+pbes2_encrypt(const secure_vector<uint8_t>& key_bits,
const std::string& passphrase,
std::chrono::milliseconds msec,
const std::string& cipher,
@@ -74,7 +74,7 @@ pbes2_encrypt(const secure_vector<byte>& key_bits,
if(cipher_spec.size() != 2)
throw Decoding_Error("PBE-PKCS5 v2.0: Invalid cipher spec " + cipher);
- const secure_vector<byte> salt = rng.random_vec(12);
+ const secure_vector<uint8_t> salt = rng.random_vec(12);
if(cipher_spec[1] != "CBC" && cipher_spec[1] != "GCM")
throw Decoding_Error("PBE-PKCS5 v2.0: Don't know param format for " + cipher);
@@ -89,13 +89,13 @@ pbes2_encrypt(const secure_vector<byte>& key_bits,
const size_t key_length = enc->key_spec().maximum_keylength();
size_t iterations = 0;
- secure_vector<byte> iv = rng.random_vec(enc->default_nonce_length());
+ secure_vector<uint8_t> iv = rng.random_vec(enc->default_nonce_length());
enc->set_key(pbkdf->derive_key(key_length, passphrase, salt.data(), salt.size(),
msec, iterations).bits_of());
enc->start(iv);
- secure_vector<byte> buf = key_bits;
+ secure_vector<uint8_t> buf = key_bits;
enc->finish(buf);
AlgorithmIdentifier id(
@@ -105,10 +105,10 @@ pbes2_encrypt(const secure_vector<byte>& key_bits,
return std::make_pair(id, unlock(buf));
}
-secure_vector<byte>
-pbes2_decrypt(const secure_vector<byte>& key_bits,
+secure_vector<uint8_t>
+pbes2_decrypt(const secure_vector<uint8_t>& key_bits,
const std::string& passphrase,
- const std::vector<byte>& params)
+ const std::vector<uint8_t>& params)
{
AlgorithmIdentifier kdf_algo, enc_algo;
@@ -125,7 +125,7 @@ pbes2_decrypt(const secure_vector<byte>& key_bits,
throw Decoding_Error("PBE-PKCS5 v2.0: Unknown KDF algorithm " +
kdf_algo.oid.as_string());
- secure_vector<byte> salt;
+ secure_vector<uint8_t> salt;
size_t iterations = 0, key_length = 0;
BER_Decoder(kdf_algo.parameters)
@@ -149,7 +149,7 @@ pbes2_decrypt(const secure_vector<byte>& key_bits,
if(salt.size() < 8)
throw Decoding_Error("PBE-PKCS5 v2.0: Encoded salt is too small");
- secure_vector<byte> iv;
+ secure_vector<uint8_t> iv;
BER_Decoder(enc_algo.parameters).decode(iv, OCTET_STRING).verify_end();
const std::string prf = OIDS::lookup(prf_algo.oid);
@@ -167,7 +167,7 @@ pbes2_decrypt(const secure_vector<byte>& key_bits,
dec->start(iv);
- secure_vector<byte> buf = key_bits;
+ secure_vector<uint8_t> buf = key_bits;
dec->finish(buf);
return buf;
diff --git a/src/lib/pubkey/pbes2/pbes2.h b/src/lib/pubkey/pbes2/pbes2.h
index 7c8c4095d..e50896c6d 100644
--- a/src/lib/pubkey/pbes2/pbes2.h
+++ b/src/lib/pubkey/pbes2/pbes2.h
@@ -23,8 +23,8 @@ namespace Botan {
* @param digest specifies the PRF to use with PBKDF2 (eg "HMAC(SHA-1)")
* @param rng a random number generator
*/
-std::pair<AlgorithmIdentifier, std::vector<byte>>
-BOTAN_DLL pbes2_encrypt(const secure_vector<byte>& key_bits,
+std::pair<AlgorithmIdentifier, std::vector<uint8_t>>
+BOTAN_DLL pbes2_encrypt(const secure_vector<uint8_t>& key_bits,
const std::string& passphrase,
std::chrono::milliseconds msec,
const std::string& cipher,
@@ -37,10 +37,10 @@ BOTAN_DLL pbes2_encrypt(const secure_vector<byte>& key_bits,
* @param passphrase the passphrase to use for decryption
* @param params the PBES2 parameters
*/
-secure_vector<byte>
-BOTAN_DLL pbes2_decrypt(const secure_vector<byte>& key_bits,
+secure_vector<uint8_t>
+BOTAN_DLL pbes2_decrypt(const secure_vector<uint8_t>& key_bits,
const std::string& passphrase,
- const std::vector<byte>& params);
+ const std::vector<uint8_t>& params);
}
diff --git a/src/lib/pubkey/pem/pem.cpp b/src/lib/pubkey/pem/pem.cpp
index 83b48c07b..bc94e3b53 100644
--- a/src/lib/pubkey/pem/pem.cpp
+++ b/src/lib/pubkey/pem/pem.cpp
@@ -40,7 +40,7 @@ std::string linewrap(size_t width, const std::string& in)
/*
* PEM encode BER/DER-encoded objects
*/
-std::string encode(const byte der[], size_t length, const std::string& label, size_t width)
+std::string encode(const uint8_t der[], size_t length, const std::string& label, size_t width)
{
const std::string PEM_HEADER = "-----BEGIN " + label + "-----\n";
const std::string PEM_TRAILER = "-----END " + label + "-----\n";
@@ -51,11 +51,11 @@ std::string encode(const byte der[], size_t length, const std::string& label, si
/*
* Decode PEM down to raw BER/DER
*/
-secure_vector<byte> decode_check_label(DataSource& source,
+secure_vector<uint8_t> decode_check_label(DataSource& source,
const std::string& label_want)
{
std::string label_got;
- secure_vector<byte> ber = decode(source, label_got);
+ secure_vector<uint8_t> ber = decode(source, label_got);
if(label_got != label_want)
throw Decoding_Error("PEM: Label mismatch, wanted " + label_want +
", got " + label_got);
@@ -65,7 +65,7 @@ secure_vector<byte> decode_check_label(DataSource& source,
/*
* Decode PEM down to raw BER/DER
*/
-secure_vector<byte> decode(DataSource& source, std::string& label)
+secure_vector<uint8_t> decode(DataSource& source, std::string& label)
{
const size_t RANDOM_CHAR_LIMIT = 8;
@@ -75,7 +75,7 @@ secure_vector<byte> decode(DataSource& source, std::string& label)
while(position != PEM_HEADER1.length())
{
- byte b;
+ uint8_t b;
if(!source.read_byte(b))
throw Decoding_Error("PEM: No PEM header found");
if(b == PEM_HEADER1[position])
@@ -88,7 +88,7 @@ secure_vector<byte> decode(DataSource& source, std::string& label)
position = 0;
while(position != PEM_HEADER2.length())
{
- byte b;
+ uint8_t b;
if(!source.read_byte(b))
throw Decoding_Error("PEM: No PEM header found");
if(b == PEM_HEADER2[position])
@@ -106,7 +106,7 @@ secure_vector<byte> decode(DataSource& source, std::string& label)
position = 0;
while(position != PEM_TRAILER.length())
{
- byte b;
+ uint8_t b;
if(!source.read_byte(b))
throw Decoding_Error("PEM: No PEM trailer found");
if(b == PEM_TRAILER[position])
@@ -121,14 +121,14 @@ secure_vector<byte> decode(DataSource& source, std::string& label)
return base64_decode(b64.data(), b64.size());
}
-secure_vector<byte> decode_check_label(const std::string& pem,
+secure_vector<uint8_t> decode_check_label(const std::string& pem,
const std::string& label_want)
{
DataSource_Memory src(pem);
return decode_check_label(src, label_want);
}
-secure_vector<byte> decode(const std::string& pem, std::string& label)
+secure_vector<uint8_t> decode(const std::string& pem, std::string& label)
{
DataSource_Memory src(pem);
return decode(src, label);
@@ -142,7 +142,7 @@ bool matches(DataSource& source, const std::string& extra,
{
const std::string PEM_HEADER = "-----BEGIN " + extra;
- secure_vector<byte> search_buf(search_range);
+ secure_vector<uint8_t> search_buf(search_range);
size_t got = source.peek(search_buf.data(), search_buf.size(), 0);
if(got < PEM_HEADER.length())
diff --git a/src/lib/pubkey/pem/pem.h b/src/lib/pubkey/pem/pem.h
index acbd40a77..1f9483ea8 100644
--- a/src/lib/pubkey/pem/pem.h
+++ b/src/lib/pubkey/pem/pem.h
@@ -21,7 +21,7 @@ namespace PEM_Code {
* @param label PEM label put after BEGIN and END
* @param line_width after this many characters, a new line is inserted
*/
-BOTAN_DLL std::string encode(const byte data[],
+BOTAN_DLL std::string encode(const uint8_t data[],
size_t data_len,
const std::string& label,
size_t line_width = 64);
@@ -32,7 +32,7 @@ BOTAN_DLL std::string encode(const byte data[],
* @param label PEM label
* @param line_width after this many characters, a new line is inserted
*/
-inline std::string encode(const std::vector<byte>& data,
+inline std::string encode(const std::vector<uint8_t>& data,
const std::string& label,
size_t line_width = 64)
{
@@ -45,7 +45,7 @@ inline std::string encode(const std::vector<byte>& data,
* @param label PEM label put after BEGIN and END
* @param line_width after this many characters, a new line is inserted
*/
-inline std::string encode(const secure_vector<byte>& data,
+inline std::string encode(const secure_vector<uint8_t>& data,
const std::string& label,
size_t line_width = 64)
{
@@ -57,7 +57,7 @@ inline std::string encode(const secure_vector<byte>& data,
* @param pem a datasource containing PEM encoded data
* @param label is set to the PEM label found for later inspection
*/
-BOTAN_DLL secure_vector<byte> decode(DataSource& pem,
+BOTAN_DLL secure_vector<uint8_t> decode(DataSource& pem,
std::string& label);
/**
@@ -65,7 +65,7 @@ BOTAN_DLL secure_vector<byte> decode(DataSource& pem,
* @param pem a string containing PEM encoded data
* @param label is set to the PEM label found for later inspection
*/
-BOTAN_DLL secure_vector<byte> decode(const std::string& pem,
+BOTAN_DLL secure_vector<uint8_t> decode(const std::string& pem,
std::string& label);
/**
@@ -73,7 +73,7 @@ BOTAN_DLL secure_vector<byte> decode(const std::string& pem,
* @param pem a datasource containing PEM encoded data
* @param label is what we expect the label to be
*/
-BOTAN_DLL secure_vector<byte> decode_check_label(
+BOTAN_DLL secure_vector<uint8_t> decode_check_label(
DataSource& pem,
const std::string& label);
@@ -82,7 +82,7 @@ BOTAN_DLL secure_vector<byte> decode_check_label(
* @param pem a string containing PEM encoded data
* @param label is what we expect the label to be
*/
-BOTAN_DLL secure_vector<byte> decode_check_label(
+BOTAN_DLL secure_vector<uint8_t> decode_check_label(
const std::string& pem,
const std::string& label);
diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp
index 696c4528b..1e1fd739a 100644
--- a/src/lib/pubkey/pk_algs.cpp
+++ b/src/lib/pubkey/pk_algs.cpp
@@ -60,7 +60,7 @@ namespace Botan {
std::unique_ptr<Public_Key>
load_public_key(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits)
+ const std::vector<uint8_t>& key_bits)
{
const std::string alg_name = OIDS::lookup(alg_id.oid);
if(alg_name == "")
@@ -131,7 +131,7 @@ load_public_key(const AlgorithmIdentifier& alg_id,
std::unique_ptr<Private_Key>
load_private_key(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits)
+ const secure_vector<uint8_t>& key_bits)
{
const std::string alg_name = OIDS::lookup(alg_id.oid);
if(alg_name == "")
diff --git a/src/lib/pubkey/pk_algs.h b/src/lib/pubkey/pk_algs.h
index 42613d0c3..04248459b 100644
--- a/src/lib/pubkey/pk_algs.h
+++ b/src/lib/pubkey/pk_algs.h
@@ -16,11 +16,11 @@ namespace Botan {
BOTAN_DLL std::unique_ptr<Public_Key>
load_public_key(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
BOTAN_DLL std::unique_ptr<Private_Key>
load_private_key(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Create a new key
diff --git a/src/lib/pubkey/pk_keys.cpp b/src/lib/pubkey/pk_keys.cpp
index 06833958d..52304eb03 100644
--- a/src/lib/pubkey/pk_keys.cpp
+++ b/src/lib/pubkey/pk_keys.cpp
@@ -14,7 +14,7 @@
namespace Botan {
-std::vector<byte> Public_Key::subject_public_key() const
+std::vector<uint8_t> Public_Key::subject_public_key() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -38,7 +38,7 @@ OID Public_Key::get_oid() const
}
}
-secure_vector<byte> Private_Key::private_key_info() const
+secure_vector<uint8_t> Private_Key::private_key_info() const
{
const size_t PKCS8_VERSION = 0;
@@ -56,7 +56,7 @@ secure_vector<byte> Private_Key::private_key_info() const
*/
std::string Private_Key::fingerprint(const std::string& alg) const
{
- secure_vector<byte> buf = private_key_bits();
+ secure_vector<uint8_t> buf = private_key_bits();
std::unique_ptr<HashFunction> hash(HashFunction::create(alg));
hash->update(buf);
const auto hex_print = hex_encode(hash->final());
diff --git a/src/lib/pubkey/pk_keys.h b/src/lib/pubkey/pk_keys.h
index f8242f429..1e7bd3216 100644
--- a/src/lib/pubkey/pk_keys.h
+++ b/src/lib/pubkey/pk_keys.h
@@ -76,12 +76,12 @@ class BOTAN_DLL Public_Key
/**
* @return BER encoded public key bits
*/
- virtual std::vector<byte> public_key_bits() const = 0;
+ virtual std::vector<uint8_t> public_key_bits() const = 0;
/**
* @return X.509 subject key encoding for this key object
*/
- std::vector<byte> subject_public_key() const;
+ std::vector<uint8_t> subject_public_key() const;
// Internal or non-public declarations follow
@@ -166,12 +166,12 @@ class BOTAN_DLL Private_Key : public virtual Public_Key
/**
* @return BER encoded private key bits
*/
- virtual secure_vector<byte> private_key_bits() const = 0;
+ virtual secure_vector<uint8_t> private_key_bits() const = 0;
/**
* @return PKCS #8 private key encoding for this key object
*/
- secure_vector<byte> private_key_info() const;
+ secure_vector<uint8_t> private_key_info() const;
/**
* @return PKCS #8 AlgorithmIdentifier for this key
@@ -266,7 +266,7 @@ class BOTAN_DLL PK_Key_Agreement_Key : public virtual Private_Key
/*
* @return public component of this key
*/
- virtual std::vector<byte> public_value() const = 0;
+ virtual std::vector<uint8_t> public_value() const = 0;
virtual ~PK_Key_Agreement_Key() {}
};
diff --git a/src/lib/pubkey/pk_ops.cpp b/src/lib/pubkey/pk_ops.cpp
index dba82345e..cf10c4ba2 100644
--- a/src/lib/pubkey/pk_ops.cpp
+++ b/src/lib/pubkey/pk_ops.cpp
@@ -27,11 +27,11 @@ size_t PK_Ops::Encryption_with_EME::max_input_bits() const
return m_eme->maximum_input_size(max_raw_input_bits());
}
-secure_vector<byte> PK_Ops::Encryption_with_EME::encrypt(const byte msg[], size_t msg_len,
+secure_vector<uint8_t> PK_Ops::Encryption_with_EME::encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
const size_t max_raw = max_raw_input_bits();
- const std::vector<byte> encoded = unlock(m_eme->encode(msg, msg_len, max_raw, rng));
+ const std::vector<uint8_t> encoded = unlock(m_eme->encode(msg, msg_len, max_raw, rng));
return raw_encrypt(encoded.data(), encoded.size(), rng);
}
@@ -44,12 +44,12 @@ PK_Ops::Decryption_with_EME::Decryption_with_EME(const std::string& eme)
PK_Ops::Decryption_with_EME::~Decryption_with_EME() {}
-secure_vector<byte>
-PK_Ops::Decryption_with_EME::decrypt(byte& valid_mask,
- const byte ciphertext[],
+secure_vector<uint8_t>
+PK_Ops::Decryption_with_EME::decrypt(uint8_t& valid_mask,
+ const uint8_t ciphertext[],
size_t ciphertext_len)
{
- const secure_vector<byte> raw = raw_decrypt(ciphertext, ciphertext_len);
+ const secure_vector<uint8_t> raw = raw_decrypt(ciphertext, ciphertext_len);
return m_eme->unpad(valid_mask, raw.data(), raw.size());
}
@@ -61,11 +61,11 @@ PK_Ops::Key_Agreement_with_KDF::Key_Agreement_with_KDF(const std::string& kdf)
PK_Ops::Key_Agreement_with_KDF::~Key_Agreement_with_KDF() {}
-secure_vector<byte> PK_Ops::Key_Agreement_with_KDF::agree(size_t key_len,
- const byte w[], size_t w_len,
- const byte salt[], size_t salt_len)
+secure_vector<uint8_t> PK_Ops::Key_Agreement_with_KDF::agree(size_t key_len,
+ const uint8_t w[], size_t w_len,
+ const uint8_t salt[], size_t salt_len)
{
- secure_vector<byte> z = raw_agree(w, w_len);
+ secure_vector<uint8_t> z = raw_agree(w, w_len);
if(m_kdf)
return m_kdf->derive_key(key_len, z, salt, salt_len);
return z;
@@ -83,21 +83,21 @@ PK_Ops::Signature_with_EMSA::Signature_with_EMSA(const std::string& emsa) :
PK_Ops::Signature_with_EMSA::~Signature_with_EMSA() {}
-void PK_Ops::Signature_with_EMSA::update(const byte msg[], size_t msg_len)
+void PK_Ops::Signature_with_EMSA::update(const uint8_t msg[], size_t msg_len)
{
if(has_prefix() && !m_prefix_used)
{
m_prefix_used = true;
- secure_vector<byte> prefix = message_prefix();
+ secure_vector<uint8_t> prefix = message_prefix();
m_emsa->update(prefix.data(), prefix.size());
}
m_emsa->update(msg, msg_len);
}
-secure_vector<byte> PK_Ops::Signature_with_EMSA::sign(RandomNumberGenerator& rng)
+secure_vector<uint8_t> PK_Ops::Signature_with_EMSA::sign(RandomNumberGenerator& rng)
{
m_prefix_used = false;
- const secure_vector<byte> msg = m_emsa->raw_data();
+ const secure_vector<uint8_t> msg = m_emsa->raw_data();
const auto padded = m_emsa->encoding_of(msg, this->max_input_bits(), rng);
return raw_sign(padded.data(), padded.size(), rng);
}
@@ -114,43 +114,43 @@ PK_Ops::Verification_with_EMSA::Verification_with_EMSA(const std::string& emsa)
PK_Ops::Verification_with_EMSA::~Verification_with_EMSA() {}
-void PK_Ops::Verification_with_EMSA::update(const byte msg[], size_t msg_len)
+void PK_Ops::Verification_with_EMSA::update(const uint8_t msg[], size_t msg_len)
{
if(has_prefix() && !m_prefix_used)
{
m_prefix_used = true;
- secure_vector<byte> prefix = message_prefix();
+ secure_vector<uint8_t> prefix = message_prefix();
m_emsa->update(prefix.data(), prefix.size());
}
m_emsa->update(msg, msg_len);
}
-bool PK_Ops::Verification_with_EMSA::is_valid_signature(const byte sig[], size_t sig_len)
+bool PK_Ops::Verification_with_EMSA::is_valid_signature(const uint8_t sig[], size_t sig_len)
{
m_prefix_used = false;
- const secure_vector<byte> msg = m_emsa->raw_data();
+ const secure_vector<uint8_t> msg = m_emsa->raw_data();
if(with_recovery())
{
- secure_vector<byte> output_of_key = verify_mr(sig, sig_len);
+ secure_vector<uint8_t> output_of_key = verify_mr(sig, sig_len);
return m_emsa->verify(output_of_key, msg, max_input_bits());
}
else
{
Null_RNG rng;
- secure_vector<byte> encoded = m_emsa->encoding_of(msg, max_input_bits(), rng);
+ secure_vector<uint8_t> encoded = m_emsa->encoding_of(msg, max_input_bits(), rng);
return verify(encoded.data(), encoded.size(), sig, sig_len);
}
}
-void PK_Ops::KEM_Encryption_with_KDF::kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+void PK_Ops::KEM_Encryption_with_KDF::kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
size_t salt_len)
{
- secure_vector<byte> raw_shared;
+ secure_vector<uint8_t> raw_shared;
this->raw_kem_encrypt(out_encapsulated_key, raw_shared, rng);
out_shared_key = m_kdf->derive_key(desired_shared_key_len,
@@ -165,14 +165,14 @@ PK_Ops::KEM_Encryption_with_KDF::KEM_Encryption_with_KDF(const std::string& kdf)
PK_Ops::KEM_Encryption_with_KDF::~KEM_Encryption_with_KDF() {}
-secure_vector<byte>
-PK_Ops::KEM_Decryption_with_KDF::kem_decrypt(const byte encap_key[],
+secure_vector<uint8_t>
+PK_Ops::KEM_Decryption_with_KDF::kem_decrypt(const uint8_t encap_key[],
size_t len,
size_t desired_shared_key_len,
const uint8_t salt[],
size_t salt_len)
{
- secure_vector<byte> raw_shared = this->raw_kem_decrypt(encap_key, len);
+ secure_vector<uint8_t> raw_shared = this->raw_kem_decrypt(encap_key, len);
return m_kdf->derive_key(desired_shared_key_len,
raw_shared.data(), raw_shared.size(),
diff --git a/src/lib/pubkey/pk_ops.h b/src/lib/pubkey/pk_ops.h
index 4a136d90f..d3c4c0d9b 100644
--- a/src/lib/pubkey/pk_ops.h
+++ b/src/lib/pubkey/pk_ops.h
@@ -36,7 +36,7 @@ namespace PK_Ops {
class BOTAN_DLL Encryption
{
public:
- virtual secure_vector<byte> encrypt(const byte msg[],
+ virtual secure_vector<uint8_t> encrypt(const uint8_t msg[],
size_t msg_len,
RandomNumberGenerator& rng) = 0;
@@ -51,8 +51,8 @@ class BOTAN_DLL Encryption
class BOTAN_DLL Decryption
{
public:
- virtual secure_vector<byte> decrypt(byte& valid_mask,
- const byte ciphertext[],
+ virtual secure_vector<uint8_t> decrypt(uint8_t& valid_mask,
+ const uint8_t ciphertext[],
size_t ciphertext_len) = 0;
virtual ~Decryption() {}
@@ -69,13 +69,13 @@ class BOTAN_DLL Verification
* @param msg the message
* @param msg_len the length of msg in bytes
*/
- virtual void update(const byte msg[], size_t msg_len) = 0;
+ virtual void update(const uint8_t msg[], size_t msg_len) = 0;
/*
* Perform a verification operation
* @param rng a random number generator
*/
- virtual bool is_valid_signature(const byte sig[], size_t sig_len) = 0;
+ virtual bool is_valid_signature(const uint8_t sig[], size_t sig_len) = 0;
virtual ~Verification() {}
};
@@ -91,13 +91,13 @@ class BOTAN_DLL Signature
* @param msg the message
* @param msg_len the length of msg in bytes
*/
- virtual void update(const byte msg[], size_t msg_len) = 0;
+ virtual void update(const uint8_t msg[], size_t msg_len) = 0;
/*
* Perform a signature operation
* @param rng a random number generator
*/
- virtual secure_vector<byte> sign(RandomNumberGenerator& rng) = 0;
+ virtual secure_vector<uint8_t> sign(RandomNumberGenerator& rng) = 0;
virtual ~Signature() {}
};
@@ -108,9 +108,9 @@ class BOTAN_DLL Signature
class BOTAN_DLL Key_Agreement
{
public:
- virtual secure_vector<byte> agree(size_t key_len,
- const byte other_key[], size_t other_key_len,
- const byte salt[], size_t salt_len) = 0;
+ virtual secure_vector<uint8_t> agree(size_t key_len,
+ const uint8_t other_key[], size_t other_key_len,
+ const uint8_t salt[], size_t salt_len) = 0;
virtual ~Key_Agreement() {}
};
@@ -121,8 +121,8 @@ class BOTAN_DLL Key_Agreement
class BOTAN_DLL KEM_Encryption
{
public:
- virtual void kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ virtual void kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
@@ -134,7 +134,7 @@ class BOTAN_DLL KEM_Encryption
class BOTAN_DLL KEM_Decryption
{
public:
- virtual secure_vector<byte> kem_decrypt(const byte encap_key[],
+ virtual secure_vector<uint8_t> kem_decrypt(const uint8_t encap_key[],
size_t len,
size_t desired_shared_key_len,
const uint8_t salt[],
diff --git a/src/lib/pubkey/pk_ops_impl.h b/src/lib/pubkey/pk_ops_impl.h
index 48552afab..f6c1b0510 100644
--- a/src/lib/pubkey/pk_ops_impl.h
+++ b/src/lib/pubkey/pk_ops_impl.h
@@ -19,7 +19,7 @@ class Encryption_with_EME : public Encryption
public:
size_t max_input_bits() const override;
- secure_vector<byte> encrypt(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
~Encryption_with_EME();
@@ -28,7 +28,7 @@ class Encryption_with_EME : public Encryption
private:
virtual size_t max_raw_input_bits() const = 0;
- virtual secure_vector<byte> raw_encrypt(const byte msg[], size_t len,
+ virtual secure_vector<uint8_t> raw_encrypt(const uint8_t msg[], size_t len,
RandomNumberGenerator& rng) = 0;
std::unique_ptr<EME> m_eme;
};
@@ -36,15 +36,15 @@ class Encryption_with_EME : public Encryption
class Decryption_with_EME : public Decryption
{
public:
- secure_vector<byte> decrypt(byte& valid_mask,
- const byte msg[], size_t msg_len) override;
+ secure_vector<uint8_t> decrypt(uint8_t& valid_mask,
+ const uint8_t msg[], size_t msg_len) override;
~Decryption_with_EME();
protected:
explicit Decryption_with_EME(const std::string& eme);
private:
virtual size_t max_raw_input_bits() const = 0;
- virtual secure_vector<byte> raw_decrypt(const byte msg[], size_t len) = 0;
+ virtual secure_vector<uint8_t> raw_decrypt(const uint8_t msg[], size_t len) = 0;
std::unique_ptr<EME> m_eme;
};
@@ -53,11 +53,11 @@ class Verification_with_EMSA : public Verification
public:
~Verification_with_EMSA();
- void update(const byte msg[], size_t msg_len) override;
- bool is_valid_signature(const byte sig[], size_t sig_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
+ bool is_valid_signature(const uint8_t sig[], size_t sig_len) override;
- bool do_check(const secure_vector<byte>& msg,
- const byte sig[], size_t sig_len);
+ bool do_check(const secure_vector<uint8_t>& msg,
+ const uint8_t sig[], size_t sig_len);
std::string hash_for_signature() { return m_hash; }
@@ -80,7 +80,7 @@ class Verification_with_EMSA : public Verification
* @return the message prefix if this signature scheme uses
* a message prefix, signaled via has_prefix()
*/
- virtual secure_vector<byte> message_prefix() const { throw Exception( "No prefix" ); }
+ virtual secure_vector<uint8_t> message_prefix() const { throw Exception( "No prefix" ); }
/**
* @return boolean specifying if this key type supports message
@@ -96,8 +96,8 @@ class Verification_with_EMSA : public Verification
* @param sig_len the length of sig in bytes
* @returns if signature is a valid one for message
*/
- virtual bool verify(const byte[], size_t,
- const byte[], size_t)
+ virtual bool verify(const uint8_t[], size_t,
+ const uint8_t[], size_t)
{
throw Invalid_State("Message recovery required");
}
@@ -109,7 +109,7 @@ class Verification_with_EMSA : public Verification
* @param msg_len the length of msg in bytes
* @returns recovered message
*/
- virtual secure_vector<byte> verify_mr(const byte[], size_t)
+ virtual secure_vector<uint8_t> verify_mr(const uint8_t[], size_t)
{
throw Invalid_State("Message recovery not supported");
}
@@ -124,9 +124,9 @@ class Verification_with_EMSA : public Verification
class Signature_with_EMSA : public Signature
{
public:
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
- secure_vector<byte> sign(RandomNumberGenerator& rng) override;
+ secure_vector<uint8_t> sign(RandomNumberGenerator& rng) override;
protected:
explicit Signature_with_EMSA(const std::string& emsa);
~Signature_with_EMSA();
@@ -143,7 +143,7 @@ class Signature_with_EMSA : public Signature
* @return the message prefix if this signature scheme uses
* a message prefix, signaled via has_prefix()
*/
- virtual secure_vector<byte> message_prefix() const { throw Exception( "No prefix" ); }
+ virtual secure_vector<uint8_t> message_prefix() const { throw Exception( "No prefix" ); }
std::unique_ptr<EMSA> m_emsa;
private:
@@ -154,10 +154,10 @@ class Signature_with_EMSA : public Signature
*/
virtual size_t max_input_bits() const = 0;
- bool self_test_signature(const std::vector<byte>& msg,
- const std::vector<byte>& sig) const;
+ bool self_test_signature(const std::vector<uint8_t>& msg,
+ const std::vector<uint8_t>& sig) const;
- virtual secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ virtual secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) = 0;
const std::string m_hash;
@@ -167,31 +167,31 @@ class Signature_with_EMSA : public Signature
class Key_Agreement_with_KDF : public Key_Agreement
{
public:
- secure_vector<byte> agree(size_t key_len,
- const byte other_key[], size_t other_key_len,
- const byte salt[], size_t salt_len) override;
+ secure_vector<uint8_t> agree(size_t key_len,
+ const uint8_t other_key[], size_t other_key_len,
+ const uint8_t salt[], size_t salt_len) override;
protected:
explicit Key_Agreement_with_KDF(const std::string& kdf);
~Key_Agreement_with_KDF();
private:
- virtual secure_vector<byte> raw_agree(const byte w[], size_t w_len) = 0;
+ virtual secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) = 0;
std::unique_ptr<KDF> m_kdf;
};
class KEM_Encryption_with_KDF : public KEM_Encryption
{
public:
- void kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ void kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
size_t salt_len) override;
protected:
- virtual void raw_kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& raw_shared_key,
+ virtual void raw_kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& raw_shared_key,
Botan::RandomNumberGenerator& rng) = 0;
explicit KEM_Encryption_with_KDF(const std::string& kdf);
@@ -203,15 +203,15 @@ class KEM_Encryption_with_KDF : public KEM_Encryption
class KEM_Decryption_with_KDF : public KEM_Decryption
{
public:
- secure_vector<byte> kem_decrypt(const byte encap_key[],
+ secure_vector<uint8_t> kem_decrypt(const uint8_t encap_key[],
size_t len,
size_t desired_shared_key_len,
const uint8_t salt[],
size_t salt_len) override;
protected:
- virtual secure_vector<byte>
- raw_kem_decrypt(const byte encap_key[], size_t len) = 0;
+ virtual secure_vector<uint8_t>
+ raw_kem_decrypt(const uint8_t encap_key[], size_t len) = 0;
explicit KEM_Decryption_with_KDF(const std::string& kdf);
~KEM_Decryption_with_KDF();
diff --git a/src/lib/pubkey/pkcs8.cpp b/src/lib/pubkey/pkcs8.cpp
index 7857e3ee0..c4294d563 100644
--- a/src/lib/pubkey/pkcs8.cpp
+++ b/src/lib/pubkey/pkcs8.cpp
@@ -24,10 +24,10 @@ namespace {
/*
* Get info from an EncryptedPrivateKeyInfo
*/
-secure_vector<byte> PKCS8_extract(DataSource& source,
+secure_vector<uint8_t> PKCS8_extract(DataSource& source,
AlgorithmIdentifier& pbe_alg_id)
{
- secure_vector<byte> key_data;
+ secure_vector<uint8_t> key_data;
BER_Decoder(source)
.start_cons(SEQUENCE)
@@ -41,14 +41,14 @@ secure_vector<byte> PKCS8_extract(DataSource& source,
/*
* PEM decode and/or decrypt a private key
*/
-secure_vector<byte> PKCS8_decode(
+secure_vector<uint8_t> PKCS8_decode(
DataSource& source,
std::function<std::string ()> get_passphrase,
AlgorithmIdentifier& pk_alg_id,
bool is_encrypted)
{
AlgorithmIdentifier pbe_alg_id;
- secure_vector<byte> key_data, key;
+ secure_vector<uint8_t> key_data, key;
try {
if(ASN1::maybe_BER(source) && !PEM_Code::matches(source))
@@ -62,7 +62,7 @@ secure_vector<byte> PKCS8_decode(
// todo read more efficiently
while ( !source.end_of_data() )
{
- byte b;
+ uint8_t b;
size_t read = source.read_byte( b );
if ( read )
{
@@ -127,7 +127,7 @@ secure_vector<byte> PKCS8_decode(
/*
* BER encode a PKCS #8 private key, unencrypted
*/
-secure_vector<byte> BER_encode(const Private_Key& key)
+secure_vector<uint8_t> BER_encode(const Private_Key& key)
{
// keeping around for compat
return key.private_key_info();
@@ -166,7 +166,7 @@ choose_pbe_params(const std::string& pbe_algo, const std::string& key_algo)
/*
* BER encode a PKCS #8 private key, encrypted
*/
-std::vector<byte> BER_encode(const Private_Key& key,
+std::vector<uint8_t> BER_encode(const Private_Key& key,
RandomNumberGenerator& rng,
const std::string& pass,
std::chrono::milliseconds msec,
@@ -174,7 +174,7 @@ std::vector<byte> BER_encode(const Private_Key& key,
{
const auto pbe_params = choose_pbe_params(pbe_algo, key.algo_name());
- const std::pair<AlgorithmIdentifier, std::vector<byte>> pbe_info =
+ const std::pair<AlgorithmIdentifier, std::vector<uint8_t>> pbe_info =
pbes2_encrypt(PKCS8::BER_encode(key), pass, msec,
pbe_params.first, pbe_params.second, rng);
@@ -213,7 +213,7 @@ Private_Key* load_key(DataSource& source,
bool is_encrypted)
{
AlgorithmIdentifier alg_id;
- secure_vector<byte> pkcs8_key = PKCS8_decode(source, get_pass, alg_id, is_encrypted);
+ secure_vector<uint8_t> pkcs8_key = PKCS8_decode(source, get_pass, alg_id, is_encrypted);
const std::string alg_name = OIDS::lookup(alg_id.oid);
if(alg_name.empty() || alg_name == alg_id.oid.as_string())
diff --git a/src/lib/pubkey/pkcs8.h b/src/lib/pubkey/pkcs8.h
index 34c687ec1..309ca2798 100644
--- a/src/lib/pubkey/pkcs8.h
+++ b/src/lib/pubkey/pkcs8.h
@@ -33,7 +33,7 @@ namespace PKCS8 {
* @param key the private key to encode
* @return BER encoded key
*/
-BOTAN_DLL secure_vector<byte> BER_encode(const Private_Key& key);
+BOTAN_DLL secure_vector<uint8_t> BER_encode(const Private_Key& key);
/**
* Get a string containing a PEM encoded private key.
@@ -53,7 +53,7 @@ BOTAN_DLL std::string PEM_encode(const Private_Key& key);
default will be chosen.
* @return encrypted key in binary BER form
*/
-BOTAN_DLL std::vector<byte>
+BOTAN_DLL std::vector<uint8_t>
BER_encode(const Private_Key& key,
RandomNumberGenerator& rng,
const std::string& pass,
diff --git a/src/lib/pubkey/pubkey.cpp b/src/lib/pubkey/pubkey.cpp
index dc98d6551..b1bd4b824 100644
--- a/src/lib/pubkey/pubkey.cpp
+++ b/src/lib/pubkey/pubkey.cpp
@@ -13,11 +13,11 @@
namespace Botan {
-secure_vector<byte> PK_Decryptor::decrypt(const byte in[], size_t length) const
+secure_vector<uint8_t> PK_Decryptor::decrypt(const uint8_t in[], size_t length) const
{
- byte valid_mask = 0;
+ uint8_t valid_mask = 0;
- secure_vector<byte> decoded = do_decrypt(valid_mask, in, length);
+ secure_vector<uint8_t> decoded = do_decrypt(valid_mask, in, length);
if(valid_mask == 0)
throw Decoding_Error("Invalid public key ciphertext, cannot decrypt");
@@ -25,19 +25,19 @@ secure_vector<byte> PK_Decryptor::decrypt(const byte in[], size_t length) const
return decoded;
}
-secure_vector<byte>
-PK_Decryptor::decrypt_or_random(const byte in[],
+secure_vector<uint8_t>
+PK_Decryptor::decrypt_or_random(const uint8_t in[],
size_t length,
size_t expected_pt_len,
RandomNumberGenerator& rng,
- const byte required_content_bytes[],
- const byte required_content_offsets[],
+ const uint8_t required_content_bytes[],
+ const uint8_t required_content_offsets[],
size_t required_contents_length) const
{
- const secure_vector<byte> fake_pms = rng.random_vec(expected_pt_len);
+ const secure_vector<uint8_t> fake_pms = rng.random_vec(expected_pt_len);
- byte valid_mask = 0;
- secure_vector<byte> decoded = do_decrypt(valid_mask, in, length);
+ uint8_t valid_mask = 0;
+ secure_vector<uint8_t> decoded = do_decrypt(valid_mask, in, length);
valid_mask &= CT::is_equal(decoded.size(), expected_pt_len);
@@ -56,8 +56,8 @@ PK_Decryptor::decrypt_or_random(const byte in[],
Alternately could always reduce the offset modulo the length?
*/
- const byte exp = required_content_bytes[i];
- const byte off = required_content_offsets[i];
+ const uint8_t exp = required_content_bytes[i];
+ const uint8_t off = required_content_offsets[i];
BOTAN_ASSERT(off < expected_pt_len, "Offset in range of plaintext");
@@ -73,8 +73,8 @@ PK_Decryptor::decrypt_or_random(const byte in[],
return decoded;
}
-secure_vector<byte>
-PK_Decryptor::decrypt_or_random(const byte in[],
+secure_vector<uint8_t>
+PK_Decryptor::decrypt_or_random(const uint8_t in[],
size_t length,
size_t expected_pt_len,
RandomNumberGenerator& rng) const
@@ -95,8 +95,8 @@ PK_Encryptor_EME::PK_Encryptor_EME(const Public_Key& key,
PK_Encryptor_EME::~PK_Encryptor_EME() { /* for unique_ptr */ }
-std::vector<byte>
-PK_Encryptor_EME::enc(const byte in[], size_t length, RandomNumberGenerator& rng) const
+std::vector<uint8_t>
+PK_Encryptor_EME::enc(const uint8_t in[], size_t length, RandomNumberGenerator& rng) const
{
return unlock(m_op->encrypt(in, length, rng));
}
@@ -118,8 +118,8 @@ PK_Decryptor_EME::PK_Decryptor_EME(const Private_Key& key,
PK_Decryptor_EME::~PK_Decryptor_EME() { /* for unique_ptr */ }
-secure_vector<byte> PK_Decryptor_EME::do_decrypt(byte& valid_mask,
- const byte in[], size_t in_len) const
+secure_vector<uint8_t> PK_Decryptor_EME::do_decrypt(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_len) const
{
return m_op->decrypt(valid_mask, in, in_len);
}
@@ -136,8 +136,8 @@ PK_KEM_Encryptor::PK_KEM_Encryptor(const Public_Key& key,
PK_KEM_Encryptor::~PK_KEM_Encryptor() { /* for unique_ptr */ }
-void PK_KEM_Encryptor::encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+void PK_KEM_Encryptor::encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
@@ -163,7 +163,7 @@ PK_KEM_Decryptor::PK_KEM_Decryptor(const Private_Key& key,
PK_KEM_Decryptor::~PK_KEM_Decryptor() { /* for unique_ptr */ }
-secure_vector<byte> PK_KEM_Decryptor::decrypt(const byte encap_key[],
+secure_vector<uint8_t> PK_KEM_Decryptor::decrypt(const uint8_t encap_key[],
size_t encap_key_len,
size_t desired_shared_key_len,
const uint8_t salt[],
@@ -200,8 +200,8 @@ PK_Key_Agreement::PK_Key_Agreement(PK_Key_Agreement&& other) :
{}
SymmetricKey PK_Key_Agreement::derive_key(size_t key_len,
- const byte in[], size_t in_len,
- const byte salt[],
+ const uint8_t in[], size_t in_len,
+ const uint8_t salt[],
size_t salt_len) const
{
return m_op->agree(key_len, in, in_len, salt, salt_len);
@@ -223,14 +223,14 @@ PK_Signer::PK_Signer(const Private_Key& key,
PK_Signer::~PK_Signer() { /* for unique_ptr */ }
-void PK_Signer::update(const byte in[], size_t length)
+void PK_Signer::update(const uint8_t in[], size_t length)
{
m_op->update(in, length);
}
-std::vector<byte> PK_Signer::signature(RandomNumberGenerator& rng)
+std::vector<uint8_t> PK_Signer::signature(RandomNumberGenerator& rng)
{
- const std::vector<byte> sig = unlock(m_op->sign(rng));
+ const std::vector<uint8_t> sig = unlock(m_op->sign(rng));
if(m_sig_format == IEEE_1363)
{
@@ -277,19 +277,19 @@ void PK_Verifier::set_input_format(Signature_Format format)
m_sig_format = format;
}
-bool PK_Verifier::verify_message(const byte msg[], size_t msg_length,
- const byte sig[], size_t sig_length)
+bool PK_Verifier::verify_message(const uint8_t msg[], size_t msg_length,
+ const uint8_t sig[], size_t sig_length)
{
update(msg, msg_length);
return check_signature(sig, sig_length);
}
-void PK_Verifier::update(const byte in[], size_t length)
+void PK_Verifier::update(const uint8_t in[], size_t length)
{
m_op->update(in, length);
}
-bool PK_Verifier::check_signature(const byte sig[], size_t length)
+bool PK_Verifier::check_signature(const uint8_t sig[], size_t length)
{
try {
if(m_sig_format == IEEE_1363)
@@ -298,7 +298,7 @@ bool PK_Verifier::check_signature(const byte sig[], size_t length)
}
else if(m_sig_format == DER_SEQUENCE)
{
- std::vector<byte> real_sig;
+ std::vector<uint8_t> real_sig;
BER_Decoder decoder(sig, length);
BER_Decoder ber_sig = decoder.start_cons(SEQUENCE);
diff --git a/src/lib/pubkey/pubkey.h b/src/lib/pubkey/pubkey.h
index f80e761dd..a5202d973 100644
--- a/src/lib/pubkey/pubkey.h
+++ b/src/lib/pubkey/pubkey.h
@@ -43,7 +43,7 @@ class BOTAN_DLL PK_Encryptor
* @param rng the random number source to use
* @return encrypted message
*/
- std::vector<byte> encrypt(const byte in[], size_t length,
+ std::vector<uint8_t> encrypt(const uint8_t in[], size_t length,
RandomNumberGenerator& rng) const
{
return enc(in, length, rng);
@@ -56,7 +56,7 @@ class BOTAN_DLL PK_Encryptor
* @return encrypted message
*/
template<typename Alloc>
- std::vector<byte> encrypt(const std::vector<byte, Alloc>& in,
+ std::vector<uint8_t> encrypt(const std::vector<uint8_t, Alloc>& in,
RandomNumberGenerator& rng) const
{
return enc(in.data(), in.size(), rng);
@@ -75,7 +75,7 @@ class BOTAN_DLL PK_Encryptor
PK_Encryptor& operator=(const PK_Encryptor&) = delete;
private:
- virtual std::vector<byte> enc(const byte[], size_t,
+ virtual std::vector<uint8_t> enc(const uint8_t[], size_t,
RandomNumberGenerator&) const = 0;
};
@@ -94,7 +94,7 @@ class BOTAN_DLL PK_Decryptor
* @param length the length of the above byte array
* @return decrypted message
*/
- secure_vector<byte> decrypt(const byte in[], size_t length) const;
+ secure_vector<uint8_t> decrypt(const uint8_t in[], size_t length) const;
/**
* Same as above, but taking a vector
@@ -102,7 +102,7 @@ class BOTAN_DLL PK_Decryptor
* @return decrypted message
*/
template<typename Alloc>
- secure_vector<byte> decrypt(const std::vector<byte, Alloc>& in) const
+ secure_vector<uint8_t> decrypt(const std::vector<uint8_t, Alloc>& in) const
{
return decrypt(in.data(), in.size());
}
@@ -113,8 +113,8 @@ class BOTAN_DLL PK_Decryptor
* returns a random string of the expected length. Use to avoid
* oracle attacks, especially against PKCS #1 v1.5 decryption.
*/
- secure_vector<byte>
- decrypt_or_random(const byte in[],
+ secure_vector<uint8_t>
+ decrypt_or_random(const uint8_t in[],
size_t length,
size_t expected_pt_len,
RandomNumberGenerator& rng) const;
@@ -133,13 +133,13 @@ class BOTAN_DLL PK_Decryptor
* the content bytes: if there is any timing variation the version
* check can be used as an oracle to recover the key.
*/
- secure_vector<byte>
- decrypt_or_random(const byte in[],
+ secure_vector<uint8_t>
+ decrypt_or_random(const uint8_t in[],
size_t length,
size_t expected_pt_len,
RandomNumberGenerator& rng,
- const byte required_content_bytes[],
- const byte required_content_offsets[],
+ const uint8_t required_content_bytes[],
+ const uint8_t required_content_offsets[],
size_t required_contents) const;
PK_Decryptor() {}
@@ -149,8 +149,8 @@ class BOTAN_DLL PK_Decryptor
PK_Decryptor& operator=(const PK_Decryptor&) = delete;
private:
- virtual secure_vector<byte> do_decrypt(byte& valid_mask,
- const byte in[], size_t in_len) const = 0;
+ virtual secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask,
+ const uint8_t in[], size_t in_len) const = 0;
};
/**
@@ -206,7 +206,7 @@ class BOTAN_DLL PK_Signer final
* @param rng the rng to use
* @return signature
*/
- std::vector<byte> sign_message(const byte in[], size_t length,
+ std::vector<uint8_t> sign_message(const uint8_t in[], size_t length,
RandomNumberGenerator& rng)
{
this->update(in, length);
@@ -219,7 +219,7 @@ class BOTAN_DLL PK_Signer final
* @param rng the rng to use
* @return signature
*/
- std::vector<byte> sign_message(const std::vector<byte>& in,
+ std::vector<uint8_t> sign_message(const std::vector<uint8_t>& in,
RandomNumberGenerator& rng)
{ return sign_message(in.data(), in.size(), rng); }
@@ -229,7 +229,7 @@ class BOTAN_DLL PK_Signer final
* @param rng the rng to use
* @return signature
*/
- std::vector<byte> sign_message(const secure_vector<byte>& in,
+ std::vector<uint8_t> sign_message(const secure_vector<uint8_t>& in,
RandomNumberGenerator& rng)
{ return sign_message(in.data(), in.size(), rng); }
@@ -237,20 +237,20 @@ class BOTAN_DLL PK_Signer final
* Add a message part (single byte).
* @param in the byte to add
*/
- void update(byte in) { update(&in, 1); }
+ void update(uint8_t in) { update(&in, 1); }
/**
* Add a message part.
* @param in the message part to add as a byte array
* @param length the length of the above byte array
*/
- void update(const byte in[], size_t length);
+ void update(const uint8_t in[], size_t length);
/**
* Add a message part.
* @param in the message part to add
*/
- void update(const std::vector<byte>& in) { update(in.data(), in.size()); }
+ void update(const std::vector<uint8_t>& in) { update(in.data(), in.size()); }
/**
* Add a message part.
@@ -258,7 +258,7 @@ class BOTAN_DLL PK_Signer final
*/
void update(const std::string& in)
{
- update(reinterpret_cast<const byte*>(in.data()), in.size());
+ update(reinterpret_cast<const uint8_t*>(in.data()), in.size());
}
/**
@@ -267,7 +267,7 @@ class BOTAN_DLL PK_Signer final
* @param rng the rng to use
* @return signature of the total message
*/
- std::vector<byte> signature(RandomNumberGenerator& rng);
+ std::vector<uint8_t> signature(RandomNumberGenerator& rng);
/**
* Set the output format of the signature.
@@ -313,8 +313,8 @@ class BOTAN_DLL PK_Verifier final
* @param sig_length the length of the above byte array sig
* @return true if the signature is valid
*/
- bool verify_message(const byte msg[], size_t msg_length,
- const byte sig[], size_t sig_length);
+ bool verify_message(const uint8_t msg[], size_t msg_length,
+ const uint8_t sig[], size_t sig_length);
/**
* Verify a signature.
* @param msg the message that the signature belongs to
@@ -322,8 +322,8 @@ class BOTAN_DLL PK_Verifier final
* @return true if the signature is valid
*/
template<typename Alloc, typename Alloc2>
- bool verify_message(const std::vector<byte, Alloc>& msg,
- const std::vector<byte, Alloc2>& sig)
+ bool verify_message(const std::vector<uint8_t, Alloc>& msg,
+ const std::vector<uint8_t, Alloc2>& sig)
{
return verify_message(msg.data(), msg.size(),
sig.data(), sig.size());
@@ -334,7 +334,7 @@ class BOTAN_DLL PK_Verifier final
* signature to be verified.
* @param in the byte to add
*/
- void update(byte in) { update(&in, 1); }
+ void update(uint8_t in) { update(&in, 1); }
/**
* Add a message part of the message corresponding to the
@@ -342,14 +342,14 @@ class BOTAN_DLL PK_Verifier final
* @param msg_part the new message part as a byte array
* @param length the length of the above byte array
*/
- void update(const byte msg_part[], size_t length);
+ void update(const uint8_t msg_part[], size_t length);
/**
* Add a message part of the message corresponding to the
* signature to be verified.
* @param in the new message part
*/
- void update(const std::vector<byte>& in)
+ void update(const std::vector<uint8_t>& in)
{ update(in.data(), in.size()); }
/**
@@ -358,7 +358,7 @@ class BOTAN_DLL PK_Verifier final
*/
void update(const std::string& in)
{
- update(reinterpret_cast<const byte*>(in.data()), in.size());
+ update(reinterpret_cast<const uint8_t*>(in.data()), in.size());
}
/**
@@ -368,7 +368,7 @@ class BOTAN_DLL PK_Verifier final
* @param length the length of the above byte array
* @return true if the signature is valid, false otherwise
*/
- bool check_signature(const byte sig[], size_t length);
+ bool check_signature(const uint8_t sig[], size_t length);
/**
* Check the signature of the buffered message, i.e. the one build
@@ -377,7 +377,7 @@ class BOTAN_DLL PK_Verifier final
* @return true if the signature is valid, false otherwise
*/
template<typename Alloc>
- bool check_signature(const std::vector<byte, Alloc>& sig)
+ bool check_signature(const std::vector<uint8_t, Alloc>& sig)
{
return check_signature(sig.data(), sig.size());
}
@@ -446,9 +446,9 @@ class BOTAN_DLL PK_Key_Agreement final
* @param params_len the length of params in bytes
*/
SymmetricKey derive_key(size_t key_len,
- const byte in[],
+ const uint8_t in[],
size_t in_len,
- const byte params[],
+ const uint8_t params[],
size_t params_len) const;
/*
@@ -460,8 +460,8 @@ class BOTAN_DLL PK_Key_Agreement final
* @param params_len the length of params in bytes
*/
SymmetricKey derive_key(size_t key_len,
- const std::vector<byte>& in,
- const byte params[],
+ const std::vector<uint8_t>& in,
+ const uint8_t params[],
size_t params_len) const
{
return derive_key(key_len, in.data(), in.size(),
@@ -476,11 +476,11 @@ class BOTAN_DLL PK_Key_Agreement final
* @param params extra derivation params
*/
SymmetricKey derive_key(size_t key_len,
- const byte in[], size_t in_len,
+ const uint8_t in[], size_t in_len,
const std::string& params = "") const
{
return derive_key(key_len, in, in_len,
- reinterpret_cast<const byte*>(params.data()),
+ reinterpret_cast<const uint8_t*>(params.data()),
params.length());
}
@@ -491,11 +491,11 @@ class BOTAN_DLL PK_Key_Agreement final
* @param params extra derivation params
*/
SymmetricKey derive_key(size_t key_len,
- const std::vector<byte>& in,
+ const std::vector<uint8_t>& in,
const std::string& params = "") const
{
return derive_key(key_len, in.data(), in.size(),
- reinterpret_cast<const byte*>(params.data()),
+ reinterpret_cast<const uint8_t*>(params.data()),
params.length());
}
@@ -542,7 +542,7 @@ class BOTAN_DLL PK_Encryptor_EME final : public PK_Encryptor
PK_Encryptor_EME& operator=(const PK_Encryptor_EME&) = delete;
PK_Encryptor_EME(const PK_Encryptor_EME&) = delete;
private:
- std::vector<byte> enc(const byte[], size_t,
+ std::vector<uint8_t> enc(const uint8_t[], size_t,
RandomNumberGenerator& rng) const override;
std::unique_ptr<PK_Ops::Encryption> m_op;
@@ -584,8 +584,8 @@ class BOTAN_DLL PK_Decryptor_EME final : public PK_Decryptor
PK_Decryptor_EME& operator=(const PK_Decryptor_EME&) = delete;
PK_Decryptor_EME(const PK_Decryptor_EME&) = delete;
private:
- secure_vector<byte> do_decrypt(byte& valid_mask,
- const byte in[],
+ secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask,
+ const uint8_t in[],
size_t in_len) const override;
std::unique_ptr<PK_Ops::Decryption> m_op;
@@ -631,8 +631,8 @@ class BOTAN_DLL PK_KEM_Encryptor final
* @param salt a salt value used in the KDF
* @param salt_len size of the salt value in bytes
*/
- void encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ void encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const uint8_t salt[],
@@ -647,8 +647,8 @@ class BOTAN_DLL PK_KEM_Encryptor final
* @param salt a salt value used in the KDF
*/
template<typename Alloc>
- void encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ void encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng,
const std::vector<uint8_t, Alloc>& salt)
@@ -668,8 +668,8 @@ class BOTAN_DLL PK_KEM_Encryptor final
* @param desired_shared_key_len desired size of the shared key in bytes
* @param rng the RNG to use
*/
- void encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& out_shared_key,
+ void encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& out_shared_key,
size_t desired_shared_key_len,
Botan::RandomNumberGenerator& rng)
{
@@ -725,7 +725,7 @@ class BOTAN_DLL PK_KEM_Decryptor final
* @param salt_len size of the salt value in bytes
* @return the shared data encryption key
*/
- secure_vector<byte> decrypt(const byte encap_key[],
+ secure_vector<uint8_t> decrypt(const uint8_t encap_key[],
size_t encap_key_len,
size_t desired_shared_key_len,
const uint8_t salt[],
@@ -738,7 +738,7 @@ class BOTAN_DLL PK_KEM_Decryptor final
* @param desired_shared_key_len desired size of the shared key in bytes
* @return the shared data encryption key
*/
- secure_vector<byte> decrypt(const byte encap_key[],
+ secure_vector<uint8_t> decrypt(const uint8_t encap_key[],
size_t encap_key_len,
size_t desired_shared_key_len)
{
@@ -755,9 +755,9 @@ class BOTAN_DLL PK_KEM_Decryptor final
* @return the shared data encryption key
*/
template<typename Alloc1, typename Alloc2>
- secure_vector<byte> decrypt(const std::vector<byte, Alloc1>& encap_key,
+ secure_vector<uint8_t> decrypt(const std::vector<uint8_t, Alloc1>& encap_key,
size_t desired_shared_key_len,
- const std::vector<byte, Alloc2>& salt)
+ const std::vector<uint8_t, Alloc2>& salt)
{
return this->decrypt(encap_key.data(), encap_key.size(),
desired_shared_key_len,
diff --git a/src/lib/pubkey/rfc6979/rfc6979.h b/src/lib/pubkey/rfc6979/rfc6979.h
index 2518535f7..90b4e3697 100644
--- a/src/lib/pubkey/rfc6979/rfc6979.h
+++ b/src/lib/pubkey/rfc6979/rfc6979.h
@@ -34,7 +34,7 @@ class BOTAN_DLL RFC6979_Nonce_Generator
BigInt m_k;
size_t m_qlen, m_rlen;
std::unique_ptr<HMAC_DRBG> m_hmac_drbg;
- secure_vector<byte> m_rng_in, m_rng_out;
+ secure_vector<uint8_t> m_rng_in, m_rng_out;
};
/**
diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp
index 0e364f69f..46192c558 100644
--- a/src/lib/pubkey/rsa/rsa.cpp
+++ b/src/lib/pubkey/rsa/rsa.cpp
@@ -41,7 +41,7 @@ AlgorithmIdentifier RSA_PublicKey::algorithm_identifier() const
AlgorithmIdentifier::USE_NULL_PARAM);
}
-std::vector<byte> RSA_PublicKey::public_key_bits() const
+std::vector<uint8_t> RSA_PublicKey::public_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -52,7 +52,7 @@ std::vector<byte> RSA_PublicKey::public_key_bits() const
}
RSA_PublicKey::RSA_PublicKey(const AlgorithmIdentifier&,
- const std::vector<byte>& key_bits)
+ const std::vector<uint8_t>& key_bits)
{
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
@@ -72,7 +72,7 @@ bool RSA_PublicKey::check_key(RandomNumberGenerator&, bool) const
return true;
}
-secure_vector<byte> RSA_PrivateKey::private_key_bits() const
+secure_vector<uint8_t> RSA_PrivateKey::private_key_bits() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -90,7 +90,7 @@ secure_vector<byte> RSA_PrivateKey::private_key_bits() const
}
RSA_PrivateKey::RSA_PrivateKey(const AlgorithmIdentifier&,
- const secure_vector<byte>& key_bits)
+ const secure_vector<uint8_t>& key_bits)
{
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
@@ -253,7 +253,7 @@ class RSA_Signature_Operation : public PK_Ops::Signature_with_EMSA,
{
}
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator&) override
{
const BigInt m(msg, msg_len);
@@ -277,7 +277,7 @@ class RSA_Decryption_Operation : public PK_Ops::Decryption_with_EME,
{
}
- secure_vector<byte> raw_decrypt(const byte msg[], size_t msg_len) override
+ secure_vector<uint8_t> raw_decrypt(const uint8_t msg[], size_t msg_len) override
{
const BigInt m(msg, msg_len);
const BigInt x = blinded_private_op(m);
@@ -299,8 +299,8 @@ class RSA_KEM_Decryption_Operation : public PK_Ops::KEM_Decryption_with_KDF,
RSA_Private_Operation(key, rng)
{}
- secure_vector<byte>
- raw_kem_decrypt(const byte encap_key[], size_t len) override
+ secure_vector<uint8_t>
+ raw_kem_decrypt(const uint8_t encap_key[], size_t len) override
{
const BigInt m(encap_key, len);
const BigInt x = blinded_private_op(m);
@@ -349,7 +349,7 @@ class RSA_Encryption_Operation : public PK_Ops::Encryption_with_EME,
size_t max_raw_input_bits() const override { return get_max_input_bits(); };
- secure_vector<byte> raw_encrypt(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_encrypt(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator&) override
{
BigInt m(msg, msg_len);
@@ -372,7 +372,7 @@ class RSA_Verify_Operation : public PK_Ops::Verification_with_EMSA,
bool with_recovery() const override { return true; }
- secure_vector<byte> verify_mr(const byte msg[], size_t msg_len) override
+ secure_vector<uint8_t> verify_mr(const uint8_t msg[], size_t msg_len) override
{
BigInt m(msg, msg_len);
return BigInt::encode_locked(public_op(m));
@@ -390,8 +390,8 @@ class RSA_KEM_Encryption_Operation : public PK_Ops::KEM_Encryption_with_KDF,
RSA_Public_Operation(key) {}
private:
- void raw_kem_encrypt(secure_vector<byte>& out_encapsulated_key,
- secure_vector<byte>& raw_shared_key,
+ void raw_kem_encrypt(secure_vector<uint8_t>& out_encapsulated_key,
+ secure_vector<uint8_t>& raw_shared_key,
Botan::RandomNumberGenerator& rng) override
{
const BigInt r = BigInt::random_integer(rng, 1, get_n());
diff --git a/src/lib/pubkey/rsa/rsa.h b/src/lib/pubkey/rsa/rsa.h
index 4561aa40f..eb128d413 100644
--- a/src/lib/pubkey/rsa/rsa.h
+++ b/src/lib/pubkey/rsa/rsa.h
@@ -25,7 +25,7 @@ class BOTAN_DLL RSA_PublicKey : public virtual Public_Key
* @param key_bits DER encoded public key bits
*/
RSA_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
/**
* Create a public key.
@@ -41,7 +41,7 @@ class BOTAN_DLL RSA_PublicKey : public virtual Public_Key
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
/**
* @return public modulus
@@ -88,7 +88,7 @@ class BOTAN_DLL RSA_PrivateKey : public Private_Key, public RSA_PublicKey
* @param key_bits PKCS #8 structure
*/
RSA_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits);
+ const secure_vector<uint8_t>& key_bits);
/**
* Construct a private key from the specified parameters.
@@ -138,7 +138,7 @@ class BOTAN_DLL RSA_PrivateKey : public Private_Key, public RSA_PublicKey
const BigInt& get_d1() const { return m_d1; }
const BigInt& get_d2() const { return m_d2; }
- secure_vector<byte> private_key_bits() const override;
+ secure_vector<uint8_t> private_key_bits() const override;
std::unique_ptr<PK_Ops::Decryption>
create_decryption_op(RandomNumberGenerator& rng,
diff --git a/src/lib/pubkey/x509_key.cpp b/src/lib/pubkey/x509_key.cpp
index 508d41432..700020901 100644
--- a/src/lib/pubkey/x509_key.cpp
+++ b/src/lib/pubkey/x509_key.cpp
@@ -16,7 +16,7 @@ namespace Botan {
namespace X509 {
-std::vector<byte> BER_encode(const Public_Key& key)
+std::vector<uint8_t> BER_encode(const Public_Key& key)
{
// keeping it around for compat
return key.subject_public_key();
@@ -38,7 +38,7 @@ Public_Key* load_key(DataSource& source)
{
try {
AlgorithmIdentifier alg_id;
- std::vector<byte> key_bits;
+ std::vector<uint8_t> key_bits;
if(ASN1::maybe_BER(source) && !PEM_Code::matches(source))
{
@@ -88,7 +88,7 @@ Public_Key* load_key(const std::string& fsname)
/*
* Extract a public key and return it
*/
-Public_Key* load_key(const std::vector<byte>& mem)
+Public_Key* load_key(const std::vector<uint8_t>& mem)
{
DataSource_Memory source(mem);
return X509::load_key(source);
diff --git a/src/lib/pubkey/x509_key.h b/src/lib/pubkey/x509_key.h
index 7162b338e..1844e6568 100644
--- a/src/lib/pubkey/x509_key.h
+++ b/src/lib/pubkey/x509_key.h
@@ -30,7 +30,7 @@ namespace X509 {
* @param key the public key to encode
* @return BER encoding of this key
*/
-BOTAN_DLL std::vector<byte> BER_encode(const Public_Key& key);
+BOTAN_DLL std::vector<uint8_t> BER_encode(const Public_Key& key);
/**
* PEM encode a public key into a string.
@@ -60,7 +60,7 @@ BOTAN_DLL Public_Key* load_key(const std::string& filename);
* @param enc the memory region containing the DER or PEM encoded key
* @return new public key object
*/
-BOTAN_DLL Public_Key* load_key(const std::vector<byte>& enc);
+BOTAN_DLL Public_Key* load_key(const std::vector<uint8_t>& enc);
/**
* Copy a key.
diff --git a/src/lib/pubkey/xmss/xmss_address.h b/src/lib/pubkey/xmss/xmss_address.h
index 07bfd1dbf..4ad30c3d9 100644
--- a/src/lib/pubkey/xmss/xmss_address.h
+++ b/src/lib/pubkey/xmss/xmss_address.h
@@ -112,7 +112,7 @@ class XMSS_Address
**/
void set_type(Type type)
{
- m_data[15] = static_cast<byte>(type);
+ m_data[15] = static_cast<uint8_t>(type);
std::fill(m_data.begin() + 16, m_data.end(), 0);
}
@@ -138,7 +138,7 @@ class XMSS_Address
BOTAN_ASSERT(value != Key_Mask::Mask_LSB_Mode ||
get_type() != Type::OTS_Hash_Address,
"Invalid Key_Mask for current XMSS_Address::Type.");
- m_data[31] = static_cast<byte>(value);
+ m_data[31] = static_cast<uint8_t>(value);
}
/**
@@ -323,12 +323,12 @@ class XMSS_Address
set_hi32(3, value);
}
- const secure_vector<byte>& bytes() const
+ const secure_vector<uint8_t>& bytes() const
{
return m_data;
}
- secure_vector<byte>& bytes()
+ secure_vector<uint8_t>& bytes()
{
return m_data;
}
@@ -353,20 +353,20 @@ class XMSS_Address
set_type(type);
}
- XMSS_Address(const secure_vector<byte>& data) : m_data(data)
+ XMSS_Address(const secure_vector<uint8_t>& data) : m_data(data)
{
BOTAN_ASSERT(m_data.size() == m_address_size,
"XMSS_Address must be of 256 bits size.");
}
- XMSS_Address(secure_vector<byte>&& data) : m_data(std::move(data))
+ XMSS_Address(secure_vector<uint8_t>&& data) : m_data(std::move(data))
{
BOTAN_ASSERT(m_data.size() == m_address_size,
"XMSS_Address must be of 256 bits size.");
}
protected:
- secure_vector<byte> m_data;
+ secure_vector<uint8_t> m_data;
private:
static const size_t m_address_size = 32;
diff --git a/src/lib/pubkey/xmss/xmss_common_ops.cpp b/src/lib/pubkey/xmss/xmss_common_ops.cpp
index aec584201..a66a413bd 100644
--- a/src/lib/pubkey/xmss/xmss_common_ops.cpp
+++ b/src/lib/pubkey/xmss/xmss_common_ops.cpp
@@ -11,26 +11,26 @@
namespace Botan {
void
-XMSS_Common_Ops::randomize_tree_hash(secure_vector<byte>& result,
- const secure_vector<byte>& left,
- const secure_vector<byte>& right,
+XMSS_Common_Ops::randomize_tree_hash(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& left,
+ const secure_vector<uint8_t>& right,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Key_Mode);
- secure_vector<byte> key { m_hash.prf(seed, adrs.bytes()) };
+ secure_vector<uint8_t> key { m_hash.prf(seed, adrs.bytes()) };
adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_MSB_Mode);
- secure_vector<byte> bitmask_l { m_hash.prf(seed, adrs.bytes()) };
+ secure_vector<uint8_t> bitmask_l { m_hash.prf(seed, adrs.bytes()) };
adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Mask_LSB_Mode);
- secure_vector<byte> bitmask_r { m_hash.prf(seed, adrs.bytes()) };
+ secure_vector<uint8_t> bitmask_r { m_hash.prf(seed, adrs.bytes()) };
BOTAN_ASSERT(bitmask_l.size() == left.size() &&
bitmask_r.size() == right.size(),
"Bitmask size doesn't match node size.");
- secure_vector<byte> concat_xor(m_xmss_params.element_size() * 2);
+ secure_vector<uint8_t> concat_xor(m_xmss_params.element_size() * 2);
for(size_t i = 0; i < left.size(); i++)
{
concat_xor[i] = left[i] ^ bitmask_l[i];
@@ -42,10 +42,10 @@ XMSS_Common_Ops::randomize_tree_hash(secure_vector<byte>& result,
void
-XMSS_Common_Ops::create_l_tree(secure_vector<byte>& result,
+XMSS_Common_Ops::create_l_tree(secure_vector<uint8_t>& result,
wots_keysig_t pk,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
size_t l = m_xmss_params.len();
adrs.set_tree_height(0);
diff --git a/src/lib/pubkey/xmss/xmss_common_ops.h b/src/lib/pubkey/xmss/xmss_common_ops.h
index bcf036f5c..26cb27d26 100644
--- a/src/lib/pubkey/xmss/xmss_common_ops.h
+++ b/src/lib/pubkey/xmss/xmss_common_ops.h
@@ -17,7 +17,7 @@
namespace Botan {
-typedef std::vector<secure_vector<byte>> wots_keysig_t;
+typedef std::vector<secure_vector<uint8_t>> wots_keysig_t;
/**
* Operations shared by XMSS signature generation and verification operations.
@@ -41,11 +41,11 @@ class XMSS_Common_Ops
* @param[in] seed The seed for G.
**/
void randomize_tree_hash(
- secure_vector<byte>& result,
- const secure_vector<byte>& left,
- const secure_vector<byte>& right,
+ secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& left,
+ const secure_vector<uint8_t>& right,
XMSS_Address& adrs,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
/**
* Algorithm 8: "ltree"
@@ -59,10 +59,10 @@ class XMSS_Common_Ops
* @param[in] seed The seed generated during the public key generation.
**/
void create_l_tree(
- secure_vector<byte>& result,
+ secure_vector<uint8_t>& result,
wots_keysig_t pk,
XMSS_Address& adrs,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
protected:
XMSS_Parameters m_xmss_params;
diff --git a/src/lib/pubkey/xmss/xmss_hash.cpp b/src/lib/pubkey/xmss/xmss_hash.cpp
index 3731f7751..27352b0e1 100644
--- a/src/lib/pubkey/xmss/xmss_hash.cpp
+++ b/src/lib/pubkey/xmss/xmss_hash.cpp
@@ -33,9 +33,9 @@ XMSS_Hash::XMSS_Hash(const std::string& h_func_name) :
}
void
-XMSS_Hash::h(secure_vector<byte>& result,
- const secure_vector<byte>& key,
- const secure_vector<byte>& data)
+XMSS_Hash::h(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data)
{
m_hash->update(m_zero_padding);
m_hash->update(m_id_h);
@@ -44,9 +44,9 @@ XMSS_Hash::h(secure_vector<byte>& result,
m_hash->final(result);
}
-void XMSS_Hash::h_msg_init(const secure_vector<byte>& randomness,
- const secure_vector<byte>& root,
- const secure_vector<byte>& index_bytes)
+void XMSS_Hash::h_msg_init(const secure_vector<uint8_t>& randomness,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& index_bytes)
{
m_msg_hash->clear();
m_msg_hash->update(m_zero_padding);
@@ -56,26 +56,26 @@ void XMSS_Hash::h_msg_init(const secure_vector<byte>& randomness,
m_msg_hash->update(index_bytes);
}
-void XMSS_Hash::h_msg_update(const secure_vector<byte>& data)
+void XMSS_Hash::h_msg_update(const secure_vector<uint8_t>& data)
{
m_msg_hash->update(data);
}
-void XMSS_Hash::h_msg_update(const byte data[], size_t size)
+void XMSS_Hash::h_msg_update(const uint8_t data[], size_t size)
{
m_msg_hash->update(data, size);
}
-secure_vector<byte> XMSS_Hash::h_msg_final()
+secure_vector<uint8_t> XMSS_Hash::h_msg_final()
{
return m_msg_hash->final();
}
-secure_vector<byte>
-XMSS_Hash::h_msg(const secure_vector<byte>& randomness,
- const secure_vector<byte>& root,
- const secure_vector<byte>& index_bytes,
- const secure_vector<byte>& data)
+secure_vector<uint8_t>
+XMSS_Hash::h_msg(const secure_vector<uint8_t>& randomness,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& index_bytes,
+ const secure_vector<uint8_t>& data)
{
h_msg_init(randomness, root, index_bytes);
m_msg_hash->update(data);
diff --git a/src/lib/pubkey/xmss/xmss_hash.h b/src/lib/pubkey/xmss/xmss_hash.h
index 2cca26658..29a6ff90e 100644
--- a/src/lib/pubkey/xmss/xmss_hash.h
+++ b/src/lib/pubkey/xmss/xmss_hash.h
@@ -35,9 +35,9 @@ class XMSS_Hash
* @param[in] key An n-byte key value.
* @param[in] data A 32-byte XMSS_Address data value
**/
- inline void prf(secure_vector<byte>& result,
- const secure_vector<byte>& key,
- const secure_vector<byte>& data)
+ inline void prf(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data)
{
m_hash->update(m_zero_padding);
m_hash->update(m_id_prf);
@@ -54,8 +54,8 @@ class XMSS_Hash
* @param[in] data A 32-byte XMSS_Address data value
* @return result The hash calculated using key and data.
**/
- inline secure_vector<byte> prf(const secure_vector<byte>& key,
- const secure_vector<byte>& data)
+ inline secure_vector<uint8_t> prf(const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data)
{
m_hash->update(m_zero_padding);
m_hash->update(m_id_prf);
@@ -71,9 +71,9 @@ class XMSS_Hash
* @param[in] key key of length n bytes.
* @param[in] data string of arbitrary length.
**/
- void f(secure_vector<byte>& result,
- const secure_vector<byte>& key,
- const secure_vector<byte>& data)
+ void f(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data)
{
m_hash->update(m_zero_padding);
m_hash->update(m_id_f);
@@ -90,9 +90,9 @@ class XMSS_Hash
* @param[in] key key of length n bytes.
* @param[in] data string of 2n bytes length.
**/
- void h(secure_vector<byte>& result,
- const secure_vector<byte>& key,
- const secure_vector<byte>& data);
+ void h(secure_vector<uint8_t>& result,
+ const secure_vector<uint8_t>& key,
+ const secure_vector<uint8_t>& data);
/**
* Cryptographic hash function h accepting 3n byte keys and data
@@ -105,10 +105,10 @@ class XMSS_Hash
*
* @return hash value of n-bytes length.
**/
- secure_vector<byte> h_msg(const secure_vector<byte>& randomness,
- const secure_vector<byte>& root,
- const secure_vector<byte>& index_bytes,
- const secure_vector<byte>& data);
+ secure_vector<uint8_t> h_msg(const secure_vector<uint8_t>& randomness,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& index_bytes,
+ const secure_vector<uint8_t>& data);
/**
* Initializes buffered h_msg computation with prefix data.
@@ -117,16 +117,16 @@ class XMSS_Hash
* @param root n-byte root node.
* @param index_bytes Index value padded with leading zeros.
**/
- void h_msg_init(const secure_vector<byte>& randomness,
- const secure_vector<byte>& root,
- const secure_vector<byte>& index_bytes);
+ void h_msg_init(const secure_vector<uint8_t>& randomness,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& index_bytes);
/**
* Adds a message block to buffered h_msg computation.
*
* @param data A message block
**/
- void h_msg_update(const secure_vector<byte>& data);
+ void h_msg_update(const secure_vector<uint8_t>& data);
/**
* Adds a message block to buffered h_msg computation.
@@ -134,7 +134,7 @@ class XMSS_Hash
* @param data A message block
* @param size Length of the message block in bytes.
**/
- void h_msg_update(const byte data[], size_t size);
+ void h_msg_update(const uint8_t data[], size_t size);
/**
* Finalizes buffered h_msg computation and retrieves the result.
@@ -142,15 +142,15 @@ class XMSS_Hash
* @return Hash calculated using the prefix set by h_msg_init() and
* message blocks provided through calls to h_msg_update().
**/
- secure_vector<byte> h_msg_final();
+ secure_vector<uint8_t> h_msg_final();
size_t output_length() const { return m_output_length; };
private:
- static const byte m_id_f = 0x00;
- static const byte m_id_h = 0x01;
- static const byte m_id_hmsg = 0x02;
- static const byte m_id_prf = 0x03;
+ static const uint8_t m_id_f = 0x00;
+ static const uint8_t m_id_h = 0x01;
+ static const uint8_t m_id_hmsg = 0x02;
+ static const uint8_t m_id_prf = 0x03;
const std::string m_hash_func_name;
std::unique_ptr<HashFunction> m_hash;
@@ -158,7 +158,7 @@ class XMSS_Hash
size_t m_output_length;
//32 byte id prefixes prepended to the hash input.
- std::vector<byte> m_zero_padding;
+ std::vector<uint8_t> m_zero_padding;
};
}
diff --git a/src/lib/pubkey/xmss/xmss_index_registry.cpp b/src/lib/pubkey/xmss/xmss_index_registry.cpp
index e26cfdad4..73f962820 100644
--- a/src/lib/pubkey/xmss/xmss_index_registry.cpp
+++ b/src/lib/pubkey/xmss/xmss_index_registry.cpp
@@ -14,15 +14,15 @@ namespace Botan {
const std::string XMSS_Index_Registry::m_index_hash_function = "SHA-256";
uint64_t XMSS_Index_Registry::make_key_id(
- const secure_vector<byte>& private_seed,
- const secure_vector<byte>& prf) const
+ const secure_vector<uint8_t>& private_seed,
+ const secure_vector<uint8_t>& prf) const
{
std::unique_ptr<HashFunction> hash =
HashFunction::create(m_index_hash_function);
BOTAN_ASSERT(hash != nullptr, "XMSS_Index_Registry requires SHA-256");
hash->update(private_seed);
hash->update(prf);
- secure_vector<byte> result = hash->final();
+ secure_vector<uint8_t> result = hash->final();
uint64_t key_id = 0;
for(size_t i = 0; i < sizeof(key_id); i++)
{
@@ -33,8 +33,8 @@ uint64_t XMSS_Index_Registry::make_key_id(
}
std::shared_ptr<Atomic<size_t>>
-XMSS_Index_Registry::get(const secure_vector<byte>& private_seed,
- const secure_vector<byte>& prf)
+XMSS_Index_Registry::get(const secure_vector<uint8_t>& private_seed,
+ const secure_vector<uint8_t>& prf)
{
size_t pos = get(make_key_id(private_seed, prf));
diff --git a/src/lib/pubkey/xmss/xmss_index_registry.h b/src/lib/pubkey/xmss/xmss_index_registry.h
index 77842e4f3..decd50a8a 100644
--- a/src/lib/pubkey/xmss/xmss_index_registry.h
+++ b/src/lib/pubkey/xmss/xmss_index_registry.h
@@ -54,8 +54,8 @@ class XMSS_Index_Registry
* @return last unused leaf index for private_key.
**/
std::shared_ptr<Atomic<size_t>>
- get(const secure_vector<byte>& private_seed,
- const secure_vector<byte>& prf);
+ get(const secure_vector<uint8_t>& private_seed,
+ const secure_vector<uint8_t>& prf);
private:
XMSS_Index_Registry()
@@ -70,8 +70,8 @@ class XMSS_Index_Registry
*
* @return unique integral identifier for an XMSS private key.
**/
- uint64_t make_key_id(const secure_vector<byte>& private_seed,
- const secure_vector<byte>& prf) const;
+ uint64_t make_key_id(const secure_vector<uint8_t>& private_seed,
+ const secure_vector<uint8_t>& prf) const;
/**
* Retrieves the index position of a key within the registry or
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.cpp b/src/lib/pubkey/xmss/xmss_privatekey.cpp
index b409789bf..3f2f949ca 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.cpp
+++ b/src/lib/pubkey/xmss/xmss_privatekey.cpp
@@ -20,7 +20,7 @@
namespace Botan {
-XMSS_PrivateKey::XMSS_PrivateKey(const secure_vector<byte>& raw_key)
+XMSS_PrivateKey::XMSS_PrivateKey(const secure_vector<uint8_t>& raw_key)
: XMSS_PublicKey(unlock(raw_key)),
XMSS_Common_Ops(XMSS_PublicKey::m_xmss_params.oid()),
m_wots_priv_key(m_wots_params.oid(), m_public_seed),
@@ -58,7 +58,7 @@ XMSS_PrivateKey::XMSS_PrivateKey(const secure_vector<byte>& raw_key)
begin = end;
end = begin + m_wots_params.element_size();
- m_wots_priv_key.set_private_seed(secure_vector<byte>(begin, end));
+ m_wots_priv_key.set_private_seed(secure_vector<uint8_t>(begin, end));
set_unused_leaf_index(static_cast<size_t>(unused_leaf));
}
@@ -79,27 +79,27 @@ XMSS_PrivateKey::XMSS_PrivateKey(
adrs));
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_PrivateKey::tree_hash(size_t start_idx,
size_t target_node_height,
XMSS_Address& adrs)
{
- const secure_vector<byte>& seed = this->public_seed();
+ const secure_vector<uint8_t>& seed = this->public_seed();
BOTAN_ASSERT((start_idx % (1 << target_node_height)) == 0,
"Start index must be divisible by 2^{target node height}.");
- std::vector<secure_vector<byte>> nodes(
+ std::vector<secure_vector<uint8_t>> nodes(
XMSS_PublicKey::m_xmss_params.tree_height() + 1,
- secure_vector<byte>(XMSS_PublicKey::m_xmss_params.element_size()));
+ secure_vector<uint8_t>(XMSS_PublicKey::m_xmss_params.element_size()));
// node stack, holds all nodes on stack and one extra "pending" node. This
// temporary node referred to as "node" in the XMSS standard document stays
// a pending element, meaning it is not regarded as element on the stack
// until level is increased.
- std::vector<byte> node_levels(XMSS_PublicKey::m_xmss_params.tree_height() + 1);
+ std::vector<uint8_t> node_levels(XMSS_PublicKey::m_xmss_params.tree_height() + 1);
- byte level = 0;
+ uint8_t level = 0;
XMSS_WOTS_PublicKey pk(m_wots_priv_key.wots_parameters().oid(), seed);
size_t last_idx = static_cast<size_t>(1 << target_node_height) + start_idx;
@@ -152,16 +152,16 @@ XMSS_PrivateKey::recover_global_leaf_index() const
m_prf);
}
-secure_vector<byte> XMSS_PrivateKey::raw_private_key() const
+secure_vector<uint8_t> XMSS_PrivateKey::raw_private_key() const
{
- std::vector<byte> pk { raw_public_key() };
- secure_vector<byte> result(pk.begin(), pk.end());
+ std::vector<uint8_t> pk { raw_public_key() };
+ secure_vector<uint8_t> result(pk.begin(), pk.end());
result.reserve(size());
for(int i = 7; i >= 0; i--)
{
result.push_back(
- static_cast<byte>(
+ static_cast<uint8_t>(
static_cast<uint64_t>(unused_leaf_index()) >> 8 * i));
}
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.h b/src/lib/pubkey/xmss/xmss_privatekey.h
index 79959c247..c8db2d7b8 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.h
+++ b/src/lib/pubkey/xmss/xmss_privatekey.h
@@ -60,7 +60,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
*
* @param raw_key An XMSS private key serialized using raw_private_key().
**/
- XMSS_PrivateKey(const secure_vector<byte>& raw_key);
+ XMSS_PrivateKey(const secure_vector<uint8_t>& raw_key);
/**
* Creates a new XMSS private key for the chosen XMSS signature method
@@ -79,10 +79,10 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
**/
XMSS_PrivateKey(XMSS_Parameters::xmss_algorithm_t xmss_algo_id,
size_t idx_leaf,
- const secure_vector<byte>& wots_priv_seed,
- const secure_vector<byte>& prf,
- const secure_vector<byte>& root,
- const secure_vector<byte>& public_seed)
+ const secure_vector<uint8_t>& wots_priv_seed,
+ const secure_vector<uint8_t>& prf,
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& public_seed)
: XMSS_PublicKey(xmss_algo_id, root, public_seed),
XMSS_Common_Ops(xmss_algo_id),
m_wots_priv_key(XMSS_PublicKey::m_xmss_params.ots_oid(),
@@ -170,30 +170,30 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
return m_wots_priv_key;
}
- const secure_vector<byte>& prf() const
+ const secure_vector<uint8_t>& prf() const
{
return m_prf;
}
- secure_vector<byte>& prf()
+ secure_vector<uint8_t>& prf()
{
return m_prf;
}
virtual void set_public_seed(
- const secure_vector<byte>& public_seed) override
+ const secure_vector<uint8_t>& public_seed) override
{
m_public_seed = public_seed;
m_wots_priv_key.set_public_seed(public_seed);
}
- virtual void set_public_seed(secure_vector<byte>&& public_seed) override
+ virtual void set_public_seed(secure_vector<uint8_t>&& public_seed) override
{
m_public_seed = std::move(public_seed);
m_wots_priv_key.set_public_seed(m_public_seed);
}
- virtual const secure_vector<byte>& public_seed() const override
+ virtual const secure_vector<uint8_t>& public_seed() const override
{
return m_public_seed;
}
@@ -203,7 +203,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
const std::string&,
const std::string& provider) const override;
- virtual secure_vector<byte> private_key_bits() const override
+ virtual secure_vector<uint8_t> private_key_bits() const override
{
return raw_private_key();
}
@@ -223,7 +223,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
* 4-byte OID, n-byte root node, n-byte public seed,
* 8-byte unused leaf index, n-byte prf seed, n-byte private seed.
**/
- virtual secure_vector<byte> raw_private_key() const;
+ virtual secure_vector<uint8_t> raw_private_key() const;
/**
* Algorithm 9: "treeHash"
* Computes the internal n-byte nodes of a Merkle tree.
@@ -236,7 +236,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
* leftmost leaf being the hash of the WOTS+ pk with index
* start_idx.
**/
- secure_vector<byte> tree_hash(
+ secure_vector<uint8_t> tree_hash(
size_t start_idx,
size_t target_node_height,
XMSS_Address& adrs);
@@ -248,7 +248,7 @@ class BOTAN_DLL XMSS_PrivateKey : public virtual XMSS_PublicKey,
std::shared_ptr<Atomic<size_t>> recover_global_leaf_index() const;
XMSS_WOTS_PrivateKey m_wots_priv_key;
- secure_vector<byte> m_prf;
+ secure_vector<uint8_t> m_prf;
XMSS_Index_Registry& m_index_reg;
};
diff --git a/src/lib/pubkey/xmss/xmss_publickey.cpp b/src/lib/pubkey/xmss/xmss_publickey.cpp
index 73bcdb1cf..801388253 100644
--- a/src/lib/pubkey/xmss/xmss_publickey.cpp
+++ b/src/lib/pubkey/xmss/xmss_publickey.cpp
@@ -20,7 +20,7 @@
namespace Botan {
-XMSS_PublicKey::XMSS_PublicKey(const std::vector<byte>& raw_key)
+XMSS_PublicKey::XMSS_PublicKey(const std::vector<uint8_t>& raw_key)
: m_xmss_params(XMSS_PublicKey::deserialize_xmss_oid(raw_key)),
m_wots_params(m_xmss_params.ots_oid())
{
@@ -45,7 +45,7 @@ XMSS_PublicKey::XMSS_PublicKey(const std::vector<byte>& raw_key)
}
XMSS_Parameters::xmss_algorithm_t
-XMSS_PublicKey::deserialize_xmss_oid(const std::vector<byte>& raw_key)
+XMSS_PublicKey::deserialize_xmss_oid(const std::vector<uint8_t>& raw_key)
{
if(raw_key.size() < 4)
{
@@ -72,14 +72,14 @@ XMSS_PublicKey::create_verification_op(const std::string&,
throw Provider_Not_Found(algo_name(), provider);
}
-std::vector<byte> XMSS_PublicKey::raw_public_key() const
+std::vector<uint8_t> XMSS_PublicKey::raw_public_key() const
{
- std::vector<byte> result
+ std::vector<uint8_t> result
{
- static_cast<byte>(m_xmss_params.oid() >> 24),
- static_cast<byte>(m_xmss_params.oid() >> 16),
- static_cast<byte>(m_xmss_params.oid() >> 8),
- static_cast<byte>(m_xmss_params.oid())
+ static_cast<uint8_t>(m_xmss_params.oid() >> 24),
+ static_cast<uint8_t>(m_xmss_params.oid() >> 16),
+ static_cast<uint8_t>(m_xmss_params.oid() >> 8),
+ static_cast<uint8_t>(m_xmss_params.oid())
};
std::copy(m_root.begin(), m_root.end(), std::back_inserter(result));
diff --git a/src/lib/pubkey/xmss/xmss_publickey.h b/src/lib/pubkey/xmss/xmss_publickey.h
index 3cc98ff77..9186b16a4 100644
--- a/src/lib/pubkey/xmss/xmss_publickey.h
+++ b/src/lib/pubkey/xmss/xmss_publickey.h
@@ -62,7 +62,7 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
* Creates an XMSS public key from a byte sequence produced by
* raw_private_key().
**/
- XMSS_PublicKey(const std::vector<byte>& raw_key);
+ XMSS_PublicKey(const std::vector<uint8_t>& raw_key);
/**
* Creates a new XMSS public key for a chosen XMSS signature method as
@@ -73,8 +73,8 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
* @param public_seed Public seed value.
**/
XMSS_PublicKey(XMSS_Parameters::xmss_algorithm_t xmss_oid,
- const secure_vector<byte>& root,
- const secure_vector<byte>& public_seed)
+ const secure_vector<uint8_t>& root,
+ const secure_vector<uint8_t>& public_seed)
: m_xmss_params(xmss_oid), m_wots_params(m_xmss_params.ots_oid()),
m_root(root), m_public_seed(public_seed) {}
@@ -87,8 +87,8 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
* @param public_seed Public seed value.
**/
XMSS_PublicKey(XMSS_Parameters::xmss_algorithm_t xmss_oid,
- secure_vector<byte>&& root,
- secure_vector<byte>&& public_seed)
+ secure_vector<uint8_t>&& root,
+ secure_vector<uint8_t>&& public_seed)
: m_xmss_params(xmss_oid), m_wots_params(m_xmss_params.ots_oid()),
m_root(std::move(root)), m_public_seed(std::move(public_seed)) {}
@@ -146,42 +146,42 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
return m_wots_params;
}
- secure_vector<byte>& root()
+ secure_vector<uint8_t>& root()
{
return m_root;
}
- void set_root(const secure_vector<byte>& root)
+ void set_root(const secure_vector<uint8_t>& root)
{
m_root = root;
}
- void set_root(secure_vector<byte>&& root)
+ void set_root(secure_vector<uint8_t>&& root)
{
m_root = std::move(root);
}
- const secure_vector<byte>& root() const
+ const secure_vector<uint8_t>& root() const
{
return m_root;
}
- virtual secure_vector<byte>& public_seed()
+ virtual secure_vector<uint8_t>& public_seed()
{
return m_public_seed;
}
- virtual void set_public_seed(const secure_vector<byte>& public_seed)
+ virtual void set_public_seed(const secure_vector<uint8_t>& public_seed)
{
m_public_seed = public_seed;
}
- virtual void set_public_seed(secure_vector<byte>&& public_seed)
+ virtual void set_public_seed(secure_vector<uint8_t>&& public_seed)
{
m_public_seed = std::move(public_seed);
}
- virtual const secure_vector<byte>& public_seed() const
+ virtual const secure_vector<uint8_t>& public_seed() const
{
return m_public_seed;
}
@@ -221,7 +221,7 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
*
* @return raw public key bits.
**/
- virtual std::vector<byte> public_key_bits() const override
+ virtual std::vector<uint8_t> public_key_bits() const override
{
return raw_public_key();
}
@@ -238,23 +238,23 @@ class BOTAN_DLL XMSS_PublicKey : public virtual Public_Key
}
/**
- * Generates a non standartized byte sequence representing the XMSS
+ * Generates a non standardized byte sequence representing the XMSS
* public key, as defined in [1] (p. 23, "XMSS Public Key")
*
* @return 4-byte OID, followed by n-byte root node, followed by
* public seed.
**/
- virtual std::vector<byte> raw_public_key() const;
+ virtual std::vector<uint8_t> raw_public_key() const;
protected:
XMSS_Parameters m_xmss_params;
XMSS_WOTS_Parameters m_wots_params;
- secure_vector<byte> m_root;
- secure_vector<byte> m_public_seed;
+ secure_vector<uint8_t> m_root;
+ secure_vector<uint8_t> m_public_seed;
private:
XMSS_Parameters::xmss_algorithm_t deserialize_xmss_oid(
- const std::vector<byte>& raw_key);
+ const std::vector<uint8_t>& raw_key);
};
}
diff --git a/src/lib/pubkey/xmss/xmss_signature.cpp b/src/lib/pubkey/xmss/xmss_signature.cpp
index a54d8d9cd..497a25f2b 100644
--- a/src/lib/pubkey/xmss/xmss_signature.cpp
+++ b/src/lib/pubkey/xmss/xmss_signature.cpp
@@ -10,7 +10,7 @@
namespace Botan {
XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
- const secure_vector<byte>& raw_sig)
+ const secure_vector<uint8_t>& raw_sig)
: m_leaf_idx(0), m_randomness(0, 0x00), m_tree_sig()
{
BOTAN_ASSERT(sizeof(size_t) >= ceil(static_cast<float>(
@@ -38,7 +38,7 @@ XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
{
begin = end;
end = begin + xmss_params.element_size();
- m_tree_sig.ots_signature().push_back(secure_vector<byte>(0));
+ m_tree_sig.ots_signature().push_back(secure_vector<uint8_t>(0));
m_tree_sig.ots_signature().back().reserve(
xmss_params.element_size());
std::copy(begin,
@@ -50,7 +50,7 @@ XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
{
begin = end;
end = begin + xmss_params.element_size();
- m_tree_sig.authentication_path().push_back(secure_vector<byte>(0));
+ m_tree_sig.authentication_path().push_back(secure_vector<uint8_t>(0));
m_tree_sig.authentication_path().back().reserve(
xmss_params.element_size());
std::copy(begin,
@@ -59,18 +59,18 @@ XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
}
}
-secure_vector<byte> XMSS_Signature::bytes() const
+secure_vector<uint8_t> XMSS_Signature::bytes() const
{
- secure_vector<byte> result
+ secure_vector<uint8_t> result
{
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 56U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 48U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 40U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 32U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 24U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 16U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) >> 8U),
- static_cast<byte>(static_cast<uint64_t>(m_leaf_idx) )
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 56U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 48U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 40U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 32U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 24U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 16U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) >> 8U),
+ static_cast<uint8_t>(static_cast<uint64_t>(m_leaf_idx) )
};
std::copy(m_randomness.begin(),
diff --git a/src/lib/pubkey/xmss/xmss_signature.h b/src/lib/pubkey/xmss/xmss_signature.h
index 662aa8988..cbeb8c514 100644
--- a/src/lib/pubkey/xmss/xmss_signature.h
+++ b/src/lib/pubkey/xmss/xmss_signature.h
@@ -22,7 +22,7 @@ class BOTAN_DLL XMSS_Signature
{
public:
/**
- * Creates a signature from an XMSS signature method and a byte sequence
+ * Creates a signature from an XMSS signature method and a uint8_t sequence
* representing a raw signature.
*
* @param oid XMSS signature method
@@ -30,7 +30,7 @@ class BOTAN_DLL XMSS_Signature
* XMSS_Signature::bytes().
**/
XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid,
- const secure_vector<byte>& raw_sig);
+ const secure_vector<uint8_t>& raw_sig);
/**
* Creates an XMSS Signature from a leaf index used for signature
@@ -41,7 +41,7 @@ class BOTAN_DLL XMSS_Signature
* @param tree_sig A tree signature.
**/
XMSS_Signature(size_t leaf_idx,
- const secure_vector<byte>& randomness,
+ const secure_vector<uint8_t>& randomness,
const XMSS_WOTS_PublicKey::TreeSignature& tree_sig)
: m_leaf_idx(leaf_idx), m_randomness(randomness),
m_tree_sig(tree_sig) {};
@@ -55,7 +55,7 @@ class BOTAN_DLL XMSS_Signature
* @param tree_sig A tree signature.
**/
XMSS_Signature(size_t leaf_idx,
- secure_vector<byte>&& randomness,
+ secure_vector<uint8_t>&& randomness,
XMSS_WOTS_PublicKey::TreeSignature&& tree_sig)
: m_leaf_idx(leaf_idx), m_randomness(std::move(randomness)),
m_tree_sig(std::move(tree_sig)) {};
@@ -63,22 +63,22 @@ class BOTAN_DLL XMSS_Signature
size_t unused_leaf_index() const { return m_leaf_idx; }
void set_unused_leaf_idx(size_t idx) { m_leaf_idx = idx; }
- const secure_vector<byte> randomness() const
+ const secure_vector<uint8_t> randomness() const
{
return m_randomness;
}
- secure_vector<byte>& randomness()
+ secure_vector<uint8_t>& randomness()
{
return m_randomness;
}
- void set_randomness(const secure_vector<byte>& randomness)
+ void set_randomness(const secure_vector<uint8_t>& randomness)
{
m_randomness = randomness;
}
- void set_randomness(secure_vector<byte>&& randomness)
+ void set_randomness(secure_vector<uint8_t>&& randomness)
{
m_randomness = std::move(randomness);
}
@@ -115,11 +115,11 @@ class BOTAN_DLL XMSS_Signature
* @return serialized signature, a sequence of
* (len + h + 1)n bytes.
**/
- secure_vector<byte> bytes() const;
+ secure_vector<uint8_t> bytes() const;
private:
size_t m_leaf_idx;
- secure_vector<byte> m_randomness;
+ secure_vector<uint8_t> m_randomness;
XMSS_WOTS_PublicKey::TreeSignature m_tree_sig;
};
diff --git a/src/lib/pubkey/xmss/xmss_signature_operation.cpp b/src/lib/pubkey/xmss/xmss_signature_operation.cpp
index 80b9c4746..bf7588abe 100644
--- a/src/lib/pubkey/xmss/xmss_signature_operation.cpp
+++ b/src/lib/pubkey/xmss/xmss_signature_operation.cpp
@@ -28,7 +28,7 @@ XMSS_Signature_Operation::XMSS_Signature_Operation(
{}
XMSS_WOTS_PublicKey::TreeSignature
-XMSS_Signature_Operation::generate_tree_signature(const secure_vector<byte>& msg,
+XMSS_Signature_Operation::generate_tree_signature(const secure_vector<uint8_t>& msg,
XMSS_PrivateKey& xmss_priv_key,
XMSS_Address& adrs)
{
@@ -42,7 +42,7 @@ XMSS_Signature_Operation::generate_tree_signature(const secure_vector<byte>& msg
}
XMSS_Signature
-XMSS_Signature_Operation::sign(const secure_vector<byte>& msg_hash,
+XMSS_Signature_Operation::sign(const secure_vector<uint8_t>& msg_hash,
XMSS_PrivateKey& xmss_priv_key)
{
XMSS_Address adrs;
@@ -68,18 +68,18 @@ XMSS_Signature_Operation::build_auth_path(XMSS_PrivateKey& priv_key,
return auth_path;
}
-void XMSS_Signature_Operation::update(const byte msg[], size_t msg_len)
+void XMSS_Signature_Operation::update(const uint8_t msg[], size_t msg_len)
{
initialize();
m_hash.h_msg_update(msg, msg_len);
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_Signature_Operation::sign(RandomNumberGenerator&)
{
initialize();
- secure_vector<byte> signature(sign(m_hash.h_msg_final(),
+ secure_vector<uint8_t> signature(sign(m_hash.h_msg_final(),
m_priv_key).bytes());
m_is_initialized = false;
return signature;
@@ -91,7 +91,7 @@ void XMSS_Signature_Operation::initialize()
if(m_is_initialized)
return;
- secure_vector<byte> index_bytes;
+ secure_vector<uint8_t> index_bytes;
// reserve leaf index so it can not be reused in by another signature
// operation using the same private key.
m_leaf_idx = m_priv_key.reserve_unused_leaf_index();
diff --git a/src/lib/pubkey/xmss/xmss_signature_operation.h b/src/lib/pubkey/xmss/xmss_signature_operation.h
index bd22f3428..8b6c87401 100644
--- a/src/lib/pubkey/xmss/xmss_signature_operation.h
+++ b/src/lib/pubkey/xmss/xmss_signature_operation.h
@@ -46,9 +46,9 @@ class BOTAN_DLL XMSS_Signature_Operation : public virtual PK_Ops::Signature,
*
* @return serialized XMSS signature.
**/
- secure_vector<byte> sign(RandomNumberGenerator&) override;
+ secure_vector<uint8_t> sign(RandomNumberGenerator&) override;
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
private:
/**
@@ -60,7 +60,7 @@ class BOTAN_DLL XMSS_Signature_Operation : public virtual PK_Ops::Signature,
* @param adrs A XMSS Address.
**/
XMSS_WOTS_PublicKey::TreeSignature generate_tree_signature(
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_PrivateKey& xmss_priv_key,
XMSS_Address& adrs);
@@ -75,7 +75,7 @@ class BOTAN_DLL XMSS_Signature_Operation : public virtual PK_Ops::Signature,
* @return The signature of msg signed using xmss_priv_key.
**/
XMSS_Signature sign(
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_PrivateKey& xmss_priv_key);
wots_keysig_t build_auth_path(XMSS_PrivateKey& priv_key,
@@ -84,7 +84,7 @@ class BOTAN_DLL XMSS_Signature_Operation : public virtual PK_Ops::Signature,
void initialize();
XMSS_PrivateKey m_priv_key;
- secure_vector<byte> m_randomness;
+ secure_vector<uint8_t> m_randomness;
size_t m_leaf_idx;
bool m_is_initialized;
};
diff --git a/src/lib/pubkey/xmss/xmss_tools.h b/src/lib/pubkey/xmss/xmss_tools.h
index 66eaf28e2..109ab91bd 100644
--- a/src/lib/pubkey/xmss/xmss_tools.h
+++ b/src/lib/pubkey/xmss/xmss_tools.h
@@ -38,7 +38,7 @@ namespace Botan {
template<typename T,
typename U = typename std::enable_if<std::is_integral<T>::value,
void>::type>
- static void concat(secure_vector<byte>& target, const T& src);
+ static void concat(secure_vector<uint8_t>& target, const T& src);
/**
* Concatenates the last n bytes of the byte representation in big-endian
@@ -53,16 +53,16 @@ namespace Botan {
template <typename T,
typename U = typename std::enable_if<std::is_integral<T>::value,
void>::type>
- static void concat(secure_vector<byte>& target, const T& src, size_t len);
+ static void concat(secure_vector<uint8_t>& target, const T& src, size_t len);
private:
XMSS_Tools();
};
template <typename T, typename U>
-void XMSS_Tools::concat(secure_vector<byte>& target, const T& src)
+void XMSS_Tools::concat(secure_vector<uint8_t>& target, const T& src)
{
- const byte* src_bytes = reinterpret_cast<const byte*>(&src);
+ const uint8_t* src_bytes = reinterpret_cast<const uint8_t*>(&src);
if(CPUID::is_little_endian())
{
std::reverse_copy(src_bytes,
@@ -79,7 +79,7 @@ void XMSS_Tools::concat(secure_vector<byte>& target, const T& src)
template <typename T, typename U>
-void XMSS_Tools::concat(secure_vector<byte>& target,
+void XMSS_Tools::concat(secure_vector<uint8_t>& target,
const T& src,
size_t len)
{
@@ -89,7 +89,7 @@ void XMSS_Tools::concat(secure_vector<byte>& target,
target.resize(target.size() + len - sizeof(src), 0);
}
- const byte* src_bytes = reinterpret_cast<const byte*>(&src);
+ const uint8_t* src_bytes = reinterpret_cast<const uint8_t*>(&src);
if(CPUID::is_little_endian())
{
std::reverse_copy(src_bytes,
diff --git a/src/lib/pubkey/xmss/xmss_verification_operation.cpp b/src/lib/pubkey/xmss/xmss_verification_operation.cpp
index 34d7ee647..fe712d4c8 100644
--- a/src/lib/pubkey/xmss/xmss_verification_operation.cpp
+++ b/src/lib/pubkey/xmss/xmss_verification_operation.cpp
@@ -20,11 +20,11 @@ XMSS_Verification_Operation::XMSS_Verification_Operation(
{
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_Verification_Operation::root_from_signature(const XMSS_Signature& sig,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
adrs.set_type(XMSS_Address::Type::OTS_Hash_Address);
adrs.set_ots_address(sig.unused_leaf_index());
@@ -38,7 +38,7 @@ XMSS_Verification_Operation::root_from_signature(const XMSS_Signature& sig,
adrs.set_type(XMSS_Address::Type::LTree_Address);
adrs.set_ltree_address(sig.unused_leaf_index());
- std::array<secure_vector<byte>, 2> node;
+ std::array<secure_vector<uint8_t>, 2> node;
create_l_tree(node[0], pub_key_ots, adrs, seed);
adrs.set_type(XMSS_Address::Type::Hash_Tree_Address);
@@ -72,21 +72,21 @@ XMSS_Verification_Operation::root_from_signature(const XMSS_Signature& sig,
bool
XMSS_Verification_Operation::verify(const XMSS_Signature& sig,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
const XMSS_PublicKey& public_key)
{
XMSS_Address adrs;
- secure_vector<byte> index_bytes;
+ secure_vector<uint8_t> index_bytes;
XMSS_Tools::concat(index_bytes,
sig.unused_leaf_index(),
m_xmss_params.element_size());
- secure_vector<byte> msg_digest =
+ secure_vector<uint8_t> msg_digest =
m_hash.h_msg(sig.randomness(),
public_key.root(),
index_bytes,
msg);
- secure_vector<byte> node = root_from_signature(sig,
+ secure_vector<uint8_t> node = root_from_signature(sig,
msg_digest,
adrs,
public_key.public_seed());
@@ -101,18 +101,18 @@ XMSS_Verification_Operation::verify(const XMSS_Signature& sig,
// impossible.
// Possible solution: Change PK_Ops::Verification interface to take the
// signature as constructor argument, make sign a parameterless member call.
-void XMSS_Verification_Operation::update(const byte msg[], size_t msg_len)
+void XMSS_Verification_Operation::update(const uint8_t msg[], size_t msg_len)
{
std::copy(msg, msg + msg_len, std::back_inserter(m_msg_buf));
}
-bool XMSS_Verification_Operation::is_valid_signature(const byte sig[],
+bool XMSS_Verification_Operation::is_valid_signature(const uint8_t sig[],
size_t sig_len)
{
try
{
XMSS_Signature signature(m_pub_key.xmss_parameters().oid(),
- secure_vector<byte>(sig, sig + sig_len));
+ secure_vector<uint8_t>(sig, sig + sig_len));
bool result = verify(signature, m_msg_buf, m_pub_key);
m_msg_buf.clear();
return result;
diff --git a/src/lib/pubkey/xmss/xmss_verification_operation.h b/src/lib/pubkey/xmss/xmss_verification_operation.h
index 35720f73d..1ef836fec 100644
--- a/src/lib/pubkey/xmss/xmss_verification_operation.h
+++ b/src/lib/pubkey/xmss/xmss_verification_operation.h
@@ -35,10 +35,10 @@ namespace Botan {
virtual ~XMSS_Verification_Operation() {}
- virtual bool is_valid_signature(const byte sig[],
+ virtual bool is_valid_signature(const uint8_t sig[],
size_t sig_len) override;
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
private:
/**
@@ -53,11 +53,11 @@ namespace Botan {
* @return An n-byte string holding the value of the root of a tree
* defined by the input parameters.
**/
- secure_vector<byte> root_from_signature(
+ secure_vector<uint8_t> root_from_signature(
const XMSS_Signature& sig,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_Address& ards,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
/**
* Algorithm 14: "XMSS_verify"
@@ -70,11 +70,11 @@ namespace Botan {
* @return true if signature sig is valid for msg, false otherwise.
**/
bool verify(const XMSS_Signature& sig,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
const XMSS_PublicKey& pub_key);
XMSS_PublicKey m_pub_key;
- secure_vector<byte> m_msg_buf;
+ secure_vector<uint8_t> m_msg_buf;
};
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h b/src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h
index deb5d7f87..66941fbfd 100644
--- a/src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_addressed_privatekey.h
@@ -54,7 +54,7 @@ class XMSS_WOTS_Addressed_PrivateKey
return m_priv_key.pkcs8_algorithm_identifier();
}
- virtual secure_vector<byte> private_key_bits() const override
+ virtual secure_vector<uint8_t> private_key_bits() const override
{
return m_priv_key.private_key_bits();
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h b/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h
index 74e686f9f..144be4efd 100644
--- a/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_addressed_publickey.h
@@ -82,7 +82,7 @@ class XMSS_WOTS_Addressed_PublicKey : public virtual Public_Key
return m_pub_key.estimated_strength();
}
- virtual std::vector<byte> public_key_bits() const override
+ virtual std::vector<uint8_t> public_key_bits() const override
{
return m_pub_key.public_key_bits();
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp b/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp
index 5d0349677..4472b3881 100644
--- a/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_common_ops.cpp
@@ -13,11 +13,11 @@
namespace Botan {
void
-XMSS_WOTS_Common_Ops::chain(secure_vector<byte>& result,
+XMSS_WOTS_Common_Ops::chain(secure_vector<uint8_t>& result,
size_t start_idx,
size_t steps,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
for(size_t i = start_idx;
i < (start_idx + steps) && i < m_wots_params.wots_parameter();
diff --git a/src/lib/pubkey/xmss/xmss_wots_common_ops.h b/src/lib/pubkey/xmss/xmss_wots_common_ops.h
index f3153515c..471b67c77 100644
--- a/src/lib/pubkey/xmss/xmss_wots_common_ops.h
+++ b/src/lib/pubkey/xmss/xmss_wots_common_ops.h
@@ -40,11 +40,11 @@ class XMSS_WOTS_Common_Ops
* @param[in] adrs An OTS Hash Address.
* @param[in] seed A Seed.
**/
- void chain(secure_vector<byte>& result,
+ void chain(secure_vector<uint8_t>& result,
size_t start_idx,
size_t steps,
XMSS_Address& adrs,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
XMSS_WOTS_Parameters m_wots_params;
XMSS_Hash m_hash;
diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
index 3a1c1902d..704bcab36 100644
--- a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp
@@ -87,10 +87,10 @@ XMSS_WOTS_Parameters::XMSS_WOTS_Parameters(ots_algorithm_t oid)
"\"len\" detedted.");
}
-secure_vector<byte>
-XMSS_WOTS_Parameters::base_w(const secure_vector<byte>& msg, size_t out_size) const
+secure_vector<uint8_t>
+XMSS_WOTS_Parameters::base_w(const secure_vector<uint8_t>& msg, size_t out_size) const
{
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
size_t in = 0;
size_t total = 0;
size_t bits = 0;
@@ -104,24 +104,24 @@ XMSS_WOTS_Parameters::base_w(const secure_vector<byte>& msg, size_t out_size) co
bits += 8;
}
bits -= m_lg_w;
- result.push_back(static_cast<byte>((total >> bits) & (m_w - 1)));
+ result.push_back(static_cast<uint8_t>((total >> bits) & (m_w - 1)));
}
return result;
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_WOTS_Parameters::base_w(size_t value) const
{
value <<= (8 - ((m_len_2 * m_lg_w) % 8));
size_t len_2_bytes = static_cast<size_t>(
ceil(static_cast<float>(m_len_2 * m_lg_w) / 8.f));
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
XMSS_Tools::concat(result, value, len_2_bytes);
return base_w(result, m_len_2);
}
void
-XMSS_WOTS_Parameters::append_checksum(secure_vector<byte>& data)
+XMSS_WOTS_Parameters::append_checksum(secure_vector<uint8_t>& data)
{
size_t csum = 0;
@@ -130,7 +130,7 @@ XMSS_WOTS_Parameters::append_checksum(secure_vector<byte>& data)
csum += wots_parameter() - 1 - data[i];
}
- secure_vector<byte> csum_bytes = base_w(csum);
+ secure_vector<uint8_t> csum_bytes = base_w(csum);
std::move(csum_bytes.begin(), csum_bytes.end(), std::back_inserter(data));
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.h b/src/lib/pubkey/xmss/xmss_wots_parameters.h
index cc89c3d4a..d48348316 100644
--- a/src/lib/pubkey/xmss/xmss_wots_parameters.h
+++ b/src/lib/pubkey/xmss/xmss_wots_parameters.h
@@ -55,11 +55,11 @@ class XMSS_WOTS_Parameters
*
* @return Input string converted to the given base.
**/
- secure_vector<byte> base_w(const secure_vector<byte>& msg, size_t out_size) const;
+ secure_vector<uint8_t> base_w(const secure_vector<uint8_t>& msg, size_t out_size) const;
- secure_vector<byte> base_w(size_t value) const;
+ secure_vector<uint8_t> base_w(size_t value) const;
- void append_checksum(secure_vector<byte>& data);
+ void append_checksum(secure_vector<uint8_t>& data);
/**
* @return XMSS WOTS registry name for the chosen parameter set.
diff --git a/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp b/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp
index e3f4cab94..d7cd3479c 100644
--- a/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_privatekey.cpp
@@ -14,10 +14,10 @@
namespace Botan {
wots_keysig_t
-XMSS_WOTS_PrivateKey::generate(const secure_vector<byte>& priv_seed)
+XMSS_WOTS_PrivateKey::generate(const secure_vector<uint8_t>& priv_seed)
{
wots_keysig_t priv_key(m_wots_params.len(),
- secure_vector<byte>(0));
+ secure_vector<uint8_t>(0));
for(size_t i = 0; i < m_wots_params.len(); i++)
{
@@ -57,11 +57,11 @@ XMSS_WOTS_PrivateKey::generate_public_key(XMSS_WOTS_PublicKey& pub_key,
wots_keysig_t
XMSS_WOTS_PrivateKey::sign(
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
XMSS_Address& adrs)
{
- secure_vector<byte> msg_digest
+ secure_vector<uint8_t> msg_digest
{
m_wots_params.base_w(msg, m_wots_params.len_1())
};
diff --git a/src/lib/pubkey/xmss/xmss_wots_privatekey.h b/src/lib/pubkey/xmss/xmss_wots_privatekey.h
index cf84fd076..445105640 100644
--- a/src/lib/pubkey/xmss/xmss_wots_privatekey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_privatekey.h
@@ -65,7 +65,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
* @param rng A random number generator to use for key generation.
**/
XMSS_WOTS_PrivateKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& public_seed,
+ const secure_vector<uint8_t>& public_seed,
RandomNumberGenerator &rng)
: XMSS_WOTS_PublicKey(oid, public_seed),
m_private_seed(rng.random_vec(m_wots_params.element_size()))
@@ -85,7 +85,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
* of public keys derived from this private key.
**/
XMSS_WOTS_PrivateKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& public_seed)
+ const secure_vector<uint8_t>& public_seed)
: XMSS_WOTS_PublicKey(oid, public_seed)
{}
@@ -100,8 +100,8 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
* @param private_seed A secret uniformly random n-byte value.
**/
XMSS_WOTS_PrivateKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& public_seed,
- const secure_vector<byte>& private_seed)
+ const secure_vector<uint8_t>& public_seed,
+ const secure_vector<uint8_t>& private_seed)
: XMSS_WOTS_PublicKey(oid, public_seed),
m_private_seed(private_seed)
{
@@ -118,7 +118,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
**/
wots_keysig_t operator[](size_t i)
{
- secure_vector<byte> idx_bytes;
+ secure_vector<uint8_t> idx_bytes;
XMSS_Tools::concat(idx_bytes, i, m_wots_params.element_size());
m_hash.h(idx_bytes, m_private_seed, idx_bytes);
return generate(idx_bytes);
@@ -134,12 +134,12 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
**/
wots_keysig_t operator[](const XMSS_Address& adrs)
{
- secure_vector<byte> result;
+ secure_vector<uint8_t> result;
m_hash.prf(result, m_private_seed, adrs.bytes());
return generate(result);
}
- wots_keysig_t generate_private_key(const secure_vector<byte>& priv_seed);
+ wots_keysig_t generate_private_key(const secure_vector<uint8_t>& priv_seed);
/**
* Algorithm 4: "WOTS_genPK"
@@ -179,7 +179,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
*
* @return signature for msg.
**/
- wots_keysig_t sign(const secure_vector<byte>& msg,
+ wots_keysig_t sign(const secure_vector<uint8_t>& msg,
XMSS_Address& adrs);
/**
@@ -188,7 +188,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
*
* @return secret seed.
**/
- const secure_vector<byte>& private_seed() const
+ const secure_vector<uint8_t>& private_seed() const
{
return m_private_seed;
}
@@ -199,7 +199,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
*
* @param private_seed Uniformly random n-byte value.
**/
- void set_private_seed(const secure_vector<byte>& private_seed)
+ void set_private_seed(const secure_vector<uint8_t>& private_seed)
{
m_private_seed = private_seed;
}
@@ -210,7 +210,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
*
* @param private_seed Uniformly random n-byte value.
**/
- void set_private_seed(secure_vector<byte>&& private_seed)
+ void set_private_seed(secure_vector<uint8_t>&& private_seed)
{
m_private_seed = std::move(private_seed);
}
@@ -226,7 +226,7 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
const std::string&,
const std::string& provider) const override;
- virtual secure_vector<byte> private_key_bits() const override
+ virtual secure_vector<uint8_t> private_key_bits() const override
{
throw Not_Implemented("No PKCS8 key format defined for XMSS-WOTS.");
}
@@ -241,9 +241,9 @@ class BOTAN_DLL XMSS_WOTS_PrivateKey : public virtual XMSS_WOTS_PublicKey,
* @returns a vector of length key_size() of vectors of n bytes length
* containing uniformly random data.
**/
- wots_keysig_t generate(const secure_vector<byte>& private_seed);
+ wots_keysig_t generate(const secure_vector<uint8_t>& private_seed);
- secure_vector<byte> m_private_seed;
+ secure_vector<uint8_t> m_private_seed;
};
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.cpp b/src/lib/pubkey/xmss/xmss_wots_publickey.cpp
index 0eea59ea3..5ae04e71f 100644
--- a/src/lib/pubkey/xmss/xmss_wots_publickey.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_publickey.cpp
@@ -14,11 +14,11 @@
namespace Botan {
void
-XMSS_WOTS_PublicKey::chain(secure_vector<byte>& result,
+XMSS_WOTS_PublicKey::chain(secure_vector<uint8_t>& result,
size_t start_idx,
size_t steps,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
for(size_t i = start_idx;
i < (start_idx + steps) && i < m_wots_params.wots_parameter();
@@ -39,12 +39,12 @@ XMSS_WOTS_PublicKey::chain(secure_vector<byte>& result,
}
wots_keysig_t
-XMSS_WOTS_PublicKey::pub_key_from_signature(const secure_vector<byte>& msg,
+XMSS_WOTS_PublicKey::pub_key_from_signature(const secure_vector<uint8_t>& msg,
const wots_keysig_t& sig,
XMSS_Address& adrs,
- const secure_vector<byte>& seed)
+ const secure_vector<uint8_t>& seed)
{
- secure_vector<byte> msg_digest
+ secure_vector<uint8_t> msg_digest
{
m_wots_params.base_w(msg, m_wots_params.len_1())
};
diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.h b/src/lib/pubkey/xmss/xmss_wots_publickey.h
index 4f414de27..5d973fd6a 100644
--- a/src/lib/pubkey/xmss/xmss_wots_publickey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_publickey.h
@@ -23,7 +23,7 @@
namespace Botan {
-typedef std::vector<secure_vector<byte>> wots_keysig_t;
+typedef std::vector<secure_vector<uint8_t>> wots_keysig_t;
/**
* A Winternitz One Time Signature public key for use with Extended Hash-Based
@@ -109,7 +109,7 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param public_seed A precomputed public seed of n-bytes length.
**/
XMSS_WOTS_PublicKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- secure_vector<byte> public_seed)
+ secure_vector<uint8_t> public_seed)
: m_wots_params(oid),
m_hash(m_wots_params.hash_function_name()),
m_public_seed(public_seed) {}
@@ -125,7 +125,7 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param key Precomputed raw key data of the XMSS_WOTS_PublicKey.
**/
XMSS_WOTS_PublicKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- secure_vector<byte>&& public_seed,
+ secure_vector<uint8_t>&& public_seed,
wots_keysig_t&& key)
: m_wots_params(oid),
m_hash(m_wots_params.hash_function_name()),
@@ -144,7 +144,7 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param key Precomputed raw key data of the XMSS_WOTS_PublicKey.
**/
XMSS_WOTS_PublicKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& public_seed,
+ const secure_vector<uint8_t>& public_seed,
const wots_keysig_t& key)
: m_wots_params(oid),
m_hash(m_wots_params.hash_function_name()),
@@ -164,10 +164,10 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param public_seed The public public_seed.
**/
XMSS_WOTS_PublicKey(XMSS_WOTS_Parameters::ots_algorithm_t oid,
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
const wots_keysig_t& sig,
XMSS_Address& adrs,
- const secure_vector<byte>& public_seed)
+ const secure_vector<uint8_t>& public_seed)
: m_wots_params(oid),
m_hash(m_wots_params.hash_function_name()),
m_key(pub_key_from_signature(msg,
@@ -184,8 +184,8 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param i index of the element.
* @returns n-byte element addressed by i.
**/
- const secure_vector<byte>& operator[](size_t i) const { return m_key[i]; }
- secure_vector<byte>& operator[](size_t i) { return m_key[i]; }
+ const secure_vector<uint8_t>& operator[](size_t i) const { return m_key[i]; }
+ secure_vector<uint8_t>& operator[](size_t i) { return m_key[i]; }
/**
* Convert the key into the raw key data. The key becomes a length
@@ -199,16 +199,16 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
**/
operator wots_keysig_t& () { return m_key; }
- const secure_vector<byte>& public_seed() const { return m_public_seed; }
+ const secure_vector<uint8_t>& public_seed() const { return m_public_seed; }
- secure_vector<byte>& public_seed() { return m_public_seed; }
+ secure_vector<uint8_t>& public_seed() { return m_public_seed; }
- void set_public_seed(const secure_vector<byte>& public_seed)
+ void set_public_seed(const secure_vector<uint8_t>& public_seed)
{
m_public_seed = public_seed;
}
- void set_public_seed(secure_vector<byte>&& public_seed)
+ void set_public_seed(secure_vector<uint8_t>&& public_seed)
{
m_public_seed = std::move(public_seed);
}
@@ -261,7 +261,7 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
return m_wots_params.estimated_strength();
}
- virtual std::vector<byte> public_key_bits() const override
+ virtual std::vector<uint8_t> public_key_bits() const override
{
throw Not_Implemented("No key format defined for XMSS-WOTS");
}
@@ -293,17 +293,17 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @param public_seed A public seed.
*
**/
- void chain(secure_vector<byte>& x,
+ void chain(secure_vector<uint8_t>& x,
size_t start_idx,
size_t steps,
XMSS_Address& adrs,
- const secure_vector<byte>& public_seed);
+ const secure_vector<uint8_t>& public_seed);
XMSS_WOTS_Parameters m_wots_params;
XMSS_Hash m_hash;
wots_keysig_t m_key;
- secure_vector<byte> m_public_seed;
+ secure_vector<uint8_t> m_public_seed;
private:
/**
@@ -319,10 +319,10 @@ class BOTAN_DLL XMSS_WOTS_PublicKey : virtual public Public_Key
* @return Temporary WOTS+ public key.
**/
wots_keysig_t pub_key_from_signature(
- const secure_vector<byte>& msg,
+ const secure_vector<uint8_t>& msg,
const wots_keysig_t& sig,
XMSS_Address& adrs,
- const secure_vector<byte>& public_seed);
+ const secure_vector<uint8_t>& public_seed);
};
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp b/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp
index 532e4d782..07d43e3bb 100644
--- a/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_signature_operation.cpp
@@ -26,7 +26,7 @@ XMSS_WOTS_Signature_Operation::XMSS_WOTS_Signature_Operation(
}
void
-XMSS_WOTS_Signature_Operation::update(const byte msg[], size_t msg_len)
+XMSS_WOTS_Signature_Operation::update(const uint8_t msg[], size_t msg_len)
{
BOTAN_ASSERT(msg_len == m_priv_key.private_key().wots_parameters().
element_size() &&
@@ -37,10 +37,10 @@ XMSS_WOTS_Signature_Operation::update(const byte msg[], size_t msg_len)
m_msg_buf.push_back(msg[i]);
}
-secure_vector<byte>
+secure_vector<uint8_t>
XMSS_WOTS_Signature_Operation::sign(RandomNumberGenerator&)
{
- secure_vector<byte> result(0);
+ secure_vector<uint8_t> result(0);
result.reserve(m_wots_params.len() * m_wots_params.element_size());
XMSS_WOTS_PrivateKey& priv_key = m_priv_key.private_key();
for(const auto& node : priv_key.sign(m_msg_buf, m_priv_key.address()))
diff --git a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h b/src/lib/pubkey/xmss/xmss_wots_signature_operation.h
index 59de4ea34..f319ac138 100644
--- a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h
+++ b/src/lib/pubkey/xmss/xmss_wots_signature_operation.h
@@ -43,17 +43,17 @@ class XMSS_WOTS_Signature_Operation : public virtual PK_Ops::Signature,
*
* @return serialized Winternitz One Time Signature.
**/
- secure_vector<byte> sign(RandomNumberGenerator&) override;
+ secure_vector<uint8_t> sign(RandomNumberGenerator&) override;
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
private:
- wots_keysig_t sign(const secure_vector<byte>& msg,
+ wots_keysig_t sign(const secure_vector<uint8_t>& msg,
const wots_keysig_t& priv_key,
XMSS_Address& adrs,
- const secure_vector<byte>& seed);
+ const secure_vector<uint8_t>& seed);
XMSS_WOTS_Addressed_PrivateKey m_priv_key;
- secure_vector<byte> m_msg_buf;
+ secure_vector<uint8_t> m_msg_buf;
};
}
diff --git a/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp b/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp
index d66c508bb..cab33870a 100644
--- a/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_verification_operation.cpp
@@ -26,7 +26,7 @@ XMSS_WOTS_Verification_Operation::XMSS_WOTS_Verification_Operation(
}
void
-XMSS_WOTS_Verification_Operation::update(const byte msg[], size_t msg_len)
+XMSS_WOTS_Verification_Operation::update(const uint8_t msg[], size_t msg_len)
{
BOTAN_ASSERT(msg_len == m_pub_key.public_key().wots_parameters().
element_size() &&
@@ -39,7 +39,7 @@ XMSS_WOTS_Verification_Operation::update(const byte msg[], size_t msg_len)
}
}
-bool XMSS_WOTS_Verification_Operation::is_valid_signature(const byte sig[],
+bool XMSS_WOTS_Verification_Operation::is_valid_signature(const uint8_t sig[],
size_t sig_len)
{
const XMSS_WOTS_Parameters& w = m_pub_key.public_key().wots_parameters();
@@ -56,7 +56,7 @@ bool XMSS_WOTS_Verification_Operation::is_valid_signature(const byte sig[],
{
begin = end;
end = begin + w.element_size();
- signature.push_back(secure_vector<byte>(sig + begin, sig + end));
+ signature.push_back(secure_vector<uint8_t>(sig + begin, sig + end));
}
XMSS_WOTS_PublicKey pubkey_msg(w.oid(),
diff --git a/src/lib/pubkey/xmss/xmss_wots_verification_operation.h b/src/lib/pubkey/xmss/xmss_wots_verification_operation.h
index a0cb0709f..0bc5f0db9 100644
--- a/src/lib/pubkey/xmss/xmss_wots_verification_operation.h
+++ b/src/lib/pubkey/xmss/xmss_wots_verification_operation.h
@@ -34,14 +34,14 @@ class XMSS_WOTS_Verification_Operation
virtual ~XMSS_WOTS_Verification_Operation() {}
- virtual bool is_valid_signature(const byte sig[],
+ virtual bool is_valid_signature(const uint8_t sig[],
size_t sig_len) override;
- void update(const byte msg[], size_t msg_len) override;
+ void update(const uint8_t msg[], size_t msg_len) override;
private:
XMSS_WOTS_Addressed_PublicKey m_pub_key;
- secure_vector<byte> m_msg_buf;
+ secure_vector<uint8_t> m_msg_buf;
};
}