You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
crypto: rsa - RSA padding algorithm
This patch adds PKCS#1 v1.5 standard RSA padding as a separate template. This way an RSA cipher with padding can be obtained by instantiating "pkcs1pad(rsa)". The reason for adding this is that RSA is almost never used without this padding (or OAEP) so it will be needed for either certificate work in the kernel or the userspace, and I also hear that it is likely implemented by hardware RSA in which case hardware implementations of the whole of pkcs1pad(rsa) can be provided. Signed-off-by: Andrew Zaborowski <andrew.zaborowski@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
28a4618ad1
commit
3d5b1ecdea
@@ -40,6 +40,7 @@ rsa_generic-y := rsapubkey-asn1.o
|
||||
rsa_generic-y += rsaprivkey-asn1.o
|
||||
rsa_generic-y += rsa.o
|
||||
rsa_generic-y += rsa_helper.o
|
||||
rsa_generic-y += rsa-pkcs1pad.o
|
||||
obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
|
||||
|
||||
cryptomgr-y := algboss.o testmgr.o
|
||||
|
||||
617
crypto/rsa-pkcs1pad.c
Normal file
617
crypto/rsa-pkcs1pad.c
Normal file
File diff suppressed because it is too large
Load Diff
16
crypto/rsa.c
16
crypto/rsa.c
@@ -13,6 +13,7 @@
|
||||
#include <crypto/internal/rsa.h>
|
||||
#include <crypto/internal/akcipher.h>
|
||||
#include <crypto/akcipher.h>
|
||||
#include <crypto/algapi.h>
|
||||
|
||||
/*
|
||||
* RSAEP function [RFC3447 sec 5.1.1]
|
||||
@@ -315,11 +316,24 @@ static struct akcipher_alg rsa = {
|
||||
|
||||
static int rsa_init(void)
|
||||
{
|
||||
return crypto_register_akcipher(&rsa);
|
||||
int err;
|
||||
|
||||
err = crypto_register_akcipher(&rsa);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = crypto_register_template(&rsa_pkcs1pad_tmpl);
|
||||
if (err) {
|
||||
crypto_unregister_akcipher(&rsa);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rsa_exit(void)
|
||||
{
|
||||
crypto_unregister_template(&rsa_pkcs1pad_tmpl);
|
||||
crypto_unregister_akcipher(&rsa);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,4 +27,6 @@ int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
|
||||
unsigned int key_len);
|
||||
|
||||
void rsa_free_key(struct rsa_key *rsa_key);
|
||||
|
||||
extern struct crypto_template rsa_pkcs1pad_tmpl;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user