asn1: Add support for encoding large values in OIDs

This commit is contained in:
Jakub Jelen 2019-10-17 14:15:49 +02:00
parent 7971bfded3
commit 61af2c1d0a
1 changed files with 6 additions and 3 deletions

View File

@ -891,10 +891,13 @@ sc_asn1_encode_object_id(u8 **buf, size_t *buflen, const struct sc_object_id *id
*p = k * 40; *p = k * 40;
break; break;
case 1: case 1:
if (k > 39) if (k > 39 && id->value[0] < 2) {
return SC_ERROR_INVALID_ARGUMENTS; return SC_ERROR_INVALID_ARGUMENTS;
*p++ += k; }
break; /* We can encode larger IDs to multiple bytes
* similarly as the following IDs */
k += *p;
/* fall through */
default: default:
shift = 28; shift = 28;
while (shift && (k >> shift) == 0) while (shift && (k >> shift) == 0)