Skip to content

Commit 15d0779

Browse files
committed
Merged PR 10817310: Add XMSS and XMSS^MT implementations
## Description: Adds support for stateful hash-based signatures XMSS and XMSS^MT per RFC 8391 and NIST SP800-208. ## Admin Checklist: - [ ] You have updated documentation in symcrypt.h to reflect any changes in behavior - [ ] You have updated CHANGELOG.md to reflect any changes in behavior - [ ] You have updated symcryptunittest to exercise any new functionality - [ ] If you have introduced any symbols in symcrypt.h you have updated production and test dynamic export symbols (exports.ver / exports.def / symcrypt.src) and tested the updated dynamic modules with symcryptunittest - [ ] If you have introduced functionality that varies based on CPU features, you have manually tested with and without relevant features - [ ] If you have made significant changes to a particular algorithm, you have checked that performance numbers reported by symcryptunittest are in line with expectations - [ ] If you have added new algorithms/modes, you have updated the status indicator text for the associated modules if necessary Related work items: #52453903
1 parent f89cbf3 commit 15d0779

29 files changed

+32891
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ prior to the creation of a new release, based on the changes contained in that r
55

66
- Internal self-test changes to support FIPS 140-3 certification
77
- Add SSKDF implementation
8+
- Add XMSS and XMSS^MT implementations
89

910
# Version 103.4.3
1011

inc/symcrypt.h

Lines changed: 551 additions & 0 deletions
Large diffs are not rendered by default.

inc/symcrypt_internal.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,6 +2784,42 @@ SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_802_11_SAE_CUSTOM_STATE {
27842784
BYTE counter;
27852785
};
27862786

2787+
//
2788+
// XMSS
2789+
//
2790+
2791+
typedef SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_XMSS_PARAMS
2792+
{
2793+
PCSYMCRYPT_HASH hash; // hash function
2794+
UINT32 id; // algorithm identifier
2795+
UINT32 cbHashOutput; // hash function output size, must be less than or equal to hash->resultSize
2796+
UINT32 nWinternitzWidth;// Wintertnitz coefficient, width of digits in bits (chain length = 2^nWinternitzWidth)
2797+
UINT32 nTotalTreeHeight;// number of layers times the tree height of one layer (each layer has the same height)
2798+
UINT32 nLayers; // hyper-tree layers, 1 for single tree
2799+
UINT32 cbPrefix; // length of the domain separator prefix in PRFs
2800+
2801+
//
2802+
// The following are derived from the above
2803+
//
2804+
UINT32 len1; // number of w-bit digits in the hash output to be signed ( len1 = ceil(8n / w) )
2805+
UINT32 len2; // number of w-bit digits in the checksum
2806+
UINT32 len; // len1 + len2
2807+
UINT32 nLayerHeight; // tree height of a single layer (h / d)
2808+
UINT32 cbIdx; // size of leaf counter in bytes (for single trees cbIdx = 4)
2809+
UINT32 nLeftShift32; // left shift count to align the checksum digits to MSB of a 32-bit word
2810+
2811+
BYTE Reserved[16]; // Reserved for future use
2812+
} SYMCRYPT_XMSS_PARAMS;
2813+
2814+
typedef SYMCRYPT_XMSS_PARAMS* PSYMCRYPT_XMSS_PARAMS;
2815+
typedef const SYMCRYPT_XMSS_PARAMS* PCSYMCRYPT_XMSS_PARAMS;
2816+
2817+
struct _SYMCRYPT_XMSS_KEY;
2818+
typedef struct _SYMCRYPT_XMSS_KEY SYMCRYPT_XMSS_KEY;
2819+
typedef SYMCRYPT_XMSS_KEY* PSYMCRYPT_XMSS_KEY;
2820+
typedef const SYMCRYPT_XMSS_KEY* PCSYMCRYPT_XMSS_KEY;
2821+
2822+
27872823

27882824
#ifndef _PREFAST_
27892825
#if SYMCRYPT_CPU_X86

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ set(SOURCES_COMMON
116116
tlsCbcVerify.c
117117
tlsprf_selftest.c
118118
tlsprf.c
119+
xmss.c
119120
xtsaes.c
120121
)
121122

lib/fips_selftest.c

Lines changed: 146 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,97 @@ const BYTE rgbSha256Hash[] =
486486
};
487487

488488

