Remove references to o_time.h
[openssl.git] / crypto / asn1 / i2d_pr.c
index 0ca7b70b16c70e98b7bc6d61fb0439fa511227a2..e398b6266612ead688d0325ae443a32e0178492d 100644 (file)
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/evp.h>
+#include <openssl/x509.h>
 #include "asn1_locl.h"
 
 int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
@@ -67,6 +68,12 @@ int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
                {
                return a->ameth->old_priv_encode(a, pp);
                }
+       if (a->ameth && a->ameth->priv_encode) {
+               PKCS8_PRIV_KEY_INFO *p8 = EVP_PKEY2PKCS8(a);
+               int ret = i2d_PKCS8_PRIV_KEY_INFO(p8,pp);
+               PKCS8_PRIV_KEY_INFO_free(p8);
+               return ret;
+       }       
        ASN1err(ASN1_F_I2D_PRIVATEKEY,ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
        return(-1);
        }