Skip to content

Commit fcea477

Browse files
Merged PR 11162679: Fix DATA annotations on Windows .def files
## Description: + Add DATA annotation to data exports in symcrypt.dll .def file, and to a few data exports missed from symcrypttestmodule.dll. This primarily fixes use of Arm64X .dlls when loaded from an emulated AMD64 process. + Remove outdated DH comment (today we do input validation when importing DH keys unless the caller explicitly opts out of doing those validations) Related work items: #50915485
1 parent 9828581 commit fcea477

File tree

4 files changed

+67
-138
lines changed

4 files changed

+67
-138
lines changed

doc/breaking_changes.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ buffers (e.g. SymCryptRsakeyCreate).
2424
This is a potentially ABI-breaking change on Windows x86.
2525

2626
### SYMCRYPT_VERSION_API will be renamed to SYMCRYPT_VERSION_MAJOR
27-
This is for consistency with the Semantic Versioning specification, as well as various tooling.
27+
This is for consistency with the Semantic Versioning specification, as well as various tooling.
28+
29+
### extern variables defined in SymCrypt headers will be removed and replaced by equivalent getter functions
30+
This simplifies how we define dynamic module exports in a cross-platform way.

lib/dh.c

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,80 +7,6 @@
77

88
#include "precomp.h"
99

