11cc6582eSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
22b49b906SJohannes Goetzfried /* Kernel cryptographic api.
32b49b906SJohannes Goetzfried * cast6.c - Cast6 cipher algorithm [rfc2612].
42b49b906SJohannes Goetzfried *
52b49b906SJohannes Goetzfried * CAST-256 (*cast6*) is a DES like Substitution-Permutation Network (SPN)
62b49b906SJohannes Goetzfried * cryptosystem built upon the CAST-128 (*cast5*) [rfc2144] encryption
72b49b906SJohannes Goetzfried * algorithm.
82b49b906SJohannes Goetzfried *
92b49b906SJohannes Goetzfried * Copyright (C) 2003 Kartikey Mahendra Bhatt <kartik_me@hotmail.com>.
102b49b906SJohannes Goetzfried */
112b49b906SJohannes Goetzfried
122b49b906SJohannes Goetzfried
1380879dd9SArd Biesheuvel #include <asm/unaligned.h>
14*14386d47SHerbert Xu #include <crypto/algapi.h>
152b49b906SJohannes Goetzfried #include <linux/init.h>
162b49b906SJohannes Goetzfried #include <linux/module.h>
172b49b906SJohannes Goetzfried #include <linux/errno.h>
182b49b906SJohannes Goetzfried #include <linux/string.h>
192b49b906SJohannes Goetzfried #include <linux/types.h>
202b49b906SJohannes Goetzfried #include <crypto/cast6.h>
212b49b906SJohannes Goetzfried
22044ab525SJussi Kivilinna #define s1 cast_s1
23044ab525SJussi Kivilinna #define s2 cast_s2
24044ab525SJussi Kivilinna #define s3 cast_s3
25044ab525SJussi Kivilinna #define s4 cast_s4
262b49b906SJohannes Goetzfried
272b49b906SJohannes Goetzfried #define F1(D, r, m) ((I = ((m) + (D))), (I = rol32(I, (r))), \
282b49b906SJohannes Goetzfried (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]))
292b49b906SJohannes Goetzfried #define F2(D, r, m) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \
302b49b906SJohannes Goetzfried (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]))
312b49b906SJohannes Goetzfried #define F3(D, r, m) ((I = ((m) - (D))), (I = rol32(I, (r))), \
322b49b906SJohannes Goetzfried (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]))
332b49b906SJohannes Goetzfried
342b49b906SJohannes Goetzfried static const u32 Tm[24][8] = {
352b49b906SJohannes Goetzfried { 0x5a827999, 0xc95c653a, 0x383650db, 0xa7103c7c, 0x15ea281d,
362b49b906SJohannes Goetzfried 0x84c413be, 0xf39dff5f, 0x6277eb00 } ,
372b49b906SJohannes Goetzfried { 0xd151d6a1, 0x402bc242, 0xaf05ade3, 0x1ddf9984, 0x8cb98525,
382b49b906SJohannes Goetzfried 0xfb9370c6, 0x6a6d5c67, 0xd9474808 } ,
392b49b906SJohannes Goetzfried { 0x482133a9, 0xb6fb1f4a, 0x25d50aeb, 0x94aef68c, 0x0388e22d,
402b49b906SJohannes Goetzfried 0x7262cdce, 0xe13cb96f, 0x5016a510 } ,
412b49b906SJohannes Goetzfried { 0xbef090b1, 0x2dca7c52, 0x9ca467f3, 0x0b7e5394, 0x7a583f35,
422b49b906SJohannes Goetzfried 0xe9322ad6, 0x580c1677, 0xc6e60218 } ,
432b49b906SJohannes Goetzfried { 0x35bfedb9, 0xa499d95a, 0x1373c4fb, 0x824db09c, 0xf1279c3d,
442b49b906SJohannes Goetzfried 0x600187de, 0xcedb737f, 0x3db55f20 } ,
452b49b906SJohannes Goetzfried { 0xac8f4ac1, 0x1b693662, 0x8a432203, 0xf91d0da4, 0x67f6f945,
462b49b906SJohannes Goetzfried 0xd6d0e4e6, 0x45aad087, 0xb484bc28 } ,
472b49b906SJohannes Goetzfried { 0x235ea7c9, 0x9238936a, 0x01127f0b, 0x6fec6aac, 0xdec6564d,
482b49b906SJohannes Goetzfried 0x4da041ee, 0xbc7a2d8f, 0x2b541930 } ,
492b49b906SJohannes Goetzfried { 0x9a2e04d1, 0x0907f072, 0x77e1dc13, 0xe6bbc7b4, 0x5595b355,
502b49b906SJohannes Goetzfried 0xc46f9ef6, 0x33498a97, 0xa2237638 } ,
512b49b906SJohannes Goetzfried { 0x10fd61d9, 0x7fd74d7a, 0xeeb1391b, 0x5d8b24bc, 0xcc65105d,
522b49b906SJohannes Goetzfried 0x3b3efbfe, 0xaa18e79f, 0x18f2d340 } ,
532b49b906SJohannes Goetzfried { 0x87ccbee1, 0xf6a6aa82, 0x65809623, 0xd45a81c4, 0x43346d65,
542b49b906SJohannes Goetzfried 0xb20e5906, 0x20e844a7, 0x8fc23048 } ,
552b49b906SJohannes Goetzfried { 0xfe9c1be9, 0x6d76078a, 0xdc4ff32b, 0x4b29decc, 0xba03ca6d,
562b49b906SJohannes Goetzfried 0x28ddb60e, 0x97b7a1af, 0x06918d50 } ,
572b49b906SJohannes Goetzfried { 0x756b78f1, 0xe4456492, 0x531f5033, 0xc1f93bd4, 0x30d32775,
582b49b906SJohannes Goetzfried 0x9fad1316, 0x0e86feb7, 0x7d60ea58 } ,
592b49b906SJohannes Goetzfried { 0xec3ad5f9, 0x5b14c19a, 0xc9eead3b, 0x38c898dc, 0xa7a2847d,
602b49b906SJohannes Goetzfried 0x167c701e, 0x85565bbf, 0xf4304760 } ,
612b49b906SJohannes Goetzfried { 0x630a3301, 0xd1e41ea2, 0x40be0a43, 0xaf97f5e4, 0x1e71e185,
622b49b906SJohannes Goetzfried 0x8d4bcd26, 0xfc25b8c7, 0x6affa468 } ,
632b49b906SJohannes Goetzfried { 0xd9d99009, 0x48b37baa, 0xb78d674b, 0x266752ec, 0x95413e8d,
642b49b906SJohannes Goetzfried 0x041b2a2e, 0x72f515cf, 0xe1cf0170 } ,
652b49b906SJohannes Goetzfried { 0x50a8ed11, 0xbf82d8b2, 0x2e5cc453, 0x9d36aff4, 0x0c109b95,
662b49b906SJohannes Goetzfried 0x7aea8736, 0xe9c472d7, 0x589e5e78 } ,
672b49b906SJohannes Goetzfried { 0xc7784a19, 0x365235ba, 0xa52c215b, 0x14060cfc, 0x82dff89d,
682b49b906SJohannes Goetzfried 0xf1b9e43e, 0x6093cfdf, 0xcf6dbb80 } ,
692b49b906SJohannes Goetzfried { 0x3e47a721, 0xad2192c2, 0x1bfb7e63, 0x8ad56a04, 0xf9af55a5,
702b49b906SJohannes Goetzfried 0x68894146, 0xd7632ce7, 0x463d1888 } ,
712b49b906SJohannes Goetzfried { 0xb5170429, 0x23f0efca, 0x92cadb6b, 0x01a4c70c, 0x707eb2ad,
722b49b906SJohannes Goetzfried 0xdf589e4e, 0x4e3289ef, 0xbd0c7590 } ,
732b49b906SJohannes Goetzfried { 0x2be66131, 0x9ac04cd2, 0x099a3873, 0x78742414, 0xe74e0fb5,
742b49b906SJohannes Goetzfried 0x5627fb56, 0xc501e6f7, 0x33dbd298 } ,
752b49b906SJohannes Goetzfried { 0xa2b5be39, 0x118fa9da, 0x8069957b, 0xef43811c, 0x5e1d6cbd,
762b49b906SJohannes Goetzfried 0xccf7585e, 0x3bd143ff, 0xaaab2fa0 } ,
772b49b906SJohannes Goetzfried { 0x19851b41, 0x885f06e2, 0xf738f283, 0x6612de24, 0xd4ecc9c5,
782b49b906SJohannes Goetzfried 0x43c6b566, 0xb2a0a107, 0x217a8ca8 } ,
792b49b906SJohannes Goetzfried { 0x90547849, 0xff2e63ea, 0x6e084f8b, 0xdce23b2c, 0x4bbc26cd,
802b49b906SJohannes Goetzfried 0xba96126e, 0x296ffe0f, 0x9849e9b0 } ,
812b49b906SJohannes Goetzfried { 0x0723d551, 0x75fdc0f2, 0xe4d7ac93, 0x53b19834, 0xc28b83d5,
822b49b906SJohannes Goetzfried 0x31656f76, 0xa03f5b17, 0x0f1946b8 }
832b49b906SJohannes Goetzfried };
842b49b906SJohannes Goetzfried
852b49b906SJohannes Goetzfried static const u8 Tr[4][8] = {
862b49b906SJohannes Goetzfried { 0x13, 0x04, 0x15, 0x06, 0x17, 0x08, 0x19, 0x0a } ,
872b49b906SJohannes Goetzfried { 0x1b, 0x0c, 0x1d, 0x0e, 0x1f, 0x10, 0x01, 0x12 } ,
882b49b906SJohannes Goetzfried { 0x03, 0x14, 0x05, 0x16, 0x07, 0x18, 0x09, 0x1a } ,
892b49b906SJohannes Goetzfried { 0x0b, 0x1c, 0x0d, 0x1e, 0x0f, 0x00, 0x11, 0x02 }
902b49b906SJohannes Goetzfried };
912b49b906SJohannes Goetzfried
922b49b906SJohannes Goetzfried /* forward octave */
W(u32 * key,unsigned int i)93312639bbSJussi Kivilinna static inline void W(u32 *key, unsigned int i)
942b49b906SJohannes Goetzfried {
952b49b906SJohannes Goetzfried u32 I;
962b49b906SJohannes Goetzfried key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]);
972b49b906SJohannes Goetzfried key[5] ^= F2(key[6], Tr[i % 4][1], Tm[i][1]);
982b49b906SJohannes Goetzfried key[4] ^= F3(key[5], Tr[i % 4][2], Tm[i][2]);
992b49b906SJohannes Goetzfried key[3] ^= F1(key[4], Tr[i % 4][3], Tm[i][3]);
1002b49b906SJohannes Goetzfried key[2] ^= F2(key[3], Tr[i % 4][4], Tm[i][4]);
1012b49b906SJohannes Goetzfried key[1] ^= F3(key[2], Tr[i % 4][5], Tm[i][5]);
1022b49b906SJohannes Goetzfried key[0] ^= F1(key[1], Tr[i % 4][6], Tm[i][6]);
1032b49b906SJohannes Goetzfried key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]);
1042b49b906SJohannes Goetzfried }
1052b49b906SJohannes Goetzfried
__cast6_setkey(struct cast6_ctx * c,const u8 * in_key,unsigned int key_len)106674f368aSEric Biggers int __cast6_setkey(struct cast6_ctx *c, const u8 *in_key, unsigned int key_len)
1072b49b906SJohannes Goetzfried {
1082b49b906SJohannes Goetzfried int i;
1092b49b906SJohannes Goetzfried u32 key[8];
1102b49b906SJohannes Goetzfried __be32 p_key[8]; /* padded key */
1112b49b906SJohannes Goetzfried
112674f368aSEric Biggers if (key_len % 4 != 0)
1132b49b906SJohannes Goetzfried return -EINVAL;
1142b49b906SJohannes Goetzfried
1152b49b906SJohannes Goetzfried memset(p_key, 0, 32);
1162b49b906SJohannes Goetzfried memcpy(p_key, in_key, key_len);
1172b49b906SJohannes Goetzfried
1182b49b906SJohannes Goetzfried key[0] = be32_to_cpu(p_key[0]); /* A */
1192b49b906SJohannes Goetzfried key[1] = be32_to_cpu(p_key[1]); /* B */
1202b49b906SJohannes Goetzfried key[2] = be32_to_cpu(p_key[2]); /* C */
1212b49b906SJohannes Goetzfried key[3] = be32_to_cpu(p_key[3]); /* D */
1222b49b906SJohannes Goetzfried key[4] = be32_to_cpu(p_key[4]); /* E */
1232b49b906SJohannes Goetzfried key[5] = be32_to_cpu(p_key[5]); /* F */
1242b49b906SJohannes Goetzfried key[6] = be32_to_cpu(p_key[6]); /* G */
1252b49b906SJohannes Goetzfried key[7] = be32_to_cpu(p_key[7]); /* H */
1262b49b906SJohannes Goetzfried
1272b49b906SJohannes Goetzfried for (i = 0; i < 12; i++) {
1282b49b906SJohannes Goetzfried W(key, 2 * i);
1292b49b906SJohannes Goetzfried W(key, 2 * i + 1);
1302b49b906SJohannes Goetzfried
1312b49b906SJohannes Goetzfried c->Kr[i][0] = key[0] & 0x1f;
1322b49b906SJohannes Goetzfried c->Kr[i][1] = key[2] & 0x1f;
1332b49b906SJohannes Goetzfried c->Kr[i][2] = key[4] & 0x1f;
1342b49b906SJohannes Goetzfried c->Kr[i][3] = key[6] & 0x1f;
1352b49b906SJohannes Goetzfried
1362b49b906SJohannes Goetzfried c->Km[i][0] = key[7];
1372b49b906SJohannes Goetzfried c->Km[i][1] = key[5];
1382b49b906SJohannes Goetzfried c->Km[i][2] = key[3];
1392b49b906SJohannes Goetzfried c->Km[i][3] = key[1];
1402b49b906SJohannes Goetzfried }
1412b49b906SJohannes Goetzfried
1422b49b906SJohannes Goetzfried return 0;
1432b49b906SJohannes Goetzfried }
1442b49b906SJohannes Goetzfried EXPORT_SYMBOL_GPL(__cast6_setkey);
1452b49b906SJohannes Goetzfried
cast6_setkey(struct crypto_tfm * tfm,const u8 * key,unsigned int keylen)1462b49b906SJohannes Goetzfried int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
1472b49b906SJohannes Goetzfried {
148674f368aSEric Biggers return __cast6_setkey(crypto_tfm_ctx(tfm), key, keylen);
1492b49b906SJohannes Goetzfried }
1502b49b906SJohannes Goetzfried EXPORT_SYMBOL_GPL(cast6_setkey);
1512b49b906SJohannes Goetzfried
1522b49b906SJohannes Goetzfried /*forward quad round*/
Q(u32 * block,const u8 * Kr,const u32 * Km)1539c1e8836SKees Cook static inline void Q(u32 *block, const u8 *Kr, const u32 *Km)
1542b49b906SJohannes Goetzfried {
1552b49b906SJohannes Goetzfried u32 I;
1562b49b906SJohannes Goetzfried block[2] ^= F1(block[3], Kr[0], Km[0]);
1572b49b906SJohannes Goetzfried block[1] ^= F2(block[2], Kr[1], Km[1]);
1582b49b906SJohannes Goetzfried block[0] ^= F3(block[1], Kr[2], Km[2]);
1592b49b906SJohannes Goetzfried block[3] ^= F1(block[0], Kr[3], Km[3]);
1602b49b906SJohannes Goetzfried }
1612b49b906SJohannes Goetzfried
1622b49b906SJohannes Goetzfried /*reverse quad round*/
QBAR(u32 * block,const u8 * Kr,const u32 * Km)1639c1e8836SKees Cook static inline void QBAR(u32 *block, const u8 *Kr, const u32 *Km)
1642b49b906SJohannes Goetzfried {
1652b49b906SJohannes Goetzfried u32 I;
1662b49b906SJohannes Goetzfried block[3] ^= F1(block[0], Kr[3], Km[3]);
1672b49b906SJohannes Goetzfried block[0] ^= F3(block[1], Kr[2], Km[2]);
1682b49b906SJohannes Goetzfried block[1] ^= F2(block[2], Kr[1], Km[1]);
1692b49b906SJohannes Goetzfried block[2] ^= F1(block[3], Kr[0], Km[0]);
1702b49b906SJohannes Goetzfried }
1712b49b906SJohannes Goetzfried
__cast6_encrypt(const void * ctx,u8 * outbuf,const u8 * inbuf)1729c1e8836SKees Cook void __cast6_encrypt(const void *ctx, u8 *outbuf, const u8 *inbuf)
1732b49b906SJohannes Goetzfried {
1749c1e8836SKees Cook const struct cast6_ctx *c = ctx;
1752b49b906SJohannes Goetzfried u32 block[4];
1769c1e8836SKees Cook const u32 *Km;
1779c1e8836SKees Cook const u8 *Kr;
1782b49b906SJohannes Goetzfried
17980879dd9SArd Biesheuvel block[0] = get_unaligned_be32(inbuf);
18080879dd9SArd Biesheuvel block[1] = get_unaligned_be32(inbuf + 4);
18180879dd9SArd Biesheuvel block[2] = get_unaligned_be32(inbuf + 8);
18280879dd9SArd Biesheuvel block[3] = get_unaligned_be32(inbuf + 12);
1832b49b906SJohannes Goetzfried
1842b49b906SJohannes Goetzfried Km = c->Km[0]; Kr = c->Kr[0]; Q(block, Kr, Km);
1852b49b906SJohannes Goetzfried Km = c->Km[1]; Kr = c->Kr[1]; Q(block, Kr, Km);
1862b49b906SJohannes Goetzfried Km = c->Km[2]; Kr = c->Kr[2]; Q(block, Kr, Km);
1872b49b906SJohannes Goetzfried Km = c->Km[3]; Kr = c->Kr[3]; Q(block, Kr, Km);
1882b49b906SJohannes Goetzfried Km = c->Km[4]; Kr = c->Kr[4]; Q(block, Kr, Km);
1892b49b906SJohannes Goetzfried Km = c->Km[5]; Kr = c->Kr[5]; Q(block, Kr, Km);
1902b49b906SJohannes Goetzfried Km = c->Km[6]; Kr = c->Kr[6]; QBAR(block, Kr, Km);
1912b49b906SJohannes Goetzfried Km = c->Km[7]; Kr = c->Kr[7]; QBAR(block, Kr, Km);
1922b49b906SJohannes Goetzfried Km = c->Km[8]; Kr = c->Kr[8]; QBAR(block, Kr, Km);
1932b49b906SJohannes Goetzfried Km = c->Km[9]; Kr = c->Kr[9]; QBAR(block, Kr, Km);
1942b49b906SJohannes Goetzfried Km = c->Km[10]; Kr = c->Kr[10]; QBAR(block, Kr, Km);
1952b49b906SJohannes Goetzfried Km = c->Km[11]; Kr = c->Kr[11]; QBAR(block, Kr, Km);
1962b49b906SJohannes Goetzfried
19780879dd9SArd Biesheuvel put_unaligned_be32(block[0], outbuf);
19880879dd9SArd Biesheuvel put_unaligned_be32(block[1], outbuf + 4);
19980879dd9SArd Biesheuvel put_unaligned_be32(block[2], outbuf + 8);
20080879dd9SArd Biesheuvel put_unaligned_be32(block[3], outbuf + 12);
2012b49b906SJohannes Goetzfried }
2022b49b906SJohannes Goetzfried EXPORT_SYMBOL_GPL(__cast6_encrypt);
2032b49b906SJohannes Goetzfried
cast6_encrypt(struct crypto_tfm * tfm,u8 * outbuf,const u8 * inbuf)2042b49b906SJohannes Goetzfried static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
2052b49b906SJohannes Goetzfried {
2062b49b906SJohannes Goetzfried __cast6_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf);
2072b49b906SJohannes Goetzfried }
2082b49b906SJohannes Goetzfried
__cast6_decrypt(const void * ctx,u8 * outbuf,const u8 * inbuf)2099c1e8836SKees Cook void __cast6_decrypt(const void *ctx, u8 *outbuf, const u8 *inbuf)
2102b49b906SJohannes Goetzfried {
2119c1e8836SKees Cook const struct cast6_ctx *c = ctx;
2122b49b906SJohannes Goetzfried u32 block[4];
2139c1e8836SKees Cook const u32 *Km;
2149c1e8836SKees Cook const u8 *Kr;
2152b49b906SJohannes Goetzfried
21680879dd9SArd Biesheuvel block[0] = get_unaligned_be32(inbuf);
21780879dd9SArd Biesheuvel block[1] = get_unaligned_be32(inbuf + 4);
21880879dd9SArd Biesheuvel block[2] = get_unaligned_be32(inbuf + 8);
21980879dd9SArd Biesheuvel block[3] = get_unaligned_be32(inbuf + 12);
2202b49b906SJohannes Goetzfried
2212b49b906SJohannes Goetzfried Km = c->Km[11]; Kr = c->Kr[11]; Q(block, Kr, Km);
2222b49b906SJohannes Goetzfried Km = c->Km[10]; Kr = c->Kr[10]; Q(block, Kr, Km);
2232b49b906SJohannes Goetzfried Km = c->Km[9]; Kr = c->Kr[9]; Q(block, Kr, Km);
2242b49b906SJohannes Goetzfried Km = c->Km[8]; Kr = c->Kr[8]; Q(block, Kr, Km);
2252b49b906SJohannes Goetzfried Km = c->Km[7]; Kr = c->Kr[7]; Q(block, Kr, Km);
2262b49b906SJohannes Goetzfried Km = c->Km[6]; Kr = c->Kr[6]; Q(block, Kr, Km);
2272b49b906SJohannes Goetzfried Km = c->Km[5]; Kr = c->Kr[5]; QBAR(block, Kr, Km);
2282b49b906SJohannes Goetzfried Km = c->Km[4]; Kr = c->Kr[4]; QBAR(block, Kr, Km);
2292b49b906SJohannes Goetzfried Km = c->Km[3]; Kr = c->Kr[3]; QBAR(block, Kr, Km);
2302b49b906SJohannes Goetzfried Km = c->Km[2]; Kr = c->Kr[2]; QBAR(block, Kr, Km);
2312b49b906SJohannes Goetzfried Km = c->Km[1]; Kr = c->Kr[1]; QBAR(block, Kr, Km);
2322b49b906SJohannes Goetzfried Km = c->Km[0]; Kr = c->Kr[0]; QBAR(block, Kr, Km);
2332b49b906SJohannes Goetzfried
23480879dd9SArd Biesheuvel put_unaligned_be32(block[0], outbuf);
23580879dd9SArd Biesheuvel put_unaligned_be32(block[1], outbuf + 4);
23680879dd9SArd Biesheuvel put_unaligned_be32(block[2], outbuf + 8);
23780879dd9SArd Biesheuvel put_unaligned_be32(block[3], outbuf + 12);
2382b49b906SJohannes Goetzfried }
2392b49b906SJohannes Goetzfried EXPORT_SYMBOL_GPL(__cast6_decrypt);
2402b49b906SJohannes Goetzfried
cast6_decrypt(struct crypto_tfm * tfm,u8 * outbuf,const u8 * inbuf)2412b49b906SJohannes Goetzfried static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
2422b49b906SJohannes Goetzfried {
2432b49b906SJohannes Goetzfried __cast6_decrypt(crypto_tfm_ctx(tfm), outbuf, inbuf);
2442b49b906SJohannes Goetzfried }
2452b49b906SJohannes Goetzfried
2462b49b906SJohannes Goetzfried static struct crypto_alg alg = {
2472b49b906SJohannes Goetzfried .cra_name = "cast6",
2482b49b906SJohannes Goetzfried .cra_driver_name = "cast6-generic",
2492b49b906SJohannes Goetzfried .cra_priority = 100,
2502b49b906SJohannes Goetzfried .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
2512b49b906SJohannes Goetzfried .cra_blocksize = CAST6_BLOCK_SIZE,
2522b49b906SJohannes Goetzfried .cra_ctxsize = sizeof(struct cast6_ctx),
2532b49b906SJohannes Goetzfried .cra_module = THIS_MODULE,
2542b49b906SJohannes Goetzfried .cra_u = {
2552b49b906SJohannes Goetzfried .cipher = {
2562b49b906SJohannes Goetzfried .cia_min_keysize = CAST6_MIN_KEY_SIZE,
2572b49b906SJohannes Goetzfried .cia_max_keysize = CAST6_MAX_KEY_SIZE,
2582b49b906SJohannes Goetzfried .cia_setkey = cast6_setkey,
2592b49b906SJohannes Goetzfried .cia_encrypt = cast6_encrypt,
2602b49b906SJohannes Goetzfried .cia_decrypt = cast6_decrypt}
2612b49b906SJohannes Goetzfried }
2622b49b906SJohannes Goetzfried };
2632b49b906SJohannes Goetzfried
cast6_mod_init(void)2642b49b906SJohannes Goetzfried static int __init cast6_mod_init(void)
2652b49b906SJohannes Goetzfried {
2662b49b906SJohannes Goetzfried return crypto_register_alg(&alg);
2672b49b906SJohannes Goetzfried }
2682b49b906SJohannes Goetzfried
cast6_mod_fini(void)2692b49b906SJohannes Goetzfried static void __exit cast6_mod_fini(void)
2702b49b906SJohannes Goetzfried {
2712b49b906SJohannes Goetzfried crypto_unregister_alg(&alg);
2722b49b906SJohannes Goetzfried }
2732b49b906SJohannes Goetzfried
274c4741b23SEric Biggers subsys_initcall(cast6_mod_init);
2752b49b906SJohannes Goetzfried module_exit(cast6_mod_fini);
2762b49b906SJohannes Goetzfried
2772b49b906SJohannes Goetzfried MODULE_LICENSE("GPL");
2782b49b906SJohannes Goetzfried MODULE_DESCRIPTION("Cast6 Cipher Algorithm");
2795d26a105SKees Cook MODULE_ALIAS_CRYPTO("cast6");
2803e14dcf7SMathias Krause MODULE_ALIAS_CRYPTO("cast6-generic");
281