~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/crypto/internal/scompress.h

Version: ~ [ linux-5.6-rc1 ] ~ [ linux-5.5.2 ] ~ [ linux-5.4.17 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.102 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.170 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.213 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.213 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Synchronous Compression operations
  3  *
  4  * Copyright 2015 LG Electronics Inc.
  5  * Copyright (c) 2016, Intel Corporation
  6  * Author: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
  7  *
  8  * This program is free software; you can redistribute it and/or modify it
  9  * under the terms of the GNU General Public License as published by the Free
 10  * Software Foundation; either version 2 of the License, or (at your option)
 11  * any later version.
 12  *
 13  */
 14 #ifndef _CRYPTO_SCOMP_INT_H
 15 #define _CRYPTO_SCOMP_INT_H
 16 #include <linux/crypto.h>
 17 
 18 #define SCOMP_SCRATCH_SIZE      131072
 19 
 20 struct crypto_scomp {
 21         struct crypto_tfm base;
 22 };
 23 
 24 /**
 25  * struct scomp_alg - synchronous compression algorithm
 26  *
 27  * @alloc_ctx:  Function allocates algorithm specific context
 28  * @free_ctx:   Function frees context allocated with alloc_ctx
 29  * @compress:   Function performs a compress operation
 30  * @decompress: Function performs a de-compress operation
 31  * @base:       Common crypto API algorithm data structure
 32  */
 33 struct scomp_alg {
 34         void *(*alloc_ctx)(struct crypto_scomp *tfm);
 35         void (*free_ctx)(struct crypto_scomp *tfm, void *ctx);
 36         int (*compress)(struct crypto_scomp *tfm, const u8 *src,
 37                         unsigned int slen, u8 *dst, unsigned int *dlen,
 38                         void *ctx);
 39         int (*decompress)(struct crypto_scomp *tfm, const u8 *src,
 40                           unsigned int slen, u8 *dst, unsigned int *dlen,
 41                           void *ctx);
 42         struct crypto_alg base;
 43 };
 44 
 45 static inline struct scomp_alg *__crypto_scomp_alg(struct crypto_alg *alg)
 46 {
 47         return container_of(alg, struct scomp_alg, base);
 48 }
 49 
 50 static inline struct crypto_scomp *__crypto_scomp_tfm(struct crypto_tfm *tfm)
 51 {
 52         return container_of(tfm, struct crypto_scomp, base);
 53 }
 54 
 55 static inline struct crypto_tfm *crypto_scomp_tfm(struct crypto_scomp *tfm)
 56 {
 57         return &tfm->base;
 58 }
 59 
 60 static inline void crypto_free_scomp(struct crypto_scomp *tfm)
 61 {
 62         crypto_destroy_tfm(tfm, crypto_scomp_tfm(tfm));
 63 }
 64 
 65 static inline struct scomp_alg *crypto_scomp_alg(struct crypto_scomp *tfm)
 66 {
 67         return __crypto_scomp_alg(crypto_scomp_tfm(tfm)->__crt_alg);
 68 }
 69 
 70 static inline void *crypto_scomp_alloc_ctx(struct crypto_scomp *tfm)
 71 {
 72         return crypto_scomp_alg(tfm)->alloc_ctx(tfm);
 73 }
 74 
 75 static inline void crypto_scomp_free_ctx(struct crypto_scomp *tfm,
 76                                          void *ctx)
 77 {
 78         return crypto_scomp_alg(tfm)->free_ctx(tfm, ctx);
 79 }
 80 
 81 static inline int crypto_scomp_compress(struct crypto_scomp *tfm,
 82                                         const u8 *src, unsigned int slen,
 83                                         u8 *dst, unsigned int *dlen, void *ctx)
 84 {
 85         return crypto_scomp_alg(tfm)->compress(tfm, src, slen, dst, dlen, ctx);
 86 }
 87 
 88 static inline int crypto_scomp_decompress(struct crypto_scomp *tfm,
 89                                           const u8 *src, unsigned int slen,
 90                                           u8 *dst, unsigned int *dlen,
 91                                           void *ctx)
 92 {
 93         return crypto_scomp_alg(tfm)->decompress(tfm, src, slen, dst, dlen,
 94                                                  ctx);
 95 }
 96 
 97 int crypto_init_scomp_ops_async(struct crypto_tfm *tfm);
 98 struct acomp_req *crypto_acomp_scomp_alloc_ctx(struct acomp_req *req);
 99 void crypto_acomp_scomp_free_ctx(struct acomp_req *req);
100 
101 /**
102  * crypto_register_scomp() -- Register synchronous compression algorithm
103  *
104  * Function registers an implementation of a synchronous
105  * compression algorithm
106  *
107  * @alg:        algorithm definition
108  *
109  * Return: zero on success; error code in case of error
110  */
111 int crypto_register_scomp(struct scomp_alg *alg);
112 
113 /**
114  * crypto_unregister_scomp() -- Unregister synchronous compression algorithm
115  *
116  * Function unregisters an implementation of a synchronous
117  * compression algorithm
118  *
119  * @alg:        algorithm definition
120  *
121  * Return: zero on success; error code in case of error
122  */
123 int crypto_unregister_scomp(struct scomp_alg *alg);
124 
125 int crypto_register_scomps(struct scomp_alg *algs, int count);
126 void crypto_unregister_scomps(struct scomp_alg *algs, int count);
127 
128 #endif
129 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp