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

Output keys (key seeds) as of_string expects #48

Merged
merged 3 commits into from
Dec 7, 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
4 changes: 4 additions & 0 deletions lib/keys.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ let typ_of_string s =
| "ed25519" -> Ok `Ed25519
| _ -> Error ("unknown key type " ^ s)

let string_of_typ = function
| `Rsa -> "rsa"
| `Ed25519 -> "ed25519"

type authenticator = [
| `No_authentication
| `Key of Hostkey.pub
Expand Down
7 changes: 5 additions & 2 deletions test/awa_gen_key.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ let gen_key seed typ =
(match hostkey with
| Awa.Hostkey.Ed25519_priv k ->
let p = Mirage_crypto_ec.Ed25519.priv_to_cstruct k in
Printf.printf "ED25519 private key %s\n" (b64s p)
Printf.printf "private key: %s:%s\n"
Awa.Keys.(string_of_typ `Ed25519)
(b64s p)
| Rsa_priv _ ->
Printf.printf "seed is %s\n" seed);
Printf.printf "private key seed: %s:%s\n"
Awa.Keys.(string_of_typ `Rsa) seed);
let pub = Awa.Hostkey.pub_of_priv hostkey in
let public = Awa.Wire.blob_of_pubkey pub in
Printf.printf "%s %s [email protected]\n" (Awa.Hostkey.sshname pub) (b64s public);
Expand Down
5 changes: 5 additions & 0 deletions test/iso-ed25519.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$ awa_gen_key --keytype ed25519 > 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 $(cat a.seed) > b.public_key
$ diff a.public_key b.public_key
6 changes: 3 additions & 3 deletions test/iso.t
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ awa_gen_key > a.key
$ awa_gen_key --keytype rsa > 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
$ cat a.key | head -n1 | cut -d' ' -f4 > a.seed
$ ./public_key_of_seed.exe $(cat a.seed) > b.public_key
$ diff a.public_key b.public_key