1 /* 2 * Copyright (C) 2021 - This file is part of libecc project 3 * 4 * Authors: 5 * Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr> 6 * Ryad BENADJILA <ryadbenadjila@gmail.com> 7 * 8 * This software is licensed under a dual BSD and GPL v2 license. 9 * See LICENSE file at the root folder of the project. 10 */ 11 #ifndef __ED25519CTX_TEST_VECTORS_H__ 12 #define __ED25519CTX_TEST_VECTORS_H__ 13 14 /************************************************/ 15 static const u8 ed25519ctx_1_test_vectors_priv_key[] = { 16 0x03, 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, 17 }; 18 static const u8 ed25519ctx_1_test_vectors_message[] = { 19 0xf7, 0x26, 0x93, 0x6d, 0x19, 0xc8, 0x00, 0x49, 0x4e, 0x3f, 0xda, 0xff, 0x20, 0xb2, 0x76, 0xa8, 20 }; 21 static const u8 ed25519ctx_1_test_vectors_expected_sig[] = { 22 0x55, 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, 23 }; 24 static const u8 ed25519ctx_1_test_vectors_adata[] = { 25 0x66, 0x6f, 0x6f, 26 }; 27 static const ec_test_case ed25519ctx_1_test_case = { 28 .name = "EDDSA25519CTX-SHA512/wei25519 1", 29 .ec_str_p = &wei25519_str_params, 30 .priv_key = ed25519ctx_1_test_vectors_priv_key, 31 .priv_key_len = sizeof(ed25519ctx_1_test_vectors_priv_key), 32 .nn_random = NULL, 33 .hash_type = SHA512, 34 .msg = (const char *)ed25519ctx_1_test_vectors_message, 35 .msglen = sizeof(ed25519ctx_1_test_vectors_message), 36 .sig_type = EDDSA25519CTX, 37 .exp_sig = ed25519ctx_1_test_vectors_expected_sig, 38 .exp_siglen = sizeof(ed25519ctx_1_test_vectors_expected_sig), 39 .adata = ed25519ctx_1_test_vectors_adata, 40 .adata_len = sizeof(ed25519ctx_1_test_vectors_adata), 41 }; 42 43 /************************************************/ 44 static const u8 ed25519ctx_2_test_vectors_priv_key[] = { 45 0x03, 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, 46 }; 47 static const u8 ed25519ctx_2_test_vectors_message[] = { 48 0xf7, 0x26, 0x93, 0x6d, 0x19, 0xc8, 0x00, 0x49, 0x4e, 0x3f, 0xda, 0xff, 0x20, 0xb2, 0x76, 0xa8, 49 }; 50 static const u8 ed25519ctx_2_test_vectors_expected_sig[] = { 51 0xfc, 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, 52 }; 53 static const u8 ed25519ctx_2_test_vectors_adata[] = { 54 0x62, 0x61, 0x72, 55 }; 56 static const ec_test_case ed25519ctx_2_test_case = { 57 .name = "EDDSA25519CTX-SHA512/wei25519 2", 58 .ec_str_p = &wei25519_str_params, 59 .priv_key = ed25519ctx_2_test_vectors_priv_key, 60 .priv_key_len = sizeof(ed25519ctx_2_test_vectors_priv_key), 61 .nn_random = NULL, 62 .hash_type = SHA512, 63 .msg = (const char *)ed25519ctx_2_test_vectors_message, 64 .msglen = sizeof(ed25519ctx_2_test_vectors_message), 65 .sig_type = EDDSA25519CTX, 66 .exp_sig = ed25519ctx_2_test_vectors_expected_sig, 67 .exp_siglen = sizeof(ed25519ctx_2_test_vectors_expected_sig), 68 .adata = ed25519ctx_2_test_vectors_adata, 69 .adata_len = sizeof(ed25519ctx_2_test_vectors_adata), 70 }; 71 72 /************************************************/ 73 static const u8 ed25519ctx_3_test_vectors_priv_key[] = { 74 0x03, 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, 75 }; 76 static const u8 ed25519ctx_3_test_vectors_message[] = { 77 0x50, 0x8e, 0x9e, 0x68, 0x82, 0xb9, 0x79, 0xfe, 0xa9, 0x00, 0xf6, 0x2a, 0xdc, 0xea, 0xca, 0x35, 78 }; 79 static const u8 ed25519ctx_3_test_vectors_expected_sig[] = { 80 0x8b, 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, 81 }; 82 static const u8 ed25519ctx_3_test_vectors_adata[] = { 83 0x66, 0x6f, 0x6f, 84 }; 85 static const ec_test_case ed25519ctx_3_test_case = { 86 .name = "EDDSA25519CTX-SHA512/wei25519 3", 87 .ec_str_p = &wei25519_str_params, 88 .priv_key = ed25519ctx_3_test_vectors_priv_key, 89 .priv_key_len = sizeof(ed25519ctx_3_test_vectors_priv_key), 90 .nn_random = NULL, 91 .hash_type = SHA512, 92 .msg = (const char *)ed25519ctx_3_test_vectors_message, 93 .msglen = sizeof(ed25519ctx_3_test_vectors_message), 94 .sig_type = EDDSA25519CTX, 95 .exp_sig = ed25519ctx_3_test_vectors_expected_sig, 96 .exp_siglen = sizeof(ed25519ctx_3_test_vectors_expected_sig), 97 .adata = ed25519ctx_3_test_vectors_adata, 98 .adata_len = sizeof(ed25519ctx_3_test_vectors_adata), 99 }; 100 101 /************************************************/ 102 static const u8 ed25519ctx_4_test_vectors_priv_key[] = { 103 0xab, 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, 104 }; 105 static const u8 ed25519ctx_4_test_vectors_message[] = { 106 0xf7, 0x26, 0x93, 0x6d, 0x19, 0xc8, 0x00, 0x49, 0x4e, 0x3f, 0xda, 0xff, 0x20, 0xb2, 0x76, 0xa8, 107 }; 108 static const u8 ed25519ctx_4_test_vectors_expected_sig[] = { 109 0x21, 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, 110 }; 111 static const u8 ed25519ctx_4_test_vectors_adata[] = { 112 0x66, 0x6f, 0x6f, 113 }; 114 static const ec_test_case ed25519ctx_4_test_case = { 115 .name = "EDDSA25519CTX-SHA512/wei25519 4", 116 .ec_str_p = &wei25519_str_params, 117 .priv_key = ed25519ctx_4_test_vectors_priv_key, 118 .priv_key_len = sizeof(ed25519ctx_4_test_vectors_priv_key), 119 .nn_random = NULL, 120 .hash_type = SHA512, 121 .msg = (const char *)ed25519ctx_4_test_vectors_message, 122 .msglen = sizeof(ed25519ctx_4_test_vectors_message), 123 .sig_type = EDDSA25519CTX, 124 .exp_sig = ed25519ctx_4_test_vectors_expected_sig, 125 .exp_siglen = sizeof(ed25519ctx_4_test_vectors_expected_sig), 126 .adata = ed25519ctx_4_test_vectors_adata, 127 .adata_len = sizeof(ed25519ctx_4_test_vectors_adata), 128 }; 129 130 131 /************************************************/ 132 #define EDDSA25519CTX_SHA512_WEI25519_ALL_TESTS() \ 133 &ed25519ctx_1_test_case,\ 134 &ed25519ctx_2_test_case,\ 135 &ed25519ctx_3_test_case,\ 136 &ed25519ctx_4_test_case, 137 138 #endif /* __ED25519CTX_TEST_VECTORS_H__ */ 139