Skip to content

Commit 8d7bf5b

Browse files
committed
unit-tests: Add fingerprint test vectors for Ed25519
1 parent 2571898 commit 8d7bf5b

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

src/libstrongswan/tests/suites/test_ed25519.c

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ struct sig_test_t {
2424
chunk_t pubkey;
2525
chunk_t msg;
2626
chunk_t sig;
27+
chunk_t fp_pk;
28+
chunk_t fp_spki;
2729
};
2830

2931
/**
@@ -51,7 +53,13 @@ static sig_test_t sig_tests[] = {
5153
0x01, 0x55, 0x5f, 0xb8, 0x82, 0x15, 0x90, 0xa3, 0x3b, 0xac,
5254
0xc6, 0x1e, 0x39, 0x70, 0x1c, 0xf9, 0xb4, 0x6b, 0xd2, 0x5b,
5355
0xf5, 0xf0, 0x59, 0x5b, 0xbe, 0x24, 0x65, 0x51, 0x41, 0x43,
54-
0x8e, 0x7a, 0x10, 0x0b)
56+
0x8e, 0x7a, 0x10, 0x0b),
57+
chunk_from_chars(
58+
0x5b, 0x27, 0xaa, 0x55, 0x89, 0x17, 0x97, 0x70, 0xe4, 0x75,
59+
0x75, 0xb1, 0x62, 0xa1, 0xde, 0xd9, 0x7b, 0x8b, 0xfc, 0x6d),
60+
chunk_from_chars(
61+
0xa5, 0x66, 0xbe, 0x19, 0x84, 0x01, 0x73, 0x41, 0x3a, 0x61,
62+
0x04, 0x83, 0x50, 0xef, 0xf2, 0x3e, 0x8f, 0xe2, 0x22, 0x66),
5563
},
5664
/* Test 2 */
5765
{ chunk_from_chars(
@@ -75,7 +83,13 @@ static sig_test_t sig_tests[] = {
7583
0x69, 0xda, 0x08, 0x5a, 0xc1, 0xe4, 0x3e, 0x15, 0x99, 0x6e,
7684
0x45, 0x8f, 0x36, 0x13, 0xd0, 0xf1, 0x1d, 0x8c, 0x38, 0x7b,
7785
0x2e, 0xae, 0xb4, 0x30, 0x2a, 0xee, 0xb0, 0x0d, 0x29, 0x16,
78-
0x12, 0xbb, 0x0c, 0x00)
86+
0x12, 0xbb, 0x0c, 0x00),
87+
chunk_from_chars(
88+
0x13, 0xf7, 0x72, 0x66, 0x9e, 0x15, 0x2a, 0xe6, 0xa6, 0x2a,
89+
0x60, 0xa3, 0x48, 0x8a, 0x6f, 0x29, 0x7d, 0x06, 0x13, 0xdd),
90+
chunk_from_chars(
91+
0xbd, 0xae, 0x41, 0xeb, 0x5d, 0xbf, 0x88, 0xb9, 0xdf, 0x18,
92+
0xda, 0xbb, 0x2d, 0xee, 0xa9, 0x1a, 0x4e, 0x03, 0x38, 0xe4),
7993
},
8094
/* Test 3 */
8195
{ chunk_from_chars(
@@ -99,7 +113,13 @@ static sig_test_t sig_tests[] = {
99113
0xc3, 0xac, 0x18, 0xff, 0x9b, 0x53, 0x8d, 0x16, 0xf2, 0x90,
100114
0xae, 0x67, 0xf7, 0x60, 0x98, 0x4d, 0xc6, 0x59, 0x4a, 0x7c,
101115
0x15, 0xe9, 0x71, 0x6e, 0xd2, 0x8d, 0xc0, 0x27, 0xbe, 0xce,
102-
0xea, 0x1e, 0xc4, 0x0a)
116+
0xea, 0x1e, 0xc4, 0x0a),
117+
chunk_from_chars(
118+
0x88, 0xc7, 0x64, 0xc8, 0xbe, 0x44, 0x37, 0x4a, 0x7d, 0x2f,
119+
0x5d, 0x84, 0x72, 0x1f, 0x8e, 0x32, 0x5e, 0x5b, 0xd6, 0x4c),
120+
chunk_from_chars(
121+
0xad, 0x01, 0x30, 0xb1, 0x2b, 0x48, 0x62, 0x9b, 0xb9, 0xad,
122+
0xea, 0x92, 0x1f, 0xfe, 0xd2, 0x9a, 0x42, 0xf0, 0xad, 0xe6),
103123
},
104124
/* Test 1024 */
105125
{ chunk_from_chars(
@@ -235,7 +255,13 @@ static sig_test_t sig_tests[] = {
235255
0xc3, 0x50, 0xaa, 0x53, 0x71, 0xb1, 0x50, 0x8f, 0x9f, 0x45,
236256
0x28, 0xec, 0xea, 0x23, 0xc4, 0x36, 0xd9, 0x4b, 0x5e, 0x8f,
237257
0xcd, 0x4f, 0x68, 0x1e, 0x30, 0xa6, 0xac, 0x00, 0xa9, 0x70,
238-
0x4a, 0x18, 0x8a, 0x03)
258+
0x4a, 0x18, 0x8a, 0x03),
259+
chunk_from_chars(
260+
0x11, 0x2d, 0xb3, 0x08, 0x97, 0x6e, 0x38, 0x8f, 0x5f, 0x5e,
261+
0xb0, 0xae, 0x8f, 0x5f, 0x59, 0x1d, 0xff, 0x74, 0xf4, 0x44),
262+
chunk_from_chars(
263+
0xcb, 0x36, 0xcc, 0x6a, 0x82, 0x2c, 0x49, 0x40, 0xfb, 0x08,
264+
0x04, 0xf6, 0x3a, 0x4f, 0x20, 0x2b, 0xe5, 0x73, 0x43, 0x2f),
239265
},
240266
/* Test SHA(abc) */
241267
{ chunk_from_chars(
@@ -265,15 +291,21 @@ static sig_test_t sig_tests[] = {
265291
0xb5, 0x89, 0x09, 0x35, 0x1f, 0xc9, 0xac, 0x90, 0xb3, 0xec,
266292
0xfd, 0xfb, 0xc7, 0xc6, 0x64, 0x31, 0xe0, 0x30, 0x3d, 0xca,
267293
0x17, 0x9c, 0x13, 0x8a, 0xc1, 0x7a, 0xd9, 0xbe, 0xf1, 0x17,
268-
0x73, 0x31, 0xa7, 0x04)
294+
0x73, 0x31, 0xa7, 0x04),
295+
chunk_from_chars(
296+
0x26, 0x4c, 0xa5, 0x7f, 0x89, 0x6d, 0x64, 0x81, 0xd1, 0x87,
297+
0xe9, 0x89, 0x47, 0x29, 0x5a, 0xfe, 0xe3, 0x6d, 0x82, 0x44),
298+
chunk_from_chars(
299+
0x27, 0x88, 0xfc, 0x14, 0xb1, 0xcd, 0xd0, 0x24, 0xd5, 0x9d,
300+
0x31, 0x65, 0x59, 0x63, 0x69, 0xcf, 0xaf, 0x50, 0x10, 0xe7),
269301
}
270302
};
271303

