ia64/linux-2.6.18-xen.hg

annotate crypto/crypto_null.c @ 749:2892ca2b9c17

linux/x86: cleanup IO-APIC code

- get 32-bit code in sync with 64-bit wrt ExtINT pin detection being
unnecessary
- eliminate build warnings resulting from c/s 725

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Nov 28 13:31:21 2008 +0000 (2008-11-28)
parents 831230e53067
children
rev   line source
ian@0 1 /*
ian@0 2 * Cryptographic API.
ian@0 3 *
ian@0 4 * Null algorithms, aka Much Ado About Nothing.
ian@0 5 *
ian@0 6 * These are needed for IPsec, and may be useful in general for
ian@0 7 * testing & debugging.
ian@0 8 *
ian@0 9 * The null cipher is compliant with RFC2410.
ian@0 10 *
ian@0 11 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
ian@0 12 *
ian@0 13 * This program is free software; you can redistribute it and/or modify
ian@0 14 * it under the terms of the GNU General Public License as published by
ian@0 15 * the Free Software Foundation; either version 2 of the License, or
ian@0 16 * (at your option) any later version.
ian@0 17 *
ian@0 18 */
ian@0 19 #include <linux/init.h>
ian@0 20 #include <linux/module.h>
ian@0 21 #include <linux/mm.h>
ian@0 22 #include <asm/scatterlist.h>
ian@0 23 #include <linux/crypto.h>
ian@0 24 #include <linux/string.h>
ian@0 25
ian@0 26 #define NULL_KEY_SIZE 0
ian@0 27 #define NULL_BLOCK_SIZE 1
ian@0 28 #define NULL_DIGEST_SIZE 0
ian@0 29
ian@0 30 static int null_compress(struct crypto_tfm *tfm, const u8 *src,
ian@0 31 unsigned int slen, u8 *dst, unsigned int *dlen)
ian@0 32 {
ian@0 33 if (slen > *dlen)
ian@0 34 return -EINVAL;
ian@0 35 memcpy(dst, src, slen);
ian@0 36 *dlen = slen;
ian@0 37 return 0;
ian@0 38 }
ian@0 39
ian@0 40 static void null_init(struct crypto_tfm *tfm)
ian@0 41 { }
ian@0 42
ian@0 43 static void null_update(struct crypto_tfm *tfm, const u8 *data,
ian@0 44 unsigned int len)
ian@0 45 { }
ian@0 46
ian@0 47 static void null_final(struct crypto_tfm *tfm, u8 *out)
ian@0 48 { }
ian@0 49
ian@0 50 static int null_setkey(struct crypto_tfm *tfm, const u8 *key,
ian@0 51 unsigned int keylen, u32 *flags)
ian@0 52 { return 0; }
ian@0 53
ian@0 54 static void null_crypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
ian@0 55 {
ian@0 56 memcpy(dst, src, NULL_BLOCK_SIZE);
ian@0 57 }
ian@0 58
ian@0 59 static struct crypto_alg compress_null = {
ian@0 60 .cra_name = "compress_null",
ian@0 61 .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
ian@0 62 .cra_blocksize = NULL_BLOCK_SIZE,
ian@0 63 .cra_ctxsize = 0,
ian@0 64 .cra_module = THIS_MODULE,
ian@0 65 .cra_list = LIST_HEAD_INIT(compress_null.cra_list),
ian@0 66 .cra_u = { .compress = {
ian@0 67 .coa_compress = null_compress,
ian@0 68 .coa_decompress = null_compress } }
ian@0 69 };
ian@0 70
ian@0 71 static struct crypto_alg digest_null = {
ian@0 72 .cra_name = "digest_null",
ian@0 73 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
ian@0 74 .cra_blocksize = NULL_BLOCK_SIZE,
ian@0 75 .cra_ctxsize = 0,
ian@0 76 .cra_module = THIS_MODULE,
ian@0 77 .cra_list = LIST_HEAD_INIT(digest_null.cra_list),
ian@0 78 .cra_u = { .digest = {
ian@0 79 .dia_digestsize = NULL_DIGEST_SIZE,
ian@0 80 .dia_init = null_init,
ian@0 81 .dia_update = null_update,
ian@0 82 .dia_final = null_final } }
ian@0 83 };
ian@0 84
ian@0 85 static struct crypto_alg cipher_null = {
ian@0 86 .cra_name = "cipher_null",
ian@0 87 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
ian@0 88 .cra_blocksize = NULL_BLOCK_SIZE,
ian@0 89 .cra_ctxsize = 0,
ian@0 90 .cra_module = THIS_MODULE,
ian@0 91 .cra_list = LIST_HEAD_INIT(cipher_null.cra_list),
ian@0 92 .cra_u = { .cipher = {
ian@0 93 .cia_min_keysize = NULL_KEY_SIZE,
ian@0 94 .cia_max_keysize = NULL_KEY_SIZE,
ian@0 95 .cia_setkey = null_setkey,
ian@0 96 .cia_encrypt = null_crypt,
ian@0 97 .cia_decrypt = null_crypt } }
ian@0 98 };
ian@0 99
ian@0 100 MODULE_ALIAS("compress_null");
ian@0 101 MODULE_ALIAS("digest_null");
ian@0 102 MODULE_ALIAS("cipher_null");
ian@0 103
ian@0 104 static int __init init(void)
ian@0 105 {
ian@0 106 int ret = 0;
ian@0 107
ian@0 108 ret = crypto_register_alg(&cipher_null);
ian@0 109 if (ret < 0)
ian@0 110 goto out;
ian@0 111
ian@0 112 ret = crypto_register_alg(&digest_null);
ian@0 113 if (ret < 0) {
ian@0 114 crypto_unregister_alg(&cipher_null);
ian@0 115 goto out;
ian@0 116 }
ian@0 117
ian@0 118 ret = crypto_register_alg(&compress_null);
ian@0 119 if (ret < 0) {
ian@0 120 crypto_unregister_alg(&digest_null);
ian@0 121 crypto_unregister_alg(&cipher_null);
ian@0 122 goto out;
ian@0 123 }
ian@0 124
ian@0 125 out:
ian@0 126 return ret;
ian@0 127 }
ian@0 128
ian@0 129 static void __exit fini(void)
ian@0 130 {
ian@0 131 crypto_unregister_alg(&compress_null);
ian@0 132 crypto_unregister_alg(&digest_null);
ian@0 133 crypto_unregister_alg(&cipher_null);
ian@0 134 }
ian@0 135
ian@0 136 module_init(init);
ian@0 137 module_exit(fini);
ian@0 138
ian@0 139 MODULE_LICENSE("GPL");
ian@0 140 MODULE_DESCRIPTION("Null Cryptographic Algorithms");