~apreiml/hare-ssh

0550a9b3e009c9c38d0c56c2f85a9c7d4b5dee59 — Drew DeVault 1 year, 8 months ago 9f154d4
Tweak cipher algorithm table

This adds the CTR variants and re-orders them preferentially ahead of
CBC, matching OpenSSH, and comments out chacha/poly until such a time as
I can be bothered to do all of the necessary refactoring to support it.
3 files changed, 25 insertions(+), 5 deletions(-)

M net/ssh/cipher.ha
M net/ssh/client.ha
M net/ssh/kex.ha
M net/ssh/cipher.ha => net/ssh/cipher.ha +19 -3
@@ 21,10 21,26 @@ export fn cipher_blksz(cipher: *cipher) size = {

// Ordered by preference
const ciphertable: [_]cipher = [
	// TODO: Finish me
	//cipher {
	//	name = "chacha20-poly1305@openssh.com",
	//	keysz = 64,
	//	blksz = 8,
	//},
	cipher {
		name = "chacha20-poly1305@openssh.com",
		keysz = 64,
		blksz = 8,
		name = "aes256-ctr",
		keysz = 32,
		blksz = 16,
	},
	cipher {
		name = "aes192-ctr",
		keysz = 24,
		blksz = 16,
	},
	cipher {
		name = "aes128-ctr",
		keysz = 16,
		blksz = 16,
	},
	cipher {
		name = "aes256-cbc",

M net/ssh/client.ha => net/ssh/client.ha +5 -1
@@ 192,12 192,16 @@ fn client_keyexch(client: *client) (void | error) = {
		client.kex = kex.init();
	};

	// TODO: Deal with incorrectly guessing the other side's algorithm
	const kex = client.kex as *kex;
	static let keybuf: [128]u8 = [0...];
	assert(kex_keysz(kex) <= len(keybuf));
	kex.getkey(kex, client, keybuf)?;

	abort(); // TODO: Set up the cipher here
	const (cipher, mac) = client.nextalgos as (const *cipher, const *mac);
	fmt::errorfln("kex complete; set up cipher {} + {}",
		cipher.name, mac.name)!;
	abort(); // TODO
};

// Reads an SSH packet from the client connection. This function may return

M net/ssh/kex.ha => net/ssh/kex.ha +1 -1
@@ 161,7 161,7 @@ fn curve25519_sha256_getkey(
			abort("invalid exchange key sig"); // TODO: Return error
		};

		abort(); // TODO
		out[..32] = shared[..];
	};
};