diff options
author | Michael Brown <mcb30@ipxe.org> | 2023-06-02 13:49:27 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2023-06-02 13:54:42 +0100 |
commit | b0093571f8bc0207673bb6a6ad5081263e7863b6 (patch) | |
tree | 9328631ee9f4a70c18d339d0ce3d20a9ff49a0d1 /src/crypto/asn1.c | |
parent | 6a7f560e60837fc2ce82a7aa976035656f7d231e (diff) | |
download | ipxe-b0093571f8bc0207673bb6a6ad5081263e7863b6.tar.gz |
[crypto] Add support for PKCS#8 private key format
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/crypto/asn1.c')
-rw-r--r-- | src/crypto/asn1.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/crypto/asn1.c b/src/crypto/asn1.c index 549ee4d86..dc9d1c54d 100644 --- a/src/crypto/asn1.c +++ b/src/crypto/asn1.c @@ -590,6 +590,32 @@ int asn1_signature_algorithm ( const struct asn1_cursor *cursor, } /** + * Check ASN.1 OID-identified algorithm + * + * @v cursor ASN.1 object cursor + * @v expected Expected algorithm + * @ret rc Return status code + */ +int asn1_check_algorithm ( const struct asn1_cursor *cursor, + struct asn1_algorithm *expected ) { + struct asn1_algorithm *actual; + int rc; + + /* Parse algorithm */ + if ( ( rc = asn1_algorithm ( cursor, &actual ) ) != 0 ) + return rc; + + /* Check algorithm matches */ + if ( actual != expected ) { + DBGC ( cursor, "ASN1 %p algorithm %s does not match %s\n", + cursor, actual->name, expected->name ); + return -ENOTTY_ALGORITHM; + } + + return 0; +} + +/** * Parse ASN.1 GeneralizedTime * * @v cursor ASN.1 cursor |