Move sign hash functions to library
This patch enables package managers, such as rpm, to include IMA signatures in packages. To do this, sign_hash and some helper functions were moved from evmctl to libimaevm. These functions used global variables that belong to evmctl, sigdump and keypass. The variable sigdump is a flag that file signatures should be printed to stdout, so the signature dump is now handled by functions that call sign_hash. The variable keypass is a passphrase for an encrypted key, so it was added to 'struct libevm_params'. v2: Uses 'struct libevm_params' to minimize sign_hash parameters v3: Export single sign_hash function that selects _v1 or _v2 internally based on params.x509. Moved parameter checks and explicitly return -1 for failures. Signed-off-by: Fionnuala Gunter <fin@linux.vnet.ibm.com> Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
This commit is contained in:

committed by
Dmitry Kasatkin

parent
29adc34d35
commit
8f04d131ac
@ -170,8 +170,10 @@ typedef int (*verify_hash_fn_t)(const unsigned char *hash, int size, unsigned ch
|
||||
|
||||
struct libevm_params {
|
||||
int verbose;
|
||||
int x509;
|
||||
const char *hash_algo;
|
||||
char *keyfile;
|
||||
char *keypass;
|
||||
};
|
||||
|
||||
struct RSA_ASN1_template {
|
||||
@ -189,6 +191,11 @@ int ima_calc_hash(const char *file, uint8_t *hash);
|
||||
int get_hash_algo(const char *algo);
|
||||
RSA *read_pub_key(const char *keyfile, int x509);
|
||||
|
||||
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, 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);
|
||||
|
||||
|
Reference in New Issue
Block a user