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

TOMOYO Linux Cross Reference
Linux/crypto/lzo-rle.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /crypto/lzo-rle.c (Version linux-6.12-rc7) and /crypto/lzo-rle.c (Version linux-6.1.116)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*                                                  2 /*
  3  * Cryptographic API.                               3  * Cryptographic API.
  4  */                                                 4  */
  5                                                     5 
  6 #include <linux/init.h>                             6 #include <linux/init.h>
  7 #include <linux/module.h>                           7 #include <linux/module.h>
  8 #include <linux/crypto.h>                           8 #include <linux/crypto.h>
  9 #include <linux/vmalloc.h>                          9 #include <linux/vmalloc.h>
 10 #include <linux/mm.h>                              10 #include <linux/mm.h>
 11 #include <linux/lzo.h>                             11 #include <linux/lzo.h>
 12 #include <crypto/internal/scompress.h>             12 #include <crypto/internal/scompress.h>
 13                                                    13 
 14 struct lzorle_ctx {                                14 struct lzorle_ctx {
 15         void *lzorle_comp_mem;                     15         void *lzorle_comp_mem;
 16 };                                                 16 };
 17                                                    17 
 18 static void *lzorle_alloc_ctx(struct crypto_sc     18 static void *lzorle_alloc_ctx(struct crypto_scomp *tfm)
 19 {                                                  19 {
 20         void *ctx;                                 20         void *ctx;
 21                                                    21 
 22         ctx = kvmalloc(LZO1X_MEM_COMPRESS, GFP     22         ctx = kvmalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
 23         if (!ctx)                                  23         if (!ctx)
 24                 return ERR_PTR(-ENOMEM);           24                 return ERR_PTR(-ENOMEM);
 25                                                    25 
 26         return ctx;                                26         return ctx;
 27 }                                                  27 }
 28                                                    28 
 29 static int lzorle_init(struct crypto_tfm *tfm)     29 static int lzorle_init(struct crypto_tfm *tfm)
 30 {                                                  30 {
 31         struct lzorle_ctx *ctx = crypto_tfm_ct     31         struct lzorle_ctx *ctx = crypto_tfm_ctx(tfm);
 32                                                    32 
 33         ctx->lzorle_comp_mem = lzorle_alloc_ct     33         ctx->lzorle_comp_mem = lzorle_alloc_ctx(NULL);
 34         if (IS_ERR(ctx->lzorle_comp_mem))          34         if (IS_ERR(ctx->lzorle_comp_mem))
 35                 return -ENOMEM;                    35                 return -ENOMEM;
 36                                                    36 
 37         return 0;                                  37         return 0;
 38 }                                                  38 }
 39                                                    39 
 40 static void lzorle_free_ctx(struct crypto_scom     40 static void lzorle_free_ctx(struct crypto_scomp *tfm, void *ctx)
 41 {                                                  41 {
 42         kvfree(ctx);                               42         kvfree(ctx);
 43 }                                                  43 }
 44                                                    44 
 45 static void lzorle_exit(struct crypto_tfm *tfm     45 static void lzorle_exit(struct crypto_tfm *tfm)
 46 {                                                  46 {
 47         struct lzorle_ctx *ctx = crypto_tfm_ct     47         struct lzorle_ctx *ctx = crypto_tfm_ctx(tfm);
 48                                                    48 
 49         lzorle_free_ctx(NULL, ctx->lzorle_comp     49         lzorle_free_ctx(NULL, ctx->lzorle_comp_mem);
 50 }                                                  50 }
 51                                                    51 
 52 static int __lzorle_compress(const u8 *src, un     52 static int __lzorle_compress(const u8 *src, unsigned int slen,
 53                           u8 *dst, unsigned in     53                           u8 *dst, unsigned int *dlen, void *ctx)
 54 {                                                  54 {
 55         size_t tmp_len = *dlen; /* size_t(ulon     55         size_t tmp_len = *dlen; /* size_t(ulong) <-> uint on 64 bit */
 56         int err;                                   56         int err;
 57                                                    57 
 58         err = lzorle1x_1_compress(src, slen, d     58         err = lzorle1x_1_compress(src, slen, dst, &tmp_len, ctx);
 59                                                    59 
 60         if (err != LZO_E_OK)                       60         if (err != LZO_E_OK)
 61                 return -EINVAL;                    61                 return -EINVAL;
 62                                                    62 
 63         *dlen = tmp_len;                           63         *dlen = tmp_len;
 64         return 0;                                  64         return 0;
 65 }                                                  65 }
 66                                                    66 
 67 static int lzorle_compress(struct crypto_tfm *     67 static int lzorle_compress(struct crypto_tfm *tfm, const u8 *src,
 68                         unsigned int slen, u8      68                         unsigned int slen, u8 *dst, unsigned int *dlen)
 69 {                                                  69 {
 70         struct lzorle_ctx *ctx = crypto_tfm_ct     70         struct lzorle_ctx *ctx = crypto_tfm_ctx(tfm);
 71                                                    71 
 72         return __lzorle_compress(src, slen, ds     72         return __lzorle_compress(src, slen, dst, dlen, ctx->lzorle_comp_mem);
 73 }                                                  73 }
 74                                                    74 
 75 static int lzorle_scompress(struct crypto_scom     75 static int lzorle_scompress(struct crypto_scomp *tfm, const u8 *src,
 76                          unsigned int slen, u8     76                          unsigned int slen, u8 *dst, unsigned int *dlen,
 77                          void *ctx)                77                          void *ctx)
 78 {                                                  78 {
 79         return __lzorle_compress(src, slen, ds     79         return __lzorle_compress(src, slen, dst, dlen, ctx);
 80 }                                                  80 }
 81                                                    81 
 82 static int __lzorle_decompress(const u8 *src,      82 static int __lzorle_decompress(const u8 *src, unsigned int slen,
 83                             u8 *dst, unsigned      83                             u8 *dst, unsigned int *dlen)
 84 {                                                  84 {
 85         int err;                                   85         int err;
 86         size_t tmp_len = *dlen; /* size_t(ulon     86         size_t tmp_len = *dlen; /* size_t(ulong) <-> uint on 64 bit */
 87                                                    87 
 88         err = lzo1x_decompress_safe(src, slen,     88         err = lzo1x_decompress_safe(src, slen, dst, &tmp_len);
 89                                                    89 
 90         if (err != LZO_E_OK)                       90         if (err != LZO_E_OK)
 91                 return -EINVAL;                    91                 return -EINVAL;
 92                                                    92 
 93         *dlen = tmp_len;                           93         *dlen = tmp_len;
 94         return 0;                                  94         return 0;
 95 }                                                  95 }
 96                                                    96 
 97 static int lzorle_decompress(struct crypto_tfm     97 static int lzorle_decompress(struct crypto_tfm *tfm, const u8 *src,
 98                           unsigned int slen, u     98                           unsigned int slen, u8 *dst, unsigned int *dlen)
 99 {                                                  99 {
100         return __lzorle_decompress(src, slen,     100         return __lzorle_decompress(src, slen, dst, dlen);
101 }                                                 101 }
102                                                   102 
103 static int lzorle_sdecompress(struct crypto_sc    103 static int lzorle_sdecompress(struct crypto_scomp *tfm, const u8 *src,
104                            unsigned int slen,     104                            unsigned int slen, u8 *dst, unsigned int *dlen,
105                            void *ctx)             105                            void *ctx)
106 {                                                 106 {
107         return __lzorle_decompress(src, slen,     107         return __lzorle_decompress(src, slen, dst, dlen);
108 }                                                 108 }
109                                                   109 
110 static struct crypto_alg alg = {                  110 static struct crypto_alg alg = {
111         .cra_name               = "lzo-rle",      111         .cra_name               = "lzo-rle",
112         .cra_driver_name        = "lzo-rle-gen    112         .cra_driver_name        = "lzo-rle-generic",
113         .cra_flags              = CRYPTO_ALG_T    113         .cra_flags              = CRYPTO_ALG_TYPE_COMPRESS,
114         .cra_ctxsize            = sizeof(struc    114         .cra_ctxsize            = sizeof(struct lzorle_ctx),
115         .cra_module             = THIS_MODULE,    115         .cra_module             = THIS_MODULE,
116         .cra_init               = lzorle_init,    116         .cra_init               = lzorle_init,
117         .cra_exit               = lzorle_exit,    117         .cra_exit               = lzorle_exit,
118         .cra_u                  = { .compress     118         .cra_u                  = { .compress = {
119         .coa_compress           = lzorle_compr    119         .coa_compress           = lzorle_compress,
120         .coa_decompress         = lzorle_decom    120         .coa_decompress         = lzorle_decompress } }
121 };                                                121 };
122                                                   122 
123 static struct scomp_alg scomp = {                 123 static struct scomp_alg scomp = {
124         .alloc_ctx              = lzorle_alloc    124         .alloc_ctx              = lzorle_alloc_ctx,
125         .free_ctx               = lzorle_free_    125         .free_ctx               = lzorle_free_ctx,
126         .compress               = lzorle_scomp    126         .compress               = lzorle_scompress,
127         .decompress             = lzorle_sdeco    127         .decompress             = lzorle_sdecompress,
128         .base                   = {               128         .base                   = {
129                 .cra_name       = "lzo-rle",      129                 .cra_name       = "lzo-rle",
130                 .cra_driver_name = "lzo-rle-sc    130                 .cra_driver_name = "lzo-rle-scomp",
131                 .cra_module      = THIS_MODULE    131                 .cra_module      = THIS_MODULE,
132         }                                         132         }
133 };                                                133 };
134                                                   134 
135 static int __init lzorle_mod_init(void)           135 static int __init lzorle_mod_init(void)
136 {                                                 136 {
137         int ret;                                  137         int ret;
138                                                   138 
139         ret = crypto_register_alg(&alg);          139         ret = crypto_register_alg(&alg);
140         if (ret)                                  140         if (ret)
141                 return ret;                       141                 return ret;
142                                                   142 
143         ret = crypto_register_scomp(&scomp);      143         ret = crypto_register_scomp(&scomp);
144         if (ret) {                                144         if (ret) {
145                 crypto_unregister_alg(&alg);      145                 crypto_unregister_alg(&alg);
146                 return ret;                       146                 return ret;
147         }                                         147         }
148                                                   148 
149         return ret;                               149         return ret;
150 }                                                 150 }
151                                                   151 
152 static void __exit lzorle_mod_fini(void)          152 static void __exit lzorle_mod_fini(void)
153 {                                                 153 {
154         crypto_unregister_alg(&alg);              154         crypto_unregister_alg(&alg);
155         crypto_unregister_scomp(&scomp);          155         crypto_unregister_scomp(&scomp);
156 }                                                 156 }
157                                                   157 
158 subsys_initcall(lzorle_mod_init);                 158 subsys_initcall(lzorle_mod_init);
159 module_exit(lzorle_mod_fini);                     159 module_exit(lzorle_mod_fini);
160                                                   160 
161 MODULE_LICENSE("GPL");                            161 MODULE_LICENSE("GPL");
162 MODULE_DESCRIPTION("LZO-RLE Compression Algori    162 MODULE_DESCRIPTION("LZO-RLE Compression Algorithm");
163 MODULE_ALIAS_CRYPTO("lzo-rle");                   163 MODULE_ALIAS_CRYPTO("lzo-rle");
164                                                   164 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php