Commit b1775147 authored by Pau Espin Pedrol's avatar Pau Espin Pedrol Committed by Mouse

aper: Update spec references for length determinants

What's seems to be newish available ITU-T X.691 (02/2021),
has the related section at 11.9, not 10.9.
parent f8a1af4a
......@@ -32,14 +32,14 @@ aper_get_length(asn_per_data_t *pd, int range, int ebits, int *repeat) {
value = per_get_few_bits(pd, 8);
if(value < 0) return -1;
if((value & 128) == 0) /* #10.9.3.6 */
if((value & 128) == 0) /* #11.9.3.6 */
return (value & 0x7F);
if((value & 64) == 0) { /* #10.9.3.7 */
if((value & 64) == 0) { /* #11.9.3.7 */
value = ((value & 63) << 8) | per_get_few_bits(pd, 8);
if(value < 0) return -1;
return value;
}
value &= 63; /* this is "m" from X.691, #10.9.3.8 */
value &= 63; /* this is "m" from X.691, #11.9.3.8 */
if(value < 1 || value > 4)
return -1;
*repeat = 1;
......@@ -162,18 +162,18 @@ aper_put_length(asn_per_outp_t *po, int range, size_t length, int *need_eom) {
ASN_DEBUG("APER put length %zu with range %d", length, range);
/* 10.9 X.691 Note 2 */
/* 11.9 X.691 Note 2 */
if (range <= 65536 && range >= 0)
return aper_put_nsnnwn(po, range, length) ? -1 : (ssize_t)length;
if (aper_put_align(po) < 0)
return -1;
if(length <= 127) { /* #10.9.3.6 */
if(length <= 127) { /* #11.9.3.6 */
return per_put_few_bits(po, length, 8)
? -1 : (ssize_t)length;
}
else if(length < 16384) /* #10.9.3.7 */
else if(length < 16384) /* #11.9.3.7 */
return per_put_few_bits(po, length|0x8000, 16)
? -1 : (ssize_t)length;
......@@ -193,7 +193,7 @@ int
aper_put_nslength(asn_per_outp_t *po, size_t length) {
if(length <= 64) {
/* #10.9.3.4 */
/* #11.9.3.4 */
if(length == 0) return -1;
return per_put_few_bits(po, length-1, 7) ? -1 : 0;
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment