sha-validation-0.1.0.1: Validation SHA Implementations
CopyrightCopyright © 2022-2024 Lars Kuhtz <lakuhtz@gmail.com>
LicenseMIT
MaintainerLars Kuhtz <lakuhtz@gmail.com>
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Hash.SHA3

Description

Synopsis

Selected Long Messages Test for Byte-Oriented Implementations

data MsgFile Source #

Constructors

MsgFile 

Instances

Instances details
Show MsgFile Source # 
Instance details

Defined in Test.Hash.Internal

Eq MsgFile Source # 
Instance details

Defined in Test.Hash.Internal

Methods

(==) :: MsgFile -> MsgFile -> Bool #

(/=) :: MsgFile -> MsgFile -> Bool #

Ord MsgFile Source # 
Instance details

Defined in Test.Hash.Internal

Lift MsgFile Source # 
Instance details

Defined in Test.Hash.Internal

Methods

lift :: Quote m => MsgFile -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => MsgFile -> Code m MsgFile #

data MsgVector Source #

Constructors

MsgVector 

Instances

Instances details
Show MsgVector Source # 
Instance details

Defined in Test.Hash.Internal

Eq MsgVector Source # 
Instance details

Defined in Test.Hash.Internal

Ord MsgVector Source # 
Instance details

Defined in Test.Hash.Internal

Lift MsgVector Source # 
Instance details

Defined in Test.Hash.Internal

Methods

lift :: Quote m => MsgVector -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => MsgVector -> Code m MsgVector #

sha3_224LongMsg :: MsgFile Source #

SHA3_224LongMsg.rsp

sha3_256LongMsg :: MsgFile Source #

SHA3_256LongMsg.rsp

sha3_384LongMsg :: MsgFile Source #

SHA3_384LongMsg.rsp

sha3_512LongMsg :: MsgFile Source #

SHA3_512LongMsg.rsp

Selected Short Messages Test for Byte-Oriented Implementations

sha3_224ShortMsg :: MsgFile Source #

SHA3_224ShortMsg.rsp

sha3_256ShortMsg :: MsgFile Source #

SHA3_256ShortMsg.rsp

sha3_384ShortMsg :: MsgFile Source #

SHA3_384ShortMsg.rsp

sha3_512ShortMsg :: MsgFile Source #

SHA3_512ShortMsg.rsp

The Pseudorandomly Generated Messages (Monte Carlo) Tests

data MonteFile Source #

Instances

Instances details
Show MonteFile Source # 
Instance details

Defined in Test.Hash.Internal

Eq MonteFile Source # 
Instance details

Defined in Test.Hash.Internal

Ord MonteFile Source # 
Instance details

Defined in Test.Hash.Internal

Lift MonteFile Source # 
Instance details

Defined in Test.Hash.Internal

Methods

lift :: Quote m => MonteFile -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => MonteFile -> Code m MonteFile #

sha3_224Monte :: MonteFile Source #

Monte Carlo SHA-3 Hash Function Tests for Hashing Byte-Oriented Messages

SHA3_224Monte.rsp

sha3_256Monte :: MonteFile Source #

SHA3_256Monte.rsp

sha3_384Monte :: MonteFile Source #

SHA3_384Monte.rsp

sha3_512Monte :: MonteFile Source #

SHA3_512Monte.rsp

Test Utils

msgTest :: (ByteString -> ByteString) -> MsgFile -> Bool Source #

Check that all test vectors in a File are satisfied by a given hash implementation.

msgAssert Source #

Arguments

:: Monad m 
=> (String -> ByteString -> ByteString -> m ())

Function to assertion Equality. The first argument is a test label, the second argument is the actual value, and the thrid value is the expected value.

-> (ByteString -> ByteString)

Hash function

-> MsgFile 
-> m () 

For a given hash implementation, assert the correct result for each test vector in a MsgFile.

The function to assert equality is usually provided by some testing framework.

monteTest :: (ByteString -> ByteString) -> MonteFile -> Bool Source #

Test a given SHA3 implementation for the test vectors in a monte file. See monteAssert for details.

monteAssert Source #

Arguments

:: Monad m 
=> (String -> ByteString -> ByteString -> m ())

Function to assertion Equality. The first argument is a test label, the second argument is the actual value, and the thrid value is the expected value.

-> (ByteString -> ByteString)

Hash function

-> MonteFile 
-> m () 

For a given SHA3 implementation, assert the correct result for each test vector in a MonteFile.

The function to assert equality is usually provided by some testing framework.

The test algorithm is describe in cf. https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/sha3/sha3vs.pdf The pseudo code is as follows:

INPUT: A random Seed n bits long
{
    MD0 = Seed;
    for (j=0; j<100; j++) {
        for (i=1; i<1001; i++) {
            Msgi = MDi-1;
            MDi = SHA3(Msgi);
        }
        MD0 = MD1000;
        OUTPUT: MD0
    }
}

NOTE that the test algorithms for SHA (SHA1 and SHA2) and SHA3 are different.