Skip to content

Commit efd3c74

Browse files
committed
FEAT: added PKIX as a basic codec
1 parent d79f41c commit efd3c74

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/mezz/mezz-crypt.r

+21
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,25 @@ import module [
7979
]
8080
]
8181
]
82+
83+
register-codec object [
84+
name: 'PKIX
85+
title: "Public-Key Infrastructure (X.509)"
86+
suffixes: [%.pem %.ssh]
87+
decode: function[data [string! binary!]][
88+
load-PKIX data
89+
]
90+
identify: function[data [string! binary!]][
91+
rl_label: [
92+
[
93+
"---- BEGIN " any ch_label "----" |
94+
"-----BEGIN " any ch_label "-----"
95+
] opt cr lf
96+
|
97+
some ch_pretext rl_label
98+
]
99+
parse/all data [rl_label to end]
100+
]
101+
]
102+
82103
] ;- end of module

src/tests/units/files/dhparam2048.pem

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-----BEGIN DH PARAMETERS-----
2+
MIIBCAKCAQEAhR9gLa+RbIUY+u3qZHRwTfw4Q0VoJOv4FK3et9HQNSvZmmUqzcG/
3+
t3v3TPD3NRsLTh7hrvQcWFR7dsgqLFjqrMvthcRXsLYOxsT9ERL3nMPloEItggRG
4+
9hk3RzGFYb9nx56RXDJ3Nh+/pYfG3Ab+3gt+V/7Ato+Ws61lHVQmQ1cBUvkdjy4i
5+
uIm5vr91VVgMc8Bi9PvhsPhjU4f9LQIykiY7+nsJpbgNdlU55Db8/Atc3PnL11z/
6+
xXjmnj1QBjWymkz5LDEMJYCkMcFGwiToL6+jYjAkG1GpU6Jt4C5Z00E4LERy/jCi
7+
geGoH8yNQvldeqw5lTcNpaWWB2+ROqUj0wIBAg==
8+
-----END DH PARAMETERS-----

src/tests/units/mezz-crypt-test.r3

+8
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ sY29ouezv4Xz2PuMch5VGPP+CDqzCM4loWgV
190190
--assert block? Load-PKIX pkix
191191
--assert binary? Load-PKIX/binary pkix
192192

193+
;-- Using codecs
194+
195+
--test-- "Load PKIX data from file using PKIX codec"
196+
197+
--assert block? pkix: load %units/files/dhparam2048.pem
198+
--assert "DH PARAMETERS" = pkix/label
199+
--assert binary? pkix/binary
200+
193201

194202
===end-group===
195203

0 commit comments

Comments
 (0)