private void RunTestValid(TestGroupTest test) { ECPublicKeyParameters publicKey = KeyParser.ParsePublicKeyDer(Hex.Decode(test.PublicKey)); ECPrivateKeyParameters privateKey = KeyParser.ParsePrivateKeyHex(test.PrivateKey); byte[] expectedSharedSecret = Hex.Decode(test.SharedSecret); byte[] sharedSecret = KeyDerivation.ComputeSharedSecret(privateKey, publicKey); Assert.True(sharedSecret.SequenceEqual(expectedSharedSecret)); }
private void RunTestInvalid(TestGroupTest test) { ECPrivateKeyParameters privateKey = KeyParser.ParsePrivateKeyHex(test.PrivateKey); byte[] publicKeyBytes = Hex.Decode(test.PublicKey); Assert.Throws <ArgumentException>(() => { ECPublicKeyParameters publicKey = KeyParser.ParsePublicKeyDer(publicKeyBytes); byte[] sharedSecret = KeyDerivation.ComputeSharedSecret(privateKey, publicKey); }); }