Re: [EXTERNAL] [PATCH v2 2/6] lib: Expand asn1_encode_integer() to variable size integers

2024-05-20 Thread Jarkko Sakkinen
On Tue May 21, 2024 at 8:36 AM EEST, Bharat Bhushan wrote: > > - data_len -= 2; > > + (*data++) = _tag(UNIV, PRIM, INT); > > Just for my clarification: > First index of "data" is updated here with tag and data pointer > incremented. > Next comment for continuation > > > + data_l

RE: [EXTERNAL] [PATCH v2 5/6] tpm: tpm2_key: Extend parser to TPM_LoadableKey

2024-05-20 Thread Bharat Bhushan
> -Original Message- > From: Jarkko Sakkinen > Sent: Tuesday, May 21, 2024 8:47 AM > To: Herbert Xu > Cc: linux-integr...@vger.kernel.org; keyri...@vger.kernel.org; > andreas.fu...@infineon.com; James Prestwood ; > David Woodhouse ; Eric Biggers > ; James Bottomley > ; Jarkko Sakkinen

RE: [EXTERNAL] [PATCH v2 2/6] lib: Expand asn1_encode_integer() to variable size integers

2024-05-20 Thread Bharat Bhushan
> -Original Message- > From: Jarkko Sakkinen > Sent: Tuesday, May 21, 2024 8:46 AM > To: Herbert Xu > Cc: linux-integr...@vger.kernel.org; keyri...@vger.kernel.org; > andreas.fu...@infineon.com; James Prestwood ; > David Woodhouse ; Eric Biggers > ; James Bottomley > ; Jarkko Sakkinen > ;

[PATCH v2 6/6] keys: asymmetric: ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE

2024-05-20 Thread Jarkko Sakkinen
From: James Prestwood Based on earlier work by James Prestwood. Add ASN.1 compatible asymmetric TPM2 RSA key subtype: 1. Signing and decryption (with the private key) is handled by TPM2_RSA_Decrypt. 2. Encryption (with the public key) is handled by the kernel RSA implementation. Link: ht

[PATCH v2 5/6] tpm: tpm2_key: Extend parser to TPM_LoadableKey

2024-05-20 Thread Jarkko Sakkinen
Extend parser to TPM_LoadableKey. Add field for oid to struct tpm2_key so that callers can differentiate different key types. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm2_key.c | 14 +++--- include/crypto/tpm2_key.h | 2 ++ security/keys/trusted

[PATCH v2 4/6] KEYS: trusted: Move tpm2_key_decode() to the TPM driver

2024-05-20 Thread Jarkko Sakkinen
Move tpm2_key_decode() to the TPM driver and export the symbols to make them callable from trusted keys. It can re-used for asymmetric keys. Signed-off-by: Jarkko Sakkinen --- v2: Do not allocate blob twice. Use the one inside struct tpm2_key. --- drivers/char/tpm/Kconfig |

[PATCH v2 3/6] tpm: Export tpm2_load_context()

2024-05-20 Thread Jarkko Sakkinen
Export tpm2_load_context() so that the null key can be loaded as the parent of a asymmetric TPM2 key. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm.h| 2 - drivers/char/tpm/tpm2-cmd.c | 77 +++ drivers/char/tpm/tpm2-space.c | 61 --

[PATCH v2 2/6] lib: Expand asn1_encode_integer() to variable size integers

2024-05-20 Thread Jarkko Sakkinen
Expand asn1_encode_integer() to variable size integers, meaning that it will get a blob in big-endian format as integer and length of the blob as parameters. This is required in order to encode RSA public key modulus. Signed-off-by: Jarkko Sakkinen --- include/linux/asn1_encoder.h |

[PATCH v2 1/6] crypto: rsa-pkcs1pad: export rsa1_asn_lookup()

2024-05-20 Thread Jarkko Sakkinen
ASN.1 template is required for TPM2 asymmetric keys, as it needs to be piggy-packed with the input data before applying TPM2_RSA_Decrypt. This patch prepares crypto subsystem for the addition of those keys. Signed-off-by: Jarkko Sakkinen --- crypto/rsa-pkcs1pad.c | 16 ++-- i

[PATCH v2 0/6] KEYS: asymmetric: tpm2_key_rsa

2024-05-20 Thread Jarkko Sakkinen
## Overview Introduce tpm2_key_rsa module, which implements asymmetric TPM2 RSA key. The feature can be enabled with the CONFIG_ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE kconfig option. The idea in the design is to over time to have submodule per key type For instance, tpm2_key_ecdsa could be one potentia

[v2 PATCH] crypto: api - Do not load modules if called by async probing

