Skip to content

Commit ea5316f

Browse files
committed
enforce only int64 integers.
that's all the decoder/encoder can handle right now
1 parent 75e4d92 commit ea5316f

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

share/dictionary/der/dictionary.common

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ END DirectoryName
4242
DEFINE GeneralSubtree sequence
4343
BEGIN GeneralSubtree
4444
DEFINE base sequence clone=GeneralName
45-
DEFINE minimum integer option=0,has_default
45+
DEFINE minimum int64 option=0,has_default
4646
VALUE minimum DEFAULT 0
47-
DEFINE maximum integer option=1
47+
DEFINE maximum int64 option=1
4848
END GeneralSubtree
4949

5050
DEFINE Name sequence

share/dictionary/der/dictionary.extensions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ATTRIBUTE basicConstraints 2.5.29.19 sequence is_oid_leaf
7878
BEGIN 2.5.29.19
7979
DEFINE cA boolean has_default
8080
VALUE cA DEFAULT false
81-
DEFINE pathLenConstraint integer
81+
DEFINE pathLenConstraint int64
8282
END 2.5.29.19
8383

8484
ATTRIBUTE nameConstraints 2.5.29.30 sequence is_oid_leaf
@@ -192,4 +192,4 @@ DEFINE cRLIssuer group ref=GeneralName,subtype=sequence,sequence_of=choice
192192

193193
END distributionPoint
194194

195-
ATTRIBUTE inhibitAnyPolicy 2.5.29.54 integer is_oid_leaf
195+
ATTRIBUTE inhibitAnyPolicy 2.5.29.54 int64 is_oid_leaf

share/dictionary/der/dictionary.rfc2986

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BEGIN CertificateRequest
77

88
DEFINE certificationRequestInfo tlv
99
BEGIN certificationRequestInfo
10-
DEFINE version integer
10+
DEFINE version int64
1111

1212
DEFINE subject tlv
1313
BEGIN subject

share/dictionary/der/dictionary.rfc5280

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DEFINE tbsCertificate tlv
99
BEGIN tbsCertificate
1010
DEFINE version tlv class=context-specific,tagnum=0,subtype=sequence
1111
BEGIN version
12-
DEFINE VersionNum integer
12+
DEFINE VersionNum int64
1313
END version
1414
DEFINE serialNumber octets tagnum=2
1515
DEFINE signature group ref=OID-Tree,is_pair

src/protocols/der/base.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,24 @@ static bool attr_valid(fr_dict_attr_t *da)
418418
return false;
419419
}
420420

421+
/*
422+
* The DER encoder / decoder assume that all pairs are FR_TYPE_INT64.
423+
*
424+
* The "on the wire" DER data has variable-sized encoding for integers,
425+
* and drops leading zeros.
426+
*
427+
* For consistency, we disallow data types which the
428+
* encoder/decoder don't handle. Except for data types
429+
* in structs, because the struct encoder/decoder takes
430+
* care of those.
431+
*/
432+
if (fr_type_is_integer_except_bool(da->type) && (da->type != FR_TYPE_INT64) &&
433+
(da->type != FR_TYPE_DATE) && (da->type != FR_TYPE_TIME_DELTA) &&
434+
(da->parent->type != FR_TYPE_STRUCT)) {
435+
fr_strerror_printf("Only 'int64' is supported by DER");
436+
return false;
437+
}
438+
421439
return true;
422440
}
423441

0 commit comments

Comments
 (0)