[winpr,asn1] fix writing integers
ASN1 integers are signed.
This commit is contained in:
parent
dc76879e0b
commit
d232037e18
@ -538,11 +538,10 @@ static size_t asn1IntegerLen(WinPrAsn1_INTEGER value)
|
||||
static size_t WinPrAsn1EncIntegerLike(WinPrAsn1Encoder* enc, WinPrAsn1_tag b,
|
||||
WinPrAsn1_INTEGER value)
|
||||
{
|
||||
wStream staticS;
|
||||
wStream staticS = { 0 };
|
||||
wStream* s = &staticS;
|
||||
size_t len = 0;
|
||||
|
||||
len = asn1IntegerLen(value);
|
||||
const size_t len = asn1IntegerLen(value);
|
||||
if (!asn1_getWriteStream(enc, 1 + len, s))
|
||||
return 0;
|
||||
|
||||
@ -551,15 +550,15 @@ static size_t WinPrAsn1EncIntegerLike(WinPrAsn1Encoder* enc, WinPrAsn1_tag b,
|
||||
{
|
||||
case 2:
|
||||
Stream_Write_UINT8(s, 1);
|
||||
Stream_Write_UINT8(s, value);
|
||||
Stream_Write_INT8(s, value);
|
||||
break;
|
||||
case 3:
|
||||
Stream_Write_UINT8(s, 2);
|
||||
Stream_Write_UINT16_BE(s, value);
|
||||
Stream_Write_INT16_BE(s, value);
|
||||
break;
|
||||
case 5:
|
||||
Stream_Write_UINT8(s, 4);
|
||||
Stream_Write_UINT32_BE(s, value);
|
||||
Stream_Write_INT32_BE(s, value);
|
||||
break;
|
||||
}
|
||||
return 1 + len;
|
||||
@ -578,17 +577,14 @@ size_t WinPrAsn1EncEnumerated(WinPrAsn1Encoder* enc, WinPrAsn1_ENUMERATED value)
|
||||
static size_t WinPrAsn1EncContextualIntegerLike(WinPrAsn1Encoder* enc, WinPrAsn1_tag tag,
|
||||
WinPrAsn1_tagId tagId, WinPrAsn1_INTEGER value)
|
||||
{
|
||||
wStream staticS;
|
||||
wStream staticS = { 0 };
|
||||
wStream* s = &staticS;
|
||||
size_t len = 0;
|
||||
size_t outLen = 0;
|
||||
|
||||
WINPR_ASSERT(enc);
|
||||
WINPR_ASSERT_VALID_TAG(tagId);
|
||||
|
||||
len = asn1IntegerLen(value);
|
||||
|
||||
outLen = 1 + lenBytes(1 + len) + (1 + len);
|
||||
const size_t len = asn1IntegerLen(value);
|
||||
const size_t outLen = 1 + lenBytes(1 + len) + (1 + len);
|
||||
if (!asn1_getWriteStream(enc, outLen, s))
|
||||
return 0;
|
||||
|
||||
@ -600,15 +596,15 @@ static size_t WinPrAsn1EncContextualIntegerLike(WinPrAsn1Encoder* enc, WinPrAsn1
|
||||
{
|
||||
case 2:
|
||||
Stream_Write_UINT8(s, 1);
|
||||
Stream_Write_UINT8(s, value);
|
||||
Stream_Write_INT8(s, value);
|
||||
break;
|
||||
case 3:
|
||||
Stream_Write_UINT8(s, 2);
|
||||
Stream_Write_UINT16_BE(s, value);
|
||||
Stream_Write_INT16_BE(s, value);
|
||||
break;
|
||||
case 5:
|
||||
Stream_Write_UINT8(s, 4);
|
||||
Stream_Write_UINT32_BE(s, value);
|
||||
Stream_Write_INT32_BE(s, value);
|
||||
break;
|
||||
}
|
||||
return outLen;
|
||||
|
Loading…
Reference in New Issue
Block a user