1219820Sjeff/*	$OpenBSD: xform.c,v 1.16 2001/08/28 12:20:43 ben Exp $	*/
2219820Sjeff/*-
3219820Sjeff * The authors of this code are John Ioannidis (ji@tla.org),
4219820Sjeff * Angelos D. Keromytis (kermit@csd.uch.gr),
5219820Sjeff * Niels Provos (provos@physnet.uni-hamburg.de) and
6219820Sjeff * Damien Miller (djm@mindrot.org).
7219820Sjeff *
8219820Sjeff * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
9219820Sjeff * in November 1995.
10219820Sjeff *
11219820Sjeff * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
12219820Sjeff * by Angelos D. Keromytis.
13219820Sjeff *
14219820Sjeff * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
15219820Sjeff * and Niels Provos.
16219820Sjeff *
17219820Sjeff * Additional features in 1999 by Angelos D. Keromytis.
18219820Sjeff *
19219820Sjeff * AES XTS implementation in 2008 by Damien Miller
20219820Sjeff *
21219820Sjeff * Copyright (C) 1995, 1996, 1997, 1998, 1999 by John Ioannidis,
22219820Sjeff * Angelos D. Keromytis and Niels Provos.
23219820Sjeff *
24219820Sjeff * Copyright (C) 2001, Angelos D. Keromytis.
25219820Sjeff *
26219820Sjeff * Copyright (C) 2008, Damien Miller
27219820Sjeff * Copyright (c) 2014 The FreeBSD Foundation
28219820Sjeff * All rights reserved.
29219820Sjeff *
30219820Sjeff * Portions of this software were developed by John-Mark Gurney
31219820Sjeff * under sponsorship of the FreeBSD Foundation and
32219820Sjeff * Rubicon Communications, LLC (Netgate).
33219820Sjeff *
34219820Sjeff * Permission to use, copy, and modify this software with or without fee
35219820Sjeff * is hereby granted, provided that this entire notice is included in
36219820Sjeff * all copies of any software which is or includes a copy or
37219820Sjeff * modification of this software.
38219820Sjeff * You may use this code under the GNU public license if you so wish. Please
39219820Sjeff * contribute changes back to the authors under this freer than GPL license
40219820Sjeff * so that we may further the use of strong encryption without limitations to
41219820Sjeff * all.
42219820Sjeff *
43219820Sjeff * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
44219820Sjeff * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
45219820Sjeff * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
46219820Sjeff * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
47219820Sjeff * PURPOSE.
48219820Sjeff */
49219820Sjeff
50219820Sjeff#include <sys/types.h>
51219820Sjeff#include <crypto/sha1.h>
52219820Sjeff#include <opencrypto/xform_auth.h>
53219820Sjeff
54219820Sjeffstatic	void SHA1Init_int(void *);
55219820Sjeffstatic	int SHA1Update_int(void *, const void *, u_int);
56219820Sjeffstatic	void SHA1Final_int(uint8_t *, void *);
57219820Sjeff
58219820Sjeff/* Plain hash */
59219820Sjeffconst struct auth_hash auth_hash_sha1 = {
60219820Sjeff	.type = CRYPTO_SHA1,
61219820Sjeff	.name = "SHA1",
62219820Sjeff	.hashsize = SHA1_HASH_LEN,
63	.ctxsize = sizeof(SHA1_CTX),
64	.blocksize = SHA1_BLOCK_LEN,
65	.Init = SHA1Init_int,
66	.Update = SHA1Update_int,
67	.Final = SHA1Final_int,
68};
69
70/* Authentication instances */
71const struct auth_hash auth_hash_hmac_sha1 = {
72	.type = CRYPTO_SHA1_HMAC,
73	.name = "HMAC-SHA1",
74	.keysize = SHA1_BLOCK_LEN,
75	.hashsize = SHA1_HASH_LEN,
76	.ctxsize = sizeof(SHA1_CTX),
77	.blocksize = SHA1_BLOCK_LEN,
78	.Init = SHA1Init_int,
79	.Update = SHA1Update_int,
80	.Final = SHA1Final_int,
81};
82
83/*
84 * And now for auth.
85 */
86static void
87SHA1Init_int(void *ctx)
88{
89	SHA1Init(ctx);
90}
91
92static int
93SHA1Update_int(void *ctx, const void *buf, u_int len)
94{
95	SHA1Update(ctx, buf, len);
96	return 0;
97}
98
99static void
100SHA1Final_int(uint8_t *blk, void *ctx)
101{
102	SHA1Final(blk, ctx);
103}
104