Path: blob/main/crypto/libecc/src/tests/ed25519ctx_test_vectors.h
34869 views
/*1* Copyright (C) 2021 - This file is part of libecc project2*3* Authors:4* Arnaud EBALARD <[email protected]>5* Ryad BENADJILA <[email protected]>6*7* This software is licensed under a dual BSD and GPL v2 license.8* See LICENSE file at the root folder of the project.9*/10#ifndef __ED25519CTX_TEST_VECTORS_H__11#define __ED25519CTX_TEST_VECTORS_H__1213/************************************************/14static const u8 ed25519ctx_1_test_vectors_priv_key[] = {150x03, 0x05, 0x33, 0x4e, 0x38, 0x1a, 0xf7, 0x8f, 0x14, 0x1c, 0xb6, 0x66, 0xf6, 0x19, 0x9f, 0x57, 0xbc, 0x34, 0x95, 0x33, 0x5a, 0x25, 0x6a, 0x95, 0xbd, 0x2a, 0x55, 0xbf, 0x54, 0x66, 0x63, 0xf6,16};17static const u8 ed25519ctx_1_test_vectors_message[] = {180xf7, 0x26, 0x93, 0x6d, 0x19, 0xc8, 0x00, 0x49, 0x4e, 0x3f, 0xda, 0xff, 0x20, 0xb2, 0x76, 0xa8,19};20static const u8 ed25519ctx_1_test_vectors_expected_sig[] = {210x55, 0xa4, 0xcc, 0x2f, 0x70, 0xa5, 0x4e, 0x04, 0x28, 0x8c, 0x5f, 0x4c, 0xd1, 0xe4, 0x5a, 0x7b, 0xb5, 0x20, 0xb3, 0x62, 0x92, 0x91, 0x18, 0x76, 0xca, 0xda, 0x73, 0x23, 0x19, 0x8d, 0xd8, 0x7a, 0x8b, 0x36, 0x95, 0x0b, 0x95, 0x13, 0x00, 0x22, 0x90, 0x7a, 0x7f, 0xb7, 0xc4, 0xe9, 0xb2, 0xd5, 0xf6, 0xcc, 0xa6, 0x85, 0xa5, 0x87, 0xb4, 0xb2, 0x1f, 0x4b, 0x88, 0x8e, 0x4e, 0x7e, 0xdb, 0x0d,22};23static const u8 ed25519ctx_1_test_vectors_adata[] = {240x66, 0x6f, 0x6f,25};26static const ec_test_case ed25519ctx_1_test_case = {27.name = "EDDSA25519CTX-SHA512/wei25519 1",28.ec_str_p = &wei25519_str_params,29.priv_key = ed25519ctx_1_test_vectors_priv_key,30.priv_key_len = sizeof(ed25519ctx_1_test_vectors_priv_key),31.nn_random = NULL,32.hash_type = SHA512,33.msg = (const char *)ed25519ctx_1_test_vectors_message,34.msglen = sizeof(ed25519ctx_1_test_vectors_message),35.sig_type = EDDSA25519CTX,36.exp_sig = ed25519ctx_1_test_vectors_expected_sig,37.exp_siglen = sizeof(ed25519ctx_1_test_vectors_expected_sig),38.adata = ed25519ctx_1_test_vectors_adata,39.adata_len = sizeof(ed25519ctx_1_test_vectors_adata),40};4142/************************************************/43static const u8 ed25519ctx_2_test_vectors_priv_key[] = {440x03, 0x05, 0x33, 0x4e, 0x38, 0x1a, 0xf7, 0x8f, 0x14, 0x1c, 0xb6, 0x66, 0xf6, 0x19, 0x9f, 0x57, 0xbc, 0x34, 0x95, 0x33, 0x5a, 0x25, 0x6a, 0x95, 0xbd, 0x2a, 0x55, 0xbf, 0x54, 0x66, 0x63, 0xf6,45};46static const u8 ed25519ctx_2_test_vectors_message[] = {470xf7, 0x26, 0x93, 0x6d, 0x19, 0xc8, 0x00, 0x49, 0x4e, 0x3f, 0xda, 0xff, 0x20, 0xb2, 0x76, 0xa8,48};49static const u8 ed25519ctx_2_test_vectors_expected_sig[] = {500xfc, 0x60, 0xd5, 0x87, 0x2f, 0xc4, 0x6b, 0x3a, 0xa6, 0x9f, 0x8b, 0x5b, 0x43, 0x51, 0xd5, 0x80, 0x8f, 0x92, 0xbc, 0xc0, 0x44, 0x60, 0x6d, 0xb0, 0x97, 0xab, 0xab, 0x6d, 0xbc, 0xb1, 0xae, 0xe3, 0x21, 0x6c, 0x48, 0xe8, 0xb3, 0xb6, 0x64, 0x31, 0xb5, 0xb1, 0x86, 0xd1, 0xd2, 0x8f, 0x8e, 0xe1, 0x5a, 0x5c, 0xa2, 0xdf, 0x66, 0x68, 0x34, 0x62, 0x91, 0xc2, 0x04, 0x3d, 0x4e, 0xb3, 0xe9, 0x0d,51};52static const u8 ed25519ctx_2_test_vectors_adata[] = {530x62, 0x61, 0x72,54};55static const ec_test_case ed25519ctx_2_test_case = {56.name = "EDDSA25519CTX-SHA512/wei25519 2",57.ec_str_p = &wei25519_str_params,58.priv_key = ed25519ctx_2_test_vectors_priv_key,59.priv_key_len = sizeof(ed25519ctx_2_test_vectors_priv_key),60.nn_random = NULL,61.hash_type = SHA512,62.msg = (const char *)ed25519ctx_2_test_vectors_message,63.msglen = sizeof(ed25519ctx_2_test_vectors_message),64.sig_type = EDDSA25519CTX,65.exp_sig = ed25519ctx_2_test_vectors_expected_sig,66.exp_siglen = sizeof(ed25519ctx_2_test_vectors_expected_sig),67.adata = ed25519ctx_2_test_vectors_adata,68.adata_len = sizeof(ed25519ctx_2_test_vectors_adata),69};7071/************************************************/72static const u8 ed25519ctx_3_test_vectors_priv_key[] = {730x03, 0x05, 0x33, 0x4e, 0x38, 0x1a, 0xf7, 0x8f, 0x14, 0x1c, 0xb6, 0x66, 0xf6, 0x19, 0x9f, 0x57, 0xbc, 0x34, 0x95, 0x33, 0x5a, 0x25, 0x6a, 0x95, 0xbd, 0x2a, 0x55, 0xbf, 0x54, 0x66, 0x63, 0xf6,74};75static const u8 ed25519ctx_3_test_vectors_message[] = {760x50, 0x8e, 0x9e, 0x68, 0x82, 0xb9, 0x79, 0xfe, 0xa9, 0x00, 0xf6, 0x2a, 0xdc, 0xea, 0xca, 0x35,77};78static const u8 ed25519ctx_3_test_vectors_expected_sig[] = {790x8b, 0x70, 0xc1, 0xcc, 0x83, 0x10, 0xe1, 0xde, 0x20, 0xac, 0x53, 0xce, 0x28, 0xae, 0x6e, 0x72, 0x07, 0xf3, 0x3c, 0x32, 0x95, 0xe0, 0x3b, 0xb5, 0xc0, 0x73, 0x2a, 0x1d, 0x20, 0xdc, 0x64, 0x90, 0x89, 0x22, 0xa8, 0xb0, 0x52, 0xcf, 0x99, 0xb7, 0xc4, 0xfe, 0x10, 0x7a, 0x5a, 0xbb, 0x5b, 0x2c, 0x40, 0x85, 0xae, 0x75, 0x89, 0x0d, 0x02, 0xdf, 0x26, 0x26, 0x9d, 0x89, 0x45, 0xf8, 0x4b, 0x0b,80};81static const u8 ed25519ctx_3_test_vectors_adata[] = {820x66, 0x6f, 0x6f,83};84static const ec_test_case ed25519ctx_3_test_case = {85.name = "EDDSA25519CTX-SHA512/wei25519 3",86.ec_str_p = &wei25519_str_params,87.priv_key = ed25519ctx_3_test_vectors_priv_key,88.priv_key_len = sizeof(ed25519ctx_3_test_vectors_priv_key),89.nn_random = NULL,90.hash_type = SHA512,91.msg = (const char *)ed25519ctx_3_test_vectors_message,92.msglen = sizeof(ed25519ctx_3_test_vectors_message),93.sig_type = EDDSA25519CTX,94.exp_sig = ed25519ctx_3_test_vectors_expected_sig,95.exp_siglen = sizeof(ed25519ctx_3_test_vectors_expected_sig),96.adata = ed25519ctx_3_test_vectors_adata,97.adata_len = sizeof(ed25519ctx_3_test_vectors_adata),98};99100/************************************************/101static const u8 ed25519ctx_4_test_vectors_priv_key[] = {1020xab, 0x9c, 0x28, 0x53, 0xce, 0x29, 0x7d, 0xda, 0xb8, 0x5c, 0x99, 0x3b, 0x3a, 0xe1, 0x4b, 0xca, 0xd3, 0x9b, 0x2c, 0x68, 0x2b, 0xea, 0xbc, 0x27, 0xd6, 0xd4, 0xeb, 0x20, 0x71, 0x1d, 0x65, 0x60,103};104static const u8 ed25519ctx_4_test_vectors_message[] = {1050xf7, 0x26, 0x93, 0x6d, 0x19, 0xc8, 0x00, 0x49, 0x4e, 0x3f, 0xda, 0xff, 0x20, 0xb2, 0x76, 0xa8,106};107static const u8 ed25519ctx_4_test_vectors_expected_sig[] = {1080x21, 0x65, 0x5b, 0x5f, 0x1a, 0xa9, 0x65, 0x99, 0x6b, 0x3f, 0x97, 0xb3, 0xc8, 0x49, 0xea, 0xfb, 0xa9, 0x22, 0xa0, 0xa6, 0x29, 0x92, 0xf7, 0x3b, 0x3d, 0x1b, 0x73, 0x10, 0x6a, 0x84, 0xad, 0x85, 0xe9, 0xb8, 0x6a, 0x7b, 0x60, 0x05, 0xea, 0x86, 0x83, 0x37, 0xff, 0x2d, 0x20, 0xa7, 0xf5, 0xfb, 0xd4, 0xcd, 0x10, 0xb0, 0xbe, 0x49, 0xa6, 0x8d, 0xa2, 0xb2, 0xe0, 0xdc, 0x0a, 0xd8, 0x96, 0x0f,109};110static const u8 ed25519ctx_4_test_vectors_adata[] = {1110x66, 0x6f, 0x6f,112};113static const ec_test_case ed25519ctx_4_test_case = {114.name = "EDDSA25519CTX-SHA512/wei25519 4",115.ec_str_p = &wei25519_str_params,116.priv_key = ed25519ctx_4_test_vectors_priv_key,117.priv_key_len = sizeof(ed25519ctx_4_test_vectors_priv_key),118.nn_random = NULL,119.hash_type = SHA512,120.msg = (const char *)ed25519ctx_4_test_vectors_message,121.msglen = sizeof(ed25519ctx_4_test_vectors_message),122.sig_type = EDDSA25519CTX,123.exp_sig = ed25519ctx_4_test_vectors_expected_sig,124.exp_siglen = sizeof(ed25519ctx_4_test_vectors_expected_sig),125.adata = ed25519ctx_4_test_vectors_adata,126.adata_len = sizeof(ed25519ctx_4_test_vectors_adata),127};128129130/************************************************/131#define EDDSA25519CTX_SHA512_WEI25519_ALL_TESTS() \132&ed25519ctx_1_test_case,\133&ed25519ctx_2_test_case,\134&ed25519ctx_3_test_case,\135&ed25519ctx_4_test_case,136137#endif /* __ED25519CTX_TEST_VECTORS_H__ */138139140