[PATCH V4 01/15] asymmetric keys: add interface and skeleton for implement signature generation

2013-09-14 Thread Lee, Chun-Yi
Add generate_signature interface on signature.c, asymmetric-subtype and rsa.c for prepare to implement signature generation. Reviewed-by: Jiri Kosina Signed-off-by: Lee, Chun-Yi --- crypto/asymmetric_keys/private_key.h | 29 + crypto/asymmetric_keys/public_key.c |

[PATCH V4 03/15] asymmetric keys: separate the length checking of octet string from RSA_I2OSP

2013-09-14 Thread Lee, Chun-Yi
Due to RSA_I2OSP is not only used by signature verification path but also used in signature generation path. So, separate the length checking of octet string because it's not for generate 0x00 0x01 leading string when used in signature generation. The naming of _RSA_I2OSP and the variables used in

[PATCH V4 02/15] asymmetric keys: implement EMSA_PKCS1-v1_5-ENCODE in rsa

2013-09-14 Thread Lee, Chun-Yi
Implement EMSA_PKCS1-v1_5-ENCODE [RFC3447 sec 9.2] in rsa.c. It's the first step of signature generation operation (RSASSA-PKCS1-v1_5-SIGN). This patch is temporary set emLen to pks->k, and temporary set EM to pks->S for debugging. We will replace the above values to real signature after implement

[PATCH 10/15] Hibernate: Avoid S4 sign key data included in snapshot image

2013-09-14 Thread Lee, Chun-Yi
This patch add swsusp_page_is_sign_key() method to hibernate_key.c and check the page is S4 sign key data when collect saveable page in snapshot.c to avoid sign key data included in snapshot image. Reviewed-by: Jiri Kosina Signed-off-by: Lee, Chun-Yi --- kernel/power/snapshot.c |6 ++ 1

[PATCH V4 11/15] Hibernate: taint kernel when signature check fail

2013-09-14 Thread Lee, Chun-Yi
We will not direct fail the hibernate snapshot restore when the signature check fail, instead kernel will complain by warning message and taint kernel. This patch also introduced a sig_enforce flag to indicate if we want direct fail the snapshot restore when signature check fail. User can enable i

[PATCH V4 07/15] asymmetric keys: explicitly add the leading zero byte to encoded message

2013-09-14 Thread Lee, Chun-Yi
Per PKCS1 spec, the EMSA-PKCS1-v1_5 encoded message is leading by 0x00 0x01 in its first 2 bytes. The leading zero byte is suppressed by MPI so we pass a pointer to the _preceding_ byte to RSA_verify() in original code, but it has risk for the byte is not zero because it's not in EM buffer's scope,

[PATCH V4 05/15] asymmetric keys: implement RSASP1

2013-09-14 Thread Lee, Chun-Yi
Implement RSASP1 and fill-in the following data to public key signature structure: signature length (pkcs->k), signature octet strings (pks->S) and MPI of signature (pks->rsa.s). The naming of RSASP1 and the variables used in this function accord PKCS#1 spec but not follow kernel naming convention

[PATCH V4 08/15] Hibernate: introduced RSA key-pair to verify signature of snapshot

2013-09-14 Thread Lee, Chun-Yi
Introduced a hibernate_key.c file to query the key pair from EFI variables and maintain key pair for check signature of S4 snapshot image. We loaded the private key when snapshot image stored success. This patch introduced 2 EFI variables for store the key to sign S4 image and verify signature whe

[PATCH V4 06/15] asymmetric keys: support parsing PKCS #8 private key information

2013-09-14 Thread Lee, Chun-Yi
Add ASN.1 files and parser to support parsing PKCS #8 noncompressed private key information. It's better than direct parsing pure private key because PKCS #8 has a privateKeyAlgorithm to indicate the algorithm of private key, e.g. RSA from PKCS #1 v2: - Removed bitfield declare of privkey_algo in

[PATCH V4 04/15] asymmetric keys: implement OS2IP in rsa

2013-09-14 Thread Lee, Chun-Yi
Implement Octet String to Integer conversion [RFC3447 sec 4.2] in rsa.c. It's the second step of signature generation operation. This patch is temporary set non-RSASP1 message to pks->S for debugging. The naming of RSA_OS2IP and the variables used in this function accord PKCS#1 spec but not follo

[PATCH V4 09/15] Hibernate: generate and verify signature of snapshot

2013-09-14 Thread Lee, Chun-Yi
This patch add the code for generate/verify signature of snapshot, it put the signature to snapshot header. This approach can support both on userspace hibernate and in-kernel hibernate. v3: - Change the naming of SIG_LENG to SIG_LEN - Extracts the code of signature generation code from copy_data_

