#
# Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License").  You may not use
# this file except in compliance with the License.  You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html

# Tests start with one of these keywords
#       Cipher Decrypt Derive Digest Encoding KDF MAC PBE
#       PrivPubKeyPair Sign Verify VerifyRecover
# and continue until a blank line. Lines starting with a pound sign are ignored.


Title = SHA tests from (RFC6234 section 8.5 and others)

Digest = SHA1
Input = "abc"
Output = a9993e364706816aba3e25717850c26c9cd0d89d

Digest = SHA1
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
Output = 84983e441c3bd26ebaae4aa1f95129e5e54670f1

Digest = SHA1
Input = "a"
Ncopy = 1000
Count = 1000
Output = 34aa973cd4c4daa4f61eeb2bdbad27316534016f

Digest = SHA224
Input = "abc"
Output = 23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7

Digest = SHA224
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
Output = 75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525

Digest = SHA224
Input = "a"
Ncopy = 64
Count = 15625
Output = 20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67

Digest = SHA256
Input = "abc"
Output = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad

Digest = SHA256
Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
Output = 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1

Digest = SHA256
Input = "a"
Ncopy = 288
Count = 3472
Input = "a"
Ncopy = 64
Output = cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0

Digest = SHA384
Input = "abc"
Output = cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7

Digest = SHA384
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
Output = 09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039

Digest = SHA384
Input = "a"
Ncopy = 64
Count = 15625
Output = 9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985

Digest = SHA512
Input = "abc"
Output = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f

Digest = SHA512
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
Output = 8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909

Digest = SHA512
Input = "a"
Ncopy = 288
Count = 3472
Input = "a"
Ncopy = 64
Output = e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b

# Some of the test vectors from the SHS CAVP for FIPS 180-4
Digest = SHA512-224
Input = 
Output = 6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4

Digest = SHA512-224
Input = cf
Output = 4199239e87d47b6feda016802bf367fb6e8b5655eff6225cb2668f4a

Digest = SHA512-224
Input = ca2d
Output = 392b99b593b85e147f031986c2a9edfdb4ffd9f24c77c452d339c9fc

Digest = SHA512-224
Input = 6963446913771410
Output = 21f6c373637e6a5e89d6e88811110c5c3fa12e497144912914c546e1

Digest = SHA512-224
Input = 44c6c75e377f21fc9cd7c164ca5c4cb82c5538a58dfb323992e6bcf588c61b246053706bf88725a09d0a8adfcdeec0db419cd7732b0e3386bc3f3407e9e016546f4d15c314bfd57e30c302926deb3342cbc315a1e706c5607c127de42a9a739b
Output = b9b62986eebdb35c88b12e0257537a05394ef5a16fad01c2fec57d6f

# The two examples from: https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA512_224.pdf
Digest = SHA512-224
Input = "abc"
Output = 4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa

Digest = SHA512-224
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
Output = 23fec5bb94d60b23308192640b0c453335d664734fe40e7268674af9

# Some of the test vectors from the SHS CAVP for FIPS 180-4
Digest = SHA512-256
Input = 
Output = c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a

Digest = SHA512-256
Input = fa
Output = c4ef36923c64e51e875720e550298a5ab8a3f2f875b1e1a4c9b95babf7344fef

Digest = SHA512-256
Input = 74e4
Output = 0c994228b8d3bd5ea5b5259157a9bba7a193118ad22817e6fbed2df1a32a4148

Digest = SHA512-256
Input = b4e2e8501f54be91
Output = d25265bf9cbc0dd2f108a2f5e8f69db7d15e5b8fe9100fe887dae20b6e054fe8

Digest = SHA512-256
Input = 63188781f4e9cbd1e89a54a65da053b93722e1106f00f024ad1582421ab919326f8a6e17536d6596e3cf413a9231141733e37aae540f8711cefafe489a87c4f2e6fd942f6809f3bef3076763487de48c2ee88733c5bc870617a668c6f01471ed
Output = 91a8e285029085e224987078066486b6c605cbac27e49e84f4639710ddd05d33

# The two examples from https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA512_256.pdf
Digest = SHA512-256
Input = "abc"
Output = 53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23

Digest = SHA512-256
Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
Output = 3928e184fb8690f840da3988121d31be65cb9d3ef83ee6146feac861e19b563a



Title = SHA3

# Empty input and \xA3x200 vectors are taken from
# http://csrc.nist.gov/groups/ST/toolkit/examples.html#aHashing
# Others are pairs of "LongMsg" vectors available at
# http://csrc.nist.gov/groups/STM/cavp/secure-hashing.html#test-vectors

Digest = SHA3-224
Input = ""
Output = 6B4E03423667DBB73B6E15454F0EB1ABD4597F9A1B078E3F5B5A6BC7

