diff options
author | lloyd <[email protected]> | 2010-01-11 22:57:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-01-11 22:57:21 +0000 |
commit | a4124ddf481bfc56859007b34dea646ecb7f8a25 (patch) | |
tree | fd842d8a091c5c529d6c32cd300bc195519ceb46 /src/ssl/handshake_hash.cpp | |
parent | f5fd85b0ea6a5a6975d595130e029f94fddae9a4 (diff) |
Import latest version of Ajisai into src/ssl; once this hits mainline
I'll officially kill off Ajisai (instead of it just lingering as a zombine
as it is currently).
Apparently I broke something (or multiple things) during the import process;
servers crash and clients gets MAC errors on connect.
Diffstat (limited to 'src/ssl/handshake_hash.cpp')
-rw-r--r-- | src/ssl/handshake_hash.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/ssl/handshake_hash.cpp b/src/ssl/handshake_hash.cpp new file mode 100644 index 000000000..9690a0edb --- /dev/null +++ b/src/ssl/handshake_hash.cpp @@ -0,0 +1,60 @@ +/** +* TLS Handshake Hash Source File +* (C) 2004-2006 Jack Lloyd +* +* Released under the terms of the Botan license +*/ + +#include <botan/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); + + return SecureVector<byte>(md5.final(), sha1.final()); + } + +/** +* 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); + + return SecureVector<byte>(md5.final(), sha1.final()); + } + +} |