#ifndef HASH_APP_TEST_VECTORS_H
#define HASH_APP_TEST_VECTORS_H
/** @file 
                    HAshApp_test_vectors.h
   
  HashApp is responsible for testing HashDxe.

  Copyright (c) 2018 Qualcomm Technologies, Inc.  All Rights Reserved.
  Qualcomm Technologies Proprietary and Confidential.

**/

/*=============================================================================
                              EDIT HISTORY
  This section contains comments describing changes made to the module.
  Notice that changes are listed in reverse chronological order.



 when       who      what, where, why
 --------   ---     ---------------------------------------------------------
 02/22/19   jp      Initial version
=============================================================================*/
#include <stdint.h>
#include <Uefi.h>
#include <Library/HashSw.h>
#include <api/securemsm/CeML.h>

UINT8 T26[]="abcdefghijklmnopqrstuvwxyz";
UINT8 T26_Sha1Result[] = {
  0x32, 0xd1, 0x0c, 0x7b, 0x8c, 0xf9, 0x65, 0x70,
  0xca, 0x04, 0xce, 0x37, 0xf2, 0xa1, 0x9d, 0x84,
  0x24, 0x0d, 0x3a, 0x89
};

UINT8 T26_Sha224Result[] = {
  0x45, 0xa5, 0xf7, 0x2c, 0x39, 0xc5, 0xcf, 0xf2,
  0x52, 0x2e, 0xb3, 0x42, 0x97, 0x99, 0xe4, 0x9e,
  0x5f, 0x44, 0xb3, 0x56, 0xef, 0x92, 0x6b, 0xcf,
  0x39, 0x0d, 0xcc, 0xc2
};

UINT8 T26_Sha256Result[] = {
  0x71, 0xc4, 0x80, 0xdf, 0x93, 0xd6, 0xae, 0x2f,
  0x1e, 0xfa, 0xd1, 0x44, 0x7c, 0x66, 0xc9, 0x52,
  0x5e, 0x31, 0x62, 0x18, 0xcf, 0x51, 0xfc, 0x8d,
  0x9e, 0xd8, 0x32, 0xf2, 0xda, 0xf1, 0x8b, 0x73
};

UINT8 T26_Sha384Result[] = {
  0xfe, 0xb6, 0x73, 0x49, 0xdf, 0x3d, 0xb6, 0xf5,
  0x92, 0x48, 0x15, 0xd6, 0xc3, 0xdc, 0x13, 0x3f,
  0x09, 0x18, 0x09, 0x21, 0x37, 0x31, 0xfe, 0x5c,
  0x7b, 0x5f, 0x49, 0x99, 0xe4, 0x63, 0x47, 0x9f,
  0xf2, 0x87, 0x7f, 0x5f, 0x29, 0x36, 0xfa, 0x63,
  0xbb, 0x43, 0x78, 0x4b, 0x12, 0xf3, 0xeb, 0xb4
};

UINT8 T26_Sha512Result[] = {
  0x4d, 0xbf, 0xf8, 0x6c, 0xc2, 0xca, 0x1b, 0xae,
  0x1e, 0x16, 0x46, 0x8a, 0x05, 0xcb, 0x98, 0x81,
  0xc9, 0x7f, 0x17, 0x53, 0xbc, 0xe3, 0x61, 0x90,
  0x34, 0x89, 0x8f, 0xaa, 0x1a, 0xab, 0xe4, 0x29,
  0x95, 0x5a, 0x1b, 0xf8, 0xec, 0x48, 0x3d, 0x74,
  0x21, 0xfe, 0x3c, 0x16, 0x46, 0x61, 0x3a, 0x59,
  0xed, 0x54, 0x41, 0xfb, 0x0f, 0x32, 0x13, 0x89,
  0xf7, 0x7f, 0x48, 0xa8, 0x79, 0xc7, 0xb1, 0xf1
};


UINT8 T64[] ="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl";
UINT8 T64_Sha1Result[] = {
  0x93, 0x24, 0x9d, 0x4c, 0x2f, 0x89, 0x03, 0xeb,
  0xf4, 0x1a, 0xc3, 0x58, 0x47, 0x31, 0x48, 0xae,
  0x6d, 0xdd, 0x70, 0x42
};

UINT8 T64_Sha224Result[] = {
  0x7c, 0x38, 0xc3, 0x40, 0x76, 0xc3, 0x66, 0x3c,
  0x36, 0x41, 0xeb, 0xb2, 0xc0, 0x34, 0x48, 0x82,
  0xc3, 0x0a, 0x90, 0xdf, 0xb6, 0x6d, 0x1a, 0xdf,
  0xa4, 0xe9, 0x1c, 0x7b
};

