Skip to content

Commit

Permalink
FEAT: support for direct DH params initialization from .key files
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Feb 21, 2022
1 parent d6afa56 commit 080cd36
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mezz/codec-ssh-key.reb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ wrap [
]
"RSA PUBLIC KEY" [ return init-rsa-public-key data ]
"RSA PRIVATE KEY" [ return init-rsa-private-key data ]
"DH PARAMETERS" [
parse data [
'SEQUENCE into [
'INTEGER set p binary!
'INTEGER set g binary!
] (
return dh-init :g :p
)
]

]
]
none ; no success!
]
Expand Down
7 changes: 7 additions & 0 deletions src/tests/units/crypt-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ sY29ouezv4Xz2PuMch5VGPP+CDqzCM4loWgV
--test-- "Init RSA key from file"
--assert handle? try [key: decode 'ssh-key read %units/files/rebol-public.ppk]
rsa key none ; release it, as it is not GCed yet.

--test-- "Init public DH params from file"
--assert all [
handle? key: load %units/files/dhparam2048.key
'dhm = query/mode key 'type
dh/release key
]
===end-group===

===start-group=== "PPK codec"
Expand Down
8 changes: 8 additions & 0 deletions src/tests/units/files/dhparam2048.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAhR9gLa+RbIUY+u3qZHRwTfw4Q0VoJOv4FK3et9HQNSvZmmUqzcG/
t3v3TPD3NRsLTh7hrvQcWFR7dsgqLFjqrMvthcRXsLYOxsT9ERL3nMPloEItggRG
9hk3RzGFYb9nx56RXDJ3Nh+/pYfG3Ab+3gt+V/7Ato+Ws61lHVQmQ1cBUvkdjy4i
uIm5vr91VVgMc8Bi9PvhsPhjU4f9LQIykiY7+nsJpbgNdlU55Db8/Atc3PnL11z/
xXjmnj1QBjWymkz5LDEMJYCkMcFGwiToL6+jYjAkG1GpU6Jt4C5Z00E4LERy/jCi
geGoH8yNQvldeqw5lTcNpaWWB2+ROqUj0wIBAg==
-----END DH PARAMETERS-----

0 comments on commit 080cd36

Please sign in to comment.