Re: [PATCH v8 10/10] integrity: support EC-RDSA signatures for asymmetric_verify

From: Mimi Zohar
Date: Wed Mar 27 2019 - 15:12:12 EST


On Tue, 2019-03-26 at 15:58 +0300, Vitaly Chikunov wrote:
> Allow to use EC-RDSA signatures for IMA by determining signature type by
> the hash algorithm name. This works good for EC-RDSA since Streebog and
> EC-RDSA should always be used together.
>
> Cc: Mimi Zohar <zohar@xxxxxxxxxxxxx>
> Cc: Dmitry Kasatkin <dmitry.kasatkin@xxxxxxxxx>
> Cc: linux-integrity@xxxxxxxxxxxxxxx
> Signed-off-by: Vitaly Chikunov <vt@xxxxxxxxxxxx>
> ---
> security/integrity/digsig_asymmetric.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/security/integrity/digsig_asymmetric.c b/security/integrity/digsig_asymmetric.c
> index d775e03fbbcc..99080871eb9f 100644
> --- a/security/integrity/digsig_asymmetric.c
> +++ b/security/integrity/digsig_asymmetric.c
> @@ -104,9 +104,16 @@ int asymmetric_verify(struct key *keyring, const char *sig,
>
> memset(&pks, 0, sizeof(pks));
>
> - pks.pkey_algo = "rsa";
> pks.hash_algo = hash_algo_name[hdr->hash_algo];
> - pks.encoding = "pkcs1";
> + if (hdr->hash_algo == HASH_ALGO_STREEBOG_256 ||
> + hdr->hash_algo == HASH_ALGO_STREEBOG_512) {
> + /* EC-RDSA and Streebog should go together. */
> + pks.pkey_algo = "ecrdsa";
> + pks.encoding = "raw";

IMA signatures are stored as xattrs, making them persistent. ÂSupport
for streebog was upstreamed in linux-5.0. ÂThis change would break
existing systems using streebog. ÂAs long as this is not yet a concern

Reviewed-by: ÂMimi Zohar <zohar@xxxxxxxxxxxxx>

> + } else {
> + pks.pkey_algo = "rsa";
> + pks.encoding = "pkcs1";
> + }
> pks.digest = (u8 *)data;
> pks.digest_size = datalen;
> pks.s = hdr->sig;