Skip to content

Commit 41652a7

Browse files
feat: Wrote unit tests/fuzzer tests for DER
Signed-off-by: ethan-thompson <[email protected]>
1 parent bd3ccad commit 41652a7

File tree

6 files changed

+1192
-1
lines changed

6 files changed

+1192
-1
lines changed

src/bin/all.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SUBMAKEFILES := \
2222
# The fuzzer binary needs special magic to run, as it doesn't parse
2323
# command-line options. See fuzzer.mk for details.
2424
#
25-
FUZZER_PROTOCOLS = radius dhcpv4 dhcpv6 dns tacacs vmps tftp util bfd cbor
25+
FUZZER_PROTOCOLS = radius dhcpv4 dhcpv6 dns tacacs vmps tftp util bfd cbor der
2626

2727
#
2828
# Add the fuzzer only if everything was built with the fuzzing flags.

src/tests/fuzzer-corpus/der.tar

720 KB
Binary file not shown.

src/tests/unit/protocols/der/csrs.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- text -*-
2+
# Copyright (C) 2025 The FreeRADIUS Server project and contributors
3+
# This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0
4+
# Version $Id$
5+
proto der
6+
proto-dictionary der
7+
fuzzer-out der
8+
max-buffer-size 2048
9+
10+
encode-pair CertificateRequest = { certificationRequestInfo = { version = 0, subject = { RelativeDistinguishedName = { AttributeTypeandValue = { OID = "2.5.4.3", Value-Thing = "test" } } }, subjectPublicKeyInfo = { algorithm = { OID = "1.3.101.112" }, subjectPublicKey = 0x00fb16e6bd645fb03d755d0c207042bf80aa7cba385becdb9c19fcfe0bc95b1898 }, Attributes = { Attribute-thing = { OID = "1.2.840.113549.1.9.14", Extensions = { joint-iso-itu-t = { ds = { certificateExtension = { subjectAltName = { otherName = { type-id = "1.3.6.1.4.1.311.20.2.3", Value-thing = { userPrincipalName = "[email protected]" } } } } } } } } } }, signatureAlgorithm = { OID = "1.3.101.112" }, signature = 0x00529e457a71c5d6b67344653eef0885fbf0f56dfc83445d1dcd6cf6b25e389e5b6ef222e31cedda21f393616a6a66568383506adcbec571bec87f8c9902c1390b }
11+
match 30 81 d0 30 81 83 02 01 00 30 0f 31 0d 30 0b 06 03 55 04 03 0c 04 74 65 73 74 30 2a 30 05 06 03 2b 65 70 03 21 00 fb 16 e6 bd 64 5f b0 3d 75 5d 0c 20 70 42 bf 80 aa 7c ba 38 5b ec db 9c 19 fc fe 0b c9 5b 18 98 a0 41 30 3f 06 09 2a 86 48 86 f7 0d 01 09 0e 31 32 30 30 30 2e 06 03 55 1d 11 04 27 30 25 a0 23 06 0a 2b 06 01 04 01 82 37 14 02 03 a0 15 0c 13 61 64 64 72 65 73 73 40 64 6f 6d 61 69 6e 2e 74 65 73 74 30 05 06 03 2b 65 70 03 41 00 52 9e 45 7a 71 c5 d6 b6 73 44 65 3e ef 08 85 fb f0 f5 6d fc 83 44 5d 1d cd 6c f6 b2 5e 38 9e 5b 6e f2 22 e3 1c ed da 21 f3 93 61 6a 6a 66 56 83 83 50 6a dc be c5 71 be c8 7f 8c 99 02 c1 39 0b
12+
13+
proto-dictionary-root CertificateRequest
14+
15+
decode-pair 30 81 D0 30 81 83 02 01 00 30 0F 31 0D 30 0B 06 03 55 04 03 0C 04 74 65 73 74 30 2A 30 05 06 03 2B 65 70 03 21 00 FB 16 E6 BD 64 5F B0 3D 75 5D 0C 20 70 42 BF 80 AA 7C BA 38 5B EC DB 9C 19 FC FE 0B C9 5B 18 98 A0 41 30 3F 06 09 2A 86 48 86 F7 0D 01 09 0E 31 32 30 30 30 2E 06 03 55 1D 11 04 27 30 25 A0 23 06 0A 2B 06 01 04 01 82 37 14 02 03 A0 15 0C 13 61 64 64 72 65 73 73 40 64 6F 6D 61 69 6E 2E 74 65 73 74 30 05 06 03 2B 65 70 03 41 00 52 9E 45 7A 71 C5 D6 B6 73 44 65 3E EF 08 85 FB F0 F5 6D FC 83 44 5D 1D CD 6C F6 B2 5E 38 9E 5B 6E F2 22 E3 1C ED DA 21 F3 93 61 6A 6A 66 56 83 83 50 6A DC BE C5 71 BE C8 7F 8C 99 02 C1 39 0B
16+
match CertificateRequest = { certificationRequestInfo = { version = 0, subject = { RelativeDistinguishedName = { AttributeTypeandValue = { OID = "2.5.4.3", Value-Thing = "test" } } }, subjectPublicKeyInfo = { algorithm = { OID = "1.3.101.112" }, subjectPublicKey = 0x00fb16e6bd645fb03d755d0c207042bf80aa7cba385becdb9c19fcfe0bc95b1898 }, Attributes = { Attribute-thing = { OID = "1.2.840.113549.1.9.14", Extensions = { joint-iso-itu-t = { ds = { certificateExtension = { subjectAltName = { otherName = { type-id = "1.3.6.1.4.1.311.20.2.3", Value-thing = { userPrincipalName = "[email protected]" } } } } } } } } } }, signatureAlgorithm = { OID = "1.3.101.112" }, signature = 0x00529e457a71c5d6b67344653eef0885fbf0f56dfc83445d1dcd6cf6b25e389e5b6ef222e31cedda21f393616a6a66568383506adcbec571bec87f8c9902c1390b }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# -*- text -*-
2+
# Copyright (C) 2025 The FreeRADIUS Server project and contributors
3+
# This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0
4+
# Version $Id$
5+
DEFINE Certificate-Extensions x509_extensions ref=OID-Tree
6+
7+
DEFINE Issuer tlv is_pairs
8+
BEGIN Issuer
9+
DEFINE RelativeDistinguishedName tlv subtype=set
10+
BEGIN RelativeDistinguishedName
11+
DEFINE AttributeTypeAndValue group ref=OID-Tree,sequence_of=set,is_pair
12+
END RelativeDistinguishedName
13+
END Issuer
14+
15+
DEFINE Issuer-Set tlv is_pairs
16+
BEGIN Issuer-Set
17+
DEFINE RelativeDistinguishedName tlv
18+
BEGIN RelativeDistinguishedName
19+
DEFINE AttributeTypeAndValue group ref=OID-Tree,sequence_of=set,is_pair
20+
END RelativeDistinguishedName
21+
END Issuer-Set
22+
23+
DEFINE Test-Seq-Of sequence sequence_of=integer
24+
BEGIN Test-Seq-Of
25+
DEFINE Test-First-Integer integer
26+
END Test-Seq-Of
27+
28+
DEFINE Test-Set-Of tlv subtype=set,set_of=integer
29+
BEGIN Test-Set-Of
30+
DEFINE Test-First-Integer int64
31+
END Test-Set-Of
32+
33+
DEFINE Test-Set-Of-Group group ref=Test-Set-Of,subtype=set,set_of=integer
34+
35+
DEFINE Test-Boolean bool
36+
37+
DEFINE Test-Integer int64
38+
39+
DEFINE Foo struct subtype=sequence
40+
BEGIN Foo
41+
MEMBER Test-Integer int64
42+
END Foo
43+
44+
DEFINE Bar struct
45+
BEGIN Bar
46+
MEMBER Test-Boolean bool
47+
END Bar
48+
49+
DEFINE Foo-Bar struct subtype=sequence
50+
BEGIN Foo-Bar
51+
MEMBER Test-Integer int64 has_default
52+
VALUE Test-Integer DEFAULT 1
53+
MEMBER Test-Boolean bool
54+
END Foo-Bar
55+
56+
DEFINE Test-Bitstring octets subtype=bitstring
57+
58+
DEFINE Seq-Bitstring-Octets struct
59+
BEGIN Seq-Bitstring-Octets
60+
MEMBER Test-Bitstring octets
61+
END Seq-Bitstring-Octets
62+
63+
DEFINE Bitstring-Struct struct subtype=bitstring
64+
BEGIN Bitstring-Struct
65+
MEMBER foo bit[8]
66+
MEMBER bar bit[4]
67+
MEMBER foo-bar bit[4]
68+
END Bitstring-Struct
69+
70+
DEFINE Bitstring-Struct-7 struct subtype=bitstring
71+
BEGIN Bitstring-Struct-7
72+
MEMBER foo bit[2]
73+
MEMBER bar bit[1]
74+
MEMBER foo-bar bit[4]
75+
END Bitstring-Struct-7
76+
77+
DEFINE Octetstring octets
78+
79+
DEFINE Seq-Octetstring struct
80+
BEGIN Seq-Octetstring
81+
MEMBER Octetstring octets
82+
END Seq-Octetstring
83+
84+
DEFINE Test-NULL bool subtype=null
85+
86+
DEFINE Seq-Null struct
87+
BEGIN Seq-Null
88+
MEMBER Test-Null bool subtype=null
89+
END Seq-Null
90+
91+
DEFINE Seq-Integer-Null struct
92+
BEGIN Seq-Integer-Null
93+
MEMBER Test-Integer int64
94+
MEMBER Test-Null bool subtype=null
95+
END Seq-Integer-Null
96+
97+
DEFINE Test-Oid string subtype=oid
98+
99+
DEFINE Seq-Oid struct subtype=sequence
100+
BEGIN Seq-Oid
101+
MEMBER Test-Oid string subtype=oid
102+
END Seq-Oid
103+
104+
DEFINE Test-Enumerated int64 subtype=enumerated
105+
106+
DEFINE Test-String string
107+
108+
DEFINE Test-String-Max string max=5
109+
110+
#DEFINE Test-String-UTF8 string subtype=utf8string
111+
DEFINE Test-String-UTF8 utf8string
112+
113+
DEFINE Test-String-Custom utf8string
114+
115+
DEFINE Test-String-Printable printablestring
116+
117+
DEFINE Test-String-T61 t61string
118+
119+
DEFINE Test-String-IA5 ia5string
120+
121+
DEFINE Test-String-Visible visiblestring
122+
123+
DEFINE Test-String-General generalstring
124+
125+
DEFINE Test-String-Universal universalstring
126+
127+
DEFINE Seq-String struct
128+
BEGIN Seq-String
129+
MEMBER Test-String string
130+
END Seq-String
131+
132+
DEFINE Test-Date date
133+
134+
DEFINE Test-UTC utctime
135+
136+
DEFINE Test-Generalized-Time generalizedtime
137+
138+
DEFINE Seq-Date struct
139+
BEGIN Seq-Date
140+
MEMBER Test-Date date
141+
END Seq-Date
142+
143+
DEFINE Set-Bool-Integer struct
144+
BEGIN Set-Bool-Integer
145+
MEMBER Test-Bool bool
146+
MEMBER Test-Integer int64
147+
END Set-Bool-Integer
148+
149+
DEFINE Test-Context-Specific bool class=context-specific,tagnum=0,subtype=boolean
150+
151+
DEFINE Test-Sequence-TLV tlv subtype=sequence
152+
BEGIN Test-Sequence-TLV
153+
DEFINE Test-Integer int64
154+
DEFINE Test-Boolean bool
155+
END Test-Sequence-TLV
156+
157+
DEFINE Test-TLV tlv
158+
BEGIN Test-TLV
159+
DEFINE Test-Integer int64 subtype=integer
160+
DEFINE Test-Boolean bool subtype=boolean
161+
END Test-TLV
162+
163+
DEFINE Test-Sequence-GROUP group subtype=sequence,ref=Test-TLV
164+
165+
DEFINE Test-Set-Struct struct subtype=set
166+
BEGIN Test-Set-Struct
167+
MEMBER Test-Boolean bool subtype=boolean
168+
MEMBER Test-Integer int64 subtype=integer
169+
END Test-Set-Struct
170+
171+
DEFINE Test-Set-Bad-Struct struct subtype=set
172+
BEGIN Test-Set-Bad-Struct
173+
MEMBER Test-Integer int64 subtype=integer
174+
MEMBER Test-Boolean bool subtype=boolean
175+
END Test-Set-Bad-Struct
176+
177+
DEFINE Test-Set-TLV tlv subtype=set
178+
BEGIN Test-Set-TLV
179+
DEFINE Test-Integer int64 subtype=integer
180+
DEFINE Test-Boolean bool subtype=boolean
181+
END Test-Set-TLV
182+
183+
DEFINE Test-Set-GROUP group subtype=set,ref=Test-TLV

0 commit comments

Comments
 (0)