On Mon May 27, 2024 at 6:45 AM EEST, Ben Boeckel wrote:
> On Fri, May 24, 2024 at 09:04:54 -0400, James Bottomley wrote:
> > diff --git a/include/linux/tpm.h b/include/linux/tpm.h
> > index c17e4efbb2e5..07f532456a0c 100644
> > --- a/include/linux/tpm.h
> > +++ b/include/linux/tpm.h
> > @@ -418,11 +418,61 @@ enum tpm2_session_attributes {
> > TPM2_SA_AUDIT = BIT(7),
> > };
> >
> > -struct tpm2_hash {
> > +static const struct {
> > unsigned int crypto_id;
> > unsigned int tpm_id;
> > +} tpm2_hash_map[] = {
> > + {HASH_ALGO_SHA1, TPM_ALG_SHA1},
> > + {HASH_ALGO_SHA256, TPM_ALG_SHA256},
> > + {HASH_ALGO_SHA384, TPM_ALG_SHA384},
> > + {HASH_ALGO_SHA512, TPM_ALG_SHA512},
> > + {HASH_ALGO_SM3_256, TPM_ALG_SM3_256},
> > };
> >
> > +/**
> > + * tpm2_crypto_to_alg() - convert a crypto hash to a TPM alg id
>
> Should "alg id" be "algorithm id" everwhere in the docs?
tpm2_hash_algorithm_from() would work for me.
> > + *
> > + * @hash: the crypto subsystem view of the hash
It is an instance of &hash_algo not "crypto subsystem view of the hash".
> > + *
> > + * Return: TPM algorithm id or -1 if no mapping was found.
> > + */
> > +static inline int tpm2_crypto_to_alg(int hash)
>
> How about naming this `crypto_id`?
It really should be @hash_info, which an instance of &hash_info.
Despite comments, this patch set will be ignored up until hmac
encryption needs no active attention and asymmetric keys have been
landed.
BR, Jarkko