From e4a4226f5d9fcf584fefafab6ee4d7d924c39c25 Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 22 Feb 2017 11:48:14 -0500 Subject: [PATCH] small change in error handling --- crypto/encoding/x509.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crypto/encoding/x509.c b/crypto/encoding/x509.c index 00ccb8c..482b693 100644 --- a/crypto/encoding/x509.c +++ b/crypto/encoding/x509.c @@ -82,17 +82,17 @@ int libp2p_crypto_encoding_x509_der_to_private_key(unsigned char* der, size_t de private_key->P = *(rsa->P.p); private_key->Q = *(rsa->Q.p); private_key->QP = *(rsa->QP.p); + + // now put the public DER format in. + private_key->der = malloc(sizeof(char) * der_length); + if (private_key->der == NULL) + return 0; + memcpy(private_key->der, der, der_length); + private_key->der_length = der_length; + + //NOTE: the public DER stuff is done in rsa.c } - // now put the public DER format in. - private_key->der = malloc(sizeof(char) * der_length); - if (private_key->der == NULL) - return 0; - memcpy(private_key->der, der, der_length); - private_key->der_length = der_length; - - //NOTE: the public DER stuff is done in rsa.c - mbedtls_pk_free(&ctx); return retVal >= 0;