summaryrefslogtreecommitdiffstats
path: root/src/crypto/rsa.c
diff options
context:
space:
mode:
authorMichael Brown2012-05-14 10:54:19 +0200
committerMichael Brown2012-05-14 12:02:38 +0200
commit4aad46ac70933458f118f59506044de35eb9f7cf (patch)
treeebdac8ad53dbfd64df37a9a4d498e2c52c9d733b /src/crypto/rsa.c
parent[crypto] Generalise asn1_{digest,pubkey,signature}_algorithm() (diff)
downloadipxe-4aad46ac70933458f118f59506044de35eb9f7cf.tar.gz
ipxe-4aad46ac70933458f118f59506044de35eb9f7cf.tar.xz
ipxe-4aad46ac70933458f118f59506044de35eb9f7cf.zip
[crypto] Generalise x509_parse_bit_string() to asn1_bit_string()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/crypto/rsa.c')
-rw-r--r--src/crypto/rsa.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/crypto/rsa.c b/src/crypto/rsa.c
index be2696ba..563d6b9b 100644
--- a/src/crypto/rsa.c
+++ b/src/crypto/rsa.c
@@ -241,7 +241,7 @@ static int rsa_parse_integer ( struct rsa_context *context,
*/
static int rsa_init ( void *ctx, const void *key, size_t key_len ) {
struct rsa_context *context = ctx;
- const struct asn1_bit_string *bit_string;
+ struct asn1_bit_string bits;
struct asn1_cursor modulus;
struct asn1_cursor exponent;
struct asn1_cursor cursor;
@@ -274,17 +274,10 @@ static int rsa_init ( void *ctx, const void *key, size_t key_len ) {
asn1_skip ( &cursor, ASN1_SEQUENCE );
/* Enter subjectPublicKey */
- asn1_enter ( &cursor, ASN1_BIT_STRING );
-
- /* Check and skip unused-bits byte of bit string */
- bit_string = cursor.data;
- if ( ( cursor.len < sizeof ( *bit_string ) ) ||
- ( bit_string->unused != 0 ) ) {
- rc = -EINVAL;
+ if ( ( rc = asn1_integral_bit_string ( &cursor, &bits ) ) != 0 )
goto err_parse;
- }
- cursor.data = &bit_string->data;
- cursor.len -= offsetof ( typeof ( *bit_string ), data );
+ cursor.data = bits.data;
+ cursor.len = bits.len;
/* Enter RSAPublicKey */
asn1_enter ( &cursor, ASN1_SEQUENCE );