aboutsummaryrefslogtreecommitdiffstats
path: root/src/pbe
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/pbe
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/pbe')
-rw-r--r--src/pbe/pbe.h2
-rw-r--r--src/pbe/pbes1/pbes1.cpp8
-rw-r--r--src/pbe/pbes1/pbes1.h4
-rw-r--r--src/pbe/pbes2/pbes2.cpp10
-rw-r--r--src/pbe/pbes2/pbes2.h4
5 files changed, 14 insertions, 14 deletions
diff --git a/src/pbe/pbe.h b/src/pbe/pbe.h
index 9add98872..975f3e6c7 100644
--- a/src/pbe/pbe.h
+++ b/src/pbe/pbe.h
@@ -37,7 +37,7 @@ class BOTAN_DLL PBE : public Filter
* DER encode the params (the number of iterations and the salt value)
* @return encoded params
*/
- virtual MemoryVector<byte> encode_params() const = 0;
+ virtual std::vector<byte> encode_params() const = 0;
/**
* Decode params and use them inside this Filter.
diff --git a/src/pbe/pbes1/pbes1.cpp b/src/pbe/pbes1/pbes1.cpp
index ec5ebb253..0e5e8284c 100644
--- a/src/pbe/pbes1/pbes1.cpp
+++ b/src/pbe/pbes1/pbes1.cpp
@@ -65,7 +65,7 @@ void PBE_PKCS5v15::flush_pipe(bool safe_to_skip)
if(safe_to_skip && pipe.remaining() < 64)
return;
- SecureVector<byte> buffer(DEFAULT_BUFFERSIZE);
+ secure_vector<byte> buffer(DEFAULT_BUFFERSIZE);
while(pipe.remaining())
{
size_t got = pipe.read(&buffer[0], buffer.size());
@@ -80,7 +80,7 @@ void PBE_PKCS5v15::set_key(const std::string& passphrase)
{
PKCS5_PBKDF1 pbkdf(hash_function->clone());
- SecureVector<byte> key_and_iv = pbkdf.derive_key(16, passphrase,
+ secure_vector<byte> key_and_iv = pbkdf.derive_key(16, passphrase,
&salt[0], salt.size(),
iterations).bits_of();
@@ -102,14 +102,14 @@ void PBE_PKCS5v15::new_params(RandomNumberGenerator& rng)
/*
* Encode PKCS#5 PBES1 parameters
*/
-MemoryVector<byte> PBE_PKCS5v15::encode_params() const
+std::vector<byte> PBE_PKCS5v15::encode_params() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
.encode(salt, OCTET_STRING)
.encode(iterations)
.end_cons()
- .get_contents();
+ .get_contents_unlocked();
}
/*
diff --git a/src/pbe/pbes1/pbes1.h b/src/pbe/pbes1/pbes1.h
index e10cbbb53..bbdbd5b9d 100644
--- a/src/pbe/pbes1/pbes1.h
+++ b/src/pbe/pbes1/pbes1.h
@@ -40,7 +40,7 @@ class BOTAN_DLL PBE_PKCS5v15 : public PBE
private:
void set_key(const std::string&);
void new_params(RandomNumberGenerator& rng);
- MemoryVector<byte> encode_params() const;
+ std::vector<byte> encode_params() const;
void decode_params(DataSource&);
OID get_oid() const;
@@ -50,7 +50,7 @@ class BOTAN_DLL PBE_PKCS5v15 : public PBE
BlockCipher* block_cipher;
HashFunction* hash_function;
- SecureVector<byte> salt, key, iv;
+ secure_vector<byte> salt, key, iv;
size_t iterations;
Pipe pipe;
};
diff --git a/src/pbe/pbes2/pbes2.cpp b/src/pbe/pbes2/pbes2.cpp
index 85afe6ffe..384fc3d90 100644
--- a/src/pbe/pbes2/pbes2.cpp
+++ b/src/pbe/pbes2/pbes2.cpp
@@ -72,7 +72,7 @@ void PBE_PKCS5v20::flush_pipe(bool safe_to_skip)
if(safe_to_skip && pipe.remaining() < 64)
return;
- SecureVector<byte> buffer(DEFAULT_BUFFERSIZE);
+ secure_vector<byte> buffer(DEFAULT_BUFFERSIZE);
while(pipe.remaining())
{
size_t got = pipe.read(&buffer[0], buffer.size());
@@ -107,7 +107,7 @@ void PBE_PKCS5v20::new_params(RandomNumberGenerator& rng)
/*
* Encode PKCS#5 PBES2 parameters
*/
-MemoryVector<byte> PBE_PKCS5v20::encode_params() const
+std::vector<byte> PBE_PKCS5v20::encode_params() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
@@ -119,18 +119,18 @@ MemoryVector<byte> PBE_PKCS5v20::encode_params() const
.encode(iterations)
.encode(key_length)
.end_cons()
- .get_contents()
+ .get_contents_unlocked()
)
)
.encode(
AlgorithmIdentifier(block_cipher->name() + "/CBC",
DER_Encoder()
.encode(iv, OCTET_STRING)
- .get_contents()
+ .get_contents_unlocked()
)
)
.end_cons()
- .get_contents();
+ .get_contents_unlocked();
}
/*
diff --git a/src/pbe/pbes2/pbes2.h b/src/pbe/pbes2/pbes2.h
index 7b82980e5..5593c9091 100644
--- a/src/pbe/pbes2/pbes2.h
+++ b/src/pbe/pbes2/pbes2.h
@@ -49,7 +49,7 @@ class BOTAN_DLL PBE_PKCS5v20 : public PBE
private:
void set_key(const std::string&);
void new_params(RandomNumberGenerator& rng);
- MemoryVector<byte> encode_params() const;
+ std::vector<byte> encode_params() const;
void decode_params(DataSource&);
OID get_oid() const;
@@ -58,7 +58,7 @@ class BOTAN_DLL PBE_PKCS5v20 : public PBE
Cipher_Dir direction;
BlockCipher* block_cipher;
HashFunction* hash_function;
- SecureVector<byte> salt, key, iv;
+ secure_vector<byte> salt, key, iv;
size_t iterations, key_length;
Pipe pipe;
};