Changeset View
Changeset View
Standalone View
Standalone View
mac.c
/* $OpenBSD: mac.c,v 1.34 2017/05/08 22:57:38 djm Exp $ */ | /* $OpenBSD: mac.c,v 1.35 2019/09/06 04:53:27 djm Exp $ */ | ||||
/* | /* | ||||
* Copyright (c) 2001 Markus Friedl. All rights reserved. | * Copyright (c) 2001 Markus Friedl. All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
Show All 12 Lines | |||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
*/ | */ | ||||
#include "includes.h" | #include "includes.h" | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <stdlib.h> | |||||
#include <string.h> | #include <string.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include "digest.h" | #include "digest.h" | ||||
#include "hmac.h" | #include "hmac.h" | ||||
#include "umac.h" | #include "umac.h" | ||||
#include "mac.h" | #include "mac.h" | ||||
#include "misc.h" | #include "misc.h" | ||||
Show All 15 Lines | struct macalg { | ||||
int len; /* just for UMAC */ | int len; /* just for UMAC */ | ||||
int etm; /* Encrypt-then-MAC */ | int etm; /* Encrypt-then-MAC */ | ||||
}; | }; | ||||
static const struct macalg macs[] = { | static const struct macalg macs[] = { | ||||
/* Encrypt-and-MAC (encrypt-and-authenticate) variants */ | /* Encrypt-and-MAC (encrypt-and-authenticate) variants */ | ||||
{ "hmac-sha1", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 0 }, | { "hmac-sha1", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 0 }, | ||||
{ "hmac-sha1-96", SSH_DIGEST, SSH_DIGEST_SHA1, 96, 0, 0, 0 }, | { "hmac-sha1-96", SSH_DIGEST, SSH_DIGEST_SHA1, 96, 0, 0, 0 }, | ||||
#ifdef HAVE_EVP_SHA256 | |||||
{ "hmac-sha2-256", SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 0 }, | { "hmac-sha2-256", SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 0 }, | ||||
{ "hmac-sha2-512", SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 0 }, | { "hmac-sha2-512", SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 0 }, | ||||
#endif | |||||
{ "hmac-md5", SSH_DIGEST, SSH_DIGEST_MD5, 0, 0, 0, 0 }, | { "hmac-md5", SSH_DIGEST, SSH_DIGEST_MD5, 0, 0, 0, 0 }, | ||||
{ "hmac-md5-96", SSH_DIGEST, SSH_DIGEST_MD5, 96, 0, 0, 0 }, | { "hmac-md5-96", SSH_DIGEST, SSH_DIGEST_MD5, 96, 0, 0, 0 }, | ||||
{ "umac-64@openssh.com", SSH_UMAC, 0, 0, 128, 64, 0 }, | { "umac-64@openssh.com", SSH_UMAC, 0, 0, 128, 64, 0 }, | ||||
{ "umac-128@openssh.com", SSH_UMAC128, 0, 0, 128, 128, 0 }, | { "umac-128@openssh.com", SSH_UMAC128, 0, 0, 128, 128, 0 }, | ||||
/* Encrypt-then-MAC variants */ | /* Encrypt-then-MAC variants */ | ||||
{ "hmac-sha1-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 1 }, | { "hmac-sha1-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA1, 0, 0, 0, 1 }, | ||||
{ "hmac-sha1-96-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA1, 96, 0, 0, 1 }, | { "hmac-sha1-96-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA1, 96, 0, 0, 1 }, | ||||
#ifdef HAVE_EVP_SHA256 | |||||
{ "hmac-sha2-256-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 1 }, | { "hmac-sha2-256-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA256, 0, 0, 0, 1 }, | ||||
{ "hmac-sha2-512-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 1 }, | { "hmac-sha2-512-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_SHA512, 0, 0, 0, 1 }, | ||||
#endif | |||||
{ "hmac-md5-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_MD5, 0, 0, 0, 1 }, | { "hmac-md5-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_MD5, 0, 0, 0, 1 }, | ||||
{ "hmac-md5-96-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_MD5, 96, 0, 0, 1 }, | { "hmac-md5-96-etm@openssh.com", SSH_DIGEST, SSH_DIGEST_MD5, 96, 0, 0, 1 }, | ||||
{ "umac-64-etm@openssh.com", SSH_UMAC, 0, 0, 128, 64, 1 }, | { "umac-64-etm@openssh.com", SSH_UMAC, 0, 0, 128, 64, 1 }, | ||||
{ "umac-128-etm@openssh.com", SSH_UMAC128, 0, 0, 128, 128, 1 }, | { "umac-128-etm@openssh.com", SSH_UMAC128, 0, 0, 128, 128, 1 }, | ||||
{ NULL, 0, 0, 0, 0, 0, 0 } | { NULL, 0, 0, 0, 0, 0, 0 } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 181 Lines • Show Last 20 Lines |