From 96e55082c24b6f136feb0f3c21aa4f8715023402 Mon Sep 17 00:00:00 2001 From: Dmitry Kasatkin Date: Thu, 23 Jul 2015 21:46:21 +0300 Subject: [PATCH] Must use 'const char*' Signed-off-by: Dmitry Kasatkin --- src/evmctl.c | 9 +++++---- src/imaevm.h | 6 +++--- src/libimaevm.c | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/evmctl.c b/src/evmctl.c index 3097494..5c05024 100644 --- a/src/evmctl.c +++ b/src/evmctl.c @@ -608,7 +608,7 @@ static int cmd_hash_ima(struct command *cmd) static int sign_ima_file(const char *file) { - char *key; + const char *key; key = params.keyfile ? : "/etc/keys/privkey_evm.pem"; @@ -622,7 +622,8 @@ static int cmd_sign_ima(struct command *cmd) static int cmd_sign_hash(struct command *cmd) { - char *key, *token, *line = NULL; + const char *key; + char *token, *line = NULL; int hashlen = 0; size_t line_len; ssize_t len; @@ -665,7 +666,7 @@ static int cmd_sign_hash(struct command *cmd) static int sign_evm_path(const char *file) { - char *key; + const char *key; int err; key = params.keyfile ? : "/etc/keys/privkey_evm.pem"; @@ -1001,7 +1002,7 @@ static int hmac_evm(const char *file, const char *key) static int cmd_hmac_evm(struct command *cmd) { - char *key, *file = g_argv[optind++]; + const char *key, *file = g_argv[optind++]; int err; if (!file) { diff --git a/src/imaevm.h b/src/imaevm.h index 31358ed..711596c 100644 --- a/src/imaevm.h +++ b/src/imaevm.h @@ -178,8 +178,8 @@ struct libevm_params { int verbose; int x509; const char *hash_algo; - char *keyfile; - char *keypass; + const char *keyfile; + const char *keypass; }; struct RSA_ASN1_template { @@ -201,7 +201,7 @@ void calc_keyid_v1(uint8_t *keyid, char *str, const unsigned char *pkey, int len void calc_keyid_v2(uint32_t *keyid, char *str, RSA *key); int key2bin(RSA *key, unsigned char *pub); -int sign_hash(const char *algo, const unsigned char *hash, int size, const char *keyfile, char *keypass, unsigned char *sig); +int sign_hash(const char *algo, const unsigned char *hash, int size, const char *keyfile, const char *keypass, unsigned char *sig); int verify_hash(const unsigned char *hash, int size, unsigned char *sig, int siglen); int ima_verify_signature(const char *file, unsigned char *sig, int siglen); diff --git a/src/libimaevm.c b/src/libimaevm.c index ecd43c9..575f053 100644 --- a/src/libimaevm.c +++ b/src/libimaevm.c @@ -491,7 +491,7 @@ static int get_hash_algo_from_sig(unsigned char *sig) int verify_hash(const unsigned char *hash, int size, unsigned char *sig, int siglen) { - char *key; + const char *key; int x509; verify_hash_fn_t verify_hash; @@ -611,7 +611,7 @@ void calc_keyid_v2(uint32_t *keyid, char *str, RSA *key) free(pkey); } -static RSA *read_priv_key(const char *keyfile, char *keypass) +static RSA *read_priv_key(const char *keyfile, const char *keypass) { FILE *fp; RSA *key; @@ -622,7 +622,7 @@ static RSA *read_priv_key(const char *keyfile, char *keypass) return NULL; } ERR_load_crypto_strings(); - key = PEM_read_RSAPrivateKey(fp, NULL, NULL, keypass); + key = PEM_read_RSAPrivateKey(fp, NULL, NULL, (void *)keypass); if (!key) { char str[256]; @@ -795,7 +795,7 @@ out: } -int sign_hash(const char *hashalgo, const unsigned char *hash, int size, const char *keyfile, char *keypass, unsigned char *sig) +int sign_hash(const char *hashalgo, const unsigned char *hash, int size, const char *keyfile, const char *keypass, unsigned char *sig) { if (keypass) params.keypass = keypass;