162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/* Kernel cryptographic api.
362306a36Sopenharmony_ci * cast6.c - Cast6 cipher algorithm [rfc2612].
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * CAST-256 (*cast6*) is a DES like Substitution-Permutation Network (SPN)
662306a36Sopenharmony_ci * cryptosystem built upon the CAST-128 (*cast5*) [rfc2144] encryption
762306a36Sopenharmony_ci * algorithm.
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * Copyright (C) 2003 Kartikey Mahendra Bhatt <kartik_me@hotmail.com>.
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <asm/unaligned.h>
1462306a36Sopenharmony_ci#include <crypto/algapi.h>
1562306a36Sopenharmony_ci#include <linux/init.h>
1662306a36Sopenharmony_ci#include <linux/module.h>
1762306a36Sopenharmony_ci#include <linux/errno.h>
1862306a36Sopenharmony_ci#include <linux/string.h>
1962306a36Sopenharmony_ci#include <linux/types.h>
2062306a36Sopenharmony_ci#include <crypto/cast6.h>
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define s1 cast_s1
2362306a36Sopenharmony_ci#define s2 cast_s2
2462306a36Sopenharmony_ci#define s3 cast_s3
2562306a36Sopenharmony_ci#define s4 cast_s4
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#define F1(D, r, m)  ((I = ((m) + (D))), (I = rol32(I, (r))),   \
2862306a36Sopenharmony_ci	(((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]))
2962306a36Sopenharmony_ci#define F2(D, r, m)  ((I = ((m) ^ (D))), (I = rol32(I, (r))),   \
3062306a36Sopenharmony_ci	(((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]))
3162306a36Sopenharmony_ci#define F3(D, r, m)  ((I = ((m) - (D))), (I = rol32(I, (r))),   \
3262306a36Sopenharmony_ci	(((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]))
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_cistatic const u32 Tm[24][8] = {
3562306a36Sopenharmony_ci	{ 0x5a827999, 0xc95c653a, 0x383650db, 0xa7103c7c, 0x15ea281d,
3662306a36Sopenharmony_ci		0x84c413be, 0xf39dff5f, 0x6277eb00 } ,
3762306a36Sopenharmony_ci	{ 0xd151d6a1, 0x402bc242, 0xaf05ade3, 0x1ddf9984, 0x8cb98525,
3862306a36Sopenharmony_ci		0xfb9370c6, 0x6a6d5c67, 0xd9474808 } ,
3962306a36Sopenharmony_ci	{ 0x482133a9, 0xb6fb1f4a, 0x25d50aeb, 0x94aef68c, 0x0388e22d,
4062306a36Sopenharmony_ci		0x7262cdce, 0xe13cb96f, 0x5016a510 } ,
4162306a36Sopenharmony_ci	{ 0xbef090b1, 0x2dca7c52, 0x9ca467f3, 0x0b7e5394, 0x7a583f35,
4262306a36Sopenharmony_ci		0xe9322ad6, 0x580c1677, 0xc6e60218 } ,
4362306a36Sopenharmony_ci	{ 0x35bfedb9, 0xa499d95a, 0x1373c4fb, 0x824db09c, 0xf1279c3d,
4462306a36Sopenharmony_ci		0x600187de, 0xcedb737f, 0x3db55f20 } ,
4562306a36Sopenharmony_ci	{ 0xac8f4ac1, 0x1b693662, 0x8a432203, 0xf91d0da4, 0x67f6f945,
4662306a36Sopenharmony_ci		0xd6d0e4e6, 0x45aad087, 0xb484bc28 } ,
4762306a36Sopenharmony_ci	{ 0x235ea7c9, 0x9238936a, 0x01127f0b, 0x6fec6aac, 0xdec6564d,
4862306a36Sopenharmony_ci		0x4da041ee, 0xbc7a2d8f, 0x2b541930 } ,
4962306a36Sopenharmony_ci	{ 0x9a2e04d1, 0x0907f072, 0x77e1dc13, 0xe6bbc7b4, 0x5595b355,
5062306a36Sopenharmony_ci		0xc46f9ef6, 0x33498a97, 0xa2237638 } ,
5162306a36Sopenharmony_ci	{ 0x10fd61d9, 0x7fd74d7a, 0xeeb1391b, 0x5d8b24bc, 0xcc65105d,
5262306a36Sopenharmony_ci		0x3b3efbfe, 0xaa18e79f, 0x18f2d340 } ,
5362306a36Sopenharmony_ci	{ 0x87ccbee1, 0xf6a6aa82, 0x65809623, 0xd45a81c4, 0x43346d65,
5462306a36Sopenharmony_ci		0xb20e5906, 0x20e844a7, 0x8fc23048 } ,
5562306a36Sopenharmony_ci	{ 0xfe9c1be9, 0x6d76078a, 0xdc4ff32b, 0x4b29decc, 0xba03ca6d,
5662306a36Sopenharmony_ci		0x28ddb60e, 0x97b7a1af, 0x06918d50 } ,
5762306a36Sopenharmony_ci	{ 0x756b78f1, 0xe4456492, 0x531f5033, 0xc1f93bd4, 0x30d32775,
5862306a36Sopenharmony_ci		0x9fad1316, 0x0e86feb7, 0x7d60ea58 } ,
5962306a36Sopenharmony_ci	{ 0xec3ad5f9, 0x5b14c19a, 0xc9eead3b, 0x38c898dc, 0xa7a2847d,
6062306a36Sopenharmony_ci		0x167c701e, 0x85565bbf, 0xf4304760 } ,
6162306a36Sopenharmony_ci	{ 0x630a3301, 0xd1e41ea2, 0x40be0a43, 0xaf97f5e4, 0x1e71e185,
6262306a36Sopenharmony_ci		0x8d4bcd26, 0xfc25b8c7, 0x6affa468 } ,
6362306a36Sopenharmony_ci	{ 0xd9d99009, 0x48b37baa, 0xb78d674b, 0x266752ec, 0x95413e8d,
6462306a36Sopenharmony_ci		0x041b2a2e, 0x72f515cf, 0xe1cf0170 } ,
6562306a36Sopenharmony_ci	{ 0x50a8ed11, 0xbf82d8b2, 0x2e5cc453, 0x9d36aff4, 0x0c109b95,
6662306a36Sopenharmony_ci		0x7aea8736, 0xe9c472d7, 0x589e5e78 } ,
6762306a36Sopenharmony_ci	{ 0xc7784a19, 0x365235ba, 0xa52c215b, 0x14060cfc, 0x82dff89d,
6862306a36Sopenharmony_ci		0xf1b9e43e, 0x6093cfdf, 0xcf6dbb80 } ,
6962306a36Sopenharmony_ci	{ 0x3e47a721, 0xad2192c2, 0x1bfb7e63, 0x8ad56a04, 0xf9af55a5,
7062306a36Sopenharmony_ci		0x68894146, 0xd7632ce7, 0x463d1888 } ,
7162306a36Sopenharmony_ci	{ 0xb5170429, 0x23f0efca, 0x92cadb6b, 0x01a4c70c, 0x707eb2ad,
7262306a36Sopenharmony_ci		0xdf589e4e, 0x4e3289ef, 0xbd0c7590 } ,
7362306a36Sopenharmony_ci	{ 0x2be66131, 0x9ac04cd2, 0x099a3873, 0x78742414, 0xe74e0fb5,
7462306a36Sopenharmony_ci		0x5627fb56, 0xc501e6f7, 0x33dbd298 } ,
7562306a36Sopenharmony_ci	{ 0xa2b5be39, 0x118fa9da, 0x8069957b, 0xef43811c, 0x5e1d6cbd,
7662306a36Sopenharmony_ci		0xccf7585e, 0x3bd143ff, 0xaaab2fa0 } ,
7762306a36Sopenharmony_ci	{ 0x19851b41, 0x885f06e2, 0xf738f283, 0x6612de24, 0xd4ecc9c5,
7862306a36Sopenharmony_ci		0x43c6b566, 0xb2a0a107, 0x217a8ca8 } ,
7962306a36Sopenharmony_ci	{ 0x90547849, 0xff2e63ea, 0x6e084f8b, 0xdce23b2c, 0x4bbc26cd,
8062306a36Sopenharmony_ci		0xba96126e, 0x296ffe0f, 0x9849e9b0 } ,
8162306a36Sopenharmony_ci	{ 0x0723d551, 0x75fdc0f2, 0xe4d7ac93, 0x53b19834, 0xc28b83d5,
8262306a36Sopenharmony_ci		0x31656f76, 0xa03f5b17, 0x0f1946b8 }
8362306a36Sopenharmony_ci};
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_cistatic const u8 Tr[4][8] = {
8662306a36Sopenharmony_ci	{ 0x13, 0x04, 0x15, 0x06, 0x17, 0x08, 0x19, 0x0a } ,
8762306a36Sopenharmony_ci	{ 0x1b, 0x0c, 0x1d, 0x0e, 0x1f, 0x10, 0x01, 0x12 } ,
8862306a36Sopenharmony_ci	{ 0x03, 0x14, 0x05, 0x16, 0x07, 0x18, 0x09, 0x1a } ,
8962306a36Sopenharmony_ci	{ 0x0b, 0x1c, 0x0d, 0x1e, 0x0f, 0x00, 0x11, 0x02 }
9062306a36Sopenharmony_ci};
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci/* forward octave */
9362306a36Sopenharmony_cistatic inline void W(u32 *key, unsigned int i)
9462306a36Sopenharmony_ci{
9562306a36Sopenharmony_ci	u32 I;
9662306a36Sopenharmony_ci	key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]);
9762306a36Sopenharmony_ci	key[5] ^= F2(key[6], Tr[i % 4][1], Tm[i][1]);
9862306a36Sopenharmony_ci	key[4] ^= F3(key[5], Tr[i % 4][2], Tm[i][2]);
9962306a36Sopenharmony_ci	key[3] ^= F1(key[4], Tr[i % 4][3], Tm[i][3]);
10062306a36Sopenharmony_ci	key[2] ^= F2(key[3], Tr[i % 4][4], Tm[i][4]);
10162306a36Sopenharmony_ci	key[1] ^= F3(key[2], Tr[i % 4][5], Tm[i][5]);
10262306a36Sopenharmony_ci	key[0] ^= F1(key[1], Tr[i % 4][6], Tm[i][6]);
10362306a36Sopenharmony_ci	key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]);
10462306a36Sopenharmony_ci}
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ciint __cast6_setkey(struct cast6_ctx *c, const u8 *in_key, unsigned int key_len)
10762306a36Sopenharmony_ci{
10862306a36Sopenharmony_ci	int i;
10962306a36Sopenharmony_ci	u32 key[8];
11062306a36Sopenharmony_ci	__be32 p_key[8]; /* padded key */
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci	if (key_len % 4 != 0)
11362306a36Sopenharmony_ci		return -EINVAL;
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci	memset(p_key, 0, 32);
11662306a36Sopenharmony_ci	memcpy(p_key, in_key, key_len);
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci	key[0] = be32_to_cpu(p_key[0]);		/* A */
11962306a36Sopenharmony_ci	key[1] = be32_to_cpu(p_key[1]);		/* B */
12062306a36Sopenharmony_ci	key[2] = be32_to_cpu(p_key[2]);		/* C */
12162306a36Sopenharmony_ci	key[3] = be32_to_cpu(p_key[3]);		/* D */
12262306a36Sopenharmony_ci	key[4] = be32_to_cpu(p_key[4]);		/* E */
12362306a36Sopenharmony_ci	key[5] = be32_to_cpu(p_key[5]);		/* F */
12462306a36Sopenharmony_ci	key[6] = be32_to_cpu(p_key[6]);		/* G */
12562306a36Sopenharmony_ci	key[7] = be32_to_cpu(p_key[7]);		/* H */
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci	for (i = 0; i < 12; i++) {
12862306a36Sopenharmony_ci		W(key, 2 * i);
12962306a36Sopenharmony_ci		W(key, 2 * i + 1);
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci		c->Kr[i][0] = key[0] & 0x1f;
13262306a36Sopenharmony_ci		c->Kr[i][1] = key[2] & 0x1f;
13362306a36Sopenharmony_ci		c->Kr[i][2] = key[4] & 0x1f;
13462306a36Sopenharmony_ci		c->Kr[i][3] = key[6] & 0x1f;
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci		c->Km[i][0] = key[7];
13762306a36Sopenharmony_ci		c->Km[i][1] = key[5];
13862306a36Sopenharmony_ci		c->Km[i][2] = key[3];
13962306a36Sopenharmony_ci		c->Km[i][3] = key[1];
14062306a36Sopenharmony_ci	}
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci	return 0;
14362306a36Sopenharmony_ci}
14462306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(__cast6_setkey);
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ciint cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
14762306a36Sopenharmony_ci{
14862306a36Sopenharmony_ci	return __cast6_setkey(crypto_tfm_ctx(tfm), key, keylen);
14962306a36Sopenharmony_ci}
15062306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(cast6_setkey);
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci/*forward quad round*/
15362306a36Sopenharmony_cistatic inline void Q(u32 *block, const u8 *Kr, const u32 *Km)
15462306a36Sopenharmony_ci{
15562306a36Sopenharmony_ci	u32 I;
15662306a36Sopenharmony_ci	block[2] ^= F1(block[3], Kr[0], Km[0]);
15762306a36Sopenharmony_ci	block[1] ^= F2(block[2], Kr[1], Km[1]);
15862306a36Sopenharmony_ci	block[0] ^= F3(block[1], Kr[2], Km[2]);
15962306a36Sopenharmony_ci	block[3] ^= F1(block[0], Kr[3], Km[3]);
16062306a36Sopenharmony_ci}
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci/*reverse quad round*/
16362306a36Sopenharmony_cistatic inline void QBAR(u32 *block, const u8 *Kr, const u32 *Km)
16462306a36Sopenharmony_ci{
16562306a36Sopenharmony_ci	u32 I;
16662306a36Sopenharmony_ci	block[3] ^= F1(block[0], Kr[3], Km[3]);
16762306a36Sopenharmony_ci	block[0] ^= F3(block[1], Kr[2], Km[2]);
16862306a36Sopenharmony_ci	block[1] ^= F2(block[2], Kr[1], Km[1]);
16962306a36Sopenharmony_ci	block[2] ^= F1(block[3], Kr[0], Km[0]);
17062306a36Sopenharmony_ci}
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_civoid __cast6_encrypt(const void *ctx, u8 *outbuf, const u8 *inbuf)
17362306a36Sopenharmony_ci{
17462306a36Sopenharmony_ci	const struct cast6_ctx *c = ctx;
17562306a36Sopenharmony_ci	u32 block[4];
17662306a36Sopenharmony_ci	const u32 *Km;
17762306a36Sopenharmony_ci	const u8 *Kr;
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci	block[0] = get_unaligned_be32(inbuf);
18062306a36Sopenharmony_ci	block[1] = get_unaligned_be32(inbuf + 4);
18162306a36Sopenharmony_ci	block[2] = get_unaligned_be32(inbuf + 8);
18262306a36Sopenharmony_ci	block[3] = get_unaligned_be32(inbuf + 12);
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci	Km = c->Km[0]; Kr = c->Kr[0]; Q(block, Kr, Km);
18562306a36Sopenharmony_ci	Km = c->Km[1]; Kr = c->Kr[1]; Q(block, Kr, Km);
18662306a36Sopenharmony_ci	Km = c->Km[2]; Kr = c->Kr[2]; Q(block, Kr, Km);
18762306a36Sopenharmony_ci	Km = c->Km[3]; Kr = c->Kr[3]; Q(block, Kr, Km);
18862306a36Sopenharmony_ci	Km = c->Km[4]; Kr = c->Kr[4]; Q(block, Kr, Km);
18962306a36Sopenharmony_ci	Km = c->Km[5]; Kr = c->Kr[5]; Q(block, Kr, Km);
19062306a36Sopenharmony_ci	Km = c->Km[6]; Kr = c->Kr[6]; QBAR(block, Kr, Km);
19162306a36Sopenharmony_ci	Km = c->Km[7]; Kr = c->Kr[7]; QBAR(block, Kr, Km);
19262306a36Sopenharmony_ci	Km = c->Km[8]; Kr = c->Kr[8]; QBAR(block, Kr, Km);
19362306a36Sopenharmony_ci	Km = c->Km[9]; Kr = c->Kr[9]; QBAR(block, Kr, Km);
19462306a36Sopenharmony_ci	Km = c->Km[10]; Kr = c->Kr[10]; QBAR(block, Kr, Km);
19562306a36Sopenharmony_ci	Km = c->Km[11]; Kr = c->Kr[11]; QBAR(block, Kr, Km);
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci	put_unaligned_be32(block[0], outbuf);
19862306a36Sopenharmony_ci	put_unaligned_be32(block[1], outbuf + 4);
19962306a36Sopenharmony_ci	put_unaligned_be32(block[2], outbuf + 8);
20062306a36Sopenharmony_ci	put_unaligned_be32(block[3], outbuf + 12);
20162306a36Sopenharmony_ci}
20262306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(__cast6_encrypt);
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_cistatic void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
20562306a36Sopenharmony_ci{
20662306a36Sopenharmony_ci	__cast6_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf);
20762306a36Sopenharmony_ci}
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_civoid __cast6_decrypt(const void *ctx, u8 *outbuf, const u8 *inbuf)
21062306a36Sopenharmony_ci{
21162306a36Sopenharmony_ci	const struct cast6_ctx *c = ctx;
21262306a36Sopenharmony_ci	u32 block[4];
21362306a36Sopenharmony_ci	const u32 *Km;
21462306a36Sopenharmony_ci	const u8 *Kr;
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci	block[0] = get_unaligned_be32(inbuf);
21762306a36Sopenharmony_ci	block[1] = get_unaligned_be32(inbuf + 4);
21862306a36Sopenharmony_ci	block[2] = get_unaligned_be32(inbuf + 8);
21962306a36Sopenharmony_ci	block[3] = get_unaligned_be32(inbuf + 12);
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci	Km = c->Km[11]; Kr = c->Kr[11]; Q(block, Kr, Km);
22262306a36Sopenharmony_ci	Km = c->Km[10]; Kr = c->Kr[10]; Q(block, Kr, Km);
22362306a36Sopenharmony_ci	Km = c->Km[9]; Kr = c->Kr[9]; Q(block, Kr, Km);
22462306a36Sopenharmony_ci	Km = c->Km[8]; Kr = c->Kr[8]; Q(block, Kr, Km);
22562306a36Sopenharmony_ci	Km = c->Km[7]; Kr = c->Kr[7]; Q(block, Kr, Km);
22662306a36Sopenharmony_ci	Km = c->Km[6]; Kr = c->Kr[6]; Q(block, Kr, Km);
22762306a36Sopenharmony_ci	Km = c->Km[5]; Kr = c->Kr[5]; QBAR(block, Kr, Km);
22862306a36Sopenharmony_ci	Km = c->Km[4]; Kr = c->Kr[4]; QBAR(block, Kr, Km);
22962306a36Sopenharmony_ci	Km = c->Km[3]; Kr = c->Kr[3]; QBAR(block, Kr, Km);
23062306a36Sopenharmony_ci	Km = c->Km[2]; Kr = c->Kr[2]; QBAR(block, Kr, Km);
23162306a36Sopenharmony_ci	Km = c->Km[1]; Kr = c->Kr[1]; QBAR(block, Kr, Km);
23262306a36Sopenharmony_ci	Km = c->Km[0]; Kr = c->Kr[0]; QBAR(block, Kr, Km);
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_ci	put_unaligned_be32(block[0], outbuf);
23562306a36Sopenharmony_ci	put_unaligned_be32(block[1], outbuf + 4);
23662306a36Sopenharmony_ci	put_unaligned_be32(block[2], outbuf + 8);
23762306a36Sopenharmony_ci	put_unaligned_be32(block[3], outbuf + 12);
23862306a36Sopenharmony_ci}
23962306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(__cast6_decrypt);
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_cistatic void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
24262306a36Sopenharmony_ci{
24362306a36Sopenharmony_ci	__cast6_decrypt(crypto_tfm_ctx(tfm), outbuf, inbuf);
24462306a36Sopenharmony_ci}
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_cistatic struct crypto_alg alg = {
24762306a36Sopenharmony_ci	.cra_name = "cast6",
24862306a36Sopenharmony_ci	.cra_driver_name = "cast6-generic",
24962306a36Sopenharmony_ci	.cra_priority = 100,
25062306a36Sopenharmony_ci	.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
25162306a36Sopenharmony_ci	.cra_blocksize = CAST6_BLOCK_SIZE,
25262306a36Sopenharmony_ci	.cra_ctxsize = sizeof(struct cast6_ctx),
25362306a36Sopenharmony_ci	.cra_module = THIS_MODULE,
25462306a36Sopenharmony_ci	.cra_u = {
25562306a36Sopenharmony_ci		  .cipher = {
25662306a36Sopenharmony_ci			     .cia_min_keysize = CAST6_MIN_KEY_SIZE,
25762306a36Sopenharmony_ci			     .cia_max_keysize = CAST6_MAX_KEY_SIZE,
25862306a36Sopenharmony_ci			     .cia_setkey = cast6_setkey,
25962306a36Sopenharmony_ci			     .cia_encrypt = cast6_encrypt,
26062306a36Sopenharmony_ci			     .cia_decrypt = cast6_decrypt}
26162306a36Sopenharmony_ci		  }
26262306a36Sopenharmony_ci};
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_cistatic int __init cast6_mod_init(void)
26562306a36Sopenharmony_ci{
26662306a36Sopenharmony_ci	return crypto_register_alg(&alg);
26762306a36Sopenharmony_ci}
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_cistatic void __exit cast6_mod_fini(void)
27062306a36Sopenharmony_ci{
27162306a36Sopenharmony_ci	crypto_unregister_alg(&alg);
27262306a36Sopenharmony_ci}
27362306a36Sopenharmony_ci
27462306a36Sopenharmony_cisubsys_initcall(cast6_mod_init);
27562306a36Sopenharmony_cimodule_exit(cast6_mod_fini);
27662306a36Sopenharmony_ci
27762306a36Sopenharmony_ciMODULE_LICENSE("GPL");
27862306a36Sopenharmony_ciMODULE_DESCRIPTION("Cast6 Cipher Algorithm");
27962306a36Sopenharmony_ciMODULE_ALIAS_CRYPTO("cast6");
28062306a36Sopenharmony_ciMODULE_ALIAS_CRYPTO("cast6-generic");
281