diff options
-rwxr-xr-x | doc/scripts/print_deps.py | 70 | ||||
-rw-r--r-- | src/hash/gost_3411/info.txt | 4 | ||||
-rw-r--r-- | src/kdf/tls_prf/info.txt | 3 | ||||
-rw-r--r-- | src/kdf/tls_prf/prf_tls.cpp | 62 | ||||
-rw-r--r-- | src/kdf/tls_prf/prf_tls.h | 5 |
5 files changed, 109 insertions, 35 deletions
diff --git a/doc/scripts/print_deps.py b/doc/scripts/print_deps.py new file mode 100755 index 000000000..b92c43310 --- /dev/null +++ b/doc/scripts/print_deps.py @@ -0,0 +1,70 @@ +#!/usr/bin/python + +""" +Analyze the botan source tree and print the module interdependencies + +(C) 2009 Jack Lloyd +Distributed under the terms of the Botan license +""" + +import os +import os.path +import sys +import re + +def find_deps_in(filename): + # By convention #include's with spaces before them are + # always wrapped in #ifdef blocks + regexp = re.compile('^#include <botan/(.*)>') + + for line in open(filename).readlines(): + match = regexp.match(line) + if match != None: + yield match.group(1) + +def get_dependencies(dirname): + all_dirdeps = {} + file_homes = {} + + is_sourcefile = re.compile('\.(cpp|h|S)$') + + for (dirpath, dirnames, filenames) in os.walk('src'): + dirdeps = set() + for filename in filenames: + if is_sourcefile.search(filename) != None: + file_homes[filename] = os.path.basename(dirpath) + + for dep in find_deps_in(os.path.join(dirpath, filename)): + if dep not in filenames and dep != 'build.h': + dirdeps.add(dep) + + dirdeps = sorted(dirdeps) + if dirdeps != []: + all_dirdeps[dirpath] = dirdeps + + return (all_dirdeps, file_homes) + +def main(): + (all_dirdeps, file_homes) = get_dependencies('src') + + def interesting_dep_for(dirname): + def interesting_dep(dep): + if dep == 'utils': + return False # everything depends on it + + # block/serpent depends on block, etc + if dirname.find('/%s/' % (dep)) > 0: + return False + return True + return interesting_dep + + for dirname in sorted(all_dirdeps.keys()): + depdirs = sorted(set(map(lambda x: file_homes[x], all_dirdeps[dirname]))) + + depdirs = filter(interesting_dep_for(dirname), depdirs) + + if depdirs != []: + print "%s: %s" % (dirname, ' '.join(depdirs)) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/src/hash/gost_3411/info.txt b/src/hash/gost_3411/info.txt index ef2879823..65b9475e1 100644 --- a/src/hash/gost_3411/info.txt +++ b/src/hash/gost_3411/info.txt @@ -8,3 +8,7 @@ load_on auto gost_3411.cpp gost_3411.h </add> + +<requires> +gost_28147 +</requires> diff --git a/src/kdf/tls_prf/info.txt b/src/kdf/tls_prf/info.txt index 58c1ed029..c775c90ba 100644 --- a/src/kdf/tls_prf/info.txt +++ b/src/kdf/tls_prf/info.txt @@ -5,9 +5,10 @@ define TLS_V10_PRF load_on auto <requires> +hmac kdf -sha1 md5 +sha1 </requires> <add> diff --git a/src/kdf/tls_prf/prf_tls.cpp b/src/kdf/tls_prf/prf_tls.cpp index a04c9045d..7c638b994 100644 --- a/src/kdf/tls_prf/prf_tls.cpp +++ b/src/kdf/tls_prf/prf_tls.cpp @@ -13,6 +13,39 @@ namespace Botan { +namespace { + +/* +* TLS PRF P_hash function +*/ +SecureVector<byte> P_hash(MessageAuthenticationCode* mac, + u32bit len, + const byte secret[], u32bit secret_len, + const byte seed[], u32bit seed_len) + { + SecureVector<byte> out; + + mac->set_key(secret, secret_len); + + SecureVector<byte> A(seed, seed_len); + while(len) + { + const u32bit this_block_len = std::min(mac->OUTPUT_LENGTH, len); + + A = mac->process(A); + + mac->update(A); + mac->update(seed, seed_len); + SecureVector<byte> block = mac->final(); + + out.append(block, this_block_len); + len -= this_block_len; + } + return out; + } + +} + /* * TLS PRF Constructor and Destructor */ @@ -49,33 +82,4 @@ SecureVector<byte> TLS_PRF::derive(u32bit key_len, return key1; } -/* -* TLS PRF P_hash function -*/ -SecureVector<byte> TLS_PRF::P_hash(MessageAuthenticationCode* mac, - u32bit len, - const byte secret[], u32bit secret_len, - const byte seed[], u32bit seed_len) - { - SecureVector<byte> out; - - mac->set_key(secret, secret_len); - - SecureVector<byte> A(seed, seed_len); - while(len) - { - const u32bit this_block_len = std::min(mac->OUTPUT_LENGTH, len); - - A = mac->process(A); - - mac->update(A); - mac->update(seed, seed_len); - SecureVector<byte> block = mac->final(); - - out.append(block, this_block_len); - len -= this_block_len; - } - return out; - } - } diff --git a/src/kdf/tls_prf/prf_tls.h b/src/kdf/tls_prf/prf_tls.h index 6b81c155f..d21279588 100644 --- a/src/kdf/tls_prf/prf_tls.h +++ b/src/kdf/tls_prf/prf_tls.h @@ -25,11 +25,6 @@ class BOTAN_DLL TLS_PRF : public KDF TLS_PRF(); ~TLS_PRF(); private: - static SecureVector<byte> P_hash(MessageAuthenticationCode*, - u32bit, - const byte[], u32bit, - const byte[], u32bit); - MessageAuthenticationCode* hmac_md5; MessageAuthenticationCode* hmac_sha1; }; |