aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-05-18 20:32:36 +0000
committerlloyd <[email protected]>2012-05-18 20:32:36 +0000
commitc691561f3198f481c13457433efbccc1c9fcd898 (patch)
treea45ea2c5a30e0cb009fbcb68a61ef39332ff790c /src/engine
parentd76700f01c7ecac5633edf75f8d7408b46c5dbac (diff)
Fairly huge update that replaces the old secmem types with std::vector
using a custom allocator. Currently our allocator just does new/delete with a memset before deletion, and the mmap and mlock allocators have been removed.
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/gnump/gmp_wrap.h2
-rw-r--r--src/engine/gnump/gnump_pk.cpp16
-rw-r--r--src/engine/openssl/bn_wrap.cpp4
-rw-r--r--src/engine/openssl/bn_wrap.h2
-rw-r--r--src/engine/openssl/ossl_bc.cpp2
-rw-r--r--src/engine/openssl/ossl_pk.cpp16
6 files changed, 21 insertions, 21 deletions
diff --git a/src/engine/gnump/gmp_wrap.h b/src/engine/gnump/gmp_wrap.h
index fc7aa856e..0a786f3ee 100644
--- a/src/engine/gnump/gmp_wrap.h
+++ b/src/engine/gnump/gmp_wrap.h
@@ -25,7 +25,7 @@ class GMP_MPZ
void encode(byte[], size_t) const;
size_t bytes() const;
- SecureVector<byte> to_bytes() const
+ secure_vector<byte> to_bytes() const
{ return BigInt::encode(to_bigint()); }
GMP_MPZ& operator=(const GMP_MPZ&);
diff --git a/src/engine/gnump/gnump_pk.cpp b/src/engine/gnump/gnump_pk.cpp
index 25735fe55..b2a2f9352 100644
--- a/src/engine/gnump/gnump_pk.cpp
+++ b/src/engine/gnump/gnump_pk.cpp
@@ -38,7 +38,7 @@ class GMP_DH_KA_Operation : public PK_Ops::Key_Agreement
GMP_DH_KA_Operation(const DH_PrivateKey& dh) :
x(dh.get_x()), p(dh.group_p()) {}
- SecureVector<byte> agree(const byte w[], size_t w_len)
+ secure_vector<byte> agree(const byte w[], size_t w_len)
{
GMP_MPZ z(w, w_len);
mpz_powm(z.value, z.value, x.value, p.value);
@@ -66,14 +66,14 @@ class GMP_DSA_Signature_Operation : public PK_Ops::Signature
size_t message_part_size() const { return (q_bits + 7) / 8; }
size_t max_input_bits() const { return q_bits; }
- SecureVector<byte> sign(const byte msg[], size_t msg_len,
+ secure_vector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
private:
const GMP_MPZ x, p, q, g;
size_t q_bits;
};
-SecureVector<byte>
+secure_vector<byte>
GMP_DSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
@@ -104,7 +104,7 @@ GMP_DSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
if(mpz_cmp_ui(r.value, 0) == 0 || mpz_cmp_ui(s.value, 0) == 0)
throw Internal_Error("GMP_DSA_Op::sign: r or s was zero");
- SecureVector<byte> output(2*q_bytes);
+ secure_vector<byte> output(2*q_bytes);
r.encode(output, q_bytes);
s.encode(output + q_bytes, q_bytes);
return output;
@@ -192,7 +192,7 @@ class GMP_RSA_Private_Operation : public PK_Ops::Signature,
size_t max_input_bits() const { return (n_bits - 1); }
- SecureVector<byte> sign(const byte msg[], size_t msg_len,
+ secure_vector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
@@ -200,7 +200,7 @@ class GMP_RSA_Private_Operation : public PK_Ops::Signature,
return BigInt::encode_1363(x, (n_bits + 7) / 8);
}
- SecureVector<byte> decrypt(const byte msg[], size_t msg_len)
+ secure_vector<byte> decrypt(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(private_op(m));
@@ -238,14 +238,14 @@ class GMP_RSA_Public_Operation : public PK_Ops::Verification,
size_t max_input_bits() const { return (n.bits() - 1); }
bool with_recovery() const { return true; }
- SecureVector<byte> encrypt(const byte msg[], size_t msg_len,
+ secure_vector<byte> encrypt(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
return BigInt::encode_1363(public_op(m), n.bytes());
}
- SecureVector<byte> verify_mr(const byte msg[], size_t msg_len)
+ secure_vector<byte> verify_mr(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(public_op(m));
diff --git a/src/engine/openssl/bn_wrap.cpp b/src/engine/openssl/bn_wrap.cpp
index 779956824..0ac31f61b 100644
--- a/src/engine/openssl/bn_wrap.cpp
+++ b/src/engine/openssl/bn_wrap.cpp
@@ -15,7 +15,7 @@ namespace Botan {
OSSL_BN::OSSL_BN(const BigInt& in)
{
value = BN_new();
- SecureVector<byte> encoding = BigInt::encode(in);
+ secure_vector<byte> encoding = BigInt::encode(in);
if(in != 0)
BN_bin2bn(encoding, encoding.size(), value);
}
@@ -75,7 +75,7 @@ size_t OSSL_BN::bytes() const
*/
BigInt OSSL_BN::to_bigint() const
{
- SecureVector<byte> out(bytes());
+ secure_vector<byte> out(bytes());
BN_bn2bin(value, out);
return BigInt::decode(out);
}
diff --git a/src/engine/openssl/bn_wrap.h b/src/engine/openssl/bn_wrap.h
index c5c07a35c..177dbd8c7 100644
--- a/src/engine/openssl/bn_wrap.h
+++ b/src/engine/openssl/bn_wrap.h
@@ -25,7 +25,7 @@ class OSSL_BN
void encode(byte[], size_t) const;
size_t bytes() const;
- SecureVector<byte> to_bytes() const
+ secure_vector<byte> to_bytes() const
{ return BigInt::encode(to_bigint()); }
OSSL_BN& operator=(const OSSL_BN&);
diff --git a/src/engine/openssl/ossl_bc.cpp b/src/engine/openssl/ossl_bc.cpp
index 36f78205f..d419f56be 100644
--- a/src/engine/openssl/ossl_bc.cpp
+++ b/src/engine/openssl/ossl_bc.cpp
@@ -123,7 +123,7 @@ void EVP_BlockCipher::decrypt_n(const byte in[], byte out[],
*/
void EVP_BlockCipher::key_schedule(const byte key[], size_t length)
{
- SecureVector<byte> full_key(key, length);
+ secure_vector<byte> full_key(key, length);
if(cipher_name == "TripleDES" && length == 16)
{
diff --git a/src/engine/openssl/ossl_pk.cpp b/src/engine/openssl/ossl_pk.cpp
index 23ae6b25d..2557ec297 100644
--- a/src/engine/openssl/ossl_pk.cpp
+++ b/src/engine/openssl/ossl_pk.cpp
@@ -36,7 +36,7 @@ class OSSL_DH_KA_Operation : public PK_Ops::Key_Agreement
OSSL_DH_KA_Operation(const DH_PrivateKey& dh) :
x(dh.get_x()), p(dh.group_p()) {}
- SecureVector<byte> agree(const byte w[], size_t w_len)
+ secure_vector<byte> agree(const byte w[], size_t w_len)
{
OSSL_BN i(w, w_len), r;
BN_mod_exp(r.value, i.value, x.value, p.value, ctx.value);
@@ -65,7 +65,7 @@ class OSSL_DSA_Signature_Operation : public PK_Ops::Signature
size_t message_part_size() const { return (q_bits + 7) / 8; }
size_t max_input_bits() const { return q_bits; }
- SecureVector<byte> sign(const byte msg[], size_t msg_len,
+ secure_vector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng);
private:
const OSSL_BN x, p, q, g;
@@ -73,7 +73,7 @@ class OSSL_DSA_Signature_Operation : public PK_Ops::Signature
size_t q_bits;
};
-SecureVector<byte>
+secure_vector<byte>
OSSL_DSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
@@ -103,7 +103,7 @@ OSSL_DSA_Signature_Operation::sign(const byte msg[], size_t msg_len,
if(BN_is_zero(r.value) || BN_is_zero(s.value))
throw Internal_Error("OpenSSL_DSA_Op::sign: r or s was zero");
- SecureVector<byte> output(2*q_bytes);
+ secure_vector<byte> output(2*q_bytes);
r.encode(output, q_bytes);
s.encode(output + q_bytes, q_bytes);
return output;
@@ -191,7 +191,7 @@ class OSSL_RSA_Private_Operation : public PK_Ops::Signature,
size_t max_input_bits() const { return (n_bits - 1); }
- SecureVector<byte> sign(const byte msg[], size_t msg_len,
+ secure_vector<byte> sign(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
@@ -199,7 +199,7 @@ class OSSL_RSA_Private_Operation : public PK_Ops::Signature,
return BigInt::encode_1363(x, (n_bits + 7) / 8);
}
- SecureVector<byte> decrypt(const byte msg[], size_t msg_len)
+ secure_vector<byte> decrypt(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(private_op(m));
@@ -237,14 +237,14 @@ class OSSL_RSA_Public_Operation : public PK_Ops::Verification,
size_t max_input_bits() const { return (n.bits() - 1); }
bool with_recovery() const { return true; }
- SecureVector<byte> encrypt(const byte msg[], size_t msg_len,
+ secure_vector<byte> encrypt(const byte msg[], size_t msg_len,
RandomNumberGenerator&)
{
BigInt m(msg, msg_len);
return BigInt::encode_1363(public_op(m), n.bytes());
}
- SecureVector<byte> verify_mr(const byte msg[], size_t msg_len)
+ secure_vector<byte> verify_mr(const byte msg[], size_t msg_len)
{
BigInt m(msg, msg_len);
return BigInt::encode(public_op(m));