Digest = SHA3-224
Input = A3
Count = 200
Output = 9376816ABA503F72F96CE7EB65AC095DEEE3BE4BF9BBC2A1CB7E11E0

Digest = SHA3-224
Input =  
Output = aab23c9e7fb9d7dacefdfd0b1ae85ab1374abff7c4e3f7556ecae412

Digest = SHA3-224
Input =  
Output = d61f04985026eee29d0f9700f8c5aea32ec2c23b1a9357edeb2be20c


Digest = SHA3-256
Input = ""
Output = A7FFC6F8BF1ED76651C14756A061D662F580FF4DE43B49FA82D80A4B80F8434A

Digest = SHA3-256
Input = A3
Count = 200
Output = 79F38ADEC5C20307A98EF76E8324AFBFD46CFD81B22E3973C65FA1BD9DE31787

Digest = SHA3-256
Input =  
Output = cb5648a1d61c6c5bdacd96f81c9591debc3950dcf658145b8d996570ba881a05

Digest = SHA3-256
Input =  
Output = 095dcd0bc55206d2e1e715fb7173fc16a81979f278495dfc69a6d8f3174eba5a


Digest = SHA3-384
Input = ""
Output = 0C63A75B845E4F7D01107D852E4C2485C51A50AAAA94FC61995E71BBEE983A2AC3713831264ADB47FB6BD1E058D5F004

Digest = SHA3-384
Input = A3
Count = 200
Output = 1881DE2CA7E41EF95DC4732B8F5F002B189CC1E42B74168ED1732649CE1DBCDD76197A31FD55EE989F2D7050DD473E8F

Digest = SHA3-384
Input = 5fe35923b4e0af7dd24971812a58425519850a506dfa9b0d254795be785786c319a2567cbaa5e35bcf8fe83d943e23fa5169b73adc1fcf8b607084b15e6a013df147e46256e4e803ab75c110f77848136be7d806e8b2f868c16c3a90c14463407038cb7d9285079ef162c6a45cedf9c9f066375c969b5fcbcda37f02aacff4f31cded3767570885426bebd9eca877e44674e9ae2f0c24cdd0e7e1aaf1ff2fe7f80a1c4f5078eb34cd4f06fa94a2d1eab5806ca43fd0f06c60b63d5402b95c70c21ea65a151c5cfaf8262a46be3c722264b
Output = 3054d249f916a6039b2a9c3ebec1418791a0608a170e6d36486035e5f92635eaba98072a85373cb54e2ae3f982ce132b

Digest = SHA3-384
Input =  
Output = 02535d86cc7518484a2a238c921b739b1704a50370a2924abf39958c5976e658dc5e87440063112459bddb40308b1c70


Digest = SHA3-512
Input = ""
Output = A69F73CCA23A9AC5C8B567DC185A756E97C982164FE25859E0D1DCC1475C80A615B2123AF1F5F94C11E3E9402C3AC558F500199D95B6D3E301758586281DCD26

Digest = SHA3-512
Input = A3
Count = 200
Output = E76DFAD22084A8B1467FCF2FFA58361BEC7628EDF5F3FDC0E4805DC48CAEECA81B7C13C30ADF52A3659584739A2DF46BE589C51CA1A4A8416DF6545A1CE8BA00

Digest = SHA3-512
Input = 664ef2e3a7059daf1c58caf52008c5227e85cdcb83b4c59457f02c508d4f4f69f826bd82c0cffc5cb6a97af6e561c6f96970005285e58f21ef6511d26e709889a7e513c434c90a3cf7448f0caeec7114c747b2a0758a3b4503a7cf0c69873ed31d94dbef2b7b2f168830ef7da3322c3d3e10cafb7c2c33c83bbf4c46a31da90cff3bfd4ccc6ed4b310758491eeba603a76
Output = e5825ff1a3c070d5a52fbbe711854a440554295ffb7a7969a17908d10163bfbe8f1d52a676e8a0137b56a11cdf0ffbb456bc899fc727d14bd8882232549d914e

Digest = SHA3-512
Input = 991c4e7402c7da689dd5525af76fcc58fe9cc1451308c0c4600363586ccc83c9ec10a8c9ddaec3d7cfbd206484d09634b9780108440bf27a5fa4a428446b3214fa17084b6eb197c5c59a4e8df1cfc521826c3b1cbf6f4212f6bfb9bc106dfb5568395643de58bffa2774c31e67f5c1e7017f57caadbb1a56cc5b8a5cf9584552e17e7af9542ba13e9c54695e0dc8f24eddb93d5a3678e10c8a80ff4f27b677d40bef5cb5f9b3a659cc4127970cd2c11ebf22d514812dfefdd73600dfc10efba38e93e5bff47736126043e50f8b9b941e4ec3083fb762dbf15c86
Output = cd0f2a48e9aa8cc700d3f64efb013f3600ebdbb524930c682d21025eab990eb6d7c52e611f884031fafd9360e5225ab7e4ec24cbe97f3af6dbe4a86a4f068ba7

