diff mbox series

[RFC,v3,04/13] keys: Add new verification type (VERIFYING_CLAVIS_SIGNATURE)

Message ID 20241017155516.2582369-5-eric.snowberg@oracle.com (mailing list archive)
State New
Delegated to: Paul Moore
Headers show
Series Clavis LSM | expand

Commit Message

Eric Snowberg Oct. 17, 2024, 3:55 p.m. UTC
Add a new verification type called VERIFYING_CLAVIS_SIGNATURE.  This new
usage will be used for validating keys added to the new clavis LSM keyring.
This will be introduced in a follow-on patch.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 crypto/asymmetric_keys/asymmetric_type.c | 1 +
 crypto/asymmetric_keys/pkcs7_verify.c    | 1 +
 include/linux/verification.h             | 2 ++
 3 files changed, 4 insertions(+)

Comments

Jarkko Sakkinen Oct. 17, 2024, 7:20 p.m. UTC | #1
On Thu, 2024-10-17 at 09:55 -0600, Eric Snowberg wrote:
> Add a new verification type called VERIFYING_CLAVIS_SIGNATURE.  This
> new
> usage will be used for validating keys added to the new clavis LSM
> keyring.
> This will be introduced in a follow-on patch.
> 
> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
> ---
>  crypto/asymmetric_keys/asymmetric_type.c | 1 +
>  crypto/asymmetric_keys/pkcs7_verify.c    | 1 +
>  include/linux/verification.h             | 2 ++
>  3 files changed, 4 insertions(+)
> 
> diff --git a/crypto/asymmetric_keys/asymmetric_type.c
> b/crypto/asymmetric_keys/asymmetric_type.c
> index 43af5fa510c0..d7bf95c77f4a 100644
> --- a/crypto/asymmetric_keys/asymmetric_type.c
> +++ b/crypto/asymmetric_keys/asymmetric_type.c
> @@ -25,6 +25,7 @@ const char *const
> key_being_used_for[NR__KEY_BEING_USED_FOR] = {
>  	[VERIFYING_KEY_SIGNATURE]		= "key sig",
>  	[VERIFYING_KEY_SELF_SIGNATURE]		= "key self sig",
>  	[VERIFYING_UNSPECIFIED_SIGNATURE]	= "unspec sig",
> +	[VERIFYING_CLAVIS_SIGNATURE]		= "clavis sig",
>  };
>  EXPORT_SYMBOL_GPL(key_being_used_for);
>  
> diff --git a/crypto/asymmetric_keys/pkcs7_verify.c
> b/crypto/asymmetric_keys/pkcs7_verify.c
> index f0d4ff3c20a8..1dc80e68ce96 100644
> --- a/crypto/asymmetric_keys/pkcs7_verify.c
> +++ b/crypto/asymmetric_keys/pkcs7_verify.c
> @@ -428,6 +428,7 @@ int pkcs7_verify(struct pkcs7_message *pkcs7,
>  		}
>  		/* Authattr presence checked in parser */
>  		break;
> +	case VERIFYING_CLAVIS_SIGNATURE:
>  	case VERIFYING_UNSPECIFIED_SIGNATURE:
>  		if (pkcs7->data_type != OID_data) {
>  			pr_warn("Invalid unspecified sig (not pkcs7-
> data)\n");
> diff --git a/include/linux/verification.h
> b/include/linux/verification.h
> index cb2d47f28091..02d2d70e2324 100644
> --- a/include/linux/verification.h
> +++ b/include/linux/verification.h
> @@ -36,6 +36,8 @@ enum key_being_used_for {
>  	VERIFYING_KEY_SIGNATURE,
>  	VERIFYING_KEY_SELF_SIGNATURE,
>  	VERIFYING_UNSPECIFIED_SIGNATURE,
> +	/* Add new entries above, keep VERIFYING_CLAVIS_SIGNATURE at
> the end. */
> +	VERIFYING_CLAVIS_SIGNATURE,
>  	NR__KEY_BEING_USED_FOR
>  };
>  extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];

This looks as good as it can get. Just wondering that does this Clavis
thing connect with the TPM2 asymmetric keys that I've been working on?
I.e. can they be used in tandem. I should really update that patch set
(latest from April).