UINT8 T64_Sha256Result[] = {
  0x2f, 0xcd, 0x5a, 0x0d, 0x60, 0xe4, 0xc9, 0x41,
  0x38, 0x1f, 0xcc, 0x4e, 0x00, 0xa4, 0xbf, 0x8b,
  0xe4, 0x22, 0xc3, 0xdd, 0xfa, 0xfb, 0x93, 0xc8,
  0x09, 0xe8, 0xd1, 0xe2, 0xbf, 0xff, 0xae, 0x8e
};

UINT8 T64_Sha384Result[] = {
  0xd5, 0xe3, 0x2c, 0x2b, 0xc1, 0x32, 0x09, 0xae,
  0x10, 0x91, 0x92, 0x51, 0x14, 0x93, 0xfe, 0xb9,
  0x2a, 0x96, 0x26, 0x48, 0x13, 0xf5, 0x6a, 0x10,
  0xb2, 0x33, 0xd8, 0xca, 0x89, 0xf4, 0x63, 0x7f,
  0x8a, 0x51, 0xb7, 0xd4, 0xf7, 0x90, 0xbc, 0xe3,
  0x71, 0x9d, 0x7e, 0xaa, 0x4b, 0xef, 0x29, 0x9b
};

UINT8 T64_Sha512Result[] = {
  0x1c, 0xdc, 0xbe, 0xbc, 0xcc, 0xca, 0xed, 0x3f,
  0xa2, 0xac, 0xc8, 0xbc, 0xd1, 0x83, 0x5c, 0x67,
  0x51, 0x4b, 0xd2, 0x96, 0x57, 0xa3, 0x48, 0xde,
  0x62, 0x9a, 0xed, 0xb0, 0xd5, 0x50, 0x33, 0x77,
  0x28, 0x5b, 0x78, 0x65, 0x6a, 0x3a, 0x79, 0x4f,
  0x4c, 0xef, 0x88, 0x70, 0x89, 0x16, 0xd2, 0x3f,
  0x78, 0xea, 0xd0, 0x8d, 0x71, 0x01, 0x01, 0xe3,
  0xc9, 0xba, 0x6a, 0x82, 0x3f, 0xfc, 0x60, 0x67
};


UINT8 T128[]="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl";
UINT8 T128_Sha1Result[] = {
  0x62, 0xe2, 0xd1, 0xa6, 0x17, 0x20, 0xb0, 0xcd,
  0x63, 0xb5, 0x31, 0xaa, 0x59, 0xed, 0xc8, 0x9d,
  0x42, 0x76, 0xcf, 0x98
};

UINT8 T128_Sha224Result[] = {
  0x93, 0xa0, 0xdc, 0x04, 0xc3, 0xc9, 0xd4, 0x53,
  0x3b, 0x6d, 0x0b, 0x24, 0xb0, 0x2b, 0x0c, 0x77,
  0x1d, 0x42, 0xdc, 0xeb, 0x0d, 0x4d, 0x4d, 0xd2,
  0x1d, 0x52, 0xed, 0x49
};

UINT8 T128_Sha256Result[] = {
  0xf8, 0xa3, 0xf2, 0x26, 0xfc, 0x42, 0x10, 0xe9,
  0x0d, 0x13, 0x0c, 0x7f, 0x41, 0xf2, 0xbe, 0x66,
  0x45, 0x53, 0x85, 0xd2, 0x92, 0x0a, 0xda, 0x78,
  0x15, 0xf8, 0xf7, 0x95, 0xd9, 0x44, 0x90, 0x5f
};

UINT8 T128_Sha384Result[] = {
  0x12, 0x84, 0xa6, 0x21, 0xd9, 0x24, 0xeb, 0x78,
  0x04, 0x8a, 0x98, 0x47, 0xc9, 0xd4, 0xe3, 0x19,
  0x42, 0xcc, 0xfc, 0x6f, 0xc8, 0x1a, 0x63, 0x3a,
  0x01, 0x37, 0xd2, 0xf3, 0x7c, 0x7b, 0x5b, 0xb5,
  0x9c, 0x9e, 0x28, 0xf7, 0x28, 0x4d, 0xf8, 0x9b,
  0x23, 0xb7, 0x80, 0x83, 0x36, 0x0c, 0x6e, 0xa4
};

