Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: provide single place for hash algo information

This patch provides a single place for information about hash algorithms,
such as hash sizes and kernel driver names, which will be used by IMA
and the public key code.

Changelog:
- Fix sparse and checkpatch warnings
- Move hash algo enums to uapi for userspace signing functions.

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Dmitry Kasatkin and committed by
Mimi Zohar
ee08997f 08de59eb

+137
+3
crypto/Kconfig
··· 1386 1386 This option enables the user-spaces interface for symmetric 1387 1387 key cipher algorithms. 1388 1388 1389 + config CRYPTO_HASH_INFO 1390 + bool 1391 + 1389 1392 source "drivers/crypto/Kconfig" 1390 1393 source crypto/asymmetric_keys/Kconfig 1391 1394
+1
crypto/Makefile
··· 104 104 obj-$(CONFIG_XOR_BLOCKS) += xor.o 105 105 obj-$(CONFIG_ASYNC_CORE) += async_tx/ 106 106 obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/ 107 + obj-$(CONFIG_CRYPTO_HASH_INFO) += hash_info.o
+56
crypto/hash_info.c
··· 1 + /* 2 + * Hash Info: Hash algorithms information 3 + * 4 + * Copyright (c) 2013 Dmitry Kasatkin <d.kasatkin@samsung.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License as published by the Free 8 + * Software Foundation; either version 2 of the License, or (at your option) 9 + * any later version. 10 + * 11 + */ 12 + 13 + #include <linux/export.h> 14 + #include <crypto/hash_info.h> 15 + 16 + const char *const hash_algo_name[HASH_ALGO__LAST] = { 17 + [HASH_ALGO_MD4] = "md4", 18 + [HASH_ALGO_MD5] = "md5", 19 + [HASH_ALGO_SHA1] = "sha1", 20 + [HASH_ALGO_RIPE_MD_160] = "rmd160", 21 + [HASH_ALGO_SHA256] = "sha256", 22 + [HASH_ALGO_SHA384] = "sha384", 23 + [HASH_ALGO_SHA512] = "sha512", 24 + [HASH_ALGO_SHA224] = "sha224", 25 + [HASH_ALGO_RIPE_MD_128] = "rmd128", 26 + [HASH_ALGO_RIPE_MD_256] = "rmd256", 27 + [HASH_ALGO_RIPE_MD_320] = "rmd320", 28 + [HASH_ALGO_WP_256] = "wp256", 29 + [HASH_ALGO_WP_384] = "wp384", 30 + [HASH_ALGO_WP_512] = "wp512", 31 + [HASH_ALGO_TGR_128] = "tgr128", 32 + [HASH_ALGO_TGR_160] = "tgr160", 33 + [HASH_ALGO_TGR_192] = "tgr192", 34 + }; 35 + EXPORT_SYMBOL_GPL(hash_algo_name); 36 + 37 + const int hash_digest_size[HASH_ALGO__LAST] = { 38 + [HASH_ALGO_MD4] = MD5_DIGEST_SIZE, 39 + [HASH_ALGO_MD5] = MD5_DIGEST_SIZE, 40 + [HASH_ALGO_SHA1] = SHA1_DIGEST_SIZE, 41 + [HASH_ALGO_RIPE_MD_160] = RMD160_DIGEST_SIZE, 42 + [HASH_ALGO_SHA256] = SHA256_DIGEST_SIZE, 43 + [HASH_ALGO_SHA384] = SHA384_DIGEST_SIZE, 44 + [HASH_ALGO_SHA512] = SHA512_DIGEST_SIZE, 45 + [HASH_ALGO_SHA224] = SHA224_DIGEST_SIZE, 46 + [HASH_ALGO_RIPE_MD_128] = RMD128_DIGEST_SIZE, 47 + [HASH_ALGO_RIPE_MD_256] = RMD256_DIGEST_SIZE, 48 + [HASH_ALGO_RIPE_MD_320] = RMD320_DIGEST_SIZE, 49 + [HASH_ALGO_WP_256] = WP256_DIGEST_SIZE, 50 + [HASH_ALGO_WP_384] = WP384_DIGEST_SIZE, 51 + [HASH_ALGO_WP_512] = WP512_DIGEST_SIZE, 52 + [HASH_ALGO_TGR_128] = TGR128_DIGEST_SIZE, 53 + [HASH_ALGO_TGR_160] = TGR160_DIGEST_SIZE, 54 + [HASH_ALGO_TGR_192] = TGR192_DIGEST_SIZE, 55 + }; 56 + EXPORT_SYMBOL_GPL(hash_digest_size);
+40
include/crypto/hash_info.h
··· 1 + /* 2 + * Hash Info: Hash algorithms information 3 + * 4 + * Copyright (c) 2013 Dmitry Kasatkin <d.kasatkin@samsung.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License as published by the Free 8 + * Software Foundation; either version 2 of the License, or (at your option) 9 + * any later version. 10 + * 11 + */ 12 + 13 + #ifndef _CRYPTO_HASH_INFO_H 14 + #define _CRYPTO_HASH_INFO_H 15 + 16 + #include <crypto/sha.h> 17 + #include <crypto/md5.h> 18 + 19 + #include <uapi/linux/hash_info.h> 20 + 21 + /* not defined in include/crypto/ */ 22 + #define RMD128_DIGEST_SIZE 16 23 + #define RMD160_DIGEST_SIZE 20 24 + #define RMD256_DIGEST_SIZE 32 25 + #define RMD320_DIGEST_SIZE 40 26 + 27 + /* not defined in include/crypto/ */ 28 + #define WP512_DIGEST_SIZE 64 29 + #define WP384_DIGEST_SIZE 48 30 + #define WP256_DIGEST_SIZE 32 31 + 32 + /* not defined in include/crypto/ */ 33 + #define TGR128_DIGEST_SIZE 16 34 + #define TGR160_DIGEST_SIZE 20 35 + #define TGR192_DIGEST_SIZE 24 36 + 37 + extern const char *const hash_algo_name[HASH_ALGO__LAST]; 38 + extern const int hash_digest_size[HASH_ALGO__LAST]; 39 + 40 + #endif /* _CRYPTO_HASH_INFO_H */
+37
include/uapi/linux/hash_info.h
··· 1 + /* 2 + * Hash Info: Hash algorithms information 3 + * 4 + * Copyright (c) 2013 Dmitry Kasatkin <d.kasatkin@samsung.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License as published by the Free 8 + * Software Foundation; either version 2 of the License, or (at your option) 9 + * any later version. 10 + * 11 + */ 12 + 13 + #ifndef _UAPI_LINUX_HASH_INFO_H 14 + #define _UAPI_LINUX_HASH_INFO_H 15 + 16 + enum hash_algo { 17 + HASH_ALGO_MD4, 18 + HASH_ALGO_MD5, 19 + HASH_ALGO_SHA1, 20 + HASH_ALGO_RIPE_MD_160, 21 + HASH_ALGO_SHA256, 22 + HASH_ALGO_SHA384, 23 + HASH_ALGO_SHA512, 24 + HASH_ALGO_SHA224, 25 + HASH_ALGO_RIPE_MD_128, 26 + HASH_ALGO_RIPE_MD_256, 27 + HASH_ALGO_RIPE_MD_320, 28 + HASH_ALGO_WP_256, 29 + HASH_ALGO_WP_384, 30 + HASH_ALGO_WP_512, 31 + HASH_ALGO_TGR_128, 32 + HASH_ALGO_TGR_160, 33 + HASH_ALGO_TGR_192, 34 + HASH_ALGO__LAST 35 + }; 36 + 37 + #endif /* _UAPI_LINUX_HASH_INFO_H */