Also known as the answer to FAQ #16: http://www.openssl.org/support/faq.html#PROG16
Have fun! Patrick. On 2011-01-04, at 7:32 AM, Martin Kaiser wrote: > Hello, > > Thus wrote [email protected] ([email protected]): > >> Could you please help me to find source code for the functions >> i2d_RSAPrivateKey, d2i_RSAPrivateKey, i2d_RSAPublicKey, >> d2i_RSAPublicKey ? > > these functions are declared and implemented using macros. > > crypto/rsa/rsa.h contains the declarations > > DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) > DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) > > the macro itself is in crypto/asn1/asn1.h > #define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ > type *d2i_##name(type **a, const unsigned char **in, long len); \ > int i2d_##name(const type *a, unsigned char **out); \ > DECLARE_ASN1_ITEM(name) > > > the macro for the implementation is in crypto/rsa/rsa_asn1.c > > IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPrivateKey, RSAPrivateKey) > IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPublicKey, RSAPublicKey) > > it's defined in crypto/asn1/asn1t.h as > > #define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ > stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ > { \ > return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, > ASN1_ITEM_rptr(itname));\ > } \ > int i2d_##fname(const stname *a, unsigned char **out) \ > { \ > return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ > } > > > In other words: You're basically looking for ASN1_item_d2i() and > ASN1_item_i2d(), respectively. > > Best regards, > > Martin > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > Development Mailing List [email protected] > Automated List Manager [email protected] --- Patrick Patterson Chief PKI Architect Carillon Information Security Inc. http://www.carillon.ca ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List [email protected] Automated List Manager [email protected]
