Deleted Added
full compact
mac.c (98675) mac.c (126274)
1/*
2 * Copyright (c) 2001 Markus Friedl. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 9 unchanged lines hidden (view full) ---

18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include "includes.h"
1/*
2 * Copyright (c) 2001 Markus Friedl. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 9 unchanged lines hidden (view full) ---

18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include "includes.h"
26RCSID("$OpenBSD: mac.c,v 1.5 2002/05/16 22:02:50 markus Exp $");
26RCSID("$OpenBSD: mac.c,v 1.6 2003/09/18 13:02:21 miod Exp $");
27
28#include <openssl/hmac.h>
29
30#include "xmalloc.h"
31#include "getput.h"
32#include "log.h"
33#include "cipher.h"
34#include "kex.h"

--- 37 unchanged lines hidden (view full) ---

72mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
73{
74 HMAC_CTX c;
75 static u_char m[EVP_MAX_MD_SIZE];
76 u_char b[4];
77
78 if (mac->key == NULL)
79 fatal("mac_compute: no key");
27
28#include <openssl/hmac.h>
29
30#include "xmalloc.h"
31#include "getput.h"
32#include "log.h"
33#include "cipher.h"
34#include "kex.h"

--- 37 unchanged lines hidden (view full) ---

72mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
73{
74 HMAC_CTX c;
75 static u_char m[EVP_MAX_MD_SIZE];
76 u_char b[4];
77
78 if (mac->key == NULL)
79 fatal("mac_compute: no key");
80 if (mac->mac_len > sizeof(m))
80 if ((u_int)mac->mac_len > sizeof(m))
81 fatal("mac_compute: mac too long");
82 HMAC_Init(&c, mac->key, mac->key_len, mac->md);
83 PUT_32BIT(b, seqno);
84 HMAC_Update(&c, b, sizeof(b));
85 HMAC_Update(&c, data, datalen);
86 HMAC_Final(&c, m, NULL);
87 HMAC_cleanup(&c);
88 return (m);

--- 26 unchanged lines hidden ---
81 fatal("mac_compute: mac too long");
82 HMAC_Init(&c, mac->key, mac->key_len, mac->md);
83 PUT_32BIT(b, seqno);
84 HMAC_Update(&c, b, sizeof(b));
85 HMAC_Update(&c, data, datalen);
86 HMAC_Final(&c, m, NULL);
87 HMAC_cleanup(&c);
88 return (m);

--- 26 unchanged lines hidden ---