summaryrefslogtreecommitdiff
path: root/mac.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-06-17 12:59:34 +1000
committerDamien Miller <djm@mindrot.org>2005-06-17 12:59:34 +1000
commiteccb9de72aa29da5a3fad87a4287b32438689c1f (patch)
tree9b8ef20a7e454b984e0ad67b54b2bdc5577aa2fa /mac.c
parent677257fe07dd2b9a58817e1d42fc2c25bb618a4d (diff)
- djm@cvs.openbsd.org 2005/06/17 02:44:33
[auth-rsa.c auth.c auth1.c auth2-chall.c auth2-gss.c authfd.c authfile.c] [bufaux.c canohost.c channels.c cipher.c clientloop.c dns.c gss-serv.c] [kex.c kex.h key.c mac.c match.c misc.c packet.c packet.h scp.c] [servconf.c session.c session.h sftp-client.c sftp-server.c sftp.c] [ssh-keyscan.c ssh-rsa.c sshconnect.c sshconnect1.c sshconnect2.c sshd.c] make this -Wsign-compare clean; ok avsm@ markus@ NB. auth1.c changes not committed yet (conflicts with uncommitted sync) NB2. more work may be needed to make portable Wsign-compare clean
Diffstat (limited to 'mac.c')
-rw-r--r--mac.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mac.c b/mac.c
index 097f0b93b..2bda5a1b9 100644
--- a/mac.c
+++ b/mac.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: mac.c,v 1.6 2003/09/18 13:02:21 miod Exp $"); 26RCSID("$OpenBSD: mac.c,v 1.7 2005/06/17 02:44:32 djm Exp $");
27 27
28#include <openssl/hmac.h> 28#include <openssl/hmac.h>
29 29
@@ -51,12 +51,15 @@ struct {
51int 51int
52mac_init(Mac *mac, char *name) 52mac_init(Mac *mac, char *name)
53{ 53{
54 int i; 54 int i, evp_len;
55
55 for (i = 0; macs[i].name; i++) { 56 for (i = 0; macs[i].name; i++) {
56 if (strcmp(name, macs[i].name) == 0) { 57 if (strcmp(name, macs[i].name) == 0) {
57 if (mac != NULL) { 58 if (mac != NULL) {
58 mac->md = (*macs[i].mdfunc)(); 59 mac->md = (*macs[i].mdfunc)();
59 mac->key_len = mac->mac_len = EVP_MD_size(mac->md); 60 if ((evp_len = EVP_MD_size(mac->md)) <= 0)
61 fatal("mac %s len %d", name, evp_len);
62 mac->key_len = mac->mac_len = (u_int)evp_len;
60 if (macs[i].truncatebits != 0) 63 if (macs[i].truncatebits != 0)
61 mac->mac_len = macs[i].truncatebits/8; 64 mac->mac_len = macs[i].truncatebits/8;
62 } 65 }
@@ -77,7 +80,7 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
77 80
78 if (mac->key == NULL) 81 if (mac->key == NULL)
79 fatal("mac_compute: no key"); 82 fatal("mac_compute: no key");
80 if ((u_int)mac->mac_len > sizeof(m)) 83 if (mac->mac_len > sizeof(m))
81 fatal("mac_compute: mac too long"); 84 fatal("mac_compute: mac too long");
82 HMAC_Init(&c, mac->key, mac->key_len, mac->md); 85 HMAC_Init(&c, mac->key, mac->key_len, mac->md);
83 PUT_32BIT(b, seqno); 86 PUT_32BIT(b, seqno);