From 989078b6cb4495b5b9545ea2cdf98943b4e2a17a Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 8 May 2020 20:00:42 -0500 Subject: [PATCH] finished basic keygen --- tests/KeyGenTest.cs | 7 +++++-- treasurechest/chestcrypto/keygen.cs | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/KeyGenTest.cs b/tests/KeyGenTest.cs index 85b9a85..f3ededf 100644 --- a/tests/KeyGenTest.cs +++ b/tests/KeyGenTest.cs @@ -14,8 +14,11 @@ namespace tests [Test] public void TestKeyGen() { - System.Console.Write(chestcrypto.PrivateKeyGenerator.generate().Length); - if (chestcrypto.PrivateKeyGenerator.generate().Length != 96){ + byte[] key = chestcrypto.PrivateKeyGenerator.generate(); + if (key.Length != 96){ + Assert.Fail(); + } + if (key.Equals(chestcrypto.PrivateKeyGenerator.generate())){ Assert.Fail(); } Assert.Pass(); diff --git a/treasurechest/chestcrypto/keygen.cs b/treasurechest/chestcrypto/keygen.cs index 4b5d3de..ff853b0 100644 --- a/treasurechest/chestcrypto/keygen.cs +++ b/treasurechest/chestcrypto/keygen.cs @@ -28,10 +28,13 @@ namespace chestcrypto{ Buffer.BlockCopy(second, 0, bytes, first.Length, second.Length); return bytes; } - public static byte[] generate(){ + public static byte[] generate() + { byte[] ed25519 = Ed25519KeyGenerator.generator(); byte[] curve25519 = Curve25519KeyGenerator.generator(); byte[] key = Combine(ed25519, curve25519); + Array.Clear(ed25519, 0, ed25519.Length); + Array.Clear(curve25519, 0, curve25519.Length); return key; }