0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _CRYPTO_SCOMP_INT_H
0010 #define _CRYPTO_SCOMP_INT_H
0011 #include <linux/crypto.h>
0012
0013 #define SCOMP_SCRATCH_SIZE 131072
0014
0015 struct crypto_scomp {
0016 struct crypto_tfm base;
0017 };
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 struct scomp_alg {
0029 void *(*alloc_ctx)(struct crypto_scomp *tfm);
0030 void (*free_ctx)(struct crypto_scomp *tfm, void *ctx);
0031 int (*compress)(struct crypto_scomp *tfm, const u8 *src,
0032 unsigned int slen, u8 *dst, unsigned int *dlen,
0033 void *ctx);
0034 int (*decompress)(struct crypto_scomp *tfm, const u8 *src,
0035 unsigned int slen, u8 *dst, unsigned int *dlen,
0036 void *ctx);
0037 struct crypto_alg base;
0038 };
0039
0040 static inline struct scomp_alg *__crypto_scomp_alg(struct crypto_alg *alg)
0041 {
0042 return container_of(alg, struct scomp_alg, base);
0043 }
0044
0045 static inline struct crypto_scomp *__crypto_scomp_tfm(struct crypto_tfm *tfm)
0046 {
0047 return container_of(tfm, struct crypto_scomp, base);
0048 }
0049
0050 static inline struct crypto_tfm *crypto_scomp_tfm(struct crypto_scomp *tfm)
0051 {
0052 return &tfm->base;
0053 }
0054
0055 static inline void crypto_free_scomp(struct crypto_scomp *tfm)
0056 {
0057 crypto_destroy_tfm(tfm, crypto_scomp_tfm(tfm));
0058 }
0059
0060 static inline struct scomp_alg *crypto_scomp_alg(struct crypto_scomp *tfm)
0061 {
0062 return __crypto_scomp_alg(crypto_scomp_tfm(tfm)->__crt_alg);
0063 }
0064
0065 static inline void *crypto_scomp_alloc_ctx(struct crypto_scomp *tfm)
0066 {
0067 return crypto_scomp_alg(tfm)->alloc_ctx(tfm);
0068 }
0069
0070 static inline void crypto_scomp_free_ctx(struct crypto_scomp *tfm,
0071 void *ctx)
0072 {
0073 return crypto_scomp_alg(tfm)->free_ctx(tfm, ctx);
0074 }
0075
0076 static inline int crypto_scomp_compress(struct crypto_scomp *tfm,
0077 const u8 *src, unsigned int slen,
0078 u8 *dst, unsigned int *dlen, void *ctx)
0079 {
0080 return crypto_scomp_alg(tfm)->compress(tfm, src, slen, dst, dlen, ctx);
0081 }
0082
0083 static inline int crypto_scomp_decompress(struct crypto_scomp *tfm,
0084 const u8 *src, unsigned int slen,
0085 u8 *dst, unsigned int *dlen,
0086 void *ctx)
0087 {
0088 return crypto_scomp_alg(tfm)->decompress(tfm, src, slen, dst, dlen,
0089 ctx);
0090 }
0091
0092 int crypto_init_scomp_ops_async(struct crypto_tfm *tfm);
0093 struct acomp_req *crypto_acomp_scomp_alloc_ctx(struct acomp_req *req);
0094 void crypto_acomp_scomp_free_ctx(struct acomp_req *req);
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 int crypto_register_scomp(struct scomp_alg *alg);
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 void crypto_unregister_scomp(struct scomp_alg *alg);
0117
0118 int crypto_register_scomps(struct scomp_alg *algs, int count);
0119 void crypto_unregister_scomps(struct scomp_alg *algs, int count);
0120
0121 #endif