272304
START_TEST(test_ed25519_sign)
273305
{
274306
private_key_t *key;
275307
public_key_t *pubkey, *public;
276-
chunk_t sig, encoding;
308+
chunk_t sig, encoding, fp;
277309

278310
/* load private key */
279311
key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_ED25519,
@@ -283,6 +315,11 @@ START_TEST(test_ed25519_sign)
283315
ck_assert_chunk_eq(encoding, sig_tests[_i].key);
284316
chunk_free(&encoding);
285317

318+
ck_assert(key->get_fingerprint(key, KEYID_PUBKEY_SHA1, &fp));
319+
ck_assert_chunk_eq(sig_tests[_i].fp_pk, fp);
320+
ck_assert(key->get_fingerprint(key, KEYID_PUBKEY_INFO_SHA1, &fp));
321+
ck_assert_chunk_eq(sig_tests[_i].fp_spki, fp);
322+
286323
/* load public key */
287324
pubkey = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ED25519,
288325
BUILD_BLOB_ASN1_DER, sig_tests[_i].pubkey, BUILD_END);
@@ -291,6 +328,11 @@ START_TEST(test_ed25519_sign)
291328
ck_assert_chunk_eq(encoding, sig_tests[_i].pubkey);
292329
chunk_free(&encoding);
293330

331+
ck_assert(pubkey->get_fingerprint(pubkey, KEYID_PUBKEY_SHA1, &fp));
332+
ck_assert_chunk_eq(sig_tests[_i].fp_pk, fp);
333+
ck_assert(pubkey->get_fingerprint(pubkey, KEYID_PUBKEY_INFO_SHA1, &fp));
334+
ck_assert_chunk_eq(sig_tests[_i].fp_spki, fp);
335+
294336
/* compare public keys */
295337
public = key->get_public_key(key);
296338
ck_assert(public != NULL);

0 commit comments

Comments
 (0)