2024-05-20 Thread Herbert Xu
On Mon, May 20, 2024 at 11:49:56AM -0400, NĂ­colas F. R. A. Prado wrote: > > Unfortunately this patch didn't work either. The warning is still there > unchanged. OK perhaps we can do it by calling current_is_async ourselves. But this is really a nasty hack because it basically defeats the whole poi

Re: [PATCH 0/6] KEYS: asymmetric: tpm2_key_rsa

2024-05-20 Thread Jarkko Sakkinen
On Mon May 20, 2024 at 11:36 PM EEST, Jarkko Sakkinen wrote: > On Mon May 20, 2024 at 9:47 PM EEST, Jarkko Sakkinen wrote: > > ## Overview > > > > Introduce tpm2_key_rsa implementing asymmetric TPM RSA key. This key type > > can be enabled with CONFIG_ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE config option.

Re: [PATCH 0/6] KEYS: asymmetric: tpm2_key_rsa

2024-05-20 Thread Jarkko Sakkinen
On Mon May 20, 2024 at 9:47 PM EEST, Jarkko Sakkinen wrote: > ## Overview > > Introduce tpm2_key_rsa implementing asymmetric TPM RSA key. This key type > can be enabled with CONFIG_ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE config option. > Carves groundwork for similar modules in future, such as tpm2_key_ecd

[PATCH 6/6] keys: asymmetric: ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE

2024-05-20 Thread Jarkko Sakkinen
From: James Prestwood Based on earlier work by James Prestwood. Add ASN.1 compatible asymmetric TPM2 RSA key subtype: 1. Signing and decryption (with the private key) is handled by TPM2_RSA_Decrypt. 2. Encryption (with the public key) is handled by the kernel RSA implementation. Link: ht

[PATCH 5/6] tpm: tpm2_key: Extend parser to TPM_LoadableKey

2024-05-20 Thread Jarkko Sakkinen
Extend parser to TPM_LoadableKey. Add field for oid to struct tpm2_key so that callers can differentiate different key types. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm2_key.c | 14 +++--- include/crypto/tpm2_key.h | 2 ++ security/keys/trusted

[PATCH 4/6] KEYS: trusted: Move tpm2_key_decode() to the TPM driver

2024-05-20 Thread Jarkko Sakkinen
Move tpm2_key_decode() to the TPM driver and export the symbols to make them callable from trusted keys. It can re-used for asymmetric keys. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/Kconfig | 1 + drivers/char/tpm/Makefile | 5 + drivers/ch

[PATCH 3/6] tpm: Export tpm2_load_context()

2024-05-20 Thread Jarkko Sakkinen
Export tpm2_load_context() so that the null key can be loaded as the parent of a asymmetric TPM2 key. Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm.h| 2 - drivers/char/tpm/tpm2-cmd.c | 77 +++ drivers/char/tpm/tpm2-space.c | 61 --

[PATCH 2/6] lib: Expand asn1_encode_integer() to variable size integers

2024-05-20 Thread Jarkko Sakkinen
Expand asn1_encode_integer() to variable size integers, meaning that it will get a blob in big-endian format as integer and length of the blob as parameters. This is required in order to encode RSA public key modulus. Signed-off-by: Jarkko Sakkinen --- include/linux/asn1_encoder.h |

[PATCH 1/6] crypto: rsa-pkcs1pad: export rsa1_asn_lookup()

2024-05-20 Thread Jarkko Sakkinen
ASN.1 template is required for TPM2 asymmetric keys, as it needs to be piggy-packed with the input data before applying TPM2_RSA_Decrypt. This patch prepares crypto subsystem for the addition of those keys. Signed-off-by: Jarkko Sakkinen --- crypto/rsa-pkcs1pad.c | 16 ++-- i

[PATCH 0/6] KEYS: asymmetric: tpm2_key_rsa

2024-05-20 Thread Jarkko Sakkinen
## Overview Introduce tpm2_key_rsa implementing asymmetric TPM RSA key. This key type can be enabled with CONFIG_ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE config option. Carves groundwork for similar modules in future, such as tpm2_key_ecdsa. ## Testing tpm2_createprimary --hierarchy o -G rsa2048 -c owner

Re: [PATCH] crypto: api - Do not load modules until algapi is ready

2024-05-20 Thread NĂ­colas F . R . A . Prado
On Sat, May 18, 2024 at 03:03:51PM +0800, Herbert Xu wrote: > On Fri, May 17, 2024 at 09:31:15PM -0700, Eric Biggers wrote: > > > > This is "normal" behavior when the crypto API instantiates a template: > > > > 1. drbg.c asks for "hmac(sha512)" > > > > 2. The crypto API looks for a direct