int len = i2d_X509(x, NULL); unsigned char *buf, *p; buf = (unsigned char *)malloc(len); p = buf; i2d_X509(x, &p); *out = (char *)buf; *outlen = len;
if(sec && !publicOnly) { int len = i2d_RSAPrivateKey(sec, NULL); unsigned char *buf, *p; buf = (unsigned char *)malloc(len); p = buf; i2d_RSAPrivateKey(sec, &p); *out = (char *)buf; *outlen = len; } else if(pub) { int len = i2d_RSAPublicKey(pub, NULL); unsigned char *buf, *p; buf = (unsigned char *)malloc(len); p = buf; i2d_RSAPublicKey(pub, &p); *out = (char *)buf; *outlen = len; } else { *out = 0; *outlen = 0; }
	void toDER(char **out, unsigned int *outlen)	{		int len = i2d_X509(x, NULL);		unsigned char *buf, *p;		buf = (unsigned char *)malloc(len);		p = buf;		i2d_X509(x, &p);		*out = (char *)buf;		*outlen = len;	}