summaryrefslogtreecommitdiff
path: root/ccast/axTLS/asn1.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-12-03 20:38:41 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-12-03 20:38:41 +0100
commitba627dd9ecb578e9852c7b9cce67ec63199d1acf (patch)
tree27c4258311ca8c8ed7ff67a8a0bc7280e8fcae79 /ccast/axTLS/asn1.c
parent69aec3b712232e93600ecd741269fed1f90b412a (diff)
parent3abb40d43649adb3807180692d8579c405524675 (diff)
Merge branch 'release/2.0.0+repack-1'2.0.0+repack-1
Diffstat (limited to 'ccast/axTLS/asn1.c')
-rwxr-xr-x[-rw-r--r--]ccast/axTLS/asn1.c34
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)