From c9092ffe6a420efa16fccad12595aae438279faf Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Tue, 1 May 2018 22:29:37 -0700 Subject: [PATCH] Slightly better test generation for RSA signatures. --- tests/rsa/GenerateRSATests.hs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/rsa/GenerateRSATests.hs b/tests/rsa/GenerateRSATests.hs index 6f2faba..ad10c7c 100644 --- a/tests/rsa/GenerateRSATests.hs +++ b/tests/rsa/GenerateRSATests.hs @@ -91,14 +91,20 @@ runSignatureGenerator inputs outputs = Left _ -> go (Just keySize) g3 Right sig -> - do writeChan outputs [("d", showHex (private_d private) ""), - ("n", showHex (public_n public) ""), - ("h", hashname), - ("k", showHex keySize ""), - ("l", showHex (BS.length message) ""), - ("m", showBinary message), - ("s", showBinary (BSL.toStrict sig))] - go Nothing g3 + case rsassa_pkcs1_v1_5_verify hash public (BSL.fromStrict message) sig of + Left err -> + fail ("RSA Verification error: " ++ show err) + Right False -> + fail ("RSA verification failed?!") + Right True -> + do writeChan outputs [("d", showHex (private_d private) ""), + ("n", showHex (public_n public) ""), + ("h", hashname), + ("k", showHex keySize ""), + ("l", showHex (BS.length message) ""), + ("m", showBinary message), + ("s", showBinary (BSL.toStrict sig))] + go Nothing g3 writeData :: Chan [(String,String)] -> (Progress -> IO ()) -> Handle -> IO () writeData outputChan progressBar hndl = go 0