]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[crypto] Parse X.509 raw public key bit string
authorMichael Brown <mcb30@ipxe.org>
Fri, 11 May 2012 23:58:42 +0000 (00:58 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sun, 13 May 2012 23:14:27 +0000 (00:14 +0100)
OCSP requires direct access to the bit string portion of the subject
public key information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/crypto/x509.c
src/include/ipxe/x509.h

index 6e3cfeadacc7a3414da0657e44a477f8a3a18db6..cfecfde35181c27d9fce5c37f294c54d890aa6e2 100644 (file)
@@ -632,6 +632,7 @@ static int x509_parse_public_key ( struct x509_certificate *cert,
                                   const struct asn1_cursor *raw ) {
        struct x509_public_key *public_key = &cert->subject.public_key;
        struct asn1_algorithm **algorithm = &public_key->algorithm;
+       struct x509_bit_string *raw_bits = &public_key->raw_bits;
        struct asn1_cursor cursor;
        int rc;
 
@@ -639,6 +640,8 @@ static int x509_parse_public_key ( struct x509_certificate *cert,
        memcpy ( &cursor, raw, sizeof ( cursor ) );
        asn1_shrink_any ( &cursor );
        memcpy ( &public_key->raw, &cursor, sizeof ( public_key->raw ) );
+       DBGC2 ( cert, "X509 %p public key is:\n", cert );
+       DBGC2_HDA ( cert, 0, public_key->raw.data, public_key->raw.len );
 
        /* Enter subjectPublicKeyInfo */
        asn1_enter ( &cursor, ASN1_SEQUENCE );
@@ -649,8 +652,11 @@ static int x509_parse_public_key ( struct x509_certificate *cert,
                return rc;
        DBGC2 ( cert, "X509 %p public key algorithm is %s\n",
                cert, (*algorithm)->name );
-       DBGC2 ( cert, "X509 %p public key is:\n", cert );
-       DBGC2_HDA ( cert, 0, public_key->raw.data, public_key->raw.len );
+       asn1_skip_any ( &cursor );
+
+       /* Parse bit string */
+       if ( ( rc = x509_parse_bit_string ( cert, raw_bits, &cursor ) ) != 0 )
+               return rc;
 
        return 0;
 }
index 8753bb050248aa4fb9a047cbf2988c47a14decf8..a55511b81087ac503714149a3522861c16117bbd 100644 (file)
@@ -54,10 +54,12 @@ struct x509_validity {
 
 /** An X.509 certificate public key */
 struct x509_public_key {
-       /** Raw public key */
+       /** Raw public key information */
        struct asn1_cursor raw;
        /** Public key algorithm */
        struct asn1_algorithm *algorithm;
+       /** Raw public key bit string */
+       struct x509_bit_string raw_bits;
 };
 
 /** An X.509 certificate subject */