version 1.18, 2012/06/28 05:07:45 |
version 1.19, 2012/10/04 13:21:50 |
|
|
|
|
#define SSH_EVP 1 /* OpenSSL EVP-based MAC */ |
#define SSH_EVP 1 /* OpenSSL EVP-based MAC */ |
#define SSH_UMAC 2 /* UMAC (not integrated with OpenSSL) */ |
#define SSH_UMAC 2 /* UMAC (not integrated with OpenSSL) */ |
|
#define SSH_UMAC128 3 |
|
|
struct { |
struct { |
char *name; |
char *name; |
|
|
{ "hmac-ripemd160", SSH_EVP, EVP_ripemd160, 0, -1, -1 }, |
{ "hmac-ripemd160", SSH_EVP, EVP_ripemd160, 0, -1, -1 }, |
{ "hmac-ripemd160@openssh.com", SSH_EVP, EVP_ripemd160, 0, -1, -1 }, |
{ "hmac-ripemd160@openssh.com", SSH_EVP, EVP_ripemd160, 0, -1, -1 }, |
{ "umac-64@openssh.com", SSH_UMAC, NULL, 0, 128, 64 }, |
{ "umac-64@openssh.com", SSH_UMAC, NULL, 0, 128, 64 }, |
|
{ "umac-128@openssh.com", SSH_UMAC128, NULL, 0, 128, 128 }, |
{ NULL, 0, NULL, 0, -1, -1 } |
{ NULL, 0, NULL, 0, -1, -1 } |
}; |
}; |
|
|
|
|
case SSH_UMAC: |
case SSH_UMAC: |
mac->umac_ctx = umac_new(mac->key); |
mac->umac_ctx = umac_new(mac->key); |
return 0; |
return 0; |
|
case SSH_UMAC128: |
|
mac->umac_ctx = umac128_new(mac->key); |
|
return 0; |
default: |
default: |
return -1; |
return -1; |
} |
} |
|
|
umac_update(mac->umac_ctx, data, datalen); |
umac_update(mac->umac_ctx, data, datalen); |
umac_final(mac->umac_ctx, m, nonce); |
umac_final(mac->umac_ctx, m, nonce); |
break; |
break; |
|
case SSH_UMAC128: |
|
put_u64(nonce, seqno); |
|
umac128_update(mac->umac_ctx, data, datalen); |
|
umac128_final(mac->umac_ctx, m, nonce); |
|
break; |
default: |
default: |
fatal("mac_compute: unknown MAC type"); |
fatal("mac_compute: unknown MAC type"); |
} |
} |
|
|
if (mac->type == SSH_UMAC) { |
if (mac->type == SSH_UMAC) { |
if (mac->umac_ctx != NULL) |
if (mac->umac_ctx != NULL) |
umac_delete(mac->umac_ctx); |
umac_delete(mac->umac_ctx); |
|
} else if (mac->type == SSH_UMAC128) { |
|
if (mac->umac_ctx != NULL) |
|
umac128_delete(mac->umac_ctx); |
} else if (mac->evp_md != NULL) |
} else if (mac->evp_md != NULL) |
HMAC_cleanup(&mac->evp_ctx); |
HMAC_cleanup(&mac->evp_ctx); |
mac->evp_md = NULL; |
mac->evp_md = NULL; |