aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2018-04-28 15:26:04 -0700
committerGravatar Benjamin Barenblat <bbaren@google.com>2018-04-28 15:26:04 -0700
commit22b190b55afcbbd2e014339ead081a552fea4287 (patch)
tree9b2ecd376d3430b51a795c6f9c6e62c84066d3b8
parent403466452dcda68763b82f409310fc41a3a6a9ab (diff)
Switch initialism style to follow the rest of the Haskell world
-rw-r--r--btls.cabal12
-rw-r--r--cbits/btls.c2
-rw-r--r--src/Data/Digest.hs16
-rw-r--r--src/Data/Digest/Internal.hs4
-rw-r--r--src/Data/HMAC.hs (renamed from src/Data/Hmac.hs)24
-rw-r--r--src/Internal/Base.chs12
-rw-r--r--src/Internal/Digest.chs44
-rw-r--r--src/Internal/HMAC.chs (renamed from src/Internal/Hmac.chs)20
-rw-r--r--tests/Data/Digest/HashTests.hs6
-rw-r--r--tests/Data/Digest/MD5Tests.hs (renamed from tests/Data/Digest/Md5Tests.hs)14
-rw-r--r--tests/Data/Digest/SHA1Tests.hs (renamed from tests/Data/Digest/Sha1Tests.hs)10
-rw-r--r--tests/Data/Digest/SHA2Tests.hs (renamed from tests/Data/Digest/Sha2Tests.hs)48
-rw-r--r--tests/Data/DigestTests.hs12
-rw-r--r--tests/Data/HMACTests.hs (renamed from tests/Data/HmacTests.hs)18
-rw-r--r--tests/Tests.hs4
15 files changed, 123 insertions, 123 deletions
diff --git a/btls.cabal b/btls.cabal
index 4246e43..d63a67a 100644
--- a/btls.cabal
+++ b/btls.cabal
@@ -48,13 +48,13 @@ library
-Wno-safe -Wno-unsafe
-optl-Wl,-z,relro -optl-Wl,-z,now -optl-Wl,-s
exposed-modules: Data.Digest
- , Data.Hmac
+ , Data.HMAC
other-modules: Data.Digest.Internal
, Foreign.Ptr.Cast
, Foreign.Ptr.ConstantTimeEquals
, Internal.Base
, Internal.Digest
- , Internal.Hmac
+ , Internal.HMAC
, Result
c-sources: cbits/btls.c
-- Use special names for the BoringSSL libraries to avoid accidentally pulling
@@ -79,10 +79,10 @@ test-suite tests
main-is: Tests.hs
other-modules: Data.DigestTests
, Data.Digest.HashTests
- , Data.Digest.Md5Tests
- , Data.Digest.Sha1Tests
- , Data.Digest.Sha2Tests
- , Data.HmacTests
+ , Data.Digest.MD5Tests
+ , Data.Digest.SHA1Tests
+ , Data.Digest.SHA2Tests
+ , Data.HMACTests
build-depends: base >=4.9 && <4.10
, btls
, bytestring >=0.10 && <0.11
diff --git a/cbits/btls.c b/cbits/btls.c
index e922f3a..d4bfd62 100644
--- a/cbits/btls.c
+++ b/cbits/btls.c
@@ -14,6 +14,6 @@
#include <openssl/digest.h>
-void btlsFinalizeEvpMdCtx(EVP_MD_CTX* const ctx) {
+void btlsFinalizeEVPMDCtx(EVP_MD_CTX* const ctx) {
(void)EVP_MD_CTX_cleanup(ctx);
}
diff --git a/src/Data/Digest.hs b/src/Data/Digest.hs
index 3bd042c..34279e5 100644
--- a/src/Data/Digest.hs
+++ b/src/Data/Digest.hs
@@ -35,23 +35,23 @@ import Internal.Digest
type LazyByteString = ByteString.Lazy.ByteString
md5, sha1, sha224, sha256, sha384, sha512 :: Algorithm
-md5 = Algorithm evpMd5
-sha1 = Algorithm evpSha1
-sha224 = Algorithm evpSha224
-sha256 = Algorithm evpSha256
-sha384 = Algorithm evpSha384
-sha512 = Algorithm evpSha512
+md5 = Algorithm evpMD5
+sha1 = Algorithm evpSHA1
+sha224 = Algorithm evpSHA224
+sha256 = Algorithm evpSHA256
+sha384 = Algorithm evpSHA384
+sha512 = Algorithm evpSHA512
-- | Hashes according to the given 'Algorithm'.
hash :: Algorithm -> LazyByteString -> Digest
hash (Algorithm md) bytes =
unsafeLocalState $ do
- ctxFP <- mallocEvpMdCtx
+ ctxFP <- mallocEVPMDCtx
withForeignPtr ctxFP $ \ctx -> do
evpDigestInitEx ctx md noEngine
mapM_ (updateBytes ctx) (ByteString.Lazy.toChunks bytes)
d <-
- allocaArray evpMaxMdSize $ \mdOut ->
+ allocaArray evpMaxMDSize $ \mdOut ->
alloca $ \pOutSize -> do
evpDigestFinalEx ctx mdOut pOutSize
outSize <- fromIntegral <$> peek pOutSize
diff --git a/src/Data/Digest/Internal.hs b/src/Data/Digest/Internal.hs
index be88e68..859f765 100644
--- a/src/Data/Digest/Internal.hs
+++ b/src/Data/Digest/Internal.hs
@@ -21,10 +21,10 @@ import Data.Char (intToDigit)
import Data.Word (Word8)
import Foreign (Ptr)
-import Internal.Base (EvpMd)
+import Internal.Base (EVPMD)
-- | A cryptographic hash function.
-newtype Algorithm = Algorithm (Ptr EvpMd)
+newtype Algorithm = Algorithm (Ptr EVPMD)
-- | The result of a hash operation.
newtype Digest = Digest ByteString
diff --git a/src/Data/Hmac.hs b/src/Data/HMAC.hs
index 2211248..1ad1bfb 100644
--- a/src/Data/Hmac.hs
+++ b/src/Data/HMAC.hs
@@ -12,9 +12,9 @@
-- License for the specific language governing permissions and limitations under
-- the License.
-module Data.Hmac
+module Data.HMAC
( SecretKey(SecretKey)
- , Hmac
+ , HMAC
, hmac
) where
@@ -30,7 +30,7 @@ import Data.Digest.Internal (Algorithm(Algorithm), Digest(Digest))
import Foreign.Ptr.ConstantTimeEquals (constantTimeEquals)
import Internal.Base
import Internal.Digest
-import Internal.Hmac
+import Internal.HMAC
type LazyByteString = ByteString.Lazy.ByteString
@@ -41,29 +41,29 @@ newtype SecretKey = SecretKey ByteString
-- | A hash-based message authentication code. Equality comparisons on this type
-- are constant-time.
-newtype Hmac = Hmac ByteString
+newtype HMAC = HMAC ByteString
-instance Eq Hmac where
- (Hmac a) == (Hmac b) =
+instance Eq HMAC where
+ (HMAC a) == (HMAC b) =
unsafeLocalState $
ByteString.unsafeUseAsCStringLen a $ \(a', size) ->
ByteString.unsafeUseAsCStringLen b $ \(b', _) ->
constantTimeEquals a' b' size
-instance Show Hmac where
- show (Hmac m) = show (Digest m)
+instance Show HMAC where
+ show (HMAC m) = show (Digest m)
-- | Creates an HMAC according to the given 'Algorithm'.
-hmac :: Algorithm -> SecretKey -> LazyByteString -> Hmac
+hmac :: Algorithm -> SecretKey -> LazyByteString -> HMAC
hmac (Algorithm md) (SecretKey key) bytes =
unsafeLocalState $ do
- ctxFP <- mallocHmacCtx
+ ctxFP <- mallocHMACCtx
withForeignPtr ctxFP $ \ctx -> do
ByteString.unsafeUseAsCStringLen key $ \(keyBytes, keySize) ->
hmacInitEx ctx keyBytes (fromIntegral keySize) md noEngine
mapM_ (updateBytes ctx) (ByteString.Lazy.toChunks bytes)
m <-
- allocaArray evpMaxMdSize $ \hmacOut ->
+ allocaArray evpMaxMDSize $ \hmacOut ->
alloca $ \pOutSize -> do
hmacFinal ctx hmacOut pOutSize
outSize <- fromIntegral <$> peek pOutSize
@@ -71,7 +71,7 @@ hmac (Algorithm md) (SecretKey key) bytes =
-- GHC reinterpret it as a 'Ptr CChar' so that it can be ingested
-- into a 'ByteString'.
ByteString.packCStringLen (unsafeCoerce hmacOut, outSize)
- return (Hmac m)
+ return (HMAC m)
where
updateBytes ctx chunk =
-- 'hmacUpdate' treats its @bytes@ argument as @const@, so the sharing
diff --git a/src/Internal/Base.chs b/src/Internal/Base.chs
index 427cf6b..c2e615a 100644
--- a/src/Internal/Base.chs
+++ b/src/Internal/Base.chs
@@ -30,14 +30,14 @@ noEngine = nullPtr
-- | The BoringSSL @EVP_MD_CTX@ type, representing the state of a pending
-- hashing operation.
-data EvpMdCtx
-{#pointer *EVP_MD_CTX as 'Ptr EvpMdCtx' -> EvpMdCtx nocode#}
+data EVPMDCtx
+{#pointer *EVP_MD_CTX as 'Ptr EVPMDCtx' -> EVPMDCtx nocode#}
-- | The BoringSSL @EVP_MD@ type, representing a hash algorithm.
-data EvpMd
-{#pointer *EVP_MD as 'Ptr EvpMd' -> EvpMd nocode#}
+data EVPMD
+{#pointer *EVP_MD as 'Ptr EVPMD' -> EVPMD nocode#}
-- | The BoringSSL @HMAC_CTX@ type, representing the state of a pending HMAC
-- operation.
-data HmacCtx
-{#pointer *HMAC_CTX as 'Ptr HmacCtx' -> HmacCtx nocode#}
+data HMACCtx
+{#pointer *HMAC_CTX as 'Ptr HMACCtx' -> HMACCtx nocode#}
diff --git a/src/Internal/Digest.chs b/src/Internal/Digest.chs
index 021de22..d451f1c 100644
--- a/src/Internal/Digest.chs
+++ b/src/Internal/Digest.chs
@@ -16,10 +16,10 @@
{-# OPTIONS_GHC -Wno-orphans #-}
module Internal.Digest
- ( evpMd5, evpSha1, evpSha224, evpSha256, evpSha384, evpSha512
- , mallocEvpMdCtx
+ ( evpMD5, evpSHA1, evpSHA224, evpSHA256, evpSHA384, evpSHA512
+ , mallocEVPMDCtx
, evpDigestInitEx, evpDigestUpdate, evpDigestFinalEx
- , evpMaxMdSize
+ , evpMaxMDSize
) where
import Foreign
@@ -33,40 +33,40 @@ import Result
#include <openssl/digest.h>
-evpMd5, evpSha1, evpSha224, evpSha256, evpSha384, evpSha512 :: Ptr EvpMd
-evpMd5 = {#call pure EVP_md5 as ^#}
-evpSha1 = {#call pure EVP_sha1 as ^#}
-evpSha224 = {#call pure EVP_sha224 as ^#}
-evpSha256 = {#call pure EVP_sha256 as ^#}
-evpSha384 = {#call pure EVP_sha384 as ^#}
-evpSha512 = {#call pure EVP_sha512 as ^#}
+evpMD5, evpSHA1, evpSHA224, evpSHA256, evpSHA384, evpSHA512 :: Ptr EVPMD
+evpMD5 = {#call pure EVP_md5 as ^#}
+evpSHA1 = {#call pure EVP_sha1 as ^#}
+evpSHA224 = {#call pure EVP_sha224 as ^#}
+evpSHA256 = {#call pure EVP_sha256 as ^#}
+evpSHA384 = {#call pure EVP_sha384 as ^#}
+evpSHA512 = {#call pure EVP_sha512 as ^#}
--- | Memory-safe allocator for 'EvpMdCtx'.
-mallocEvpMdCtx :: IO (ForeignPtr EvpMdCtx)
-mallocEvpMdCtx = do
+-- | Memory-safe allocator for 'EVPMDCtx'.
+mallocEVPMDCtx :: IO (ForeignPtr EVPMDCtx)
+mallocEVPMDCtx = do
fp <- mallocForeignPtr
withForeignPtr fp {#call EVP_MD_CTX_init as ^#}
- addForeignPtrFinalizer btlsFinalizeEvpMdCtxPtr fp
+ addForeignPtrFinalizer btlsFinalizeEVPMDCtxPtr fp
return fp
-foreign import ccall "&btlsFinalizeEvpMdCtx"
- btlsFinalizeEvpMdCtxPtr :: FinalizerPtr EvpMdCtx
+foreign import ccall "&btlsFinalizeEVPMDCtx"
+ btlsFinalizeEVPMDCtxPtr :: FinalizerPtr EVPMDCtx
-evpDigestInitEx :: Ptr EvpMdCtx -> Ptr EvpMd -> Ptr Engine -> IO ()
+evpDigestInitEx :: Ptr EVPMDCtx -> Ptr EVPMD -> Ptr Engine -> IO ()
evpDigestInitEx ctx md engine =
requireSuccess $ {#call EVP_DigestInit_ex as ^#} ctx md engine
-evpDigestUpdate :: Ptr EvpMdCtx -> Ptr a -> CULong -> IO ()
+evpDigestUpdate :: Ptr EVPMDCtx -> Ptr a -> CULong -> IO ()
evpDigestUpdate ctx md bytes =
alwaysSucceeds $ {#call EVP_DigestUpdate as ^#} ctx (asVoidPtr md) bytes
-evpDigestFinalEx :: Ptr EvpMdCtx -> Ptr CUChar -> Ptr CUInt -> IO ()
+evpDigestFinalEx :: Ptr EVPMDCtx -> Ptr CUChar -> Ptr CUInt -> IO ()
evpDigestFinalEx ctx mdOut outSize =
alwaysSucceeds $ {#call EVP_DigestFinal_ex as ^#} ctx mdOut outSize
-evpMaxMdSize :: Int
-evpMaxMdSize = {#const EVP_MAX_MD_SIZE#}
+evpMaxMDSize :: Int
+evpMaxMDSize = {#const EVP_MAX_MD_SIZE#}
-instance Storable EvpMdCtx where
+instance Storable EVPMDCtx where
sizeOf _ = {#sizeof EVP_MD_CTX#}
alignment _ = {#alignof EVP_MD_CTX#}
diff --git a/src/Internal/Hmac.chs b/src/Internal/HMAC.chs
index 0ef1e2e..7e64edf 100644
--- a/src/Internal/Hmac.chs
+++ b/src/Internal/HMAC.chs
@@ -15,8 +15,8 @@
{-# OPTIONS_GHC -Wno-missing-methods #-}
{-# OPTIONS_GHC -Wno-orphans #-}
-module Internal.Hmac
- ( mallocHmacCtx
+module Internal.HMAC
+ ( mallocHMACCtx
, hmacInitEx, hmacUpdate, hmacFinal
) where
@@ -31,30 +31,30 @@ import Result
#include <openssl/hmac.h>
--- | Memory-safe allocator for 'HmacCtx'.
-mallocHmacCtx :: IO (ForeignPtr HmacCtx)
-mallocHmacCtx = do
+-- | Memory-safe allocator for 'HMACCtx'.
+mallocHMACCtx :: IO (ForeignPtr HMACCtx)
+mallocHMACCtx = do
fp <- mallocForeignPtr
withForeignPtr fp {#call HMAC_CTX_init as ^#}
addForeignPtrFinalizer hmacCtxCleanup fp
return fp
foreign import ccall "&HMAC_CTX_cleanup"
- hmacCtxCleanup :: FinalizerPtr HmacCtx
+ hmacCtxCleanup :: FinalizerPtr HMACCtx
-hmacInitEx :: Ptr HmacCtx -> Ptr a -> CULong -> Ptr EvpMd -> Ptr Engine -> IO ()
+hmacInitEx :: Ptr HMACCtx -> Ptr a -> CULong -> Ptr EVPMD -> Ptr Engine -> IO ()
hmacInitEx ctx bytes size md engine =
requireSuccess $
{#call HMAC_Init_ex as ^#} ctx (asVoidPtr bytes) size md engine
-hmacUpdate :: Ptr HmacCtx -> Ptr CUChar -> CULong -> IO ()
+hmacUpdate :: Ptr HMACCtx -> Ptr CUChar -> CULong -> IO ()
hmacUpdate ctx bytes size =
alwaysSucceeds $ {#call HMAC_Update as ^#} ctx bytes size
-hmacFinal :: Ptr HmacCtx -> Ptr CUChar -> Ptr CUInt -> IO ()
+hmacFinal :: Ptr HMACCtx -> Ptr CUChar -> Ptr CUInt -> IO ()
hmacFinal ctx out outSize =
requireSuccess $ {#call HMAC_Final as ^#} ctx out outSize
-instance Storable HmacCtx where
+instance Storable HMACCtx where
sizeOf _ = {#sizeof HMAC_CTX#}
alignment _ = {#alignof HMAC_CTX#}
diff --git a/tests/Data/Digest/HashTests.hs b/tests/Data/Digest/HashTests.hs
index 16b1aa8..45b31e2 100644
--- a/tests/Data/Digest/HashTests.hs
+++ b/tests/Data/Digest/HashTests.hs
@@ -17,7 +17,7 @@
module Data.Digest.HashTests
( tableTestCase
, testAgainstCoreutils
- , testAgainstOpenssl
+ , testAgainstOpenSSL
) where
import Data.ByteString (ByteString)
@@ -55,8 +55,8 @@ runExternal p s = do
hClose stdin -- causes process to exit
hGetContents stdout
-testAgainstOpenssl :: (ByteString -> String) -> String -> Property IO
-testAgainstOpenssl f flag =
+testAgainstOpenSSL :: (ByteString -> String) -> String -> Property IO
+testAgainstOpenSSL f flag =
over ByteString.Series.enumW8s $ \s ->
monadic $ do
theirs <- runExternal (proc "openssl" ["dgst", '-' : flag]) s
diff --git a/tests/Data/Digest/Md5Tests.hs b/tests/Data/Digest/MD5Tests.hs
index 79f8757..0db7bcb 100644
--- a/tests/Data/Digest/Md5Tests.hs
+++ b/tests/Data/Digest/MD5Tests.hs
@@ -14,26 +14,26 @@
{-# LANGUAGE OverloadedStrings #-}
-module Data.Digest.Md5Tests (tests) where
+module Data.Digest.MD5Tests (tests) where
import qualified Data.ByteString.Lazy as ByteString.Lazy
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.SmallCheck (testProperty)
import Data.Digest.HashTests
- (tableTestCase, testAgainstCoreutils, testAgainstOpenssl)
+ (tableTestCase, testAgainstCoreutils, testAgainstOpenSSL)
import Data.Digest (hash, md5)
tests :: TestTree
tests = testGroup "MD5"
- [ testRfcExamples
+ [ testRFCExamples
, testGoExamples
, testCoreutilsConformance
- , testOpensslConformance
+ , testOpenSSLConformance
]
-- | MD5 example vectors from RFC 1321.
-testRfcExamples = testGroup "RFC 1321 examples" $
+testRFCExamples = testGroup "RFC 1321 examples" $
map (tableTestCase md5sum)
[ ("d41d8cd98f00b204e9800998ecf8427e", "")
, ("0cc175b9c0f1b6a831c399e269772661", "a")
@@ -85,8 +85,8 @@ testCoreutilsConformance = testProperty "conformance with coreutils" $
testAgainstCoreutils md5sum "md5sum"
-- | Tests our MD5 implementation against openssl(1)'s.
-testOpensslConformance = testProperty "conformance with OpenSSL" $
- testAgainstOpenssl md5sum "md5"
+testOpenSSLConformance = testProperty "conformance with OpenSSL" $
+ testAgainstOpenSSL md5sum "md5"
-- Convenience function.
md5sum = show . hash md5 . ByteString.Lazy.fromStrict
diff --git a/tests/Data/Digest/Sha1Tests.hs b/tests/Data/Digest/SHA1Tests.hs
index ea84553..362660f 100644
--- a/tests/Data/Digest/Sha1Tests.hs
+++ b/tests/Data/Digest/SHA1Tests.hs
@@ -14,7 +14,7 @@
{-# LANGUAGE OverloadedStrings #-}
-module Data.Digest.Sha1Tests (tests) where
+module Data.Digest.SHA1Tests (tests) where
import qualified Data.ByteString.Lazy as ByteString.Lazy
import Test.Tasty (TestTree, testGroup)
@@ -22,7 +22,7 @@ import Test.Tasty.HUnit ((@?=), testCase)
import Test.Tasty.SmallCheck (testProperty)
import Data.Digest.HashTests
- (tableTestCase, testAgainstCoreutils, testAgainstOpenssl)
+ (tableTestCase, testAgainstCoreutils, testAgainstOpenSSL)
import Data.Digest (hash, sha1)
tests :: TestTree
@@ -30,7 +30,7 @@ tests = testGroup "SHA-1"
[ testNistExamples
, testGoExamples
, testCoreutilsConformance
- , testOpensslConformance
+ , testOpenSSLConformance
]
@@ -83,8 +83,8 @@ testCoreutilsConformance = testProperty "conformance with coreutils" $
testAgainstCoreutils sha1sum "sha1sum"
-- | Tests our SHA-1 implementation against openssl(1)'s.
-testOpensslConformance = testProperty "conformance with OpenSSL" $
- testAgainstOpenssl sha1sum "sha1"
+testOpenSSLConformance = testProperty "conformance with OpenSSL" $
+ testAgainstOpenSSL sha1sum "sha1"
-- Convenience function.
sha1sum = show . hash sha1 . ByteString.Lazy.fromStrict
diff --git a/tests/Data/Digest/Sha2Tests.hs b/tests/Data/Digest/SHA2Tests.hs
index 374157c..eecf1d8 100644
--- a/tests/Data/Digest/Sha2Tests.hs
+++ b/tests/Data/Digest/SHA2Tests.hs
@@ -14,7 +14,7 @@
{-# LANGUAGE OverloadedStrings #-}
-module Data.Digest.Sha2Tests (tests) where
+module Data.Digest.SHA2Tests (tests) where
import qualified Data.ByteString.Lazy as ByteString.Lazy
import Test.Tasty (TestTree, testGroup)
@@ -22,7 +22,7 @@ import Test.Tasty.HUnit ((@?=), testCase)
import Test.Tasty.SmallCheck (testProperty)
import Data.Digest.HashTests
- (tableTestCase, testAgainstCoreutils, testAgainstOpenssl)
+ (tableTestCase, testAgainstCoreutils, testAgainstOpenSSL)
import Data.Digest (hash, sha224, sha256, sha384, sha512)
tests :: TestTree
@@ -30,47 +30,47 @@ tests = testGroup "SHA-2"
[ testNistExamples
, testGoExamples
, testCoreutilsConformance
- , testOpensslConformance
+ , testOpenSSLConformance
]
-- | SHA-2 example vectors from
-- https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values.
testNistExamples = testGroup "NIST examples"
- [ testNistSha224
- , testNistSha256
- , testNistSha384
- , testNistSha512
+ [ testNistSHA224
+ , testNistSHA256
+ , testNistSHA384
+ , testNistSHA512
]
-testNistSha224 = testGroup "SHA-224"
+testNistSHA224 = testGroup "SHA-224"
[ testCase "one-block" $ sha224sum "abc" @?= "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7"
, testCase "two-block" $ sha224sum "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" @?= "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525"
]
-testNistSha256 = testGroup "SHA-256"
+testNistSHA256 = testGroup "SHA-256"
[ testCase "one-block" $ sha256sum "abc" @?= "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
, testCase "two-block" $ sha256sum "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" @?= "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
]
-testNistSha384 = testGroup "SHA-384"
+testNistSHA384 = testGroup "SHA-384"
[ testCase "one-block" $ sha384sum "abc" @?= "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"
, testCase "two-block" $ sha384sum "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" @?= "09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"
]
-testNistSha512 = testGroup "SHA-512"
+testNistSHA512 = testGroup "SHA-512"
[ testCase "one-block" $ sha512sum "abc" @?= "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"
, testCase "two-block" $ sha512sum "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" @?= "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"
]
-- | Test vectors used to test the Go SHA-2 implementations.
testGoExamples = testGroup "Go tests"
- [ testGoSha224
- , testGoSha256
- , testGoSha384
- , testGoSha512
+ [ testGoSHA224
+ , testGoSHA256
+ , testGoSHA384
+ , testGoSHA512
]
-testGoSha224 = testGroup "SHA-224" $
+testGoSHA224 = testGroup "SHA-224" $
map (tableTestCase sha224sum)
[ ("d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f", "")
, ("abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5", "a")
@@ -105,7 +105,7 @@ testGoSha224 = testGroup "SHA-224" $
, ("86ed2eaa9c75ba98396e5c9fb2f679ecf0ea2ed1e0ee9ceecb4a9332", "How can you write a big system without C++? -Paul Glick")
]
-testGoSha256 = testGroup "SHA-256" $
+testGoSHA256 = testGroup "SHA-256" $
map (tableTestCase sha256sum)
[ ("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "")
, ("ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "a")
@@ -140,7 +140,7 @@ testGoSha256 = testGroup "SHA-256" $
, ("4f9b189a13d030838269dce846b16a1ce9ce81fe63e65de2f636863336a98fe6", "How can you write a big system without C++? -Paul Glick")
]
-testGoSha384 = testGroup "SHA-384" $
+testGoSHA384 = testGroup "SHA-384" $
map (tableTestCase sha384sum)
[ ("38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b", "")
, ("54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31", "a")
@@ -175,7 +175,7 @@ testGoSha384 = testGroup "SHA-384" $
, ("1764b700eb1ead52a2fc33cc28975c2180f1b8faa5038d94cffa8d78154aab16e91dd787e7b0303948ebed62561542c8", "How can you write a big system without C++? -Paul Glick")
]
-testGoSha512 = testGroup "SHA-512" $
+testGoSHA512 = testGroup "SHA-512" $
map (tableTestCase sha512sum)
[ ("cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e", "")
, ("1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75", "a")
@@ -219,11 +219,11 @@ testCoreutilsConformance = testGroup "conformance with coreutils"
]
-- | Tests our SHA-2 implementations against openssl(1)'s.
-testOpensslConformance = testGroup "conformance with OpenSSL"
- [ testProperty "SHA-224" $ testAgainstOpenssl sha224sum "sha224"
- , testProperty "SHA-256" $ testAgainstOpenssl sha256sum "sha256"
- , testProperty "SHA-384" $ testAgainstOpenssl sha384sum "sha384"
- , testProperty "SHA-512" $ testAgainstOpenssl sha512sum "sha512"
+testOpenSSLConformance = testGroup "conformance with OpenSSL"
+ [ testProperty "SHA-224" $ testAgainstOpenSSL sha224sum "sha224"
+ , testProperty "SHA-256" $ testAgainstOpenSSL sha256sum "sha256"
+ , testProperty "SHA-384" $ testAgainstOpenSSL sha384sum "sha384"
+ , testProperty "SHA-512" $ testAgainstOpenSSL sha512sum "sha512"
]
-- Convenience functions.
diff --git a/tests/Data/DigestTests.hs b/tests/Data/DigestTests.hs
index daef282..5bcf3b1 100644
--- a/tests/Data/DigestTests.hs
+++ b/tests/Data/DigestTests.hs
@@ -16,13 +16,13 @@ module Data.DigestTests (tests) where
import Test.Tasty (TestTree, testGroup)
-import qualified Data.Digest.Md5Tests
-import qualified Data.Digest.Sha1Tests
-import qualified Data.Digest.Sha2Tests
+import qualified Data.Digest.MD5Tests
+import qualified Data.Digest.SHA1Tests
+import qualified Data.Digest.SHA2Tests
tests :: TestTree
tests = testGroup "Data.Digest"
- [ Data.Digest.Md5Tests.tests
- , Data.Digest.Sha1Tests.tests
- , Data.Digest.Sha2Tests.tests
+ [ Data.Digest.MD5Tests.tests
+ , Data.Digest.SHA1Tests.tests
+ , Data.Digest.SHA2Tests.tests
]
diff --git a/tests/Data/HmacTests.hs b/tests/Data/HMACTests.hs
index c1abc38..06ee8eb 100644
--- a/tests/Data/HmacTests.hs
+++ b/tests/Data/HMACTests.hs
@@ -14,7 +14,7 @@
{-# LANGUAGE OverloadedStrings #-}
-module Data.HmacTests (tests) where
+module Data.HMACTests (tests) where
import qualified Data.ByteString as ByteString
import qualified Data.ByteString.Lazy as ByteString.Lazy
@@ -23,15 +23,15 @@ import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit ((@?=), testCase)
import Data.Digest (md5, sha1, sha224, sha256, sha384, sha512)
-import Data.Hmac (SecretKey(SecretKey), hmac)
+import Data.HMAC (SecretKey(SecretKey), hmac)
type LazyByteString = ByteString.Lazy.ByteString
tests :: TestTree
-tests = testGroup "Data.Hmac"
- [ testRfc2202
+tests = testGroup "Data.HMAC"
+ [ testRFC2202
, testFips198
- , testRfc4231
+ , testRFC4231
]
tableTestCase ::
@@ -47,7 +47,7 @@ abbreviate input =
x ++ (if null y then "" else "...") ++ "\""
-- | Tests from RFC 2202.
-testRfc2202 = testGroup "RFC 2202" [testMd5, testSha1]
+testRFC2202 = testGroup "RFC 2202" [testMd5, testSha1]
where
testMd5 = testGroup "MD5" $
map (tableTestCase hmacMd5)
@@ -132,7 +132,7 @@ rfc4231TestCase (key, input, sha224Output, sha256Output, sha384Output, sha512Out
]
-- | Tests from RFC 4231.
-testRfc4231 = testGroup "RFC 4231" $
+testRFC4231 = testGroup "RFC 4231" $
map rfc4231TestCase
[ ( SecretKey (ByteString.replicate 20 0x0b)
, "Hi There"
@@ -171,9 +171,9 @@ testRfc4231 = testGroup "RFC 4231" $
, "6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e"
, "e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58")
]
- ++ [truncatedRfc4231Test]
+ ++ [truncatedRFC4231Test]
-truncatedRfc4231Test =
+truncatedRFC4231Test =
let key = SecretKey (ByteString.replicate 20 0x0c)
input = "Test With Truncation" :: LazyByteString
t f = take 32 (f key input) :: String
diff --git a/tests/Tests.hs b/tests/Tests.hs
index 58e9be6..ee38f2a 100644
--- a/tests/Tests.hs
+++ b/tests/Tests.hs
@@ -19,10 +19,10 @@ module Main
import Test.Tasty (defaultMain, testGroup)
import qualified Data.DigestTests
-import qualified Data.HmacTests
+import qualified Data.HMACTests
main :: IO ()
main = defaultMain $ testGroup "btls"
[ Data.DigestTests.tests
- , Data.HmacTests.tests
+ , Data.HMACTests.tests
]