UINT8 T128_Sha512Result[] = {
  0xc7, 0xca, 0x65, 0x55, 0x6e, 0x0f, 0x2f, 0x59,
  0xa0, 0x4e, 0xb3, 0xcd, 0x43, 0xca, 0xd3, 0xa5,
  0xe7, 0x89, 0xe4, 0x1c, 0x8f, 0x2a, 0x08, 0xba,
  0x69, 0x1b, 0xcb, 0xb2, 0x88, 0x7e, 0x0d, 0x48,
  0xad, 0x90, 0x33, 0xb7, 0x02, 0x27, 0xc8, 0x1b,
  0xa1, 0x7a, 0x42, 0x28, 0xd5, 0x91, 0x5d, 0xbb,
  0x35, 0x06, 0x7a, 0x7e, 0x73, 0xc5, 0xa2, 0xdd,
  0x91, 0xe1, 0x94, 0x08, 0xed, 0xb7, 0xa9, 0xb7
};


/* Results for 1000000 'a' string hash */
UINT8 T1000000_Sha1Result[] = {
  0x34, 0xaa, 0x97, 0x3c, 0xd4, 0xc4, 0xda, 0xa4,
  0xf6, 0x1e, 0xeb, 0x2b, 0xdb, 0xad, 0x27, 0x31,
  0x65, 0x34, 0x01, 0x6f
};

UINT8 T1000000_Sha224Result[] = {
  0x20, 0x79, 0x46, 0x55, 0x98, 0x0c, 0x91, 0xd8,
  0xbb, 0xb4, 0xc1, 0xea, 0x97, 0x61, 0x8a, 0x4b,
  0xf0, 0x3f, 0x42, 0x58, 0x19, 0x48, 0xb2, 0xee,
  0x4e, 0xe7, 0xad, 0x67
};

UINT8 T1000000_Sha256Result[] = {
  0xcd, 0xc7, 0x6e, 0x5c, 0x99, 0x14, 0xfb, 0x92,
  0x81, 0xa1, 0xc7, 0xe2, 0x84, 0xd7, 0x3e, 0x67,
  0xf1, 0x80, 0x9a, 0x48, 0xa4, 0x97, 0x20, 0x0e,
  0x04, 0x6d, 0x39, 0xcc, 0xc7, 0x11, 0x2c, 0xd0
};

UINT8 T1000000_Sha384Result[] = {
  0x9d, 0x0e, 0x18, 0x09, 0x71, 0x64, 0x74, 0xcb,
  0x08, 0x6e, 0x83, 0x4e, 0x31, 0x0a, 0x4a, 0x1c,
  0xed, 0x14, 0x9e, 0x9c, 0x00, 0xf2, 0x48, 0x52,
  0x79, 0x72, 0xce, 0xc5, 0x70, 0x4c, 0x2a, 0x5b,
  0x07, 0xb8, 0xb3, 0xdc, 0x38, 0xec, 0xc4, 0xeb,
  0xae, 0x97, 0xdd, 0xd8, 0x7f, 0x3d, 0x89, 0x85
};

UINT8 T1000000_Sha512Result[] = {
  0xe7, 0x18, 0x48, 0x3d, 0x0c, 0xe7, 0x69, 0x64,
  0x4e, 0x2e, 0x42, 0xc7, 0xbc, 0x15, 0xb4, 0x63,
  0x8e, 0x1f, 0x98, 0xb1, 0x3b, 0x20, 0x44, 0x28,
  0x56, 0x32, 0xa8, 0x03, 0xaf, 0xa9, 0x73, 0xeb,
  0xde, 0x0f, 0xf2, 0x44, 0x87, 0x7e, 0xa6, 0x0a,
  0x4c, 0xb0, 0x43, 0x2c, 0xe5, 0x77, 0xc3, 0x1b,
  0xeb, 0x00, 0x9c, 0x5c, 0x2c, 0x49, 0xaa, 0x2e,
  0x4e, 0xad, 0xb2, 0x17, 0xad, 0x8c, 0xc0, 0x9b
};

typedef struct{
  EFI_GUID     *AlgoGuid;
  UINT8        *Data;
  UINTN        DataLen;
  UINT8        *Result;
} uefi_hash_test_vector_type;

