[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Bit String Error
Chris,
This code has been fixed but not released as of yet. The new function looks like this and should be available in the eSNACC 2.0 release which will be available in the September time frame.
AsnLen BEncAsnBitsContent(GenBuf* pBuf, AsnBits* pBits)
{
unsigned long byteLen;
unsigned char unusedBits;
/* Check for invalid parameters */
if ((pBuf == NULL) || (pBits == NULL))
return 0;
/* Calculate number of bytes and number of unused bits */
byteLen = (pBits->bitLen + 7) / 8;
unusedBits = (unsigned char)(pBits->bitLen % 8);
if (unusedBits != 0)
unusedBits = 8 - unusedBits;
BufPutSegRvs(pBuf, pBits->bits, byteLen);
BufPutByteRvs(pBuf, unusedBits);
return byteLen + 1;
} /* end of BEncAsnBitsContent() */
Regards,
Tom
________________________________________
From: owner-imc-snacc@xxxxxxxxxxxx [mailto:owner-imc-snacc@xxxxxxxxxxxx] On Behalf Of Christopher.J.Demattio@xxxxxxxxxxx
Sent: Thursday, July 28, 2005 1:36 PM
To: imc-snacc@xxxxxxx
Subject: Bit String Error
Hello,
I am using SNACC to encode a simple bit string whose maximum length is 4 bits. If only bit zero is set (corresponding to a hex value of 0x80), the bit string encodes as:
0x03, 0x01, 0x80
In my understanding, I believe that it should encode as
0x03, 0x02, 0x07, 0x80
Is my understanding correct? If so, I think there is a bug in the asn-bits.c module. The offending code is located in BEncAsnBitsContent:
/* check for special DER encoding rules to return 03 01 00 not
03 02 07 00 RWC */
if (((bits->bits[0] != 0) || (byteLen > 1)) && (unusedBits != 7))
{
BufPutByteRvs (b, (unsigned char)unusedBits);
return byteLen + 1;
}
else
return byteLen;
While I can't comment on what the code is trying to avoid here, it looks to me like the "(unusedBits != 7)" check is erroneously keeping the code from writing out the number of unused bits for this case.
Can you please advise?
Regards,
Chris