xref: /freebsd/sys/opencrypto/xform_rmd160.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
12155bb23SAllan Jude /*	$OpenBSD: xform.c,v 1.16 2001/08/28 12:20:43 ben Exp $	*/
22155bb23SAllan Jude /*-
32155bb23SAllan Jude  * The authors of this code are John Ioannidis (ji@tla.org),
42155bb23SAllan Jude  * Angelos D. Keromytis (kermit@csd.uch.gr),
52155bb23SAllan Jude  * Niels Provos (provos@physnet.uni-hamburg.de) and
62155bb23SAllan Jude  * Damien Miller (djm@mindrot.org).
72155bb23SAllan Jude  *
82155bb23SAllan Jude  * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
92155bb23SAllan Jude  * in November 1995.
102155bb23SAllan Jude  *
112155bb23SAllan Jude  * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
122155bb23SAllan Jude  * by Angelos D. Keromytis.
132155bb23SAllan Jude  *
142155bb23SAllan Jude  * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
152155bb23SAllan Jude  * and Niels Provos.
162155bb23SAllan Jude  *
172155bb23SAllan Jude  * Additional features in 1999 by Angelos D. Keromytis.
182155bb23SAllan Jude  *
192155bb23SAllan Jude  * AES XTS implementation in 2008 by Damien Miller
202155bb23SAllan Jude  *
212155bb23SAllan Jude  * Copyright (C) 1995, 1996, 1997, 1998, 1999 by John Ioannidis,
222155bb23SAllan Jude  * Angelos D. Keromytis and Niels Provos.
232155bb23SAllan Jude  *
242155bb23SAllan Jude  * Copyright (C) 2001, Angelos D. Keromytis.
252155bb23SAllan Jude  *
262155bb23SAllan Jude  * Copyright (C) 2008, Damien Miller
272155bb23SAllan Jude  * Copyright (c) 2014 The FreeBSD Foundation
282155bb23SAllan Jude  * All rights reserved.
292155bb23SAllan Jude  *
302155bb23SAllan Jude  * Portions of this software were developed by John-Mark Gurney
312155bb23SAllan Jude  * under sponsorship of the FreeBSD Foundation and
322155bb23SAllan Jude  * Rubicon Communications, LLC (Netgate).
332155bb23SAllan Jude  *
342155bb23SAllan Jude  * Permission to use, copy, and modify this software with or without fee
352155bb23SAllan Jude  * is hereby granted, provided that this entire notice is included in
362155bb23SAllan Jude  * all copies of any software which is or includes a copy or
372155bb23SAllan Jude  * modification of this software.
382155bb23SAllan Jude  * You may use this code under the GNU public license if you so wish. Please
392155bb23SAllan Jude  * contribute changes back to the authors under this freer than GPL license
402155bb23SAllan Jude  * so that we may further the use of strong encryption without limitations to
412155bb23SAllan Jude  * all.
422155bb23SAllan Jude  *
432155bb23SAllan Jude  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
442155bb23SAllan Jude  * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
452155bb23SAllan Jude  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
462155bb23SAllan Jude  * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
472155bb23SAllan Jude  * PURPOSE.
482155bb23SAllan Jude  */
492155bb23SAllan Jude 
50*faf470ffSJohn Baldwin #include <sys/types.h>
512155bb23SAllan Jude #include <opencrypto/rmd160.h>
522155bb23SAllan Jude #include <opencrypto/xform_auth.h>
532155bb23SAllan Jude 
549b6b2f86SJohn Baldwin static	void RMD160Init_int(void *);
559b6b2f86SJohn Baldwin static	int RMD160Update_int(void *, const void *, u_int);
569b6b2f86SJohn Baldwin static	void RMD160Final_int(uint8_t *, void *);
572155bb23SAllan Jude 
58c3a688efSJohn Baldwin /* Plain hash */
59c3a688efSJohn Baldwin const struct auth_hash auth_hash_ripemd_160 = {
60c3a688efSJohn Baldwin 	.type = CRYPTO_RIPEMD160,
61c3a688efSJohn Baldwin 	.name = "RIPEMD-160",
62c3a688efSJohn Baldwin 	.hashsize = RIPEMD160_HASH_LEN,
63c3a688efSJohn Baldwin 	.ctxsize = sizeof(RMD160_CTX),
64c3a688efSJohn Baldwin 	.blocksize = RIPEMD160_BLOCK_LEN,
65c3a688efSJohn Baldwin 	.Init = RMD160Init_int,
66c3a688efSJohn Baldwin 	.Update = RMD160Update_int,
67c3a688efSJohn Baldwin 	.Final = RMD160Final_int,
68c3a688efSJohn Baldwin };
69c3a688efSJohn Baldwin 
702155bb23SAllan Jude /* Authentication instances */
71d8787d4fSMark Johnston const struct auth_hash auth_hash_hmac_ripemd_160 = {
72255811d7SConrad Meyer 	.type = CRYPTO_RIPEMD160_HMAC,
73255811d7SConrad Meyer 	.name = "HMAC-RIPEMD-160",
74590adc1bSConrad Meyer 	.keysize = RIPEMD160_BLOCK_LEN,
75255811d7SConrad Meyer 	.hashsize = RIPEMD160_HASH_LEN,
76255811d7SConrad Meyer 	.ctxsize = sizeof(RMD160_CTX),
77590adc1bSConrad Meyer 	.blocksize = RIPEMD160_BLOCK_LEN,
789b6b2f86SJohn Baldwin 	.Init = RMD160Init_int,
79255811d7SConrad Meyer 	.Update = RMD160Update_int,
809b6b2f86SJohn Baldwin 	.Final = RMD160Final_int,
812155bb23SAllan Jude };
822155bb23SAllan Jude 
839b6b2f86SJohn Baldwin static void
RMD160Init_int(void * ctx)849b6b2f86SJohn Baldwin RMD160Init_int(void *ctx)
859b6b2f86SJohn Baldwin {
869b6b2f86SJohn Baldwin 	RMD160Init(ctx);
879b6b2f86SJohn Baldwin }
889b6b2f86SJohn Baldwin 
892155bb23SAllan Jude static int
RMD160Update_int(void * ctx,const void * buf,u_int len)909b6b2f86SJohn Baldwin RMD160Update_int(void *ctx, const void *buf, u_int len)
912155bb23SAllan Jude {
922155bb23SAllan Jude 	RMD160Update(ctx, buf, len);
932155bb23SAllan Jude 	return 0;
942155bb23SAllan Jude }
959b6b2f86SJohn Baldwin 
969b6b2f86SJohn Baldwin static void
RMD160Final_int(uint8_t * digest,void * ctx)979b6b2f86SJohn Baldwin RMD160Final_int(uint8_t *digest, void *ctx)
989b6b2f86SJohn Baldwin {
999b6b2f86SJohn Baldwin 	RMD160Final(digest, ctx);
1009b6b2f86SJohn Baldwin }
101