From 289612160d1d98ea4541b09afb3c8e846c071fd6 Mon Sep 17 00:00:00 2001 From: Sharif Olorin Date: Tue, 29 Nov 2016 04:37:55 +0000 Subject: [PATCH] Temporarily drop EdDSA support until linking is sorted Packages which depend on tinfoil currently rely on linking with libsodium, which makes the executables they build nonportable. The right solution to this is linking to a static version of libsodium (#65) and/or split the package (#59), but until this can be fully implemented and pushed through to master, this is a temporary fix so we can build working client executables (ref https://github.com/ambiata/ambiata-cli/issues/59). --- ambiata-tinfoil.cabal | 7 --- cbits/tinfoil/sodium/constants.c | 16 ------ cbits/tinfoil/sodium/constants.h | 14 ------ cbits/tinfoil/tinfoil.h | 1 - test/Test/IO/Tinfoil/Signing/Ed25519.hs | 45 ----------------- .../IO/Tinfoil/Signing/Ed25519/Internal.hs | 49 ------------------- test/Test/Tinfoil/Signing/Ed25519/Internal.hs | 24 --------- test/bench.hs | 20 -------- test/test-io.hs | 4 -- test/test.hs | 2 - 10 files changed, 182 deletions(-) delete mode 100644 cbits/tinfoil/sodium/constants.c delete mode 100644 cbits/tinfoil/sodium/constants.h delete mode 100644 test/Test/IO/Tinfoil/Signing/Ed25519.hs delete mode 100644 test/Test/IO/Tinfoil/Signing/Ed25519/Internal.hs delete mode 100644 test/Test/Tinfoil/Signing/Ed25519/Internal.hs diff --git a/ambiata-tinfoil.cabal b/ambiata-tinfoil.cabal index c2fa351..6bb38af 100644 --- a/ambiata-tinfoil.cabal +++ b/ambiata-tinfoil.cabal @@ -56,18 +56,11 @@ library Tinfoil.MAC Tinfoil.Random Tinfoil.Random.Internal - Tinfoil.Signing.Ed25519 - Tinfoil.Signing.Ed25519.Internal Tinfoil.Token - extra-libraries: sodium - - pkgconfig-depends: libsodium >= 0.4.5 - c-sources: -- tinfoil's own c bits cbits/tinfoil/memory.c - cbits/tinfoil/sodium/constants.c -- scrypt (https://github.com/Tarsnap/scrypt) , cbits/scrypt/insecure_memzero.c diff --git a/cbits/tinfoil/sodium/constants.c b/cbits/tinfoil/sodium/constants.c deleted file mode 100644 index ac33654..0000000 --- a/cbits/tinfoil/sodium/constants.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#include "constants.h" - -size_t tinfoil_sodium_pubkey_len() { - return crypto_sign_PUBLICKEYBYTES; -} - -size_t tinfoil_sodium_seckey_len() { - return crypto_sign_SECRETKEYBYTES; -} - -size_t tinfoil_sodium_sig_len() { - return crypto_sign_BYTES; -} - diff --git a/cbits/tinfoil/sodium/constants.h b/cbits/tinfoil/sodium/constants.h deleted file mode 100644 index 4096ba3..0000000 --- a/cbits/tinfoil/sodium/constants.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef H_TINFOIL_SODIUM_CONSTANTS -#define H_TINFOIL_SODIUM_CONSTANTS - -#include - -#include - -size_t tinfoil_sodium_pubkey_len(); - -size_t tinfoil_sodium_seckey_len(); - -size_t tinfoil_sodium_sig_len(); - -#endif diff --git a/cbits/tinfoil/tinfoil.h b/cbits/tinfoil/tinfoil.h index a6ee35c..38b2a78 100644 --- a/cbits/tinfoil/tinfoil.h +++ b/cbits/tinfoil/tinfoil.h @@ -2,6 +2,5 @@ #define H_TINFOIL #include "memory.h" -#include "sodium/constants.h" #endif diff --git a/test/Test/IO/Tinfoil/Signing/Ed25519.hs b/test/Test/IO/Tinfoil/Signing/Ed25519.hs deleted file mode 100644 index 4ab81d6..0000000 --- a/test/Test/IO/Tinfoil/Signing/Ed25519.hs +++ /dev/null @@ -1,45 +0,0 @@ -{-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-missing-signatures #-} -module Test.IO.Tinfoil.Signing.Ed25519 where - -import Data.ByteString (ByteString) -import qualified Data.ByteString as BS -import qualified Data.Text as T - -import Disorder.Core.IO (testIO) -import Disorder.Core.Property (failWith) -import Disorder.Core.UniquePair (UniquePair(..)) - -import P - -import System.IO - -import Test.QuickCheck -import Test.QuickCheck.Instances () - -import Tinfoil.Data -import Tinfoil.Signing.Ed25519 - -prop_signMessage :: UniquePair ByteString -> Property -prop_signMessage (UniquePair msg1 msg2) = - let msg3 = msg1 <> BS.singleton 0x00 - msg4 = BS.singleton 0x00 <> msg1 in testIO $ do - (pk1, sk1) <- genKeyPair - (pk2, _sk2) <- genKeyPair - case signMessage sk1 msg1 of - Nothing' -> - pure . failWith $ "Unexpected failure signing: " <> T.pack (show msg1) - Just' sig -> - let good = verifyMessage pk1 sig msg1 - bads = [ verifyMessage pk2 sig msg1 - , verifyMessage pk1 sig msg2 - , verifyMessage pk1 sig msg3 - , verifyMessage pk1 sig msg4 - ] in - pure $ (good, all (== NotVerified) bads) === (Verified, True) - -return [] -tests :: IO Bool -tests = $forAllProperties $ quickCheckWithResult (stdArgs { maxSuccess = 1000 } ) diff --git a/test/Test/IO/Tinfoil/Signing/Ed25519/Internal.hs b/test/Test/IO/Tinfoil/Signing/Ed25519/Internal.hs deleted file mode 100644 index 98b08c9..0000000 --- a/test/Test/IO/Tinfoil/Signing/Ed25519/Internal.hs +++ /dev/null @@ -1,49 +0,0 @@ -{-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE GADTs #-} -{-# OPTIONS_GHC -fno-warn-missing-signatures #-} -module Test.IO.Tinfoil.Signing.Ed25519.Internal where - -import Data.ByteString (ByteString) -import qualified Data.ByteString as BS -import qualified Data.Text as T - -import Disorder.Core.IO (testIO) -import Disorder.Core.Property (failWith) - -import P - -import System.IO - -import Test.QuickCheck -import Test.QuickCheck.Instances () - -import Tinfoil.Data -import Tinfoil.Signing.Ed25519.Internal - -prop_genKeyPair_len :: Property -prop_genKeyPair_len = testIO $ do - (PKey_Ed25519 pk, SKey_Ed25519 sk) <- genKeyPair - pure $ (BS.length pk, BS.length sk) === (pubKeyLen, secKeyLen) - -prop_genKeyPair :: Property -prop_genKeyPair = testIO $ do - (pk1, sk1) <- genKeyPair - (pk2, sk2) <- genKeyPair - pure $ (pk1 == pk2, sk1 == sk2) === (False, False) - --- Check the signed-message construction works how we think it does. -prop_signMessage' :: ByteString -> Property -prop_signMessage' msg = testIO $ do - (_pk, sk) <- genKeyPair - case signMessage' sk msg of - Nothing' -> - pure . failWith $ "Unexpected failure signing: " <> T.pack (show msg) - Just' sm -> - let msg' = BS.drop maxSigLen sm in - pure $ msg === msg' - -return [] -tests :: IO Bool -tests = $forAllProperties $ quickCheckWithResult (stdArgs { maxSuccess = 1000 } ) diff --git a/test/Test/Tinfoil/Signing/Ed25519/Internal.hs b/test/Test/Tinfoil/Signing/Ed25519/Internal.hs deleted file mode 100644 index 9c25372..0000000 --- a/test/Test/Tinfoil/Signing/Ed25519/Internal.hs +++ /dev/null @@ -1,24 +0,0 @@ -{-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fno-warn-missing-signatures #-} - -module Test.Tinfoil.Signing.Ed25519.Internal where - -import P - -import System.IO - -import Tinfoil.Signing.Ed25519.Internal - -import Test.QuickCheck -import Test.QuickCheck.Instances () - --- Check these don't change on us. -prop_ed25519_lengths = - once $ (pubKeyLen, secKeyLen, maxSigLen) === (32, 64, 64) - -return [] -tests :: IO Bool -tests = $forAllProperties $ quickCheckWithResult (stdArgs { maxSuccess = 1000 } ) diff --git a/test/bench.hs b/test/bench.hs index 68628da..12308e7 100644 --- a/test/bench.hs +++ b/test/bench.hs @@ -14,8 +14,6 @@ import Disorder.Core.Gen (GenSeed(..), genDeterministic) import P -import qualified Prelude - import System.IO import qualified System.Random as R @@ -24,12 +22,10 @@ import Test.QuickCheck import Test.QuickCheck.Instances () import Tinfoil.Comparison -import Tinfoil.Data import Tinfoil.Hash import qualified Tinfoil.KDF.Scrypt as Scrypt import Tinfoil.MAC import Tinfoil.Random -import qualified Tinfoil.Signing.Ed25519 as Ed25519 generate' :: Gen a -> IO a generate' = pure . genDeterministic (GenSeed 314159) @@ -43,16 +39,6 @@ bsTriple small big = do let big2 = BS.copy big1 pure (BS.pack $ short1 <> long, big1, big2) -genEd25519 :: IO (SecretKey Ed25519, PublicKey Ed25519, Signature Ed25519, ByteString) -genEd25519 = do - (pk, sk) <- Ed25519.genKeyPair - msg <- generate' arbitrary - let sig = fromJust' $ Ed25519.signMessage sk msg - pure (sk, pk, sig, msg) - where - fromJust' Nothing' = Prelude.error "impossible: signing valid message failed" - fromJust' (Just' x) = x - -- non-CSPRNG, just a performance baseline. stdRandom :: Int -> IO ByteString stdRandom n = BS.pack <$> R.getStdRandom (genBytes n []) @@ -116,10 +102,4 @@ main = tinfoilBench [ , env ((,) <$> generate' arbitrary <*> generate' arbitrary) $ \ ~(sk, bs) -> bgroup "mac/hmacSHA256" $ [ bench "hmacSHA256" $ nf (hmacSHA256 sk) bs ] - , env genEd25519 $ \ ~(sk, pk, sig, msg) -> - bgroup "signing/ed25519" $ [ - bench "genKeyPair" $ nfIO Ed25519.genKeyPair - , bench "signMessage" $ nf (Ed25519.signMessage sk) msg - , bench "verifyMessage" $ nf (Ed25519.verifyMessage pk sig) msg - ] ] diff --git a/test/test-io.hs b/test/test-io.hs index aceed54..d653738 100644 --- a/test/test-io.hs +++ b/test/test-io.hs @@ -8,8 +8,6 @@ import qualified Test.IO.Tinfoil.KDF.Scrypt import qualified Test.IO.Tinfoil.KDF.Scrypt.Compat import qualified Test.IO.Tinfoil.MAC import qualified Test.IO.Tinfoil.Random -import qualified Test.IO.Tinfoil.Signing.Ed25519 -import qualified Test.IO.Tinfoil.Signing.Ed25519.Internal main :: IO () main = @@ -22,6 +20,4 @@ main = , Test.IO.Tinfoil.KDF.Scrypt.Compat.tests , Test.IO.Tinfoil.MAC.tests , Test.IO.Tinfoil.Random.tests - , Test.IO.Tinfoil.Signing.Ed25519.tests - , Test.IO.Tinfoil.Signing.Ed25519.Internal.tests ] diff --git a/test/test.hs b/test/test.hs index 08d6382..978c1ee 100644 --- a/test/test.hs +++ b/test/test.hs @@ -11,7 +11,6 @@ import qualified Test.Tinfoil.Hash.TestVectors import qualified Test.Tinfoil.KDF.Scrypt import qualified Test.Tinfoil.MAC import qualified Test.Tinfoil.Random -import qualified Test.Tinfoil.Signing.Ed25519.Internal main :: IO () main = @@ -27,5 +26,4 @@ main = , Test.Tinfoil.MAC.tests , Test.Tinfoil.KDF.Scrypt.tests , Test.Tinfoil.Random.tests - , Test.Tinfoil.Signing.Ed25519.Internal.tests ]