From fa2334561d4a888a94c8c161b2e7d4581061844f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 14 Jan 2009 16:21:09 +0000 Subject: small improvement auth_algo --- src/auth_algo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/auth_algo.c b/src/auth_algo.c index 0193fa6..ae33233 100644 --- a/src/auth_algo.c +++ b/src/auth_algo.c @@ -176,6 +176,9 @@ void auth_algo_sha1_close(auth_algo_t* aa) void auth_algo_sha1_generate(auth_algo_t* aa, key_derivation_t* kd, encrypted_packet_t* packet) { + if(!encrypted_packet_get_auth_tag_length(packet)) + return; + if(!aa || !aa->params_) { log_printf(ERR, "auth algo not initialized"); return; @@ -230,6 +233,9 @@ void auth_algo_sha1_generate(auth_algo_t* aa, key_derivation_t* kd, encrypted_pa int auth_algo_sha1_check_tag(auth_algo_t* aa, key_derivation_t* kd, encrypted_packet_t* packet) { + if(!encrypted_packet_get_auth_tag_length(packet)) + return 1; + if(!aa || !aa->params_) { log_printf(ERR, "auth algo not initialized"); return 0; @@ -248,7 +254,7 @@ int auth_algo_sha1_check_tag(auth_algo_t* aa, key_derivation_t* kd, encrypted_pa gcry_error_t err = gcry_md_setkey(params->handle_, aa->key_.buf_, aa->key_.length_); if(err) { log_printf(ERR, "failed to set hmac key: %s", gcry_strerror(err)); - return; + return -1; } #else HMAC_Init_ex(¶ms->ctx_, aa->key_.buf_, aa->key_.length_, EVP_sha1(), NULL); -- cgit v1.2.3