4 * Null algorithms, aka Much Ado About Nothing.
6 * These are needed for IPsec, and may be useful in general for
9 * The null cipher is compliant with RFC2410.
11 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
19 #include <linux/init.h>
20 #include <linux/module.h>
22 #include <asm/scatterlist.h>
23 #include <linux/crypto.h>
25 #define NULL_KEY_SIZE 0
26 #define NULL_BLOCK_SIZE 1
27 #define NULL_DIGEST_SIZE 0
29 static int null_compress(void *ctx
, const u8
*src
, unsigned int slen
,
30 u8
*dst
, unsigned int *dlen
)
33 static int null_decompress(void *ctx
, const u8
*src
, unsigned int slen
,
34 u8
*dst
, unsigned int *dlen
)
37 static void null_init(void *ctx
)
40 static void null_update(void *ctx
, const u8
*data
, unsigned int len
)
43 static void null_final(void *ctx
, u8
*out
)
46 static int null_setkey(void *ctx
, const u8
*key
,
47 unsigned int keylen
, u32
*flags
)
50 static void null_encrypt(void *ctx
, u8
*dst
, const u8
*src
)
53 static void null_decrypt(void *ctx
, u8
*dst
, const u8
*src
)
56 static struct crypto_alg compress_null
= {
57 .cra_name
= "compress_null",
58 .cra_flags
= CRYPTO_ALG_TYPE_COMPRESS
,
59 .cra_blocksize
= NULL_BLOCK_SIZE
,
61 .cra_module
= THIS_MODULE
,
62 .cra_list
= LIST_HEAD_INIT(compress_null
.cra_list
),
63 .cra_u
= { .compress
= {
64 .coa_compress
= null_compress
,
65 .coa_decompress
= null_decompress
} }
68 static struct crypto_alg digest_null
= {
69 .cra_name
= "digest_null",
70 .cra_flags
= CRYPTO_ALG_TYPE_DIGEST
,
71 .cra_blocksize
= NULL_BLOCK_SIZE
,
73 .cra_module
= THIS_MODULE
,
74 .cra_list
= LIST_HEAD_INIT(digest_null
.cra_list
),
75 .cra_u
= { .digest
= {
76 .dia_digestsize
= NULL_DIGEST_SIZE
,
77 .dia_init
= null_init
,
78 .dia_update
= null_update
,
79 .dia_final
= null_final
} }
82 static struct crypto_alg cipher_null
= {
83 .cra_name
= "cipher_null",
84 .cra_flags
= CRYPTO_ALG_TYPE_CIPHER
,
85 .cra_blocksize
= NULL_BLOCK_SIZE
,
87 .cra_module
= THIS_MODULE
,
88 .cra_list
= LIST_HEAD_INIT(cipher_null
.cra_list
),
89 .cra_u
= { .cipher
= {
90 .cia_min_keysize
= NULL_KEY_SIZE
,
91 .cia_max_keysize
= NULL_KEY_SIZE
,
92 .cia_setkey
= null_setkey
,
93 .cia_encrypt
= null_encrypt
,
94 .cia_decrypt
= null_decrypt
} }
97 MODULE_ALIAS("compress_null");
98 MODULE_ALIAS("digest_null");
99 MODULE_ALIAS("cipher_null");
101 static int __init
init(void)
105 ret
= crypto_register_alg(&cipher_null
);
109 ret
= crypto_register_alg(&digest_null
);
111 crypto_unregister_alg(&cipher_null
);
115 ret
= crypto_register_alg(&compress_null
);
117 crypto_unregister_alg(&digest_null
);
118 crypto_unregister_alg(&cipher_null
);
126 static void __exit
fini(void)
128 crypto_unregister_alg(&compress_null
);
129 crypto_unregister_alg(&digest_null
);
130 crypto_unregister_alg(&cipher_null
);
136 MODULE_LICENSE("GPL");
137 MODULE_DESCRIPTION("Null Cryptographic Algorithms");