From 91f18866cc6d93ba8dfbf3f9a4739fa6ef1ac849 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 3 Jan 2020 19:32:35 +0100 Subject: [PATCH] Added more checks --- Ed25519/Signer.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Ed25519/Signer.cs b/Ed25519/Signer.cs index 8a058a1..2bc16b4 100644 --- a/Ed25519/Signer.cs +++ b/Ed25519/Signer.cs @@ -10,6 +10,12 @@ namespace Ed25519 { public static ReadOnlySpan Sign(ReadOnlySpan message, ReadOnlySpan privateKey, ReadOnlySpan publicKey) { + if(privateKey.Length == 0) + throw new ArgumentException("Private key length is wrong"); + + if (publicKey.Length != Constants.BIT_LENGTH / 8) + throw new ArgumentException("Public key length is wrong"); + var privateKeyHash = privateKey.ComputeHash(); var privateKeyBits = Constants.TWO_POW_BIT_LENGTH_MINUS_TWO; for (var i = 3; i < Constants.BIT_LENGTH - 2; i++)