uefi_hash_test_vector_type uefi_hash_test_vectors[] = {
  /* T26 */
  {&gEfiHashAlgorithmSha1Guid,
  T26, sizeof(T26)-1,
  T26_Sha1Result}
  ,
  {&gEfiHashAlgorithmSha224Guid,
  T26, sizeof(T26)-1,
  T26_Sha224Result}
  ,
  {&gEfiHashAlgorithmSha256Guid,
  T26, sizeof(T26)-1,
  T26_Sha256Result}
  ,
  {&gEfiHashAlgorithmSha384Guid,
  T26, sizeof(T26)-1,
  T26_Sha384Result}
  ,
  {&gEfiHashAlgorithmSha512Guid,
  T26, sizeof(T26)-1,
  T26_Sha512Result}
  ,
  /* T64 */
  {&gEfiHashAlgorithmSha1Guid,
  T64, sizeof(T64)-1,
  T64_Sha1Result}
  ,
  {&gEfiHashAlgorithmSha224Guid,
  T64, sizeof(T64)-1,
  T64_Sha224Result}
  ,
  {&gEfiHashAlgorithmSha256Guid,
  T64, sizeof(T64)-1,
  T64_Sha256Result}
  ,
  {&gEfiHashAlgorithmSha384Guid,
  T64, sizeof(T64)-1,
  T64_Sha384Result}
  ,
  {&gEfiHashAlgorithmSha512Guid,
  T64, sizeof(T64)-1,
  T64_Sha512Result}
  ,
  /* T128 */
  {&gEfiHashAlgorithmSha1Guid,
  T128, sizeof(T128)-1,
  T128_Sha1Result}
  ,
  {&gEfiHashAlgorithmSha224Guid,
  T128, sizeof(T128)-1,
  T128_Sha224Result}
  ,
  {&gEfiHashAlgorithmSha256Guid,
  T128, sizeof(T128)-1,
  T128_Sha256Result}
  ,
  {&gEfiHashAlgorithmSha384Guid,
  T128, sizeof(T128)-1,
  T128_Sha384Result}
  ,
  {&gEfiHashAlgorithmSha512Guid,
  T128, sizeof(T128)-1,
  T128_Sha512Result}
};

typedef struct{
  EFI_GUID     *AlgoGuid;
  UINT8        *Result;
} uefi_hash_large_test_vector_type;

uefi_hash_large_test_vector_type uefi_hash_large_test_vectors[] = {
  /* T1000000 */
  {&gEfiHashAlgorithmSha1Guid,
  T1000000_Sha1Result}
  ,
  {&gEfiHashAlgorithmSha224Guid,
  T1000000_Sha224Result}
  ,
  {&gEfiHashAlgorithmSha256Guid,
  T1000000_Sha256Result}
  ,
  {&gEfiHashAlgorithmSha384Guid,
  T1000000_Sha384Result}
  ,
  {&gEfiHashAlgorithmSha512Guid,
  T1000000_Sha512Result}
};

/* CeML API Test Vectors */
typedef struct{
  CeMLHashAlgoType Algo;
  UINT8            *Data;
  UINTN            DataLen;
  UINT8            *Result;
} CeML_hash_test_vector_type;

CeML_hash_test_vector_type CeML_hash_test_vectors[] = {
  /* T26 */
  {CEML_HASH_ALGO_SHA1,
  T26, sizeof(T26)-1,
  T26_Sha1Result}
  ,
  {CEML_HASH_ALGO_SHA256,
  T26, sizeof(T26)-1,
  T26_Sha256Result}
  ,
  /* T64 */
  {CEML_HASH_ALGO_SHA1,
  T64, sizeof(T64)-1,
  T64_Sha1Result}
  ,
  {CEML_HASH_ALGO_SHA256,
  T64, sizeof(T64)-1,
  T64_Sha256Result}
  ,
  /* T128 */
  {CEML_HASH_ALGO_SHA1,
  T128, sizeof(T128)-1,
  T128_Sha1Result}
  ,
  {CEML_HASH_ALGO_SHA256,
  T128, sizeof(T128)-1,
  T128_Sha256Result}
};

/* HashSw API Test Vectors */
typedef struct{
  SW_Auth_Alg_Type Algo;
  UINT8            *Data;
  UINTN            DataLen;
  UINT8            *Result;
} HashSwAPI_hash_test_vector_type;

HashSwAPI_hash_test_vector_type HashSwAPI_hash_test_vectors[] = {
  /* T26 */
  {SW_AUTH_ALG_SHA1,
  T26, sizeof(T26)-1,
  T26_Sha1Result}
  ,
  {SW_AUTH_ALG_SHA256,
  T26, sizeof(T26)-1,
  T26_Sha256Result}
  ,
  /* T64 */
  {SW_AUTH_ALG_SHA1,
  T64, sizeof(T64)-1,
  T64_Sha1Result}
  ,
  {SW_AUTH_ALG_SHA256,
  T64, sizeof(T64)-1,
  T64_Sha256Result}
  ,
  /* T128 */
  {SW_AUTH_ALG_SHA1,
  T128, sizeof(T128)-1,
  T128_Sha1Result}
  ,
  {SW_AUTH_ALG_SHA256,
  T128, sizeof(T128)-1,
  T128_Sha256Result}
};

#endif /* HASH_APP_TEST_VECTORS_H */
