aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/prov/openssl
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/prov/openssl
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/prov/openssl')
-rw-r--r--src/lib/prov/openssl/openssl_block.cpp10
-rw-r--r--src/lib/prov/openssl/openssl_ec.cpp26
-rw-r--r--src/lib/prov/openssl/openssl_hash.cpp4
-rw-r--r--src/lib/prov/openssl/openssl_rc4.cpp10
-rw-r--r--src/lib/prov/openssl/openssl_rsa.cpp40
5 files changed, 45 insertions, 45 deletions
diff --git a/src/lib/prov/openssl/openssl_block.cpp b/src/lib/prov/openssl/openssl_block.cpp
index cb98be70d..842730af7 100644
--- a/src/lib/prov/openssl/openssl_block.cpp
+++ b/src/lib/prov/openssl/openssl_block.cpp
@@ -34,19 +34,19 @@ class OpenSSL_BlockCipher : public BlockCipher
Key_Length_Specification key_spec() const override { return m_cipher_key_spec; }
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
{
int out_len = 0;
EVP_EncryptUpdate(&m_encrypt, out, &out_len, in, blocks * m_block_sz);
}
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
{
int out_len = 0;
EVP_DecryptUpdate(&m_decrypt, out, &out_len, in, blocks * m_block_sz);
}
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
size_t m_block_sz;
Key_Length_Specification m_cipher_key_spec;
@@ -104,9 +104,9 @@ OpenSSL_BlockCipher::~OpenSSL_BlockCipher()
/*
* Set the key
*/
-void OpenSSL_BlockCipher::key_schedule(const byte key[], size_t length)
+void OpenSSL_BlockCipher::key_schedule(const uint8_t key[], size_t length)
{
- secure_vector<byte> full_key(key, key + length);
+ secure_vector<uint8_t> full_key(key, key + length);
if(m_cipher_name == "TripleDES" && length == 16)
{
diff --git a/src/lib/prov/openssl/openssl_ec.cpp b/src/lib/prov/openssl/openssl_ec.cpp
index 5fe7865a1..84f3a1ca0 100644
--- a/src/lib/prov/openssl/openssl_ec.cpp
+++ b/src/lib/prov/openssl/openssl_ec.cpp
@@ -43,7 +43,7 @@ namespace Botan {
namespace {
-secure_vector<byte> PKCS8_for_openssl(const EC_PrivateKey& ec)
+secure_vector<uint8_t> PKCS8_for_openssl(const EC_PrivateKey& ec)
{
const PointGFp& pub_key = ec.public_point();
const BigInt& priv_key = ec.private_value();
@@ -123,8 +123,8 @@ class OpenSSL_ECDSA_Verification_Operation : public PK_Ops::Verification_with_EM
::EC_KEY_set_group(m_ossl_ec.get(), grp.get());
- const secure_vector<byte> enc = EC2OSP(ecdsa.public_point(), PointGFp::UNCOMPRESSED);
- const byte* enc_ptr = enc.data();
+ const secure_vector<uint8_t> enc = EC2OSP(ecdsa.public_point(), PointGFp::UNCOMPRESSED);
+ const uint8_t* enc_ptr = enc.data();
EC_KEY* key_ptr = m_ossl_ec.get();
if(!::o2i_ECPublicKey(&key_ptr, &enc_ptr, enc.size()))
throw OpenSSL_Error("o2i_ECPublicKey");
@@ -137,8 +137,8 @@ class OpenSSL_ECDSA_Verification_Operation : public PK_Ops::Verification_with_EM
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig_bytes[], size_t sig_len) override
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig_bytes[], size_t sig_len) override
{
const size_t order_bytes = (m_order_bits + 7) / 8;
if(sig_len != 2 * order_bytes)
@@ -168,8 +168,8 @@ class OpenSSL_ECDSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
PK_Ops::Signature_with_EMSA(emsa),
m_ossl_ec(nullptr, ::EC_KEY_free)
{
- const secure_vector<byte> der = PKCS8_for_openssl(ecdsa);
- const byte* der_ptr = der.data();
+ const secure_vector<uint8_t> der = PKCS8_for_openssl(ecdsa);
+ const uint8_t* der_ptr = der.data();
m_ossl_ec.reset(d2i_ECPrivateKey(nullptr, &der_ptr, der.size()));
if(!m_ossl_ec)
throw OpenSSL_Error("d2i_ECPrivateKey");
@@ -178,7 +178,7 @@ class OpenSSL_ECDSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
m_order_bits = ::EC_GROUP_get_degree(group);
}
- 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
{
std::unique_ptr<ECDSA_SIG, std::function<void (ECDSA_SIG*)>> sig(nullptr, ECDSA_SIG_free);
@@ -190,7 +190,7 @@ class OpenSSL_ECDSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
const size_t order_bytes = (m_order_bits + 7) / 8;
const size_t r_bytes = BN_num_bytes(sig->r);
const size_t s_bytes = BN_num_bytes(sig->s);
- secure_vector<byte> sigval(2*order_bytes);
+ secure_vector<uint8_t> sigval(2*order_bytes);
BN_bn2bin(sig->r, &sigval[order_bytes - r_bytes]);
BN_bn2bin(sig->s, &sigval[2*order_bytes - s_bytes]);
return sigval;
@@ -240,18 +240,18 @@ class OpenSSL_ECDH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF
OpenSSL_ECDH_KA_Operation(const ECDH_PrivateKey& ecdh, const std::string& kdf) :
PK_Ops::Key_Agreement_with_KDF(kdf), m_ossl_ec(::EC_KEY_new(), ::EC_KEY_free)
{
- const secure_vector<byte> der = PKCS8_for_openssl(ecdh);
- const byte* der_ptr = der.data();
+ const secure_vector<uint8_t> der = PKCS8_for_openssl(ecdh);
+ const uint8_t* der_ptr = der.data();
m_ossl_ec.reset(d2i_ECPrivateKey(nullptr, &der_ptr, der.size()));
if(!m_ossl_ec)
throw OpenSSL_Error("d2i_ECPrivateKey");
}
- 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 EC_GROUP* group = ::EC_KEY_get0_group(m_ossl_ec.get());
const size_t out_len = (::EC_GROUP_get_degree(group) + 7) / 8;
- secure_vector<byte> out(out_len);
+ secure_vector<uint8_t> out(out_len);
EC_POINT* pub_key = ::EC_POINT_new(group);
if(!pub_key)
diff --git a/src/lib/prov/openssl/openssl_hash.cpp b/src/lib/prov/openssl/openssl_hash.cpp
index 8e36866a1..19a12d938 100644
--- a/src/lib/prov/openssl/openssl_hash.cpp
+++ b/src/lib/prov/openssl/openssl_hash.cpp
@@ -54,12 +54,12 @@ class OpenSSL_HashFunction : public HashFunction
}
private:
- void add_data(const byte input[], size_t length) override
+ void add_data(const uint8_t input[], size_t length) override
{
EVP_DigestUpdate(&m_md, input, length);
}
- void final_result(byte output[]) override
+ void final_result(uint8_t output[]) override
{
EVP_DigestFinal_ex(&m_md, output, nullptr);
const EVP_MD* algo = EVP_MD_CTX_md(&m_md);
diff --git a/src/lib/prov/openssl/openssl_rc4.cpp b/src/lib/prov/openssl/openssl_rc4.cpp
index c8ba32235..9cca7fdd1 100644
--- a/src/lib/prov/openssl/openssl_rc4.cpp
+++ b/src/lib/prov/openssl/openssl_rc4.cpp
@@ -48,26 +48,26 @@ class OpenSSL_RC4 : public StreamCipher
explicit OpenSSL_RC4(size_t skip = 0) : m_skip(skip) { clear(); }
~OpenSSL_RC4() { clear(); }
- void set_iv(const byte*, size_t len) override
+ void set_iv(const uint8_t*, size_t len) override
{
if(len > 0)
throw Exception("RC4 does not support an IV");
}
- void seek(u64bit) override
+ void seek(uint64_t) override
{
throw Exception("RC4 does not support seeking");
}
private:
- void cipher(const byte in[], byte out[], size_t length) override
+ void cipher(const uint8_t in[], uint8_t out[], size_t length) override
{
::RC4(&m_rc4, length, in, out);
}
- void key_schedule(const byte key[], size_t length) override
+ void key_schedule(const uint8_t key[], size_t length) override
{
::RC4_set_key(&m_rc4, length, key);
- byte d = 0;
+ uint8_t d = 0;
for(size_t i = 0; i != m_skip; ++i)
::RC4(&m_rc4, 1, &d, &d);
}
diff --git a/src/lib/prov/openssl/openssl_rsa.cpp b/src/lib/prov/openssl/openssl_rsa.cpp
index aef9c95d8..e7a562cf5 100644
--- a/src/lib/prov/openssl/openssl_rsa.cpp
+++ b/src/lib/prov/openssl/openssl_rsa.cpp
@@ -44,8 +44,8 @@ class OpenSSL_RSA_Encryption_Operation : public PK_Ops::Encryption
OpenSSL_RSA_Encryption_Operation(const RSA_PublicKey& rsa, int pad, size_t pad_overhead) :
m_openssl_rsa(nullptr, ::RSA_free), m_padding(pad)
{
- const std::vector<byte> der = rsa.public_key_bits();
- const byte* der_ptr = der.data();
+ const std::vector<uint8_t> der = rsa.public_key_bits();
+ const uint8_t* der_ptr = der.data();
m_openssl_rsa.reset(::d2i_RSAPublicKey(nullptr, &der_ptr, der.size()));
if(!m_openssl_rsa)
throw OpenSSL_Error("d2i_RSAPublicKey");
@@ -55,7 +55,7 @@ class OpenSSL_RSA_Encryption_Operation : public PK_Ops::Encryption
size_t max_input_bits() const override { return m_bits; };
- 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&) override
{
const size_t mod_sz = n_size();
@@ -63,9 +63,9 @@ class OpenSSL_RSA_Encryption_Operation : public PK_Ops::Encryption
if(msg_len > mod_sz)
throw Invalid_Argument("Input too large for RSA key");
- secure_vector<byte> outbuf(mod_sz);
+ secure_vector<uint8_t> outbuf(mod_sz);
- secure_vector<byte> inbuf;
+ secure_vector<uint8_t> inbuf;
if(m_padding == RSA_NO_PADDING)
{
@@ -99,17 +99,17 @@ class OpenSSL_RSA_Decryption_Operation : public PK_Ops::Decryption
OpenSSL_RSA_Decryption_Operation(const RSA_PrivateKey& rsa, int pad) :
m_openssl_rsa(nullptr, ::RSA_free), m_padding(pad)
{
- const secure_vector<byte> der = rsa.private_key_bits();
- const byte* der_ptr = der.data();
+ const secure_vector<uint8_t> der = rsa.private_key_bits();
+ const uint8_t* der_ptr = der.data();
m_openssl_rsa.reset(d2i_RSAPrivateKey(nullptr, &der_ptr, der.size()));
if(!m_openssl_rsa)
throw OpenSSL_Error("d2i_RSAPrivateKey");
}
- 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
{
- secure_vector<byte> buf(::RSA_size(m_openssl_rsa.get()));
+ secure_vector<uint8_t> buf(::RSA_size(m_openssl_rsa.get()));
int rc = ::RSA_private_decrypt(msg_len, msg, buf.data(), m_openssl_rsa.get(), m_padding);
if(rc < 0 || static_cast<size_t>(rc) > buf.size())
{
@@ -143,8 +143,8 @@ class OpenSSL_RSA_Verification_Operation : public PK_Ops::Verification_with_EMSA
PK_Ops::Verification_with_EMSA(emsa),
m_openssl_rsa(nullptr, ::RSA_free)
{
- const std::vector<byte> der = rsa.public_key_bits();
- const byte* der_ptr = der.data();
+ const std::vector<uint8_t> der = rsa.public_key_bits();
+ const uint8_t* der_ptr = der.data();
m_openssl_rsa.reset(::d2i_RSAPublicKey(nullptr, &der_ptr, der.size()));
}
@@ -152,17 +152,17 @@ class OpenSSL_RSA_Verification_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
{
const size_t mod_sz = ::RSA_size(m_openssl_rsa.get());
if(msg_len > mod_sz)
throw Invalid_Argument("OpenSSL RSA verify input too large");
- secure_vector<byte> inbuf(mod_sz);
+ secure_vector<uint8_t> inbuf(mod_sz);
copy_mem(&inbuf[mod_sz - msg_len], msg, msg_len);
- secure_vector<byte> outbuf(mod_sz);
+ secure_vector<uint8_t> outbuf(mod_sz);
int rc = ::RSA_public_decrypt(inbuf.size(), inbuf.data(), outbuf.data(),
m_openssl_rsa.get(), RSA_NO_PADDING);
@@ -183,14 +183,14 @@ class OpenSSL_RSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
PK_Ops::Signature_with_EMSA(emsa),
m_openssl_rsa(nullptr, ::RSA_free)
{
- const secure_vector<byte> der = rsa.private_key_bits();
- const byte* der_ptr = der.data();
+ const secure_vector<uint8_t> der = rsa.private_key_bits();
+ const uint8_t* der_ptr = der.data();
m_openssl_rsa.reset(d2i_RSAPrivateKey(nullptr, &der_ptr, der.size()));
if(!m_openssl_rsa)
throw OpenSSL_Error("d2i_RSAPrivateKey");
}
- 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 size_t mod_sz = ::RSA_size(m_openssl_rsa.get());
@@ -198,10 +198,10 @@ class OpenSSL_RSA_Signing_Operation : public PK_Ops::Signature_with_EMSA
if(msg_len > mod_sz)
throw Invalid_Argument("OpenSSL RSA sign input too large");
- secure_vector<byte> inbuf(mod_sz);
+ secure_vector<uint8_t> inbuf(mod_sz);
copy_mem(&inbuf[mod_sz - msg_len], msg, msg_len);
- secure_vector<byte> outbuf(mod_sz);
+ secure_vector<uint8_t> outbuf(mod_sz);
int rc = ::RSA_private_encrypt(inbuf.size(), inbuf.data(), outbuf.data(),
m_openssl_rsa.get(), RSA_NO_PADDING);