diff options
author | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-11-16 07:27:01 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-11-16 07:27:01 -0200 |
commit | 5096a469f3f9cca036d3ed147b8a01fcd3d2ef20 (patch) | |
tree | 50a07d35f4a47620c4c611db434bf4fce05b9260 /crypto/rsa_helper.c | |
parent | 64af4a27c71a2e29a1ea4f7ee1848dec09f146df (diff) | |
parent | d3dd09594f91ee57e76cbc27023b214afa01a99a (diff) | |
download | linux-crypto-5096a469f3f9cca036d3ed147b8a01fcd3d2ef20.tar.gz linux-crypto-5096a469f3f9cca036d3ed147b8a01fcd3d2ef20.zip |
Merge tag 'v4.4-rc1' into patchwork
Linux 4.4-rc1
* tag 'v4.4-rc1': (12900 commits)
Linux 4.4-rc1
ARC: Fix silly typo in MAINTAINERS file
ARC: cpu_relax() to be compiler barrier even for UP
ARC: use ASL assembler mnemonic
ARC: [arcompact] Handle bus error from userspace as Interrupt not exception
ARC: remove extraneous header include
f2fs: xattr simplifications
squashfs: xattr simplifications
9p: xattr simplifications
xattr handlers: Pass handler to operations instead of flags
jffs2: Add missing capability check for listing trusted xattrs
hfsplus: Remove unused xattr handler list operations
ubifs: Remove unused security xattr handler
vfs: Fix the posix_acl_xattr_list return value
vfs: Check attribute names in posix acl xattr handers
mpt3sas: fix inline markers on non inline function declarations
dax: fix __dax_pmd_fault crash
Revert "drm/rockchip: Convert the probe function to the generic drm_of_component_probe()"
drm: Don't oops in drm_calc_timestamping_constants() if drm_vblank_init() wasn't called
ALSA: pci: depend on ZONE_DMA
...
Diffstat (limited to 'crypto/rsa_helper.c')
-rw-r--r-- | crypto/rsa_helper.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/crypto/rsa_helper.c b/crypto/rsa_helper.c index 8d96ce96..d226f48d 100644 --- a/crypto/rsa_helper.c +++ b/crypto/rsa_helper.c @@ -15,7 +15,8 @@ #include <linux/err.h> #include <linux/fips.h> #include <crypto/internal/rsa.h> -#include "rsakey-asn1.h" +#include "rsapubkey-asn1.h" +#include "rsaprivkey-asn1.h" int rsa_get_n(void *context, size_t hdrlen, unsigned char tag, const void *value, size_t vlen) @@ -94,8 +95,8 @@ void rsa_free_key(struct rsa_key *key) EXPORT_SYMBOL_GPL(rsa_free_key); /** - * rsa_parse_key() - extracts an rsa key from BER encoded buffer - * and stores it in the provided struct rsa_key + * rsa_parse_pub_key() - extracts an rsa public key from BER encoded buffer + * and stores it in the provided struct rsa_key * * @rsa_key: struct rsa_key key representation * @key: key in BER format @@ -103,13 +104,13 @@ EXPORT_SYMBOL_GPL(rsa_free_key); * * Return: 0 on success or error code in case of error */ -int rsa_parse_key(struct rsa_key *rsa_key, const void *key, - unsigned int key_len) +int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key, + unsigned int key_len) { int ret; free_mpis(rsa_key); - ret = asn1_ber_decoder(&rsakey_decoder, rsa_key, key, key_len); + ret = asn1_ber_decoder(&rsapubkey_decoder, rsa_key, key, key_len); if (ret < 0) goto error; @@ -118,4 +119,31 @@ error: free_mpis(rsa_key); return ret; } -EXPORT_SYMBOL_GPL(rsa_parse_key); +EXPORT_SYMBOL_GPL(rsa_parse_pub_key); + +/** + * rsa_parse_pub_key() - extracts an rsa private key from BER encoded buffer + * and stores it in the provided struct rsa_key + * + * @rsa_key: struct rsa_key key representation + * @key: key in BER format + * @key_len: length of key + * + * Return: 0 on success or error code in case of error + */ +int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key, + unsigned int key_len) +{ + int ret; + + free_mpis(rsa_key); + ret = asn1_ber_decoder(&rsaprivkey_decoder, rsa_key, key, key_len); + if (ret < 0) + goto error; + + return 0; +error: + free_mpis(rsa_key); + return ret; +} +EXPORT_SYMBOL_GPL(rsa_parse_priv_key); |