1
0
mirror of https://git.code.sf.net/p/linux-ima/ima-evm-utils synced 2025-04-28 14:43:37 +02:00

ima-evm-utils: functions/arrays define as static

Make sign_hash_v1(), sign_hash_v2(), get_hash_algo_by_id, and
 pkey_hash_algo[] and pkey_hash_algo_kern[] static.

Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:
Mimi Zohar 2019-07-24 19:32:04 -04:00
parent c317d4618f
commit 28cbfa1769

View File

@ -62,7 +62,7 @@
#include "hash_info.h" #include "hash_info.h"
/* Names that are primary for OpenSSL. */ /* Names that are primary for OpenSSL. */
const char *const pkey_hash_algo[PKEY_HASH__LAST] = { static const char *const pkey_hash_algo[PKEY_HASH__LAST] = {
[PKEY_HASH_MD4] = "md4", [PKEY_HASH_MD4] = "md4",
[PKEY_HASH_MD5] = "md5", [PKEY_HASH_MD5] = "md5",
[PKEY_HASH_SHA1] = "sha1", [PKEY_HASH_SHA1] = "sha1",
@ -76,7 +76,7 @@ const char *const pkey_hash_algo[PKEY_HASH__LAST] = {
}; };
/* Names that are primary for the kernel. */ /* Names that are primary for the kernel. */
const char *const pkey_hash_algo_kern[PKEY_HASH__LAST] = { static const char *const pkey_hash_algo_kern[PKEY_HASH__LAST] = {
[PKEY_HASH_STREEBOG_256] = "streebog256", [PKEY_HASH_STREEBOG_256] = "streebog256",
[PKEY_HASH_STREEBOG_512] = "streebog512", [PKEY_HASH_STREEBOG_512] = "streebog512",
}; };
@ -105,7 +105,7 @@ void imaevm_hexdump(const void *ptr, int len)
imaevm_do_hexdump(stdout, ptr, len, true); imaevm_do_hexdump(stdout, ptr, len, true);
} }
const char *get_hash_algo_by_id(int algo) static const char *get_hash_algo_by_id(int algo)
{ {
if (algo < PKEY_HASH__LAST) if (algo < PKEY_HASH__LAST)
return pkey_hash_algo[algo]; return pkey_hash_algo[algo];
@ -792,7 +792,8 @@ static int get_hash_algo_v1(const char *algo)
return -1; return -1;
} }
int sign_hash_v1(const char *hashalgo, const unsigned char *hash, int size, const char *keyfile, unsigned char *sig) static int sign_hash_v1(const char *hashalgo, const unsigned char *hash,
int size, const char *keyfile, unsigned char *sig)
{ {
int len = -1, hashalgo_idx; int len = -1, hashalgo_idx;
SHA_CTX ctx; SHA_CTX ctx;
@ -877,7 +878,8 @@ out:
* @sig is assumed to be of (MAX_SIGNATURE_SIZE - 1) size * @sig is assumed to be of (MAX_SIGNATURE_SIZE - 1) size
* Return: -1 signing error, >0 length of signature * Return: -1 signing error, >0 length of signature
*/ */
int sign_hash_v2(const char *algo, const unsigned char *hash, int size, const char *keyfile, unsigned char *sig) static int sign_hash_v2(const char *algo, const unsigned char *hash,
int size, const char *keyfile, unsigned char *sig)
{ {
struct signature_v2_hdr *hdr; struct signature_v2_hdr *hdr;
int len = -1; int len = -1;