Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test to ensure the isomorphism for RSA key between awa_gen_key and what the user can give to initiate an SSH connection #44

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
(lang dune 1.0)
(lang dune 2.7)
(name awa)
(cram enable)
14 changes: 12 additions & 2 deletions test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
(name test)
(modules test)
(package awa)
(deps (source_tree data))
(deps
(source_tree data))
(libraries awa mtime.clock.os cstruct-unix mirage-crypto-rng.unix))

(executable
Expand All @@ -17,7 +18,8 @@
(public_name awa_test_client)
(modules awa_test_client)
(package awa)
(libraries awa mirage-crypto-rng.unix mtime.clock.os cmdliner fmt.tty logs.fmt logs.cli fmt.cli cstruct-unix))
(libraries awa mirage-crypto-rng.unix mtime.clock.os cmdliner fmt.tty
logs.fmt logs.cli fmt.cli cstruct-unix))

(executable
(name awa_lwt_server)
Expand All @@ -32,3 +34,11 @@
(modules awa_gen_key)
(package awa)
(libraries awa mirage-crypto-rng.unix cmdliner))

(executable
(name public_key_of_seed)
(modules public_key_of_seed)
(libraries awa))

(cram
(deps %{bin:awa_gen_key} public_key_of_seed.exe))
5 changes: 5 additions & 0 deletions test/iso.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$ awa_gen_key > a.key
$ cat a.key | tail -n1 > a.public_key
$ cat a.key | head -n1 | cut -d' ' -f3 > a.seed
$ ./public_key_of_seed.exe rsa:$(cat a.seed) > b.public_key
$ diff a.public_key b.public_key
13 changes: 13 additions & 0 deletions test/public_key_of_seed.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let b64s x = Cstruct.to_string x |> Base64.encode_string

let () =
match Awa.Keys.of_string Sys.argv.(1) with
| Ok pk ->
let pub = Awa.Hostkey.pub_of_priv pk in
let public = Awa.Wire.blob_of_pubkey pub in
Format.printf "%s %s [email protected]\n%!"
(Awa.Hostkey.sshname pub)
(b64s public)
| Error (`Msg err) ->
Format.eprintf "%s: %s.\n%!" Sys.argv.(0) err ;
exit 1