xref: /openbmc/linux/drivers/crypto/cavium/zip/zip_crypto.h (revision a976c2951d8f376112361830aa7762beff83a205)
1640035a2SMahipal Challa /***********************license start************************************
2640035a2SMahipal Challa  * Copyright (c) 2003-2017 Cavium, Inc.
3640035a2SMahipal Challa  * All rights reserved.
4640035a2SMahipal Challa  *
5640035a2SMahipal Challa  * License: one of 'Cavium License' or 'GNU General Public License Version 2'
6640035a2SMahipal Challa  *
7640035a2SMahipal Challa  * This file is provided under the terms of the Cavium License (see below)
8640035a2SMahipal Challa  * or under the terms of GNU General Public License, Version 2, as
9640035a2SMahipal Challa  * published by the Free Software Foundation. When using or redistributing
10640035a2SMahipal Challa  * this file, you may do so under either license.
11640035a2SMahipal Challa  *
12640035a2SMahipal Challa  * Cavium License:  Redistribution and use in source and binary forms, with
13640035a2SMahipal Challa  * or without modification, are permitted provided that the following
14640035a2SMahipal Challa  * conditions are met:
15640035a2SMahipal Challa  *
16640035a2SMahipal Challa  *  * Redistributions of source code must retain the above copyright
17640035a2SMahipal Challa  *    notice, this list of conditions and the following disclaimer.
18640035a2SMahipal Challa  *
19640035a2SMahipal Challa  *  * Redistributions in binary form must reproduce the above
20640035a2SMahipal Challa  *    copyright notice, this list of conditions and the following
21640035a2SMahipal Challa  *    disclaimer in the documentation and/or other materials provided
22640035a2SMahipal Challa  *    with the distribution.
23640035a2SMahipal Challa  *
24640035a2SMahipal Challa  *  * Neither the name of Cavium Inc. nor the names of its contributors may be
25640035a2SMahipal Challa  *    used to endorse or promote products derived from this software without
26640035a2SMahipal Challa  *    specific prior written permission.
27640035a2SMahipal Challa  *
28640035a2SMahipal Challa  * This Software, including technical data, may be subject to U.S. export
29640035a2SMahipal Challa  * control laws, including the U.S. Export Administration Act and its
30640035a2SMahipal Challa  * associated regulations, and may be subject to export or import
31640035a2SMahipal Challa  * regulations in other countries.
32640035a2SMahipal Challa  *
33640035a2SMahipal Challa  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
34640035a2SMahipal Challa  * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS
35640035a2SMahipal Challa  * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
36640035a2SMahipal Challa  * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
37640035a2SMahipal Challa  * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
38640035a2SMahipal Challa  * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY)
39640035a2SMahipal Challa  * WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A
40640035a2SMahipal Challa  * PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET
41640035a2SMahipal Challa  * ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE
42640035a2SMahipal Challa  * ENTIRE  RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES
43640035a2SMahipal Challa  * WITH YOU.
44640035a2SMahipal Challa  ***********************license end**************************************/
45640035a2SMahipal Challa 
46640035a2SMahipal Challa #ifndef __ZIP_CRYPTO_H__
47640035a2SMahipal Challa #define __ZIP_CRYPTO_H__
48640035a2SMahipal Challa 
49640035a2SMahipal Challa #include <linux/crypto.h>
50640035a2SMahipal Challa #include <crypto/internal/scompress.h>
51640035a2SMahipal Challa #include "common.h"
52*f05845fcSMahipal Challa #include "zip_deflate.h"
53*f05845fcSMahipal Challa #include "zip_inflate.h"
54640035a2SMahipal Challa 
55640035a2SMahipal Challa struct zip_kernel_ctx {
56640035a2SMahipal Challa 	struct zip_operation zip_comp;
57640035a2SMahipal Challa 	struct zip_operation zip_decomp;
58640035a2SMahipal Challa };
59640035a2SMahipal Challa 
60640035a2SMahipal Challa int  zip_alloc_comp_ctx_deflate(struct crypto_tfm *tfm);
61640035a2SMahipal Challa int  zip_alloc_comp_ctx_lzs(struct crypto_tfm *tfm);
62640035a2SMahipal Challa void zip_free_comp_ctx(struct crypto_tfm *tfm);
63640035a2SMahipal Challa int  zip_comp_compress(struct crypto_tfm *tfm,
64640035a2SMahipal Challa 		       const u8 *src, unsigned int slen,
65640035a2SMahipal Challa 		       u8 *dst, unsigned int *dlen);
66640035a2SMahipal Challa int  zip_comp_decompress(struct crypto_tfm *tfm,
67640035a2SMahipal Challa 			 const u8 *src, unsigned int slen,
68640035a2SMahipal Challa 			 u8 *dst, unsigned int *dlen);
69640035a2SMahipal Challa 
70640035a2SMahipal Challa void *zip_alloc_scomp_ctx_deflate(struct crypto_scomp *tfm);
71640035a2SMahipal Challa void *zip_alloc_scomp_ctx_lzs(struct crypto_scomp *tfm);
72640035a2SMahipal Challa void  zip_free_scomp_ctx(struct crypto_scomp *tfm, void *zip_ctx);
73640035a2SMahipal Challa int   zip_scomp_compress(struct crypto_scomp *tfm,
74640035a2SMahipal Challa 			 const u8 *src, unsigned int slen,
75640035a2SMahipal Challa 			 u8 *dst, unsigned int *dlen, void *ctx);
76640035a2SMahipal Challa int   zip_scomp_decompress(struct crypto_scomp *tfm,
77640035a2SMahipal Challa 			   const u8 *src, unsigned int slen,
78640035a2SMahipal Challa 			   u8 *dst, unsigned int *dlen, void *ctx);
79640035a2SMahipal Challa #endif
80