ReactOS 0.4.17-dev-1005-g171e1de
symcrypt_internal.h
Go to the documentation of this file.
1//
2// SymCrypt_internal.h
3//
4// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5//
6
7//
8// This file contains information that is internal to the symcrypt library,
9// but which still needs to be known to the compiler to be able to use the library.
10// This includes structure declarations and all support for inline implementations
11// of some of the library functions.
12// Information in this file is not part of the API and can change at any time.
13//
14
15#pragma GCC diagnostic ignored "-Wunknown-pragmas"
16
17//
18// We use Prefast pragmas, but they are not recognized by the compiler.
19// We disable the 'unknown pragma' warning if we are not in prefast mode.
20//
21#ifndef _PREFAST_
22#pragma warning(disable:4068)
23#endif
24
25//==============================================================================================
26// PLATFORM/COMPILER DETECTION
27//==============================================================================================
28
29#define SYMCRYPT_PLATFORM_WINDOWS 0
30#define SYMCRYPT_PLATFORM_APPLE 0 // macOS and other Apple platforms
31#define SYMCRYPT_PLATFORM_UNIX 0 // Linux and other Unix-likes, besides macOS. Must support POSIX.
32
33#if defined(_WIN32)
34 #undef SYMCRYPT_PLATFORM_WINDOWS
35 #define SYMCRYPT_PLATFORM_WINDOWS 1
36#elif defined(__APPLE__)
37 #undef SYMCRYPT_PLATFORM_APPLE
38 #define SYMCRYPT_PLATFORM_APPLE 1
39#elif (defined(linux) || defined(__unix__))
40 #undef SYMCRYPT_PLATFORM_UNIX
41 #define SYMCRYPT_PLATFORM_UNIX 1
42#endif
43
44#define SYMCRYPT_MS_VC 0 // Microsoft compiler (cl.exe - Visual Studio/MSBuild)
45#define SYMCRYPT_GNUC 0 // GCC and compatible compilers (including Clang)
46
47#if defined(_MSC_VER)
48 #undef SYMCRYPT_MS_VC
49 #define SYMCRYPT_MS_VC 1
50#elif defined(__GNUC__)
51 #undef SYMCRYPT_GNUC
52 #define SYMCRYPT_GNUC 1
53#else
54 #error Unsupported compiler
55#endif
56
57#if SYMCRYPT_MS_VC
58
59// This should go somewhere else. Same in the other #if branches.
60#define SYMCRYPT_ANYSIZE_ARRAY 1
61#define SYMCRYPT_NOINLINE __declspec(noinline)
62#define SYMCRYPT_CDECL __cdecl
63#define SYMCRYPT_FASTCALL __fastcall
64
65#define SYMCRYPT_UNALIGNED
66
67#elif SYMCRYPT_GNUC
68
69// Ignore the multi-character character constant warnings
70#pragma GCC diagnostic ignored "-Wmultichar"
71#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
72
73#define SYMCRYPT_ANYSIZE_ARRAY 1
74#define SYMCRYPT_NOINLINE __attribute__ ((noinline))
75#define SYMCRYPT_UNALIGNED
76#define SYMCRYPT_CDECL
77#define SYMCRYPT_FASTCALL __attribute__((fastcall))
78
79#endif
80
81#ifdef __clang__
82#pragma clang diagnostic ignored "-Wmultichar"
83#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
84#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
85#endif
86
87//==============================================================================================
88// PLATFORM SPECIFICS
89//==============================================================================================
90
91//
92// SYMCRYPT_CALL & SYMCRYPT_ALIGN
93//
94// SYMCRYPT_CALL is a macro that selects the calling convention used by the library.
95// Crypto functions often have to perform very many small operations, and a fast calling convention is
96// preferable. We use __fastcall on platforms that support it.
97//
98// SYMCRYPT_ALIGN is the default alignment for the platform.
99// On platforms that have alignment restrictions the default alignment should be large enough that
100// an aligned BYTE * can be cast to a pointer to a UINT32 and be used.
101//
102//
103// The SYMCRYPT_IGNORE_PLATFORM macro can be defined to switch off any platform-specific
104// optimizations and run just the C implementations.
105// The rest of the library uses SYMCRYPT_CPU_* macros to make platform decisions.
106//
107//
108// WARNING: both the library and the calling application must be compiled with the same
109// set of flags, as the flags affect things like the structure layout and size and
110// the calling convention, both of which need to be in sync between the lib and the caller.
111//
112
113//#define SYMCRYPT_IGNORE_PLATFORM // #defining this flag disables all platform optimizations.
114
115#ifndef __WINE_PE_BUILD
116#define SYMCRYPT_IGNORE_PLATFORM
117#elif defined __clang_major__ && __clang_major__ < 19
118/* clang versions < 19 don't implement target attributes correctly */
119#define SYMCRYPT_IGNORE_PLATFORM
120#endif
121
122#define SYMCRYPT_CPU_X86 0
123#define SYMCRYPT_CPU_AMD64 0
124#define SYMCRYPT_CPU_ARM 0
125#define SYMCRYPT_CPU_ARM64 0
126#define SYMCRYPT_CPU_UNKNOWN 0
127
128#if (defined( _X86_ ) || defined( _M_IX86 ) || defined( __i386__ )) && !defined ( SYMCRYPT_IGNORE_PLATFORM )
129
130#undef SYMCRYPT_CPU_X86
131#define SYMCRYPT_CPU_X86 1
132
133#define SYMCRYPT_CALL SYMCRYPT_FASTCALL
134#define SYMCRYPT_ALIGN_VALUE 4
135
136#ifndef _PREFAST_
137#pragma warning(push)
138#pragma warning(disable:4359) // *** Alignment specifier is less than actual alignment
139#endif
140
141#elif (defined( _ARM64_ ) || defined( _ARM64EC_ ) || defined( _M_ARM64 ) || defined( __aarch64__ ) || defined(__arm64ec__)) && !defined( SYMCRYPT_IGNORE_PLATFORM )
142
143#undef SYMCRYPT_CPU_ARM64
144#define SYMCRYPT_CPU_ARM64 1
145#define SYMCRYPT_CALL
146#define SYMCRYPT_ALIGN_VALUE 16
147
148#elif (defined( _AMD64_ ) || defined( _M_AMD64 ) || defined( __amd64__ )) && !defined ( SYMCRYPT_IGNORE_PLATFORM )
149
150#undef SYMCRYPT_CPU_AMD64
151#define SYMCRYPT_CPU_AMD64 1
152
153#define SYMCRYPT_CALL
154#define SYMCRYPT_ALIGN_VALUE 16
155
156#elif (defined( _ARM_ ) || defined( _M_ARM ) || defined( __arm__ )) && !defined( SYMCRYPT_IGNORE_PLATFORM )
157
158#undef SYMCRYPT_CPU_ARM
159#define SYMCRYPT_CPU_ARM 1
160#define SYMCRYPT_CALL
161#define SYMCRYPT_ALIGN_VALUE 8
162
163#elif defined( SYMCRYPT_IGNORE_PLATFORM )
164
165#undef SYMCRYPT_CPU_UNKNOWN
166#define SYMCRYPT_CPU_UNKNOWN 1
167#define SYMCRYPT_CALL
168#define SYMCRYPT_ALIGN_VALUE 4
169
170#ifndef _PREFAST_
171#pragma warning(push)
172#pragma warning(disable:4359) // *** Alignment specifier is less than actual alignment
173#endif
174
175#else
176
177#error Unknown CPU platform
178
179#endif // SYMCRYPT_CALL platforms switch
180
181
182//
183// Datatypes used by the SymCrypt library. This ensures compatibility
184// with multiple environments, such as Windows, iOS, and Android.
185//
186
187#if SYMCRYPT_PLATFORM_WINDOWS
188
189 //
190 // Types included in intsafe.h:
191 // BYTE,
192 // INT16, UINT16,
193 // INT32, UINT32,
194 // INT64, UINT64,
195 // UINT_PTR
196 // and macro:
197 // UINT32_MAX
198 //
199#include <intsafe.h>
200
201#else
202
203#include <stdint.h>
204
205typedef uint8_t BYTE;
206
207#ifndef UINT32_MAX
208#define UINT32_MAX (0xffffffff)
209#endif
210
211#ifndef TRUE
212#define TRUE 0x01
213#endif
214
215#ifndef FALSE
216#define FALSE 0x00
217#endif
218
219// Size_t
220typedef size_t SIZE_T;
221
222#ifndef SIZE_T_MAX
223#define SIZE_T_MAX SIZE_MAX
224#endif
225
226typedef int BOOL;
227
228typedef int8_t INT8, *PINT8;
236
237// minwindef.h
238typedef char CHAR;
239
240#endif //WIN32
241
242#include <stddef.h>
243
244//
245// Pointer types
246//
247typedef BYTE * PBYTE;
248typedef const BYTE * PCBYTE;
249
250typedef UINT16 * PUINT16;
251typedef const UINT16 * PCUINT16;
252
253typedef UINT32 * PUINT32;
254typedef const UINT32 * PCUINT32;
255
256typedef UINT64 * PUINT64;
257typedef const UINT64 * PCUINT64;
258
259// Void
260
261#ifndef VOID
262#define VOID void
263#endif
264
265typedef void * PVOID;
266typedef const void * PCVOID;
267
268// winnt.h
269typedef BYTE BOOLEAN;
270
271// Useful macros for structs
272#define SYMCRYPT_FIELD_OFFSET(type, field) (offsetof(type, field))
273#define SYMCRYPT_FIELD_SIZE(type, field) (sizeof( ((type *)0)->field ))
274
275#if SYMCRYPT_MS_VC
276
277#ifndef FORCEINLINE
278#if (_MSC_VER >= 1200)
279#define FORCEINLINE __forceinline
280#else
281#define FORCEINLINE __inline
282#endif
283#endif
284
285#else
286
287#undef FORCEINLINE
288#define FORCEINLINE static inline
289
290#endif
291
293#define SYMCRYPT_ALIGN_UP( _p ) ((PBYTE) ( ((SIZE_T) (_p) + SYMCRYPT_ALIGN_VALUE - 1) & ~(SYMCRYPT_ALIGN_VALUE - 1 ) ) )
294
295#if SYMCRYPT_MS_VC
296 #define SYMCRYPT_ALIGN_AT(alignment) __declspec(align(alignment))
297 #define SYMCRYPT_WEAK_SYMBOL
298#elif SYMCRYPT_GNUC
299 #define SYMCRYPT_ALIGN_AT(alignment) __attribute__((aligned(alignment)))
300 #define SYMCRYPT_WEAK_SYMBOL __attribute__((weak))
301#else
302 #define SYMCRYPT_ALIGN_AT(alignment)
303 #define SYMCRYPT_WEAK_SYMBOL
304#endif
305#define SYMCRYPT_ALIGN_TYPE_AT(typename, alignment) typename SYMCRYPT_ALIGN_AT(alignment)
306#define SYMCRYPT_ALIGN SYMCRYPT_ALIGN_AT(SYMCRYPT_ALIGN_VALUE)
307#define SYMCRYPT_ALIGN_STRUCT SYMCRYPT_ALIGN_TYPE_AT(struct, SYMCRYPT_ALIGN_VALUE)
308#define SYMCRYPT_ALIGN_UNION SYMCRYPT_ALIGN_TYPE_AT(union, SYMCRYPT_ALIGN_VALUE)
309
310
311#define SYMCRYPT_MAX( _a, _b ) ((_a)>(_b)?(_a):(_b))
312#define SYMCRYPT_MIN( _a, _b ) ((_a)<(_b)?(_a):(_b))
313
314#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64
315//
316// XMM related declarations, used in data structures.
317//
318#pragma prefast(push)
319#pragma prefast(disable: 28251, "Windows headers define _mm_clflush with SAL annotation, Intel header doesn't have SAL annotation leading to inconsistent annotation errors")
320#include <emmintrin.h>
321#pragma prefast(pop)
322#endif
323
324
325//
326// To provide quick error detection we have magic values in all
327// our data structures, but only in CHKed builds.
328// Our magic value depends on the address of the structure.
329// This has the advantage that we detect blind memcpy's of our data structures.
330// Memcpy is not supported as it limits what the library is allowed to do.
331// Where needed the library provides for copy functions of its internal data structures.
332//
333#if SYMCRYPT_DEBUG && !defined(__REACTOS__)
334 #define SYMCRYPT_MAGIC_ENABLED
335#endif
336
337#if defined(SYMCRYPT_MAGIC_ENABLED )
338
339#define SYMCRYPT_MAGIC_FIELD SIZE_T magic;
340#define SYMCRYPT_MAGIC_VALUE( p ) ((SIZE_T) p + 'S1mv' + SYMCRYPT_API_VERSION)
341
342
343#define SYMCRYPT_SET_MAGIC( p ) {(p)->magic = SYMCRYPT_MAGIC_VALUE( p );}
344#define SYMCRYPT_CHECK_MAGIC( p ) {if((p)->magic!=SYMCRYPT_MAGIC_VALUE(p)) SymCryptFatal('magc');}
345#define SYMCRYPT_WIPE_MAGIC( p ) {(p)->magic = 0;}
346
347#else
348
349//
350// We define the magic field even for FRE builds, because we get too many
351// hard-to-debug problems with people who accidentally mix FRE headers with CHKed libraries,
352// or the other way around.
353// E.g. BitLocker only publishes the FRE version of their library, and building a CHKed binary with
354// that FRE lib crashes
355//
356
357#define SYMCRYPT_MAGIC_FIELD SIZE_T magic;
358#define SYMCRYPT_SET_MAGIC( p )
359#define SYMCRYPT_CHECK_MAGIC( p )
360#define SYMCRYPT_WIPE_MAGIC( p )
361
362#endif
363
364//
365// CPU feature detection infrastructure
366//
367
368#if !SYMCRYPT_PLATFORM_WINDOWS
369 // Forward declarations for CPUID intrinsic replacements
370 void __cpuidex(int CPUInfo[4], int InfoType, int ECXValue);
371#endif
372
373#if SYMCRYPT_CPU_ARM || SYMCRYPT_CPU_ARM64
374
375#define SYMCRYPT_CPU_FEATURE_NEON 0x01
376#define SYMCRYPT_CPU_FEATURE_NEON_AES 0x02
377#define SYMCRYPT_CPU_FEATURE_NEON_PMULL 0x04
378#define SYMCRYPT_CPU_FEATURE_NEON_SHA256 0x08
379
380#elif SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64
381
382//
383// We keep the most commonly tested bits in the least significant byte, to make it easier for the compiler to optimize
384// There is a many to one relationship between CPUID feature flags and SYMCRYPT_CPU_FEATURE_XXX bits
385// since a SYMCRYPT_CPU_FEATURE_XXX could require multiple CPUID features.
386
387#define SYMCRYPT_CPU_FEATURE_SSE2 0x0001 // includes SSE, SSE2
388#define SYMCRYPT_CPU_FEATURE_SSSE3 0x0002 // includes SSE, SSE2, SSE3, SSSE3
389#define SYMCRYPT_CPU_FEATURE_AESNI 0x0004
390#define SYMCRYPT_CPU_FEATURE_PCLMULQDQ 0x0008
391#define SYMCRYPT_CPU_FEATURE_AVX2 0x0010 // includes AVX, AVX2 - also indicates support for saving/restoring Ymm registers
392#define SYMCRYPT_CPU_FEATURE_SAVEXMM_NOFAIL 0x0020 // if SymCryptSaveXmm() will never fail
393#define SYMCRYPT_CPU_FEATURE_SHANI 0x0040
394#define SYMCRYPT_CPU_FEATURE_BMI2 0x0080 // MULX, RORX, SARX, SHLX, SHRX
395
396#define SYMCRYPT_CPU_FEATURE_ADX 0x0100 // ADCX, ADOX
397#define SYMCRYPT_CPU_FEATURE_RDRAND 0x0200
398#define SYMCRYPT_CPU_FEATURE_RDSEED 0x0400
399#define SYMCRYPT_CPU_FEATURE_VAES 0x0800 // support for VAES and VPCLMULQDQ (may only be supported on Ymm registers (i.e. Zen3))
400#define SYMCRYPT_CPU_FEATURE_AVX512 0x1000 // includes F, VL, DQ, BW (VL allows AVX-512 instructions to be used on Xmm and Ymm registers)
401 // also indicates support for saving/restoring additional AVX-512 state
402
403#define SYMCRYPT_CPU_FEATURE_CMPXCHG16B 0x2000 // Compare and Swap 128b value
404
405#endif
406
408
409//
410// We have two feature fields.
411// g_SymCryptCpuFeaturesNotPresent reports with features are not present on the current CPU
412// SymCryptCpuFeaturesNeverPresent() is a function that returns a static (compiler-predictable) value,
413// and allows the environment to lock out features in a way that the compiler can optimize away all the code that uses these features.
414// Using a function allows the environment macro to forward it to an environment-specific function.
415//
416
418
422
423#define SYMCRYPT_CPU_FEATURES_PRESENT( x ) ( ((x) & SymCryptCpuFeaturesNeverPresent()) == 0 && ( (x) & g_SymCryptCpuFeaturesNotPresent ) == 0 )
424
425//
426// VOLATILE MEMORY ACCESS
427//
428// These macros are used to explicitly handle volatile memory access independent of compiler settings.
429// If volatile memory is accessed directly without using the appropriate macro, MSVC may emit warning
430// C4746, because the volatile semantics depend on the value of the /volatile flag, which can result in
431// undesired hardware memory barriers that impact performance.
432//
433// More info:
434// https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c4746?view=msvc-170
435// https://docs.microsoft.com/en-us/cpp/build/reference/volatile-volatile-keyword-interpretation?view=msvc-170
436//
437
438#if SYMCRYPT_MS_VC // Microsoft VC++ Compiler
439
440 #if SYMCRYPT_CPU_ARM || SYMCRYPT_CPU_ARM64
441 #define SYMCRYPT_INTERNAL_VOLATILE_READ8( _p ) ( __iso_volatile_load8( (const volatile char*)(_p) ) )
442 #define SYMCRYPT_INTERNAL_VOLATILE_READ16( _p ) ( __iso_volatile_load16( (const volatile short*)(_p) ) )
443 #define SYMCRYPT_INTERNAL_VOLATILE_READ32( _p ) ( __iso_volatile_load32( (const volatile int*)(_p) ) )
444 #define SYMCRYPT_INTERNAL_VOLATILE_READ64( _p ) ( __iso_volatile_load64( (const volatile __int64*)(_p) ) )
445
446 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE8( _p, _v ) ( __iso_volatile_store8( (volatile char*)(_p), (_v) ) )
447 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE16( _p, _v ) ( __iso_volatile_store16( (volatile short*)(_p), (_v) ) )
448 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE32( _p, _v ) ( __iso_volatile_store32( (volatile int*)(_p), (_v) ) )
449 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE64( _p, _v ) ( __iso_volatile_store64( (volatile __int64*)(_p), (_v) ) )
450 #elif SYMCRYPT_CPU_X86 || SYMCRYPT_CPU_AMD64
451 #define SYMCRYPT_INTERNAL_VOLATILE_READ8( _p ) ( *((const volatile BYTE*) (_p)) )
452 #define SYMCRYPT_INTERNAL_VOLATILE_READ16( _p ) ( *((const volatile UINT16*)(_p)) )
453 #define SYMCRYPT_INTERNAL_VOLATILE_READ32( _p ) ( *((const volatile UINT32*)(_p)) )
454 #define SYMCRYPT_INTERNAL_VOLATILE_READ64( _p ) ( *((const volatile UINT64*)(_p)) )
455
456 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE8( _p, _v ) ( *((volatile BYTE*) (_p)) = (_v) )
457 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE16( _p, _v ) ( *((volatile UINT16*)(_p)) = (_v) )
458 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE32( _p, _v ) ( *((volatile UINT32*)(_p)) = (_v) )
459 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE64( _p, _v ) ( *((volatile UINT64*)(_p)) = (_v) )
460 #else // Temporary workaround for CMake compilation issues on Windows. Assume X86/ADM64.
461 #define SYMCRYPT_INTERNAL_VOLATILE_READ8( _p ) ( *((const volatile BYTE*) (_p)) )
462 #define SYMCRYPT_INTERNAL_VOLATILE_READ16( _p ) ( *((const volatile UINT16*)(_p)) )
463 #define SYMCRYPT_INTERNAL_VOLATILE_READ32( _p ) ( *((const volatile UINT32*)(_p)) )
464 #define SYMCRYPT_INTERNAL_VOLATILE_READ64( _p ) ( *((const volatile UINT64*)(_p)) )
465
466 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE8( _p, _v ) ( *((volatile BYTE*) (_p)) = (_v) )
467 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE16( _p, _v ) ( *((volatile UINT16*)(_p)) = (_v) )
468 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE32( _p, _v ) ( *((volatile UINT32*)(_p)) = (_v) )
469 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE64( _p, _v ) ( *((volatile UINT64*)(_p)) = (_v) )
470 #endif
471
472#elif SYMCRYPT_GNUC
473
474 #if !SYMCRYPT_CPU_ARM
475 #define SYMCRYPT_INTERNAL_VOLATILE_READ8( _p ) ( *((const volatile BYTE*) (_p)) )
476 #define SYMCRYPT_INTERNAL_VOLATILE_READ16( _p ) ( *((const volatile UINT16*)(_p)) )
477 #define SYMCRYPT_INTERNAL_VOLATILE_READ32( _p ) ( *((const volatile UINT32*)(_p)) )
478 #define SYMCRYPT_INTERNAL_VOLATILE_READ64( _p ) ( *((const volatile UINT64*)(_p)) )
479
480 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE8( _p, _v ) ( *((volatile BYTE*) (_p)) = (_v) )
481 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE16( _p, _v ) ( *((volatile UINT16*)(_p)) = (_v) )
482 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE32( _p, _v ) ( *((volatile UINT32*)(_p)) = (_v) )
483 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE64( _p, _v ) ( *((volatile UINT64*)(_p)) = (_v) )
484 #else // SYMCRYPT_CPU_ARM
485 #define SYMCRYPT_INTERNAL_VOLATILE_READ8( _p ) ( *((const volatile BYTE*) (_p)) )
486 #define SYMCRYPT_INTERNAL_VOLATILE_READ16( _p ) ( *((const volatile UINT16*)(_p)) )
487 #define SYMCRYPT_INTERNAL_VOLATILE_READ32( _p ) ( *((const volatile UINT32*)(_p)) )
488 #define SYMCRYPT_INTERNAL_VOLATILE_READ64( p ) ( (UINT64)SYMCRYPT_INTERNAL_VOLATILE_READ32(&((PBYTE)p)[4]) << 32 | SYMCRYPT_INTERNAL_VOLATILE_READ32(&((PBYTE)p)[0]) )
489
490 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE8( _p, _v ) ( *((volatile BYTE*) (_p)) = (_v) )
491 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE16( _p, _v ) ( *((volatile UINT16*)(_p)) = (_v) )
492 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE32( _p, _v ) ( *((volatile UINT32*)(_p)) = (_v) )
493 #define SYMCRYPT_INTERNAL_VOLATILE_WRITE64( p, x ) { \
494 SYMCRYPT_INTERNAL_VOLATILE_WRITE32( &((PBYTE)p)[0], (UINT32)((x) ) );\
495 SYMCRYPT_INTERNAL_VOLATILE_WRITE32( &((PBYTE)p)[4], (UINT32)(((UINT64)(x))>>32) );\
496 }
497 #endif
498
499#else
500
501 #error Unknown compiler
502
503#endif
504
505//
506// FORCED MEMORY ACCESS
507//
508// These macros force a memory access. That is, they require that the memory
509// read or write takes place, and do not allow the compiler to optimize the access
510// away.
511// They provide no other memory ordering requirements, so there are no acquire/release
512// semantics, memory barriers, etc.
513//
514// The generic versions are implemented with a volatile access, but that is inefficient on some platforms
515// because it might introduce memory ordering requirements.
516//
517
518#define SYMCRYPT_INTERNAL_FORCE_READ8( _p ) SYMCRYPT_INTERNAL_VOLATILE_READ8( _p )
519#define SYMCRYPT_INTERNAL_FORCE_READ16( _p ) SYMCRYPT_INTERNAL_VOLATILE_READ16( _p )
520#define SYMCRYPT_INTERNAL_FORCE_READ32( _p ) SYMCRYPT_INTERNAL_VOLATILE_READ32( _p )
521#define SYMCRYPT_INTERNAL_FORCE_READ64( _p ) SYMCRYPT_INTERNAL_VOLATILE_READ64( _p )
522
523#define SYMCRYPT_INTERNAL_FORCE_WRITE8( _p, _v ) SYMCRYPT_INTERNAL_VOLATILE_WRITE8( _p, _v )
524#define SYMCRYPT_INTERNAL_FORCE_WRITE16( _p, _v ) SYMCRYPT_INTERNAL_VOLATILE_WRITE16( _p, _v )
525#define SYMCRYPT_INTERNAL_FORCE_WRITE32( _p, _v ) SYMCRYPT_INTERNAL_VOLATILE_WRITE32( _p, _v )
526#define SYMCRYPT_INTERNAL_FORCE_WRITE64( _p, _v ) SYMCRYPT_INTERNAL_VOLATILE_WRITE64( _p, _v )
527
528//
529// FIXED ENDIANNESS ACCESS
530//
531// Fixed endianness load and store
532// We do this by platform because it affected by both endianness and alignment requirements
533// The p pointer is always a pointer to BYTE
534//
535#if SYMCRYPT_MS_VC // Microsoft VC++ Compiler
536 #define SYMCRYPT_BSWAP16( x ) _byteswap_ushort(x)
537 #define SYMCRYPT_BSWAP32( x ) _byteswap_ulong(x)
538 #define SYMCRYPT_BSWAP64( x ) _byteswap_uint64(x)
539#elif SYMCRYPT_GNUC
540 #define SYMCRYPT_BSWAP16( x ) __builtin_bswap16(x)
541 #define SYMCRYPT_BSWAP32( x ) __builtin_bswap32(x)
542 #define SYMCRYPT_BSWAP64( x ) __builtin_bswap64(x)
543#endif
544
545#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM64
546
547
548//
549// X86, AMD64, ARM, and ARM64 have no alignment restrictions, and are little-endian.
550// We do straight store/loads with BSWAPs where required.
551// This technically relies upon on undefined behavior, as we assume the compiler will translate
552// operations on unaligned pointers to 2, 4, and 8 bytes types to appropriately unaligned store/load
553// instructions on these platforms (not just in these macros). This works for all compilers we
554// currently use.
555//
556#define SYMCRYPT_INTERNAL_LOAD_MSBFIRST16( p ) SYMCRYPT_BSWAP16( *((UINT16 *)(p)) )
557#define SYMCRYPT_INTERNAL_LOAD_LSBFIRST16( p ) ( *((UINT16 *)(p)) )
558#define SYMCRYPT_INTERNAL_LOAD_MSBFIRST32( p ) SYMCRYPT_BSWAP32( *((UINT32 *)(p)) )
559#define SYMCRYPT_INTERNAL_LOAD_LSBFIRST32( p ) ( *((UINT32 *)(p)) )
560#define SYMCRYPT_INTERNAL_LOAD_MSBFIRST64( p ) SYMCRYPT_BSWAP64( *((UINT64 *)(p)) )
561#define SYMCRYPT_INTERNAL_LOAD_LSBFIRST64( p ) ( *((UINT64 *)(p)) )
562
563#define SYMCRYPT_INTERNAL_STORE_MSBFIRST16( p, x ) ( *(UINT16 *)(p) = SYMCRYPT_BSWAP16(x) )
564#define SYMCRYPT_INTERNAL_STORE_LSBFIRST16( p, x ) ( *(UINT16 *)(p) = (x) )
565#define SYMCRYPT_INTERNAL_STORE_MSBFIRST32( p, x ) ( *(UINT32 *)(p) = SYMCRYPT_BSWAP32(x) )
566#define SYMCRYPT_INTERNAL_STORE_LSBFIRST32( p, x ) ( *(UINT32 *)(p) = (x) )
567#define SYMCRYPT_INTERNAL_STORE_MSBFIRST64( p, x ) ( *(UINT64 *)(p) = SYMCRYPT_BSWAP64(x) )
568#define SYMCRYPT_INTERNAL_STORE_LSBFIRST64( p, x ) ( *(UINT64 *)(p) = (x) )
569
570#elif SYMCRYPT_CPU_ARM
571
572//
573// Only 64 bit accesses need to be aligned.
574//
575#define SYMCRYPT_INTERNAL_LOAD_MSBFIRST16( p ) SYMCRYPT_BSWAP16( *((UINT16 *)(p)) )
576#define SYMCRYPT_INTERNAL_LOAD_LSBFIRST16( p ) ( *((UINT16 *)(p)) )
577#define SYMCRYPT_INTERNAL_LOAD_MSBFIRST32( p ) SYMCRYPT_BSWAP32( *((UINT32 *)(p)) )
578#define SYMCRYPT_INTERNAL_LOAD_LSBFIRST32( p ) ( *((UINT32 *)(p)) )
579
580#define SYMCRYPT_INTERNAL_LOAD_MSBFIRST64( p ) ( (UINT64)SYMCRYPT_INTERNAL_LOAD_MSBFIRST32(&((PBYTE)p)[0]) << 32 | SYMCRYPT_INTERNAL_LOAD_MSBFIRST32(&((PBYTE)p)[4]) )
581#define SYMCRYPT_INTERNAL_LOAD_LSBFIRST64( p ) ( (UINT64)SYMCRYPT_INTERNAL_LOAD_LSBFIRST32(&((PBYTE)p)[4]) << 32 | SYMCRYPT_INTERNAL_LOAD_LSBFIRST32(&((PBYTE)p)[0]) )
582
583
584
585#define SYMCRYPT_INTERNAL_STORE_MSBFIRST16( p, x ) ( *(UINT16 *)(p) = SYMCRYPT_BSWAP16(x) )
586#define SYMCRYPT_INTERNAL_STORE_LSBFIRST16( p, x ) ( *(UINT16 *)(p) = (x) )
587#define SYMCRYPT_INTERNAL_STORE_MSBFIRST32( p, x ) ( *(UINT32 *)(p) = SYMCRYPT_BSWAP32(x) )
588#define SYMCRYPT_INTERNAL_STORE_LSBFIRST32( p, x ) ( *(UINT32 *)(p) = (x) )
589#define SYMCRYPT_INTERNAL_STORE_MSBFIRST64( p, x ) { \
590 SYMCRYPT_INTERNAL_STORE_MSBFIRST32( &((PBYTE)p)[0],(UINT32)(((UINT64)(x))>>32) );\
591 SYMCRYPT_INTERNAL_STORE_MSBFIRST32( &((PBYTE)p)[4],(UINT32)(x));\
592 }
593
594#define SYMCRYPT_INTERNAL_STORE_LSBFIRST64( p, x ) { \
595 SYMCRYPT_INTERNAL_STORE_LSBFIRST32( &((PBYTE)p)[0], (UINT32)((x) ) );\
596 SYMCRYPT_INTERNAL_STORE_LSBFIRST32( &((PBYTE)p)[4], (UINT32)(((UINT64)(x))>>32) );\
597 }
598#else // unknown platform
599
600//
601// These functions have to handle arbitrary alignments too, so we do them byte-by-byte in the
602// generic case.
603// So far these macros have not been fully tested
604//
605#define SYMCRYPT_INTERNAL_LOAD_MSBFIRST16( p ) ( ((UINT16)((PBYTE)p)[0]) << 8 | ((PBYTE)p)[1] )
606#define SYMCRYPT_INTERNAL_LOAD_LSBFIRST16( p ) ( ((UINT16)((PBYTE)p)[1]) << 8 | ((PBYTE)p)[0] )
607#define SYMCRYPT_INTERNAL_LOAD_MSBFIRST32( p ) ( (UINT32)SYMCRYPT_INTERNAL_LOAD_MSBFIRST16(&((PBYTE)p)[0]) << 16 | SYMCRYPT_INTERNAL_LOAD_MSBFIRST16(&((PBYTE)p)[2]) )
608#define SYMCRYPT_INTERNAL_LOAD_LSBFIRST32( p ) ( (UINT32)SYMCRYPT_INTERNAL_LOAD_LSBFIRST16(&((PBYTE)p)[2]) << 16 | SYMCRYPT_INTERNAL_LOAD_LSBFIRST16(&((PBYTE)p)[0]) )
609#define SYMCRYPT_INTERNAL_LOAD_MSBFIRST64( p ) ( (UINT64)SYMCRYPT_INTERNAL_LOAD_MSBFIRST32(&((PBYTE)p)[0]) << 32 | SYMCRYPT_INTERNAL_LOAD_MSBFIRST32(&((PBYTE)p)[4]) )
610#define SYMCRYPT_INTERNAL_LOAD_LSBFIRST64( p ) ( (UINT64)SYMCRYPT_INTERNAL_LOAD_LSBFIRST32(&((PBYTE)p)[4]) << 32 | SYMCRYPT_INTERNAL_LOAD_LSBFIRST32(&((PBYTE)p)[0]) )
611
612#define SYMCRYPT_INTERNAL_STORE_MSBFIRST16( p, x ) { \
613 ((PBYTE)p)[0] = (BYTE)((x)>> 8);\
614 ((PBYTE)p)[1] = (BYTE)((x) );\
615 }
616
617#define SYMCRYPT_INTERNAL_STORE_LSBFIRST16( p, x ) { \
618 ((PBYTE)p)[0] = (BYTE)((x) );\
619 ((PBYTE)p)[1] = (BYTE)((x)>> 8);\
620 }
621
622#define SYMCRYPT_INTERNAL_STORE_MSBFIRST32( p, x ) { \
623 ((PBYTE)p)[0] = (BYTE)((x)>>24);\
624 ((PBYTE)p)[1] = (BYTE)((x)>>16);\
625 ((PBYTE)p)[2] = (BYTE)((x)>> 8);\
626 ((PBYTE)p)[3] = (BYTE)((x) );\
627 }
628
629#define SYMCRYPT_INTERNAL_STORE_LSBFIRST32( p, x ) { \
630 ((PBYTE)p)[0] = (BYTE)((x) );\
631 ((PBYTE)p)[1] = (BYTE)((x)>> 8);\
632 ((PBYTE)p)[2] = (BYTE)((x)>>16);\
633 ((PBYTE)p)[3] = (BYTE)((x)>>24);\
634 }
635
636#define SYMCRYPT_INTERNAL_STORE_MSBFIRST64( p, x ) { \
637 SYMCRYPT_INTERNAL_STORE_MSBFIRST32( &((PBYTE)p)[0],(UINT32)(((UINT64)(x))>>32) );\
638 SYMCRYPT_INTERNAL_STORE_MSBFIRST32( &((PBYTE)p)[4],(UINT32)(x));\
639 }
640
641#define SYMCRYPT_INTERNAL_STORE_LSBFIRST64( p, x ) { \
642 SYMCRYPT_INTERNAL_STORE_LSBFIRST32( &((PBYTE)p)[0], (UINT32)((x) ) );\
643 SYMCRYPT_INTERNAL_STORE_LSBFIRST32( &((PBYTE)p)[4], (UINT32)(((UINT64)(x))>>32) );\
644 }
645
646#endif // platform switch for load/store macros
647
648
649//==============================================================================================
650// INTERNAL DATA STRUCTURES
651//==============================================================================================
652//
653// Note: we do not use the symbolic names like SYMCRYPT_SHA1_INPUT_BLOCK_SIZE as this
654// file is included before that name is defined. Fixing that would make the public API header
655// file harder to read by moving the constant away from the associated functions, or forcing
656// the header file to use the struct name rather than the typedef. The current solution
657// works quite well.
658//
659
660//-----------------------------------------------------------------
661// Block cipher description table
662// Below are the typedefs for the block cipher description table type
663// Callers can use this to define their own block cipher and use the block cipher
664// modes.
665//
666
669
670//
671// Note that blockSize must be <= 32 and must be a power of two. This is true for all the block ciphers
672// implemented in SymCrypt.
673//
674
675//
676// HASH STATES
677//
678// All hash states have the same basic structure. This allows all hash implementations to share
679// the same buffer management code. Some algorithms might still have optimized buffer management code
680// specific for their algorithm, but most algs use the generic code.
681// This is especially important for parallel hashing, where the buffer management & parallel organizational
682// code are tightly coupled.
683//
684
686{
689 UINT64 dataLengthL; // lower part of msg length
690 UINT64 dataLengthH; // upper part of msg length
691 SYMCRYPT_ALIGN BYTE buffer[SYMCRYPT_ANYSIZE_ARRAY]; // Size depends on algorithm
692 // ...
693 // Chaining state // type/location depends on algorithm
694 //
696
697
698//
699// SYMCRYPT_MD2_STATE
700//
701// Data structure that stores the state of an ongoing MD2 computation.
702//
703// The field names are from RFC 1319.
704// It would be more efficient to store only the first 16 bytes of the X array,
705// but that would complicate the code and MD2 isn't important enough to add
706// extra complications.
707//
709{
710 SYMCRYPT_ALIGN BYTE C[16]; // State for internal checksum computation
711 BYTE X[48]; // State for actual hash chaining
713
714//
715// MD2 hash computation state.
716//
718{
721 UINT64 dataLengthL; // lower part of msg length
722 UINT64 dataLengthH; // upper part of msg length
723 SYMCRYPT_ALIGN BYTE buffer[16]; // buffer to keep one input block in
727
728//
729// SYMCRYPT_MD4_STATE
730//
731// Data structure that stores the state of an ongoing MD4 computation.
732// The buffer contains dataLength % 64 bytes of data.
733//
735{
736 UINT32 H[4];
738
740{
743 UINT64 dataLengthL; // lower part of msg length
744 UINT64 dataLengthH; // upper part of msg length
745 SYMCRYPT_ALIGN BYTE buffer[64]; // buffer to keep one input block in
746 SYMCRYPT_MD4_CHAINING_STATE chain; // chaining state
749
750
751//
752// SYMCRYPT_MD5_STATE
753//
754// Data structure that stores the state of an ongoing MD5 computation.
755// The buffer contains dataLength % 64 bytes of data.
756//
758{
759 UINT32 H[4];
761
762
764{
767 UINT64 dataLengthL; // lower part of msg length
768 UINT64 dataLengthH; // upper part of msg length
769 SYMCRYPT_ALIGN BYTE buffer[64]; // buffer to keep one input block in
770 SYMCRYPT_MD5_CHAINING_STATE chain; // chaining state
773
774
775//
776// SYMCRYPT_SHA1_STATE
777//
778// Data structure that stores the state of an ongoing SHA1 computation.
779// The buffer contains dataLength % 64 bytes of data.
780//
782{
783 UINT32 H[5];
785
787{
790 UINT64 dataLengthL; // lower part of msg length
791 UINT64 dataLengthH; // upper part of msg length
792 SYMCRYPT_ALIGN BYTE buffer[64]; // buffer to keep one input block in
793 SYMCRYPT_SHA1_CHAINING_STATE chain; // chaining state
796
797
798//
799// SYMCRYPT_SHA256_STATE
800//
801// Data structure that stores the state of an ongoing SHA256 computation.
802// The buffer contains dataLength % 64 bytes of data.
803//
805{
808
810{
813 UINT64 dataLengthL; // lower part of msg length
814 UINT64 dataLengthH; // upper part of msg length
815 SYMCRYPT_ALIGN BYTE buffer[64]; // buffer to keep one input block in
816 SYMCRYPT_SHA256_CHAINING_STATE chain; // chaining state
819
820
821//
822// SYMCRYPT_SHA224_STATE
823//
824// This is identical to the SHA256 state.
825//
827{
830 UINT64 dataLengthL; // lower part of msg length
831 UINT64 dataLengthH; // upper part of msg length
832 SYMCRYPT_ALIGN BYTE buffer[64]; // buffer to keep one input block in
833 SYMCRYPT_SHA256_CHAINING_STATE chain; // chaining state
836
837
838//
839// SYMCRYPT_SHA512_STATE
840//
841// Data structure that stores the state of an ongoing SHA512 computation.
842// The buffer contains dataLength % 128 bytes of data.
843//
845{
846 UINT64 H[8];
848
850{
853 UINT64 dataLengthL; // lower part of msg length
854 UINT64 dataLengthH; // upper part of msg length
855 SYMCRYPT_ALIGN BYTE buffer[128]; // buffer to keep one input block in
856 SYMCRYPT_SHA512_CHAINING_STATE chain; // chaining state
859
860
861//
862// SYMCRYPT_SHA384_STATE
863//
864// This is identical to the SHA512.
865//
867{
870 UINT64 dataLengthL; // lower part of msg length
871 UINT64 dataLengthH; // upper part of msg length
872 SYMCRYPT_ALIGN BYTE buffer[128]; // buffer to keep one input block in
873 SYMCRYPT_SHA512_CHAINING_STATE chain; // chaining state
876
877
878//
879// SYMCRYPT_SHA512_224_STATE
880//
881// This is identical to the SHA512.
882//
884{
887 UINT64 dataLengthL; // lower part of msg length
888 UINT64 dataLengthH; // upper part of msg length
889 SYMCRYPT_ALIGN BYTE buffer[128]; // buffer to keep one input block in
890 SYMCRYPT_SHA512_CHAINING_STATE chain; // chaining state
893
894
895//
896// SYMCRYPT_SHA512_256_STATE
897//
898// This is identical to the SHA512.
899//
901{
904 UINT64 dataLengthL; // lower part of msg length
905 UINT64 dataLengthH; // upper part of msg length
906 SYMCRYPT_ALIGN BYTE buffer[128]; // buffer to keep one input block in
907 SYMCRYPT_SHA512_CHAINING_STATE chain; // chaining state
910
911
912//
913// SYMCRYPT_KECCAK_STATE
914//
915// Data structure that stores the state of an ongoing SHA-3 derived algorithm computation.
916//
917
919{
920 SYMCRYPT_ALIGN UINT64 state[25]; // state for Keccak-f[1600] permutation
922 UINT32 stateIndex; // position in the state for next merge/extract operation
923 UINT8 paddingValue; // Keccak padding value
924 BOOLEAN squeezeMode; // denotes whether the state is in squeeze mode
927
928//
929// SYMCRYPT_SHA3_224_STATE
930//
931// Data structure that stores the state of an ongoing SHA3-224 computation.
932//
934{
939
940//
941// SYMCRYPT_SHA3_256_STATE
942//
943// Data structure that stores the state of an ongoing SHA3-256 computation.
944//
946{
951
952//
953// SYMCRYPT_SHA3_384_STATE
954//
955// Data structure that stores the state of an ongoing SHA3-384 computation.
956//
958{
963
964//
965// SYMCRYPT_SHA3_512_STATE
966//
967// Data structure that stores the state of an ongoing SHA3-512 computation.
968//
970{
975
976//
977// SYMCRYPT_SHAKE128_STATE
978//
979// Data structure that stores the state of an ongoing SHAKE128 computation.
980//
982{
987
988//
989// SYMCRYPT_SHAKE256_STATE
990//
991// Data structure that stores the state of an ongoing SHAKE256 computation.
992//
994{
999
1000//
1001// SYMCRYPT_CSHAKE128_STATE
1002//
1003// Data structure that stores the state of an ongoing CSHAKE128 computation.
1004//
1006{
1011
1012//
1013// SYMCRYPT_CSHAKE256_STATE
1014//
1015// Data structure that stores the state of an ongoing CSHAKE256 computation.
1016//
1018{
1023
1024//
1025// SYMCRYPT_KMAC128_EXPANDED_KEY
1026//
1027// Data structure that stores the expanded key for KMAC128.
1028//
1030{
1035
1036//
1037// SYMCRYPT_KMAC128_STATE
1038//
1039// Data structure that stores the state of an ongoing KMAC128 computation.
1040//
1042{
1047
1048//
1049// SYMCRYPT_KMAC256_EXPANDED_KEY
1050//
1051// Data structure that stores the expanded key for KMAC256.
1052//
1054{
1059
1060//
1061// SYMCRYPT_KMAC256_STATE
1062//
1063// Data structure that stores the state of an ongoing KMAC256 computation.
1064//
1066{
1071
1072
1073//
1074// Generic hashing
1075//
1076
1077typedef struct _SYMCRYPT_OID {
1082
1083//
1084// OID lists for the most commonly used hash functions
1085//
1086
1087#define SYMCRYPT_MD5_OID_COUNT (2)
1089
1090#define SYMCRYPT_SHA1_OID_COUNT (2)
1092
1093#define SYMCRYPT_SHA224_OID_COUNT (2)
1095
1096#define SYMCRYPT_SHA256_OID_COUNT (2)
1098
1099#define SYMCRYPT_SHA384_OID_COUNT (2)
1101
1102#define SYMCRYPT_SHA512_OID_COUNT (2)
1104
1105#define SYMCRYPT_SHA512_224_OID_COUNT (2)
1107
1108#define SYMCRYPT_SHA512_256_OID_COUNT (2)
1110
1111#define SYMCRYPT_SHA3_224_OID_COUNT (2)
1113
1114#define SYMCRYPT_SHA3_256_OID_COUNT (2)
1116
1117#define SYMCRYPT_SHA3_384_OID_COUNT (2)
1119
1120#define SYMCRYPT_SHA3_512_OID_COUNT (2)
1122
1123#define SYMCRYPT_SHAKE128_OID_COUNT (2)
1125
1126#define SYMCRYPT_SHAKE256_OID_COUNT (2)
1128
1130{
1147
1151//
1152// Returns a pointer to the OID list for the specified OID list ID. If pCount is non-NULL, the
1153// pointed-to value will be set to the number of elements in the OID list.
1154// Returns NULL if the OID list ID is invalid.
1155//
1156
1158{
1175
1176#define SYMCRYPT_HASH_MAX_RESULT_SIZE SYMCRYPT_SHA512_RESULT_SIZE
1177
1180
1185
1190typedef VOID (SYMCRYPT_CALL * PSYMCRYPT_HASH_STATE_COPY_FUNC) ( PCVOID pStateSrc, PVOID pStateDst );
1191
1193{
1194 PSYMCRYPT_HASH_INIT_FUNC initFunc;
1199 UINT32 stateSize; // sizeof( hash state )
1200 UINT32 resultSize; // size of hash result
1202 UINT32 chainOffset; // offset into state structure of the chaining state
1203 UINT32 chainSize; // size of chaining state
1205
1206
1207//
1208// Parallel hashing
1209//
1210
1211#if SYMCRYPT_CPU_ARM
1212#define SYMCRYPT_PARALLEL_SHA256_MIN_PARALLELISM (3)
1213#define SYMCRYPT_PARALLEL_SHA256_MAX_PARALLELISM (4)
1214#else
1215#define SYMCRYPT_PARALLEL_SHA256_MIN_PARALLELISM (2)
1216#define SYMCRYPT_PARALLEL_SHA256_MAX_PARALLELISM (8)
1217#endif
1218
1223
1226
1228 SIZE_T iHash; // index of hash object into the state array
1229 SYMCRYPT_HASH_OPERATION_TYPE hashOperation; // operation to be performed
1230 _Field_size_( cbBuffer ) PBYTE pbBuffer; // data to be hashed, or result buffer
1231 SIZE_T cbBuffer; // size of pbData buffer.
1232 PSYMCRYPT_PARALLEL_HASH_OPERATION next; // internal scratch space; do not use.
1233};
1234
1235
1239
1241 PVOID hashState; // the actual hash state
1243 BYTE bytesAlreadyProcessed; // of the next Append operation
1244 UINT64 bytes; // # bytes left to process on this state
1245 PSYMCRYPT_PARALLEL_HASH_OPERATION next; // next operation to be performed.
1246 PCBYTE pbData; // data/size of ongoing append operation; this op has already been removed from the next linked list
1247 SIZE_T cbData;
1249
1250
1251//
1252// The scratch space used by parallel SHA-256 consists of three regions:
1253// - an array of SYMCRYPT_PARALLEL_HASH_SCRATCH_STATE structures, aligned to SYMCRYPT_ALIGN_VALUE.
1254// - the work array, an array of pointers to SYMCRYPT_PARALLEL_HASH_SCRATCH_STATEs.
1255// - an array of 4 + 8 + 64 SIMD vector elements, aligned to the size of those elements.
1256//
1257//
1258#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64
1259#define SYMCRYPT_SIMD_ELEMENT_SIZE 32
1260#elif SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM64
1261#define SYMCRYPT_SIMD_ELEMENT_SIZE 16
1262#elif SYMCRYPT_CPU_UNKNOWN
1263#define SYMCRYPT_SIMD_ELEMENT_SIZE 0
1264#else
1265#error Unknown CPU
1266#endif
1267
1268#define SYMCRYPT_PARALLEL_SHA256_FIXED_SCRATCH ( (4 + 8 + 64) * SYMCRYPT_SIMD_ELEMENT_SIZE + SYMCRYPT_SIMD_ELEMENT_SIZE - 1 + SYMCRYPT_ALIGN_VALUE - 1 )
1269#define SYMCRYPT_PARALLEL_SHA384_FIXED_SCRATCH ( (4 + 8 + 80) * SYMCRYPT_SIMD_ELEMENT_SIZE + SYMCRYPT_SIMD_ELEMENT_SIZE - 1 + SYMCRYPT_ALIGN_VALUE - 1 )
1270#define SYMCRYPT_PARALLEL_SHA512_FIXED_SCRATCH ( (4 + 8 + 80) * SYMCRYPT_SIMD_ELEMENT_SIZE + SYMCRYPT_SIMD_ELEMENT_SIZE - 1 + SYMCRYPT_ALIGN_VALUE - 1 )
1271#define SYMCRYPT_PARALLEL_HASH_PER_STATE_SCRATCH (sizeof( SYMCRYPT_PARALLEL_HASH_SCRATCH_STATE ) + sizeof( PSYMCRYPT_PARALLEL_HASH_SCRATCH_STATE ) )
1272
1276
1281 SIZE_T nPar,
1282 SIZE_T nBytes,
1283 _Out_writes_( cbSimdScratch ) PBYTE pbSimdScratch,
1284 SIZE_T cbSimdScratch );
1285
1287{
1288 PCSYMCRYPT_HASH pHash;
1289 UINT32 parScratchFixed; // fixed scratch size for parallel hash
1292 PSYMCRYPT_PARALLEL_HASH_RESULT_DONE_FUNC parResultDoneFunc;
1293
1296
1297
1298//======================================================================================================
1299// MAC
1300//
1301
1302
1303//
1304// SYMCRYPT_HMAC_MD5_EXPANDED_KEY
1305//
1306// Data structure to store an expanded key for HMAC-MD5.
1307//
1309{
1315
1316//
1317// SYMCRYPT_HMAC_MD5_STATE
1318//
1319// Data structure that encodes an ongoing HMAC-MD5 computation.
1320//
1322{
1328
1329
1330//
1331// SYMCRYPT_HMAC_SHA1_EXPANDED_KEY
1332//
1333// Data structure to store an expanded key for HMAC-SHA1.
1334//
1336{
1342
1343//
1344// SYMCRYPT_HMAC_SHA1_STATE
1345//
1346// Data structure that encodes an ongoing HMAC-SHA1 computation.
1347//
1349{
1355
1356
1357//
1358// SYMCRYPT_HMAC_SHA224_EXPANDED_KEY
1359//
1360// Data structure to store an expanded key for HMAC-SHA224.
1361//
1363{
1369
1370//
1371// SYMCRYPT_HMAC_SHA224_STATE
1372//
1373// Data structure that encodes an ongoing HMAC-SHA224 computation.
1374//
1376{
1382
1383
1384//
1385// SYMCRYPT_HMAC_SHA256_EXPANDED_KEY
1386//
1387// Data structure to store an expanded key for HMAC-SHA256.
1388//
1390{
1396
1397//
1398// SYMCRYPT_HMAC_SHA256_STATE
1399//
1400// Data structure that encodes an ongoing HMAC-SHA256 computation.
1401//
1403{
1409
1410
1411//
1412// SYMCRYPT_HMAC_SHA384_EXPANDED_KEY
1413//
1414// Data structure to store an expanded key for HMAC-SHA384.
1415//
1417{
1423
1424//
1425// SYMCRYPT_HMAC_SHA384_STATE
1426//
1427// Data structure that encodes an ongoing HMAC-SHA384 computation.
1428//
1430{
1436
1437//
1438// SYMCRYPT_HMAC_SHA512_EXPANDED_KEY
1439//
1440// Data structure to store an expanded key for HMAC-SHA512.
1441//
1443{
1449
1450//
1451// SYMCRYPT_HMAC_SHA512_STATE
1452//
1453// Data structure that encodes an ongoing HMAC-SHA512 computation.
1454//
1456{
1462
1463//
1464// SYMCRYPT_HMAC_SHA512_224_EXPANDED_KEY
1465//
1466// Data structure to store an expanded key for HMAC-SHA512_224.
1467//
1469{
1475
1476//
1477// SYMCRYPT_HMAC_SHA512_224_STATE
1478//
1479// Data structure that encodes an ongoing HMAC-SHA512_224 computation.
1480//
1482{
1488
1489//
1490// SYMCRYPT_HMAC_SHA512_256_EXPANDED_KEY
1491//
1492// Data structure to store an expanded key for HMAC-SHA512_256.
1493//
1495{
1501
1502//
1503// SYMCRYPT_HMAC_SHA512_256_STATE
1504//
1505// Data structure that encodes an ongoing HMAC-SHA512_256 computation.
1506//
1508{
1514
1515//
1516// SYMCRYPT_HMAC_EXPANDED_KEY
1517//
1518// Generic HMAC Expanded Key data structure
1519//
1521{
1522 PCSYMCRYPT_HASH pHash;
1528
1529//
1530// SYMCRYPT_HMAC_STATE
1531//
1532// Generic HMAC data structure
1533//
1535{
1541
1542//
1543// SYMCRYPT_HMAC_SHA3_224_EXPANDED_KEY
1544//
1545// Data structure to store an expanded key for HMAC-SHA3-224
1546//
1548{
1550
1553
1554//
1555// SYMCRYPT_HMAC_SHA3_224_STATE
1556//
1557// Data structure that encodes an ongoing HMAC-SHA3-224 computation.
1558//
1560{
1561 SYMCRYPT_HMAC_STATE generic;
1562
1565
1566//
1567// SYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY
1568//
1569// Data structure to store an expanded key for HMAC-SHA3-256
1570//
1572{
1574
1577
1578//
1579// SYMCRYPT_HMAC_SHA3_256_STATE
1580//
1581// Data structure that encodes an ongoing HMAC-SHA3-256 computation.
1582//
1584{
1585 SYMCRYPT_HMAC_STATE generic;
1586
1589
1590//
1591// SYMCRYPT_HMAC_SHA3_384_EXPANDED_KEY
1592//
1593// Data structure to store an expanded key for HMAC-SHA3-384
1594//
1596{
1598
1601
1602//
1603// SYMCRYPT_HMAC_SHA3_384_STATE
1604//
1605// Data structure that encodes an ongoing HMAC-SHA3-384 computation.
1606//
1608{
1609 SYMCRYPT_HMAC_STATE generic;
1610
1613
1614//
1615// SYMCRYPT_HMAC_SHA3_512_EXPANDED_KEY
1616//
1617// Data structure to store an expanded key for HMAC-SHA3-512
1618//
1620{
1622
1625
1626//
1627// SYMCRYPT_HMAC_SHA3_512_STATE
1628//
1629// Data structure that encodes an ongoing HMAC-SHA3-512 computation.
1630//
1632{
1633 SYMCRYPT_HMAC_STATE generic;
1634
1637
1638//
1639// SYMCRYPT_AES_EXPANDED_KEY
1640//
1641// Expanded key for AES operations.
1642//
1644 SYMCRYPT_ALIGN BYTE RoundKey[29][4][4];
1645 // Round keys, first the encryption round keys in encryption order,
1646 // followed by the decryption round keys in decryption order.
1647 // The first decryption round key is the last encryption round key.
1648 // AES-256 has 14 rounds and thus 15 round keys for encryption and 15
1649 // for decryption. As they share one round key, we need room for 29.
1650 BYTE (*lastEncRoundKey)[4][4]; // Pointer to last encryption round key
1651 // also the first round key for decryption
1652 BYTE (*lastDecRoundKey)[4][4]; // Pointer to last decryption round key.
1653
1657
1658//
1659// AES-CMAC
1660//
1661// Note: SYMCRYPT_AES_BLOCK_SIZE is not yet defined, so we use
1662// literal constants instead.
1663//
1665{
1672
1674{
1675 BYTE chain[16];
1679
1683
1684//
1685// POLY1305
1686//
1687
1689{
1690 UINT32 r[4]; // R := \sum 2^{32*i} r[i]. R is already clamped.
1691 UINT32 s[4]; // S := \sum 2^{32*i} s[i]
1692 UINT32 a[5]; // Accumulator := sum 2^{32*i} a[i], a[4] <= approx 8
1694 BYTE buf[16]; // Partial block buffer
1695
1698
1699//
1700// XTS-AES
1701//
1702
1704{
1709
1710
1711//-----------------------------------------------------------------
1712// Mac description table
1713// Below are the typedefs for the Mac description table type
1714// Callers can use this to define Mac algorithm they want to use
1715//
1716
1717#define SYMCRYPT_MAC_MAX_RESULT_SIZE SYMCRYPT_HMAC_SHA512_RESULT_SIZE
1718
1720{
1738
1740{
1758
1765
1766typedef struct _SYMCRYPT_MAC
1767{
1775 const PCSYMCRYPT_HASH * ppHashAlgorithm; // NULL for MACs not based on hashes
1776 UINT32 outerChainingStateOffset; // Offset into expanded key of outer chaining state; 0 for non-HMAC algorithms
1779
1780
1781
1782//
1783// 3DES
1784//
1786 UINT32 roundKey[3][16][2]; // 3 keys, 16 rounds, 2 UINT32s/round
1790
1791//
1792// DES
1793//
1798
1799//
1800// DESX
1801//
1808
1809//
1810// RC2
1811//
1813 UINT16 K[64];
1817
1818
1819//
1820// CCM states for incremental computations
1821//
1822#define SYMCRYPT_CCM_BLOCK_SIZE (16)
1823
1827 UINT64 cbData; // exact length of data
1830 SIZE_T cbCounter; // # bytes in counter field
1831 UINT64 bytesProcessed; // data bytes processed so far
1834 SYMCRYPT_ALIGN BYTE macBlock[SYMCRYPT_CCM_BLOCK_SIZE]; // Current state of the CBC-MAC part of CCM
1835 SYMCRYPT_ALIGN BYTE keystreamBlock[SYMCRYPT_CCM_BLOCK_SIZE]; // Remaining key stream if partial block has been processed
1838
1839
1840//
1841// GHash & GCM
1842//
1843
1845{
1848
1849#define SYMCRYPT_GCM_BLOCKCIPHER_KEY_SIZE sizeof( union _SYMCRYPT_GCM_SUPPORTED_BLOCKCIPHER_KEYS )
1850
1851#define SYMCRYPT_GF128_FIELD_SIZE (128)
1852#define SYMCRYPT_GF128_BLOCK_SIZE (16) // # bytes in a field element/block
1853#define SYMCRYPT_GCM_BLOCK_SIZE (16)
1854#define SYMCRYPT_GCM_MAX_KEY_SIZE (32)
1855
1856
1857#define SYMCRYPT_GCM_MAX_DATA_SIZE (((UINT64)1 << 36) - 32)
1858
1859#define SYMCRYPT_GCM_BLOCK_MOD_MASK (SYMCRYPT_GCM_BLOCK_SIZE - 1)
1860#define SYMCRYPT_GCM_BLOCK_ROUND_MASK (~SYMCRYPT_GCM_BLOCK_MOD_MASK)
1861
1862#if SYMCRYPT_CPU_X86
1863 //
1864 // x86 needs extra alignment of the GHASH expanded key to support
1865 // aligned (fast) XMM access. AMD64 has enough natural alignment to
1866 // achieve this.
1867 //
1868 #define SYMCRYPT_GHASH_EXTRA_KEY_ALIGNMENT
1869#endif
1870
1871#define SYMCRYPT_GHASH_ALLOW_XMM (SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64)
1872#define SYMCRYPT_GHASH_ALLOW_NEON (SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM64)
1873
1874
1875#if SYMCRYPT_CPU_ARM
1876#include <arm_neon.h>
1877#if SYMCRYPT_GNUC || defined(__clang__)
1878 #define __n128 uint32x4_t
1879 #define __n64 uint64x1_t
1880#endif
1881
1882#elif SYMCRYPT_CPU_ARM64
1883
1884 #if SYMCRYPT_MS_VC && !defined(__clang__)
1885 #include <arm64_neon.h>
1886
1887 // See section 6.7.8 of the C standard for details on this initializer usage.
1888 #define SYMCRYPT_SET_N128_U64(d0, d1) \
1889 ((__n128) {.n128_u64 = {d0, d1}})
1890 #define SYMCRYPT_SET_N64_U64(d0) \
1891 ((__n64) {.n64_u64 = {d0}})
1892 #define SYMCRYPT_SET_N128_U8(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15) \
1893 ((__n128) {.n128_u8 = {b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15}})
1894 #else
1895 #include <arm_neon.h>
1896
1897 #define __n128 uint8x16_t
1898 #define __n64 uint8x8_t
1899
1900 #define SYMCRYPT_SET_N128_U64(d0, d1) \
1901 ((__n128) ((uint64x2_t) {d0, d1}))
1902 #define SYMCRYPT_SET_N64_U64(d0) \
1903 ((__n64) ((uint64x1_t) {d0}))
1904 #define SYMCRYPT_SET_N128_U8(b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15) \
1905 ((__n128) ((uint8x16_t) {b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15}))
1906
1907 #define vmullq_p64( a, b ) ((__n128) vmull_p64(vgetq_lane_p64((poly64x2_t)a, 0), vgetq_lane_p64((poly64x2_t)b, 0)))
1908 #define vmull_p64( a, b ) ((__n128) vmull_p64( (poly64_t)a, (poly64_t)b ))
1909 #define vmull_high_p64( a, b ) ((__n128) vmull_high_p64( (poly64x2_t)a, (poly64x2_t)b ))
1910 #endif
1911
1912#endif
1913
1914//
1915// All platforms use the same in-memory representation:
1916// elements of GF(2^128) stored as two 64-bit integers which are best
1917// interpreted as a single 128-bit integer, least significant half first.
1918// Note: the actual GF(2^128) bit order is reversed in the standard
1919// for some reason; the
1920// polynomial \sum b_i x^i is represented by integer \sum b_i 2^{127-i})
1921// On x86/amd64 the same in-memory byte structure is also accessed as an
1922// __m128i, which works as both the UINT64s, UINT32s, and the __m128i use
1923// LSBfirst convention.
1924//
1926 UINT64 ull[2];
1927#if SYMCRYPT_GHASH_ALLOW_XMM
1928 //
1929 // The XMM code accesses this both as UINT32[] and __m128i
1930 // This is safe as XMM code only runs on little endian machines so the
1931 // ordering is known.
1932 //
1933 __m128i m128i;
1934 UINT32 ul[4];
1935#endif
1936#if SYMCRYPT_GHASH_ALLOW_NEON
1937 __n128 n128;
1938 UINT32 ul[4];
1939#endif
1942
1943
1944
1946#if defined( SYMCRYPT_GHASH_EXTRA_KEY_ALIGNMENT )
1947 UINT32 tableOffset;
1948 BYTE tableSpace[ (SYMCRYPT_GF128_FIELD_SIZE + 1) * sizeof( SYMCRYPT_GF128_ELEMENT ) ];
1949#else
1951#endif
1954
1955
1960 SIZE_T cbKey;
1965
1966
1969 UINT64 cbData; // Number of data bytes
1970 UINT64 cbAuthData; // Number of AAD bytes
1979
1980
1981//
1982// Block ciphers
1983//
1984#define SYMCRYPT_MAX_BLOCK_SIZE (32) // max block length of a block cipher.
1985
1986typedef SYMCRYPT_ERROR( SYMCRYPT_CALL * PSYMCRYPT_BLOCKCIPHER_EXPAND_KEY )
1988typedef VOID( SYMCRYPT_CALL * PSYMCRYPT_BLOCKCIPHER_CRYPT ) (PCVOID pExpandedKey, PCBYTE pbSrc, PBYTE pbDst);
1989typedef VOID( SYMCRYPT_CALL * PSYMCRYPT_BLOCKCIPHER_CRYPT_ECB ) (PCVOID pExpandedKey, PCBYTE pbSrc, PBYTE pbDst, SIZE_T cbData);
1990typedef VOID( SYMCRYPT_CALL * PSYMCRYPT_BLOCKCIPHER_CRYPT_MODE ) (PCVOID pExpandedKey, PBYTE pbChainingValue, PCBYTE pbSrc, PBYTE pbDst, SIZE_T cbData);
1991typedef VOID( SYMCRYPT_CALL * PSYMCRYPT_BLOCKCIPHER_MAC_MODE ) (PCVOID pExpandedKey, PBYTE pbChainingValue, PCBYTE pbSrc, SIZE_T cbData);
1992typedef VOID( SYMCRYPT_CALL * PSYMCRYPT_BLOCKCIPHER_AEADPART_MODE ) (PVOID pState, PCBYTE pbSrc, PBYTE pbDst, SIZE_T cbData);
1993
1995 PSYMCRYPT_BLOCKCIPHER_EXPAND_KEY expandKeyFunc; // mandatory
1996 PSYMCRYPT_BLOCKCIPHER_CRYPT encryptFunc; // mandatory
1997 PSYMCRYPT_BLOCKCIPHER_CRYPT decryptFunc; // mandatory
1998 PSYMCRYPT_BLOCKCIPHER_CRYPT_ECB ecbEncryptFunc; // NULL if no optimized version available
1999 PSYMCRYPT_BLOCKCIPHER_CRYPT_ECB ecbDecryptFunc; // NULL if no optimized version available
2000 PSYMCRYPT_BLOCKCIPHER_CRYPT_MODE cbcEncryptFunc; // NULL if no optimized version available
2001 PSYMCRYPT_BLOCKCIPHER_CRYPT_MODE cbcDecryptFunc; // NULL if no optimized version available
2002 PSYMCRYPT_BLOCKCIPHER_MAC_MODE cbcMacFunc; // NULL if no optimized version available
2003 PSYMCRYPT_BLOCKCIPHER_CRYPT_MODE ctrMsb64Func; // NULL if no optimized version available
2004 PSYMCRYPT_BLOCKCIPHER_AEADPART_MODE gcmEncryptPartFunc; // NULL if no optimized version available
2005 PSYMCRYPT_BLOCKCIPHER_AEADPART_MODE gcmDecryptPartFunc; // NULL if no optimized version available
2006 _Field_range_( 1, SYMCRYPT_MAX_BLOCK_SIZE ) SIZE_T blockSize; // = SYMCRYPT_XXX_BLOCK_SIZE, power of 2, 1 <= value <= 32.
2007 SIZE_T expandedKeySize; // = sizeof( SYMCRYPT_XXX_EXPANDED_KEY )
2008};
2009
2010
2011
2012//
2013// Session structs
2014//
2015
2016#define SYMCRYPT_FLAG_SESSION_ENCRYPT (0x1)
2017
2018//
2019// SYMCRYPT_SESSION tracks the Nonces being used in a session. It is used differently depending on
2020// whether the session is an Encryption session or a Decryption session.
2021//
2022// In Encryption sessions, SYMCRYPT_SESSION tracks the Nonce which was used in the most recent
2023// attempted encryption in the session.
2024// messageNumber is atomically incremented by each encryption call, and the encryption method uses
2025// the messageNumber value that is the _result_ of the increment.
2026//
2027// In Decryption sessions, SYMCRYPT_SESSION tracks the most recently received Nonces in a series of
2028// successful decryptions. Nonces used in unsuccessful decryption calls do not update SYMCRYPT_SESSION.
2029// Information is tracked such that the decryption function can detect repeated Nonce values and
2030// fail decryption in this case. In order for this to work the message numbers that are provided
2031// to decrypt calls must be somewhat ordered. Provided message numbers may be arbitrarily far ahead
2032// of previously successfully decrypted message numbers, but may only be up to 63 behind the highest
2033// message number successfully decrypted so far.
2034// messageNumber normally represents the highest message number used in a successful decryption in
2035// this session. (The exception is at initialization, where messageNumber is initialized to 64
2036// without the corresponding 0th bit in the replayMask being set - this initial state represents
2037// there have been no successful decryptions yet, and that the earliest messageNumber that can be
2038// successfully received is 1)
2039// replayMask represents whether a window of 64 message numbers up to messageNumber have already been
2040// successfully used;
2041// bit n of replayMask (from n=0 to n=63) represents message number = (messageNumber-n), 0 means not
2042// yet used, and 1 means already used in a successful decryption call
2043//
2044
2045#if SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM64
2046#define SYMCRYPT_USE_CAS128 (1)
2047
2048// For CompareAndSwap128 method, SYMCRYPT_SESSION must be aligned to 16B
2049#define SYMCRYPT_ALIGN_SESSION SYMCRYPT_ALIGN_TYPE_AT(struct, 16)
2050#else
2051#define SYMCRYPT_USE_CAS128 (0)
2052
2053// For method with only 64-bit atomics, SYMCRYPT_SESSION must be aligned to 8B
2054#define SYMCRYPT_ALIGN_SESSION SYMCRYPT_ALIGN_TYPE_AT(struct, 8)
2055#endif
2056
2057// Nested struct used within SYMCRYPT_SESSION
2059 UINT64 replayMask;
2060 // 64 bit mask representing message numbers previously successfully decrypted up to 63
2061 // before the most recent message number.
2062
2064 // the last 8 bytes of the Nonce (MSB-first)
2067
2070 // nested replayState struct is to improve code clarity in SymCryptSessionDecryptUpdate*
2071
2073 // the first 4 bytes of the Nonce (MSB-first)
2074 // (set by the caller and constant for the lifetime of a session)
2075
2077 // SYMCRYPT_FLAG_SESSION_ENCRYPT indicates the struct is to be used for an encryption session,
2078 // otherwise the struct is to be used for a decryption session
2079
2081 // Pointer to a fast single-process mutex object used to enable atomic update of replayMask and
2082 // messageNumber in the absence of support for a 128b CAS operation
2084
2085#define SYMCRYPT_SESSION_MAX_MESSAGE_NUMBER (0xffffffff00000000ull)
2086// We do not allow messageNumber to go above some maximum value (currently 2^64 - 2^32)
2087// This gives us a large window to prevent many concurrent encryption threads from updating the
2088// session such that the messageNumber overflows and the same IV is used in many encryptions
2089// (i.e. we would only potentially get a spurious success using a repeated IV when there are
2090// >2^32 concurrent threads!)
2091
2092#if SYMCRYPT_USE_CAS128
2093C_ASSERT(SYMCRYPT_FIELD_OFFSET(SYMCRYPT_SESSION, replayState.replayMask) == 0);
2094C_ASSERT(SYMCRYPT_FIELD_OFFSET(SYMCRYPT_SESSION, replayState.messageNumber) == 8);
2095// For CompareAndSwap128 method, replayMask and messageNumber must be tightly packed
2096#endif
2097
2098//
2099// RC4
2100//
2101
2102//
2103// Some CPUs like the S array type to be larger than BYTE. We abstract the data type
2104// of the S array to accommodate such CPUs in future.
2105//
2106
2108
2115
2116//
2117// ChaCha20
2118//
2119
2121 UINT32 key[8];
2123 UINT64 offset; // offset to use for next operation
2124 BOOLEAN keystreamBufferValid; // keystream buffer matches offset value
2127
2128
2129//
2130// AES_CTR_DRBG
2131//
2132
2134 //
2135 // Key and V value are in one array, to allow fast generation of both of them
2136 // in a single call.
2137 //
2138 BYTE keyAndV[32 + 16];
2140 UINT64 requestCounter; // called reseed_counter in SP 800-90
2141 BOOLEAN fips140_2Check; // set if the FIPS 140-2 continuous self-test is required
2144
2148
2149
2150//
2151// MARVIN32
2152//
2153
2155{
2156 UINT32 s[2];
2160
2161
2163
2165{
2166 SYMCRYPT_ALIGN BYTE buffer[8]; // 4 bytes of data, 4 more bytes for final padding
2167 SYMCRYPT_MARVIN32_CHAINING_STATE chain; // chaining state
2169 UINT32 dataLength; // length of the data processed so far, mod 2^32
2173
2174
2175//
2176// Export blob sizes
2177//
2178
2179#define SYMCRYPT_MD2_STATE_EXPORT_SIZE (80)
2180#define SYMCRYPT_MD4_STATE_EXPORT_SIZE (116)
2181#define SYMCRYPT_MD5_STATE_EXPORT_SIZE (116)
2182#define SYMCRYPT_SHA1_STATE_EXPORT_SIZE (120)
2183#define SYMCRYPT_SHA224_STATE_EXPORT_SIZE (132)
2184#define SYMCRYPT_SHA256_STATE_EXPORT_SIZE (132)
2185#define SYMCRYPT_SHA384_STATE_EXPORT_SIZE (236)
2186#define SYMCRYPT_SHA512_STATE_EXPORT_SIZE (236)
2187#define SYMCRYPT_SHA512_224_STATE_EXPORT_SIZE (236)
2188#define SYMCRYPT_SHA512_256_STATE_EXPORT_SIZE (236)
2189
2190#define SYMCRYPT_KECCAK_STATE_EXPORT_SIZE (234)
2191#define SYMCRYPT_SHA3_224_STATE_EXPORT_SIZE SYMCRYPT_KECCAK_STATE_EXPORT_SIZE
2192#define SYMCRYPT_SHA3_256_STATE_EXPORT_SIZE SYMCRYPT_KECCAK_STATE_EXPORT_SIZE
2193#define SYMCRYPT_SHA3_384_STATE_EXPORT_SIZE SYMCRYPT_KECCAK_STATE_EXPORT_SIZE
2194#define SYMCRYPT_SHA3_512_STATE_EXPORT_SIZE SYMCRYPT_KECCAK_STATE_EXPORT_SIZE
2195
2196
2197//
2198// KDF algorithms
2199//
2200
2201//
2202// PBKDF2
2203//
2204
2210
2211//
2212// SP 800-108
2213//
2214
2220
2221//
2222// TLS PRF 1.1
2223//
2224
2230
2231//
2232// TLS PRF 1.2
2233//
2234
2240
2241//
2242// SSH-KDF
2243//
2249
2250//
2251// SRTP-KDF
2252//
2257
2258//
2259// HKDF
2260//
2261
2267
2268//
2269// SSKDF
2270//
2276
2277//
2278// Digit & alignment sizes.
2279//
2280// WARNING: do not change these without updating all the optimized code,
2281// including assembler code.
2282// The FDEF_DIGIT_SIZE is the digit size used by the FDEF format.
2283//
2284#if SYMCRYPT_CPU_AMD64
2285
2286#define SYMCRYPT_FDEF_DIGIT_SIZE 64
2287#define SYMCRYPT_ASYM_ALIGN_VALUE 32
2288
2289#elif SYMCRYPT_CPU_ARM64
2290
2291#define SYMCRYPT_FDEF_DIGIT_SIZE 32
2292#define SYMCRYPT_ASYM_ALIGN_VALUE 32
2293
2294#else
2295
2296#define SYMCRYPT_FDEF_DIGIT_SIZE 16
2297#define SYMCRYPT_ASYM_ALIGN_VALUE 16 // We have some bugs when ASYM_ALIGN_VALUE > DIGIT_SIZE; need to fix them if we implement AVX2-based x86 code.
2298
2299#endif
2300
2301#define SYMCRYPT_ASYM_ALIGN_UP( _p ) ((PBYTE) ( ((SIZE_T) (_p) + SYMCRYPT_ASYM_ALIGN_VALUE - 1) & ~(SYMCRYPT_ASYM_ALIGN_VALUE - 1 ) ) )
2302
2303
2304//==============================================================================================
2305// Object types for low-level API
2306//
2307// INT integer in range 0..N for some N
2308// DIVISOR an integer > 0 that can be used to divide with.
2309// MODULUS a value M > 1 to use in modulo-M computations
2310// MODELEMENT An element in a modulo-M ring.
2311// ECPOINT A point on an elliptic curve.
2312//
2313// These objects are all aligned to SYMCRYPT_ASYM_ALIGN
2314//
2315#define SYMCRYPT_ASYM_ALIGN SYMCRYPT_ALIGN_AT(SYMCRYPT_ASYM_ALIGN_VALUE)
2316#if SYMCRYPT_MS_VC
2317#define SYMCRYPT_ASYM_ALIGN_STRUCT SYMCRYPT_ASYM_ALIGN struct
2318#elif SYMCRYPT_GNUC
2319#define SYMCRYPT_ASYM_ALIGN_STRUCT struct SYMCRYPT_ASYM_ALIGN
2320#else
2321#error Unknown compiler
2322#endif
2323
2324SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_INT;
2328
2329SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_DIVISOR;
2333
2334SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_MODULUS;
2338
2339SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_MODELEMENT;
2343
2344SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_ECPOINT;
2348
2349
2350//
2351// Arithmetic formats
2352//
2353
2354#define SYMCRYPT_ANYSIZE 1 // used to mark arrays of arbitrary size
2355
2356#define SYMCRYPT_FDEF_DIGIT_BITS (8*SYMCRYPT_FDEF_DIGIT_SIZE)
2357#define SYMCRYPT_FDEF_DIGITS_FROM_BITS( _bits ) ( \
2358 ((_bits)/ SYMCRYPT_FDEF_DIGIT_BITS) + \
2359 (( ((_bits) & (SYMCRYPT_FDEF_DIGIT_BITS-1)) + (SYMCRYPT_FDEF_DIGIT_BITS - 1) )/SYMCRYPT_FDEF_DIGIT_BITS) \
2360 )
2361
2362#define SYMCRYPT_BYTES_FROM_BITS(bits) ( ( (bits) + 7 ) / 8 )
2363
2364// The maximum number of bits in any integer value that the library supports. If the
2365// caller's input exceed this bound then the integer object will not be created.
2366// The caller either must ensure the bound is not exceeded, or check for NULL before
2367// using created SymCrypt objects.
2368// The primary purpose of this limit is to avoid integer overflows in size computations.
2369// Having a reasonable upper bound avoids all size overflows, even on 32-bit CPUs
2370#define SYMCRYPT_INT_MAX_BITS ((UINT32)(1 << 20))
2371
2372//
2373// Upper bound for the number of digits: this MUST be enforced on runtime
2374// on all Allocate, SizeOf, and Create calls which take as input a digit number.
2375//
2376// Using this upper bound and the SYMCRYPT_INT_MAX_BITS upper bound we can argue
2377// that no integer overflow on 32-bit sizes can happen. Note that the computed upper
2378// bounds are very loose and the actual values are much smaller.
2379//
2380#define SYMCRYPT_FDEF_UPB_DIGITS (SYMCRYPT_FDEF_DIGITS_FROM_BITS(SYMCRYPT_INT_MAX_BITS))
2381
2382
2383
2384
2385//
2386// All of the following SYMCRYPT_FDEF_SIZEOF_XXX_FROM_YYY computations for the four
2387// main SymCrypt objects (INT, DIVISOR, MODULUS, MODELEMENT) return a value not
2388// larger than 2^19 if the inputs _nDigits and _bits are not larger than
2389// SYMCRYPT_FDEF_UPB_DIGITS and SYMCRYPT_INT_MAX_BITS respectively (For MODELEMENT this bound
2390// is 2^17). The latter bounds must be enforced on runtime for all calculations taking as inputs
2391// number of digits or bits.
2392//
2393// The 2^19 upper bound is derived from:
2394// - the maximum (byte) size of an "integer": 2^20 bits / 8 = 2^17 bytes
2395// - "sizeof" computations add up to less than 2^18 bytes ~ 262 Kb
2396// - the modulus object contains two "integers"
2397//
2398
2399//
2400// Type fields contain the following:
2401// lower 16 bits: offset into virtual table (if any)
2402// upper 16 bits: bits 16-23: 1-character object type. Bits 24-31: 1 char implementation type
2403// The upper bits allow objects to be recognized in memory, making debugging easier.
2404//
2405
2406SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_INT {
2407 UINT32 type;
2408 _Field_range_( 1, SYMCRYPT_FDEF_UPB_DIGITS ) UINT32 nDigits; // digit size depends on run-time decisions...
2410
2412 SYMCRYPT_ASYM_ALIGN union {
2413 struct {
2414 UINT32 uint32[SYMCRYPT_ANYSIZE]; // FDEF: array UINT32[nDigits * # uint32 per digit]
2416 } ti; // we must have a name here. 'ti' stands for 'Type-Int', it helps catch type errors when type-casting macros are used.
2417};
2418
2419#define SYMCRYPT_FDEF_INT_PUINT32( p ) (&(p)->ti.fdef.uint32[0])
2420
2421
2422#define SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( _nDigits ) ((_nDigits) * SYMCRYPT_FDEF_DIGIT_SIZE + sizeof( SYMCRYPT_INT ) )
2423#define SYMCRYPT_FDEF_SIZEOF_INT_FROM_BITS( _bits ) SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( SYMCRYPT_FDEF_DIGITS_FROM_BITS( _bits ))
2424
2425SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_DIVISOR {
2426 UINT32 type;
2427 _Field_range_( 1, SYMCRYPT_FDEF_UPB_DIGITS ) UINT32 nDigits; // digit size depends on run-time decisions...
2428 UINT32 cbSize;
2429
2430 UINT32 nBits; // # bits in divisor
2431
2433 union{
2434 struct {
2435 UINT64 W; // approximate inverse of the divisor. Some implementations will use 64 bits, others 32 bits.
2436 } fdef;
2438 SYMCRYPT_INT Int; // Having a full Int here uses more space, but allows any Divisor to still be used as an Int.
2439 // This structure is directly followed by the Int extension
2440};
2441
2442#define SYMCRYPT_FDEF_SIZEOF_DIVISOR_FROM_DIGITS( _nDigits ) ((_nDigits) * SYMCRYPT_FDEF_DIGIT_SIZE + sizeof( SYMCRYPT_DIVISOR ) )
2443#define SYMCRYPT_FDEF_SIZEOF_DIVISOR_FROM_BITS( _bits ) SYMCRYPT_FDEF_SIZEOF_DIVISOR_FROM_DIGITS( SYMCRYPT_FDEF_DIGITS_FROM_BITS( _bits ))
2444
2445SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_MODULUS {
2446 UINT32 type;
2447 _Field_range_( 1, SYMCRYPT_FDEF_UPB_DIGITS ) UINT32 nDigits; // digit size depends on run-time decisions...
2448 UINT32 cbSize; // Size of modulus object
2449
2450 UINT32 flags; // The flags the modulus was created with
2451 UINT32 cbModElement; // Size of one modElement
2452 UINT64 inv64; // -1/modulus mod 2^64 (always set but only to a useful value when the modulus is odd)
2453
2455 union{
2456 struct {
2457 //UINT32 nUint32Used; // # 32-bit words used in representing numbers. modulus < 2^{32*nUint32Used}.
2458 // only values used are nDigits * uint32-per-digit or specific smaller values for optimized implementations
2459 PCUINT32 Rsqr; // R^2 mod modulus, in uint32 form, nUint32Used words. Stored after Divisor. R = 2^{32*nUint32Used}
2461 struct {
2462 UINT32 k; // modulus = 2^<bitsize of modelement> - k
2464 } tm; // type specific data. Every Modulus can be used as a generic modulus, so no type-specific data for generic.
2465
2467 // This structure is directly followed by:
2468 // The extensions of the Divisor object
2469 // and after that:
2470 // FDEF: Rsqr as an array of UINT32, size = nDigits * digitsize
2471 // FDEF: negDivisor as an array of UINT32, size = nDigits * digitsize
2472};
2473
2474#define SYMCRYPT_FDEF_SIZEOF_MODULUS_FROM_DIGITS( _nDigits ) (sizeof( SYMCRYPT_MODULUS ) + SYMCRYPT_FDEF_SIZEOF_DIVISOR_FROM_DIGITS( _nDigits ) + (2 * _nDigits * SYMCRYPT_FDEF_DIGIT_SIZE) )
2475#define SYMCRYPT_FDEF_SIZEOF_MODULUS_FROM_BITS( _bits ) SYMCRYPT_FDEF_SIZEOF_MODULUS_FROM_DIGITS(SYMCRYPT_FDEF_DIGITS_FROM_BITS( _bits ))
2476
2477SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_MODELEMENT {
2478 // ModElements just store the information without any header. This union makes this well-defined, and allows easy access.
2479 union{
2481 } d;
2482};
2483
2484#define SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_DIGITS( _nDigits ) ((_nDigits) * SYMCRYPT_FDEF_DIGIT_SIZE)
2485#define SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_BITS( _bits ) SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_DIGITS( SYMCRYPT_FDEF_DIGITS_FROM_BITS( _bits ) )
2486
2487//
2488// Upper bound for scratch size computations for FDEF objects depending only on digits
2489//
2490// The following 14 scratch size computation macros are all of the form:
2491// Some SIZEOF macros + max( some other scratch macros )
2492// and all depend on some number of digits. (Slight exceptions are
2493// INT_TO_MODULUS and INT_PRIME_GEN but they can fit into the below
2494// rationale.)
2495//
2496// One can see that the deepest recursion in these macros and the biggest
2497// return value is for
2498// INT_PRIME_GEN -> INT_MILLER_RABIN -> MODEXP ->
2499// COMMON_MOD_OPERATIONS -> SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_DIVMOD
2500//
2501// Using the 2^19 (2^17) bound on the sizeof computations the biggest contribution on the above chain is for MODEXP:
2502// ((1 << SYMCRYPT_FDEF_MAX_WINDOW_MODEXP) + 2) * SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_DIGITS( _nModDigits )
2503// which is bounded above by
2504// (2^6 + 2) * 2^17 < 2^24
2505//
2506// By doubling on each subsequent recursive call we get the conservative
2507// upper bound for all scratch size computation macros of 2^26.
2508//
2509
2510#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_TO_DIVISOR( _nDigits ) (16 * (_nDigits)) // unused currently, but this catches errors
2511
2512#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_MUL( _nDigits ) (16 * (_nDigits)) // unused currently, but nonzero size catches errors
2513
2514#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_DIVMOD( _nSrcDigits, _nDivisorDigits ) ( (_nSrcDigits + 1) * SYMCRYPT_FDEF_DIGIT_SIZE )
2515
2516#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_EXTENDED_GCD( _nDigits ) ( \
2517 4 * SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( _nDigits ) + \
2518 SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( 2 * _nDigits ) + \
2519 2 * SYMCRYPT_FDEF_SIZEOF_DIVISOR_FROM_DIGITS( _nDigits ) + \
2520 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_DIVMOD( 2 * _nDigits, _nDigits ), \
2521 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_MUL( 2 * _nDigits ), \
2522 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_TO_DIVISOR( _nDigits ) )) )
2523
2524#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_COMMON_MOD_OPERATIONS( _nModDigits ) \
2525 ( (2*(_nModDigits) * SYMCRYPT_FDEF_DIGIT_SIZE) + \
2526 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_DIVMOD( 2*(_nModDigits), _nModDigits )) // for mult: tmp product + divmod scratch
2527
2528#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_CRT_GENERATION( _nDigits ) ( \
2529 2*SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( _nDigits ) + \
2530 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_EXTENDED_GCD( _nDigits ), \
2531 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_COMMON_MOD_OPERATIONS( _nDigits ) ))
2532
2533#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_CRT_SOLUTION( _nDigits ) ( \
2534 SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( _nDigits ) + \
2535 SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_DIGITS( _nDigits ) + \
2536 SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( 2*_nDigits ) + \
2537 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_COMMON_MOD_OPERATIONS( _nDigits ), \
2538 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_MUL( 2*_nDigits ) ))
2539
2540#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_TO_MODULUS( _nDigits ) ( \
2541 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_TO_DIVISOR( _nDigits ),\
2542 (2*_nDigits+1) * SYMCRYPT_FDEF_DIGIT_SIZE + SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_DIVMOD( 2*_nDigits + 1, nDigits )) )
2543
2544#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODINV( _nModDigits ) ( \
2545 4 * SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_DIGITS( _nModDigits ) + \
2546 3 * SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( _nModDigits ) + \
2547 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_COMMON_MOD_OPERATIONS( _nModDigits ) )
2548
2549#define SYMCRYPT_FDEF_MAX_WINDOW_MODEXP (6)
2550
2551#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODEXP( _nModDigits ) ( \
2552 ((1 << SYMCRYPT_FDEF_MAX_WINDOW_MODEXP) + 2) * SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_DIGITS( _nModDigits ) + \
2553 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_COMMON_MOD_OPERATIONS( _nModDigits ) )
2554
2555#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_IS_POTENTIAL_PRIME( _nDigits ) (0)
2556
2557#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_MILLER_RABIN( _nDigits ) ( \
2558 SYMCRYPT_FDEF_SIZEOF_MODULUS_FROM_DIGITS(_nDigits) + \
2559 3*SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_DIGITS(_nDigits) + \
2560 SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS(_nDigits) + \
2561 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_TO_MODULUS(_nDigits), \
2562 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_COMMON_MOD_OPERATIONS(_nDigits), \
2563 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODEXP( _nDigits ) )) )
2564
2565#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_IS_PRIME( _nDigits ) ( \
2566 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_IS_POTENTIAL_PRIME( _nDigits ), \
2567 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_MILLER_RABIN( _nDigits ) ))
2568
2569#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_PRIME_GEN( _nDigits ) ( \
2570 SYMCRYPT_RSAKEY_MAX_NUMOF_PUBEXPS * SYMCRYPT_FDEF_SIZEOF_DIVISOR_FROM_DIGITS( 1 ) + \
2571 SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( 1 ) + \
2572 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_TO_DIVISOR( 1 ), \
2573 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_DIVMOD( _nDigits, 1 ), \
2574 SYMCRYPT_MAX( SYMCRYPT_FDEF_SIZEOF_INT_FROM_DIGITS( _nDigits ), \
2575 SYMCRYPT_MAX( SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_IS_POTENTIAL_PRIME( _nDigits ), \
2576 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_MILLER_RABIN( _nDigits ) )))))
2577
2578//
2579// Upper bound for SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODMULTIEXP
2580//
2581// _nBase and _nBitsExp are bounded by SYMCRYPT_MODMULTIEXP_MAX_NBASES = 8 and
2582// SYMCRYPT_MODMULTIEXP_MAX_NBITSEXP = 2^20. Therefore the upper bound on this computation
2583// is
2584// 2^21 + 2^3*(2^6+4)*2^17 + 2^3*2^20*4 < 2^27
2585//
2586#define SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODMULTIEXP( _nModDigits, _nBases, _nBitsExp ) ( \
2587 SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_COMMON_MOD_OPERATIONS( _nModDigits ) + \
2588 ((_nBases)*(1<<SYMCRYPT_FDEF_MAX_WINDOW_MODEXP) + 4)*SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_DIGITS( _nModDigits ) + \
2589 (((_nBases)*(_nBitsExp)*sizeof(UINT32) + SYMCRYPT_ASYM_ALIGN_VALUE - 1) & ~(SYMCRYPT_ASYM_ALIGN_VALUE - 1)) )
2590// Note: We need +4 multiplied with SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_DIGITS so that SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODMULTIEXP
2591// is always at least 2 modelements bigger than SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODEXP (see modexp.c)
2592
2593//
2594// Support for masked operations
2595
2596#define SYMCRYPT_MASK32_SET ((UINT32)-1)
2597#define SYMCRYPT_MASK32_NONZERO( _v ) ((UINT32)(((UINT64)0 - (_v)) >> 32))
2598#define SYMCRYPT_MASK32_ZERO( _v ) (~SYMCRYPT_MASK32_NONZERO( _v ))
2599#define SYMCRYPT_MASK32_EQ( _a, _b ) (~SYMCRYPT_MASK32_NONZERO( (_a) ^ (_b) ))
2600#define SYMCRYPT_MASK32_LT( _a, _b ) ((UINT32)( ((UINT64)(_a) - (_b)) >> 32 ))
2601
2602
2603//
2604// Dispatch definitions
2605// When multiple formats are supported, this is where the information of the multiple formats is combined.
2606//
2607// See the comments in SYMCRYPT_FDEF_SCRATCH_XXX regarding 32 bit overflow protection. All results
2608// are bounded above by 2^27.
2609//
2610
2611#define SYMCRYPT_INTERNAL_SIZEOF_INT_FROM_BITS( _bitsize ) SYMCRYPT_FDEF_SIZEOF_INT_FROM_BITS( _bitsize )
2612#define SYMCRYPT_INTERNAL_SIZEOF_DIVISOR_FROM_BITS( _bitsize ) SYMCRYPT_FDEF_SIZEOF_DIVISOR_FROM_BITS( _bitsize )
2613#define SYMCRYPT_INTERNAL_SIZEOF_MODULUS_FROM_BITS( _bitsize ) SYMCRYPT_FDEF_SIZEOF_MODULUS_FROM_BITS( _bitsize )
2614#define SYMCRYPT_INTERNAL_SIZEOF_MODELEMENT_FROM_BITS( _bitsize ) SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_BITS( _bitsize )
2615
2616#define SYMCRYPT_INTERNAL_SIZEOF_RSAKEY_FROM_PARAMS( modBits, nPrimes, nPubExps ) SYMCRYPT_FDEF_SIZEOF_RSAKEY_FROM_PARAMS( modBits, nPrimes, nPubExps )
2617// For now we don't need the pubExpBits so we drop them, but we might use them later.
2618
2619#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_INT_TO_DIVISOR( _nDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_TO_DIVISOR( _nDigits )
2620#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_INT_MUL( _nDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_MUL( _nDigits )
2621#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_INT_DIVMOD( _nSrcDigits, _nDivisorDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_DIVMOD( _nSrcDigits, _nDivisorDigits )
2622#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_EXTENDED_GCD( _nDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_EXTENDED_GCD( _nDigits )
2623#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_COMMON_MOD_OPERATIONS( _nModDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_COMMON_MOD_OPERATIONS( _nModDigits )
2624#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_CRT_GENERATION( _nDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_CRT_GENERATION( _nDigits )
2625#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_CRT_SOLUTION( _nDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_CRT_SOLUTION( _nDigits )
2626#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_INT_TO_MODULUS( _nDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_TO_MODULUS( _nDigits )
2627#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_MODINV( _nModDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODINV( _nModDigits )
2628#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_MODEXP( _nModDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODEXP( _nModDigits )
2629#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_INT_IS_PRIME( _nDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_IS_PRIME( _nDigits )
2630#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_INT_PRIME_GEN( _nDigits ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_INT_PRIME_GEN( _nDigits )
2631
2632#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_MODMULTIEXP( _nModDigits, _nBases, _nBitsExp ) SYMCRYPT_FDEF_SCRATCH_BYTES_FOR_MODMULTIEXP( _nModDigits, _nBases, _nBitsExp )
2633
2634//
2635// Forward declarations for MlKemkey types
2636//
2637SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_MLKEMKEY;
2641
2642//
2643// Forward declarations for MlDsakey types
2644//
2645struct _SYMCRYPT_MLDSAKEY;
2646typedef struct _SYMCRYPT_MLDSAKEY SYMCRYPT_MLDSAKEY;
2649
2650//
2651// Forward declarations for CompositeMlKemkey types
2652//
2653SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_COMPOSITE_MLKEMKEY;
2657
2658//
2659// RSA padding scratch definitions
2660//
2661// The maximum sizes of the state and the result for all hash algorithms are
2662// sizeof(SYMCRYPT_HASH_STATE) and SYMCRYPT_HASH_MAX_RESULT_SIZE, both not bigger
2663// 2^20. All the nBytes inputs are bounded by 2^17 (the maximum byte-size
2664// of the RSA modulus).
2665//
2666// Thus a total upper bound on these results is 2^20.
2667//
2668#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_RSA_OAEP( _hashAlgorithm, _nBytesOAEP ) ( SymCryptHashStateSize( _hashAlgorithm ) + \
2669 SymCryptHashResultSize( _hashAlgorithm ) + \
2670 2*(_nBytesOAEP - 1) )
2671
2672#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_RSA_PKCS1( _nBytesPKCS1 ) ( _nBytesPKCS1 )
2673
2674#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_RSA_PSS( _hashAlgorithm, _nBytesMessage, _nBytesPSS ) ( SymCryptHashStateSize( _hashAlgorithm ) + \
2675 _nBytesMessage + \
2676 3*(_nBytesPSS) + 5 )
2677
2678//
2679// RSAKEY Type
2680//
2681
2682#define SYMCRYPT_FDEF_SIZEOF_RSAKEY_FROM_PARAMS( modBits, nPrimes, nPubExps ) \
2683 sizeof( SYMCRYPT_RSAKEY ) + \
2684 (nPrimes + 1) * SYMCRYPT_FDEF_SIZEOF_MODULUS_FROM_BITS( modBits ) + \
2685 nPrimes * SYMCRYPT_FDEF_SIZEOF_MODELEMENT_FROM_BITS( modBits ) + \
2686 (nPrimes + 1) * nPubExps * SYMCRYPT_FDEF_SIZEOF_INT_FROM_BITS( modBits )
2687// 1 modulus object per prime + 1 for the RSA modulus
2688// 1 modelement for every crtInverse
2689// 1 int per pubexp for each privexp + 1 int per prime*pubexp for each crtprivexp
2690
2691#define SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES (2)
2692#define SYMCRYPT_RSAKEY_MAX_NUMOF_PUBEXPS (1)
2693
2694#define SYMCRYPT_RSAKEY_MIN_BITSIZE_MODULUS (256) // Some of our SCS code requires at least 32 bytes...
2695#define SYMCRYPT_RSAKEY_MAX_BITSIZE_MODULUS (1 << 16) // Avoid any integer overflows in size calculations
2696
2697// RSA FIPS self-tests require at least 496 bits to avoid fatal
2698// Require caller to specify NO_FIPS for up to 1024 bits as running FIPS tests on too-small keys
2699// does not make it FIPS certifiable and gives the wrong impression to callers
2700#define SYMCRYPT_RSAKEY_FIPS_MIN_BITSIZE_MODULUS (1024)
2701
2702#define SYMCRYPT_RSAKEY_MIN_BITSIZE_PRIME (128)
2703#define SYMCRYPT_RSAKEY_MAX_BITSIZE_PRIME (SYMCRYPT_RSAKEY_MAX_BITSIZE_MODULUS / 2)
2704
2705// Minimum allowable bit sizes for generated and imported parameters for
2706// the RSA modulus and each prime.
2707
2708typedef SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_RSAKEY {
2709 UINT32 fAlgorithmInfo; // Tracks which algorithms the key can be used in
2710 // Also tracks which per-key selftests have been performed on this key
2711 // A bitwise OR of SYMCRYPT_FLAG_KEY_*, SYMCRYPT_FLAG_RSAKEY_*, and
2712 // SYMCRYPT_PCT_* values
2713
2714 UINT32 cbTotalSize; // Total size of the rsa key
2715 BOOLEAN hasPrivateKey; // Set to true if there is private key information set
2716
2717 UINT32 nSetBitsOfModulus; // Bits of modulus specified during creation
2718
2719 UINT32 nBitsOfModulus; // Number of bits of the value of the modulus (not the object's size)
2720 UINT32 nDigitsOfModulus; // Number of digits of the modulus object (always equal to SymCryptDigitsFromBits(nSetBitsOfModulus))
2721
2722 UINT32 nPubExp; // Number of public exponents
2723
2724 UINT32 nPrimes; // Number of primes, can be 0 if the object only supports public keys
2726 // Number of bits of the value of each prime (not the object's size)
2728 // Number of digits of each prime object
2729 UINT32 nMaxDigitsOfPrimes; // Maximum number of digits in nDigitsOfPrimes
2730
2732 // SYMCRYPT_ASYM_ALIGN'ed buffers that point to memory allocated for each object
2737
2738 // SymCryptObjects
2739 PSYMCRYPT_MODULUS pmModulus; // The modulus N=p*q
2741 // Pointers to the secret primes
2743 // Pointers to the CRT inverses of the primes
2745 // Pointers to the corresponding private exponents
2747 // Pointers to the private exponents modulo each prime minus 1 (for CRT)
2748
2750 // Followed by:
2751 // Modulus
2752 // Primes
2753 // CrtInverses
2754 // PrivExps
2755 // CrtPrivExps
2759
2760//
2761// The following definitions relating to trial division are not needed by normal callers
2762// but are used by the test program to measure performance of components.
2763//
2764
2766 UINT64 invMod2e64; // Inverse of prime modulo 2^64
2767 UINT64 compareLimit; // floor( (2^{64}-1)/ prime )
2770//
2771// This structure is used to test whether a UINT64 is a multiple of a (small) prime.
2772// Let V be the input value, P the small prime, and W the inverse of P modulo 2^64.
2773// If V = k*P then V * M mod 2^64 = V/P mod 2^64 = k.
2774// This holds for k = 0, 1, ..., floor( (2^{64}-1)/p ).
2775// If V is not a multiple of P then the result of the multiplication must be larger than that.
2776//
2777
2779 UINT32 nPrimes; // # primes are in this group (use the next ones)
2780 UINT32 factor[9]; // factors[i] = 2^{32*(i+1)} mod Prod where Prod = product of the primes
2781 // It is guaranteed that Prod <= (2^{32}-1)/9
2784
2785
2789 PSYMCRYPT_TRIALDIVISION_GROUP pGroupList; // terminated with 0 record
2790 PSYMCRYPT_TRIALDIVISION_PRIME pPrimeList; // terminated with 0 record
2791 PUINT32 pPrimes; // terminated with a 0.
2792 SYMCRYPT_TRIALDIVISION_PRIME Primes3_5_17[3]; // Structures for 3, 5 and 17 in that order
2795
2796UINT32
2797SymCryptTestTrialdivisionMaxSmallPrime( PCSYMCRYPT_TRIALDIVISION_CONTEXT pContext ); // Expose small prime limit to help test code
2798
2799//
2800// DLGROUP type
2801//
2802
2803#define SYMCRYPT_DLGROUP_MIN_BITSIZE_P (32)
2804#define SYMCRYPT_DLGROUP_MIN_BITSIZE_Q (31) // Q must always be at least 1 bit shorter than P
2805// Minimum allowable bit sizes for generated and imported parameters for both P and
2806// Q primes.
2807
2808typedef SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_DLGROUP {
2809 UINT32 cbTotalSize; // Total size of the dl group object
2810 BOOLEAN fHasPrimeQ; // Flag that specifies whether the object has a Q parameter
2811
2812 UINT32 nBitsOfP; // Number of bits of the value of P (not the object's size)
2813 UINT32 cbPrimeP; // Number of bytes of the value of P (not the object's size), equal to ceil(nBitsOfP/8)
2814 UINT32 nDigitsOfP; // Number of digits of the object of prime P
2815 UINT32 nMaxBitsOfP; // Maximum number of bits of the value of P
2816
2817 UINT32 nBitsOfQ; // Number of bits of the value of Q (not the object's bits)
2818 UINT32 cbPrimeQ; // Number of bytes of the value of Q (not the object's size), equal to ceil(nBitsOfQ/8)
2819 UINT32 nDigitsOfQ; // Number of digits of the object of prime Q
2820 UINT32 nMaxBitsOfQ; // Maximum number of bits of the value of Q
2821
2822 BOOLEAN isSafePrimeGroup; // Boolean indicating if this is a Safe Prime group
2823 UINT32 nMinBitsPriv; // Minimum number of bits to be used in private keys for this group
2824 // This only applies to named Safe Prime groups where this is related to the security strength
2825 // i.e. this corresponds to 2s in SP800-56arev3 5.6.1.1.1 / 5.6.2.1.2
2826 UINT32 nDefaultBitsPriv; // Default number of bits used in private keys for this group
2827 // Normally equals nBitsOfQ, but may be further restricted (i.e. for named Safe Prime groups)
2828 // i.e. this corresponds to a default value of N in SP800-56arev3 5.6.1.1.1 / 5.6.2.1.2
2829
2830 UINT32 nBitsOfSeed; // Number of bits of the seed used for generation (seedlen in FIPS 186-3)
2831 UINT32 cbSeed; // Number of bytes of the seed, equal to ceil(nBitsOfSeed/8)
2832
2833 SYMCRYPT_DLGROUP_FIPS eFipsStandard; // Code specifying the FIPS standard used to create the keys. If 0 the group is unverified.
2834
2835 PCSYMCRYPT_HASH pHashAlgorithm; // Hash algorithm used for the generation of parameters
2836 UINT32 dwGenCounter; // Number of iterations used for the generation of parameters
2837 BYTE bIndexGenG; // Index for the generation of generator G (FIPS 186-3) (Always 1 for now)
2838
2839 PBYTE pbQ; // SYMCRYPT_ASYM_ALIGN'ed buffer that points to the memory allocated for modulus Q
2840
2841 PSYMCRYPT_MODULUS pmP; // Pointer to the prime P
2842 PSYMCRYPT_MODULUS pmQ; // Pointer to the prime Q
2843
2844 PSYMCRYPT_MODELEMENT peG; // Pointer to the generator G
2845
2846 PBYTE pbSeed; // Buffer that will hold the seed (this is padded at the end so that the entire structure
2847 // has size a multiple of SYMCRYPT_ASYM_ALIGN_VALUE)
2848
2850
2851 // P
2852 // Q
2853 // G
2854 // Seed
2858
2859//
2860// DLKEY type
2861//
2862typedef SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_DLKEY {
2863 UINT32 fAlgorithmInfo; // Tracks which algorithms the key can be used in
2864 // Also tracks which per-key selftests have been performed on this key
2865 // A bitwise OR of SYMCRYPT_FLAG_KEY_*, SYMCRYPT_FLAG_DLKEY_*, and
2866 // SYMCRYPT_PCT_* values
2867
2868 BOOLEAN fHasPrivateKey; // Set to true if there is a private key set
2869 BOOLEAN fPrivateModQ; // Set to true if the private key is at most Q-1, otherwise it is at most P-2
2870 UINT32 nBitsPriv; // Number of bits used in private keys
2871
2872 PCSYMCRYPT_DLGROUP pDlgroup; // Handle to the group which created the key
2873
2874 PBYTE pbPrivate; // SYMCRYPT_ASYM_ALIGN'ed buffer that points to the memory allocated for the private key
2875
2876 PSYMCRYPT_MODELEMENT pePublicKey; // Public key (modelement modulo P)
2877 PSYMCRYPT_INT piPrivateKey; // Private key (integer up to 2^nBitsPriv-1, Q-1 or P-2)
2878
2880
2881 // PublicKey
2882 // PrivateKey // The size of this must always be the same as the size of P
2886
2887//
2888// Elliptic Curve Function Types
2889//
2890
2891#define SYMCRYPT_ECPOINT_FORMAT_MAX_LENGTH 4 // Number of MODELEMENTs for the largest ECPOINT format
2892
2893// Coordinate representations for ECPOINTs
2894// NOTE: The value masked with 0xf gives you the number of coordinates
2896 SYMCRYPT_ECPOINT_COORDINATES_INVALID = 0x00, // Invalid point representation
2897 SYMCRYPT_ECPOINT_COORDINATES_SINGLE = 0x11, // Representation with only X
2898 SYMCRYPT_ECPOINT_COORDINATES_AFFINE = 0x22, // Affine representation (X,Y)
2899 SYMCRYPT_ECPOINT_COORDINATES_PROJECTIVE = 0x33, // Three equally-sized values where the triple (X,Y,Z) represents the affine point (X/Z, Y/Z)
2900 SYMCRYPT_ECPOINT_COORDINATES_JACOBIAN = 0x43, // Three equally-sized values where the triple (X,Y,Z) represents the affine point (X/Z^2, Y/Z^3)
2901 SYMCRYPT_ECPOINT_COORDINATES_EXTENDED_PROJECTIVE = 0x54, // Four equally-sized values where (X,Y,Z,T) represents the affine point (X/Z, Y/Z) with T=X*Y*Z
2902 SYMCRYPT_ECPOINT_COORDINATES_SINGLE_PROJECTIVE = 0x62, // Two equally-sized values where (X,Z) represents the point (X/Z)
2904
2905#define SYMCRYPT_INTERNAL_NUMOF_COORDINATES( _eCoordinates ) ((_eCoordinates) & 0xf)
2906
2907
2908//
2909// Curve-type-dependent information
2910//
2911
2912// Short-Weierstrass
2913
2914#define SYMCRYPT_ECURVE_SW_DEF_WINDOW (6) // Default window size for the windowed methods
2915
2916#define SYMCRYPT_ECURVE_SW_MAX_NPRECOMP_POINTS (64) // Maximum number of precomputed points
2917
2919 UINT32 window; // Window size
2920 UINT32 nPrecompPoints; // Number of precomputed points
2921 UINT32 nRecodedDigits; // Number of recoded digits
2923 // Table of pointers to precomputed powers of the distinguished point
2925
2926//
2927// ECURVE object
2928//
2929
2930#define SYMCRYPT_ECURVE_MIN_BITSIZE_FMOD (32)
2931#define SYMCRYPT_ECURVE_MIN_BITSIZE_GORD (32)
2932#define SYMCRYPT_ECURVE_MAX_COFACTOR_POWER (8)
2933// Minimum (maximum for cofactor) allowable bit sizes for imported
2934// parameters for field modulus, group order of curve (and cofactor).
2935
2936#define SYMCRYPT_INTERNAL_ECURVE_VERSION_LATEST 1
2937
2942 SYMCRYPT_INTERNAL_ECURVE_TYPE_SHORT_WEIERSTRASS_AM3 = 4,// This type is a specialization of Short-Weierstrass when A == -3
2943 // This condition is detected and used for all NIST prime curves
2945
2949
2950typedef SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_ECURVE {
2951 UINT32 version; // Version #
2953 type; // Internal type of the curve
2955 eCoordinates; // Default representation of the EC points
2956
2957 UINT32 FModBitsize; // Bitsize of the field modulus
2958 UINT32 FModDigits; // Number of digits of the field modulus
2959 UINT32 FModBytesize; // Bytesize of the field modulus (specified in the curve parameters as cbFieldLength)
2960
2961 UINT32 GOrdBitsize; // Bitsize of the (sub)group order
2962 UINT32 GOrdDigits; // Number of digits of the (sub)group order
2963 UINT32 GOrdBytesize; // Bytesize of the (sub)group order (specified in the curve parameters as cbSubgroupOrder)
2964
2965 UINT32 cbModElement; // (Internal) bytesize of one mod element
2966
2967 UINT32 cbAlloc; // Bytesize of the total curve blob
2968
2969 UINT32 cbScratchCommon; // Size of scratch space for common ecurve operations
2970 UINT32 cbScratchScalar; // Size of constant scratch space for scalar ecurve operations (without the nPoints dependence)
2971 UINT32 cbScratchScalarMulti; // Dependence of scratch space for scalar ecurve operations from nPoints
2972 UINT32 cbScratchGetSetValue; // Size of scratch space for get set value ecpoint operations
2973 UINT32 cbScratchEckey; // Size of scratch space for eckey operations
2974
2975 UINT32 coFactorPower; // The cofactor of the curve will be equal to 2^coFactorPower
2976
2977 // Parameters V2 Extensions
2982
2983 union {
2984
2985 SYMCRYPT_ECURVE_INFO_PRECOMP sw; // Info for short Weierstrass curves (only the precomputation parameters are needed now)
2986
2987 } info; // Precomputed information related to each curve
2988
2989 PSYMCRYPT_MODULUS FMod; // Field modulus
2990 PSYMCRYPT_MODULUS GOrd; // Order of the subgroup
2991
2992 PSYMCRYPT_MODELEMENT A; // Parameter A
2993 PSYMCRYPT_MODELEMENT B; // Parameter B
2994 PSYMCRYPT_ECPOINT G; // Distinguished point (generator of the subgroup)
2995 PSYMCRYPT_INT H; // Cofactor of the curve
2996
2998
2999 // FMod
3000 // A
3001 // B
3002 // GOrd
3003 // H
3004 // G
3008
3009#define SYMCRYPT_INTERNAL_ECPOINT_COORDINATE_OFFSET( _pCurve, _ord ) ( sizeof(SYMCRYPT_ECPOINT) + (_ord) * (_pCurve)->cbModElement )
3010#define SYMCRYPT_INTERNAL_ECPOINT_COORDINATE( _ord, _pCurve, _pEcpoint ) (PSYMCRYPT_MODELEMENT)( (PBYTE)(_pEcpoint) + SYMCRYPT_INTERNAL_ECPOINT_COORDINATE_OFFSET( (_pCurve), _ord ) )
3011
3012// Convenience macros to make adding internal specializations easier
3013#define SYMCRYPT_CURVE_IS_SHORT_WEIERSTRASS_TYPE( _pCurve ) \
3014 ( _pCurve->type == SYMCRYPT_INTERNAL_ECURVE_TYPE_SHORT_WEIERSTRASS || \
3015 _pCurve->type == SYMCRYPT_INTERNAL_ECURVE_TYPE_SHORT_WEIERSTRASS_AM3 )
3016
3017#define SYMCRYPT_CURVE_IS_TWISTED_EDWARDS_TYPE( _pCurve ) \
3018 ( _pCurve->type == SYMCRYPT_INTERNAL_ECURVE_TYPE_TWISTED_EDWARDS )
3019
3020#define SYMCRYPT_CURVE_IS_MONTGOMERY_TYPE( _pCurve ) \
3021 ( _pCurve->type == SYMCRYPT_INTERNAL_ECURVE_TYPE_MONTGOMERY )
3022
3023//
3024// Scratch space sizes for ECURVE operations
3025//
3026// Overflow protection is enforced when creating the ECURVE objects on
3027// the cbScratchCommon, cbScratchScalar, cbScratchScalarMulti, and cbScratchEckey fields.
3028//
3029// All of them are upper bounded by 2^26 (see SymCrypt<CurveType>FillScratchSpaces functions)
3030// and since _nPoints is bounded by SYMCRYPT_ECURVE_MULTI_SCALAR_MUL_MAX_NPOINTS = 2, all
3031// the macros are bounded by 2^27.
3032//
3033
3034#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_COMMON_ECURVE_OPERATIONS( _pCurve ) ( (_pCurve)->cbScratchCommon)
3035#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_SCALAR_ECURVE_OPERATIONS( _pCurve, _nPoints ) ( (_pCurve)->cbScratchScalar + \
3036 (_nPoints) * (_pCurve)->cbScratchScalarMulti )
3037#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_GETSET_VALUE_ECURVE_OPERATIONS( _pCurve ) ( (_pCurve)->cbScratchGetSetValue)
3038#define SYMCRYPT_INTERNAL_SCRATCH_BYTES_FOR_ECKEY_ECURVE_OPERATIONS( _pCurve ) ( (_pCurve)->cbScratchEckey)
3039
3040typedef SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_ECPOINT {
3041 BOOLEAN normalized; // A flag specifying whether the point is normalized or not. This flag
3042 // makes sense only for PROJECTIVE, JACOBIAN, EXTENDED_PROJECTIVE, and
3043 // SINGLE_PROJECTIVE coordinates. If set to TRUE (non-zero), it means
3044 // that the Z coordinate of the point is equal to 1.
3045 PCSYMCRYPT_ECURVE pCurve; // Handle to the curve which the point is on. Only used in CHKed builds for ASSERTs
3047 // An array of MODELEMENTs. The total size will depend on the MODELEMENT size and the number of MODELEMENTs.
3049typedef const SYMCRYPT_ECPOINT * PCSYMCRYPT_ECPOINT;
3050
3051typedef SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_ECKEY {
3052 UINT32 fAlgorithmInfo; // Tracks which algorithms the key can be used in
3053 // Also tracks which per-key selftests have been performed on this key
3054 // A bitwise OR of SYMCRYPT_FLAG_KEY_*, SYMCRYPT_FLAG_ECKEY_*, and
3055 // SYMCRYPT_PCT_* values
3056 BOOLEAN hasPrivateKey; // Set to true if there is a private key set
3057 PCSYMCRYPT_ECURVE pCurve; // Handle to the curve which created the key
3058
3059 PSYMCRYPT_ECPOINT poPublicKey; // Public key (ECPOINT)
3060 PSYMCRYPT_INT piPrivateKey; // Private key
3061
3063
3064 // PublicKey
3065 // PrivateKey
3069
3077};
3078
3079//
3080// XMSS
3081//
3082
3084{
3085 PCSYMCRYPT_HASH hash; // hash function
3086 UINT32 id; // algorithm identifier
3087 UINT32 cbHashOutput; // hash function output size, must be less than or equal to hash->resultSize
3088 UINT32 nWinternitzWidth;// Winternitz coefficient, width of digits in bits (chain length = 2^nWinternitzWidth)
3089 UINT32 nTotalTreeHeight;// number of layers times the tree height of one layer (each layer has the same height)
3090 UINT32 nLayers; // hyper-tree layers, 1 for single tree
3091 UINT32 cbPrefix; // length of the domain separator prefix in PRFs
3092
3093 //
3094 // The following are derived from the above
3095 //
3096 UINT32 len1; // number of w-bit digits in the hash output to be signed ( len1 = ceil(8n / w) )
3097 UINT32 len2; // number of w-bit digits in the checksum
3098 UINT32 len; // len1 + len2
3099 UINT32 nLayerHeight; // tree height of a single layer (h / d)
3100 UINT32 cbIdx; // size of leaf counter in bytes (for single trees cbIdx = 4)
3101 UINT32 nLeftShift32; // left shift count to align the checksum digits to MSB of a 32-bit word
3102
3103 BYTE Reserved[16]; // Reserved for future use
3105
3108
3109struct _SYMCRYPT_XMSS_KEY;
3113
3114
3115//==========================================================================
3116// LMS internal structures
3117//==========================================================================
3118
3120{
3121 // algorithm ID of the LMS signature scheme
3122 UINT32 lmsAlgID;
3123
3124 // algorithm ID of the LM-OTS signature scheme
3126
3127 // hash function pointer to be used as part of the LMS operations
3129
3130 // the height of the LMS tree. There are 2^h leaves in the tree - h
3132
3133 // the number of bytes for each tree node, equals to the output length of the hash function - m, n
3135
3136 // Winternitz coefficient, width of digits in bits (chain length = 2^w) - w
3138
3139 // the number of n-byte string elements that make up the LM-OTS signature - p
3141
3142 // the number of left-shift bits used in the checksum function Cksm - ls
3147
3148struct _SYMCRYPT_LMS_KEY;
3152
3153#ifndef _PREFAST_
3154#if SYMCRYPT_CPU_X86
3155#pragma warning(pop)
3156#endif
3157#endif
3158
3159
3160
3162//
3163// Environment macros
3164//
3165
3166#ifdef __cplusplus
3167#define SYMCRYPT_EXTERN_C extern "C" {
3168#define SYMCRYPT_EXTERN_C_END }
3169#else
3170#define SYMCRYPT_EXTERN_C
3171#define SYMCRYPT_EXTERN_C_END
3172#endif
3173
3174//
3175// Callers of SymCrypt should NOT depend on the function names in these macros.
3176// The definition of these macros can change in future releases of the library.
3177//
3178
3179#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64
3180typedef struct _SYMCRYPT_EXTENDED_SAVE_DATA SYMCRYPT_EXTENDED_SAVE_DATA, *PSYMCRYPT_EXTENDED_SAVE_DATA;
3181
3182#define SYMCRYPT_ENVIRONMENT_DEFS_SAVEYMM( envName ) \
3183 SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSaveYmmEnv##envName( _Out_ PSYMCRYPT_EXTENDED_SAVE_DATA pSaveArea ); \
3184 SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSaveYmm( _Out_ PSYMCRYPT_EXTENDED_SAVE_DATA pSaveArea ) \
3185 { return SymCryptSaveYmmEnv##envName( pSaveArea ); } \
3186 \
3187 VOID SYMCRYPT_CALL SymCryptRestoreYmmEnv##envName( _Inout_ PSYMCRYPT_EXTENDED_SAVE_DATA pSaveArea ); \
3188 VOID SYMCRYPT_CALL SymCryptRestoreYmm( _Inout_ PSYMCRYPT_EXTENDED_SAVE_DATA pSaveArea ) \
3189 { SymCryptRestoreYmmEnv##envName( pSaveArea ); } \
3190
3191#define SYMCRYPT_ENVIRONMENT_DEFS_SAVEXMM( envName ) \
3192 SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSaveXmmEnv##envName( _Out_ PSYMCRYPT_EXTENDED_SAVE_DATA pSaveArea ); \
3193 SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptSaveXmm( _Out_ PSYMCRYPT_EXTENDED_SAVE_DATA pSaveArea ) \
3194 { return SymCryptSaveXmmEnv##envName( pSaveArea ); } \
3195 \
3196 VOID SYMCRYPT_CALL SymCryptRestoreXmmEnv##envName( _Inout_ PSYMCRYPT_EXTENDED_SAVE_DATA pSaveArea ); \
3197 VOID SYMCRYPT_CALL SymCryptRestoreXmm( _Inout_ PSYMCRYPT_EXTENDED_SAVE_DATA pSaveArea ) \
3198 { SymCryptRestoreXmmEnv##envName( pSaveArea ); } \
3199
3200
3201#else
3202
3203#define SYMCRYPT_ENVIRONMENT_DEFS_SAVEYMM( envName )
3204#define SYMCRYPT_ENVIRONMENT_DEFS_SAVEXMM( envName )
3205
3206#endif
3207
3208// Environment forwarding functions.
3209// CPUIDEX is only forwarded on CPUs that have it.
3210#if SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_X86
3211#define SYMCRYPT_ENVIRONMENT_FORWARD_CPUIDEX( envName ) \
3212 VOID SYMCRYPT_CALL SymCryptCpuidExFuncEnv##envName( int cpuInfo[4], int function_id, int subfunction_id ); \
3213 VOID SYMCRYPT_CALL SymCryptCpuidExFunc( int cpuInfo[4], int function_id, int subfunction_id ) \
3214 { SymCryptCpuidExFuncEnv##envName( cpuInfo, function_id, subfunction_id ); }
3215#else
3216#define SYMCRYPT_ENVIRONMENT_FORWARD_CPUIDEX( envName )
3217#endif
3218
3219#define SYMCRYPT_ENVIRONMENT_DEFS( envName ) \
3220SYMCRYPT_EXTERN_C \
3221 VOID SYMCRYPT_CALL SymCryptInitEnv##envName( UINT32 version ); \
3222 VOID SYMCRYPT_CALL SymCryptInit(void) \
3223 { SymCryptInitEnv##envName( SYMCRYPT_API_VERSION ); } \
3224 \
3225 _Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatalEnv##envName( UINT32 fatalCode ); \
3226 _Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal( UINT32 fatalCode ) \
3227 { SymCryptFatalEnv##envName( fatalCode ); } \
3228 SYMCRYPT_CPU_FEATURES SYMCRYPT_CALL SymCryptCpuFeaturesNeverPresentEnv##envName(void); \
3229 SYMCRYPT_CPU_FEATURES SYMCRYPT_CALL SymCryptCpuFeaturesNeverPresent(void) \
3230 { return SymCryptCpuFeaturesNeverPresentEnv##envName(); } \
3231 \
3232 SYMCRYPT_ENVIRONMENT_DEFS_SAVEXMM( envName ) \
3233 SYMCRYPT_ENVIRONMENT_DEFS_SAVEYMM( envName ) \
3234 \
3235 VOID SYMCRYPT_CALL SymCryptTestInjectErrorEnv##envName( PBYTE pbBuf, SIZE_T cbBuf ); \
3236 VOID SYMCRYPT_CALL SymCryptInjectError( PBYTE pbBuf, SIZE_T cbBuf ) \
3237 { SymCryptTestInjectErrorEnv##envName( pbBuf, cbBuf ); } \
3238 SYMCRYPT_ENVIRONMENT_FORWARD_CPUIDEX( envName ) \
3239SYMCRYPT_EXTERN_C_END
3240
3241//
3242// To avoid hard-do-diagnose mistakes, we skip defining environment macros in those cases where we
3243// know they cannot or should not be used.
3244//
3245
3246#define SYMCRYPT_ENVIRONMENT_GENERIC SYMCRYPT_ENVIRONMENT_DEFS( Generic )
3247
3248#if defined(EFI) | defined(PCAT) | defined(DIRECT)
3249#define SYMCRYPT_ENVIRONMENT_WINDOWS_BOOTLIBRARY SYMCRYPT_ENVIRONMENT_DEFS( WindowsBootlibrary )
3250#endif
3251
3252//
3253// There are no defined symbols that we can use to detect that we are in debugger code
3254// But this is unlikely to be misused.
3255//
3256#define SYMCRYPT_ENVIRONMENT_WINDOWS_KERNELDEBUGGER SYMCRYPT_ENVIRONMENT_DEFS( WindowsKernelDebugger )
3257
3258
3259
3260#define SYMCRYPT_ENVIRONMENT_WINDOWS_KERNELMODE_LEGACY SYMCRYPT_ENVIRONMENT_GENERIC
3261
3262#ifdef NTDDI_VERSION
3263#if (NTDDI_VERSION >= NTDDI_WIN7)
3264#define SYMCRYPT_ENVIRONMENT_WINDOWS_KERNELMODE_WIN7_N_LATER SYMCRYPT_ENVIRONMENT_DEFS( WindowsKernelmodeWin7nLater )
3265#endif
3266
3267#if (NTDDI_VERSION >= NTDDI_WINBLUE)
3268#define SYMCRYPT_ENVIRONMENT_WINDOWS_KERNELMODE_WIN8_1_N_LATER SYMCRYPT_ENVIRONMENT_DEFS( WindowsKernelmodeWin8_1nLater )
3269#endif
3270
3271#define SYMCRYPT_ENVIRONMENT_WINDOWS_KERNELMODE_LATEST SYMCRYPT_ENVIRONMENT_WINDOWS_KERNELMODE_WIN8_1_N_LATER
3272
3273
3274
3275#define SYMCRYPT_ENVIRONMENT_WINDOWS_USERMODE_LEGACY SYMCRYPT_ENVIRONMENT_GENERIC
3276
3277#if (NTDDI_VERSION >= NTDDI_WIN7)
3278#define SYMCRYPT_ENVIRONMENT_WINDOWS_USERMODE_WIN7_N_LATER SYMCRYPT_ENVIRONMENT_DEFS( WindowsUsermodeWin7nLater )
3279#endif
3280
3281#if (NTDDI_VERSION >= NTDDI_WINBLUE)
3282#define SYMCRYPT_ENVIRONMENT_WINDOWS_USERMODE_WIN8_1_N_LATER SYMCRYPT_ENVIRONMENT_DEFS( WindowsUsermodeWin8_1nLater )
3283#endif
3284
3285#if (NTDDI_VERSION >= NTDDI_WIN10)
3286#define SYMCRYPT_ENVIRONMENT_WINDOWS_USERMODE_WIN10_SGX SYMCRYPT_ENVIRONMENT_DEFS( Win10Sgx )
3287#endif
3288#endif // NTDDI_VERSION
3289
3290#define SYMCRYPT_ENVIRONMENT_WINDOWS_USERMODE_LATEST SYMCRYPT_ENVIRONMENT_WINDOWS_USERMODE_WIN8_1_N_LATER
3291
3292
3293#define SYMCRYPT_ENVIRONMENT_POSIX_USERMODE SYMCRYPT_ENVIRONMENT_DEFS( PosixUsermode )
3294
3295// For backwards compatibility with previous macro name
3296#define SYMCRYPT_ENVIRONMENT_LINUX_USERMODE SYMCRYPT_ENVIRONMENT_POSIX_USERMODE
3297
3298
3299#define SYMCRYPT_ENVIRONMENT_OPTEE_TA SYMCRYPT_ENVIRONMENT_DEFS( OpteeTa )
3300
3302//
3303// SymCryptWipe & SymCryptWipeKnownSize
3304//
3305
3306VOID
3310 SIZE_T cbData);
3311
3312#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM | SYMCRYPT_CPU_ARM64
3313
3314//
3315// If the known size is large we call the generic wipe function anyway.
3316// For small known sizes we perform the wipe inline.
3317// This is a tradeoff between speed and code size and there are diminishing returns to supporting
3318// increasingly large sizes.
3319// We currently put the limit at ~8 native writes, which varies by platform.
3320//
3321#if SYMCRYPT_CPU_X86 | SYMCRYPT_CPU_ARM
3322#define SYMCRYPT_WIPE_FUNCTION_LIMIT (32) // If this is increased beyond 127 the code below must be updated.
3323#elif SYMCRYPT_CPU_AMD64 | SYMCRYPT_CPU_ARM64
3324#define SYMCRYPT_WIPE_FUNCTION_LIMIT (64) // If this is increased beyond 127 the code below must be updated.
3325#else
3326#error ??
3327#endif
3328
3329//
3330// The buffer analysis code doesn't understand our optimized in-line wiping code
3331// well enough to conclude it is safe.
3332//
3333#pragma prefast(push)
3334#pragma prefast( disable: 26001 )
3335
3337VOID
3339#pragma prefast( suppress: 6101, "Logic why this properly initializes the pbData buffer is too complicated for prefast" )
3341{
3342 volatile BYTE * pb = (volatile BYTE *)pbData;
3343
3344 if (cbData > SYMCRYPT_WIPE_FUNCTION_LIMIT)
3345 {
3347 }
3348 else
3349 {
3350 //
3351 // We assume that pb is aligned, so we wipe from the end to the front to keep alignment.
3352 //
3353 if (cbData & 1)
3354 {
3355 cbData--;
3356 SYMCRYPT_INTERNAL_FORCE_WRITE8((volatile BYTE *)&pb[cbData], 0);
3357 }
3358 if (cbData & 2)
3359 {
3360 cbData -= 2;
3361 SYMCRYPT_INTERNAL_FORCE_WRITE16((volatile UINT16 *)&pb[cbData], 0);
3362 }
3363 if (cbData & 4)
3364 {
3365 cbData -= 4;
3366 SYMCRYPT_INTERNAL_FORCE_WRITE32((volatile UINT32 *)&pb[cbData], 0);
3367 }
3368 if (cbData & 8)
3369 {
3370 cbData -= 8;
3371 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData], 0);
3372 }
3373 if (cbData & 16)
3374 {
3375 cbData -= 16;
3376 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData], 0);
3377 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 8], 0);
3378 }
3379 if (cbData & 32)
3380 {
3381 cbData -= 32;
3382 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData], 0);
3383 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 8], 0);
3384 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 16], 0);
3385 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 24], 0);
3386 }
3387#if SYMCRYPT_WIPE_FUNCTION_LIMIT >= 64
3388 if (cbData & 64)
3389 {
3390 cbData -= 64;
3391 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData], 0);
3392 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 8], 0);
3393 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 16], 0);
3394 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 24], 0);
3395 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 32], 0);
3396 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 40], 0);
3397 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 48], 0);
3398 SYMCRYPT_INTERNAL_FORCE_WRITE64((volatile UINT64 *)&pb[cbData + 56], 0);
3399 }
3400#endif
3401 }
3402}
3403
3404#pragma prefast(pop)
3405
3406#else // Platform switch for SymCryptWipeKnownSize
3407
3409VOID
3412{
3414}
3415
3416#endif // Platform switch for SymCryptWipeKnownSize
3417
3418#define SYMCRYPT_FIPS_ASSERT(x) { if(!(x)){ SymCryptFatal('FIPS'); } }
3419
3420// Flags for FIPS on-demand selftests. When an on-demand selftest succeeds, the corresponding flag
3421// will be set in g_SymCryptFipsSelftestsPerformed. Other selftests are performed automatically
3422// when the module is loaded, so they don't have a corresponding flag.
3436
3437// Takes values which are some bitwise OR combination of SYMCRYPT_SELFTEST_ALGORITHM values
3438// Specified as UINT32 as we will update with 32 bit atomics, and compilers may choose to make enum
3439// types smaller than 32 bits.
3441
3442UINT32
3445// Returns current value of g_SymCryptFipsSelftestsPerformed so callers may inspect which FIPS
3446// algorithm selftests have run
3447
3448// Flags for per-key selftests.
3449// When an asymmetric key is generated or imported, and SYMCRYPT_FLAG_KEY_NO_FIPS is not specified,
3450// some selftests must be performed on the key, before its operational use in an algorithm, to
3451// comply with FIPS.
3452// The algorithms the key may be used in will be tracked in the key's fAlgorithmInfo field, as a
3453// bitwise OR of SYMCRYPT_FLAG_<keytype>_<algorithm> (e.g. SYMCRYPT_FLAG_DLKEY_DH).
3454// This field will also track which per-key selftests have been run on the key using the below flags
3455// We want to track which selftests have been run independently of which algorithms the key may be
3456// used in as in some scenarios at key generation / import time we may not know what algorithm the
3457// key will actually be used in. Tracking the run per-key selftests in fAlgorithmInfo allows us to
3458// defer running expensive tests until we know they are required (e.g. if we generate an Eckey which
3459// may be used in ECDH or ECDSA, and only use it for ECDH, the ECDSA PCT is deferred until we first
3460// attempt to use the key in ECDSA, or export the private key).
3461//
3462// For clarity, SYMCRYPT_PCT_* should be used instead of SYMCRYPT_SELFTEST_KEY_* going forward.
3463// The latter is retained for compatibility with existing code, but may be removed in a future
3464// breaking change.
3465
3466// Dlkey selftest flags
3467// DSA Pairwise Consistency Test to be run on generated keys
3468#define SYMCRYPT_SELFTEST_KEY_DSA (0x1)
3469#define SYMCRYPT_PCT_DSA SYMCRYPT_SELFTEST_KEY_DSA
3470
3471// Eckey selftest flags
3472// ECDSA Pairwise Consistency Test to be run on generated keys
3473#define SYMCRYPT_SELFTEST_KEY_ECDSA (0x1)
3474#define SYMCRYPT_PCT_ECDSA SYMCRYPT_SELFTEST_KEY_ECDSA
3475
3476// Rsakey selftest flags
3477// RSA Pairwise Consistency Test to be run on generated keys
3478#define SYMCRYPT_SELFTEST_KEY_RSA_SIGN (0x1)
3479#define SYMCRYPT_PCT_RSA_SIGN SYMCRYPT_SELFTEST_KEY_RSA_SIGN
3480
3481UINT32
3484//
3485// Returns the FIPS Approved Services Status Indicator as an ASCII string.
3486// This API is required to satisfy FIPS 140-3 requirements, but is *not* recommended
3487// to be used in production code. It should be considered unstable,
3488// and may be removed at any time.
3489//
3490// The output string will be copied to pbOutput if the size of the buffer
3491// cbOutput is large enough. The function returns the required buffer size
3492// when pbOutput is passed as NULL. If pbOutput is not NULL, the function
3493// returns the number of bytes copied to pbOutput.
3494//
3495
3496
3497
3498typedef enum _SYMCRYPT_SI_TYPE {
3499
3500 // Algorithm types (specific algorithms are represented as a bitmask of a type)
3509
3510 // Other types where elements are a bitmask
3514
3515 // Non-bitmask types
3519
3522
3523#define SYMCRYPT_SI_CREATE_ID(type, index) (((UINT64)(type) << 56) + (1ULL << (index)))
3524
3525#define SYMCRYPT_SI_INTBITS ((64 - 8) / 2) // 8-bits for type, remaining bits shared by two integers
3526#define SYMCRYPT_SI_INTMASK ((1ULL << SYMCRYPT_SI_INTBITS) - 1) // typically should be 0x0FFFFFFF with 28 1s
3527#define SYMCRYPT_SI_INTPACK(High, Low) (((((UINT64)High) & SYMCRYPT_SI_INTMASK) << SYMCRYPT_SI_INTBITS) | (((UINT64)Low) & SYMCRYPT_SI_INTMASK))
3528#define SYMCRYPT_SI_INTUNPACKLO(X) ((X) & SYMCRYPT_SI_INTMASK)
3529#define SYMCRYPT_SI_INTUNPACKHI(X) (((X) >> SYMCRYPT_SI_INTBITS) & SYMCRYPT_SI_INTMASK)
3530
3531#define SYMCRYPT_SI_INTRANGE(Low, High) (((UINT64)SYMCRYPT_SI_TYPE_INTRANGE << 56) | SYMCRYPT_SI_INTPACK(High, Low))
3532#define SYMCRYPT_SI_INTPAIR(X, Y) (((UINT64)SYMCRYPT_SI_TYPE_INTPAIR << 56) | SYMCRYPT_SI_INTPACK(Y, X))
3533#define SYMCRYPT_SI_SIZERANGE(Low, High) (((UINT64)SYMCRYPT_SI_TYPE_SIZERANGE << 56) | SYMCRYPT_SI_INTPACK(High, Low))
3534
3535#define SYMCRYPT_SI_CHECK_INT(L) C_ASSERT(L <= SYMCRYPT_SI_INTMASK)
3536
3537#define SYMCRYPT_SI_KEYBITS(L) SYMCRYPT_SI_SIZERANGE(L, L)
3538#define SYMCRYPT_SI_MODULUS(L) SYMCRYPT_SI_SIZERANGE(L, L)
3539#define SYMCRYPT_SI_DSAPARAMS(N, L) SYMCRYPT_SI_INTPAIR(N, L)
3540
3541
3542// Services
3543#define SYMCRYPT_SI_SVC_ENCRYPTION 0x00000001
3544#define SYMCRYPT_SI_SVC_DECRYPTION 0x00000002
3545#define SYMCRYPT_SI_SVC_HASHING 0x00000004
3546#define SYMCRYPT_SI_SVC_MESSAGE_AUTHENTICATION 0x00000008
3547#define SYMCRYPT_SI_SVC_KEY_DERIVATION 0x00000010
3548#define SYMCRYPT_SI_SVC_ASYMMETRIC_KEY_GENERATION 0x00000020
3549#define SYMCRYPT_SI_SVC_ASYMMETRIC_KEY_VERIFICATION 0x00000080
3550#define SYMCRYPT_SI_SVC_RANDOM_NUMBER_GENERATION 0x00000400
3551#define SYMCRYPT_SI_SVC_SECRET_AGREEMENT 0x00000800
3552#define SYMCRYPT_SI_SVC_SIGNATURE_GENERATION 0x00001000
3553#define SYMCRYPT_SI_SVC_SIGNATURE_VERIFICATION 0x00002000
3554#define SYMCRYPT_SI_SVC_KEY_ENCAPSULATION 0x00004000
3555#define SYMCRYPT_SI_SVC_KEY_DECAPSULATION 0x00008000
3556
3557// Ciphers
3558#define SYMCRYPT_SI_AES_CBC SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 0)
3559#define SYMCRYPT_SI_AES_CCM SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 1)
3560#define SYMCRYPT_SI_AES_CFB128 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 2)
3561#define SYMCRYPT_SI_AES_CFB8 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 3)
3562#define SYMCRYPT_SI_AES_CTR SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 4)
3563#define SYMCRYPT_SI_AES_ECB SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 5)
3564#define SYMCRYPT_SI_AES_GCM SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 6)
3565#define SYMCRYPT_SI_AES_XTS SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 7)
3566#define SYMCRYPT_SI_RC2 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 8)
3567#define SYMCRYPT_SI_RC4 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 9)
3568#define SYMCRYPT_SI_CHACHA SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 10)
3569#define SYMCRYPT_SI_DES SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 11)
3570#define SYMCRYPT_SI_TRIPLEDES SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 12)
3571#define SYMCRYPT_SI_CHACHA20 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 13)
3572#define SYMCRYPT_SI_CHACHA20_POLY1305 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 14)
3573#define SYMCRYPT_SI_AES_KW SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 15)
3574#define SYMCRYPT_SI_AES_KWP SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_CIPHER, 16)
3575
3576// Hash Functions
3577#define SYMCRYPT_SI_MD2 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 0)
3578#define SYMCRYPT_SI_MD4 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 1)
3579#define SYMCRYPT_SI_MD5 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 2)
3580#define SYMCRYPT_SI_SHA1 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 3)
3581#define SYMCRYPT_SI_SHA2_224 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 4)
3582#define SYMCRYPT_SI_SHA2_256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 5)
3583#define SYMCRYPT_SI_SHA2_384 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 6)
3584#define SYMCRYPT_SI_SHA2_512 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 7)
3585#define SYMCRYPT_SI_SHA2_512_224 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 8)
3586#define SYMCRYPT_SI_SHA2_512_256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 9)
3587#define SYMCRYPT_SI_SHA3_224 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 10)
3588#define SYMCRYPT_SI_SHA3_256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 11)
3589#define SYMCRYPT_SI_SHA3_384 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 12)
3590#define SYMCRYPT_SI_SHA3_512 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 13)
3591#define SYMCRYPT_SI_SHAKE128 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 14)
3592#define SYMCRYPT_SI_SHAKE256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 15)
3593#define SYMCRYPT_SI_CSHAKE128 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 16)
3594#define SYMCRYPT_SI_CSHAKE256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 17)
3595#define SYMCRYPT_SI_MARVIN32 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_HASH, 18)
3596
3597// MAC
3598#define SYMCRYPT_SI_HMAC_MD2 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 0)
3599#define SYMCRYPT_SI_HMAC_MD4 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 1)
3600#define SYMCRYPT_SI_HMAC_MD5 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 2)
3601#define SYMCRYPT_SI_HMAC_SHA1 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 3)
3602#define SYMCRYPT_SI_HMAC_SHA2_224 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 4)
3603#define SYMCRYPT_SI_HMAC_SHA2_256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 5)
3604#define SYMCRYPT_SI_HMAC_SHA2_384 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 6)
3605#define SYMCRYPT_SI_HMAC_SHA2_512 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 7)
3606#define SYMCRYPT_SI_HMAC_SHA2_512_224 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 8)
3607#define SYMCRYPT_SI_HMAC_SHA2_512_256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 9)
3608#define SYMCRYPT_SI_HMAC_SHA3_224 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 10)
3609#define SYMCRYPT_SI_HMAC_SHA3_256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 11)
3610#define SYMCRYPT_SI_HMAC_SHA3_384 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 12)
3611#define SYMCRYPT_SI_HMAC_SHA3_512 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 13)
3612#define SYMCRYPT_SI_KMAC128 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 14)
3613#define SYMCRYPT_SI_KMAC256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 15)
3614#define SYMCRYPT_SI_AES_GMAC SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 16)
3615#define SYMCRYPT_SI_AES_CMAC SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 17)
3616#define SYMCRYPT_SI_AES_CBCMAC SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 18)
3617#define SYMCRYPT_SI_POLY1305 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_MAC, 19)
3618
3619// KDF
3620#define SYMCRYPT_SI_HKDF SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 0)
3621#define SYMCRYPT_SI_PBKDF SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 1)
3622#define SYMCRYPT_SI_KDA_ONESTEP SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 2)
3623#define SYMCRYPT_SI_KDF_IKEV1 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 3)
3624#define SYMCRYPT_SI_KDF_IKEV2 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 4)
3625#define SYMCRYPT_SI_KDF_SP800_108_CTR SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 5)
3626#define SYMCRYPT_SI_KDF_SRTP SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 6)
3627#define SYMCRYPT_SI_KDF_SSH SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 7)
3628#define SYMCRYPT_SI_KDF_TLS SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 8)
3629#define SYMCRYPT_SI_KDF_TLS_V12 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KDF, 9)
3630
3631// DRBG
3632#define SYMCRYPT_SI_CTR_DRBG_AES256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_DRBG, 0)
3633
3634// Asymmetric Algorithms
3635#define SYMCRYPT_SI_SAFE_PRIME_KEYGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 0)
3636#define SYMCRYPT_SI_DSA_KEYGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 1)
3637#define SYMCRYPT_SI_DSA_PQGGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 2)
3638#define SYMCRYPT_SI_DSA_PQGVER SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 3)
3639#define SYMCRYPT_SI_DSA_SIGVER SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 4)
3640
3641#define SYMCRYPT_SI_ECDSA_KEYGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 5)
3642#define SYMCRYPT_SI_ECDSA_KEYVER SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 6)
3643#define SYMCRYPT_SI_ECDSA_SIGGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 7)
3644#define SYMCRYPT_SI_ECDSA_SIGVER SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 8)
3645#define SYMCRYPT_SI_ECDSA_SIGGEN_COMP SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 9)
3646
3647#define SYMCRYPT_SI_RSA_KEYGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 10)
3648#define SYMCRYPT_SI_RSA_DEC_PRIM SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 12)
3649#define SYMCRYPT_SI_RSA_SIG_PRIM SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 13)
3650#define SYMCRYPT_SI_RSA_SIGGEN_PKCS15 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 14)
3651#define SYMCRYPT_SI_RSA_SIGGEN_PKCSPSS SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 15)
3652#define SYMCRYPT_SI_RSA_SIGVER_PKCS15 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 16)
3653#define SYMCRYPT_SI_RSA_SIGVER_PKCSPSS SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 17)
3654
3655#define SYMCRYPT_SI_KAS_ECC SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 18)
3656#define SYMCRYPT_SI_KAS_ECC_SSC SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 19)
3657#define SYMCRYPT_SI_KAS_FFC SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 20)
3658#define SYMCRYPT_SI_KAS_FFC_SSC SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 21)
3659
3660// PQ Algorithms
3661
3662// Asym Alg IDs for PQC algorithms in range 22-26 are replaced with more granular
3663// algorithms as below.
3664// Keeping this range reserved until there's a need to use it in the future.
3665
3666#define SYMCRYPT_SI_MLDSA_KEYGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 27)
3667#define SYMCRYPT_SI_MLDSA_SIGGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 28)
3668#define SYMCRYPT_SI_MLDSA_SIGVER SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 29)
3669#define SYMCRYPT_SI_LMS_KEYGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 30)
3670#define SYMCRYPT_SI_LMS_SIGGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 31)
3671#define SYMCRYPT_SI_LMS_SIGVER SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 32)
3672#define SYMCRYPT_SI_XMSS_KEYGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 33)
3673#define SYMCRYPT_SI_XMSS_SIGGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 34)
3674#define SYMCRYPT_SI_XMSS_SIGVER SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 35)
3675#define SYMCRYPT_SI_XMSS_MT_KEYGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 36)
3676#define SYMCRYPT_SI_XMSS_MT_SIGGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 37)
3677#define SYMCRYPT_SI_XMSS_MT_SIGVER SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ASYM_ALG, 38)
3678
3679#define SYMCRYPT_SI_MLKEM_KEYGEN SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KEM, 0)
3680#define SYMCRYPT_SI_MLKEM_ENCAPS SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KEM, 1)
3681#define SYMCRYPT_SI_MLKEM_DECAPS SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KEM, 2)
3682
3683
3684// Elliptic Curves
3685#define SYMCRYPT_SI_ECURVE_NISTP192 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ECURVE, 0)
3686#define SYMCRYPT_SI_ECURVE_NISTP224 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ECURVE, 1)
3687#define SYMCRYPT_SI_ECURVE_NISTP256 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ECURVE, 2)
3688#define SYMCRYPT_SI_ECURVE_NISTP384 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ECURVE, 3)
3689#define SYMCRYPT_SI_ECURVE_NISTP521 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ECURVE, 4)
3690#define SYMCRYPT_SI_ECURVE_NUMSP256T1 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ECURVE, 5)
3691#define SYMCRYPT_SI_ECURVE_NUMSP384T1 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ECURVE, 6)
3692#define SYMCRYPT_SI_ECURVE_NUMSP512T1 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ECURVE, 7)
3693#define SYMCRYPT_SI_ECURVE_CURVE25519 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_ECURVE, 8)
3694
3695// Safe Prime Groups
3696#define SYMCRYPT_SI_SPG_FFDHE_2048 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 0)
3697#define SYMCRYPT_SI_SPG_FFDHE_3072 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 1)
3698#define SYMCRYPT_SI_SPG_FFDHE_4096 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 2)
3699#define SYMCRYPT_SI_SPG_FFDHE_6144 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 3)
3700#define SYMCRYPT_SI_SPG_FFDHE_8192 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 4)
3701#define SYMCRYPT_SI_SPG_MODP_2048 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 5)
3702#define SYMCRYPT_SI_SPG_MODP_3072 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 6)
3703#define SYMCRYPT_SI_SPG_MODP_4096 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 7)
3704#define SYMCRYPT_SI_SPG_MODP_6144 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 8)
3705#define SYMCRYPT_SI_SPG_MODP_8192 SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP, 9)
3706
3707// KAS Schemes
3708#define SYMCRYPT_SI_SCHEME_EPHEM_UNIFIED SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KAS_SCHEME, 0)
3709#define SYMCRYPT_SI_SCHEME_DH_EPHEM SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KAS_SCHEME, 1)
3710#define SYMCRYPT_SI_SCHEME_DH_ONEFLOW SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KAS_SCHEME, 2)
3711#define SYMCRYPT_SI_SCHEME_DH_STATIC SYMCRYPT_SI_CREATE_ID(SYMCRYPT_SI_TYPE_KAS_SCHEME, 3)
3712
3713
3714UINT32
3718 UINT64 Alg,
3719 UINT64 Param1,
3720 UINT64 Param2,
3721 UINT64 Param3);
3722//
3723// Returns FIPS 140 Approved Services Indicator for an algorithm.
3724//
3725// Parameters:
3726// - Service. Service identifier, one of SYMCRYPT_SI_SVC_XXX.
3727// - Alg. Identifier of the algorithm for which the status is being queried. This must be
3728// exactly one of the algorithm identifiers defined above.
3729// - Param1, Param2, Param3. Depending on the Alg parameter, these parameters provide
3730// additional information about the capabilities and parameters associated with an
3731// algorithm. For each algorithm, the number and type of the parameters must be provided
3732// as specified below. Any unused parameters must be passed as 0. The algorithms that require
3733// parameters to be specified are listed below, the remaining algorithms do not have any parameters.
3734//
3735// Alg Id Param1 Param2
3736// ----------------------------- -------------------------------- ---------------
3737// SYMCRYPT_SI_AES_XTS SYMCRYPT_SI_KEYBITS(int) -
3738// SYMCRYPT_SI_DSA_PQGVER SYMCRYPT_SI_DSAPARAMS(int, int) -
3739// SYMCRYPT_SI_DSA_SIGVER SYMCRYPT_SI_DSAPARAMS(int, int) -
3740// SYMCRYPT_SI_ECDSA_KEYGEN SYMCRYPT_SI_ECURVE_XXX -
3741// SYMCRYPT_SI_ECDSA_KEYVER SYMCRYPT_SI_ECURVE_XXX -
3742// SYMCRYPT_SI_ECDSA_SIGGEN SYMCRYPT_SI_ECURVE_XXX Hash Alg Id
3743// SYMCRYPT_SI_ECDSA_SIGGEN_COMP SYMCRYPT_SI_ECURVE_XXX Hash Alg Id
3744// SYMCRYPT_SI_ECDSA_SIGVER SYMCRYPT_SI_ECURVE_XXX Hash Alg Id
3745// SYMCRYPT_SI_RSA_DEC_PRIM SYMCRYPT_SI_MODULUS(int) -
3746// SYMCRYPT_SI_RSA_KEYGEN SYMCRYPT_SI_MODULUS(int) -
3747// SYMCRYPT_SI_RSA_SIGGEN_PKCS15 SYMCRYPT_SI_MODULUS(int) Hash Alg Id
3748// SYMCRYPT_SI_RSA_SIGVER_PKCS15 SYMCRYPT_SI_MODULUS(int) Hash Alg Id
3749// SYMCRYPT_SI_RSA_SIGGEN_PKCSPSS SYMCRYPT_SI_MODULUS(int) Hash Alg Id
3750// SYMCRYPT_SI_RSA_SIGVER_PKCSPSS SYMCRYPT_SI_MODULUS(int) Hash Alg Id
3751// SYMCRYPT_SI_SAFE_PRIME_KEYGEN SYMCRYPT_SI_SPG_XXX Hash Alg Id
3752// SYMCRYPT_SI_HMAC_XXX SYMCRYPT_SI_KEYBITS(int) -
3753// SYMCRYPT_SI_KDA_ONESTEP Hash Alg Id or MAC alg Id -
3754// SYMCRYPT_SI_PBKDF MAC Alg Id -
3755// SYMCRYPT_SI_KDF_SP800_108_CTR MAC Alg Id -
3756// SYMCRYPT_SI_KDF_SSH Hash Alg Id -
3757// SYMCRYPT_SI_TLS_V12_KDF Hash Alg Id -
3758// SYMCRYPT_SI_KAS_ECC SYMCRYPT_SI_ECURVE_XXX Hash Alg Id
3759// SYMCRYPT_SI_KAS_ECC_SSC SYMCRYPT_SI_ECURVE_XXX SYMCRYPT_SI_SCHEME_XXX
3760// SYMCRYPT_SI_KAS_FFC SYMCRYPT_SI_SPG_XXX Hash Alg Id
3761// SYMCRYPT_SI_KAS_FFC_SSC SYMCRYPT_SI_SPG_XXX SYMCRYPT_SI_SCHEME_XXX
3762// SYMCRYPT_SI_LMS_SIGVER SYMCRYPT_LMS_XXX -
3763// SYMCRYPT_SI_XMSS_SIGVER SYMCRYPT_XMSS_XXX -
3764// SYMCRYPT_SI_XMSS_MT_SIGVER SYMCRYPT_XMSSMT_XXX -
3765//
3766//
3767// Return value:
3768// For the specified service and algorithm (and parameters if any), the function
3769// returns 0 if SymCrypt implements the algorithm in an approved manner. A non-zero
3770// value indicates either the algorithm is non-approved or the parameters were invalid.
3771//
3772// Remarks:
3773// - For parameters that contain integer values, the callers must ensure that the values
3774// are within the acceptable limits by using the SYMCRYPT_SI_CHECK_INT(L) macro.
unsigned short UINT16
Definition: actypes.h:129
unsigned char BOOLEAN
Definition: actypes.h:127
unsigned char UINT8
Definition: actypes.h:128
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
static int state
Definition: maze.c:121
unsigned int uint32
Definition: types.h:32
CONST VOID * PCVOID
Definition: cfgmgr32.h:44
Definition: terminate.cpp:24
INT32 int32_t
Definition: types.h:71
UINT32 uint32_t
Definition: types.h:75
INT16 int16_t
Definition: types.h:70
UINT64 uint64_t
Definition: types.h:77
INT64 int64_t
Definition: types.h:72
static const WCHAR version[]
Definition: asmname.c:66
unsigned short uint16_t
Definition: stdint.h:35
unsigned char uint8_t
Definition: stdint.h:33
signed char int8_t
Definition: stdint.h:32
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLint GLenum GLboolean normalized
Definition: glext.h:6117
GLuint64EXT GLuint GLuint GLenum GLenum GLuint GLuint GLenum GLuint GLuint key1
Definition: glext.h:10608
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint factor
Definition: glfuncs.h:178
#define Alg
Definition: hmacmd5.c:10
Windows helper functions for integer overflow prevention.
#define C_ASSERT(e)
Definition: intsafe.h:73
#define d
Definition: ke_i.h:81
#define _Out_opt_
Definition: no_sal2.h:214
#define _Inout_updates_(s)
Definition: no_sal2.h:182
#define _Out_writes_(s)
Definition: no_sal2.h:176
#define _Field_range_(l, h)
Definition: no_sal2.h:380
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
BYTE * PBYTE
Definition: pedump.c:66
@ Service
Definition: ntsecapi.h:292
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_COMPOSITE_MLKEMKEY
Definition: sc_lib.h:4442
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_LMS_KEY
Definition: sc_lib.h:4718
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_XMSS_KEY
Definition: sc_lib.h:4520
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_MLKEMKEY
Definition: sc_lib_mlkem.h:82
static const BYTE pbResult[]
Definition: movable.cpp:9
PSYMCRYPT_BLOCKCIPHER_CRYPT_ECB ecbDecryptFunc
PSYMCRYPT_BLOCKCIPHER_AEADPART_MODE gcmDecryptPartFunc
PSYMCRYPT_BLOCKCIPHER_CRYPT_MODE cbcEncryptFunc
PSYMCRYPT_BLOCKCIPHER_CRYPT decryptFunc
PSYMCRYPT_BLOCKCIPHER_CRYPT_MODE ctrMsb64Func
PSYMCRYPT_BLOCKCIPHER_CRYPT_MODE cbcDecryptFunc
PSYMCRYPT_BLOCKCIPHER_CRYPT encryptFunc
PSYMCRYPT_BLOCKCIPHER_AEADPART_MODE gcmEncryptPartFunc
PSYMCRYPT_BLOCKCIPHER_CRYPT_ECB ecbEncryptFunc
PSYMCRYPT_BLOCKCIPHER_EXPAND_KEY expandKeyFunc
_Field_range_(1, SYMCRYPT_MAX_BLOCK_SIZE) SIZE_T blockSize
PSYMCRYPT_BLOCKCIPHER_MAC_MODE cbcMacFunc
SYMCRYPT_MAC_EXPANDED_KEY macKey
const PCSYMCRYPT_HASH * ppHashAlgorithm
PSYMCRYPT_MAC_EXPAND_KEY expandKeyFunc
PSYMCRYPT_MAC_RESULT resultFunc
PSYMCRYPT_MAC_APPEND appendFunc
PSYMCRYPT_MAC_INIT initFunc
UINT32 outerChainingStateOffset
_Field_size_(cbOID) PCBYTE pbOID
_Field_size_(cbBuffer) PBYTE pbBuffer
SYMCRYPT_HASH_OPERATION_TYPE hashOperation
PSYMCRYPT_PARALLEL_HASH_OPERATION next
SYMCRYPT_MAC_EXPANDED_KEY macKey
SYMCRYPT_MAC_EXPANDED_KEY macKey
SYMCRYPT_AES_EXPANDED_KEY aesExpandedKey
SYMCRYPT_MAC_EXPANDED_KEY macKey
SYMCRYPT_HMAC_SHA1_EXPANDED_KEY macSha1Key
SYMCRYPT_HMAC_MD5_EXPANDED_KEY macMd5Key
SYMCRYPT_MAC_EXPANDED_KEY macKey
PSYMCRYPT_TRIALDIVISION_PRIME pPrimeList
PSYMCRYPT_TRIALDIVISION_GROUP pGroupList
Definition: copy.c:22
enum _SYMCRYPT_DLGROUP_FIPS SYMCRYPT_DLGROUP_FIPS
@ SYMCRYPT_ECURVE_TYPE_TWISTED_EDWARDS
Definition: symcrypt.h:234
@ SYMCRYPT_ECURVE_TYPE_MONTGOMERY
Definition: symcrypt.h:235
@ SYMCRYPT_ECURVE_TYPE_SHORT_WEIERSTRASS
Definition: symcrypt.h:233
SYMCRYPT_ERROR
Definition: symcrypt.h:227
const SYMCRYPT_SHA512_224_STATE * PCSYMCRYPT_SHA512_224_STATE
union _SYMCRYPT_MAC_STATE * PSYMCRYPT_MAC_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_GHASH_EXPANDED_KEY
* PSYMCRYPT_MD2_STATE
* PSYMCRYPT_SHA512_CHAINING_STATE
struct _SYMCRYPT_HKDF_EXPANDED_KEY SYMCRYPT_HKDF_EXPANDED_KEY
UINT32 stateIndex
const SYMCRYPT_BLOCKCIPHER * PCSYMCRYPT_BLOCKCIPHER
PSYMCRYPT_INT piPrivExps[SYMCRYPT_RSAKEY_MAX_NUMOF_PUBEXPS]
SIZE_T cbTag
* PSYMCRYPT_SHA512_256_STATE
struct _SYMCRYPT_XMSS_KEY SYMCRYPT_XMSS_KEY
int BOOL
struct _SYMCRYPT_MLKEMKEY SYMCRYPT_MLKEMKEY
const SYMCRYPT_KECCAK_STATE * PCSYMCRYPT_KECCAK_STATE
const SYMCRYPT_XMSS_PARAMS * PCSYMCRYPT_XMSS_PARAMS
#define SYMCRYPT_ALIGN
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA512_EXPANDED_KEY
PBYTE pbChainingValue
PSYMCRYPT_HASH_STATE_COPY_FUNC stateCopyFunc
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA512_224_EXPANDED_KEY
PCSYMCRYPT_DLGROUP pDlgroup
SYMCRYPT_ALIGN BYTE counterBlock[SYMCRYPT_CCM_BLOCK_SIZE]
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_EXPANDED_KEY
PCBYTE pbSrc
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA1_STATE
_SYMCRYPT_SELFTEST_ALGORITHM
@ SYMCRYPT_SELFTEST_ALGORITHM_DSA
@ SYMCRYPT_SELFTEST_ALGORITHM_MLKEM
@ SYMCRYPT_SELFTEST_ALGORITHM_DH
@ SYMCRYPT_SELFTEST_ALGORITHM_LMS
@ SYMCRYPT_SELFTEST_ALGORITHM_RSA
@ SYMCRYPT_SELFTEST_ALGORITHM_NONE
@ SYMCRYPT_SELFTEST_ALGORITHM_XMSS
@ SYMCRYPT_SELFTEST_ALGORITHM_ECDH
@ SYMCRYPT_SELFTEST_ALGORITHM_STARTUP
@ SYMCRYPT_SELFTEST_ALGORITHM_ECDSA
@ SYMCRYPT_SELFTEST_ALGORITHM_MLDSA
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA1_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA384_EXPANDED_KEY
PSYMCRYPT_INT piCrtPrivExps[SYMCRYPT_RSAKEY_MAX_NUMOF_PUBEXPS *SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES]
struct _SYMCRYPT_OID SYMCRYPT_OID
UINT32 cbTotalSize
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA224_EXPANDED_KEY
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_COMPOSITE_MLKEMKEY
enum _SYMCRYPT_SELFTEST_ALGORITHM SYMCRYPT_SELFTEST_ALGORITHM
const SYMCRYPT_RC2_EXPANDED_KEY * PCSYMCRYPT_RC2_EXPANDED_KEY
* PSYMCRYPT_DESX_EXPANDED_KEY
const SYMCRYPT_HMAC_EXPANDED_KEY * PCSYMCRYPT_HMAC_EXPANDED_KEY
SYMCRYPT_MAGIC_FIELD SYMCRYPT_SHA3_384_STATE
#define SYMCRYPT_CALL
int8_t INT8
UINT64 au64PubExp[SYMCRYPT_RSAKEY_MAX_NUMOF_PUBEXPS]
PSYMCRYPT_PARALLEL_HASH_RESULT_FUNC parResult2Func
struct _SYMCRYPT_COMPOSITE_MLKEMKEY SYMCRYPT_COMPOSITE_MLKEMKEY
const SYMCRYPT_MODELEMENT * PCSYMCRYPT_MODELEMENT
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_GCM_STATE
SYMCRYPT_SESSION
SYMCRYPT_SESSION_REPLAY_STATE
const SYMCRYPT_LMS_PARAMS * PCSYMCRYPT_LMS_PARAMS
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_DLGROUP
SYMCRYPT_MAGIC_FIELD SYMCRYPT_DLGROUP
UINT32 HighBitRestrictionPosition
const SYMCRYPT_SSHKDF_EXPANDED_KEY * PCSYMCRYPT_SSHKDF_EXPANDED_KEY
UINT32 cbHashOutput
const SYMCRYPT_MARVIN32_EXPANDED_SEED * PCSYMCRYPT_MARVIN32_EXPANDED_SEED
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_KMAC128_STATE
PSYMCRYPT_ECPOINT poPWE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA256_STATE
const SYMCRYPT_ECPOINT * PCSYMCRYPT_ECPOINT
struct _SYMCRYPT_SSHKDF_EXPANDED_KEY SYMCRYPT_SSHKDF_EXPANDED_KEY
#define SYMCRYPT_SHA512_256_OID_COUNT
SYMCRYPT_COMMON_HASH_STATE
UINT64 messageNumber
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA3_224_STATE
SYMCRYPT_SHA512_256_STATE
BYTE * PBYTE
const SYMCRYPT_SHA512_256_STATE * PCSYMCRYPT_SHA512_256_STATE
VOID(SYMCRYPT_CALL * PSYMCRYPT_HASH_APPEND_BLOCKS_FUNC)(PVOID pChain, PCBYTE pbData, SIZE_T cbData, SIZE_T *pcbRemaining)
#define SYMCRYPT_GCM_BLOCK_SIZE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_DESX_EXPANDED_KEY
UINT32 chainSize
union _SYMCRYPT_HASH_STATE SYMCRYPT_HASH_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_RNG_AES_FIPS140_2_STATE
PCSYMCRYPT_OID SYMCRYPT_CALL SymCryptGetOidList(SYMCRYPT_OID_LIST_ID oidId, _Out_opt_ SIZE_T *pCount)
* PSYMCRYPT_SHA1_STATE
struct _SYMCRYPT_SRTPKDF_EXPANDED_KEY SYMCRYPT_SRTPKDF_EXPANDED_KEY
UINT32 SYMCRYPT_CALL SymCryptDeprecatedStatusIndicator(PBYTE pbOutput, UINT32 cbOutput)
SYMCRYPT_MAGIC_FIELD SYMCRYPT_KMAC128_STATE
#define SYMCRYPT_MD5_OID_COUNT
_SYMCRYPT_SI_TYPE
@ SYMCRYPT_SI_TYPE_INTPAIR
@ SYMCRYPT_SI_TYPE_INTRANGE
@ SYMCRYPT_SI_TYPE_MAX
@ SYMCRYPT_SI_TYPE_CIPHER
@ SYMCRYPT_SI_TYPE_KAS_SCHEME
@ SYMCRYPT_SI_TYPE_SIZERANGE
@ SYMCRYPT_SI_TYPE_SAFE_PRIME_GROUP
@ SYMCRYPT_SI_TYPE_KEM
@ SYMCRYPT_SI_TYPE_DRBG
@ SYMCRYPT_SI_TYPE_ASYM_ALG
@ SYMCRYPT_SI_TYPE_MAC
@ SYMCRYPT_SI_TYPE_KDF
@ SYMCRYPT_SI_TYPE_ECURVE
@ SYMCRYPT_SI_TYPE_KAS
@ SYMCRYPT_SI_TYPE_HASH
struct _SYMCRYPT_ECPOINT SYMCRYPT_ECPOINT
struct _SYMCRYPT_SSKDF_MAC_EXPANDED_SALT SYMCRYPT_SSKDF_MAC_EXPANDED_SALT
SYMCRYPT_DIVISOR Divisor
* PSYMCRYPT_HMAC_SHA3_384_STATE
BYTE counter
BOOLEAN fPrivateModQ
PSYMCRYPT_MODULUS pmModulus
UINT32 nByteStringCount
SYMCRYPT_SHA256_STATE
struct _SYMCRYPT_TLSPRF1_2_EXPANDED_KEY * PSYMCRYPT_TLSPRF1_2_EXPANDED_KEY
const SYMCRYPT_HMAC_SHA3_224_STATE * PCSYMCRYPT_HMAC_SHA3_224_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_POLY1305_STATE
#define SYMCRYPT_SHA3_224_OID_COUNT
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_3DES_EXPANDED_KEY
const SYMCRYPT_AES_CMAC_EXPANDED_KEY * PCSYMCRYPT_AES_CMAC_EXPANDED_KEY
const SYMCRYPT_CSHAKE128_STATE * PCSYMCRYPT_CSHAKE128_STATE
struct _SYMCRYPT_SP800_108_EXPANDED_KEY SYMCRYPT_SP800_108_EXPANDED_KEY
const SYMCRYPT_MLDSAKEY * PCSYMCRYPT_MLDSAKEY
PCBYTE pbKey
UINT64 cbAuthData
const SYMCRYPT_SHA3_224_STATE * PCSYMCRYPT_SHA3_224_STATE
struct _SYMCRYPT_HASH SYMCRYPT_HASH
UINT32 SymCryptTestTrialdivisionMaxSmallPrime(PCSYMCRYPT_TRIALDIVISION_CONTEXT pContext)
VOID(SYMCRYPT_CALL * PSYMCRYPT_PARALLEL_APPEND_FUNC)(_Inout_updates_(nPar) PSYMCRYPT_PARALLEL_HASH_SCRATCH_STATE *pWork, SIZE_T nPar, SIZE_T nBytes, _Out_writes_(cbSimdScratch) PBYTE pbSimdScratch, SIZE_T cbSimdScratch)
SYMCRYPT_DLGROUP_FIPS eFipsStandard
UINT32 len2
UINT32 k
SYMCRYPT_HMAC_SHA3_256_STATE
* PSYMCRYPT_KECCAK_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA512_256_EXPANDED_KEY
const SYMCRYPT_SESSION_REPLAY_STATE * PCSYMCRYPT_SESSION_REPLAY_STATE
int64_t * PINT64
const SYMCRYPT_SHA384_STATE * PCSYMCRYPT_SHA384_STATE
const SYMCRYPT_ECKEY * PCSYMCRYPT_ECKEY
FORCEINLINE VOID SYMCRYPT_CALL SymCryptWipeKnownSize(_Out_writes_bytes_(cbData) PVOID pbData, SIZE_T cbData)
const SYMCRYPT_TRIALDIVISION_GROUP * PCSYMCRYPT_TRIALDIVISION_GROUP
* PSYMCRYPT_MD5_CHAINING_STATE
struct _SYMCRYPT_PARALLEL_HASH * PSYMCRYPT_PARALLEL_HASH
struct _SYMCRYPT_TRIALDIVISION_PRIME SYMCRYPT_TRIALDIVISION_PRIME
int64_t INT64
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_STATE
SYMCRYPT_KECCAK_STATE
const SYMCRYPT_OID * PCSYMCRYPT_OID
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA1_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_MARVIN32_EXPANDED_SEED
struct _SYMCRYPT_SSHKDF_EXPANDED_KEY * PSYMCRYPT_SSHKDF_EXPANDED_KEY
void * PVOID
int32_t INT32
BYTE BOOLEAN
VOID(SYMCRYPT_CALL * PSYMCRYPT_MAC_RESULT)(PVOID pState, PVOID pbResult)
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA3_512_EXPANDED_KEY
const SYMCRYPT_GF128_ELEMENT * PCSYMCRYPT_GF128_ELEMENT
UINT32 nDefaultBitsPriv
const SYMCRYPT_TLSPRF1_1_EXPANDED_KEY * PCSYMCRYPT_TLSPRF1_1_EXPANDED_KEY
const SYMCRYPT_OID SymCryptSha3_224OidList[SYMCRYPT_SHA3_224_OID_COUNT]
Definition: rsa_padding.c:67
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA512_256_EXPANDED_KEY
VOID(SYMCRYPT_CALL * PSYMCRYPT_MAC_APPEND)(PVOID pState, PCBYTE pbData, SIZE_T cbData)
BYTE bIndexGenG
SYMCRYPT_SHA256_CHAINING_STATE
SYMCRYPT_MODELEMENT * PSYMCRYPT_MODELEMENT
#define SYMCRYPT_SHA3_256_OID_COUNT
#define SYMCRYPT_ALIGN_UNION
const SYMCRYPT_OID SymCryptMd5OidList[SYMCRYPT_MD5_OID_COUNT]
Definition: rsa_padding.c:19
uint16_t * PUINT16
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA512_256_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_RSAKEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA512_224_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_MD5_EXPANDED_KEY
const SYMCRYPT_OID SymCryptSha3_384OidList[SYMCRYPT_SHA3_384_OID_COUNT]
Definition: rsa_padding.c:79
struct _SYMCRYPT_TRIALDIVISION_CONTEXT SYMCRYPT_TRIALDIVISION_CONTEXT
union _SYMCRYPT_MAC_EXPANDED_KEY SYMCRYPT_MAC_EXPANDED_KEY
const UINT64 * PCUINT64
const SYMCRYPT_HMAC_SHA384_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA384_EXPANDED_KEY
UINT64 inv64
VOID SYMCRYPT_CALL SymCryptWipe(_Out_writes_bytes_(cbData) PVOID pbData, SIZE_T cbData)
Definition: libmain.c:137
SYMCRYPT_HMAC_SHA3_384_EXPANDED_KEY
#define SYMCRYPT_FDEF_UPB_DIGITS
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_SHA3_224_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_RC4_STATE
const SYMCRYPT_HMAC_SHA512_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA512_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA3_384_EXPANDED_KEY
UINT32 cbPrefix
struct _SYMCRYPT_PBKDF2_EXPANDED_KEY * PSYMCRYPT_PBKDF2_EXPANDED_KEY
const SYMCRYPT_OID SymCryptShake256OidList[SYMCRYPT_SHAKE256_OID_COUNT]
Definition: rsa_padding.c:97
const SYMCRYPT_HMAC_SHA512_256_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA512_256_EXPANDED_KEY
#define SYMCRYPT_ALIGN_VALUE
const SYMCRYPT_HMAC_SHA256_STATE * PCSYMCRYPT_HMAC_SHA256_STATE
SYMCRYPT_INTERNAL_ECURVE_TYPE type
SYMCRYPT_HMAC_SHA3_512_EXPANDED_KEY
BYTE(* lastDecRoundKey)[4][4]
#define SYMCRYPT_SHAKE256_OID_COUNT
SYMCRYPT_MAGIC_FIELD SYMCRYPT_SHAKE256_STATE
const SYMCRYPT_HMAC_SHA384_STATE * PCSYMCRYPT_HMAC_SHA384_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA224_STATE
#define SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES
const SYMCRYPT_OID SymCryptSha384OidList[SYMCRYPT_SHA384_OID_COUNT]
Definition: rsa_padding.c:43
SYMCRYPT_MLKEMKEY * PSYMCRYPT_MLKEMKEY
SYMCRYPT_MD5_CHAINING_STATE outerState
#define SYMCRYPT_MAX_BLOCK_SIZE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA384_STATE
#define SYMCRYPT_INTERNAL_FORCE_WRITE64(_p, _v)
UINT32 FModBytesize
SYMCRYPT_ECURVE_INFO_PRECOMP sw
union _SYMCRYPT_MAC_EXPANDED_KEY * PSYMCRYPT_MAC_EXPANDED_KEY
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_MARVIN32_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_MD5_STATE
SIZE_T bytesInBuffer
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_AES_CMAC_STATE
PBYTE pbCrtInverses[SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES]
PSYMCRYPT_MODELEMENT peMask
struct _SYMCRYPT_MLDSAKEY SYMCRYPT_MLDSAKEY
const SYMCRYPT_HMAC_SHA3_224_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA3_224_EXPANDED_KEY
const SYMCRYPT_HMAC_SHA512_224_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA512_224_EXPANDED_KEY
const SYMCRYPT_HMAC_SHA224_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA224_EXPANDED_KEY
SYMCRYPT_ALIGN BYTE macBlock[SYMCRYPT_CCM_BLOCK_SIZE]
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_AES_CMAC_STATE
UINT32 parScratchFixed
BOOLEAN squeezeMode
BYTE(* lastEncRoundKey)[4][4]
PSYMCRYPT_INT H
const SYMCRYPT_KMAC128_EXPANDED_KEY * PCSYMCRYPT_KMAC128_EXPANDED_KEY
PCSYMCRYPT_ECURVE pCurve
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA512_EXPANDED_KEY
UINT32 nBitsOfP
const SYMCRYPT_DES_EXPANDED_KEY * PCSYMCRYPT_DES_EXPANDED_KEY
SYMCRYPT_MAGIC_FIELD SYMCRYPT_CCM_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA3_256_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_KECCAK_STATE
SYMCRYPT_SHA512_STATE
SYMCRYPT_SHA512_CHAINING_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHAKE128_STATE
#define SYMCRYPT_SHA384_OID_COUNT
struct _SYMCRYPT_BLOCKCIPHER * PSYMCRYPT_BLOCKCIPHER
* PSYMCRYPT_DES_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_3DES_EXPANDED_KEY
BYTE K2[16]
union @5240 info
#define SYMCRYPT_CCM_BLOCK_SIZE
SYMCRYPT_XTS_AES_EXPANDED_KEY
const SYMCRYPT_SSKDF_MAC_EXPANDED_SALT * PCSYMCRYPT_SSKDF_MAC_EXPANDED_SALT
PCBYTE SIZE_T cbKey
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA224_STATE
UINT32 nMinBitsPriv
const SYMCRYPT_MAC_STATE * PCSYMCRYPT_MAC_STATE
* PSYMCRYPT_SESSION
struct _SYMCRYPT_TRIALDIVISION_GROUP * PSYMCRYPT_TRIALDIVISION_GROUP
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA512_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_KMAC256_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA3_256_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_SHA3_384_STATE
UINT32 HighBitRestrictionNumOfBits
UINT32 nMaxDigitsOfPrimes
#define SYMCRYPT_ASYM_ALIGN
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA512_256_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_802_11_SAE_CUSTOM_STATE
struct _SYMCRYPT_SRTPKDF_EXPANDED_KEY * PSYMCRYPT_SRTPKDF_EXPANDED_KEY
const SYMCRYPT_CSHAKE256_STATE * PCSYMCRYPT_CSHAKE256_STATE
SYMCRYPT_ALIGN_UNION _SYMCRYPT_GF128_ELEMENT
* PSYMCRYPT_MD4_CHAINING_STATE
BYTE SYMCRYPT_RC4_S_TYPE
SIZE_T bytesInBuf
struct _SYMCRYPT_HKDF_EXPANDED_KEY * PSYMCRYPT_HKDF_EXPANDED_KEY
struct @5239::@5243 montgomery
uint32_t * PUINT32
const SYMCRYPT_SHA3_256_STATE * PCSYMCRYPT_SHA3_256_STATE
UINT32 cbPrimeP
const SYMCRYPT_DIVISOR * PCSYMCRYPT_DIVISOR
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA512_STATE
VOID(SYMCRYPT_CALL * PSYMCRYPT_HASH_STATE_COPY_FUNC)(PCVOID pStateSrc, PVOID pStateDst)
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA512_CHAINING_STATE
BOOLEAN fHasPrivateKey
UINT32 flags
* PSYMCRYPT_XTS_AES_EXPANDED_KEY
SYMCRYPT_XMSS_KEY * PSYMCRYPT_XMSS_KEY
SYMCRYPT_MAGIC_FIELD SYMCRYPT_ECKEY
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_DIVISOR
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA224_STATE
SYMCRYPT_MD2_STATE
#define SYMCRYPT_SHA512_224_OID_COUNT
int8_t * PINT8
const SYMCRYPT_HMAC_SHA3_384_STATE * PCSYMCRYPT_HMAC_SHA3_384_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_SHA3_256_STATE
const SYMCRYPT_HKDF_EXPANDED_KEY * PCSYMCRYPT_HKDF_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_GCM_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA256_STATE
struct _SYMCRYPT_TRIALDIVISION_PRIME * PSYMCRYPT_TRIALDIVISION_PRIME
SYMCRYPT_RSAKEY * PSYMCRYPT_RSAKEY
uint64_t * PUINT64
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_KMAC256_EXPANDED_KEY
PCUINT32 Rsqr
const SYMCRYPT_HMAC_SHA3_256_STATE * PCSYMCRYPT_HMAC_SHA3_256_STATE
BYTE processingState
SYMCRYPT_LMS_PARAMS * PSYMCRYPT_LMS_PARAMS
SYMCRYPT_MAGIC_FIELD SYMCRYPT_MARVIN32_STATE
#define SYMCRYPT_INTERNAL_FORCE_WRITE32(_p, _v)
SYMCRYPT_HMAC_SHA3_512_STATE
const SYMCRYPT_AES_EXPANDED_KEY * PCSYMCRYPT_AES_EXPANDED_KEY
UINT8 paddingValue
SYMCRYPT_DLKEY * PSYMCRYPT_DLKEY
UINT32 nBitsOfSeed
UINT64 W
BOOLEAN keystreamBufferValid
const SYMCRYPT_PARALLEL_HASH * PCSYMCRYPT_PARALLEL_HASH
PCSYMCRYPT_BLOCKCIPHER pBlockCipher
SYMCRYPT_MD4_STATE
struct _SYMCRYPT_INT SYMCRYPT_INT
UINT32 SYMCRYPT_CPU_FEATURES
PSYMCRYPT_PARALLEL_APPEND_FUNC parAppendFunc
BYTE i
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_CSHAKE256_STATE
SYMCRYPT_COMPOSITE_MLKEMKEY * PSYMCRYPT_COMPOSITE_MLKEMKEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA384_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA512_256_EXPANDED_KEY
BYTE outputWhitening[8]
SYMCRYPT_ALIGN_SESSION _SYMCRYPT_SESSION_REPLAY_STATE
#define SYMCRYPT_GF128_FIELD_SIZE
const SYMCRYPT_OID SymCryptSha512OidList[SYMCRYPT_SHA512_OID_COUNT]
Definition: rsa_padding.c:49
const SYMCRYPT_HASH * PCSYMCRYPT_HASH
UINT64 bytes
const SYMCRYPT_COMPOSITE_MLKEMKEY * PCSYMCRYPT_COMPOSITE_MLKEMKEY
struct @5237::@5241 fdef
PBYTE pbPrivExps[SYMCRYPT_RSAKEY_MAX_NUMOF_PUBEXPS]
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_RC2_EXPANDED_KEY
PCSYMCRYPT_HASH pLmsHashFunction
struct _SYMCRYPT_HASH * PSYMCRYPT_HASH
SYMCRYPT_GCM_SUPPORTED_BLOCKCIPHER_KEYS blockcipherKey
UINT32 nBits
UINT64 requestCounter
struct @5239::@5244 pseudoMersenne
UINT32 len1
* PSYMCRYPT_MD5_STATE
struct _SYMCRYPT_TLSPRF1_1_EXPANDED_KEY SYMCRYPT_TLSPRF1_1_EXPANDED_KEY
BOOLEAN fHasPrimeQ
UINT32 nBitsOfQ
* PSYMCRYPT_GF128_ELEMENT
#define SYMCRYPT_ANYSIZE
#define SYMCRYPT_SHA3_384_OID_COUNT
UINT32 g_SymCryptFipsSelftestsPerformed
Definition: implglue.c:61
UINT32 cbPrimeQ
PCBYTE PBYTE SIZE_T cbData
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_RC4_STATE
SYMCRYPT_XMSS_PARAMS * PSYMCRYPT_XMSS_PARAMS
SYMCRYPT_MD2_CHAINING_STATE chain
#define FORCEINLINE
UINT32 nMaxBitsOfQ
UINT32 nPrimes
UINT32 nLeftShift32
const SYMCRYPT_OID SymCryptSha3_256OidList[SYMCRYPT_SHA3_256_OID_COUNT]
Definition: rsa_padding.c:73
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA384_EXPANDED_KEY
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_ECPOINT
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_STATE
struct _SYMCRYPT_TRIALDIVISION_GROUP SYMCRYPT_TRIALDIVISION_GROUP
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_SHAKE128_STATE
PSYMCRYPT_PARALLEL_HASH_RESULT_DONE_FUNC parResultDoneFunc
SYMCRYPT_HMAC_SHA3_224_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA384_STATE
BYTE previousBlock[16]
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_CSHAKE128_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_PARALLEL_HASH_SCRATCH_STATE
SYMCRYPT_DES_EXPANDED_KEY
SYMCRYPT_CPU_FEATURES g_SymCryptCpuFeaturesNotPresent
Definition: libmain.c:20
SYMCRYPT_MAGIC_FIELD SYMCRYPT_3DES_EXPANDED_KEY
PBYTE pbCrtPrivExps[SYMCRYPT_RSAKEY_MAX_NUMOF_PUBEXPS *SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES]
SYMCRYPT_SHA224_STATE
PCSYMCRYPT_MARVIN32_EXPANDED_SEED pSeed
SYMCRYPT_MD4_CHAINING_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_CCM_STATE
const SYMCRYPT_RSAKEY * PCSYMCRYPT_RSAKEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA512_224_EXPANDED_KEY
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA256_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_XTS_AES_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA3_224_EXPANDED_KEY
const SYMCRYPT_AES_CMAC_STATE * PCSYMCRYPT_AES_CMAC_STATE
UINT32 nLayerHeight
enum _SYMCRYPT_ECPOINT_COORDINATES SYMCRYPT_ECPOINT_COORDINATES
SYMCRYPT_MD2_CHAINING_STATE
const SYMCRYPT_OID SymCryptSha512_256OidList[SYMCRYPT_SHA512_256_OID_COUNT]
Definition: rsa_padding.c:61
const SYMCRYPT_HMAC_MD5_STATE * PCSYMCRYPT_HMAC_MD5_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_RNG_AES_STATE
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_ECURVE
struct _SYMCRYPT_OID * PSYMCRYPT_OID
SYMCRYPT_HASH_STATE innerState
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_EXPANDED_KEY
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA1_STATE
UINT32 nTotalTreeHeight
SYMCRYPT_GHASH_EXPANDED_KEY
PCBYTE PBYTE pbDst
const SYMCRYPT_DESX_EXPANDED_KEY * PCSYMCRYPT_DESX_EXPANDED_KEY
* PSYMCRYPT_SESSION_REPLAY_STATE
const SYMCRYPT_HMAC_SHA512_224_STATE * PCSYMCRYPT_HMAC_SHA512_224_STATE
UINT32 nLayers
UINT32 resultSize
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA1_STATE
const SYMCRYPT_LMS_KEY * PCSYMCRYPT_LMS_KEY
SYMCRYPT_LMS_PARAMS
SYMCRYPT_MAGIC_FIELD SYMCRYPT_RNG_AES_STATE
#define VOID
const SYMCRYPT_KMAC256_EXPANDED_KEY * PCSYMCRYPT_KMAC256_EXPANDED_KEY
const SYMCRYPT_XMSS_KEY * PCSYMCRYPT_XMSS_KEY
_SYMCRYPT_HASH_OPERATION_TYPE
@ SYMCRYPT_HASH_OPERATION_RESULT
@ SYMCRYPT_HASH_OPERATION_APPEND
PSYMCRYPT_MODULUS FMod
VOID(SYMCRYPT_CALL * PSYMCRYPT_HASH_APPEND_FUNC)(PVOID pState, PCBYTE pbData, SIZE_T cbData)
PSYMCRYPT_MODELEMENT pePublicKey
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_KMAC128_STATE
UINT32 nBitsOfModulus
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_MLKEMKEY
SYMCRYPT_MAGIC_FIELD SYMCRYPT_SHA3_512_STATE
const SYMCRYPT_3DES_EXPANDED_KEY * PCSYMCRYPT_3DES_EXPANDED_KEY
const SYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY
SYMCRYPT_ALIGN_SESSION _SYMCRYPT_SESSION
UINT32 SYMCRYPT_CALL SymCryptDeprecatedServiceIndicator(UINT32 Service, UINT64 Alg, UINT64 Param1, UINT64 Param2, UINT64 Param3)
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_AES_CMAC_EXPANDED_KEY
const SYMCRYPT_HMAC_SHA1_STATE * PCSYMCRYPT_HMAC_SHA1_STATE
* PSYMCRYPT_HMAC_SHA3_512_STATE
struct _SYMCRYPT_PARALLEL_HASH SYMCRYPT_PARALLEL_HASH
SYMCRYPT_MAGIC_FIELD SYMCRYPT_AES_EXPANDED_KEY
const SYMCRYPT_PARALLEL_HASH_OPERATION * PCSYMRYPT_PARALLEL_HASH_OPERATION
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA512_STATE
const SYMCRYPT_HMAC_SHA3_512_STATE * PCSYMCRYPT_HMAC_SHA3_512_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_SHA3_512_STATE
const SYMCRYPT_HMAC_SHA512_256_STATE * PCSYMCRYPT_HMAC_SHA512_256_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_MD4_STATE
UINT32 nDigitsOfPrimes[SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES]
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_EXPANDED_KEY
SYMCRYPT_MAGIC_FIELD SYMCRYPT_RC2_EXPANDED_KEY
PVOID pMutex
SIZE_T cbNonce
int16_t * PINT16
void __cpuidex(int CPUInfo[4], int InfoType, int ECXValue)
Definition: intrin_x86.h:1680
#define SYMCRYPT_SHA512_OID_COUNT
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA3_384_STATE
VOID(SYMCRYPT_CALL * PSYMCRYPT_HASH_RESULT_FUNC)(PVOID pState, PVOID pbResult)
SYMCRYPT_LMS_KEY * PSYMCRYPT_LMS_KEY
PSYMCRYPT_INT piPrivateKey
UINT32 id
SYMCRYPT_MAGIC_FIELD SYMCRYPT_CSHAKE256_STATE
const SYMCRYPT_OID SymCryptSha224OidList[SYMCRYPT_SHA224_OID_COUNT]
Definition: rsa_padding.c:31
SYMCRYPT_MAGIC_FIELD union @5239 tm
PCSYMCRYPT_HMAC_MD5_EXPANDED_KEY pKey
UINT32 cbModElement
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_KMAC256_STATE
const SYMCRYPT_SHA3_512_STATE * PCSYMCRYPT_SHA3_512_STATE
#define SYMCRYPT_SHA3_512_OID_COUNT
PSYMCRYPT_PARALLEL_HASH_OPERATION next
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA3_384_STATE
UINT32 cbSize
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_MD5_EXPANDED_KEY
* PSYMCRYPT_HMAC_SHA3_224_STATE
PSYMCRYPT_ECPOINT G
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_SHA3_256_STATE
struct _SYMCRYPT_TLSPRF1_1_EXPANDED_KEY * PSYMCRYPT_TLSPRF1_1_EXPANDED_KEY
SYMCRYPT_DLGROUP * PSYMCRYPT_DLGROUP
uint64_t UINT64
UINT32 PrivateKeyDefaultFormat
const SYMCRYPT_GHASH_EXPANDED_KEY * PCSYMCRYPT_GHASH_EXPANDED_KEY
* PSYMCRYPT_SHA512_STATE
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_INT
* PSYMCRYPT_SHA256_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA224_STATE
const SYMCRYPT_HMAC_MD5_EXPANDED_KEY * PCSYMCRYPT_HMAC_MD5_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA512_256_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_MD5_STATE
SYMCRYPT_AES_EXPANDED_KEY key2
PSYMCRYPT_MODULUS GOrd
UINT32 cbAlloc
SYMCRYPT_MAGIC_FIELD SYMCRYPT_SHAKE128_STATE
UINT32 nWinternitzChainWidth
#define SYMCRYPT_FIELD_OFFSET(type, field)
UINT32 coFactorPower
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_COMMON_HASH_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_CSHAKE128_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_AES_EXPANDED_KEY
PSYMCRYPT_MODULUS pmQ
const void * PCVOID
struct _SYMCRYPT_PBKDF2_EXPANDED_KEY SYMCRYPT_PBKDF2_EXPANDED_KEY
* PSYMCRYPT_COMMON_HASH_STATE
const SYMCRYPT_MAC * PCSYMCRYPT_MAC
PSYMCRYPT_MODELEMENT peCrtInverses[SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES]
int32_t * PINT32
const SYMCRYPT_TRIALDIVISION_CONTEXT * PCSYMCRYPT_TRIALDIVISION_CONTEXT
UINT32 GOrdBytesize
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_MD4_CHAINING_STATE
SYMCRYPT_HMAC_SHA3_384_STATE
UINT32 cbSeed
SYMCRYPT_ALIGN BYTE keystreamBlock[SYMCRYPT_CCM_BLOCK_SIZE]
PSYMCRYPT_PARALLEL_HASH_RESULT_FUNC parResult1Func
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA256_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_CHACHA20_STATE
#define SYMCRYPT_MAGIC_FIELD
* PSYMCRYPT_CHACHA20_STATE
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_MODELEMENT
PBYTE pbPrimes[SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES]
const SYMCRYPT_GCM_EXPANDED_KEY * PCSYMCRYPT_GCM_EXPANDED_KEY
const SYMCRYPT_HMAC_SHA3_512_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA3_512_EXPANDED_KEY
UINT64 dataLengthH
SYMCRYPT_SHA384_STATE
* PSYMCRYPT_MD2_CHAINING_STATE
* PSYMCRYPT_SHA384_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA512_256_STATE
const SYMCRYPT_INT * PCSYMCRYPT_INT
SIZE_T cbCounter
* PSYMCRYPT_RNG_AES_FIPS140_2_STATE
struct _SYMCRYPT_TRIALDIVISION_CONTEXT * PSYMCRYPT_TRIALDIVISION_CONTEXT
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_KMAC128_EXPANDED_KEY
const SYMCRYPT_KMAC256_STATE * PCSYMCRYPT_KMAC256_STATE
const SYMCRYPT_MARVIN32_STATE * PCSYMCRYPT_MARVIN32_STATE
UINT32 cbScratchGetSetValue
SYMCRYPT_MAGIC_FIELD SYMCRYPT_ASYM_ALIGN union @5237 ti
struct _SYMCRYPT_DIVISOR SYMCRYPT_DIVISOR
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_MODULUS
uint8_t BYTE
SYMCRYPT_ERROR(SYMCRYPT_CALL * PSYMCRYPT_MAC_EXPAND_KEY)(PVOID pExpandedKey, PCBYTE pbKey, SIZE_T cbKey)
struct _SYMCRYPT_ECURVE_INFO_PRECOMP SYMCRYPT_ECURVE_INFO_PRECOMP
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_GCM_EXPANDED_KEY
UINT32 cbScratchScalarMulti
UINT32 inputBlockSize
* PSYMCRYPT_HMAC_SHA3_256_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_KMAC256_EXPANDED_KEY
_SYMCRYPT_OID_LIST_ID
@ SYMCRYPT_OID_LIST_ID_MD5
@ SYMCRYPT_OID_LIST_ID_SHA3_224
@ SYMCRYPT_OID_LIST_ID_SHA224
@ SYMCRYPT_OID_LIST_ID_SHAKE128
@ SYMCRYPT_OID_LIST_ID_SHA256
@ SYMCRYPT_OID_LIST_ID_SHA512
@ SYMCRYPT_OID_LIST_ID_SHA3_384
@ SYMCRYPT_OID_LIST_ID_SHA512_224
@ SYMCRYPT_OID_LIST_ID_SHA3_512
@ SYMCRYPT_OID_LIST_ID_SHA3_256
@ SYMCRYPT_OID_LIST_ID_SHA384
@ SYMCRYPT_OID_LIST_ID_SHA1
@ SYMCRYPT_OID_LIST_ID_SHA512_256
@ SYMCRYPT_OID_LIST_ID_NULL
@ SYMCRYPT_OID_LIST_ID_SHAKE256
SYMCRYPT_GF128_ELEMENT ghashState
SYMCRYPT_CHACHA20_STATE
UINT64 bytesProcessed
const SYMCRYPT_HMAC_SHA512_STATE * PCSYMCRYPT_HMAC_SHA512_STATE
SYMCRYPT_SHA1_STATE
const UINT16 * PCUINT16
UINT32 nSetBitsOfModulus
UINT32 nMaxBitsOfP
* PSYMCRYPT_HMAC_SHA3_224_EXPANDED_KEY
const SYMCRYPT_MD2_STATE * PCSYMCRYPT_MD2_STATE
UINT32 nBitsOfPrimes[SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES]
BOOLEAN isSafePrimeGroup
struct _SYMCRYPT_MODELEMENT SYMCRYPT_MODELEMENT
SYMCRYPT_MAGIC_FIELD union @5238 td
UINT32 cbIdx
SYMCRYPT_GF128_ELEMENT
struct _SYMCRYPT_PARALLEL_HASH_OPERATION * PSYMCRYPT_PARALLEL_HASH_OPERATION
SYMCRYPT_MARVIN32_EXPANDED_SEED SYMCRYPT_MARVIN32_CHAINING_STATE
UINT32 GOrdBitsize
SYMCRYPT_SHA512_224_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_KMAC128_EXPANDED_KEY
UINT32 nDigitsOfQ
PBYTE pbQ
union _SYMCRYPT_MAC_STATE SYMCRYPT_MAC_STATE
UINT32 stateSize
UINT32 len
const SYMCRYPT_DLKEY * PCSYMCRYPT_DLKEY
PSYMCRYPT_MODELEMENT A
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA512_224_STATE
const SYMCRYPT_MAC_EXPANDED_KEY * PCSYMCRYPT_MAC_EXPANDED_KEY
const SYMCRYPT_SHAKE128_STATE * PCSYMCRYPT_SHAKE128_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_XMSS_PARAMS
UINT32 nTreeHeight
PSYMCRYPT_ECPOINT poPublicKey
SYMCRYPT_ECPOINT * PSYMCRYPT_ECPOINT
PSYMCRYPT_COMMON_HASH_STATE pState
const SYMCRYPT_HMAC_SHA1_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA1_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA3_512_STATE
UINT32 nPubExp
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA384_STATE
struct _SYMCRYPT_MAC * PSYMCRYPT_MAC
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA512_EXPANDED_KEY
const SYMCRYPT_SHA256_STATE * PCSYMCRYPT_SHA256_STATE
const SYMCRYPT_MD5_STATE * PCSYMCRYPT_MD5_STATE
SYMCRYPT_INT Int
UINT32 dataLength
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA256_STATE
VOID(SYMCRYPT_CALL * PSYMCRYPT_MAC_RESULT_EX)(PVOID pState, PVOID pbResult, SIZE_T cbResult)
#define SYMCRYPT_RSAKEY_MAX_NUMOF_PUBEXPS
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_MD2_CHAINING_STATE
#define SYMCRYPT_INTERNAL_FORCE_WRITE16(_p, _v)
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA512_224_STATE
#define SYMCRYPT_ALIGN_SESSION
PSYMCRYPT_MODULUS pmP
const SYMCRYPT_SHA224_STATE * PCSYMCRYPT_SHA224_STATE
const BYTE * PCBYTE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_RC4_STATE
UINT32 nDigitsOfModulus
SYMCRYPT_MLDSAKEY * PSYMCRYPT_MLDSAKEY
#define SYMCRYPT_INTERNAL_FORCE_WRITE8(_p, _v)
SYMCRYPT_MAGIC_FIELD SYMCRYPT_GCM_EXPANDED_KEY
const SYMCRYPT_MODULUS * PCSYMCRYPT_MODULUS
const SYMCRYPT_HMAC_SHA224_STATE * PCSYMCRYPT_HMAC_SHA224_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_KMAC256_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA1_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_CCM_STATE
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_RSAKEY
UINT32 senderId
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA256_CHAINING_STATE
enum _SYMCRYPT_HASH_OPERATION_TYPE SYMCRYPT_HASH_OPERATION_TYPE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA1_CHAINING_STATE
SYMCRYPT_DIVISOR * PSYMCRYPT_DIVISOR
* PSYMCRYPT_SHA512_224_STATE
PSYMCRYPT_MODULUS pmPrimes[SYMCRYPT_RSAKEY_MAX_NUMOF_PRIMES]
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHA3_512_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_MD5_STATE
uint8_t * PUINT8
int16_t INT16
_SYMCRYPT_INTERNAL_ECURVE_TYPE
@ SYMCRYPT_INTERNAL_ECURVE_TYPE_TWISTED_EDWARDS
@ SYMCRYPT_INTERNAL_ECURVE_TYPE_SHORT_WEIERSTRASS_AM3
@ SYMCRYPT_INTERNAL_ECURVE_TYPE_SHORT_WEIERSTRASS
@ SYMCRYPT_INTERNAL_ECURVE_TYPE_MONTGOMERY
SYMCRYPT_MAGIC_FIELD SYMCRYPT_POLY1305_STATE
UINT32 cbScratchScalar
uint16_t UINT16
struct _SYMCRYPT_PARALLEL_HASH_SCRATCH_OPERATION * PSYMCRYPT_PARALLEL_HASH_SCRATCH_OPERATION
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA224_EXPANDED_KEY
PSYMCRYPT_MODELEMENT peG
const SYMCRYPT_OID SymCryptSha256OidList[SYMCRYPT_SHA256_OID_COUNT]
Definition: rsa_padding.c:37
UINT32 FModBitsize
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_CSHAKE128_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_SHAKE256_STATE
SYMCRYPT_HMAC_SHA3_224_STATE
BOOLEAN hasPrivateKey
* PSYMCRYPT_HMAC_SHA3_512_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA3_224_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_KMAC128_EXPANDED_KEY
SYMCRYPT_DESX_EXPANDED_KEY
SYMCRYPT_XMSS_PARAMS
const SYMCRYPT_OID SymCryptSha1OidList[SYMCRYPT_SHA1_OID_COUNT]
Definition: rsa_padding.c:25
const SYMCRYPT_HMAC_STATE * PCSYMCRYPT_HMAC_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_ECURVE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA512_STATE
UINT32 nChecksumLShiftBits
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_AES_EXPANDED_KEY
SYMCRYPT_MAGIC_FIELD SYMCRYPT_AES_CMAC_STATE
#define SYMCRYPT_ALIGN_STRUCT
SYMCRYPT_MAGIC_FIELD SYMCRYPT_AES_CMAC_EXPANDED_KEY
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_KMAC256_EXPANDED_KEY
BYTE inputWhitening[8]
const SYMCRYPT_KMAC128_STATE * PCSYMCRYPT_KMAC128_STATE
const UINT32 * PCUINT32
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_DLKEY
struct _SYMCRYPT_TLSPRF1_2_EXPANDED_KEY SYMCRYPT_TLSPRF1_2_EXPANDED_KEY
SYMCRYPT_HASH_STATE hash
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_RNG_AES_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_STATE
* PSYMCRYPT_SHA224_STATE
PCBYTE pbData
SYMCRYPT_ECKEY * PSYMCRYPT_ECKEY
struct _SYMCRYPT_LMS_KEY SYMCRYPT_LMS_KEY
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA256_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_GCM_EXPANDED_KEY
UINT32 HighBitRestrictionValue
BYTE K1[16]
SYMCRYPT_MAGIC_FIELD SYMCRYPT_GCM_STATE
UINT32 nWinternitzWidth
struct _SYMCRYPT_PARALLEL_HASH_SCRATCH_OPERATION SYMCRYPT_PARALLEL_HASH_SCRATCH_OPERATION
* PSYMCRYPT_MD4_STATE
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA256_EXPANDED_KEY
SYMCRYPT_MODULUS * PSYMCRYPT_MODULUS
enum _SYMCRYPT_OID_LIST_ID SYMCRYPT_OID_LIST_ID
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_AES_CMAC_EXPANDED_KEY
BOOLEAN(SYMCRYPT_CALL * PSYMCRYPT_PARALLEL_HASH_RESULT_FUNC)(PCSYMCRYPT_PARALLEL_HASH pParHash, PSYMCRYPT_COMMON_HASH_STATE pState, PSYMCRYPT_PARALLEL_HASH_SCRATCH_STATE pScratch, BOOLEAN *pRes)
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA512_224_STATE
BOOLEAN fips140_2Check
PSYMCRYPT_MODELEMENT peRand
struct _SYMCRYPT_SP800_108_EXPANDED_KEY * PSYMCRYPT_SP800_108_EXPANDED_KEY
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_SHA512_224_EXPANDED_KEY
size_t SIZE_T
UINT32 FModDigits
PSYMCRYPT_MODELEMENT B
SYMCRYPT_SHA1_CHAINING_STATE
BYTE bytesAlreadyProcessed
SYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY
union _SYMCRYPT_GCM_SUPPORTED_BLOCKCIPHER_KEYS SYMCRYPT_GCM_SUPPORTED_BLOCKCIPHER_KEYS
struct _SYMCRYPT_MAC SYMCRYPT_MAC
UINT32 GOrdDigits
const SYMCRYPT_SHA3_384_STATE * PCSYMCRYPT_SHA3_384_STATE
const SYMCRYPT_PBKDF2_EXPANDED_KEY * PCSYMCRYPT_PBKDF2_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY
BYTE j
const SYMCRYPT_XTS_AES_EXPANDED_KEY * PCSYMCRYPT_XTS_AES_EXPANDED_KEY
const SYMCRYPT_SP800_108_EXPANDED_KEY * PCSYMCRYPT_SP800_108_EXPANDED_KEY
uint32_t UINT32
const SYMCRYPT_HMAC_SHA3_384_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA3_384_EXPANDED_KEY
SYMCRYPT_INT * PSYMCRYPT_INT
const SYMCRYPT_OID SymCryptSha512_224OidList[SYMCRYPT_SHA512_224_OID_COUNT]
Definition: rsa_padding.c:55
* PSYMCRYPT_SHA256_CHAINING_STATE
union _SYMCRYPT_HASH_STATE * PSYMCRYPT_HASH_STATE
#define SYMCRYPT_ECURVE_SW_MAX_NPRECOMP_POINTS
SYMCRYPT_ECPOINT_COORDINATES eCoordinates
#define SYMCRYPT_SHA224_OID_COUNT
const SYMCRYPT_GCM_STATE * PCSYMCRYPT_GCM_STATE
UINT32 chainOffset
PSYMCRYPT_COMMON_HASH_STATE PCSYMRYPT_PARALLEL_HASH_OPERATION pOp
SYMCRYPT_RNG_AES_FIPS140_2_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_HMAC_MD5_EXPANDED_KEY
const SYMCRYPT_ECURVE * PCSYMCRYPT_ECURVE
SYMCRYPT_ECURVE * PSYMCRYPT_ECURVE
enum _SYMCRYPT_SI_TYPE SYMCRYPT_SI_TYPE
SYMCRYPT_ASYM_ALIGN_STRUCT _SYMCRYPT_ECKEY
UINT32 lmsOtsAlgID
UINT32 cbScratchCommon
struct _SYMCRYPT_MODULUS SYMCRYPT_MODULUS
UINT32 nBitsPriv
* PSYMCRYPT_HMAC_SHA3_384_EXPANDED_KEY
#define SYMCRYPT_SHA1_OID_COUNT
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_PARALLEL_HASH
VOID(SYMCRYPT_CALL * PSYMCRYPT_HASH_INIT_FUNC)(PVOID pState)
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_DES_EXPANDED_KEY
* PSYMCRYPT_PARALLEL_HASH_SCRATCH_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_SHA3_224_STATE
struct _SYMCRYPT_SSKDF_MAC_EXPANDED_SALT * PSYMCRYPT_SSKDF_MAC_EXPANDED_SALT
SYMCRYPT_CPU_FEATURES SYMCRYPT_CALL SymCryptCpuFeaturesNeverPresent(void)
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_LMS_PARAMS
PSYMCRYPT_HASH_APPEND_BLOCKS_FUNC appendBlockFunc
PSYMCRYPT_HASH_APPEND_FUNC appendFunc
SYMCRYPT_MAGIC_FIELD SYMCRYPT_DLKEY
SYMCRYPT_MAGIC_FIELD UINT64 dataLengthL
char CHAR
UINT32 nonce[3]
const SYMCRYPT_OID SymCryptShake128OidList[SYMCRYPT_SHAKE128_OID_COUNT]
Definition: rsa_padding.c:91
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_PARALLEL_HASH_SCRATCH_OPERATION
#define SYMCRYPT_SHAKE128_OID_COUNT
const SYMCRYPT_HASH_STATE * PCSYMCRYPT_HASH_STATE
const SYMCRYPT_MLKEMKEY * PCSYMCRYPT_MLKEMKEY
SYMCRYPT_MD5_CHAINING_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_CSHAKE256_STATE
VOID(SYMCRYPT_CALL * PSYMCRYPT_MAC_INIT)(PVOID pState, PCVOID pExpandedKey)
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_SHAKE256_STATE
SYMCRYPT_MARVIN32_EXPANDED_SEED * PSYMCRYPT_MARVIN32_CHAINING_STATE
SYMCRYPT_PARALLEL_HASH_SCRATCH_STATE
const SYMCRYPT_MD4_STATE * PCSYMCRYPT_MD4_STATE
const SYMCRYPT_SHA1_STATE * PCSYMCRYPT_SHA1_STATE
const SYMCRYPT_HMAC_SHA256_EXPANDED_KEY * PCSYMCRYPT_HMAC_SHA256_EXPANDED_KEY
const SYMCRYPT_SHA512_STATE * PCSYMCRYPT_SHA512_STATE
#define SYMCRYPT_SHA256_OID_COUNT
PCSYMCRYPT_MAC macAlgorithm
UINT32 nDigitsOfP
uint8_t UINT8
const SYMCRYPT_SHAKE256_STATE * PCSYMCRYPT_SHAKE256_STATE
BYTE keystream[64]
BYTE abKey[SYMCRYPT_GCM_MAX_KEY_SIZE]
PBYTE pbPrivate
PSYMCRYPT_HASH_RESULT_FUNC resultFunc
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_MD5_CHAINING_STATE
* PSYMCRYPT_SHA1_CHAINING_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_HMAC_SHA384_EXPANDED_KEY
const SYMCRYPT_DLGROUP * PCSYMCRYPT_DLGROUP
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_RC2_EXPANDED_KEY
PBYTE pbSeed
const SYMCRYPT_TLSPRF1_2_EXPANDED_KEY * PCSYMCRYPT_TLSPRF1_2_EXPANDED_KEY
const SYMCRYPT_SRTPKDF_EXPANDED_KEY * PCSYMCRYPT_SRTPKDF_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_POLY1305_STATE
SYMCRYPT_MAGIC_FIELD SYMCRYPT_MARVIN32_EXPANDED_SEED
* PSYMCRYPT_GHASH_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_MD2_STATE
* PSYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY
const SYMCRYPT_OID SymCryptSha3_512OidList[SYMCRYPT_SHA3_512_OID_COUNT]
Definition: rsa_padding.c:85
PCSYMCRYPT_HASH pHashAlgorithm
const SYMCRYPT_TRIALDIVISION_PRIME * PCSYMCRYPT_TRIALDIVISION_PRIME
SYMCRYPT_MD5_STATE
SYMCRYPT_MAGIC_FIELD * PSYMCRYPT_MARVIN32_EXPANDED_SEED
enum _SYMCRYPT_INTERNAL_ECURVE_TYPE SYMCRYPT_INTERNAL_ECURVE_TYPE
PCVOID pExpandedKey
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA224_EXPANDED_KEY
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_SHA1_EXPANDED_KEY
UINT32 cbScratchEckey
#define SYMCRYPT_GCM_MAX_KEY_SIZE
UINT32 dwGenCounter
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_MARVIN32_STATE
UINT64 offset
_SYMCRYPT_ECPOINT_COORDINATES
@ SYMCRYPT_ECPOINT_COORDINATES_AFFINE
@ SYMCRYPT_ECPOINT_COORDINATES_PROJECTIVE
@ SYMCRYPT_ECPOINT_COORDINATES_SINGLE_PROJECTIVE
@ SYMCRYPT_ECPOINT_COORDINATES_INVALID
@ SYMCRYPT_ECPOINT_COORDINATES_SINGLE
@ SYMCRYPT_ECPOINT_COORDINATES_JACOBIAN
@ SYMCRYPT_ECPOINT_COORDINATES_EXTENDED_PROJECTIVE
UINT32 SYMCRYPT_CALL SymCryptFipsGetSelftestsPerformed(void)
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HASH
SYMCRYPT_ALIGN_STRUCT _SYMCRYPT_HMAC_MD5_STATE
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t UINT32
Definition: typedefs.h:59
SYMCRYPT_SHA3_224_STATE sha3_224State
SYMCRYPT_SHA1_STATE sha1State
SYMCRYPT_MD5_STATE md5State
SYMCRYPT_SHA256_STATE sha256State
SYMCRYPT_SHA512_224_STATE sha512_224State
SYMCRYPT_SHA512_STATE sha512State
SYMCRYPT_SHA224_STATE sha224State
SYMCRYPT_SHA3_256_STATE sha3_256State
SYMCRYPT_SHA512_256_STATE sha512_256State
SYMCRYPT_SHA384_STATE sha384State
SYMCRYPT_MD2_STATE md2State
SYMCRYPT_MD4_STATE md4State
SYMCRYPT_SHA3_384_STATE sha3_384State
SYMCRYPT_SHA3_512_STATE sha3_512State
SYMCRYPT_HMAC_SHA384_EXPANDED_KEY sha384Key
SYMCRYPT_KMAC256_EXPANDED_KEY kmac256Key
SYMCRYPT_HMAC_SHA3_224_EXPANDED_KEY sha3_224Key
SYMCRYPT_HMAC_SHA224_EXPANDED_KEY sha224Key
SYMCRYPT_HMAC_SHA512_EXPANDED_KEY sha512Key
SYMCRYPT_HMAC_MD5_EXPANDED_KEY md5Key
SYMCRYPT_KMAC128_EXPANDED_KEY kmac128Key
SYMCRYPT_HMAC_SHA256_EXPANDED_KEY sha256Key
SYMCRYPT_AES_CMAC_EXPANDED_KEY aescmacKey
SYMCRYPT_HMAC_SHA1_EXPANDED_KEY sha1Key
SYMCRYPT_HMAC_SHA512_256_EXPANDED_KEY sha512_256Key
SYMCRYPT_HMAC_SHA3_384_EXPANDED_KEY sha3_384Key
SYMCRYPT_HMAC_SHA512_224_EXPANDED_KEY sha512_224Key
SYMCRYPT_HMAC_SHA3_512_EXPANDED_KEY sha3_512Key
SYMCRYPT_HMAC_SHA3_256_EXPANDED_KEY sha3_256Key
SYMCRYPT_HMAC_MD5_STATE md5State
SYMCRYPT_HMAC_SHA3_224_STATE sha3_224State
SYMCRYPT_KMAC256_STATE kmac256State
SYMCRYPT_HMAC_SHA512_STATE sha512State
SYMCRYPT_HMAC_SHA512_224_STATE sha512_224State
SYMCRYPT_HMAC_SHA384_STATE sha384State
SYMCRYPT_HMAC_SHA224_STATE sha224State
SYMCRYPT_HMAC_SHA512_256_STATE sha512_256State
SYMCRYPT_HMAC_SHA3_256_STATE sha3_256State
SYMCRYPT_AES_CMAC_STATE aescmacState
SYMCRYPT_HMAC_SHA3_512_STATE sha3_512State
SYMCRYPT_HMAC_SHA256_STATE sha256State
SYMCRYPT_HMAC_SHA1_STATE sha1State
SYMCRYPT_HMAC_SHA3_384_STATE sha3_384State
SYMCRYPT_KMAC128_STATE kmac128State
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
unsigned char BYTE
Definition: xxhash.c:193
#define const
Definition: zconf.h:233