]> andersk Git - gssapi-openssh.git/blobdiff - openssh/mac.c
whitespace
[gssapi-openssh.git] / openssh / mac.c
index e5d5bfa88e76e84be63f00adde174966ba551c28..e8b4267c3fc1e739236bbe41d05694049a4b402e 100644 (file)
@@ -1,4 +1,3 @@
-/* $OpenBSD: mac.c,v 1.12 2006/08/03 03:34:42 deraadt Exp $ */
 /*
  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
  *
  */
 
 #include "includes.h"
-
-#include <sys/types.h>
+RCSID("$OpenBSD: mac.c,v 1.2 2001/04/05 10:42:51 markus Exp $");
 
 #include <openssl/hmac.h>
 
-#include <stdarg.h>
-#include <string.h>
-#include <signal.h>
-
 #include "xmalloc.h"
+#include "getput.h"
 #include "log.h"
 #include "cipher.h"
-#include "buffer.h"
-#include "key.h"
 #include "kex.h"
 #include "mac.h"
-#include "misc.h"
 
 struct {
        char            *name;
-       const EVP_MD *  (*mdfunc)(void);
+       EVP_MD *        (*mdfunc)(void);
        int             truncatebits;   /* truncate digest if != 0 */
 } macs[] = {
        { "hmac-sha1",                  EVP_sha1, 0, },
@@ -59,15 +51,12 @@ struct {
 int
 mac_init(Mac *mac, char *name)
 {
-       int i, evp_len;
-
+       int i;
        for (i = 0; macs[i].name; i++) {
                if (strcmp(name, macs[i].name) == 0) {
                        if (mac != NULL) {
                                mac->md = (*macs[i].mdfunc)();
-                               if ((evp_len = EVP_MD_size(mac->md)) <= 0)
-                                       fatal("mac %s len %d", name, evp_len);
-                               mac->key_len = mac->mac_len = (u_int)evp_len;
+                               mac->key_len = mac->mac_len = mac->md->md_size;
                                if (macs[i].truncatebits != 0)
                                        mac->mac_len = macs[i].truncatebits/8;
                        }
@@ -91,7 +80,7 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
        if (mac->mac_len > sizeof(m))
                fatal("mac_compute: mac too long");
        HMAC_Init(&c, mac->key, mac->key_len, mac->md);
-       put_u32(b, seqno);
+       PUT_32BIT(b, seqno);
        HMAC_Update(&c, b, sizeof(b));
        HMAC_Update(&c, data, datalen);
        HMAC_Final(&c, m, NULL);
@@ -110,7 +99,7 @@ mac_valid(const char *names)
                return (0);
        maclist = cp = xstrdup(names);
        for ((p = strsep(&cp, MAC_SEP)); p && *p != '\0';
-           (p = strsep(&cp, MAC_SEP))) {
+            (p = strsep(&cp, MAC_SEP))) {
                if (mac_init(NULL, p) < 0) {
                        debug("bad mac %s [%s]", p, names);
                        xfree(maclist);
This page took 0.080858 seconds and 4 git commands to generate.