summaryrefslogtreecommitdiffstats
path: root/mac.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2012-10-05 11:02:39 +1000
committerDarren Tucker <dtucker@zip.com.au>2012-10-05 11:02:39 +1000
commit427e409e99d465118fbc2f7c1ca2c5d44365f5a8 (patch)
tree13b60a8b85469f596ffef7f57f086b24ec1f4551 /mac.c
parent0dc283b13acdd4926dec1289b94badc3bbc7f321 (diff)
- markus@cvs.openbsd.org 2012/10/04 13:21:50
[myproposal.h ssh_config.5 umac.h sshd_config.5 ssh.1 sshd.8 mac.c] add umac128 variant; ok djm@ at n2k12 (note: further Makefile work is required)
Diffstat (limited to 'mac.c')
-rw-r--r--mac.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/mac.c b/mac.c
index 9b450e4e..47db127f 100644
--- a/mac.c
+++ b/mac.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mac.c,v 1.18 2012/06/28 05:07:45 dtucker Exp $ */
+/* $OpenBSD: mac.c,v 1.19 2012/10/04 13:21:50 markus Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
*
@@ -48,6 +48,7 @@
#define SSH_EVP 1 /* OpenSSL EVP-based MAC */
#define SSH_UMAC 2 /* UMAC (not integrated with OpenSSL) */
+#define SSH_UMAC128 3
struct {
char *name;
@@ -68,6 +69,7 @@ struct {
{ "hmac-ripemd160", 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-128@openssh.com", SSH_UMAC128, NULL, 0, 128, 128 },
{ NULL, 0, NULL, 0, -1, -1 }
};
@@ -122,6 +124,9 @@ mac_init(Mac *mac)
case SSH_UMAC:
mac->umac_ctx = umac_new(mac->key);
return 0;
+ case SSH_UMAC128:
+ mac->umac_ctx = umac128_new(mac->key);
+ return 0;
default:
return -1;
}
@@ -151,6 +156,11 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
umac_update(mac->umac_ctx, data, datalen);
umac_final(mac->umac_ctx, m, nonce);
break;
+ case SSH_UMAC128:
+ put_u64(nonce, seqno);
+ umac128_update(mac->umac_ctx, data, datalen);
+ umac128_final(mac->umac_ctx, m, nonce);
+ break;
default:
fatal("mac_compute: unknown MAC type");
}
@@ -163,6 +173,9 @@ mac_clear(Mac *mac)
if (mac->type == SSH_UMAC) {
if (mac->umac_ctx != NULL)
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)
HMAC_cleanup(&mac->evp_ctx);
mac->evp_md = NULL;