Skip to content

Commit 080cd36

Browse files
committed
FEAT: support for direct DH params initialization from .key files
1 parent d6afa56 commit 080cd36

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/mezz/codec-ssh-key.reb

+11
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,17 @@ wrap [
142142
]
143143
"RSA PUBLIC KEY" [ return init-rsa-public-key data ]
144144
"RSA PRIVATE KEY" [ return init-rsa-private-key data ]
145+
"DH PARAMETERS" [
146+
parse data [
147+
'SEQUENCE into [
148+
'INTEGER set p binary!
149+
'INTEGER set g binary!
150+
] (
151+
return dh-init :g :p
152+
)
153+
]
154+
155+
]
145156
]
146157
none ; no success!
147158
]

src/tests/units/crypt-test.r3

+7
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ sY29ouezv4Xz2PuMch5VGPP+CDqzCM4loWgV
224224
--test-- "Init RSA key from file"
225225
--assert handle? try [key: decode 'ssh-key read %units/files/rebol-public.ppk]
226226
rsa key none ; release it, as it is not GCed yet.
227+
228+
--test-- "Init public DH params from file"
229+
--assert all [
230+
handle? key: load %units/files/dhparam2048.key
231+
'dhm = query/mode key 'type
232+
dh/release key
233+
]
227234
===end-group===
228235

229236
===start-group=== "PPK codec"

src/tests/units/files/dhparam2048.key

+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-----

0 commit comments

Comments
 (0)