489+
// XMSS-SHA2_10_192 public-key and signature for message "abc"
490+
const BYTE rgbXmssSha2_10_192Pubkey[] =
491+
{
492+
// Algorithm ID
493+
0x00, 0x00, 0x00, 0x0d,
494+
495+
// Root
496+
0x7e, 0x63, 0xd5, 0x1d, 0xdf, 0x92, 0x0f, 0x10,
497+
0x63, 0x52, 0x82, 0x38, 0xdf, 0x15, 0x0e, 0x83,
498+
0x5c, 0x74, 0x0a, 0x25, 0x10, 0xc8, 0x3b, 0xdc,
499+
500+
// Seed
501+
0x75, 0x78, 0x08, 0x77, 0xb0, 0x90, 0x02, 0x63,
502+
0x45, 0x4b, 0xf9, 0xad, 0xee, 0x52, 0x04, 0x75,
503+
0x45, 0x13, 0x99, 0xdd, 0x9f, 0xbb, 0xc7, 0x43,
504+
};
505+
506+
const BYTE rgbXmssSha2_10_192Signature[] =
507+
{
508+
// Idx
509+
0x00, 0x00, 0x00, 0x03,
510+
511+
// Randomness
512+
0xf8, 0xbe, 0x24, 0x0e, 0x21, 0x1f, 0x9b, 0x7f, 0x3a, 0x81, 0x82, 0x32, 0x79, 0xe2, 0x2f, 0x42, 0xa5, 0x5a, 0xea, 0x32, 0x75, 0x58, 0x47, 0x8a,
513+
514+
// WOTSP signature
515+
0x2d, 0xaa, 0x55, 0xc6, 0xdb, 0xa4, 0x46, 0x83, 0xda, 0x62, 0xba, 0x67, 0x1a, 0xa2, 0x53, 0x4a, 0xbf, 0xf4, 0x0c, 0x4e, 0x8d, 0xa6, 0x3b, 0xdf,
516+
0x92, 0x1c, 0x80, 0xb7, 0xe6, 0x58, 0x66, 0xf3, 0x5d, 0x01, 0xd7, 0x31, 0x70, 0x7e, 0x22, 0x04, 0x73, 0xb0, 0xaa, 0x7a, 0x64, 0xf9, 0xba, 0xf5,
517+
0x37, 0x58, 0x98, 0x7e, 0x9c, 0x81, 0xd4, 0xa5, 0xe0, 0x2e, 0xed, 0x6b, 0x61, 0x57, 0xe5, 0x73, 0x80, 0x42, 0x79, 0xe2, 0x30, 0x9d, 0xa8, 0x9c,
518+
0x0c, 0x10, 0x1f, 0xb9, 0xf5, 0xa0, 0x17,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, 0xd3, 0xb5, 0x1c, 0xb1, 0xdc, 0x20, 0xe5, 0x5c, 0x8d, 0x83, 0xa6, 0xf8, 0x12, 0x2e,
564+
0x6c, 0x6a, 0x2e, 0x16, 0x23, 0xed, 0x3c, 0x96, 0x52, 0x9c, 0x51, 0x0f, 0x2d, 0xbe, 0x1b, 0x3d, 0x6a, 0xd2, 0xf5, 0x43, 0xde, 0x7a, 0x5c, 0x07,
565+
0x85, 0x42, 0x89, 0x49, 0xa6, 0x08, 0x82, 0x13, 0xcd, 0xa1, 0xd5, 0x7d, 0x86, 0x51, 0x9b, 0x20, 0x44, 0x59, 0x71, 0x24, 0x72, 0xcc, 0xf0, 0x69,
566+
567+
// Authentication nodes
568+
0x51, 0x4f, 0x87, 0x42, 0xee, 0x41, 0x95, 0x4d, 0x7c, 0x77, 0x36, 0x33, 0x58, 0x8c, 0xaa, 0x8e, 0x24, 0x53, 0xaf, 0x69, 0xdc, 0x0a, 0xd9, 0x62,
569+
0x5b, 0x42, 0xf1, 0x46, 0xcd, 0x85, 0x59, 0x18, 0x85, 0x48, 0xd3, 0x4c, 0xbe, 0xd6, 0xb3, 0x36, 0x3f, 0x1f, 0x2b, 0x30, 0x13, 0x87, 0x2b, 0xd5,
570+
0xcd, 0xb7, 0x6b, 0x19, 0x68, 0x16, 0x91, 0x25, 0xc2, 0x0e, 0xbe, 0xb6, 0xbb, 0x6d, 0xe1, 0x37, 0x4d, 0x4c, 0x0a, 0x80, 0x02, 0x01, 0xdd, 0xfb,
571+
0x0e, 0xb3, 0xaa, 0xf9, 0x83, 0x0d, 0x44, 0x72, 0x64, 0x5b, 0xec, 0xbf, 0xe0, 0x98, 0xd7, 0x4f, 0x09, 0x85, 0xf9, 0x99, 0x88, 0x78, 0xa7, 0xad,
572+
0x6b, 0xce, 0xa3, 0xa0, 0x74, 0x72, 0xe1, 0x3a, 0x39, 0x29, 0x3f, 0x1b, 0xcd, 0xfe, 0x60, 0x54, 0xf5, 0xdb, 0xa3, 0xd6, 0x21, 0xde, 0x8c, 0x6f,
573+
0x33, 0x52, 0x0c, 0xfb, 0x61, 0x60, 0x88, 0xb3, 0x17, 0x8a, 0xe5, 0x4a, 0xaa, 0x5b, 0x64, 0x01, 0x33, 0x57, 0x46, 0x91, 0x61, 0x95, 0x93, 0x08,
574+
0xe8, 0x0d, 0xba, 0xda, 0x0c, 0xeb, 0x96, 0x7b, 0x73, 0xa5, 0x79, 0xe4, 0x0b, 0x93, 0x51, 0x28, 0xa3, 0x44, 0x76, 0x62, 0xe6, 0xbe, 0xca, 0x0e,
575+
0x37, 0x7b, 0xf6, 0xfb, 0xbd, 0x6c, 0xd7, 0x8f, 0xba, 0x75, 0xd5, 0x6b, 0xc1, 0xc2, 0x04, 0xfa, 0xf8, 0xe3, 0x07, 0x10, 0x6f, 0xb4, 0x97, 0xf1,
576+
0xd7, 0xa8, 0x83, 0xa9, 0x9f, 0x20, 0x9c, 0xfc, 0xa7, 0x45, 0x71, 0x36, 0xeb, 0x26, 0xc7, 0x1d, 0x8a, 0x3c, 0x66, 0x78, 0x02, 0xc5, 0x76, 0xa1,
577+
0xd5, 0xc2, 0x15, 0x86, 0x2e, 0x8a, 0x46, 0xde, 0x45, 0xcf, 0xaf, 0xdd, 0xe3, 0xbe, 0xb6, 0x5e, 0x88, 0x1f, 0x9e, 0x63, 0xa6, 0xca, 0x89, 0x8b,
578+
};
579+
489580
VOID
490581
SYMCRYPT_CALL
491582
SymCryptDhSecretAgreementSelftest(void)
@@ -847,4 +938,58 @@ SymCryptRsaSelftest(void)
847938
SymCryptRsaSignVerifyTest( pkRsakey );
848939

