On Tue, Oct 29, 2013, cellecial wrote:
>
> I have a problem with i2d_ASN1_BIT_STRING().
> If I set data with a 0x00-terminated string , i2d_ASN1_BIT_STRING() will
> trim off 0x00.
>
Usually a BIT STRING is a, err, string of bits and DER dictates that trailing
zero bits are removed. In some case
Thank you, I rewrite the code ,but 0x00 is still trimmed off.
int main()
{
unsigned char *buf = NULL,*temp_buf = NULL;
int buflen = 128;
ASN1_BIT_STRING *bs = NULL,*bs2 = NULL;
int i = 0,j = 0;
int ret = 0;
int derlen = 0;
unsigned char *p = NULL;
buf = OPENSSL_malloc(150);
temp_buf = OPE
You are comparing the native form to the DER encoding. You need to d2i back
and see that the data is preserved.
Not only is “the 0x00 trimmed” but those bytes at the front 03 81 80 01 are
also a clue. ☺
/r$
--
Principal Security Engineer
Akamai Technology
Cambridge, MA