BR, Jarkko
Eric Snowberg Oct. 17, 2024, 9:42 p.m. UTC | #2
> On Oct 17, 2024, at 1:20 PM, Jarkko Sakkinen <jarkko@kernel.org> wrote:
> 
> On Thu, 2024-10-17 at 09:55 -0600, Eric Snowberg wrote:
>> Add a new verification type called VERIFYING_CLAVIS_SIGNATURE.  This
>> new
>> usage will be used for validating keys added to the new clavis LSM
>> keyring.
>> This will be introduced in a follow-on patch.
>> 
>> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
>> ---
>>  crypto/asymmetric_keys/asymmetric_type.c | 1 +
>>  crypto/asymmetric_keys/pkcs7_verify.c    | 1 +
>>  include/linux/verification.h             | 2 ++
>>  3 files changed, 4 insertions(+)
>> 
>> diff --git a/crypto/asymmetric_keys/asymmetric_type.c
>> b/crypto/asymmetric_keys/asymmetric_type.c
>> index 43af5fa510c0..d7bf95c77f4a 100644
>> --- a/crypto/asymmetric_keys/asymmetric_type.c
>> +++ b/crypto/asymmetric_keys/asymmetric_type.c
>> @@ -25,6 +25,7 @@ const char *const
>> key_being_used_for[NR__KEY_BEING_USED_FOR] = {
>>   [VERIFYING_KEY_SIGNATURE] = "key sig",
>>   [VERIFYING_KEY_SELF_SIGNATURE] = "key self sig",
>>   [VERIFYING_UNSPECIFIED_SIGNATURE] = "unspec sig",
>> + [VERIFYING_CLAVIS_SIGNATURE] = "clavis sig",
>>  };
>>  EXPORT_SYMBOL_GPL(key_being_used_for);
>>  
>> diff --git a/crypto/asymmetric_keys/pkcs7_verify.c
>> b/crypto/asymmetric_keys/pkcs7_verify.c
>> index f0d4ff3c20a8..1dc80e68ce96 100644
>> --- a/crypto/asymmetric_keys/pkcs7_verify.c
>> +++ b/crypto/asymmetric_keys/pkcs7_verify.c
>> @@ -428,6 +428,7 @@ int pkcs7_verify(struct pkcs7_message *pkcs7,
>>   }
>>   /* Authattr presence checked in parser */
>>   break;
>> + case VERIFYING_CLAVIS_SIGNATURE:
>>   case VERIFYING_UNSPECIFIED_SIGNATURE:
>>   if (pkcs7->data_type != OID_data) {
>>   pr_warn("Invalid unspecified sig (not pkcs7-
>> data)\n");
>> diff --git a/include/linux/verification.h
>> b/include/linux/verification.h
>> index cb2d47f28091..02d2d70e2324 100644
>> --- a/include/linux/verification.h
>> +++ b/include/linux/verification.h
>> @@ -36,6 +36,8 @@ enum key_being_used_for {
>>   VERIFYING_KEY_SIGNATURE,
>>   VERIFYING_KEY_SELF_SIGNATURE,
>>   VERIFYING_UNSPECIFIED_SIGNATURE,
>> + /* Add new entries above, keep VERIFYING_CLAVIS_SIGNATURE at
>> the end. */
>> + VERIFYING_CLAVIS_SIGNATURE,
>>   NR__KEY_BEING_USED_FOR
>>  };
>>  extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
> 
> This looks as good as it can get. Just wondering that does this Clavis
> thing connect with the TPM2 asymmetric keys that I've been working on?
> I.e. can they be used in tandem. I should really update that patch set
> (latest from April).

With some changes, I think they could be used in tandem.  If I'm looking at 
the correct series, tpm2_key_rsa_describe would need to be changed to 
return a unique identifier, instead of "TPM2/RSA".  This identifier could be 
used instead of the skid when creating a Clavis ACL.  There would probably 
also need to be a new system kernel keyring containing these TPM keys. 
Similar to the builtin, secondary, machine, etc.
Jarkko Sakkinen Oct. 17, 2024, 9:58 p.m. UTC | #3
On Thu, 2024-10-17 at 21:42 +0000, Eric Snowberg wrote:
> 
> 
> > On Oct 17, 2024, at 1:20 PM, Jarkko Sakkinen <jarkko@kernel.org>
> > wrote:
> > 
> > On Thu, 2024-10-17 at 09:55 -0600, Eric Snowberg wrote:
> > > Add a new verification type called VERIFYING_CLAVIS_SIGNATURE. 
> > > This
> > > new
> > > usage will be used for validating keys added to the new clavis
> > > LSM
> > > keyring.
> > > This will be introduced in a follow-on patch.
> > > 
> > > Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
> > > ---
> > >  crypto/asymmetric_keys/asymmetric_type.c | 1 +
> > >  crypto/asymmetric_keys/pkcs7_verify.c    | 1 +
> > >  include/linux/verification.h             | 2 ++
> > >  3 files changed, 4 insertions(+)
> > > 
> > > diff --git a/crypto/asymmetric_keys/asymmetric_type.c
> > > b/crypto/asymmetric_keys/asymmetric_type.c
> > > index 43af5fa510c0..d7bf95c77f4a 100644
> > > --- a/crypto/asymmetric_keys/asymmetric_type.c
> > > +++ b/crypto/asymmetric_keys/asymmetric_type.c
> > > @@ -25,6 +25,7 @@ const char *const
> > > key_being_used_for[NR__KEY_BEING_USED_FOR] = {
> > >   [VERIFYING_KEY_SIGNATURE] = "key sig",
> > >   [VERIFYING_KEY_SELF_SIGNATURE] = "key self sig",
> > >   [VERIFYING_UNSPECIFIED_SIGNATURE] = "unspec sig",
> > > + [VERIFYING_CLAVIS_SIGNATURE] = "clavis sig",
> > >  };
> > >  EXPORT_SYMBOL_GPL(key_being_used_for);
> > >  
> > > diff --git a/crypto/asymmetric_keys/pkcs7_verify.c
> > > b/crypto/asymmetric_keys/pkcs7_verify.c
> > > index f0d4ff3c20a8..1dc80e68ce96 100644
> > > --- a/crypto/asymmetric_keys/pkcs7_verify.c
> > > +++ b/crypto/asymmetric_keys/pkcs7_verify.c
> > > @@ -428,6 +428,7 @@ int pkcs7_verify(struct pkcs7_message *pkcs7,
> > >   }
> > >   /* Authattr presence checked in parser */
> > >   break;
> > > + case VERIFYING_CLAVIS_SIGNATURE:
> > >   case VERIFYING_UNSPECIFIED_SIGNATURE:
> > >   if (pkcs7->data_type != OID_data) {
> > >   pr_warn("Invalid unspecified sig (not pkcs7-
> > > data)\n");
> > > diff --git a/include/linux/verification.h
> > > b/include/linux/verification.h
> > > index cb2d47f28091..02d2d70e2324 100644
> > > --- a/include/linux/verification.h
> > > +++ b/include/linux/verification.h
> > > @@ -36,6 +36,8 @@ enum key_being_used_for {
> > >   VERIFYING_KEY_SIGNATURE,
> > >   VERIFYING_KEY_SELF_SIGNATURE,
> > >   VERIFYING_UNSPECIFIED_SIGNATURE,
> > > + /* Add new entries above, keep VERIFYING_CLAVIS_SIGNATURE at
> > > the end. */
> > > + VERIFYING_CLAVIS_SIGNATURE,
> > >   NR__KEY_BEING_USED_FOR
> > >  };
> > >  extern const char *const
> > > key_being_used_for[NR__KEY_BEING_USED_FOR];
> > 
> > This looks as good as it can get. Just wondering that does this
> > Clavis
> > thing connect with the TPM2 asymmetric keys that I've been working
> > on?
> > I.e. can they be used in tandem. I should really update that patch
> > set
> > (latest from April).
> 
> With some changes, I think they could be used in tandem.  If I'm
> looking at 
> the correct series, tpm2_key_rsa_describe would need to be changed to
> return a unique identifier, instead of "TPM2/RSA".  This identifier
> could be 
> used instead of the skid when creating a Clavis ACL.  There would
> probably 
> also need to be a new system kernel keyring containing these TPM
> keys. 
> Similar to the builtin, secondary, machine, etc.

I think when I finally get into working on this again I focus on
purely to get ECDSA right. Thanks for the tip, most likely this
revamp will happen post your patch set. I'm still busy fixing
corner cases with the bus encryption that James Bottomley
contributed.

BR, Jarkko
diff mbox series

Patch

diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index 43af5fa510c0..d7bf95c77f4a 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -25,6 +25,7 @@  const char *const key_being_used_for[NR__KEY_BEING_USED_FOR] = {
 	[VERIFYING_KEY_SIGNATURE]		= "key sig",
 	[VERIFYING_KEY_SELF_SIGNATURE]		= "key self sig",
 	[VERIFYING_UNSPECIFIED_SIGNATURE]	= "unspec sig",
+	[VERIFYING_CLAVIS_SIGNATURE]		= "clavis sig",
 };
 EXPORT_SYMBOL_GPL(key_being_used_for);
 
diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
index f0d4ff3c20a8..1dc80e68ce96 100644
--- a/crypto/asymmetric_keys/pkcs7_verify.c
+++ b/crypto/asymmetric_keys/pkcs7_verify.c
@@ -428,6 +428,7 @@  int pkcs7_verify(struct pkcs7_message *pkcs7,
 		}
 		/* Authattr presence checked in parser */
 		break;
+	case VERIFYING_CLAVIS_SIGNATURE:
 	case VERIFYING_UNSPECIFIED_SIGNATURE:
 		if (pkcs7->data_type != OID_data) {
 			pr_warn("Invalid unspecified sig (not pkcs7-data)\n");
diff --git a/include/linux/verification.h b/include/linux/verification.h
index cb2d47f28091..02d2d70e2324 100644
--- a/include/linux/verification.h
+++ b/include/linux/verification.h
@@ -36,6 +36,8 @@  enum key_being_used_for {
 	VERIFYING_KEY_SIGNATURE,
 	VERIFYING_KEY_SELF_SIGNATURE,
 	VERIFYING_UNSPECIFIED_SIGNATURE,
+	/* Add new entries above, keep VERIFYING_CLAVIS_SIGNATURE at the end. */
+	VERIFYING_CLAVIS_SIGNATURE,
 	NR__KEY_BEING_USED_FOR
 };
 extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];