diff options
author | lloyd <[email protected]> | 2014-01-18 23:00:53 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-01-18 23:00:53 +0000 |
commit | d5354c1c3ee0067dd35ca253d4b8914f870cea75 (patch) | |
tree | 09dce01e5489528a2fe1874547ae97effccdd746 /src/lib/pk_pad | |
parent | 700ae0440c1fac65a218fc2ae5883bdc63683f08 (diff) |
More unique_ptr, and pull <memory> all the way up to types.h
Diffstat (limited to 'src/lib/pk_pad')
-rw-r--r-- | src/lib/pk_pad/emsa1/emsa1.cpp | 24 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa1/emsa1.h | 23 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp (renamed from src/lib/pk_pad/emsa_raw_bsi/emsa1_bsi.cpp) | 2 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa1_bsi/emsa1_bsi.h (renamed from src/lib/pk_pad/emsa_raw_bsi/emsa1_bsi.h) | 6 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa1_bsi/info.txt (renamed from src/lib/pk_pad/emsa_raw_bsi/info.txt) | 0 |
5 files changed, 21 insertions, 34 deletions
diff --git a/src/lib/pk_pad/emsa1/emsa1.cpp b/src/lib/pk_pad/emsa1/emsa1.cpp index 2358023f8..2da38f12f 100644 --- a/src/lib/pk_pad/emsa1/emsa1.cpp +++ b/src/lib/pk_pad/emsa1/emsa1.cpp @@ -40,42 +40,30 @@ secure_vector<byte> emsa1_encoding(const secure_vector<byte>& msg, } -/* -* EMSA1 Update Operation -*/ void EMSA1::update(const byte input[], size_t length) { - hash->update(input, length); + m_hash->update(input, length); } -/* -* Return the raw (unencoded) data -*/ secure_vector<byte> EMSA1::raw_data() { - return hash->final(); + return m_hash->final(); } -/* -* EMSA1 Encode Operation -*/ secure_vector<byte> EMSA1::encoding_of(const secure_vector<byte>& msg, - size_t output_bits, - RandomNumberGenerator&) + size_t output_bits, + RandomNumberGenerator&) { - if(msg.size() != hash->output_length()) + if(msg.size() != hash_output_length()) throw Encoding_Error("EMSA1::encoding_of: Invalid size for input"); return emsa1_encoding(msg, output_bits); } -/* -* EMSA1 Decode/Verify Operation -*/ bool EMSA1::verify(const secure_vector<byte>& coded, const secure_vector<byte>& raw, size_t key_bits) { try { - if(raw.size() != hash->output_length()) + if(raw.size() != m_hash->output_length()) throw Encoding_Error("EMSA1::encoding_of: Invalid size for input"); secure_vector<byte> our_coding = emsa1_encoding(raw, key_bits); diff --git a/src/lib/pk_pad/emsa1/emsa1.h b/src/lib/pk_pad/emsa1/emsa1.h index f84ca5ae7..8df53f789 100644 --- a/src/lib/pk_pad/emsa1/emsa1.h +++ b/src/lib/pk_pad/emsa1/emsa1.h @@ -21,26 +21,25 @@ class BOTAN_DLL EMSA1 : public EMSA { public: /** - * @param h the hash object to use + * @param hash the hash function to use */ - EMSA1(HashFunction* h) : hash(h) {} - ~EMSA1() { delete hash; } + EMSA1(HashFunction* hash) : m_hash(hash) {} + protected: - /** - * @return const pointer to the underlying hash - */ - const HashFunction* hash_ptr() const { return hash; } + size_t hash_output_length() const { return m_hash->output_length(); } private: void update(const byte[], size_t); secure_vector<byte> raw_data(); - secure_vector<byte> encoding_of(const secure_vector<byte>&, size_t, - RandomNumberGenerator& rng); + secure_vector<byte> encoding_of(const secure_vector<byte>& msg, + size_t output_bits, + RandomNumberGenerator& rng); - bool verify(const secure_vector<byte>&, const secure_vector<byte>&, - size_t); + bool verify(const secure_vector<byte>& coded, + const secure_vector<byte>& raw, + size_t key_bits); - HashFunction* hash; + std::unique_ptr<HashFunction> m_hash; }; } diff --git a/src/lib/pk_pad/emsa_raw_bsi/emsa1_bsi.cpp b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp index 9096edfbf..235dfb91b 100644 --- a/src/lib/pk_pad/emsa_raw_bsi/emsa1_bsi.cpp +++ b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp @@ -17,7 +17,7 @@ secure_vector<byte> EMSA1_BSI::encoding_of(const secure_vector<byte>& msg, size_t output_bits, RandomNumberGenerator&) { - if(msg.size() != hash_ptr()->output_length()) + if(msg.size() != hash_output_length()) throw Encoding_Error("EMSA1_BSI::encoding_of: Invalid size for input"); if(8*msg.size() <= output_bits) diff --git a/src/lib/pk_pad/emsa_raw_bsi/emsa1_bsi.h b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.h index 1b90f48df..a2b0c7432 100644 --- a/src/lib/pk_pad/emsa_raw_bsi/emsa1_bsi.h +++ b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.h @@ -14,9 +14,9 @@ namespace Botan { /** -EMSA1_BSI is a variant of EMSA1 specified by the BSI. It accepts only -hash values which are less or equal than the maximum key length. The -implementation comes from InSiTo +* EMSA1_BSI is a variant of EMSA1 specified by the BSI. It accepts +* only hash values which are less or equal than the maximum key +* length. The implementation comes from InSiTo */ class BOTAN_DLL EMSA1_BSI : public EMSA1 { diff --git a/src/lib/pk_pad/emsa_raw_bsi/info.txt b/src/lib/pk_pad/emsa1_bsi/info.txt index 021c99720..021c99720 100644 --- a/src/lib/pk_pad/emsa_raw_bsi/info.txt +++ b/src/lib/pk_pad/emsa1_bsi/info.txt |