10-
/*
11-
Input validation in DH
12-
13-
Jack Lloyd pointed out that we do not have any validation of the public key in our SymCryptDhSecretAgreement
14-
function. In particular, he suggested verifying that Y is not 0, 1, or P-1. This seems a natural improvement,
15-
but things get a little bit more complicated.
16-
17-
The primary purpose of SymCrypt is to be the core crypto library for Windows. The original Windows DH code dates
18-
back to the 20th century, and SymCrypt has to be compatible. Adding a new check on Y, rejecting inputs that used
19-
to work, is a big problem because something, somewhere, will break, and customers really don't like that.
20-
To maintain backward compatibility we don't introduce breaking API changes unless we have a compelling reason.
21-
So the question is: is there a compelling reason to veryfy that Y is not 0, 1, or P-1?
22-
23-
First, let's look at validation and authentication in a DH exchange. We'll use P for the group prime, G for
24-
the generator, Q for the order of G mod P, Y for the public key, and x for the private key. The shared secret
25-
S = Y^x mod P.
26-
27-
The group parameters (P, G, Q) need to be properly chosen. Malicous group parameters destroy the security of DH.
28-
Proper validation is:
29-
- P is a prime of the right size (e.g. 2048 bits)
30-
- Q is a prime of the right size (e.g. 256 bits, or 2047 bits)
31-
- Q is a divisor of P-1
32-
- 2 <= G < P
33-
- G^Q mod P = 1
34-
In some protocols the value of Q is not provided, which makes checking G much more complicated.
35-
36-
These validations are far too expensive to perform for every DH exchange. And in almost all protocols there is no
37-
need to validate them. Some protocols use trusted group parameters that are part of the code. Other protocols have
38-
one party authenticate the selected group parameters. (If a party authenticates bad group parameters then it is
39-
malicous, and there is no point in trying to be secure when one of the parties involved is malicious.)
40-
In practical terms, a protocol that uses DH with attacker-modifyable group parameters is simply insecure.
41-
42-
Now let's look at the public key Y. The recipient computes S := Y^x mod P. There are various unsuitable values that
43-
the attacker can send instead of Y
44-
- Y = 0 leads to S = 0
45-
- Y = 1 leads to S = 1
46-
- Y = P-1 leads to S = 1 or P-1
47-
- a Y with small order modulo P leads to S being in a small set of known values
48-
- Y could be outside the subgroup generated by G. This is a breach of the protocol, but absent Y being in
49-
a small subgroup it is unclear whether this is a security issue.
50-
If P is a 'safe' prime where Q = (P-1)/2 and Q is prime, there are no small subgroups apart from {1, P-1}.
51-
However, many DH systems use DSA-like group structures for efficiency (the private key is smaller)
52-
and those are not 'safe' primes so this only helps in some cases.
53-
54-
Let's see under what circumstances checking Y = 0, 1, or P-1 would help an application:
55-
- The group parameters are trusted or authenticated.
56-
- The group mod P does not have any small subgroups.
57-
- The protocol does not authenticate the public key Y
58-
- The protocol does authenticate S.
59-
The last item is crucual. If S is not authenticated then an attacker can simply replace Y with its own G^z mod P
60-
and use the private key z to recover S, so adding checks for Y in {0,1,P-1} would not fix the problem.
61-
62-
We are not aware of any of our products that uses DH in this way. The closest we can think of are some old secure
63-
phones that would do a DH exchange and then authenticate S by having the parties verify a few digits of Hash(S) by
64-
voice.
65-
66-
One imporant case to check is TLS which supports the DHE-RSA cipher suites.
67-
In TLS the DHE_RSA cipher suite uses DH. The server's DH public key is authenticated by the server's signature.
68-
Typically there is no client authentication. The client can't be fooled because of the server's signature, but
69-
the attacker could set the client's DH public key and force the server to a known shared secret. But the attacker
70-
could also just send a proper Y corresponding to its own private key and achieve the same effect, so the proposed
71-
new checks don't actually help. Furthermore, without client authentication the attacker could just be the client.
72-
If client authentication is used, the client signs the client's DH public key, so there is no problem at all.
73-
74-
Conclusion:
75-
DH is hard to use right, and the protocol implementation has to consider many things. Y = 0, 1, or P-1 is just
76-
one of many potential problems. Most protocol countermeasures against the other attacks also protect against the
77-
Y = 0, 1, or P-1 issue. Absent a more concrete security problem with Y = 0, 1, or P-1 we do not see a
78-
justification for making a backward-incompatible change at this layer of the code.
79-
80-
Niels, 20190704
81-
82-
*/
83-
8410
SYMCRYPT_ERROR
8511
SYMCRYPT_CALL
8612
SymCryptDhSecretAgreement(

modules/windows/user/symcrypt.def

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,62 @@
11
NAME symcrypt.dll
22

33
EXPORTS
4-
SymCrypt3DesBlockCipher
4+
SymCrypt3DesBlockCipher DATA
5+
SymCryptAesBlockCipher DATA
6+
SymCryptAesCmacAlgorithm DATA
7+
SymCryptDesBlockCipher DATA
8+
SymCryptDesxBlockCipher DATA
9+
SymCryptEcurveParamsCurve25519 DATA
10+
SymCryptEcurveParamsNistP192 DATA
11+
SymCryptEcurveParamsNistP224 DATA
12+
SymCryptEcurveParamsNistP256 DATA
13+
SymCryptEcurveParamsNistP384 DATA
14+
SymCryptEcurveParamsNistP521 DATA
15+
SymCryptEcurveParamsNumsP256t1 DATA
16+
SymCryptEcurveParamsNumsP384t1 DATA
17+
SymCryptEcurveParamsNumsP512t1 DATA
18+
SymCryptHmacMd5Algorithm DATA
19+
SymCryptHmacSha1Algorithm DATA
20+
SymCryptHmacSha256Algorithm DATA
21+
SymCryptHmacSha3_256Algorithm DATA
22+
SymCryptHmacSha3_384Algorithm DATA
23+
SymCryptHmacSha3_512Algorithm DATA
24+
SymCryptHmacSha384Algorithm DATA
25+
SymCryptHmacSha512Algorithm DATA
26+
SymCryptKmac128Algorithm DATA
27+
SymCryptKmac256Algorithm DATA
28+
SymCryptMarvin32DefaultSeed DATA
29+
SymCryptMd2Algorithm DATA
30+
SymCryptMd4Algorithm DATA
31+
SymCryptMd5Algorithm DATA
32+
SymCryptMd5OidList DATA
33+
SymCryptRc2BlockCipher DATA
34+
SymCryptSha1Algorithm DATA
35+
SymCryptSha1OidList DATA
36+
SymCryptSha256Algorithm DATA
37+
SymCryptSha256OidList DATA
38+
SymCryptSha3_256Algorithm DATA
39+
SymCryptSha3_256OidList DATA
40+
SymCryptSha3_384Algorithm DATA
41+
SymCryptSha3_384OidList DATA
42+
SymCryptSha3_512Algorithm DATA
43+
SymCryptSha3_512OidList DATA
44+
SymCryptSha384Algorithm DATA
45+
SymCryptSha384OidList DATA
46+
SymCryptSha512Algorithm DATA
47+
SymCryptSha512OidList DATA
48+
SymCryptShake128HashAlgorithm DATA
49+
SymCryptShake256HashAlgorithm DATA
550
SymCrypt3DesCbcDecrypt
651
SymCrypt3DesCbcEncrypt
752
SymCrypt3DesDecrypt
853
SymCrypt3DesEncrypt
954
SymCrypt3DesExpandKey
1055
SymCrypt3DesSelftest
11-
SymCryptAesBlockCipher
1256
SymCryptAesCbcDecrypt
1357
SymCryptAesCbcEncrypt
1458
SymCryptAesCbcMac
1559
SymCryptAesCmac
16-
SymCryptAesCmacAlgorithm
1760
SymCryptAesCmacAppend
1861
SymCryptAesCmacExpandKey
1962
SymCryptAesCmacInit
@@ -67,12 +110,10 @@ EXPORTS
67110
SymCryptCShake256StateCopy
68111
SymCryptCtrMsb64
69112
SymCryptDeprecatedStatusIndicator
70-
SymCryptDesBlockCipher
71113
SymCryptDesDecrypt
72114
SymCryptDesEncrypt
73115
SymCryptDesExpandKey
74116
SymCryptDesSelftest
75-
SymCryptDesxBlockCipher
76117
SymCryptDesxDecrypt
77118
SymCryptDesxEncrypt
78119
SymCryptDesxExpandKey
@@ -134,15 +175,6 @@ EXPORTS
134175
SymCryptEcurveHighBitRestrictionPosition
135176
SymCryptEcurveHighBitRestrictionValue
136177
SymCryptEcurveIsSame
137-
SymCryptEcurveParamsCurve25519
138-
SymCryptEcurveParamsNistP192
139-
SymCryptEcurveParamsNistP224
140-
SymCryptEcurveParamsNistP256
141-
SymCryptEcurveParamsNistP384
142-
SymCryptEcurveParamsNistP521
143-
SymCryptEcurveParamsNumsP256t1
144-
SymCryptEcurveParamsNumsP384t1
145-
SymCryptEcurveParamsNumsP512t1
146178
SymCryptEcurvePrivateKeyDefaultFormat
147179
SymCryptEcurveSizeofFieldElement
148180
SymCryptEcurveSizeofScalarMultiplier
@@ -175,7 +207,6 @@ EXPORTS
175207
SymCryptHkdfPrkExpandKey
176208
SymCryptHkdfSelfTest
177209
SymCryptHmacMd5
178-
SymCryptHmacMd5Algorithm
179210
SymCryptHmacMd5Append
180211
SymCryptHmacMd5ExpandKey
181212
SymCryptHmacMd5Init
@@ -184,7 +215,6 @@ EXPORTS
184215
SymCryptHmacMd5Selftest
185216
SymCryptHmacMd5StateCopy
186217
SymCryptHmacSha1
187-
SymCryptHmacSha1Algorithm
188218
SymCryptHmacSha1Append
189219
SymCryptHmacSha1ExpandKey
190220
SymCryptHmacSha1Init
@@ -193,7 +223,6 @@ EXPORTS
193223
SymCryptHmacSha1Selftest
194224
SymCryptHmacSha1StateCopy
195225
SymCryptHmacSha256
196-
SymCryptHmacSha256Algorithm
197226
SymCryptHmacSha256Append
198227
SymCryptHmacSha256ExpandKey
199228
SymCryptHmacSha256Init
@@ -202,7 +231,6 @@ EXPORTS
202231
SymCryptHmacSha256Selftest
203232
SymCryptHmacSha256StateCopy
204233
SymCryptHmacSha3_256
205-
SymCryptHmacSha3_256Algorithm
206234
SymCryptHmacSha3_256Append
207235
SymCryptHmacSha3_256ExpandKey
208236
SymCryptHmacSha3_256Init
@@ -211,7 +239,6 @@ EXPORTS
211239
SymCryptHmacSha3_256Selftest
212240
SymCryptHmacSha3_256StateCopy
213241
SymCryptHmacSha3_384
214-
SymCryptHmacSha3_384Algorithm
215242
SymCryptHmacSha3_384Append
216243
SymCryptHmacSha3_384ExpandKey
217244
SymCryptHmacSha3_384Init
@@ -220,7 +247,6 @@ EXPORTS
220247
SymCryptHmacSha3_384Selftest
221248
SymCryptHmacSha3_384StateCopy
222249
SymCryptHmacSha3_512
223-
SymCryptHmacSha3_512Algorithm
224250
SymCryptHmacSha3_512Append
225251
SymCryptHmacSha3_512ExpandKey
226252
SymCryptHmacSha3_512Init
@@ -229,7 +255,6 @@ EXPORTS
229255
SymCryptHmacSha3_512Selftest
230256
SymCryptHmacSha3_512StateCopy
231257
SymCryptHmacSha384
232-
SymCryptHmacSha384Algorithm
233258
SymCryptHmacSha384Append
234259
SymCryptHmacSha384ExpandKey
235260
SymCryptHmacSha384Init
@@ -238,7 +263,6 @@ EXPORTS
238263
SymCryptHmacSha384Selftest
239264
SymCryptHmacSha384StateCopy
240265
SymCryptHmacSha512
241-
SymCryptHmacSha512Algorithm
242266
SymCryptHmacSha512Append
243267
SymCryptHmacSha512ExpandKey
244268
SymCryptHmacSha512Init
@@ -247,7 +271,6 @@ EXPORTS
247271
SymCryptHmacSha512Selftest
248272
SymCryptHmacSha512StateCopy
249273
SymCryptKmac128
250-
SymCryptKmac128Algorithm
251274
SymCryptKmac128Append
252275
SymCryptKmac128Ex
253276
SymCryptKmac128ExpandKey
@@ -260,7 +283,6 @@ EXPORTS
260283
SymCryptKmac128Selftest
261284
SymCryptKmac128StateCopy
262285
SymCryptKmac256
263-
SymCryptKmac256Algorithm
264286
SymCryptKmac256Append
265287
SymCryptKmac256Ex
266288
SymCryptKmac256ExpandKey
@@ -279,15 +301,13 @@ EXPORTS
279301
SymCryptMapUint32
280302
SymCryptMarvin32
281303
SymCryptMarvin32Append
282-
SymCryptMarvin32DefaultSeed
283304
SymCryptMarvin32ExpandSeed
284305
SymCryptMarvin32Init
285306
SymCryptMarvin32Result
286307
SymCryptMarvin32SeedCopy
287308
SymCryptMarvin32Selftest
288309
SymCryptMarvin32StateCopy
289310
SymCryptMd2
290-
SymCryptMd2Algorithm
291311
SymCryptMd2Append
292312
SymCryptMd2Init
293313
SymCryptMd2Result
@@ -296,7 +316,6 @@ EXPORTS
296316
SymCryptMd2StateExport
297317
SymCryptMd2StateImport
298318
SymCryptMd4
299-
SymCryptMd4Algorithm
300319
SymCryptMd4Append
301320
SymCryptMd4Init
302321
SymCryptMd4Result
@@ -305,10 +324,8 @@ EXPORTS
305324
SymCryptMd4StateExport
306325
SymCryptMd4StateImport
307326
SymCryptMd5
308-
SymCryptMd5Algorithm
309327
SymCryptMd5Append
310328
SymCryptMd5Init
311-
SymCryptMd5OidList
312329
SymCryptMd5Result
313330
SymCryptMd5Selftest
314331
SymCryptMd5StateCopy
@@ -338,7 +355,6 @@ EXPORTS
338355
SymCryptPoly1305Selftest
339356
SymCryptProvideEntropy
340357
SymCryptRandom
341-
SymCryptRc2BlockCipher
342358
SymCryptRc2Decrypt
343359
SymCryptRc2Encrypt
344360
SymCryptRc2ExpandKey
@@ -391,67 +407,53 @@ EXPORTS
391407
SymCryptSessionReceiverInit
392408
SymCryptSessionSenderInit
393409
SymCryptSha1
394-
SymCryptSha1Algorithm
395410
SymCryptSha1Append
396411
SymCryptSha1Init
397-
SymCryptSha1OidList
398412
SymCryptSha1Result
399413
SymCryptSha1Selftest
400414
SymCryptSha1StateCopy
401415
SymCryptSha1StateExport
402416
SymCryptSha1StateImport
403417
SymCryptSha256
404-
SymCryptSha256Algorithm
405418
SymCryptSha256Append
406419
SymCryptSha256Init
407-
SymCryptSha256OidList
408420
SymCryptSha256Result
409421
SymCryptSha256Selftest
410422
SymCryptSha256StateCopy
411423
SymCryptSha256StateExport
412424
SymCryptSha256StateImport
413425
SymCryptSha3_256
414-
SymCryptSha3_256Algorithm
415426
SymCryptSha3_256Append
416427
SymCryptSha3_256Init
417-
SymCryptSha3_256OidList
418428
SymCryptSha3_256Result
419429
SymCryptSha3_256StateCopy
420430
SymCryptSha3_256StateExport
421431
SymCryptSha3_256StateImport
422432
SymCryptSha3_384
423-
SymCryptSha3_384Algorithm
424433
SymCryptSha3_384Append
425434
SymCryptSha3_384Init
426-
SymCryptSha3_384OidList
427435
SymCryptSha3_384Result
428436
SymCryptSha3_384StateCopy
429437
SymCryptSha3_384StateExport
430438
SymCryptSha3_384StateImport
431439
SymCryptSha3_512
432-
SymCryptSha3_512Algorithm
433440
SymCryptSha3_512Append
434441
SymCryptSha3_512Init
435-
SymCryptSha3_512OidList
436442
SymCryptSha3_512Result
437443
SymCryptSha3_512StateCopy
438444
SymCryptSha3_512StateExport
439445
SymCryptSha3_512StateImport
440446
SymCryptSha384
441-
SymCryptSha384Algorithm
442447
SymCryptSha384Append
443448
SymCryptSha384Init
444-
SymCryptSha384OidList
445449
SymCryptSha384Result
446450
SymCryptSha384Selftest
447451
SymCryptSha384StateCopy
448452
SymCryptSha384StateExport
449453
SymCryptSha384StateImport
450454
SymCryptSha512
451-
SymCryptSha512Algorithm
452455
SymCryptSha512Append
453456
SymCryptSha512Init
454-
SymCryptSha512OidList
455457
SymCryptSha512Result
456458
SymCryptSha512Selftest
457459
SymCryptSha512StateCopy
@@ -461,7 +463,6 @@ EXPORTS
461463
SymCryptShake128Append
462464
SymCryptShake128Default
463465
SymCryptShake128Extract
464-
SymCryptShake128HashAlgorithm
465466
SymCryptShake128Init
466467
SymCryptShake128Result
467468
SymCryptShake128Selftest
@@ -470,7 +471,6 @@ EXPORTS
470471
SymCryptShake256Append
471472
SymCryptShake256Default
472473
SymCryptShake256Extract
473-
SymCryptShake256HashAlgorithm
474474
SymCryptShake256Init
475475
SymCryptShake256Result
476476
SymCryptShake256Selftest

0 commit comments

Comments
 (0)