cryptosoft_xform.c revision 1.15 1 /* $NetBSD: cryptosoft_xform.c,v 1.15 2011/05/05 17:44:39 drochner Exp $ */
2 /* $FreeBSD: src/sys/opencrypto/xform.c,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $ */
3 /* $OpenBSD: xform.c,v 1.19 2002/08/16 22:47:25 dhartmei Exp $ */
4
5 /*
6 * The authors of this code are John Ioannidis (ji (at) tla.org),
7 * Angelos D. Keromytis (kermit (at) csd.uch.gr) and
8 * Niels Provos (provos (at) physnet.uni-hamburg.de).
9 *
10 * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
11 * in November 1995.
12 *
13 * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
14 * by Angelos D. Keromytis.
15 *
16 * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
17 * and Niels Provos.
18 *
19 * Additional features in 1999 by Angelos D. Keromytis.
20 *
21 * Copyright (C) 1995, 1996, 1997, 1998, 1999 by John Ioannidis,
22 * Angelos D. Keromytis and Niels Provos.
23 *
24 * Copyright (C) 2001, Angelos D. Keromytis.
25 *
26 * Permission to use, copy, and modify this software with or without fee
27 * is hereby granted, provided that this entire notice is included in
28 * all copies of any software which is or includes a copy or
29 * modification of this software.
30 * You may use this code under the GNU public license if you so wish. Please
31 * contribute changes back to the authors under this freer than GPL license
32 * so that we may further the use of strong encryption without limitations to
33 * all.
34 *
35 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
36 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
37 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
38 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
39 * PURPOSE.
40 */
41
42 #include <sys/cdefs.h>
43 __KERNEL_RCSID(1, "$NetBSD: cryptosoft_xform.c,v 1.15 2011/05/05 17:44:39 drochner Exp $");
44
45 #include <crypto/blowfish/blowfish.h>
46 #include <crypto/cast128/cast128.h>
47 #include <crypto/des/des.h>
48 #include <crypto/rijndael/rijndael.h>
49 #include <crypto/skipjack/skipjack.h>
50 #include <crypto/camellia/camellia.h>
51
52 #include <opencrypto/deflate.h>
53
54 #include <sys/md5.h>
55 #include <sys/rmd160.h>
56 #include <sys/sha1.h>
57
58 struct swcr_auth_hash {
59 const struct auth_hash *auth_hash;
60 void (*Init)(void *);
61 int (*Update)(void *, const uint8_t *, uint16_t);
62 void (*Final)(uint8_t *, void *);
63 };
64
65 struct swcr_enc_xform {
66 const struct enc_xform *enc_xform;
67 void (*encrypt)(void *, uint8_t *);
68 void (*decrypt)(void *, uint8_t *);
69 int (*setkey)(uint8_t **, const uint8_t *, int len);
70 void (*zerokey)(uint8_t **);
71 };
72
73 struct swcr_comp_algo {
74 const struct comp_algo *unused_comp_algo;
75 uint32_t (*compress)(uint8_t *, uint32_t, uint8_t **);
76 uint32_t (*decompress)(uint8_t *, uint32_t, uint8_t **, int);
77 };
78
79 static void null_encrypt(void *, u_int8_t *);
80 static void null_decrypt(void *, u_int8_t *);
81 static int null_setkey(u_int8_t **, const u_int8_t *, int);
82 static void null_zerokey(u_int8_t **);
83
84 static int des1_setkey(u_int8_t **, const u_int8_t *, int);
85 static int des3_setkey(u_int8_t **, const u_int8_t *, int);
86 static int blf_setkey(u_int8_t **, const u_int8_t *, int);
87 static int cast5_setkey(u_int8_t **, const u_int8_t *, int);
88 static int skipjack_setkey(u_int8_t **, const u_int8_t *, int);
89 static int rijndael128_setkey(u_int8_t **, const u_int8_t *, int);
90 static int cml_setkey(u_int8_t **, const u_int8_t *, int);
91 static void des1_encrypt(void *, u_int8_t *);
92 static void des3_encrypt(void *, u_int8_t *);
93 static void blf_encrypt(void *, u_int8_t *);
94 static void cast5_encrypt(void *, u_int8_t *);
95 static void skipjack_encrypt(void *, u_int8_t *);
96 static void rijndael128_encrypt(void *, u_int8_t *);
97 static void cml_encrypt(void *, u_int8_t *);
98 static void des1_decrypt(void *, u_int8_t *);
99 static void des3_decrypt(void *, u_int8_t *);
100 static void blf_decrypt(void *, u_int8_t *);
101 static void cast5_decrypt(void *, u_int8_t *);
102 static void skipjack_decrypt(void *, u_int8_t *);
103 static void rijndael128_decrypt(void *, u_int8_t *);
104 static void cml_decrypt(void *, u_int8_t *);
105 static void des1_zerokey(u_int8_t **);
106 static void des3_zerokey(u_int8_t **);
107 static void blf_zerokey(u_int8_t **);
108 static void cast5_zerokey(u_int8_t **);
109 static void skipjack_zerokey(u_int8_t **);
110 static void rijndael128_zerokey(u_int8_t **);
111 static void cml_zerokey(u_int8_t **);
112
113 static void null_init(void *);
114 static int null_update(void *, const u_int8_t *, u_int16_t);
115 static void null_final(u_int8_t *, void *);
116
117 static int MD5Update_int(void *, const u_int8_t *, u_int16_t);
118 static void SHA1Init_int(void *);
119 static int SHA1Update_int(void *, const u_int8_t *, u_int16_t);
120 static void SHA1Final_int(u_int8_t *, void *);
121
122
123 static int RMD160Update_int(void *, const u_int8_t *, u_int16_t);
124 static int SHA1Update_int(void *, const u_int8_t *, u_int16_t);
125 static void SHA1Final_int(u_int8_t *, void *);
126 static int RMD160Update_int(void *, const u_int8_t *, u_int16_t);
127 static int SHA256Update_int(void *, const u_int8_t *, u_int16_t);
128 static int SHA384Update_int(void *, const u_int8_t *, u_int16_t);
129 static int SHA512Update_int(void *, const u_int8_t *, u_int16_t);
130
131 static u_int32_t deflate_compress(u_int8_t *, u_int32_t, u_int8_t **);
132 static u_int32_t deflate_decompress(u_int8_t *, u_int32_t, u_int8_t **, int);
133 static u_int32_t gzip_compress(u_int8_t *, u_int32_t, u_int8_t **);
134 static u_int32_t gzip_decompress(u_int8_t *, u_int32_t, u_int8_t **, int);
135
136 /* Encryption instances */
137 static const struct swcr_enc_xform swcr_enc_xform_null = {
138 &enc_xform_null,
139 null_encrypt,
140 null_decrypt,
141 null_setkey,
142 null_zerokey,
143 };
144
145 static const struct swcr_enc_xform swcr_enc_xform_des = {
146 &enc_xform_des,
147 des1_encrypt,
148 des1_decrypt,
149 des1_setkey,
150 des1_zerokey,
151 };
152
153 static const struct swcr_enc_xform swcr_enc_xform_3des = {
154 &enc_xform_3des,
155 des3_encrypt,
156 des3_decrypt,
157 des3_setkey,
158 des3_zerokey
159 };
160
161 static const struct swcr_enc_xform swcr_enc_xform_blf = {
162 &enc_xform_blf,
163 blf_encrypt,
164 blf_decrypt,
165 blf_setkey,
166 blf_zerokey
167 };
168
169 static const struct swcr_enc_xform swcr_enc_xform_cast5 = {
170 &enc_xform_cast5,
171 cast5_encrypt,
172 cast5_decrypt,
173 cast5_setkey,
174 cast5_zerokey
175 };
176
177 static const struct swcr_enc_xform swcr_enc_xform_skipjack = {
178 &enc_xform_skipjack,
179 skipjack_encrypt,
180 skipjack_decrypt,
181 skipjack_setkey,
182 skipjack_zerokey
183 };
184
185 static const struct swcr_enc_xform swcr_enc_xform_rijndael128 = {
186 &enc_xform_rijndael128,
187 rijndael128_encrypt,
188 rijndael128_decrypt,
189 rijndael128_setkey,
190 rijndael128_zerokey,
191 };
192
193 static const struct swcr_enc_xform swcr_enc_xform_arc4 = {
194 &enc_xform_arc4,
195 NULL,
196 NULL,
197 NULL,
198 NULL,
199 };
200
201 static const struct swcr_enc_xform swcr_enc_xform_camellia = {
202 &enc_xform_camellia,
203 cml_encrypt,
204 cml_decrypt,
205 cml_setkey,
206 cml_zerokey
207 };
208
209 /* Authentication instances */
210 static const struct swcr_auth_hash swcr_auth_hash_null = {
211 &auth_hash_null,
212 null_init, null_update, null_final
213 };
214
215 static const struct swcr_auth_hash swcr_auth_hash_hmac_md5 = {
216 &auth_hash_hmac_md5,
217 (void (*) (void *)) MD5Init, MD5Update_int,
218 (void (*) (u_int8_t *, void *)) MD5Final
219 };
220
221 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha1 = {
222 &auth_hash_hmac_sha1,
223 SHA1Init_int, SHA1Update_int, SHA1Final_int
224 };
225
226 static const struct swcr_auth_hash swcr_auth_hash_hmac_ripemd_160 = {
227 &auth_hash_hmac_ripemd_160,
228 (void (*)(void *)) RMD160Init, RMD160Update_int,
229 (void (*)(u_int8_t *, void *)) RMD160Final
230 };
231 static const struct swcr_auth_hash swcr_auth_hash_hmac_md5_96 = {
232 &auth_hash_hmac_md5_96,
233 (void (*) (void *)) MD5Init, MD5Update_int,
234 (void (*) (u_int8_t *, void *)) MD5Final
235 };
236
237 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha1_96 = {
238 &auth_hash_hmac_sha1_96,
239 SHA1Init_int, SHA1Update_int, SHA1Final_int
240 };
241
242 static const struct swcr_auth_hash swcr_auth_hash_hmac_ripemd_160_96 = {
243 &auth_hash_hmac_ripemd_160_96,
244 (void (*)(void *)) RMD160Init, RMD160Update_int,
245 (void (*)(u_int8_t *, void *)) RMD160Final
246 };
247
248 static const struct swcr_auth_hash swcr_auth_hash_key_md5 = {
249 &auth_hash_key_md5,
250 (void (*)(void *)) MD5Init, MD5Update_int,
251 (void (*)(u_int8_t *, void *)) MD5Final
252 };
253
254 static const struct swcr_auth_hash swcr_auth_hash_key_sha1 = {
255 &auth_hash_key_sha1,
256 SHA1Init_int, SHA1Update_int, SHA1Final_int
257 };
258
259 static const struct swcr_auth_hash swcr_auth_hash_md5 = {
260 &auth_hash_md5,
261 (void (*) (void *)) MD5Init, MD5Update_int,
262 (void (*) (u_int8_t *, void *)) MD5Final
263 };
264
265 static const struct swcr_auth_hash swcr_auth_hash_sha1 = {
266 &auth_hash_sha1,
267 (void (*)(void *)) SHA1Init, SHA1Update_int,
268 (void (*)(u_int8_t *, void *)) SHA1Final
269 };
270
271 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha2_256 = {
272 &auth_hash_hmac_sha2_256,
273 (void (*)(void *)) SHA256_Init, SHA256Update_int,
274 (void (*)(u_int8_t *, void *)) SHA256_Final
275 };
276
277 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha2_384 = {
278 &auth_hash_hmac_sha2_384,
279 (void (*)(void *)) SHA384_Init, SHA384Update_int,
280 (void (*)(u_int8_t *, void *)) SHA384_Final
281 };
282
283 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha2_512 = {
284 &auth_hash_hmac_sha2_384,
285 (void (*)(void *)) SHA512_Init, SHA512Update_int,
286 (void (*)(u_int8_t *, void *)) SHA512_Final
287 };
288
289 /* Compression instance */
290 static const struct swcr_comp_algo swcr_comp_algo_deflate = {
291 &comp_algo_deflate,
292 deflate_compress,
293 deflate_decompress
294 };
295
296 static const struct swcr_comp_algo swcr_comp_algo_deflate_nogrow = {
297 &comp_algo_deflate_nogrow,
298 deflate_compress,
299 deflate_decompress
300 };
301
302 static const struct swcr_comp_algo swcr_comp_algo_gzip = {
303 &comp_algo_deflate,
304 gzip_compress,
305 gzip_decompress
306 };
307
308 /*
309 * Encryption wrapper routines.
310 */
311 static void
312 null_encrypt(void *key, u_int8_t *blk)
313 {
314 }
315 static void
316 null_decrypt(void *key, u_int8_t *blk)
317 {
318 }
319 static int
320 null_setkey(u_int8_t **sched, const u_int8_t *key, int len)
321 {
322 *sched = NULL;
323 return 0;
324 }
325 static void
326 null_zerokey(u_int8_t **sched)
327 {
328 *sched = NULL;
329 }
330
331 static void
332 des1_encrypt(void *key, u_int8_t *blk)
333 {
334 des_cblock *cb = (des_cblock *) blk;
335 des_key_schedule *p = (des_key_schedule *) key;
336
337 des_ecb_encrypt(cb, cb, p[0], DES_ENCRYPT);
338 }
339
340 static void
341 des1_decrypt(void *key, u_int8_t *blk)
342 {
343 des_cblock *cb = (des_cblock *) blk;
344 des_key_schedule *p = (des_key_schedule *) key;
345
346 des_ecb_encrypt(cb, cb, p[0], DES_DECRYPT);
347 }
348
349 static int
350 des1_setkey(u_int8_t **sched, const u_int8_t *key, int len)
351 {
352 des_key_schedule *p;
353 int err;
354
355 p = malloc(sizeof (des_key_schedule),
356 M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
357 if (p != NULL) {
358 des_set_key((des_cblock *)__UNCONST(key), p[0]);
359 err = 0;
360 } else
361 err = ENOMEM;
362 *sched = (u_int8_t *) p;
363 return err;
364 }
365
366 static void
367 des1_zerokey(u_int8_t **sched)
368 {
369 memset(*sched, 0, sizeof (des_key_schedule));
370 free(*sched, M_CRYPTO_DATA);
371 *sched = NULL;
372 }
373
374 static void
375 des3_encrypt(void *key, u_int8_t *blk)
376 {
377 des_cblock *cb = (des_cblock *) blk;
378 des_key_schedule *p = (des_key_schedule *) key;
379
380 des_ecb3_encrypt(cb, cb, p[0], p[1], p[2], DES_ENCRYPT);
381 }
382
383 static void
384 des3_decrypt(void *key, u_int8_t *blk)
385 {
386 des_cblock *cb = (des_cblock *) blk;
387 des_key_schedule *p = (des_key_schedule *) key;
388
389 des_ecb3_encrypt(cb, cb, p[0], p[1], p[2], DES_DECRYPT);
390 }
391
392 static int
393 des3_setkey(u_int8_t **sched, const u_int8_t *key, int len)
394 {
395 des_key_schedule *p;
396 int err;
397
398 p = malloc(3*sizeof (des_key_schedule),
399 M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
400 if (p != NULL) {
401 des_set_key((des_cblock *)__UNCONST(key + 0), p[0]);
402 des_set_key((des_cblock *)__UNCONST(key + 8), p[1]);
403 des_set_key((des_cblock *)__UNCONST(key + 16), p[2]);
404 err = 0;
405 } else
406 err = ENOMEM;
407 *sched = (u_int8_t *) p;
408 return err;
409 }
410
411 static void
412 des3_zerokey(u_int8_t **sched)
413 {
414 memset(*sched, 0, 3*sizeof (des_key_schedule));
415 free(*sched, M_CRYPTO_DATA);
416 *sched = NULL;
417 }
418
419 static void
420 blf_encrypt(void *key, u_int8_t *blk)
421 {
422
423 BF_ecb_encrypt(blk, blk, (BF_KEY *)key, 1);
424 }
425
426 static void
427 blf_decrypt(void *key, u_int8_t *blk)
428 {
429
430 BF_ecb_encrypt(blk, blk, (BF_KEY *)key, 0);
431 }
432
433 static int
434 blf_setkey(u_int8_t **sched, const u_int8_t *key, int len)
435 {
436 int err;
437
438 *sched = malloc(sizeof(BF_KEY),
439 M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
440 if (*sched != NULL) {
441 BF_set_key((BF_KEY *) *sched, len, key);
442 err = 0;
443 } else
444 err = ENOMEM;
445 return err;
446 }
447
448 static void
449 blf_zerokey(u_int8_t **sched)
450 {
451 memset(*sched, 0, sizeof(BF_KEY));
452 free(*sched, M_CRYPTO_DATA);
453 *sched = NULL;
454 }
455
456 static void
457 cast5_encrypt(void *key, u_int8_t *blk)
458 {
459 cast128_encrypt((cast128_key *) key, blk, blk);
460 }
461
462 static void
463 cast5_decrypt(void *key, u_int8_t *blk)
464 {
465 cast128_decrypt((cast128_key *) key, blk, blk);
466 }
467
468 static int
469 cast5_setkey(u_int8_t **sched, const u_int8_t *key, int len)
470 {
471 int err;
472
473 *sched = malloc(sizeof(cast128_key), M_CRYPTO_DATA,
474 M_NOWAIT|M_ZERO);
475 if (*sched != NULL) {
476 cast128_setkey((cast128_key *)*sched, key, len);
477 err = 0;
478 } else
479 err = ENOMEM;
480 return err;
481 }
482
483 static void
484 cast5_zerokey(u_int8_t **sched)
485 {
486 memset(*sched, 0, sizeof(cast128_key));
487 free(*sched, M_CRYPTO_DATA);
488 *sched = NULL;
489 }
490
491 static void
492 skipjack_encrypt(void *key, u_int8_t *blk)
493 {
494 skipjack_forwards(blk, blk, (u_int8_t **) key);
495 }
496
497 static void
498 skipjack_decrypt(void *key, u_int8_t *blk)
499 {
500 skipjack_backwards(blk, blk, (u_int8_t **) key);
501 }
502
503 static int
504 skipjack_setkey(u_int8_t **sched, const u_int8_t *key, int len)
505 {
506 int err;
507
508 /* NB: allocate all the memory that's needed at once */
509 /* XXX assumes bytes are aligned on sizeof(u_char) == 1 boundaries.
510 * Will this break a pdp-10, Cray-1, or GE-645 port?
511 */
512 *sched = malloc(10 * (sizeof(u_int8_t *) + 0x100),
513 M_CRYPTO_DATA, M_NOWAIT|M_ZERO);
514
515 if (*sched != NULL) {
516
517 u_int8_t** key_tables = (u_int8_t**) *sched;
518 u_int8_t* table = (u_int8_t*) &key_tables[10];
519 int k;
520
521 for (k = 0; k < 10; k++) {
522 key_tables[k] = table;
523 table += 0x100;
524 }
525 subkey_table_gen(key, (u_int8_t **) *sched);
526 err = 0;
527 } else
528 err = ENOMEM;
529 return err;
530 }
531
532 static void
533 skipjack_zerokey(u_int8_t **sched)
534 {
535 memset(*sched, 0, 10 * (sizeof(u_int8_t *) + 0x100));
536 free(*sched, M_CRYPTO_DATA);
537 *sched = NULL;
538 }
539
540 static void
541 rijndael128_encrypt(void *key, u_int8_t *blk)
542 {
543 rijndael_encrypt((rijndael_ctx *) key, (u_char *) blk, (u_char *) blk);
544 }
545
546 static void
547 rijndael128_decrypt(void *key, u_int8_t *blk)
548 {
549 rijndael_decrypt((rijndael_ctx *) key, (u_char *) blk,
550 (u_char *) blk);
551 }
552
553 static int
554 rijndael128_setkey(u_int8_t **sched, const u_int8_t *key, int len)
555 {
556 int err;
557
558 *sched = malloc(sizeof(rijndael_ctx), M_CRYPTO_DATA,
559 M_NOWAIT|M_ZERO);
560 if (*sched != NULL) {
561 rijndael_set_key((rijndael_ctx *) *sched, key, len * 8);
562 err = 0;
563 } else
564 err = ENOMEM;
565 return err;
566 }
567
568 static void
569 rijndael128_zerokey(u_int8_t **sched)
570 {
571 memset(*sched, 0, sizeof(rijndael_ctx));
572 free(*sched, M_CRYPTO_DATA);
573 *sched = NULL;
574 }
575
576 static void
577 cml_encrypt(void *key, u_int8_t *blk)
578 {
579
580 camellia_encrypt(key, blk, blk);
581 }
582
583 static void
584 cml_decrypt(void *key, u_int8_t *blk)
585 {
586
587 camellia_decrypt(key, blk, blk);
588 }
589
590 static int
591 cml_setkey(u_int8_t **sched, const u_int8_t *key, int len)
592 {
593 int err;
594
595 if (len != 16 && len != 24 && len != 32)
596 return (EINVAL);
597 *sched = malloc(sizeof(camellia_ctx), M_CRYPTO_DATA,
598 M_NOWAIT|M_ZERO);
599 if (*sched != NULL) {
600 camellia_set_key((camellia_ctx *) *sched, key, len * 8);
601 err = 0;
602 } else
603 err = ENOMEM;
604 return err;
605 }
606
607 static void
608 cml_zerokey(u_int8_t **sched)
609 {
610
611 memset(*sched, 0, sizeof(camellia_ctx));
612 free(*sched, M_CRYPTO_DATA);
613 *sched = NULL;
614 }
615
616 /*
617 * And now for auth.
618 */
619
620 static void
621 null_init(void *ctx)
622 {
623 }
624
625 static int
626 null_update(void *ctx, const u_int8_t *buf,
627 u_int16_t len)
628 {
629 return 0;
630 }
631
632 static void
633 null_final(u_int8_t *buf, void *ctx)
634 {
635 if (buf != (u_int8_t *) 0)
636 memset(buf, 0, 12);
637 }
638
639 static int
640 RMD160Update_int(void *ctx, const u_int8_t *buf, u_int16_t len)
641 {
642 RMD160Update(ctx, buf, len);
643 return 0;
644 }
645
646 static int
647 MD5Update_int(void *ctx, const u_int8_t *buf, u_int16_t len)
648 {
649 MD5Update(ctx, buf, len);
650 return 0;
651 }
652
653 static void
654 SHA1Init_int(void *ctx)
655 {
656 SHA1Init(ctx);
657 }
658
659 static int
660 SHA1Update_int(void *ctx, const u_int8_t *buf, u_int16_t len)
661 {
662 SHA1Update(ctx, buf, len);
663 return 0;
664 }
665
666 static void
667 SHA1Final_int(u_int8_t *blk, void *ctx)
668 {
669 SHA1Final(blk, ctx);
670 }
671
672 static int
673 SHA256Update_int(void *ctx, const u_int8_t *buf, u_int16_t len)
674 {
675 SHA256_Update(ctx, buf, len);
676 return 0;
677 }
678
679 static int
680 SHA384Update_int(void *ctx, const u_int8_t *buf, u_int16_t len)
681 {
682 SHA384_Update(ctx, buf, len);
683 return 0;
684 }
685
686 static int
687 SHA512Update_int(void *ctx, const u_int8_t *buf, u_int16_t len)
688 {
689 SHA512_Update(ctx, buf, len);
690 return 0;
691 }
692
693 /*
694 * And compression
695 */
696
697 static u_int32_t
698 deflate_compress(u_int8_t *data, u_int32_t size, u_int8_t **out)
699 {
700 return deflate_global(data, size, 0, out, 0);
701 }
702
703 static u_int32_t
704 deflate_decompress(u_int8_t *data, u_int32_t size, u_int8_t **out,
705 int size_hint)
706 {
707 return deflate_global(data, size, 1, out, size_hint);
708 }
709
710 static u_int32_t
711 gzip_compress(u_int8_t *data, u_int32_t size, u_int8_t **out)
712 {
713 return gzip_global(data, size, 0, out, 0);
714 }
715
716 static u_int32_t
717 gzip_decompress(u_int8_t *data, u_int32_t size, u_int8_t **out,
718 int size_hint)
719 {
720 return gzip_global(data, size, 1, out, size_hint);
721 }
722