diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2000-12-07 09:47:03 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2000-12-07 09:47:03 +0000 |
commit | f926187b03b89113734cf7cac57e62b7ed8755a5 (patch) | |
tree | 346baece0b273edf5a4695cbe0c75fef9f3c2ffc /lib/gnutls_hash_int.c | |
parent | 8ea2cb55648ba24899e57ed41b61ee7dc5bf7678 (diff) | |
download | gnutls-f926187b03b89113734cf7cac57e62b7ed8755a5.tar.gz |
SSL3 support was added
Diffstat (limited to 'lib/gnutls_hash_int.c')
-rw-r--r-- | lib/gnutls_hash_int.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/gnutls_hash_int.c b/lib/gnutls_hash_int.c index c847d42edf..8fe6d06d15 100644 --- a/lib/gnutls_hash_int.c +++ b/lib/gnutls_hash_int.c @@ -265,6 +265,22 @@ GNUTLS_MAC_HANDLE gnutls_mac_init_ssl3(MACAlgorithm algorithm, void *key, return ret; } +GNUTLS_MAC_HANDLE gnutls_mac_init_ssl3_handshake(MACAlgorithm algorithm, void *key, + int keylen) +{ + GNUTLS_MAC_HANDLE ret; + char *digest; + int padsize; + + ret = gnutls_hash_init(algorithm); + if (ret!=GNUTLS_MAC_FAILED) { + ret->key = key; + ret->keysize = keylen; + } + + return ret; +} + void *gnutls_mac_deinit_ssl3(GNUTLS_MAC_HANDLE handle) { void *ret=NULL; @@ -302,6 +318,49 @@ void *gnutls_mac_deinit_ssl3(GNUTLS_MAC_HANDLE handle) return ret; } +void *gnutls_mac_deinit_ssl3_handshake(GNUTLS_MAC_HANDLE handle) +{ + void *ret=NULL; + GNUTLS_MAC_HANDLE td; + char opad[48]; + char ipad[48]; + int padsize; + int block; + + switch (handle->algorithm) { + case GNUTLS_MAC_MD5: + padsize = 48; + break; + case GNUTLS_MAC_SHA: + padsize = 40; + break; + default: + padsize=0; + } + if (padsize > 0) { + memset(opad, 0x5C, padsize); + memset(ipad, 0x36, padsize); + } + + td = gnutls_hash_init(handle->algorithm); + if (td!=GNUTLS_MAC_FAILED) { + if (handle->keysize > 0) gnutls_hash(td, handle->key, handle->keysize); + + gnutls_hash(td, opad, padsize); + block = gnutls_hmac_get_algo_len(handle->algorithm); + + if (handle->keysize > 0) gnutls_hash( handle, handle->key, handle->keysize); + gnutls_hash(handle, ipad, padsize); + ret = gnutls_hash_deinit(handle); /* get the previous hash */ + + gnutls_hash(td, ret, block); + gnutls_free(ret); + + ret = gnutls_hash_deinit(td); + } + return ret; +} + static void *ssl3_sha(int i, char *secret, int secret_len, char *random, int random_len) { |