Digest = SHAKE128
Input = ""
Output =  

Digest = SHAKE128
Input = A3
Count = 200
Output =  

Digest = SHAKE128
Input =  
Output = 3109d9472ca436e805c6b3db2251a9bc

Digest = SHAKE128
Input =  
Output = c609be05458f7ab33e7b6b54bc6e8999

Digest = SHAKE256
Input = ""
Output =  

Digest = SHAKE256
Input = A3
Count = 200
Output =  

Digest = SHAKE256
Input =  
Output = 2bac5716803a9cda8f9e84365ab0a681327b5ba34fdedfb1c12e6e807f45284b

Digest = SHAKE256
Input =  
Output = 21a48efd949c3f785179a0e340756a23f77d29a7625229a71a05731c7fbd5aa9

# Following tests are pairs of *last* "VariableOut" vectors from
# http://csrc.nist.gov/groups/STM/cavp/secure-hashing.html#test-vectors

Digest = SHAKE128
Input = c60a221c975e14bf835827c1103a2906
Output = 0db7f7196eee8dd6994a16ded19cb09f05f89ccd2464333df2c017c6ca041fa0d54a4832a74ce86ce9b41d8e523e66ce6ef9df7c20aa70e0ac00f54eb072a472ef46cf2a933df0d5f9fafab6388a206f6bd1df50b0836500c758c557c8ac965733fdaaa59f5ed661a1bda61e2952886a60f9568157e3d72e49b6e061fc08f3f1caf159e8eff77ea5221565d2

Digest = SHAKE128
Input = 0a13ad2c7a239b4ba73ea6592ae84ea9
Output = 5feaf99c15f48851943ff9baa6e5055d8377f0dd347aa4dbece51ad3a6d9ce0c01aee9fe2260b80a4673a909b532adcdd1e421c32d6460535b5fe392a58d2634979a5a104d6c470aa3306c400b061db91c463b2848297bca2bc26d1864ba49d7ff949ebca50fbf79a5e63716dc82b600bd52ca7437ed774d169f6bf02e46487956fba2230f34cd2a0485484d

Digest = SHAKE256
Input = 6ae23f058f0f2264a18cd609acc26dd4dbc00f5c3ee9e13ecaea2bb5a2f0bb6b
Output = b9b92544fb25cfe4ec6fe437d8da2bbe00f7bdaface3de97b8775a44d753c3adca3f7c6f183cc8647e229070439aa9539ae1f8f13470c9d3527fffdeef6c94f9f0520ff0c1ba8b16e16014e1af43ac6d94cb7929188cce9d7b02f81a2746f52ba16988e5f6d93298d778dfe05ea0ef256ae3728643ce3e29c794a0370e9ca6a8bf3e7a41e86770676ac106f7ae79e67027ce7b7b38efe27d253a52b5cb54d6eb4367a87736ed48cb45ef27f42683da140ed3295dfc575d3ea38cfc2a3697cc92864305407369b4abac054e497378dd9fd0c4b352ea3185ce1178b3dc1599df69db29259d4735320c8e7d33e8226620c9a1d22761f1d35bdff79a

Digest = SHAKE256
Input = 8d8001e2c096f1b88e7c9224a086efd4797fbf74a8033a2d422a2b6b8f6747e4
Output = 2e975f6a8a14f0704d51b13667d8195c219f71e6345696c49fa4b9d08e9225d3d39393425152c97e71dd24601c11abcfa0f12f53c680bd3ae757b8134a9c10d429615869217fdd5885c4db174985703a6d6de94a667eac3023443a8337ae1bc601b76d7d38ec3c34463105f0d3949d78e562a039e4469548b609395de5a4fd43c46ca9fd6ee29ada5efc07d84d553249450dab4a49c483ded250c9338f85cd937ae66bb436f3b4026e859fda1ca571432f3bfc09e7c03ca4d183b741111ca0483d0edabc03feb23b17ee48e844ba2408d9dcfd0139d2e8c7310125aee801c61ab7900d1efc47c078281766f361c5e6111346235e1dc38325666c

Title = Case insensitive digest tests

Digest = Sha3-256
Input = ""
Output = A7FFC6F8BF1ED76651C14756A061D662F580FF4DE43B49FA82D80A4B80F8434A

Digest = shA512
Input = "abc"
Output = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f