[PATCH V4 15/15] Hibernate: adapt to UEFI secure boot with signature check

2013-09-14 Thread Lee, Chun-Yi
Base on Matthew Garrett's 2 patches in "[PATCH] Add additional security checks when module loading is restricted" series [PATCH 01/10] Add secure_modules() call [PATCH V3 11/11] Add option to automatically enforce module signatures when in Secure Boot mode This patch introduced EFI_SECURE_BO

[PATCH V4 13/15] Hibernate: introduced SNAPSHOT_SIG_HASH config for select hash algorithm

2013-09-14 Thread Lee, Chun-Yi
This patch introduced SNAPSHOT_SIG_HASH config for user to select which hash algorithm will be used during signature generation of snapshot. v2: Add define check of oCONFIG_SNAPSHOT_VERIFICATION in snapshot.c before declare pkey_hash(). Reviewed-by: Jiri Kosina Signed-off-by: Lee, Chun-Yi ---

[PATCH V4 12/15] Hibernate: show the verification time for monitor performance

2013-09-14 Thread Lee, Chun-Yi
Show the verification time for monitor the performance of SHA256 and RSA verification. Reviewed-by: Jiri Kosina Signed-off-by: Lee, Chun-Yi --- kernel/power/snapshot.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.

[PATCH V4 14/15] Hibernate: notify bootloader regenerate key-pair for snapshot verification

2013-09-14 Thread Lee, Chun-Yi
This patch introduced SNAPSHOT_REGEN_KEYS kernel config, enable this option let kernel notify booloader (e.g. shim) to regenerate key-pair of snapshot verification for each hibernate. Kernel loaded S4 sign key in efi stub, so the private key forward from efi bootloader to kernel in UEFI secure env

[RFC V4 PATCH 00/15] Signature verification of hibernate snapshot

2013-09-14 Thread Lee, Chun-Yi
Hi experts, This patchset is the implementation for signature verification of hibernate snapshot image. The origin idea is from Jiri Kosina: Let EFI bootloader generate key-pair in UEFI secure boot environment, then pass it to kernel for sign/verify S4 image. Due to there have potential threat fr

Re: [RFC PATCH 2/2] arm64: add support for AES using ARMv8 Crypto Extensions

2013-09-14 Thread Jussi Kivilinna
On 14.09.2013 16:30, Ard Biesheuvel wrote: > On 14 September 2013 10:08, Jussi Kivilinna wrote: >> On 13.09.2013 18:08, Ard Biesheuvel wrote: >>> This adds ARMv8 Crypto Extensions based implemenations of >>> AES in CBC, CTR and XTS mode. >>> >>> Signed-off-by: Ard Biesheuvel >>> --- >> ..snip.. >

Re: [RFC PATCH 2/2] arm64: add support for AES using ARMv8 Crypto Extensions

2013-09-14 Thread Ard Biesheuvel
On 14 September 2013 10:08, Jussi Kivilinna wrote: > On 13.09.2013 18:08, Ard Biesheuvel wrote: >> This adds ARMv8 Crypto Extensions based implemenations of >> AES in CBC, CTR and XTS mode. >> >> Signed-off-by: Ard Biesheuvel >> --- > ..snip.. >> +static int xts_set_key(struct crypto_tfm *tfm, co

[PATCH] crypto: move ablk_helper out of arch/x86

2013-09-14 Thread Ard Biesheuvel
Move the ablk_helper code out of arch/x86 so it can be reused by other architectures. The only x86 specific dependency is a call to irq_fpu_usable(), in the generic case we use !in_interrupt() instead. Cc: jussi.kivili...@iki.fi Signed-off-by: Ard Biesheuvel --- Any need to split this up between

Re: [RFC PATCH 2/2] arm64: add support for AES using ARMv8 Crypto Extensions

2013-09-14 Thread Jussi Kivilinna
On 13.09.2013 18:08, Ard Biesheuvel wrote: > This adds ARMv8 Crypto Extensions based implemenations of > AES in CBC, CTR and XTS mode. > > Signed-off-by: Ard Biesheuvel > --- ..snip.. > +static int xts_set_key(struct crypto_tfm *tfm, const u8 *in_key, > +unsigned int key_len)

Re: [RFC PATCH 1/2] crypto: move ablk_helper out of arch/x86

2013-09-14 Thread Jussi Kivilinna
On 13.09.2013 18:08, Ard Biesheuvel wrote: > Move the ablk_helper code out of arch/x86 so it can be reused > by other architectures. The only x86 specific dependency was > a call to irq_fpu_usable(), this has been factored out and moved > to crypto/ablk_helper_x86.c > > Signed-off-by: Ard Biesheuv