849940
SymCryptRsakeyFree( pkRsakey );
850-
}
941+
}
942+
943+
VOID
944+
SYMCRYPT_CALL
945+
SymCryptXmssVerifySelftest(void)
946+
{
947+
SYMCRYPT_ERROR scError = SYMCRYPT_NO_ERROR;
948+
PSYMCRYPT_XMSS_KEY pKey = NULL;
949+
SYMCRYPT_XMSS_PARAMS params;
950+
PBYTE pbSignature;
951+
SIZE_T cbSignature = sizeof(rgbXmssSha2_10_192Signature);
952+
953+
scError = SymCryptXmssParamsFromAlgId(SYMCRYPT_XMSS_SHA2_10_192, &params);
954+
SYMCRYPT_FIPS_ASSERT(scError == SYMCRYPT_NO_ERROR);
955+
956+
pKey = SymCryptXmsskeyAllocate(&params, 0);
957+
SYMCRYPT_FIPS_ASSERT(pKey != NULL);
958+
959+
scError = SymCryptXmsskeySetValue(
960+
rgbXmssSha2_10_192Pubkey,
961+
sizeof(rgbXmssSha2_10_192Pubkey),
962+
SYMCRYPT_XMSSKEY_TYPE_PUBLIC,
963+
0,
964+
pKey);
965+
966+
// Make a copy of the signature so that we can inject errors in it
967+
pbSignature = SymCryptCallbackAlloc(cbSignature);
968+
SYMCRYPT_FIPS_ASSERT(pbSignature != NULL);
969+
memcpy(pbSignature, rgbXmssSha2_10_192Signature, cbSignature);
970+
971+
SymCryptInjectError(pbSignature, cbSignature);
972+
973+
scError = SymCryptXmssVerify(
974+
pKey,
975+
SymCryptTestMsg3,
976+
sizeof(SymCryptTestMsg3),
977+
0,
978+
pbSignature,
979+
cbSignature);
980+
SYMCRYPT_FIPS_ASSERT(scError == SYMCRYPT_NO_ERROR);
981+
982+
SymCryptWipe(pbSignature, cbSignature);
983+
SymCryptCallbackFree(pbSignature);
984+
985+
SymCryptXmsskeyFree(pKey);
986+
}
987+
988+
VOID
989+
SYMCRYPT_CALL
990+
SymCryptXmssSelftest(void)
991+
{
992+
// Perform only signature verification self-test
993+
SymCryptXmssVerifySelftest();
994+
}
995+

0 commit comments

Comments
 (0)