diff options
author | lloyd <[email protected]> | 2010-09-15 14:20:38 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-15 14:20:38 +0000 |
commit | d432647483aa74c97460eb065f2b11fd82fc9177 (patch) | |
tree | 8fae2888ff5c18ab87fbf0c5c63a7e35b5db76a7 /src/ssl/tls_handshake_hash.cpp | |
parent | 72ba429aa2550d12b13ce321a567601bddf7c665 (diff) |
Hide a number of the internal SSL headers from the user, you can still
see too much but better than before.
Diffstat (limited to 'src/ssl/tls_handshake_hash.cpp')
-rw-r--r-- | src/ssl/tls_handshake_hash.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/ssl/tls_handshake_hash.cpp b/src/ssl/tls_handshake_hash.cpp new file mode 100644 index 000000000..93442cad1 --- /dev/null +++ b/src/ssl/tls_handshake_hash.cpp @@ -0,0 +1,66 @@ +/* +* TLS Handshake Hash +* (C) 2004-2006 Jack Lloyd +* +* Released under the terms of the Botan license +*/ + +#include <botan/internal/tls_handshake_hash.h> +#include <botan/md5.h> +#include <botan/sha160.h> +#include <memory> + +namespace Botan { + +/** +* Return a TLS Handshake Hash +*/ +SecureVector<byte> HandshakeHash::final() + { + MD5 md5; + SHA_160 sha1; + + md5.update(data); + sha1.update(data); + + SecureVector<byte> output; + output += md5.final(); + output += sha1.final(); + return output; + } + +/** +* Return a SSLv3 Handshake Hash +*/ +SecureVector<byte> HandshakeHash::final_ssl3(const MemoryRegion<byte>& secret) + { + const byte PAD_INNER = 0x36, PAD_OUTER = 0x5C; + + MD5 md5; + SHA_160 sha1; + + md5.update(data); + sha1.update(data); + + md5.update(secret); + sha1.update(secret); + + for(u32bit j = 0; j != 48; j++) md5.update(PAD_INNER); + for(u32bit j = 0; j != 40; j++) sha1.update(PAD_INNER); + + SecureVector<byte> inner_md5 = md5.final(), inner_sha1 = sha1.final(); + + md5.update(secret); + sha1.update(secret); + for(u32bit j = 0; j != 48; j++) md5.update(PAD_OUTER); + for(u32bit j = 0; j != 40; j++) sha1.update(PAD_OUTER); + md5.update(inner_md5); + sha1.update(inner_sha1); + + SecureVector<byte> output; + output += md5.final(); + output += sha1.final(); + return output; + } + +} |