diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-11-25 10:16:54 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-11-25 10:16:54 +0100 |
commit | 1b1126bd023a2bb92699773a1867358067dabcb8 (patch) | |
tree | 6fd56d034e5a154c7992e7855d61691cecd043c4 /ccast/axTLS/asn1.c | |
parent | cb5c7cec4aa1946f75dc3d408eb7f1051f3fb3d4 (diff) | |
parent | f6b8e0eae4374f339487a33e3e4fe5462d5816e1 (diff) |
Update upstream source from tag 'upstream/2.0.0'
Update to upstream version '2.0.0'
with Debian dir e866e6e75661017faaa5331becda76021407390b
Diffstat (limited to 'ccast/axTLS/asn1.c')
-rwxr-xr-x[-rw-r--r--] | ccast/axTLS/asn1.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ccast/axTLS/asn1.c b/ccast/axTLS/asn1.c index b082275..b5e678e 100644..100755 --- a/ccast/axTLS/asn1.c +++ b/ccast/axTLS/asn1.c @@ -201,6 +201,40 @@ int asn1_get_private_key(const uint8_t *buf, int len, RSA_CTX **rsa_ctx) } /** + * Read the modulus and public exponent of an RSA certificate. + */ +int asn1_get_public_key(const uint8_t *cert, int *offset, RSA_CTX **rsa_ctx) +{ + int ret = X509_NOT_OK, mod_len, pub_len; + uint8_t *modulus = NULL, *pub_exp = NULL; + int len; + + /* Hmm. Not checking that the two ints are within the squence ... */ + if ((len = asn1_next_obj(cert, offset, ASN1_SEQUENCE)) < 0) + goto end_pub_key; + + if ((mod_len = asn1_get_int(cert, offset, &modulus)) <= 0) { + ret = X509_INVALID_PUB_KEY; + goto end_pub_key; + } + if ((pub_len = asn1_get_int(cert, offset, &pub_exp)) <= 0) { + free(modulus); + ret = X509_INVALID_PUB_KEY; + goto end_pub_key; + } + + RSA_pub_key_new(rsa_ctx, modulus, mod_len, pub_exp, pub_len); + + free(modulus); + free(pub_exp); + + ret = X509_OK; + +end_pub_key: + return ret; +} + +/** * Get the time of a certificate. Ignore hours/minutes/seconds. */ static int asn1_get_utc_time(const uint8_t *buf, int *offset, time_t *t) |