Ticket #38391

CALG_TLS1PRF in wincrypt.h unusable

Open Date: 2018-07-10 16:32 Last Update: 2018-07-12 20:17

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
3
Vote
Score: 1
100.0% (1/1)
0.0% (0/1)

Details

I'm using w32api 5.0.2, but the issue is also in the trunk and experimental branches.

CALG_TLS1PRF is defined as (ALG_CLASS_DHASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF) in https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.1-trunk/w32api/include/wincrypt.h. This doesn't compile as ALG_CLASS_DHASH is not defined. The Microsoft Windows SDK uses ALG_CLASS_HASH instead.

#include <windows.h>
#include <wincrypt.h>

int i = CALG_TLS1PRF;

results in

$ gcc test_wincrypt.c
In file included from test_wincrypt.c:2:0:
test_wincrypt.c:4:9: error: 'ALG_CLASS_DHASH' undeclared here (not in a function)
 int i = CALG_TLS1PRF;
         ^

Ticket History (3/9 Histories)

2018-07-10 16:32 Updated by: marcelraad
  • New Ticket "CALG_TLS1PRF in wincrypt.h unusable" created
2018-07-11 03:12 Updated by: marcelraad
  • Details Updated
2018-07-11 05:55 Updated by: earnie
  • Owner Update from (None) to keith
Comment

Reply To marcelraad

I'm using w32api 5.0.2, but the issue is also in the trunk and experimental branches. CALG_TLS1PRF is defined as (ALG_CLASS_DHASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF) in https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.1-trunk/w32api/include/wincrypt.h. This doesn't compile as ALG_CLASS_DHASH is not defined. The Microsoft Windows SDK uses ALG_CLASS_HASH instead.

#include <windows.h>
#include <wincrypt.h>

int i = CALG_TLS1PRF;
results in
$ gcc test_wincrypt.c
In file included from test_wincrypt.c:2:0:
test_wincrypt.c:4:9: error: 'ALG_CLASS_DHASH' undeclared here (not in a function)
 int i = CALG_TLS1PRF;
         ^

The ALG_CLASS_DHASH appears to be a typo and ALG_CLASS_HASH should have been used. I've assigned to Keith but he may want to reassign elsewhere.

(Edited, 2018-07-12 00:31 Updated by: keith)
2018-07-12 00:15 Updated by: keith
Comment

I agree with Earnie -- this looks like a typo; what's more, it's been this way since Danny Smith committed the update, (per attached w32api-r247.diff), which added the CALG_TLS1PRF manifest constant definition, in August 2002.

FWIW, Danny's ChangeLog entry is a classical example of how not to write ChangeLogs -- a malaise which afflicted both CygWin and MinGW at that time, and may well still afflict CygWin today. Had Danny written the ChangeLog properly -- enumerating, in full, all of the definitions he added -- he might well have noticed the typo, at the time, (and I could simply have searched the ChangLog, rather than resorting to hg archaeology on an old, converted CVS repository, to locate the offending commit). But, that's water under the bridge -- I'll fix it.

2018-07-12 20:02 Updated by: keith
  • Status Update from Open to Closed
  • Resolution Update from None to Fixed
Comment

My own (local) patch queue has a further issue to resolve, in <wincrypt.h> — two extraneous typedef keywords preceding struct definitions, with no directly associated type name, in either case. I've folded the removal of these extraneous typedefs into the patch to correct the bogus reference to ALG_CLASS_DHASH.

I also have a trivial patch to make <wincrypt.h> effectively self-contained. (Microsoft may not care about such niceties, but it is better software engineering, and thus right and proper, that we do so).

I've gone ahead, and committed both of the attached patches, as commit #73aedcc, and commit #7b0f1f2, respectively.

(Edited, 2018-07-12 20:03 Updated by: keith)
2018-07-12 20:17 Updated by: marcelraad
Comment

Great, thanks for the fast fix!

Attachment File List

Edit

Please login to add comment to this ticket » Login