xref: /freebsd/sys/opencrypto/xform_deflate.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/deflate.h>
522155bb23SAllan Jude #include <opencrypto/xform_comp.h>
532155bb23SAllan Jude 
54d3d79e96SJohn Baldwin static	uint32_t deflate_compress(uint8_t *, uint32_t, uint8_t **);
55d3d79e96SJohn Baldwin static	uint32_t deflate_decompress(uint8_t *, uint32_t, uint8_t **);
562155bb23SAllan Jude 
572155bb23SAllan Jude /* Compression instance */
58d8787d4fSMark Johnston const struct comp_algo comp_algo_deflate = {
592155bb23SAllan Jude 	CRYPTO_DEFLATE_COMP, "Deflate",
602155bb23SAllan Jude 	90, deflate_compress,
612155bb23SAllan Jude 	deflate_decompress
622155bb23SAllan Jude };
632155bb23SAllan Jude 
642155bb23SAllan Jude /*
652155bb23SAllan Jude  * And compression
662155bb23SAllan Jude  */
672155bb23SAllan Jude 
68d3d79e96SJohn Baldwin static uint32_t
deflate_compress(uint8_t * data,uint32_t size,uint8_t ** out)699038e6a1SJohn Baldwin deflate_compress(uint8_t *data, uint32_t size, uint8_t **out)
702155bb23SAllan Jude {
712155bb23SAllan Jude 	return deflate_global(data, size, 0, out);
722155bb23SAllan Jude }
732155bb23SAllan Jude 
74d3d79e96SJohn Baldwin static uint32_t
deflate_decompress(uint8_t * data,uint32_t size,uint8_t ** out)759038e6a1SJohn Baldwin deflate_decompress(uint8_t *data, uint32_t size, uint8_t **out)
762155bb23SAllan Jude {
772155bb23SAllan Jude 	return deflate_global(data, size, 1, out);
782155bb23SAllan Jude }
79