Hi Steve, Viktor, I have tried with len also, But this also causing seg fault. my requiremnt is to store max 2048 bit keys. Hence I used length as 512 +1. currently i ma getting len value = 28514. X509_SIG sig; X509_ALGOR algor; ASN1_OCTET_STRING digest; ASN1_TYPE parameter; ASN1_item_digest() // to get digest details sig.algor = &algor; sig.algor->algorithm=OBJ_nid2obj(NID_md5); parameter.type=V_ASN1_NULL; parameter.value.ptr=NULL; sig.algor->parameter = ¶meter; sig.digest = &digest; sig.digest->data=(unsigned char*)msg; sig.digest->length=datalen; len = i2d_X509_SIG(&sig,NULL); Thanks, Gayathri On Mon, Feb 2, 2015 at 9:31 PM, Viktor Dukhovni <openssl-users at dukhovni.org> wrote: > On Mon, Feb 02, 2015 at 07:15:12PM +0530, Gayathri Manoj wrote: > > > unsigned char *ptr, *tmp=NULL; > > X509_SIG sig; > > .... > > How is "sig" initialized? > > > len=i2d_X509_SIG(sig,NULL); > > tmp = (unsigned char*) malloc(513); > > Why 513 and not len? What is the value of len? > > > ptr=tmp; > > i2d_X509_SIG(&sig, &ptr); // here causing problem. > > -- > Viktor. > _______________________________________________ > openssl-users mailing list > To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20150203/6d4f9248/attachment.html>