diff options
author | lloyd <[email protected]> | 2010-10-28 21:15:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-10-28 21:15:21 +0000 |
commit | 22f02b418f7f53431da168abe9fb74f15bf3cb0e (patch) | |
tree | cdc81938c979403d20a438d134bbd6d64479f17d /src/libstate | |
parent | a7a047e6823dcbf23e172dd5c0f9a7b4fd748f10 (diff) |
Eliminate the constant size_t values in SymmetricAlgorithm that give
the parameters of the key length. Instead define a new function which
returns a simple object which contains this information.
This definitely breaks backwards compatability, though only with code
that directly manipulates low level objects like BlockCipher*s
directly, which is probably relatively rare.
Also remove some deprecated accessor functions from lookup.h. It turns
out block_size_of and output_size_of are being used in the TLS code; I
need to remove them from there before I can delete these entirely.
Really that didn't make much sense, because they assumed all
implementations of a particular algorithm will have the same
specifications, which is definitely not necessarily true, especially
WRT key length. It is much safer (and probably simpler) to first
retrieve an instance of the actual object you are going to use and
then ask it directly.
Diffstat (limited to 'src/libstate')
-rw-r--r-- | src/libstate/lookup.cpp | 76 | ||||
-rw-r--r-- | src/libstate/lookup.h | 39 |
2 files changed, 0 insertions, 115 deletions
diff --git a/src/libstate/lookup.cpp b/src/libstate/lookup.cpp index d971618c2..f5d2c5a0c 100644 --- a/src/libstate/lookup.cpp +++ b/src/libstate/lookup.cpp @@ -62,82 +62,6 @@ u32bit output_length_of(const std::string& name) } /* -* Check if a keylength is valid for this algo -*/ -bool valid_keylength_for(u32bit key_len, const std::string& name) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - - if(const BlockCipher* bc = af.prototype_block_cipher(name)) - return bc->valid_keylength(key_len); - - if(const StreamCipher* sc = af.prototype_stream_cipher(name)) - return sc->valid_keylength(key_len); - - if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) - return mac->valid_keylength(key_len); - - throw Algorithm_Not_Found(name); - } - -/* -* Query the MINIMUM_KEYLENGTH of an algorithm -*/ -u32bit min_keylength_of(const std::string& name) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - - if(const BlockCipher* bc = af.prototype_block_cipher(name)) - return bc->MINIMUM_KEYLENGTH; - - if(const StreamCipher* sc = af.prototype_stream_cipher(name)) - return sc->MINIMUM_KEYLENGTH; - - if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) - return mac->MINIMUM_KEYLENGTH; - - throw Algorithm_Not_Found(name); - } - -/* -* Query the MAXIMUM_KEYLENGTH of an algorithm -*/ -u32bit max_keylength_of(const std::string& name) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - - if(const BlockCipher* bc = af.prototype_block_cipher(name)) - return bc->MAXIMUM_KEYLENGTH; - - if(const StreamCipher* sc = af.prototype_stream_cipher(name)) - return sc->MAXIMUM_KEYLENGTH; - - if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) - return mac->MAXIMUM_KEYLENGTH; - - throw Algorithm_Not_Found(name); - } - -/* -* Query the KEYLENGTH_MULTIPLE of an algorithm -*/ -u32bit keylength_multiple_of(const std::string& name) - { - Algorithm_Factory& af = global_state().algorithm_factory(); - - if(const BlockCipher* bc = af.prototype_block_cipher(name)) - return bc->KEYLENGTH_MULTIPLE; - - if(const StreamCipher* sc = af.prototype_stream_cipher(name)) - return sc->KEYLENGTH_MULTIPLE; - - if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) - return mac->KEYLENGTH_MULTIPLE; - - throw Algorithm_Not_Found(name); - } - -/* * Get a cipher object */ Keyed_Filter* get_cipher(const std::string& algo_spec, diff --git a/src/libstate/lookup.h b/src/libstate/lookup.h index 178f80428..f1e1a52ca 100644 --- a/src/libstate/lookup.h +++ b/src/libstate/lookup.h @@ -299,45 +299,6 @@ BOTAN_DLL u32bit block_size_of(const std::string& algo_spec); */ BOTAN_DLL u32bit output_length_of(const std::string& algo_spec); -/** -* Find out the whether a certain key length is allowd for a given -* symmetric algorithm. -* @deprecated Call algorithm_factory() directly -* -* @param key_len the key length in question -* @param algo_spec the name of the algorithm -* @return true if the key length is valid for that algorithm, false otherwise -*/ -BOTAN_DLL bool valid_keylength_for(u32bit key_len, - const std::string& algo_spec); - -/** -* Find out the minimum key size of a certain symmetric algorithm. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the algorithm -* @return minimum key length of the specified algorithm -*/ -BOTAN_DLL u32bit min_keylength_of(const std::string& algo_spec); - -/** -* Find out the maximum key size of a certain symmetric algorithm. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the algorithm -* @return maximum key length of the specified algorithm -*/ -BOTAN_DLL u32bit max_keylength_of(const std::string& algo_spec); - -/** -* Find out the size any valid key is a multiple of for a certain algorithm. -* @deprecated Call algorithm_factory() directly -* -* @param algo_spec the name of the algorithm -* @return size any valid key is a multiple of -*/ -BOTAN_DLL u32bit keylength_multiple_of(const std::string& algo_spec); - } #endif |