1104476Ssam/*	$OpenBSD: xform.c,v 1.16 2001/08/28 12:20:43 ben Exp $	*/
2139825Simp/*-
3104476Ssam * The authors of this code are John Ioannidis (ji@tla.org),
4247061Spjd * Angelos D. Keromytis (kermit@csd.uch.gr),
5247061Spjd * Niels Provos (provos@physnet.uni-hamburg.de) and
6247061Spjd * Damien Miller (djm@mindrot.org).
7104476Ssam *
8104476Ssam * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
9104476Ssam * in November 1995.
10104476Ssam *
11104476Ssam * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
12104476Ssam * by Angelos D. Keromytis.
13104476Ssam *
14104476Ssam * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
15104476Ssam * and Niels Provos.
16104476Ssam *
17104476Ssam * Additional features in 1999 by Angelos D. Keromytis.
18104476Ssam *
19247061Spjd * AES XTS implementation in 2008 by Damien Miller
20247061Spjd *
21104476Ssam * Copyright (C) 1995, 1996, 1997, 1998, 1999 by John Ioannidis,
22104476Ssam * Angelos D. Keromytis and Niels Provos.
23104476Ssam *
24104476Ssam * Copyright (C) 2001, Angelos D. Keromytis.
25104476Ssam *
26247061Spjd * Copyright (C) 2008, Damien Miller
27275732Sjmg * Copyright (c) 2014 The FreeBSD Foundation
28275732Sjmg * All rights reserved.
29247061Spjd *
30275732Sjmg * Portions of this software were developed by John-Mark Gurney
31275732Sjmg * under sponsorship of the FreeBSD Foundation and
32275732Sjmg * Rubicon Communications, LLC (Netgate).
33275732Sjmg *
34104476Ssam * Permission to use, copy, and modify this software with or without fee
35104476Ssam * is hereby granted, provided that this entire notice is included in
36104476Ssam * all copies of any software which is or includes a copy or
37104476Ssam * modification of this software.
38104476Ssam * You may use this code under the GNU public license if you so wish. Please
39104476Ssam * contribute changes back to the authors under this freer than GPL license
40104476Ssam * so that we may further the use of strong encryption without limitations to
41104476Ssam * all.
42104476Ssam *
43104476Ssam * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
44104476Ssam * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
45104476Ssam * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
46104476Ssam * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
47104476Ssam * PURPOSE.
48104476Ssam */
49104476Ssam
50116191Sobrien#include <sys/cdefs.h>
51116191Sobrien__FBSDID("$FreeBSD: releng/11.0/sys/opencrypto/xform_deflate.c 292963 2015-12-30 22:43:07Z allanjude $");
52116191Sobrien
53104476Ssam#include <opencrypto/deflate.h>
54292963Sallanjude#include <opencrypto/xform_comp.h>
55104476Ssam
56104476Ssamstatic	u_int32_t deflate_compress(u_int8_t *, u_int32_t, u_int8_t **);
57104476Ssamstatic	u_int32_t deflate_decompress(u_int8_t *, u_int32_t, u_int8_t **);
58104476Ssam
59104476Ssam/* Compression instance */
60104476Ssamstruct comp_algo comp_algo_deflate = {
61104476Ssam	CRYPTO_DEFLATE_COMP, "Deflate",
62104476Ssam	90, deflate_compress,
63104476Ssam	deflate_decompress
64104476Ssam};
65104476Ssam
66104476Ssam/*
67104476Ssam * And compression
68104476Ssam */
69104476Ssam
70104476Ssamstatic u_int32_t
71104476Ssamdeflate_compress(data, size, out)
72104476Ssam	u_int8_t *data;
73104476Ssam	u_int32_t size;
74104476Ssam	u_int8_t **out;
75104476Ssam{
76104476Ssam	return deflate_global(data, size, 0, out);
77104476Ssam}
78104476Ssam
79104476Ssamstatic u_int32_t
80104476Ssamdeflate_decompress(data, size, out)
81104476Ssam	u_int8_t *data;
82104476Ssam	u_int32_t size;
83104476Ssam	u_int8_t **out;
84104476Ssam{
85104476Ssam	return deflate_global(data, size, 1, out);
86104476Ssam}
87