~sircmpwn/himitsu-ssh

442dee9c9f1871b381c549161db02a30592dbe69 — Armin Preiml 1 year, 3 months ago 2753e40
fix public key export
1 files changed, 7 insertions(+), 10 deletions(-)

M cmd/hissh-export/main.ha
M cmd/hissh-export/main.ha => cmd/hissh-export/main.ha +7 -10
@@ 82,21 82,18 @@ fn encode(key: *query::query) void = {
	const pkey = base64::decodestr(&base64::std_encoding, pkey.value)!;
	defer free(pkey);

	const key = switch (keytype.value) {
	case "ssh-ed25519" =>
		let key = ssh::ed25519key {
			comment = comment,
			...
		};
		// XXX: We could validate the length here
		key.pubkey[..] = pkey[..];
		yield key;
	const key = match (ssh::newkey(keytype.value)) {
	case let k: *ssh::key =>
		yield k;
	case =>
		fmt::errorfln("Skipping unsupported key type {}", keytype)!;
		return;
	};

	ssh::encode_pubkeystr(os::stdout, &key)!;
	let pkeyh = bufio::fixed(pkey, io::mode::READ);
	ssh::key_decoderawpub(key, &pkeyh)!;

	ssh::encode_pubkeystr(os::stdout, key)!;
	fmt::println()!;
};