| .. | .. |
|---|
| 15 | 15 | * #include <stdio.h> |
|---|
| 16 | 16 | * |
|---|
| 17 | 17 | * #include <openssl/evp.h> |
|---|
| 18 | | - * #include <openssl/hmac.h> |
|---|
| 19 | 18 | * |
|---|
| 20 | 19 | * #define BLAKE2S_TESTVEC_COUNT 256 |
|---|
| 21 | 20 | * |
|---|
| .. | .. |
|---|
| 57 | 56 | * print_vec(hash, outlen); |
|---|
| 58 | 57 | * } |
|---|
| 59 | 58 | * printf("};\n\n"); |
|---|
| 60 | | - * |
|---|
| 61 | | - * printf("static const u8 blake2s_hmac_testvecs[][BLAKE2S_HASH_SIZE] __initconst = {\n"); |
|---|
| 62 | | - * |
|---|
| 63 | | - * HMAC(EVP_blake2s256(), key, sizeof(key), buf, sizeof(buf), hash, NULL); |
|---|
| 64 | | - * print_vec(hash, BLAKE2S_OUTBYTES); |
|---|
| 65 | | - * |
|---|
| 66 | | - * HMAC(EVP_blake2s256(), buf, sizeof(buf), key, sizeof(key), hash, NULL); |
|---|
| 67 | | - * print_vec(hash, BLAKE2S_OUTBYTES); |
|---|
| 68 | | - * |
|---|
| 69 | | - * printf("};\n"); |
|---|
| 70 | 59 | * |
|---|
| 71 | 60 | * return 0; |
|---|
| 72 | 61 | *} |
|---|
| .. | .. |
|---|
| 554 | 543 | 0xd6, 0x98, 0x6b, 0x07, 0x10, 0x65, 0x52, 0x65, }, |
|---|
| 555 | 544 | }; |
|---|
| 556 | 545 | |
|---|
| 557 | | -static const u8 blake2s_hmac_testvecs[][BLAKE2S_HASH_SIZE] __initconst = { |
|---|
| 558 | | - { 0xce, 0xe1, 0x57, 0x69, 0x82, 0xdc, 0xbf, 0x43, 0xad, 0x56, 0x4c, 0x70, |
|---|
| 559 | | - 0xed, 0x68, 0x16, 0x96, 0xcf, 0xa4, 0x73, 0xe8, 0xe8, 0xfc, 0x32, 0x79, |
|---|
| 560 | | - 0x08, 0x0a, 0x75, 0x82, 0xda, 0x3f, 0x05, 0x11, }, |
|---|
| 561 | | - { 0x77, 0x2f, 0x0c, 0x71, 0x41, 0xf4, 0x4b, 0x2b, 0xb3, 0xc6, 0xb6, 0xf9, |
|---|
| 562 | | - 0x60, 0xde, 0xe4, 0x52, 0x38, 0x66, 0xe8, 0xbf, 0x9b, 0x96, 0xc4, 0x9f, |
|---|
| 563 | | - 0x60, 0xd9, 0x24, 0x37, 0x99, 0xd6, 0xec, 0x31, }, |
|---|
| 564 | | -}; |
|---|
| 565 | | - |
|---|
| 566 | 546 | bool __init blake2s_selftest(void) |
|---|
| 567 | 547 | { |
|---|
| 568 | 548 | u8 key[BLAKE2S_KEY_SIZE]; |
|---|
| .. | .. |
|---|
| 605 | 585 | i + 1); |
|---|
| 606 | 586 | success = false; |
|---|
| 607 | 587 | } |
|---|
| 608 | | - } |
|---|
| 609 | | - |
|---|
| 610 | | - if (success) { |
|---|
| 611 | | - blake2s256_hmac(hash, buf, key, sizeof(buf), sizeof(key)); |
|---|
| 612 | | - success &= !memcmp(hash, blake2s_hmac_testvecs[0], BLAKE2S_HASH_SIZE); |
|---|
| 613 | | - |
|---|
| 614 | | - blake2s256_hmac(hash, key, buf, sizeof(key), sizeof(buf)); |
|---|
| 615 | | - success &= !memcmp(hash, blake2s_hmac_testvecs[1], BLAKE2S_HASH_SIZE); |
|---|
| 616 | | - |
|---|
| 617 | | - if (!success) |
|---|
| 618 | | - pr_err("blake2s256_hmac self-test: FAIL\n"); |
|---|
| 619 | 588 | } |
|---|
| 620 | 589 | |
|---|
| 621 | 590 | return success; |
|---|