ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
March 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
25 participants
436 discussions
Start a n
N
ew thread
01/01: [DCIMAN32] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2d651230a4b1f06400f53…
commit 2d651230a4b1f06400f53cfe0ff8fd629cbffc89 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 13:05:29 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 13:05:29 2018 +0100 [DCIMAN32] Sync with Wine Staging 3.3. CORE-14434 --- dll/win32/dciman32/dciman_main.c | 15 ++++++++------- media/doc/README.WINE | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dll/win32/dciman32/dciman_main.c b/dll/win32/dciman32/dciman_main.c index 6446f28aa2..7e2e5730f8 100644 --- a/dll/win32/dciman32/dciman_main.c +++ b/dll/win32/dciman32/dciman_main.c @@ -19,16 +19,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WIN32_NO_STATUS - #include <stdarg.h> -//#include <stdio.h> +#include <stdio.h> -#include <windef.h> -#include <winbase.h> +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#ifdef __REACTOS__ #include <wingdi.h> -#include <dciman.h> -#include <wine/debug.h> +#endif +#include "dciman.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(dciman); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 38f498ab7d..4fde5a92a4 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -64,7 +64,7 @@ reactos/dll/win32/cryptdll # Synced to WineStaging-3.3 reactos/dll/win32/cryptnet # Synced to WineStaging-3.3 reactos/dll/win32/cryptui # Synced to WineStaging-3.3 reactos/dll/win32/dbghelp # Synced to WineStaging-3.3 -reactos/dll/win32/dciman32 # Synced to WineStaging-2.9 +reactos/dll/win32/dciman32 # Synced to WineStaging-3.3 reactos/dll/win32/faultrep # Synced to WineStaging-2.9 reactos/dll/win32/fontsub # Synced to WineStaging-2.9 reactos/dll/win32/fusion # Synced to Wine-3.0
6 years, 9 months
1
0
0
0
01/01: [CRYPTUI] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=72e8d9fa92eae8f28e89e…
commit 72e8d9fa92eae8f28e89e7c764d767f34e5b4549 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 13:04:41 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 13:04:41 2018 +0100 [CRYPTUI] Sync with Wine Staging 3.3. CORE-14434 --- dll/win32/cryptui/cryptui.rc | 7 +------ dll/win32/cryptui/cryptuires.h | 6 +++--- dll/win32/cryptui/main.c | 40 ++++++++++++++++++---------------------- media/doc/README.WINE | 2 +- 4 files changed, 23 insertions(+), 32 deletions(-) diff --git a/dll/win32/cryptui/cryptui.rc b/dll/win32/cryptui/cryptui.rc index e1e7f01fb1..3f3027b92d 100644 --- a/dll/win32/cryptui/cryptui.rc +++ b/dll/win32/cryptui/cryptui.rc @@ -17,11 +17,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windef.h> -//#include "winbase.h" -#include <winuser.h> -#include <commctrl.h> -//#include "dlgs.h" #include "cryptuires.h" @@ -98,4 +93,4 @@ IDB_CERT_HEADER BITMAP "res/certheader.bmp" #endif #ifdef LANGUAGE_ZH_CN #include "lang/cryptui_Zh.rc" -#endif \ No newline at end of file +#endif diff --git a/dll/win32/cryptui/cryptuires.h b/dll/win32/cryptui/cryptuires.h index 9b3edafb7c..df321df463 100644 --- a/dll/win32/cryptui/cryptuires.h +++ b/dll/win32/cryptui/cryptuires.h @@ -18,9 +18,9 @@ #ifndef __CRYPTUIRES_H_ #define __CRYPTUIRES_H_ -//#include <windef.h> -//#include <winuser.h> -//#include <commctrl.h> +#include <windef.h> +#include <winuser.h> +#include <commctrl.h> #define IDS_CERTIFICATE 1000 #define IDS_CERTIFICATEINFORMATION 1001 diff --git a/dll/win32/cryptui/main.c b/dll/win32/cryptui/main.c index 010fe5da3c..a652239bb3 100644 --- a/dll/win32/cryptui/main.c +++ b/dll/win32/cryptui/main.c @@ -16,35 +16,31 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#include <wine/config.h> +#include "config.h" #include <stdarg.h> #define COBJMACROS #define NONAMELESSUNION -#include <windef.h> -#include <winbase.h> -//#include "winnls.h" -#include <winuser.h> -#include <softpub.h> -#include <wingdi.h> -#include <richedit.h> -#include <ole2.h> -#include <richole.h> -#include <commdlg.h> -#include <commctrl.h> -#include <cryptuiapi.h> +#include "windef.h" +#include "winbase.h" +#include "winnls.h" +#include "winuser.h" +#include "softpub.h" +#include "wingdi.h" +#include "richedit.h" +#include "ole2.h" +#include "richole.h" +#include "commdlg.h" +#include "commctrl.h" +#include "cryptuiapi.h" #include "cryptuires.h" -//#include "urlmon.h" -#include <hlink.h> -#include <winreg.h> -#include <wine/debug.h> -#include <wine/unicode.h> +#include "urlmon.h" +#include "hlink.h" +#include "winreg.h" +#include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(cryptui); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 11662a9f7b..38f498ab7d 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -62,7 +62,7 @@ reactos/dll/win32/crypt32 # Synced to WineStaging-3.3 reactos/dll/win32/cryptdlg # Synced to WineStaging-3.3 reactos/dll/win32/cryptdll # Synced to WineStaging-3.3 reactos/dll/win32/cryptnet # Synced to WineStaging-3.3 -reactos/dll/win32/cryptui # Synced to WineStaging-2.16 +reactos/dll/win32/cryptui # Synced to WineStaging-3.3 reactos/dll/win32/dbghelp # Synced to WineStaging-3.3 reactos/dll/win32/dciman32 # Synced to WineStaging-2.9 reactos/dll/win32/faultrep # Synced to WineStaging-2.9
6 years, 9 months
1
0
0
0
01/01: [CRYPTNET_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c2d08daae1c7e8a8e70d4…
commit c2d08daae1c7e8a8e70d4c72d1ae423d042fdce6 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 13:03:51 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 13:03:51 2018 +0100 [CRYPTNET_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/cryptnet/cryptnet.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/rostests/winetests/cryptnet/cryptnet.c b/modules/rostests/winetests/cryptnet/cryptnet.c index a8ead636fa..8600fda645 100644 --- a/modules/rostests/winetests/cryptnet/cryptnet.c +++ b/modules/rostests/winetests/cryptnet/cryptnet.c @@ -17,14 +17,14 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -//#include <stdarg.h> +#include <stdarg.h> #include <stdio.h> -#define NONAMELESSUNION + #include <windef.h> #include <winbase.h> -//#include <winerror.h> +#include <winerror.h> #include <wincrypt.h> -#include <wine/test.h> +#include "wine/test.h" static const BYTE bigCert[] = { 0x30,0x78,0x02,0x01,0x01,0x30,0x02,0x06,0x00,0x30,0x14,0x31,0x12,0x30,0x10,
6 years, 9 months
1
0
0
0
01/01: [CRYPTNET] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=18075aa0401020629a643…
commit 18075aa0401020629a64372b2486b97ebdb83c5a Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 13:03:13 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 13:03:13 2018 +0100 [CRYPTNET] Sync with Wine Staging 3.3. CORE-14434 --- dll/win32/cryptnet/cryptnet_main.c | 25 +++++++++++-------------- media/doc/README.WINE | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/dll/win32/cryptnet/cryptnet_main.c b/dll/win32/cryptnet/cryptnet_main.c index a7838b1e76..be38ca35b3 100644 --- a/dll/win32/cryptnet/cryptnet_main.c +++ b/dll/win32/cryptnet/cryptnet_main.c @@ -18,27 +18,24 @@ * */ -#define WIN32_NO_STATUS - -#include <config.h> -//#include "wine/port.h" +#include "config.h" +#include "wine/port.h" #define NONAMELESSUNION -#define NONAMELESSSTRUCT #define CERT_REVOCATION_PARA_HAS_EXTRA_FIELDS #include <stdio.h> -//#include <stdarg.h> +#include <stdarg.h> -#include <windef.h> -#include <winbase.h> -//#include "winnt.h" -#include <winnls.h> -#include <wininet.h> -//#include "objbase.h" -#include <wincrypt.h> +#include "windef.h" +#include "winbase.h" +#include "winnt.h" +#include "winnls.h" +#include "wininet.h" +#include "objbase.h" +#include "wincrypt.h" -#include <wine/debug.h> +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(cryptnet); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 0ee163be51..11662a9f7b 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -61,7 +61,7 @@ reactos/dll/win32/credui # Synced to WineStaging-3.3 reactos/dll/win32/crypt32 # Synced to WineStaging-3.3 reactos/dll/win32/cryptdlg # Synced to WineStaging-3.3 reactos/dll/win32/cryptdll # Synced to WineStaging-3.3 -reactos/dll/win32/cryptnet # Synced to WineStaging-2.9 +reactos/dll/win32/cryptnet # Synced to WineStaging-3.3 reactos/dll/win32/cryptui # Synced to WineStaging-2.16 reactos/dll/win32/dbghelp # Synced to WineStaging-3.3 reactos/dll/win32/dciman32 # Synced to WineStaging-2.9
6 years, 9 months
1
0
0
0
01/01: [CRYPTDLL] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3e2633b7816f5fcf564b7…
commit 3e2633b7816f5fcf564b79c9b7b25d4e38ae04b8 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 13:02:26 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 13:02:26 2018 +0100 [CRYPTDLL] Sync with Wine Staging 3.3. CORE-14434 --- dll/win32/cryptdll/cryptdll.c | 12 +++++------- media/doc/README.WINE | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dll/win32/cryptdll/cryptdll.c b/dll/win32/cryptdll/cryptdll.c index 11ee06f7d6..1146a6d1ee 100644 --- a/dll/win32/cryptdll/cryptdll.c +++ b/dll/win32/cryptdll/cryptdll.c @@ -16,14 +16,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WIN32_NO_STATUS - -#include <config.h> +#include "config.h" #include <stdarg.h> -//#include <stdlib.h> -#include <windef.h> -#include <winbase.h> -#include <wine/debug.h> +#include <stdlib.h> +#include "windef.h" +#include "winbase.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(cryptdll); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index c9a7dca4f2..0ee163be51 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -60,7 +60,7 @@ reactos/dll/win32/compstui # Synced to WineStaging-3.3 reactos/dll/win32/credui # Synced to WineStaging-3.3 reactos/dll/win32/crypt32 # Synced to WineStaging-3.3 reactos/dll/win32/cryptdlg # Synced to WineStaging-3.3 -reactos/dll/win32/cryptdll # Synced to WineStaging-2.9 +reactos/dll/win32/cryptdll # Synced to WineStaging-3.3 reactos/dll/win32/cryptnet # Synced to WineStaging-2.9 reactos/dll/win32/cryptui # Synced to WineStaging-2.16 reactos/dll/win32/dbghelp # Synced to WineStaging-3.3
6 years, 9 months
1
0
0
0
01/01: [CRYPTDLG] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7342d6751c456df1dbc32…
commit 7342d6751c456df1dbc32b2c81d78faf78c8c9d3 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 13:01:37 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 13:01:37 2018 +0100 [CRYPTDLG] Sync with Wine Staging 3.3. CORE-14434 --- dll/win32/cryptdlg/cryptdlg.rc | 1 - dll/win32/cryptdlg/cryptres.h | 2 +- dll/win32/cryptdlg/main.c | 28 +++++++++++++--------------- media/doc/README.WINE | 2 +- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/dll/win32/cryptdlg/cryptdlg.rc b/dll/win32/cryptdlg/cryptdlg.rc index 4444211a2d..f1a96aaabe 100644 --- a/dll/win32/cryptdlg/cryptdlg.rc +++ b/dll/win32/cryptdlg/cryptdlg.rc @@ -17,7 +17,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windef.h> #include "cryptres.h" diff --git a/dll/win32/cryptdlg/cryptres.h b/dll/win32/cryptdlg/cryptres.h index 821fda378f..4d3c2d2ffb 100644 --- a/dll/win32/cryptdlg/cryptres.h +++ b/dll/win32/cryptdlg/cryptres.h @@ -18,7 +18,7 @@ #ifndef __CRYPTRES_H__ #define __CRYPTRES_H__ -//#include <windef.h> +#include <windef.h> #define IDS_CERT_POLICY 100 #define IDS_POLICY_ID 101 diff --git a/dll/win32/cryptdlg/main.c b/dll/win32/cryptdlg/main.c index 7e875c3b49..e3eaec1e19 100644 --- a/dll/win32/cryptdlg/main.c +++ b/dll/win32/cryptdlg/main.c @@ -16,27 +16,25 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WIN32_NO_STATUS - #define NONAMELESSUNION -#include <config.h> +#include "config.h" #include <stdarg.h> -#include <windef.h> -#include <winbase.h> -//#include "winnls.h" -#include <winreg.h> -#include <wincrypt.h> -//#include "wintrust.h" -#include <winuser.h> -//#include "objbase.h" -#include <cryptdlg.h> -#include <cryptuiapi.h> +#include "windef.h" +#include "winbase.h" +#include "winnls.h" +#include "winreg.h" +#include "wincrypt.h" +#include "wintrust.h" +#include "winuser.h" +#include "objbase.h" +#include "cryptdlg.h" +#include "cryptuiapi.h" #include "cryptres.h" -#include <wine/unicode.h> -#include <wine/debug.h> +#include "wine/unicode.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(cryptdlg); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 7d6bb23c99..c9a7dca4f2 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -59,7 +59,7 @@ reactos/dll/win32/comdlg32 # Synced to WineStaging-3.3 reactos/dll/win32/compstui # Synced to WineStaging-3.3 reactos/dll/win32/credui # Synced to WineStaging-3.3 reactos/dll/win32/crypt32 # Synced to WineStaging-3.3 -reactos/dll/win32/cryptdlg # Synced to WineStaging-2.9 +reactos/dll/win32/cryptdlg # Synced to WineStaging-3.3 reactos/dll/win32/cryptdll # Synced to WineStaging-2.9 reactos/dll/win32/cryptnet # Synced to WineStaging-2.9 reactos/dll/win32/cryptui # Synced to WineStaging-2.16
6 years, 9 months
1
0
0
0
01/01: [CRYPT32_WINETEST] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d03ac84f4f0584b5db9ae…
commit d03ac84f4f0584b5db9aedd6bb0af55136da84a2 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 13:00:36 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 13:00:36 2018 +0100 [CRYPT32_WINETEST] Sync with Wine Staging 3.3. CORE-14434 --- modules/rostests/winetests/crypt32/base64.c | 84 ++-- modules/rostests/winetests/crypt32/cert.c | 11 +- modules/rostests/winetests/crypt32/chain.c | 93 +++- modules/rostests/winetests/crypt32/crl.c | 12 +- modules/rostests/winetests/crypt32/ctl.c | 10 +- modules/rostests/winetests/crypt32/encode.c | 520 +++++++++++++++++++---- modules/rostests/winetests/crypt32/main.c | 10 +- modules/rostests/winetests/crypt32/message.c | 9 +- modules/rostests/winetests/crypt32/msg.c | 16 +- modules/rostests/winetests/crypt32/object.c | 8 +- modules/rostests/winetests/crypt32/oid.c | 70 ++- modules/rostests/winetests/crypt32/precomp.h | 5 + modules/rostests/winetests/crypt32/protectdata.c | 9 +- modules/rostests/winetests/crypt32/sip.c | 10 +- modules/rostests/winetests/crypt32/store.c | 351 ++++++--------- modules/rostests/winetests/crypt32/str.c | 8 +- 16 files changed, 833 insertions(+), 393 deletions(-) diff --git a/modules/rostests/winetests/crypt32/base64.c b/modules/rostests/winetests/crypt32/base64.c index 4898d3897e..e127fc3891 100644 --- a/modules/rostests/winetests/crypt32/base64.c +++ b/modules/rostests/winetests/crypt32/base64.c @@ -18,8 +18,14 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#include <wincrypt.h> -#include "precomp.h" +#include "wine/test.h" #define CERT_HEADER "-----BEGIN CERTIFICATE-----\r\n" #define ALT_CERT_HEADER "-----BEGIN This is some arbitrary text that goes on and on-----\r\n" @@ -36,15 +42,6 @@ #define X509_HEADER_NOCR "-----BEGIN X509 CRL-----\n" #define X509_TRAILER_NOCR "-----END X509 CRL-----\n" -static BOOL (WINAPI *pCryptBinaryToStringA)(const BYTE *pbBinary, - DWORD cbBinary, DWORD dwFlags, LPSTR pszString, DWORD *pcchString); -static BOOL (WINAPI *pCryptStringToBinaryA)(LPCSTR pszString, - DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary, - DWORD *pdwSkip, DWORD *pdwFlags); -static BOOL (WINAPI *pCryptStringToBinaryW)(LPCWSTR pszString, - DWORD cchString, DWORD dwFlags, BYTE *pbBinary, DWORD *pcbBinary, - DWORD *pdwSkip, DWORD *pdwFlags); - struct BinTests { const BYTE *toEncode; @@ -91,7 +88,7 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen, LPSTR str = NULL; BOOL ret; - ret = pCryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen); + ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen); ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); str = HeapAlloc(GetProcessHeap(), 0, strLen); if (str) @@ -99,7 +96,7 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen, DWORD strLen2 = strLen; LPCSTR ptr = str; - ret = pCryptBinaryToStringA(toEncode, toEncodeLen, format, str, + ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, &strLen2); ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); ok(strLen2 == strLen - 1, "Expected length %d, got %d\n", @@ -125,10 +122,10 @@ static void testBinaryToStringA(void) BOOL ret; DWORD strLen = 0, i; - ret = pCryptBinaryToStringA(NULL, 0, 0, NULL, NULL); + ret = CryptBinaryToStringA(NULL, 0, 0, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); - ret = pCryptBinaryToStringA(NULL, 0, 0, NULL, &strLen); + ret = CryptBinaryToStringA(NULL, 0, 0, NULL, &strLen); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) @@ -137,7 +134,7 @@ static void testBinaryToStringA(void) LPSTR str = NULL; BOOL ret; - ret = pCryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, + ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, NULL, &strLen); ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); str = HeapAlloc(GetProcessHeap(), 0, strLen); @@ -145,7 +142,7 @@ static void testBinaryToStringA(void) { DWORD strLen2 = strLen; - ret = pCryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, + ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, str, &strLen2); ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); ok(strLen == strLen2, "Expected length %d, got %d\n", strLen, @@ -172,7 +169,7 @@ static void testBinaryToStringA(void) LPSTR str = NULL; BOOL ret; - ret = pCryptBinaryToStringA(testsNoCR[i].toEncode, + ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, NULL, &strLen); ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); @@ -181,7 +178,7 @@ static void testBinaryToStringA(void) { DWORD strLen2 = strLen; - ret = pCryptBinaryToStringA(testsNoCR[i].toEncode, + ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, str, &strLen2); ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); @@ -236,7 +233,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header, strcat(str, toDecode); if (trailer) strcat(str, trailer); - ret = pCryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL, + ret = CryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL, NULL); ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); buf = HeapAlloc(GetProcessHeap(), 0, bufLen); @@ -245,14 +242,14 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header, DWORD skipped, usedFormat; /* check as normal, make sure last two parameters are optional */ - ret = pCryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, NULL, + ret = CryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, NULL, NULL); ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); ok(bufLen == expectedLen, "Expected length %d, got %d\n", expectedLen, bufLen); ok(!memcmp(buf, expected, bufLen), "Unexpected value\n"); /* check last two params */ - ret = pCryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, + ret = CryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, &skipped, &usedFormat); ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); ok(skipped == 0, "Expected skipped 0, got %d\n", skipped); @@ -268,7 +265,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header, strcat(str, toDecode); if (trailer) strcat(str, trailer); - ret = pCryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL, + ret = CryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL, NULL); /* expect failure with no header, and success with one */ if (header) @@ -283,7 +280,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header, { DWORD skipped, usedFormat; - ret = pCryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, + ret = CryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, &skipped, &usedFormat); ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); ok(skipped == strlen(garbage), @@ -305,7 +302,7 @@ static void decodeBase64WithLenFmtW(LPCSTR strA, int len, DWORD fmt, BOOL retA, WCHAR strW[64]; int i; for (i = 0; (strW[i] = strA[i]) != 0; ++i); - ret = pCryptStringToBinaryW(strW, len, fmt, buf, &bufLen, NULL, &fmtUsed); + ret = CryptStringToBinaryW(strW, len, fmt, buf, &bufLen, NULL, &fmtUsed); ok(ret == retA && bufLen == bufLenA && memcmp(bufA, buf, bufLen) == 0 && fmtUsed == fmtUsedA, "base64 \"%s\" len %d: W and A differ\n", strA, len); } @@ -316,7 +313,7 @@ static void decodeBase64WithLenFmt(LPCSTR str, int len, DWORD fmt, LPCSTR expect DWORD bufLen = sizeof(buf)-1, fmtUsed = 0xdeadbeef; BOOL ret; SetLastError(0xdeadbeef); - ret = pCryptStringToBinaryA(str, len, fmt, buf, &bufLen, NULL, &fmtUsed); + ret = CryptStringToBinaryA(str, len, fmt, buf, &bufLen, NULL, &fmtUsed); buf[bufLen] = 0; if (expected) { BOOL correct = ret && strcmp(expected, (char*)buf) == 0; @@ -331,8 +328,8 @@ static void decodeBase64WithLenFmt(LPCSTR str, int len, DWORD fmt, LPCSTR expect "base64 \"%s\" len %d: expected failure, got \"%s\" (ret %d, le %d)\n", str, len, (char*)buf, ret, GetLastError()); } - if (pCryptStringToBinaryW) - decodeBase64WithLenFmtW(str, len, fmt, ret, buf, bufLen, fmtUsed); + + decodeBase64WithLenFmtW(str, len, fmt, ret, buf, bufLen, fmtUsed); } static void decodeBase64WithLenBroken(LPCSTR str, int len, LPCSTR expected, int le) @@ -366,19 +363,19 @@ static void testStringToBinaryA(void) DWORD bufLen = 0, i; BYTE buf[8]; - ret = pCryptStringToBinaryA(NULL, 0, 0, NULL, NULL, NULL, NULL); + ret = CryptStringToBinaryA(NULL, 0, 0, NULL, NULL, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%u\n", ret, GetLastError()); - ret = pCryptStringToBinaryA(NULL, 0, 0, NULL, &bufLen, NULL, NULL); + ret = CryptStringToBinaryA(NULL, 0, 0, NULL, &bufLen, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%u\n", ret, GetLastError()); /* Bogus format */ - ret = pCryptStringToBinaryA(tests[0].base64, 0, 0, NULL, &bufLen, NULL, + ret = CryptStringToBinaryA(tests[0].base64, 0, 0, NULL, &bufLen, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_DATA, "Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", ret, GetLastError()); /* Decoding doesn't expect the NOCR flag to be specified */ - ret = pCryptStringToBinaryA(tests[0].base64, 1, + ret = CryptStringToBinaryA(tests[0].base64, 1, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, NULL, &bufLen, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_DATA, "Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", ret, GetLastError()); @@ -386,7 +383,7 @@ static void testStringToBinaryA(void) for (i = 0; i < sizeof(badStrings) / sizeof(badStrings[0]); i++) { bufLen = 0; - ret = pCryptStringToBinaryA(badStrings[i].str, 0, badStrings[i].format, + ret = CryptStringToBinaryA(badStrings[i].str, 0, badStrings[i].format, NULL, &bufLen, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_DATA, "%d: Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", i, ret, GetLastError()); @@ -444,7 +441,7 @@ static void testStringToBinaryA(void) /* Too small buffer */ buf[0] = 0; bufLen = 4; - ret = pCryptStringToBinaryA("VVVVVVVV", 8, CRYPT_STRING_BASE64, (BYTE*)buf, &bufLen, NULL, NULL); + ret = CryptStringToBinaryA("VVVVVVVV", 8, CRYPT_STRING_BASE64, (BYTE*)buf, &bufLen, NULL, NULL); ok(!ret && bufLen == 4 && buf[0] == 0, "Expected ret 0, bufLen 4, buf[0] '\\0', got ret %d, bufLen %d, buf[0] '%c'\n", ret, bufLen, buf[0]); @@ -456,7 +453,7 @@ static void testStringToBinaryA(void) /* Bogus length--oddly enough, that succeeds, even though it's not * properly padded. */ - ret = pCryptStringToBinaryA(tests[i].base64, 1, CRYPT_STRING_BASE64, + ret = CryptStringToBinaryA(tests[i].base64, 1, CRYPT_STRING_BASE64, NULL, &bufLen, NULL, NULL); ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); /* Check with the precise format */ @@ -513,7 +510,7 @@ static void testStringToBinaryA(void) /* Bogus length--oddly enough, that succeeds, even though it's not * properly padded. */ - ret = pCryptStringToBinaryA(testsNoCR[i].base64, 1, CRYPT_STRING_BASE64, + ret = CryptStringToBinaryA(testsNoCR[i].base64, 1, CRYPT_STRING_BASE64, NULL, &bufLen, NULL, NULL); ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError()); /* Check with the precise format */ @@ -548,19 +545,6 @@ static void testStringToBinaryA(void) START_TEST(base64) { - HMODULE lib = GetModuleHandleA("crypt32"); - - pCryptBinaryToStringA = (void *)GetProcAddress(lib, "CryptBinaryToStringA"); - pCryptStringToBinaryA = (void *)GetProcAddress(lib, "CryptStringToBinaryA"); - pCryptStringToBinaryW = (void *)GetProcAddress(lib, "CryptStringToBinaryW"); - - if (pCryptBinaryToStringA) - testBinaryToStringA(); - else - win_skip("CryptBinaryToStringA is not available\n"); - - if (pCryptStringToBinaryA) - testStringToBinaryA(); - else - win_skip("CryptStringToBinaryA is not available\n"); + testBinaryToStringA(); + testStringToBinaryA(); } diff --git a/modules/rostests/winetests/crypt32/cert.c b/modules/rostests/winetests/crypt32/cert.c index 8a8d36b926..e49b2a9798 100644 --- a/modules/rostests/winetests/crypt32/cert.c +++ b/modules/rostests/winetests/crypt32/cert.c @@ -18,7 +18,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include <stdarg.h> + +#include <windef.h> +#include <winbase.h> +#include <winreg.h> +#include <winerror.h> +#include <wincrypt.h> + +#include "wine/test.h" static PCCERT_CONTEXT (WINAPI *pCertCreateSelfSignCertificate)(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE,PCERT_NAME_BLOB,DWORD,PCRYPT_KEY_PROV_INFO,PCRYPT_ALGORITHM_IDENTIFIER,PSYSTEMTIME,PSYSTEMTIME,PCERT_EXTENSIONS); static BOOL (WINAPI *pCertGetValidUsages)(DWORD,PCCERT_CONTEXT*,int*,LPSTR*,DWORD*); diff --git a/modules/rostests/winetests/crypt32/chain.c b/modules/rostests/winetests/crypt32/chain.c index e9e8634b2b..e3b280b088 100644 --- a/modules/rostests/winetests/crypt32/chain.c +++ b/modules/rostests/winetests/crypt32/chain.c @@ -18,10 +18,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#include <wincrypt.h> #include <wininet.h> +#include "wine/test.h" + static const BYTE selfSignedCert[] = { 0x30, 0x82, 0x01, 0x1f, 0x30, 0x81, 0xce, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0xeb, 0x0d, 0x57, 0x2a, 0x9c, 0x09, 0xba, 0xa4, 0x4a, 0xb7, 0x25, 0x49, @@ -2882,6 +2889,59 @@ static const BYTE chain31_1[] = { 0x43,0x08,0xe5,0x78,0x2b,0x95,0xf3,0x75,0xb6,0x88,0xf0,0x6b,0x5c,0x5b,0x50, 0x04,0x91,0x3b,0x89,0x5a,0x60,0x1f,0xfc,0x36,0x53,0x32,0x36,0x0a,0x4d,0x03, 0x2c,0xd7 }; +static const BYTE ecc_crt[] = { +0x30,0x82,0x01,0x46,0x30,0x81,0xec,0x02,0x09,0x00,0xe7,0x6b,0x26,0x86,0x0a, +0x82,0xff,0xe9,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02, +0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45, +0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,0x04,0x57,0x69,0x6e,0x65, +0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,0x0c,0x04,0x57,0x69,0x6e,0x65, +0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x39,0x32,0x37,0x31,0x33,0x34,0x31,0x30, +0x34,0x5a,0x17,0x0d,0x32,0x37,0x30,0x39,0x32,0x35,0x31,0x33,0x34,0x31,0x30, +0x34,0x5a,0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02, +0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,0x04,0x54,0x65, +0x73,0x74,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,0x0c,0x04,0x54,0x65, +0x73,0x74,0x30,0x59,0x30,0x13,0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02,0x01, +0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07,0x03,0x42,0x00,0x04,0xed, +0xfc,0x77,0xd8,0xb9,0xe7,0xf3,0xf8,0xce,0x13,0xb8,0x7f,0x0f,0x78,0xea,0x73, +0x87,0x29,0x10,0xe1,0x6d,0x10,0xce,0x57,0x60,0x3b,0x3e,0xb4,0x5f,0x0d,0x20, +0xc1,0xeb,0x6d,0x74,0xe9,0x7b,0x11,0x51,0x9a,0x00,0xe8,0xe9,0x12,0x84,0xb9, +0x07,0x7e,0x7b,0x62,0x67,0x12,0x67,0x08,0xe5,0x2e,0x27,0xce,0xa2,0x57,0x15, +0xad,0xc5,0x1f,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02, +0x03,0x49,0x00,0x30,0x46,0x02,0x21,0x00,0xd7,0x29,0xce,0x5a,0xef,0x74,0x85, +0xd1,0x18,0x5f,0x6e,0xf1,0xba,0x53,0xd4,0xcd,0xdd,0xe0,0x5d,0xf1,0x5e,0x48, +0x51,0xea,0x63,0xc0,0xe8,0xe2,0xf6,0xfa,0x4c,0xaf,0x02,0x21,0x00,0xe3,0x94, +0x15,0x3b,0x6c,0x71,0x6e,0x44,0x22,0xcb,0xa0,0x88,0xcd,0x0a,0x5a,0x50,0x29, +0x7c,0x5c,0xd6,0x6c,0xd2,0xe0,0x7f,0xcd,0x02,0x92,0x21,0x4c,0x2c,0x92,0xee }; +static const BYTE ecc_ca[] = { +0x30,0x82,0x01,0x9f,0x30,0x82,0x01,0x46,0xa0,0x03,0x02,0x01,0x02,0x02,0x09, +0x00,0xf1,0x54,0xae,0x21,0x2e,0x4d,0x31,0x9f,0x30,0x0a,0x06,0x08,0x2a,0x86, +0x48,0xce,0x3d,0x04,0x03,0x02,0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55, +0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a, +0x0c,0x04,0x57,0x69,0x6e,0x65,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03, +0x0c,0x04,0x57,0x69,0x6e,0x65,0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x39,0x32, +0x37,0x31,0x33,0x33,0x39,0x31,0x35,0x5a,0x17,0x0d,0x32,0x37,0x30,0x39,0x32, +0x35,0x31,0x33,0x33,0x39,0x31,0x35,0x5a,0x30,0x2b,0x31,0x0b,0x30,0x09,0x06, +0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55, +0x04,0x0a,0x0c,0x04,0x57,0x69,0x6e,0x65,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55, +0x04,0x03,0x0c,0x04,0x57,0x69,0x6e,0x65,0x30,0x59,0x30,0x13,0x06,0x07,0x2a, +0x86,0x48,0xce,0x3d,0x02,0x01,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01, +0x07,0x03,0x42,0x00,0x04,0x3b,0x3c,0x34,0xc8,0x3f,0x15,0xea,0x02,0x68,0x46, +0x69,0xdf,0x0c,0xa6,0xee,0x7a,0xd9,0x82,0x08,0x9b,0x37,0x53,0x42,0xf3,0x13, +0x63,0xda,0x65,0x79,0xe8,0x04,0x9e,0x8c,0x77,0xc4,0x33,0x77,0xd9,0x5a,0x7f, +0x60,0x7b,0x98,0xce,0xf3,0x96,0x56,0xd6,0xb5,0x8d,0x87,0x7a,0x00,0x2b,0xf3, +0x70,0xb3,0x90,0x73,0xa0,0x56,0x06,0x3b,0x22,0xa3,0x53,0x30,0x51,0x30,0x1d, +0x06,0x03,0x55,0x1d,0x0e,0x04,0x16,0x04,0x14,0x26,0xef,0x6f,0xe4,0xb5,0x24, +0x2f,0x68,0x49,0x84,0xd9,0x89,0xa6,0xab,0x0c,0xf8,0x6d,0xf5,0xe5,0x0c,0x30, +0x1f,0x06,0x03,0x55,0x1d,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x26,0xef,0x6f, +0xe4,0xb5,0x24,0x2f,0x68,0x49,0x84,0xd9,0x89,0xa6,0xab,0x0c,0xf8,0x6d,0xf5, +0xe5,0x0c,0x30,0x0f,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x05,0x30, +0x03,0x01,0x01,0xff,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03, +0x02,0x03,0x47,0x00,0x30,0x44,0x02,0x20,0x2b,0x6b,0x23,0x42,0x32,0xf2,0xcb, +0x71,0xd7,0x5c,0xfa,0x5e,0x6c,0x19,0x31,0xd6,0x74,0xf7,0xc0,0xf8,0xc6,0x39, +0x38,0xe9,0x79,0x4d,0x84,0x44,0x40,0x13,0x8e,0x43,0x02,0x20,0x34,0xc7,0x61, +0xbb,0x18,0x1c,0x85,0x34,0xe3,0x4c,0x30,0x28,0x42,0x0e,0x06,0x65,0x68,0x1d, +0x76,0x53,0x24,0xa0,0x27,0xa5,0x84,0x3b,0x2d,0xf3,0xec,0x27,0x60,0xb2 }; + typedef struct _CONST_DATA_BLOB { @@ -3079,6 +3139,8 @@ static SYSTEMTIME jun2013 = { 2013, 6, 5, 6, 0, 0, 0, 0 }; static SYSTEMTIME oct2016 = { 2016, 10, 6, 1, 0, 0, 0, 0 }; /* Wednesday, Nov 17, 2016 */ static SYSTEMTIME nov2016 = { 2016, 11, 3, 17, 0, 0, 0, 0 }; +/* Wednesday, Nov 17, 2017 */ +static SYSTEMTIME nov2017 = { 2017, 11, 3, 17, 0, 0, 0, 0 }; typedef struct _ChainCheck { @@ -3866,6 +3928,25 @@ static ChainCheck chainCheckEmbeddedNullBroken = { CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS }, 1, simpleStatus27Broken }, 0 }; +static CONST_DATA_BLOB chainECDSA[] = { + { sizeof(ecc_ca), ecc_ca }, + { sizeof(ecc_crt), ecc_crt }, +}; +static const CERT_TRUST_STATUS elementStatusECDSA[] = { + { CERT_TRUST_NO_ERROR, CERT_TRUST_HAS_NAME_MATCH_ISSUER }, + { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_KEY_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, +}; +static const SimpleChainStatusCheck simpleStatusECDSA[] = { + { sizeof(elementStatusECDSA) / sizeof(elementStatusECDSA[0]), elementStatusECDSA }, +}; +static ChainCheck chainCheckECDSA = { + { sizeof(chainECDSA) / sizeof(chainECDSA[0]), chainECDSA }, + { + { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_PREFERRED_ISSUER }, + { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, + 1, simpleStatusECDSA + }, 0 +}; #define test_name_blob(a,b) _test_name_blob(__LINE__,a,b) static void _test_name_blob(unsigned line, CERT_NAME_BLOB *blob, const char *exdata) @@ -4141,6 +4222,16 @@ static void testGetCertChain(void) pCertFreeCertificateChain(chain); + /* Test with ECDSA certificate */ + chain = getChain(NULL, &chainCheckECDSA.certs, 0, TRUE, &nov2017, FALSE, 0); + if (chain) + { + ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_IS_UNTRUSTED_ROOT, + "unexpected chain error status %08x\n", chain->TrustStatus.dwErrorStatus); + checkChainStatus(chain, &chainCheckECDSA.status, chainCheckECDSA.todo, "chainCheckECDSA", 0); + pCertFreeCertificateChain(chain); + } + /* Test HCCE_LOCAL_MACHINE */ ret = CertGetCertificateChain(HCCE_LOCAL_MACHINE, cert, &fileTime, store, ¶, 0, NULL, &chain); ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError()); diff --git a/modules/rostests/winetests/crypt32/crl.c b/modules/rostests/winetests/crypt32/crl.c index 32460e32d9..c350b20f00 100644 --- a/modules/rostests/winetests/crypt32/crl.c +++ b/modules/rostests/winetests/crypt32/crl.c @@ -18,7 +18,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include <stdarg.h> + +#include <windef.h> +#include <winbase.h> +#include <winreg.h> +#include <winerror.h> +#include <wincrypt.h> + +#include "wine/test.h" + static const BYTE bigCert[] = { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, diff --git a/modules/rostests/winetests/crypt32/ctl.c b/modules/rostests/winetests/crypt32/ctl.c index 18993c0965..79a60f8c6e 100644 --- a/modules/rostests/winetests/crypt32/ctl.c +++ b/modules/rostests/winetests/crypt32/ctl.c @@ -18,7 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include <stdarg.h> + +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#include <wincrypt.h> + +#include "wine/test.h" static const BYTE emptyCTL[] = { 0x30,0x17,0x30,0x00,0x18,0x0f,0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30, diff --git a/modules/rostests/winetests/crypt32/encode.c b/modules/rostests/winetests/crypt32/encode.c index 97cedb1981..ad39a35606 100644 --- a/modules/rostests/winetests/crypt32/encode.c +++ b/modules/rostests/winetests/crypt32/encode.c @@ -17,8 +17,16 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#include <wincrypt.h> +#include <snmp.h> + +#include "wine/test.h" -#include "precomp.h" static BOOL (WINAPI *pCryptDecodeObjectEx)(DWORD,LPCSTR,const BYTE*,DWORD,DWORD,PCRYPT_DECODE_PARA,void*,DWORD*); static BOOL (WINAPI *pCryptEncodeObjectEx)(DWORD,LPCSTR,const void*,DWORD,PCRYPT_ENCODE_PARA,void*,DWORD*); @@ -1952,80 +1960,138 @@ static void test_decodeUnicodeNameValue(DWORD dwEncoding) } } -struct encodedOctets -{ - const BYTE *val; - const BYTE *encoded; -}; - -static const unsigned char bin46[] = { 'h','i',0 }; -static const unsigned char bin47[] = { 0x04,0x02,'h','i',0 }; -static const unsigned char bin48[] = { - 's','o','m','e','l','o','n','g',0xff,'s','t','r','i','n','g',0 }; -static const unsigned char bin49[] = { - 0x04,0x0f,'s','o','m','e','l','o','n','g',0xff,'s','t','r','i','n','g',0 }; -static const unsigned char bin50[] = { 0 }; -static const unsigned char bin51[] = { 0x04,0x00,0 }; - -static const struct encodedOctets octets[] = { - { bin46, bin47 }, - { bin48, bin49 }, - { bin50, bin51 }, -}; +static const unsigned char decoded_hi_octet[] = { 'h','i' }; +static const unsigned char encoded_hi_octet[] = { ASN_OCTETSTRING,2,'h','i' }; +static const unsigned char decoded_something_long_octet[] = { + 's','o','m','e','l','o','n','g',0xff,'s','t','r','i','n','g' }; +static const unsigned char encoded_something_long_octet[] = { + ASN_OCTETSTRING,15,'s','o','m','e','l','o','n','g',0xff,'s','t','r','i','n','g' }; +static const unsigned char encoded_empty_octet[] = { ASN_OCTETSTRING,0 }; static void test_encodeOctets(DWORD dwEncoding) { CRYPT_DATA_BLOB blob; DWORD i; - for (i = 0; i < sizeof(octets) / sizeof(octets[0]); i++) + static const struct { + const BYTE *decoded; + UINT decoded_size; + const BYTE *encoded; + UINT encoded_size; + } tests[] = { + { + decoded_hi_octet, sizeof(decoded_hi_octet), + encoded_hi_octet, sizeof(encoded_hi_octet) + },{ + decoded_something_long_octet, sizeof(decoded_something_long_octet), + encoded_something_long_octet, sizeof(encoded_something_long_octet) + },{ + encoded_empty_octet, 0, + encoded_empty_octet, sizeof(encoded_empty_octet) + } + }; + + for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { BYTE *buf = NULL; BOOL ret; DWORD bufSize = 0; - blob.cbData = strlen((const char*)octets[i].val); - blob.pbData = (BYTE*)octets[i].val; + blob.cbData = tests[i].decoded_size; + blob.pbData = (BYTE*)tests[i].decoded; ret = pCryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); if (ret) { - ok(buf[0] == 4, - "Got unexpected type %d for octet string (expected 4)\n", buf[0]); - ok(buf[1] == octets[i].encoded[1], "Got length %d, expected %d\n", - buf[1], octets[i].encoded[1]); - ok(!memcmp(buf + 1, octets[i].encoded + 1, - octets[i].encoded[1] + 1), "Got unexpected value\n"); + ok(bufSize == tests[i].encoded_size, "[%u] buf size %u expected %u\n", + i, bufSize, tests[i].encoded_size); + ok(buf[0] == 4, "Got unexpected type %d for octet string (expected 4)\n", buf[0]); + ok(buf[1] == tests[i].decoded_size, "[%u] Got length %d, expected %d\n", + i, buf[1], tests[i].decoded_size); + ok(!memcmp(buf, tests[i].encoded, tests[i].encoded_size), "[%u] Got unexpected value\n", i); LocalFree(buf); } } } +static const unsigned char encoded_constructed_hi_octet[] = + { ASN_CONSTRUCTOR|ASN_OCTETSTRING,0x80, ASN_OCTETSTRING,2,'h','i', 0,0 }; +static const unsigned char encoded_constructed_hi_octet2[] = + { ASN_CONSTRUCTOR|ASN_OCTETSTRING,4, ASN_OCTETSTRING,2,'h','i', 1,2,3 }; +static const unsigned char encoded_constructed_hi_octet3[] = + { ASN_CONSTRUCTOR|ASN_OCTETSTRING,8, ASN_CONSTRUCTOR|ASN_OCTETSTRING,0x80, ASN_OCTETSTRING,2,'h','i', 0,0, 0,0 }; +static const unsigned char encoded_constructed_hi_octet_invalid_end[] = + { ASN_CONSTRUCTOR|ASN_OCTETSTRING,0x80, ASN_OCTETSTRING,2,'h','i', 0,1 }; + static void test_decodeOctets(DWORD dwEncoding) { DWORD i; - for (i = 0; i < sizeof(octets) / sizeof(octets[0]); i++) + static const struct { + const BYTE *encoded; + UINT encoded_size; + const BYTE *decoded; + UINT decoded_size; + DWORD error; + } tests[] = { + { + encoded_hi_octet, sizeof(encoded_hi_octet), + decoded_hi_octet, sizeof(decoded_hi_octet) + },{ + encoded_something_long_octet, sizeof(encoded_something_long_octet), + decoded_something_long_octet, sizeof(decoded_something_long_octet) + },{ + encoded_constructed_hi_octet, sizeof(encoded_constructed_hi_octet), + decoded_hi_octet, sizeof(decoded_hi_octet) + },{ + encoded_constructed_hi_octet2, sizeof(encoded_constructed_hi_octet2), + decoded_hi_octet, sizeof(decoded_hi_octet) + },{ + encoded_constructed_hi_octet3, sizeof(encoded_constructed_hi_octet3), + decoded_hi_octet, sizeof(decoded_hi_octet) + },{ + encoded_empty_octet, sizeof(encoded_empty_octet), + encoded_empty_octet, 0 + },{ + encoded_hi_octet, sizeof(encoded_hi_octet) - 1, + NULL, 0, CRYPT_E_ASN1_EOD + },{ + encoded_constructed_hi_octet, sizeof(encoded_constructed_hi_octet) - 1, + NULL, 0, CRYPT_E_ASN1_EOD + },{ + encoded_constructed_hi_octet_invalid_end, sizeof(encoded_constructed_hi_octet_invalid_end), + NULL, 0, CRYPT_E_ASN1_CORRUPT + } + }; + + for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { BYTE *buf = NULL; BOOL ret; DWORD bufSize = 0; ret = pCryptDecodeObjectEx(dwEncoding, X509_OCTET_STRING, - octets[i].encoded, octets[i].encoded[1] + 2, + tests[i].encoded, tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - ok(bufSize >= sizeof(CRYPT_DATA_BLOB) + octets[i].encoded[1], - "Expected size >= %d, got %d\n", - (int)sizeof(CRYPT_DATA_BLOB) + octets[i].encoded[1], bufSize); + if (tests[i].error) + { + ok(!ret && GetLastError() == tests[i].error, + "[%u] CryptDecodeObjectEx returned %x(%x)\n", i, ret, GetLastError()); + continue; + } + ok(ret, "[%u] CryptDecodeObjectEx failed: %08x\n", i, GetLastError()); + ok(bufSize >= sizeof(CRYPT_DATA_BLOB) + tests[i].decoded_size, + "[%u] Expected size >= %d, got %d\n", i, + (int)sizeof(CRYPT_DATA_BLOB) + tests[i].decoded_size, bufSize); ok(buf != NULL, "Expected allocated buffer\n"); if (ret) { CRYPT_DATA_BLOB *blob = (CRYPT_DATA_BLOB *)buf; + ok (blob->cbData == tests[i].decoded_size, "[%u] cbData = %u\n", i, blob->cbData); if (blob->cbData) - ok(!memcmp(blob->pbData, octets[i].val, blob->cbData), + ok(!memcmp(blob->pbData, tests[i].decoded, blob->cbData), "Unexpected value\n"); LocalFree(buf); } @@ -3302,18 +3368,76 @@ static const BYTE hash[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; static const BYTE signedBigCert[] = { - 0x30, 0x81, 0x93, 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, 0x00, 0x30, - 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, - 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22, 0x18, 0x0f, - 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, - 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, - 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00, 0xa3, - 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, - 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, - 0x00, 0x03, 0x11, 0x00, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, - 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 }; + ASN_SEQUENCE,0x81,147, + ASN_SEQUENCE,122, + ASN_INTEGER,1, 0x01, + ASN_SEQUENCE,2, + ASN_OBJECTIDENTIFIER,0, + ASN_SEQUENCE,21, + 0x31,19, + ASN_SEQUENCE,17, + ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03, + 0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00, + ASN_SEQUENCE,34, + 0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a, + 0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a, + ASN_SEQUENCE,21, + 0x31,19, + ASN_SEQUENCE,17, + ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03, + 0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00, + ASN_SEQUENCE,7, + ASN_SEQUENCE,2, + ASN_OBJECTIDENTIFIER,0, + ASN_BITS,1, 0x00, + 0xa3,22, + ASN_SEQUENCE,20, + ASN_SEQUENCE,18, + ASN_OBJECTIDENTIFIER,3, 0x55,0x1d,0x13, + 0x01,1, 0xff, + ASN_OCTETSTRING,8, 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01, + ASN_SEQUENCE,2, + ASN_OBJECTIDENTIFIER,0, + ASN_BITS,17, 0x00,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08, + 0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00 +}; + +static const BYTE signedBigCertWithIndefiniteSeq[] = { + ASN_SEQUENCE,0x81,151, + ASN_SEQUENCE,126, + ASN_INTEGER,1, 0x01, + ASN_SEQUENCE,2, + ASN_OBJECTIDENTIFIER,0, + ASN_SEQUENCE,21, + 0x31,19, + ASN_SEQUENCE,17, + ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03, + 0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00, + ASN_SEQUENCE,0x80, + 0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a, + 0x18,15, 0x31,0x36,0x30,0x31,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5a, + 0,0, + ASN_SEQUENCE,21, + 0x31,19, + ASN_SEQUENCE,17, + ASN_OBJECTIDENTIFIER,3, 0x55,0x04,0x03, + 0x13,10, 0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x00, + ASN_SEQUENCE,0x80, + ASN_SEQUENCE,2, + ASN_OBJECTIDENTIFIER,0, + ASN_BITS,1, 0x00, + 0,0, + 0xa3,22, + ASN_SEQUENCE,20, + ASN_SEQUENCE,18, + ASN_OBJECTIDENTIFIER,3, 0x55,0x1d,0x13, + 0x01,1, 0xff, + ASN_OCTETSTRING,8, 0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01, + ASN_SEQUENCE,2, + ASN_OBJECTIDENTIFIER,0, + ASN_BITS,17, 0x00,0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08, + 0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00 +}; static void test_encodeCert(DWORD dwEncoding) { @@ -3369,6 +3493,29 @@ static void test_decodeCert(DWORD dwEncoding) { CERT_INFO *info = (CERT_INFO *)buf; + ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size); + ok(info->SerialNumber.cbData == 1, + "Expected serial number size 1, got %d\n", info->SerialNumber.cbData); + ok(*info->SerialNumber.pbData == *serialNum, + "Expected serial number %d, got %d\n", *serialNum, + *info->SerialNumber.pbData); + ok(info->Issuer.cbData == sizeof(encodedCommonName), + "Wrong size %d\n", info->Issuer.cbData); + ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData), + "Unexpected issuer\n"); + ok(info->Subject.cbData == sizeof(encodedCommonName), + "Wrong size %d\n", info->Subject.cbData); + ok(!memcmp(info->Subject.pbData, encodedCommonName, + info->Subject.cbData), "Unexpected subject\n"); + LocalFree(buf); + } + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCertWithIndefiniteSeq, + sizeof(signedBigCertWithIndefiniteSeq), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); + ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + if (ret) + { + CERT_INFO *info = (CERT_INFO *)buf; + ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size); ok(info->SerialNumber.cbData == 1, "Expected serial number size 1, got %d\n", info->SerialNumber.cbData); @@ -5909,32 +6056,79 @@ static const BYTE indefiniteSignedPKCSContent[] = { 0xe3,0x55,0x71,0x91,0xf9,0x2a,0xd1,0xb8,0xaa,0x52,0xb8,0x22,0x3a,0xeb,0x61, 0x00,0x00,0x00,0x00,0x00,0x00 }; +static const BYTE content_abcd[] = { + ASN_SEQUENCE, 0x80, + ASN_OBJECTIDENTIFIER, 2, 42,3, + ASN_CONTEXT|ASN_CONSTRUCTOR, 0x80, + ASN_OCTETSTRING, 4, 'a','b','c','d', + 0,0, + 0,0, +}; + +static const BYTE encoded_abcd[] = { + ASN_OCTETSTRING, 4, 'a','b','c','d', +}; + +static const BYTE content_constructed_abcd[] = { + ASN_SEQUENCE, 0x80, + ASN_OBJECTIDENTIFIER, 2, 42,3, + ASN_CONTEXT|ASN_CONSTRUCTOR, 0x80, + ASN_CONSTRUCTOR|ASN_OCTETSTRING,0x80, + ASN_OCTETSTRING, 4, 'a','b','0','0', + 0,0, + 0,0, + 0,0, + 1,2,3,4,5,6,7 /* extra garbage */ +}; + static void test_decodePKCSContentInfo(DWORD dwEncoding) { BOOL ret; LPBYTE buf = NULL; - DWORD size = 0; + DWORD size = 0, i; CRYPT_CONTENT_INFO *info; - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, - emptyPKCSContentInfo, sizeof(emptyPKCSContentInfo), - CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); - if (ret) + const struct { + const BYTE *encoded; + UINT encoded_size; + const char *obj_id; + const BYTE *content; + UINT content_size; + } tests[] = { + { emptyPKCSContentInfo, sizeof(emptyPKCSContentInfo), + "1.2.3", NULL, 0 }, + { emptyPKCSContentInfoExtraBytes, sizeof(emptyPKCSContentInfoExtraBytes), + "1.2.3", NULL, 0 }, + { intPKCSContentInfo, sizeof(intPKCSContentInfo), + "1.2.3", ints[0].encoded, ints[0].encoded[1] + 2 }, + { indefiniteSignedPKCSContent, sizeof(indefiniteSignedPKCSContent), + "1.2.840.113549.1.7.2", NULL, 392 }, + { content_abcd, sizeof(content_abcd), + "1.2.3", encoded_abcd, 6 }, + { content_constructed_abcd, sizeof(content_constructed_abcd), + "1.2.3", content_constructed_abcd + 8, 10 } + }; + + for (i = 0; i < sizeof(tests)/sizeof(*tests); i++) { + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, tests[i].encoded, + tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); + ok(ret, "[%u] CryptDecodeObjectEx failed: %x\n", i, GetLastError()); + if (!ret) continue; + info = (CRYPT_CONTENT_INFO *)buf; - ok(!strcmp(info->pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n", - info->pszObjId); - ok(info->Content.cbData == 0, "Expected no data, got %d\n", - info->Content.cbData); + ok(!strcmp(info->pszObjId, tests[i].obj_id), "[%u] Expected %s, got %s\n", + i, tests[i].obj_id, info->pszObjId); + ok(info->Content.cbData == tests[i].content_size, + "[%u] Unexpected size %d expected %d\n", i, info->Content.cbData, + tests[i].content_size); + if (tests[i].content) + ok(!memcmp(info->Content.pbData, tests[i].content, tests[i].content_size), + "[%u] Unexpected value\n", i); LocalFree(buf); } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, - emptyPKCSContentInfoExtraBytes, sizeof(emptyPKCSContentInfoExtraBytes), - 0, NULL, NULL, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); - SetLastError(0xdeadbeef); + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, bogusPKCSContentInfo, sizeof(bogusPKCSContentInfo), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); @@ -5945,36 +6139,6 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding) GetLastError() == CRYPT_E_ASN1_CORRUPT)) || broken(ret), "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %x\n", GetLastError()); - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, - intPKCSContentInfo, sizeof(intPKCSContentInfo), - CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); - if (ret) - { - info = (CRYPT_CONTENT_INFO *)buf; - - ok(!strcmp(info->pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n", - info->pszObjId); - ok(info->Content.cbData == ints[0].encoded[1] + 2, - "Unexpected size %d\n", info->Content.cbData); - ok(!memcmp(info->Content.pbData, ints[0].encoded, - info->Content.cbData), "Unexpected value\n"); - LocalFree(buf); - } - ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, - indefiniteSignedPKCSContent, sizeof(indefiniteSignedPKCSContent), - CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); - ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); - if (ret) - { - info = (CRYPT_CONTENT_INFO *)buf; - - ok(!strcmp(info->pszObjId, szOID_RSA_signedData), - "Expected %s, got %s\n", szOID_RSA_signedData, info->pszObjId); - ok(info->Content.cbData == 392, "Expected 392, got %d\n", - info->Content.cbData); - LocalFree(buf); - } } static const BYTE emptyPKCSAttr[] = { 0x30,0x06,0x06,0x02,0x2a,0x03,0x31, @@ -8345,6 +8509,173 @@ static void testPortPublicKeyInfo(void) ok(ret,"CryptAcquireContextA failed\n"); } +static const BYTE eccCert[] = { +0x30,0x82,0x01,0x46,0x30,0x81,0xec,0x02,0x09,0x00,0xe7,0x6b, +0x26,0x86,0x0a,0x82,0xff,0xe9,0x30,0x0a,0x06,0x08,0x2a,0x86, +0x48,0xce,0x3d,0x04,0x03,0x02,0x30,0x2b,0x31,0x0b,0x30,0x09, +0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x0d,0x30, +0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,0x04,0x57,0x69,0x6e,0x65, +0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,0x0c,0x04,0x57, +0x69,0x6e,0x65,0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x39,0x32, +0x37,0x31,0x33,0x34,0x31,0x30,0x34,0x5a,0x17,0x0d,0x32,0x37, +0x30,0x39,0x32,0x35,0x31,0x33,0x34,0x31,0x30,0x34,0x5a,0x30, +0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02, +0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c, +0x04,0x54,0x65,0x73,0x74,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55, +0x04,0x03,0x0c,0x04,0x54,0x65,0x73,0x74,0x30,0x59,0x30,0x13, +0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02,0x01,0x06,0x08,0x2a, +0x86,0x48,0xce,0x3d,0x03,0x01,0x07,0x03,0x42,0x00,0x04,0xed, +0xfc,0x77,0xd8,0xb9,0xe7,0xf3,0xf8,0xce,0x13,0xb8,0x7f,0x0f, +0x78,0xea,0x73,0x87,0x29,0x10,0xe1,0x6d,0x10,0xce,0x57,0x60, +0x3b,0x3e,0xb4,0x5f,0x0d,0x20,0xc1,0xeb,0x6d,0x74,0xe9,0x7b, +0x11,0x51,0x9a,0x00,0xe8,0xe9,0x12,0x84,0xb9,0x07,0x7e,0x7b, +0x62,0x67,0x12,0x67,0x08,0xe5,0x2e,0x27,0xce,0xa2,0x57,0x15, +0xad,0xc5,0x1f,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d, +0x04,0x03,0x02,0x03,0x49,0x00,0x30,0x46,0x02,0x21,0x00,0xd7, +0x29,0xce,0x5a,0xef,0x74,0x85,0xd1,0x18,0x5f,0x6e,0xf1,0xba, +0x53,0xd4,0xcd,0xdd,0xe0,0x5d,0xf1,0x5e,0x48,0x51,0xea,0x63, +0xc0,0xe8,0xe2,0xf6,0xfa,0x4c,0xaf,0x02,0x21,0x00,0xe3,0x94, +0x15,0x3b,0x6c,0x71,0x6e,0x44,0x22,0xcb,0xa0,0x88,0xcd,0x0a, +0x5a,0x50,0x29,0x7c,0x5c,0xd6,0x6c,0xd2,0xe0,0x7f,0xcd,0x02, +0x92,0x21,0x4c,0x2c,0x92,0xee }; +static const BYTE ecdsaSig[] = { +0x30,0x46,0x02,0x21,0x00,0xd7,0x29,0xce,0x5a,0xef,0x74,0x85, +0xd1,0x18,0x5f,0x6e,0xf1,0xba,0x53,0xd4,0xcd,0xdd,0xe0,0x5d, +0xf1,0x5e,0x48,0x51,0xea,0x63,0xc0,0xe8,0xe2,0xf6,0xfa,0x4c, +0xaf,0x02,0x21,0x00,0xe3,0x94,0x15,0x3b,0x6c,0x71,0x6e,0x44, +0x22,0xcb,0xa0,0x88,0xcd,0x0a,0x5a,0x50,0x29,0x7c,0x5c,0xd6, +0x6c,0xd2,0xe0,0x7f,0xcd,0x02,0x92,0x21,0x4c,0x2c,0x92,0xee }; +static const BYTE eccPubKey[] = { +0x30,0x59,0x30,0x13,0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02, +0x01,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07,0x03, +0x42,0x00,0x04,0xed,0xfc,0x77,0xd8,0xb9,0xe7,0xf3,0xf8,0xce, +0x13,0xb8,0x7f,0x0f,0x78,0xea,0x73,0x87,0x29,0x10,0xe1,0x6d, +0x10,0xce,0x57,0x60,0x3b,0x3e,0xb4,0x5f,0x0d,0x20,0xc1,0xeb, +0x6d,0x74,0xe9,0x7b,0x11,0x51,0x9a,0x00,0xe8,0xe9,0x12,0x84, +0xb9,0x07,0x7e,0x7b,0x62,0x67,0x12,0x67,0x08,0xe5,0x2e,0x27, +0xce,0xa2,0x57,0x15,0xad,0xc5,0x1f }; + +static void testECDSACert(void) +{ + DWORD decode_flags = CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG; + CERT_SIGNED_CONTENT_INFO *info; + CERT_PUBLIC_KEY_INFO *pubkey; + CERT_ECC_SIGNATURE *ecc_sig; + LPSTR *ecc_curve; + DWORD size; + BOOL ret; + int i; + + info = NULL; + ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT, eccCert, sizeof(eccCert), decode_flags, + NULL, &info, &size); + ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError()); + + ok(!strcmp(info->SignatureAlgorithm.pszObjId, szOID_ECDSA_SHA256), + "Expected 1.2.840.10045.4.3.2, got %s\n", info->SignatureAlgorithm.pszObjId); + ok(!info->SignatureAlgorithm.Parameters.cbData, + "Expected no parameter data, got %d bytes\n", info->SignatureAlgorithm.Parameters.cbData); + ok(!info->SignatureAlgorithm.Parameters.pbData, + "Expected no parameter data, got %p pointer\n", info->SignatureAlgorithm.Parameters.pbData); + + ok(info->Signature.cbData == sizeof(ecdsaSig), + "Expected %d bytes, got %d\n", (int)sizeof(ecdsaSig), info->Signature.cbData); + ok(info->Signature.pbData != NULL, "Got NULL pointer\n"); + ok(!info->Signature.cUnusedBits, "Expected no unused bytes, got %d\n", info->Signature.cUnusedBits); + for (i = 0; i < info->Signature.cbData; i++) + { + ok(ecdsaSig[i] == info->Signature.pbData[i], "Expected %02x, got %02x at offset %d\n", + ecdsaSig[i], info->Signature.pbData[i], i); + } + + ecc_sig = NULL; + ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_ECC_SIGNATURE, info->Signature.pbData, + info->Signature.cbData, decode_flags, NULL, &ecc_sig, &size); + ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError()); + if (ret) + { + ok(ecc_sig->r.cbData == 32, "Expected 32 bytes, got %d\n", ecc_sig->r.cbData); + ok(ecc_sig->r.pbData != NULL, "Got NULL pointer\n"); + ok(ecc_sig->s.cbData == 32, "Expected 32 bytes, got %d\n", ecc_sig->s.cbData); + ok(ecc_sig->s.pbData != NULL, "Got NULL pointer\n"); + for (i = 0; i < ecc_sig->r.cbData; i++) + { + ok(ecdsaSig[4+32-i] == ecc_sig->r.pbData[i], "Expected %02x, got %02x at offset %d\n", + ecdsaSig[4+32-i], ecc_sig->r.pbData[i], i); + } + for (i = 0; i < ecc_sig->s.cbData; i++) + { + ok(ecdsaSig[4+35+32-i] == ecc_sig->s.pbData[i], "Expected %02x, got %02x at offset %d\n", + ecdsaSig[4+35+32-i], ecc_sig->s.pbData[i], i); + } + LocalFree(ecc_sig); + } + + LocalFree(info); + + info = NULL; + decode_flags &= ~CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG; + ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT, eccCert, sizeof(eccCert), decode_flags, + NULL, &info, &size); + ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError()); + + ok(info->Signature.cbData == sizeof(ecdsaSig), + "Expected %d bytes, got %d\n", (int)sizeof(ecdsaSig), info->Signature.cbData); + ok(info->Signature.pbData != NULL, "Got NULL pointer\n"); + ok(!info->Signature.cUnusedBits, "Expected no unused bytes, got %d\n", info->Signature.cUnusedBits); + for (i = 0; i < info->Signature.cbData; i++) + { + ok(ecdsaSig[sizeof(ecdsaSig)-i-1] == info->Signature.pbData[i], "Expected %02x, got %02x at offset %d\n", + ecdsaSig[sizeof(ecdsaSig)-i-1], info->Signature.pbData[i], i); + } + + LocalFree(info); + + pubkey = NULL; + ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, eccPubKey, sizeof(eccPubKey), + decode_flags, NULL, &pubkey, &size); + ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError()); + + ok(!strcmp(pubkey->Algorithm.pszObjId, szOID_ECC_PUBLIC_KEY), + "Expected 1.2.840.10045.2.1, got %s\n", pubkey->Algorithm.pszObjId); + ok(pubkey->Algorithm.Parameters.cbData == 10, + "Expected 10 bytes parameters, got %d bytes\n", pubkey->Algorithm.Parameters.cbData); + ok(pubkey->Algorithm.Parameters.pbData != NULL, + "Expected pointer to parameters, got NULL\n"); + + ecc_curve = NULL; + ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_OBJECT_IDENTIFIER, pubkey->Algorithm.Parameters.pbData, + pubkey->Algorithm.Parameters.cbData, decode_flags, NULL, &ecc_curve, &size); + ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND /* < Vista */), + "CryptDecodeObjectEx failed with %d\n", GetLastError()); + if (ret) + { + ok(!strcmp(*ecc_curve, szOID_ECC_CURVE_P256), "Expected 1.2.840.10045.3.1.7, got %s\n", *ecc_curve); + LocalFree(ecc_curve); + } + + ecc_curve = NULL; + ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, szOID_ECC_PUBLIC_KEY, pubkey->Algorithm.Parameters.pbData, + pubkey->Algorithm.Parameters.cbData, decode_flags, NULL, &ecc_curve, &size); + ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND /* < Vista */), + "CryptDecodeObjectEx failed with %d\n", GetLastError()); + if (ret) + { + ok(!strcmp(*ecc_curve, szOID_ECC_CURVE_P256), "Expected 1.2.840.10045.3.1.7, got %s\n", *ecc_curve); + LocalFree(ecc_curve); + } + + ok(pubkey->PublicKey.cbData == 65, "Expected 32 bytes parameters, got %d bytes\n", pubkey->PublicKey.cbData); + ok(pubkey->PublicKey.pbData != NULL, "Expected pointer to parameters, got NULL\n"); + for (i = 0; i < pubkey->PublicKey.cbData; i++) + { + ok(eccPubKey[26+i] == pubkey->PublicKey.pbData[i], "Expected %02x, got %02x at offset %d\n", + eccPubKey[26+i], pubkey->PublicKey.pbData[i], i); + } + + LocalFree(pubkey); +} + START_TEST(encode) { static const DWORD encodings[] = { X509_ASN_ENCODING, PKCS_7_ASN_ENCODING, @@ -8438,4 +8769,5 @@ START_TEST(encode) test_decodeRsaPrivateKey(encodings[i]); } testPortPublicKeyInfo(); + testECDSACert(); } diff --git a/modules/rostests/winetests/crypt32/main.c b/modules/rostests/winetests/crypt32/main.c index d6ef8ddeed..a0019b5869 100644 --- a/modules/rostests/winetests/crypt32/main.c +++ b/modules/rostests/winetests/crypt32/main.c @@ -18,7 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#include <wincrypt.h> +#include <winreg.h> + +#include "wine/test.h" static HMODULE hCrypt; diff --git a/modules/rostests/winetests/crypt32/message.c b/modules/rostests/winetests/crypt32/message.c index 11f3ff0cf3..7e2e8aa840 100644 --- a/modules/rostests/winetests/crypt32/message.c +++ b/modules/rostests/winetests/crypt32/message.c @@ -18,7 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#include <wincrypt.h> + +#include "wine/test.h" static BOOL (WINAPI * pCryptAcquireContextA) (HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD); diff --git a/modules/rostests/winetests/crypt32/msg.c b/modules/rostests/winetests/crypt32/msg.c index 45a012a22c..c2405335b9 100644 --- a/modules/rostests/winetests/crypt32/msg.c +++ b/modules/rostests/winetests/crypt32/msg.c @@ -18,7 +18,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#define CMSG_SIGNER_ENCODE_INFO_HAS_CMS_FIELDS +#define CMSG_SIGNED_ENCODE_INFO_HAS_CMS_FIELDS +#include <wincrypt.h> + +#include "wine/test.h" static BOOL have_nt = TRUE; static BOOL old_crypt32 = FALSE; @@ -2848,7 +2857,7 @@ static void test_decode_msg_get_param(void) HCRYPTPROV hCryptProv; HCRYPTKEY key = 0; BOOL ret; - DWORD size = 0, value; + DWORD size = 0, value, req_size; LPBYTE buf; CMSG_CTRL_DECRYPT_PARA decryptPara = { sizeof(decryptPara), 0 }; @@ -2938,7 +2947,10 @@ static void test_decode_msg_get_param(void) signer.SerialNumber.cbData = sizeof(serialNum); signer.SerialNumber.pbData = serialNum; signer.HashAlgorithm.pszObjId = oid_rsa_md5; + req_size = size; + size += 10; CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, buf, &size); + ok(size == req_size, "size = %u, expected %u\n", size, req_size); compare_signer_info((CMSG_SIGNER_INFO *)buf, &signer); CryptMemFree(buf); } diff --git a/modules/rostests/winetests/crypt32/object.c b/modules/rostests/winetests/crypt32/object.c index 61e64442f5..211b5423e0 100644 --- a/modules/rostests/winetests/crypt32/object.c +++ b/modules/rostests/winetests/crypt32/object.c @@ -17,8 +17,14 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#include <wincrypt.h> -#include "precomp.h" +#include "wine/test.h" static BOOL (WINAPI * pCryptQueryObject)(DWORD, const void *, DWORD, DWORD, DWORD, DWORD *, DWORD *, DWORD *, HCERTSTORE *, HCRYPTMSG *, const void **); diff --git a/modules/rostests/winetests/crypt32/oid.c b/modules/rostests/winetests/crypt32/oid.c index 9a3dbe130c..89d58b77f8 100644 --- a/modules/rostests/winetests/crypt32/oid.c +++ b/modules/rostests/winetests/crypt32/oid.c @@ -17,8 +17,17 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS +#include <wincrypt.h> +#include <winreg.h> + +#include "wine/test.h" -#include "precomp.h" static BOOL (WINAPI *pCryptEnumOIDInfo)(DWORD,DWORD,void*,PFN_CRYPT_ENUM_OID_INFO); @@ -28,6 +37,7 @@ struct OIDToAlgID LPCSTR oid; LPCSTR altOid; DWORD algID; + DWORD altAlgID; }; static const struct OIDToAlgID oidToAlgID[] = { @@ -64,6 +74,9 @@ static const struct OIDToAlgID oidToAlgID[] = { { szOID_OIWDIR_md2RSA, NULL, CALG_MD2 }, { szOID_INFOSEC_mosaicUpdatedSig, NULL, CALG_SHA }, { szOID_INFOSEC_mosaicKMandUpdSig, NULL, CALG_DSS_SIGN }, + { szOID_NIST_sha256, NULL, CALG_SHA_256, -1 }, + { szOID_NIST_sha384, NULL, CALG_SHA_384, -1 }, + { szOID_NIST_sha512, NULL, CALG_SHA_512, -1 } }; static const struct OIDToAlgID algIDToOID[] = { @@ -96,10 +109,7 @@ static void testOIDToAlgID(void) for (i = 0; i < sizeof(oidToAlgID) / sizeof(oidToAlgID[0]); i++) { alg = CertOIDToAlgId(oidToAlgID[i].oid); - /* Not all Windows installations support all these, so make sure it's - * at least not the wrong one. - */ - ok(alg == 0 || alg == oidToAlgID[i].algID, + ok(alg == oidToAlgID[i].algID || (oidToAlgID[i].altAlgID && alg == oidToAlgID[i].altAlgID), "Expected %d, got %d\n", oidToAlgID[i].algID, alg); } } @@ -118,6 +128,7 @@ static void testAlgIDToOID(void) { oid = CertAlgIdToOID(algIDToOID[i].algID); /* Allow failure, not every version of Windows supports every algo */ + ok(oid != NULL || broken(!oid), "CertAlgIdToOID failed, expected %s\n", algIDToOID[i].oid); if (oid) { if (strcmp(oid, algIDToOID[i].oid)) @@ -533,12 +544,16 @@ static void test_enumOIDInfo(void) static void test_findOIDInfo(void) { + static WCHAR sha256ECDSA[] = { 's','h','a','2','5','6','E','C','D','S','A',0 }; static WCHAR sha1[] = { 's','h','a','1',0 }; - static CHAR oid_rsa_md5[] = szOID_RSA_MD5; + static CHAR oid_rsa_md5[] = szOID_RSA_MD5, oid_sha256[] = szOID_NIST_sha256; + static CHAR oid_ecda_sha25[] = szOID_ECDSA_SHA256; ALG_ID alg = CALG_SHA1; ALG_ID algs[2] = { CALG_MD5, CALG_RSA_SIGN }; PCCRYPT_OID_INFO info; + static const WCHAR sha256W[] = {'s','h','a','2','5','6',0}; + info = CryptFindOIDInfo(0, NULL, 0); ok(info == NULL, "Expected NULL\n"); info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, 0); @@ -577,6 +592,49 @@ static void test_findOIDInfo(void) ok(U(*info).Algid == CALG_MD5, "Expected CALG_MD5, got %d\n", U(*info).Algid); } + + info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_sha256, 0); + ok(info != NULL, "Expected to find szOID_RSA_MD5\n"); + if (info) + { + ok(!strcmp(info->pszOID, szOID_NIST_sha256), "Expected %s, got %s\n", + szOID_NIST_sha256, info->pszOID); + ok(!lstrcmpW(info->pwszName, sha256W), "pwszName = %s\n", wine_dbgstr_w(info->pwszName)); + ok(U(*info).Algid == CALG_SHA_256 || U(*info).Algid == -1, + "Expected CALG_MD5 or -1, got %d\n", U(*info).Algid); + } + + info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_ecda_sha25, 0); + if (info) + { + DWORD *data; + + ok(info->cbSize == sizeof(*info), + "Expected %d, got %d\n", (int)sizeof(*info), info->cbSize); + ok(!strcmp(info->pszOID, oid_ecda_sha25), + "Expected %s, got %s\n", oid_ecda_sha25, info->pszOID); + ok(!lstrcmpW(info->pwszName, sha256ECDSA), + "Expected %s, got %s\n", wine_dbgstr_w(sha256ECDSA), wine_dbgstr_w(info->pwszName)); + ok(info->dwGroupId == CRYPT_SIGN_ALG_OID_GROUP_ID, + "Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %u\n", info->dwGroupId); + ok(U(*info).Algid == CALG_OID_INFO_CNG_ONLY, + "Expected CALG_OID_INFO_CNG_ONLY, got %d\n", U(*info).Algid); + + data = (DWORD *)info->ExtraInfo.pbData; + ok(info->ExtraInfo.cbData == 8, + "Expected 8, got %d\n", info->ExtraInfo.cbData); + ok(data[0] == CALG_OID_INFO_PARAMETERS, + "Expected CALG_OID_INFO_PARAMETERS, got %x\n", data[0]); + ok(data[1] == CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, + "Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %x\n", data[1]); + + ok(!lstrcmpW(info->pwszCNGAlgid, BCRYPT_SHA256_ALGORITHM), "Expected %s, got %s\n", + wine_dbgstr_w(BCRYPT_SHA256_ALGORITHM), wine_dbgstr_w(info->pwszCNGAlgid)); + ok(!lstrcmpW(info->pwszCNGExtraAlgid, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM), "Expected %s, got %s\n", + wine_dbgstr_w(CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM), wine_dbgstr_w(info->pwszCNGExtraAlgid)); + } + else + win_skip("Host does not support ECDSA_SHA256, skipping test\n"); } START_TEST(oid) diff --git a/modules/rostests/winetests/crypt32/precomp.h b/modules/rostests/winetests/crypt32/precomp.h index 81c3376acc..247edf56f1 100644 --- a/modules/rostests/winetests/crypt32/precomp.h +++ b/modules/rostests/winetests/crypt32/precomp.h @@ -1,3 +1,4 @@ + #ifndef _CRYPT32_WINETEST_PRECOMP_H_ #define _CRYPT32_WINETEST_PRECOMP_H_ @@ -5,12 +6,16 @@ #define _INC_WINDOWS #define COM_NO_WINDOWS_H + #include <ntstatus.h> #define WIN32_NO_STATUS + #include <wine/test.h> #include <winreg.h> + #define CMSG_SIGNER_ENCODE_INFO_HAS_CMS_FIELDS #define CMSG_SIGNED_ENCODE_INFO_HAS_CMS_FIELDS +#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS #include <wincrypt.h> #endif /* !_CRYPT32_WINETEST_PRECOMP_H_ */ diff --git a/modules/rostests/winetests/crypt32/protectdata.c b/modules/rostests/winetests/crypt32/protectdata.c index 3cde714cad..70a8ba86b0 100644 --- a/modules/rostests/winetests/crypt32/protectdata.c +++ b/modules/rostests/winetests/crypt32/protectdata.c @@ -18,7 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#include <wincrypt.h> + +#include "wine/test.h" static BOOL (WINAPI *pCryptProtectData)(DATA_BLOB*,LPCWSTR,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*); static BOOL (WINAPI *pCryptUnprotectData)(DATA_BLOB*,LPWSTR*,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*); diff --git a/modules/rostests/winetests/crypt32/sip.c b/modules/rostests/winetests/crypt32/sip.c index 512146e826..e2ec2f411d 100644 --- a/modules/rostests/winetests/crypt32/sip.c +++ b/modules/rostests/winetests/crypt32/sip.c @@ -19,11 +19,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" - +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> #include <winnls.h> +#include <wincrypt.h> #include <mssip.h> +#include "wine/test.h" + static BOOL (WINAPI * funcCryptSIPGetSignedDataMsg)(SIP_SUBJECTINFO *,DWORD *,DWORD,DWORD *,BYTE *); static BOOL (WINAPI * funcCryptSIPPutSignedDataMsg)(SIP_SUBJECTINFO *,DWORD,DWORD *,DWORD,BYTE *); static BOOL (WINAPI * funcCryptSIPCreateIndirectData)(SIP_SUBJECTINFO *,DWORD *,SIP_INDIRECT_DATA *); diff --git a/modules/rostests/winetests/crypt32/store.c b/modules/rostests/winetests/crypt32/store.c index 226ffc04c3..47cd0b38cd 100644 --- a/modules/rostests/winetests/crypt32/store.c +++ b/modules/rostests/winetests/crypt32/store.c @@ -18,10 +18,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winuser.h> #include <shlobj.h> #include <shlwapi.h> +#include <winreg.h> +#include <winerror.h> +#include <wincrypt.h> + +#include "wine/test.h" /* The following aren't defined in wincrypt.h, as they're "reserved" */ #define CERT_CERT_PROP_ID 32 @@ -108,16 +117,6 @@ static const BYTE signedCTLWithCTLInnerContent[] = { 0x8e,0xe7,0x5f,0x76,0x2b,0xd1,0x6a,0x82,0xb3,0x30,0x25,0x61,0xf6,0x25,0x23, 0x57,0x6c,0x0b,0x47,0xb8 }; -static BOOL (WINAPI *pCertControlStore)(HCERTSTORE,DWORD,DWORD,void const*); -static PCCRL_CONTEXT (WINAPI *pCertEnumCRLsInStore)(HCERTSTORE,PCCRL_CONTEXT); -static BOOL (WINAPI *pCertEnumSystemStore)(DWORD,void*,void*,PFN_CERT_ENUM_SYSTEM_STORE); -static BOOL (WINAPI *pCertGetStoreProperty)(HCERTSTORE,DWORD,void*,DWORD*); -static void (WINAPI *pCertRemoveStoreFromCollection)(HCERTSTORE,HCERTSTORE); -static BOOL (WINAPI *pCertSetStoreProperty)(HCERTSTORE,DWORD,DWORD,const void*); -static BOOL (WINAPI *pCertAddCertificateLinkToStore)(HCERTSTORE,PCCERT_CONTEXT,DWORD,PCCERT_CONTEXT*); -static BOOL (WINAPI *pCertRegisterSystemStore)(const void*,DWORD,void*,void*); -static BOOL (WINAPI *pCertUnregisterSystemStore)(const void*,DWORD); - #define test_store_is_empty(store) _test_store_is_empty(__LINE__,store) static void _test_store_is_empty(unsigned line, HCERTSTORE store) { @@ -882,32 +881,25 @@ static void testCollectionStore(void) ok(context == NULL, "Unexpected cert\n"); } - if (!pCertRemoveStoreFromCollection) - { - win_skip("CertRemoveStoreFromCollection() is not available\n"); - } - else - { - /* Finally, test removing stores from the collection. No return - * value, so it's a bit funny to test. - */ - /* This crashes - * pCertRemoveStoreFromCollection(NULL, NULL); - */ - /* This "succeeds," no crash, no last error set */ - SetLastError(0xdeadbeef); - pCertRemoveStoreFromCollection(store2, collection); - ok(GetLastError() == 0xdeadbeef, - "Didn't expect an error to be set: %08x\n", GetLastError()); - - /* After removing store2, the collection should be empty */ - SetLastError(0xdeadbeef); - pCertRemoveStoreFromCollection(collection, store2); - ok(GetLastError() == 0xdeadbeef, - "Didn't expect an error to be set: %08x\n", GetLastError()); - context = CertEnumCertificatesInStore(collection, NULL); - ok(!context, "Unexpected cert\n"); - } + /* Finally, test removing stores from the collection. No return + * value, so it's a bit funny to test. + */ + /* This crashes + * CertRemoveStoreFromCollection(NULL, NULL); + */ + /* This "succeeds," no crash, no last error set */ + SetLastError(0xdeadbeef); + CertRemoveStoreFromCollection(store2, collection); + ok(GetLastError() == 0xdeadbeef, + "Didn't expect an error to be set: %08x\n", GetLastError()); + + /* After removing store2, the collection should be empty */ + SetLastError(0xdeadbeef); + CertRemoveStoreFromCollection(collection, store2); + ok(GetLastError() == 0xdeadbeef, + "Didn't expect an error to be set: %08x\n", GetLastError()); + context = CertEnumCertificatesInStore(collection, NULL); + ok(!context, "Unexpected cert\n"); CertCloseStore(collection, 0); CertCloseStore(store2, 0); @@ -935,16 +927,11 @@ static void testCollectionStore(void) CertCloseStore(store1, 0); /* Test whether a collection store can be committed */ - if (!pCertControlStore) - { - win_skip("CertControlStore() is not available\n"); - return; - } collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); SetLastError(0xdeadbeef); - ret = pCertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* Adding a mem store that can't be committed prevents a successful commit. @@ -953,10 +940,10 @@ static void testCollectionStore(void) CERT_STORE_CREATE_NEW_FLAG, NULL); CertAddStoreToCollection(collection, store1, 0, 0); SetLastError(0xdeadbeef); - ret = pCertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "expected ERROR_CALL_NOT_IMPLEMENTED, got %d\n", GetLastError()); - pCertRemoveStoreFromCollection(collection, store1); + CertRemoveStoreFromCollection(collection, store1); CertCloseStore(store1, 0); /* Test adding a cert to a collection with a file store, committing the @@ -982,7 +969,7 @@ static void testCollectionStore(void) bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); - ret = pCertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %d\n", ret); compareStore(collection, "serialized store with cert", serializedStoreWithCert, sizeof(serializedStoreWithCert), FALSE); @@ -1050,13 +1037,6 @@ static void testRegStore(void) todo_wine ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError()); CertCloseStore(store, 0); - /* It looks like the remainder pretty much needs CertControlStore() */ - if (!pCertControlStore) - { - win_skip("CertControlStore() is not available\n"); - return; - } - rc = RegCreateKeyExA(HKEY_CURRENT_USER, tempKey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL); ok(!rc, "RegCreateKeyExA failed: %d\n", rc); @@ -1080,7 +1060,7 @@ static void testRegStore(void) ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); /* so flush the cache to force a commit.. */ - ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* and check that the expected subkey was written. */ size = sizeof(hash); @@ -1139,7 +1119,7 @@ static void testRegStore(void) ok(context != NULL, "Expected a cert context\n"); if (context) CertDeleteCertificateFromStore(context); - ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* Add a serialized cert with a bogus hash directly to the registry */ @@ -1176,7 +1156,7 @@ static void testRegStore(void) sizeof(buf)); ok(!rc, "RegSetValueExA failed: %d\n", rc); - ret = pCertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); + ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* Make sure the bogus hash cert gets loaded. */ @@ -1233,7 +1213,7 @@ static void testRegStore(void) sizeof(buf)); ok(!rc, "RegSetValueExA failed: %d\n", rc); - ret = pCertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); + ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* and make sure just one cert still gets loaded. */ @@ -1244,9 +1224,7 @@ static void testRegStore(void) if (context) certCount++; } while (context != NULL); - ok(certCount == 1 || - broken(certCount == 2) /* NT4 */ , - "Expected 1 certificates, got %d\n", certCount); + ok(certCount == 1, "Expected 1 certificate, got %d\n", certCount); /* Try again with the correct hash... */ ptr = buf + sizeof(*hdr); @@ -1256,7 +1234,7 @@ static void testRegStore(void) sizeof(buf)); ok(!rc, "RegSetValueExA failed: %d\n", rc); - ret = pCertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); + ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* and make sure two certs get loaded. */ @@ -1295,20 +1273,10 @@ static void testRegStore(void) rc = RegDeleteKeyA(HKEY_CURRENT_USER, tempKey); if (rc) { - HMODULE shlwapi = LoadLibraryA("shlwapi"); - /* Use shlwapi's SHDeleteKeyA to _really_ blow away the key, * otherwise subsequent tests will fail. */ - if (shlwapi) - { - DWORD (WINAPI *pSHDeleteKeyA)(HKEY, LPCSTR); - - pSHDeleteKeyA = (void*)GetProcAddress(shlwapi, "SHDeleteKeyA"); - if (pSHDeleteKeyA) - pSHDeleteKeyA(HKEY_CURRENT_USER, tempKey); - FreeLibrary(shlwapi); - } + SHDeleteKeyA(HKEY_CURRENT_USER, tempKey); } } } @@ -1429,7 +1397,6 @@ static void testSystemStore(void) if (memStore) { BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0); - /* FIXME: this'll fail on NT4, but what error will it give? */ ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); CertCloseStore(memStore, 0); } @@ -1480,12 +1447,6 @@ static void testFileStore(void) PCCERT_CONTEXT cert; HANDLE file; - if (!pCertControlStore) - { - win_skip("CertControlStore() is not available\n"); - return; - } - store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, 0, NULL); ok(!store && GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError()); @@ -1521,7 +1482,7 @@ static void testFileStore(void) /* apparently allows adding certificates.. */ ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret); /* but not commits.. */ - ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); /* It still has certs in memory.. */ @@ -1545,7 +1506,7 @@ static void testFileStore(void) ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret); - ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); CertCloseStore(store, 0); @@ -1560,7 +1521,7 @@ static void testFileStore(void) ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret); - ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); CertCloseStore(store, 0); @@ -1576,7 +1537,7 @@ static void testFileStore(void) ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); /* with commits enabled, commit is allowed */ - ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %d\n", ret); compareStore(store, "serialized store with cert", serializedStoreWithCert, sizeof(serializedStoreWithCert), FALSE); @@ -1692,15 +1653,11 @@ static void testFileNameStore(void) BOOL ret; DWORD GLE; - if (0) - { - /* Crashes on NT4 */ - store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, 0, NULL); - GLE = GetLastError(); - ok(!store && (GLE == ERROR_PATH_NOT_FOUND || GLE == ERROR_INVALID_PARAMETER), - "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08x\n", - GLE); - } + store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, 0, NULL); + GLE = GetLastError(); + ok(!store && (GLE == ERROR_PATH_NOT_FOUND || GLE == ERROR_INVALID_PARAMETER), + "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08x\n", + GLE); if (!GetTempFileNameW(szDot, szPrefix, 0, filename)) return; @@ -1727,11 +1684,8 @@ static void testFileNameStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - if (pCertEnumCRLsInStore) - { - crl = pCertEnumCRLsInStore(store, NULL); - ok(!crl, "Expected no CRLs\n"); - } + crl = CertEnumCRLsInStore(store, NULL); + ok(!crl, "Expected no CRLs\n"); CertCloseStore(store, 0); DeleteFileW(filename); @@ -1751,11 +1705,8 @@ static void testFileNameStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - if (pCertEnumCRLsInStore) - { - crl = pCertEnumCRLsInStore(store, NULL); - ok(!crl, "Expected no CRLs\n"); - } + crl = CertEnumCRLsInStore(store, NULL); + ok(!crl, "Expected no CRLs\n"); CertCloseStore(store, 0); DeleteFileW(filename); @@ -1775,13 +1726,10 @@ static void testFileNameStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - if (pCertEnumCRLsInStore) - { - crl = pCertEnumCRLsInStore(store, NULL); - ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", GetLastError()); - crl = pCertEnumCRLsInStore(store, crl); - ok(!crl, "Expected only one CRL\n"); - } + crl = CertEnumCRLsInStore(store, NULL); + ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", GetLastError()); + crl = CertEnumCRLsInStore(store, crl); + ok(!crl, "Expected only one CRL\n"); CertCloseStore(store, 0); /* Don't delete it this time, the next test uses it */ @@ -1839,11 +1787,8 @@ static void testFileNameStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - if (pCertEnumCRLsInStore) - { - crl = pCertEnumCRLsInStore(store, NULL); - ok(!crl, "Expected no CRLs\n"); - } + crl = CertEnumCRLsInStore(store, NULL); + ok(!crl, "Expected no CRLs\n"); CertCloseStore(store, 0); DeleteFileW(filename); @@ -1863,11 +1808,8 @@ static void testFileNameStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - if (pCertEnumCRLsInStore) - { - crl = pCertEnumCRLsInStore(store, NULL); - ok(!crl, "Expected no CRLs\n"); - } + crl = CertEnumCRLsInStore(store, NULL); + ok(!crl, "Expected no CRLs\n"); CertCloseStore(store, 0); DeleteFileW(filename); @@ -1957,16 +1899,13 @@ static void testMessageStore(void) } while (cert); ok(count == 0, "Expected 0 certificates, got %d\n", count); - if (pCertEnumCRLsInStore) - { - count = 0; - do { - crl = pCertEnumCRLsInStore(store, crl); - if (crl) - count++; - } while (crl); - ok(count == 0, "Expected 0 CRLs, got %d\n", count); - } + count = 0; + do { + crl = CertEnumCRLsInStore(store, crl); + if (crl) + count++; + } while (crl); + ok(count == 0, "Expected 0 CRLs, got %d\n", count); /* Can add certs to a message store */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, @@ -2008,16 +1947,14 @@ static void testMessageStore(void) } while (cert); ok(count == 1, "Expected 1 certificate, got %d\n", count); - if (pCertEnumCRLsInStore) - { - count = 0; - do { - crl = pCertEnumCRLsInStore(store, crl); - if (crl) - count++; - } while (crl); - ok(count == 1, "Expected 1 CRL, got %d\n", count); - } + count = 0; + do { + crl = CertEnumCRLsInStore(store, crl); + if (crl) + count++; + } while (crl); + ok(count == 1, "Expected 1 CRL, got %d\n", count); + CertCloseStore(store, 0); } /* Encoding appears to be ignored */ @@ -2037,9 +1974,7 @@ static void testMessageStore(void) blob.pbData = (LPBYTE)hashBareContent; SetLastError(0xdeadbeef); store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob); - ok(!store && - (GetLastError() == CRYPT_E_ASN1_BADTAG || - broken(GetLastError() == OSS_DATA_ERROR)), /* NT4 */ + ok(!store && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); } @@ -2073,11 +2008,9 @@ static void testSerializedStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - if (pCertEnumCRLsInStore) - { - crl = pCertEnumCRLsInStore(store, NULL); - ok(!crl, "Expected no CRLs\n"); - } + crl = CertEnumCRLsInStore(store, NULL); + ok(!crl, "Expected no CRLs\n"); + CertCloseStore(store, 0); } blob.cbData = sizeof(serializedStoreWithCertAndCRL); @@ -2094,14 +2027,12 @@ static void testSerializedStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - if (pCertEnumCRLsInStore) - { - crl = pCertEnumCRLsInStore(store, NULL); - ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", - GetLastError()); - crl = pCertEnumCRLsInStore(store, crl); - ok(!crl, "Expected only one CRL\n"); - } + crl = CertEnumCRLsInStore(store, NULL); + ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", + GetLastError()); + crl = CertEnumCRLsInStore(store, crl); + ok(!crl, "Expected only one CRL\n"); + CertCloseStore(store, 0); } } @@ -2150,15 +2081,9 @@ static void testCertRegisterSystemStore(void) const CERT_CONTEXT *cert, *cert2; unsigned int i; - if (!pCertRegisterSystemStore || !pCertUnregisterSystemStore) - { - win_skip("CertRegisterSystemStore() or CertUnregisterSystemStore() is not available\n"); - return; - } - for (i = 0; i < sizeof(reg_system_store_test_data) / sizeof(reg_system_store_test_data[0]); i++) { cur_flag = reg_system_store_test_data[i].cert_store; - ret = pCertRegisterSystemStore(WineTestW, cur_flag, NULL, NULL); + ret = CertRegisterSystemStore(WineTestW, cur_flag, NULL, NULL); if (!ret) { err = GetLastError(); @@ -2200,7 +2125,7 @@ static void testCertRegisterSystemStore(void) ret = CertCloseStore(hstore, 0); ok (ret, "CertCloseStore failed at %08x, last error %x\n", cur_flag, GetLastError()); - ret = pCertUnregisterSystemStore(WineTestW, cur_flag ); + ret = CertUnregisterSystemStore(WineTestW, cur_flag ); todo_wine_if (reg_system_store_test_data[i].todo) ok( ret == reg_system_store_test_data[i].expected, "Unregistering failed at %08x, last error %d\n", cur_flag, GetLastError()); @@ -2228,23 +2153,17 @@ static void testCertEnumSystemStore(void) BOOL ret; struct EnumSystemStoreInfo info = { FALSE, 0 }; - if (!pCertEnumSystemStore) - { - win_skip("CertEnumSystemStore() is not available\n"); - return; - } - SetLastError(0xdeadbeef); - ret = pCertEnumSystemStore(0, NULL, NULL, NULL); + ret = CertEnumSystemStore(0, NULL, NULL, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); /* Crashes - ret = pCertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, NULL, + ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, NULL, NULL); */ SetLastError(0xdeadbeef); - ret = pCertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info, + ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info, enumSystemStoreCB); /* Callback returning FALSE stops enumeration */ ok(!ret, "Expected CertEnumSystemStore to stop\n"); @@ -2253,7 +2172,7 @@ static void testCertEnumSystemStore(void) info.goOn = TRUE; info.storeCount = 0; - ret = pCertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info, + ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info, enumSystemStoreCB); ok(ret, "CertEnumSystemStore failed: %08x\n", GetLastError()); /* There should always be at least My, Root, and CA stores */ @@ -2268,58 +2187,52 @@ static void testStoreProperty(void) DWORD propID, size = 0, state; CRYPT_DATA_BLOB blob; - if (!pCertGetStoreProperty || !pCertSetStoreProperty) - { - win_skip("CertGet/SetStoreProperty() is not available\n"); - return; - } - /* Crash - ret = pCertGetStoreProperty(NULL, 0, NULL, NULL); - ret = pCertGetStoreProperty(NULL, 0, NULL, &size); - ret = pCertGetStoreProperty(store, 0, NULL, NULL); + ret = CertGetStoreProperty(NULL, 0, NULL, NULL); + ret = CertGetStoreProperty(NULL, 0, NULL, &size); + ret = CertGetStoreProperty(store, 0, NULL, NULL); */ store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); /* Check a missing prop ID */ SetLastError(0xdeadbeef); - ret = pCertGetStoreProperty(store, 0, NULL, &size); + ret = CertGetStoreProperty(store, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); /* Contrary to MSDN, CERT_ACCESS_STATE_PROP_ID is supported for stores.. */ size = sizeof(state); - ret = pCertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); + ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n", GetLastError()); ok(!state, "Expected a non-persisted store\n"); /* and CERT_STORE_LOCALIZED_NAME_PROP_ID isn't supported by default. */ size = 0; - ret = pCertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, + ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); /* Delete an arbitrary property on a store */ - ret = pCertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); + ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError()); /* Set an arbitrary property on a store */ blob.pbData = (LPBYTE)&state; blob.cbData = sizeof(state); - ret = pCertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, &blob); + ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, &blob); ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError()); /* Get an arbitrary property that's been set */ - ret = pCertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); + ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError()); ok(size == sizeof(state), "Unexpected data size %d\n", size); - ret = pCertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, &propID, &size); + ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, &propID, &size); ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError()); ok(propID == state, "CertGetStoreProperty got the wrong value\n"); /* Delete it again */ - ret = pCertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); + ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError()); /* And check that it's missing */ SetLastError(0xdeadbeef); - ret = pCertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); + ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); CertCloseStore(store, 0); @@ -2327,13 +2240,13 @@ static void testStoreProperty(void) /* Recheck on the My store.. */ store = CertOpenSystemStoreW(0, MyW); size = sizeof(state); - ret = pCertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); + ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n", GetLastError()); ok(state, "Expected a persisted store\n"); SetLastError(0xdeadbeef); size = 0; - ret = pCertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, + ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); @@ -2579,32 +2492,26 @@ static void testAddCertificateLink(void) WCHAR filename1[MAX_PATH], filename2[MAX_PATH]; HANDLE file; - if (!pCertAddCertificateLinkToStore) - { - win_skip("CertAddCertificateLinkToStore not found\n"); - return; - } - if (0) { /* Crashes, i.e. the store is dereferenced without checking. */ - ret = pCertAddCertificateLinkToStore(NULL, NULL, 0, NULL); + ret = CertAddCertificateLinkToStore(NULL, NULL, 0, NULL); } /* Adding a certificate link to a store requires a valid add disposition */ store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); SetLastError(0xdeadbeef); - ret = pCertAddCertificateLinkToStore(store1, NULL, 0, NULL); + ret = CertAddCertificateLinkToStore(store1, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", GetLastError()); source = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); SetLastError(0xdeadbeef); - ret = pCertAddCertificateLinkToStore(store1, source, 0, NULL); + ret = CertAddCertificateLinkToStore(store1, source, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", GetLastError()); - ret = pCertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS, + ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS, NULL); ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); if (0) @@ -2612,14 +2519,14 @@ static void testAddCertificateLink(void) /* Crashes, i.e. the source certificate is dereferenced without * checking when a valid add disposition is given. */ - ret = pCertAddCertificateLinkToStore(store1, NULL, CERT_STORE_ADD_ALWAYS, + ret = CertAddCertificateLinkToStore(store1, NULL, CERT_STORE_ADD_ALWAYS, NULL); } CertCloseStore(store1, 0); store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ret = pCertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS, + ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS, &linked); ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); if (ret) @@ -2695,7 +2602,7 @@ static void testAddCertificateLink(void) /* Test adding a link to a memory store. */ store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ret = pCertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, + ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, &linked); ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); if (ret) @@ -2757,7 +2664,7 @@ static void testAddCertificateLink(void) ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError()); CloseHandle(file); /* Test adding a link to a file store. */ - ret = pCertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, + ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, &linked); ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); if (ret) @@ -2799,7 +2706,7 @@ static void testAddCertificateLink(void) source = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); SetLastError(0xdeadbeef); - ret = pCertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS, + ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS, &linked); ok(!ret && GetLastError() == E_INVALIDARG, "expected E_INVALIDARG, got %08x\n", GetLastError()); @@ -2826,13 +2733,13 @@ static void testAddCertificateLink(void) ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError()); CloseHandle(file); - ret = pCertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, + ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, &linked); ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); if (ret) { ok(linked->hCertStore == store2, "unexpected store\n"); - ret = pCertControlStore(store2, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = CertControlStore(store2, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %d\n", ret); compareStore(store2, "file store -> system store", serializedStoreWithCertAndHash, @@ -2849,7 +2756,7 @@ static void testAddCertificateLink(void) store2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, WineTestW); ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError()); - ret = pCertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, + ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS, &linked); ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError()); if (ret) @@ -2884,7 +2791,7 @@ static DWORD countCRLsInStore(HCERTSTORE store) DWORD crls = 0; do { - crl = pCertEnumCRLsInStore(store, crl); + crl = CertEnumCRLsInStore(store, crl); if (crl) crls++; } while (crl); @@ -3112,11 +3019,8 @@ static void test_I_UpdateStore(void) ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError()); certs = countCertsInStore(store1); ok(certs == 1, "Expected 1 cert, got %d\n", certs); - if (pCertEnumCRLsInStore) - { - certs = countCRLsInStore(store1); - ok(certs == 1, "Expected 1 CRL, got %d\n", certs); - } + certs = countCRLsInStore(store1); + ok(certs == 1, "Expected 1 CRL, got %d\n", certs); CertDeleteCertificateFromStore(cert); /* If a context is deleted from store2, I_CertUpdateStore deletes it @@ -3133,19 +3037,6 @@ static void test_I_UpdateStore(void) START_TEST(store) { - HMODULE hdll; - - hdll = GetModuleHandleA("Crypt32.dll"); - pCertControlStore = (void*)GetProcAddress(hdll, "CertControlStore"); - pCertEnumCRLsInStore = (void*)GetProcAddress(hdll, "CertEnumCRLsInStore"); - pCertEnumSystemStore = (void*)GetProcAddress(hdll, "CertEnumSystemStore"); - pCertGetStoreProperty = (void*)GetProcAddress(hdll, "CertGetStoreProperty"); - pCertRemoveStoreFromCollection = (void*)GetProcAddress(hdll, "CertRemoveStoreFromCollection"); - pCertSetStoreProperty = (void*)GetProcAddress(hdll, "CertSetStoreProperty"); - pCertAddCertificateLinkToStore = (void*)GetProcAddress(hdll, "CertAddCertificateLinkToStore"); - pCertRegisterSystemStore = (void*)GetProcAddress(hdll, "CertRegisterSystemStore"); - pCertUnregisterSystemStore = (void*)GetProcAddress(hdll, "CertUnregisterSystemStore"); - /* various combinations of CertOpenStore */ testMemStore(); testCollectionStore(); diff --git a/modules/rostests/winetests/crypt32/str.c b/modules/rostests/winetests/crypt32/str.c index 56480859f8..5245885503 100644 --- a/modules/rostests/winetests/crypt32/str.c +++ b/modules/rostests/winetests/crypt32/str.c @@ -17,8 +17,14 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <winerror.h> +#include <wincrypt.h> -#include "precomp.h" +#include "wine/test.h" typedef struct _CertRDNAttrEncoding { LPCSTR pszObjId;
6 years, 9 months
1
0
0
0
01/01: [CRYPT32] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a6e1034289e78bab3fcb1…
commit a6e1034289e78bab3fcb153b54bccaf164688d38 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 12:59:49 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 12:59:49 2018 +0100 [CRYPT32] Sync with Wine Staging 3.3. CORE-14434 --- dll/win32/crypt32/CMakeLists.txt | 6 +- dll/win32/crypt32/base64.c | 8 +- dll/win32/crypt32/cert.c | 307 +++++++++++++++++++++++++++++++++--- dll/win32/crypt32/chain.c | 33 ++-- dll/win32/crypt32/collectionstore.c | 7 +- dll/win32/crypt32/context.c | 7 +- dll/win32/crypt32/crl.c | 8 + dll/win32/crypt32/crypt32.rc | 2 +- dll/win32/crypt32/crypt32.spec | 1 + dll/win32/crypt32/crypt32_private.h | 35 +--- dll/win32/crypt32/cryptres.h | 3 +- dll/win32/crypt32/ctl.c | 7 + dll/win32/crypt32/decode.c | 241 ++++++++++++++++++++++++---- dll/win32/crypt32/encode.c | 17 ++ dll/win32/crypt32/filestore.c | 8 +- dll/win32/crypt32/main.c | 13 +- dll/win32/crypt32/message.c | 7 +- dll/win32/crypt32/msg.c | 15 +- dll/win32/crypt32/object.c | 14 +- dll/win32/crypt32/oid.c | 32 ++++ dll/win32/crypt32/precomp.h | 40 +++++ dll/win32/crypt32/proplist.c | 8 +- dll/win32/crypt32/protectdata.c | 10 +- dll/win32/crypt32/provstore.c | 7 + dll/win32/crypt32/regstore.c | 11 +- dll/win32/crypt32/rootstore.c | 15 +- dll/win32/crypt32/serialize.c | 9 ++ dll/win32/crypt32/sip.c | 14 +- dll/win32/crypt32/store.c | 22 ++- dll/win32/crypt32/str.c | 11 +- media/doc/README.WINE | 2 +- 31 files changed, 802 insertions(+), 118 deletions(-) diff --git a/dll/win32/crypt32/CMakeLists.txt b/dll/win32/crypt32/CMakeLists.txt index 11539f7e07..6bef4c7af9 100644 --- a/dll/win32/crypt32/CMakeLists.txt +++ b/dll/win32/crypt32/CMakeLists.txt @@ -35,7 +35,7 @@ list(APPEND SOURCE sip.c store.c str.c - crypt32_private.h) + precomp.h) add_library(crypt32 SHARED ${SOURCE} @@ -46,6 +46,6 @@ add_library(crypt32 SHARED set_module_type(crypt32 win32dll) target_link_libraries(crypt32 wine ${PSEH_LIB} oldnames) add_delay_importlibs(crypt32 cryptnet) -add_importlibs(crypt32 user32 advapi32 advapi32_vista msvcrt kernel32 ntdll) -add_pch(crypt32 crypt32_private.h SOURCE) +add_importlibs(crypt32 bcrypt user32 advapi32 advapi32_vista msvcrt kernel32 ntdll) +add_pch(crypt32 precomp.h SOURCE) add_cd_file(TARGET crypt32 DESTINATION reactos/system32 FOR all) diff --git a/dll/win32/crypt32/base64.c b/dll/win32/crypt32/base64.c index d3c6ecf52b..4a904d41cc 100644 --- a/dll/win32/crypt32/base64.c +++ b/dll/win32/crypt32/base64.c @@ -19,7 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "crypt32_private.h" +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "wincrypt.h" +#include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/cert.c b/dll/win32/crypt32/cert.c index 0cf885b20b..e379dc8a03 100644 --- a/dll/win32/crypt32/cert.c +++ b/dll/win32/crypt32/cert.c @@ -17,10 +17,24 @@ * */ +#include <assert.h> +#include <stdarg.h> + +#define NONAMELESSUNION +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "wine/winternl.h" +#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS +#include "wincrypt.h" +#include "bcrypt.h" +#include "winnls.h" +#include "rpc.h" +#include "wine/debug.h" +#include "wine/unicode.h" #include "crypt32_private.h" -#include <rpc.h> - WINE_DEFAULT_DEBUG_CHANNEL(crypt); /* Internal version of CertGetCertificateContextProperty that gets properties @@ -1875,7 +1889,7 @@ PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore(HCERTSTORE hCertStore, CertFreeCertificateContext(ret); ret = NULL; } - if (CRYPT_IsCertificateSelfSigned(pSubjectContext)) + if (CRYPT_IsCertificateSelfSigned(pSubjectContext, NULL)) { CertFreeCertificateContext(ret); ret = NULL; @@ -2400,36 +2414,29 @@ BOOL WINAPI CryptVerifyCertificateSignature(HCRYPTPROV_LEGACY hCryptProv, CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY, pPublicKey, 0, NULL); } -static BOOL CRYPT_VerifyCertSignatureFromPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, - DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pubKeyInfo, - const CERT_SIGNED_CONTENT_INFO *signedCert) +static BOOL verify_signature_crypt(HCRYPTPROV_LEGACY hCryptProv, + DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pubKeyInfo, + const CERT_SIGNED_CONTENT_INFO *signedCert, PCCRYPT_OID_INFO info) { - BOOL ret; - HCRYPTKEY key; - PCCRYPT_OID_INFO info; ALG_ID pubKeyID, hashID; + HCRYPTHASH hash; + HCRYPTKEY key; + BOOL ret; - info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, - signedCert->SignatureAlgorithm.pszObjId, 0); - if (!info || info->dwGroupId != CRYPT_SIGN_ALG_OID_GROUP_ID) - { - SetLastError(NTE_BAD_ALGID); - return FALSE; - } hashID = info->u.Algid; if (info->ExtraInfo.cbData >= sizeof(ALG_ID)) pubKeyID = *(ALG_ID *)info->ExtraInfo.pbData; else pubKeyID = hashID; + /* Load the default provider if necessary */ if (!hCryptProv) hCryptProv = CRYPT_GetDefaultProvider(); + ret = CryptImportPublicKeyInfoEx(hCryptProv, dwCertEncodingType, pubKeyInfo, pubKeyID, 0, NULL, &key); if (ret) { - HCRYPTHASH hash; - ret = CryptCreateHash(hCryptProv, hashID, 0, 0, &hash); if (ret) { @@ -2445,6 +2452,270 @@ static BOOL CRYPT_VerifyCertSignatureFromPublicKeyInfo(HCRYPTPROV_LEGACY hCryptP return ret; } +static BOOL calculate_hash_bcrypt(const WCHAR *algorithm, + const CERT_SIGNED_CONTENT_INFO *signedCert, BYTE **hash_value, DWORD *hash_len) +{ + BCRYPT_HASH_HANDLE hash = NULL; + BCRYPT_ALG_HANDLE alg = NULL; + NTSTATUS status; + DWORD size; + BOOL ret = FALSE; + + if ((status = BCryptOpenAlgorithmProvider(&alg, algorithm, NULL, 0))) + goto done; + + if ((status = BCryptCreateHash(alg, &hash, NULL, 0, NULL, 0, 0))) + goto done; + + if ((status = BCryptHashData(hash, signedCert->ToBeSigned.pbData, signedCert->ToBeSigned.cbData, 0))) + goto done; + + if ((status = BCryptGetProperty(hash, BCRYPT_HASH_LENGTH, (BYTE *)hash_len, sizeof(*hash_len), &size, 0))) + goto done; + + if (!(*hash_value = CryptMemAlloc(*hash_len))) + { + status = STATUS_NO_MEMORY; + goto done; + } + + if ((status = BCryptFinishHash(hash, *hash_value, *hash_len, 0))) + { + CryptMemFree(*hash_value); + goto done; + } + + ret = TRUE; + +done: + if (hash) BCryptDestroyHash(hash); + if (alg) BCryptCloseAlgorithmProvider(alg, 0); + if (status) SetLastError(RtlNtStatusToDosError(status)); + return ret; +} + +static BOOL import_bcrypt_pubkey_ecc(PCERT_PUBLIC_KEY_INFO pubKeyInfo, BCRYPT_KEY_HANDLE *key) +{ + DWORD blob_magic, ecckey_len, size; + NTSTATUS status = STATUS_SUCCESS; + BCRYPT_ECCKEY_BLOB *ecckey; + const WCHAR *sign_algo; + BCRYPT_ALG_HANDLE alg; + LPSTR *ecc_curve; + + if (!pubKeyInfo->PublicKey.cbData) + { + SetLastError(NTE_BAD_ALGID); + return FALSE; + } + + if (pubKeyInfo->PublicKey.pbData[0] != 0x4) + { + FIXME("Compressed ECC curves (%02x) not yet supported\n", pubKeyInfo->PublicKey.pbData[0]); + SetLastError(NTE_BAD_ALGID); + return FALSE; + } + + if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_OBJECT_IDENTIFIER, + pubKeyInfo->Algorithm.Parameters.pbData, + pubKeyInfo->Algorithm.Parameters.cbData, + CRYPT_DECODE_ALLOC_FLAG, NULL, &ecc_curve, &size)) + return FALSE; + + if (!strcmp(*ecc_curve, szOID_ECC_CURVE_P256)) + { + sign_algo = BCRYPT_ECDSA_P256_ALGORITHM; + blob_magic = BCRYPT_ECDSA_PUBLIC_P256_MAGIC; + } + else if(!strcmp(*ecc_curve, szOID_ECC_CURVE_P384)) + { + sign_algo = BCRYPT_ECDSA_P384_ALGORITHM; + blob_magic = BCRYPT_ECDSA_PUBLIC_P384_MAGIC; + } + else + { + FIXME("Unsupported ecc curve type: %s\n", *ecc_curve); + sign_algo = NULL; + blob_magic = 0; + } + LocalFree(ecc_curve); + + if (!sign_algo) + { + SetLastError(NTE_BAD_ALGID); + return FALSE; + } + + if ((status = BCryptOpenAlgorithmProvider(&alg, sign_algo, NULL, 0))) + { + SetLastError(RtlNtStatusToDosError(status)); + return FALSE; + } + + ecckey_len = sizeof(BCRYPT_ECCKEY_BLOB) + pubKeyInfo->PublicKey.cbData - 1; + if (!(ecckey = CryptMemAlloc(ecckey_len))) + { + BCryptCloseAlgorithmProvider(alg, 0); + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } + + ecckey->dwMagic = blob_magic; + ecckey->cbKey = (pubKeyInfo->PublicKey.cbData - 1) / 2; + memcpy(ecckey + 1, pubKeyInfo->PublicKey.pbData + 1, pubKeyInfo->PublicKey.cbData - 1); + + status = BCryptImportKeyPair(alg, NULL, BCRYPT_ECCPUBLIC_BLOB, key, (BYTE*)ecckey, ecckey_len, 0); + BCryptCloseAlgorithmProvider(alg, 0); + if (status) + { + SetLastError(RtlNtStatusToDosError(status)); + return FALSE; + } + + return TRUE; +} + +static BOOL import_bcrypt_pubkey(PCERT_PUBLIC_KEY_INFO pubKeyInfo, BCRYPT_KEY_HANDLE *key) +{ + if (!strcmp(pubKeyInfo->Algorithm.pszObjId, szOID_ECC_PUBLIC_KEY)) + return import_bcrypt_pubkey_ecc(pubKeyInfo, key); + + FIXME("Unsupported public key type: %s\n", debugstr_a(pubKeyInfo->Algorithm.pszObjId)); + SetLastError(NTE_BAD_ALGID); + return FALSE; +} + +static BOOL prepare_bcrypt_signature_ecc(BYTE *encoded_sig, DWORD encoded_size, + BYTE **sig_value, DWORD *sig_len) +{ + CERT_ECC_SIGNATURE *ecc_sig; + DWORD size; + int i; + + if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_ECC_SIGNATURE, + encoded_sig, encoded_size, + CRYPT_DECODE_ALLOC_FLAG, NULL, &ecc_sig, &size)) + return FALSE; + + if (!ecc_sig->r.cbData || !ecc_sig->s.cbData) + { + LocalFree(ecc_sig); + SetLastError(ERROR_INVALID_DATA); + return FALSE; + } + + *sig_len = ecc_sig->r.cbData + ecc_sig->s.cbData; + if (!(*sig_value = CryptMemAlloc(*sig_len))) + { + LocalFree(ecc_sig); + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } + + for (i = 0; i < ecc_sig->r.cbData; i++) + (*sig_value)[i] = ecc_sig->r.pbData[ecc_sig->r.cbData - i - 1]; + for (i = 0; i < ecc_sig->s.cbData; i++) + (*sig_value)[ecc_sig->r.cbData + i] = ecc_sig->s.pbData[ecc_sig->s.cbData - i - 1]; + + LocalFree(ecc_sig); + return TRUE; +} + +static BOOL prepare_bcrypt_signature(PCERT_PUBLIC_KEY_INFO pubKeyInfo, + const CERT_SIGNED_CONTENT_INFO *signedCert, BYTE **sig_value, DWORD *sig_len) +{ + BYTE *encoded_sig; + BOOL ret = FALSE; + int i; + + if (!signedCert->Signature.cbData) + { + SetLastError(ERROR_INVALID_DATA); + return FALSE; + } + + if (!(encoded_sig = CryptMemAlloc(signedCert->Signature.cbData))) + { + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } + + for (i = 0; i < signedCert->Signature.cbData; i++) + encoded_sig[i] = signedCert->Signature.pbData[signedCert->Signature.cbData - i - 1]; + + if (!strcmp(pubKeyInfo->Algorithm.pszObjId, szOID_ECC_PUBLIC_KEY)) + ret = prepare_bcrypt_signature_ecc(encoded_sig, signedCert->Signature.cbData, sig_value, sig_len); + else + { + FIXME("Unsupported public key type: %s\n", debugstr_a(pubKeyInfo->Algorithm.pszObjId)); + SetLastError(NTE_BAD_ALGID); + } + + CryptMemFree(encoded_sig); + return ret; +} + +static BOOL verify_signature_bcrypt(HCRYPTPROV_LEGACY hCryptProv, + DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pubKeyInfo, + const CERT_SIGNED_CONTENT_INFO *signedCert, PCCRYPT_OID_INFO info) +{ + BCRYPT_KEY_HANDLE key = NULL; + BYTE *hash_value, *sig_value; + DWORD hash_len, sig_len; + NTSTATUS status; + + if (!calculate_hash_bcrypt(info->pwszCNGAlgid, signedCert, &hash_value, &hash_len)) + return FALSE; + + if (!import_bcrypt_pubkey(pubKeyInfo, &key)) + { + CryptMemFree(hash_value); + return FALSE; + } + + if (!prepare_bcrypt_signature(pubKeyInfo, signedCert, &sig_value, &sig_len)) + { + CryptMemFree(hash_value); + BCryptDestroyKey(key); + return FALSE; + } + + status = BCryptVerifySignature(key, NULL, hash_value, hash_len, sig_value, sig_len, 0); + + BCryptDestroyKey(key); + CryptMemFree(hash_value); + CryptMemFree(sig_value); + + if (status) + { + FIXME("Failed to verify signature: %08x\n", status); + SetLastError(RtlNtStatusToDosError(status)); + return FALSE; + } + + return TRUE; +} + +static BOOL CRYPT_VerifyCertSignatureFromPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, + DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pubKeyInfo, + const CERT_SIGNED_CONTENT_INFO *signedCert) +{ + PCCRYPT_OID_INFO info; + + info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, + signedCert->SignatureAlgorithm.pszObjId, 0); + if (!info || info->dwGroupId != CRYPT_SIGN_ALG_OID_GROUP_ID) + { + SetLastError(NTE_BAD_ALGID); + return FALSE; + } + + if (info->u.Algid == CALG_OID_INFO_CNG_ONLY) + return verify_signature_bcrypt(hCryptProv, dwCertEncodingType, pubKeyInfo, signedCert, info); + else + return verify_signature_crypt(hCryptProv, dwCertEncodingType, pubKeyInfo, signedCert, info); +} + BOOL WINAPI CryptVerifyCertificateSignatureEx(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, DWORD dwSubjectType, void *pvSubject, DWORD dwIssuerType, void *pvIssuer, DWORD dwFlags, void *pvReserved) diff --git a/dll/win32/crypt32/chain.c b/dll/win32/crypt32/chain.c index 45bb8f3a42..89a8ddb95f 100644 --- a/dll/win32/crypt32/chain.c +++ b/dll/win32/crypt32/chain.c @@ -16,11 +16,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * */ - +#include <stdarg.h> +#define NONAMELESSUNION +#include "windef.h" +#include "winbase.h" +#define CERT_CHAIN_PARA_HAS_EXTRA_FIELDS +#define CERT_REVOCATION_PARA_HAS_EXTRA_FIELDS +#include "wincrypt.h" +#include "wininet.h" +#include "wine/debug.h" +#include "wine/unicode.h" #include "crypt32_private.h" -#include <wininet.h> - WINE_DEFAULT_DEBUG_CHANNEL(crypt); WINE_DECLARE_DEBUG_CHANNEL(chain); @@ -258,7 +265,7 @@ typedef struct _CertificateChain LONG ref; } CertificateChain; -BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert) +BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert, DWORD *type) { PCERT_EXTENSION ext; DWORD size; @@ -293,6 +300,7 @@ BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert) &directoryName->u.DirectoryName, &cert->pCertInfo->Issuer) && CertCompareIntegerBlob(&info->AuthorityCertSerialNumber, &cert->pCertInfo->SerialNumber); + if (type) *type = CERT_TRUST_HAS_NAME_MATCH_ISSUER; } else { @@ -314,6 +322,7 @@ BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert) CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); ret = !memcmp(buf, info->KeyId.pbData, size); CryptMemFree(buf); + if (type) *type = CERT_TRUST_HAS_KEY_MATCH_ISSUER; } else ret = FALSE; @@ -341,6 +350,7 @@ BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert) &info->CertIssuer, &cert->pCertInfo->Issuer) && CertCompareIntegerBlob(&info->CertSerialNumber, &cert->pCertInfo->SerialNumber); + if (type) *type = CERT_TRUST_HAS_NAME_MATCH_ISSUER; } else if (info->KeyId.cbData) { @@ -356,6 +366,7 @@ BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert) CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); ret = !memcmp(buf, info->KeyId.pbData, size); CryptMemFree(buf); + if (type) *type = CERT_TRUST_HAS_KEY_MATCH_ISSUER; } else ret = FALSE; @@ -369,8 +380,11 @@ BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert) } } else + { ret = CertCompareCertificateName(cert->dwCertEncodingType, &cert->pCertInfo->Subject, &cert->pCertInfo->Issuer); + if (type) *type = CERT_TRUST_HAS_NAME_MATCH_ISSUER; + } return ret; } @@ -1313,7 +1327,7 @@ static void CRYPT_CheckChainNameConstraints(PCERT_SIMPLE_CHAIN chain) * constraints checked unless they're the end cert. */ if (j == 0 || !CRYPT_IsCertificateSelfSigned( - chain->rgpElement[j]->pCertContext)) + chain->rgpElement[j]->pCertContext, NULL)) { CRYPT_CheckNameConstraints(nameConstraints, chain->rgpElement[j]->pCertContext->pCertInfo, @@ -1886,6 +1900,7 @@ static void CRYPT_CheckSimpleChain(CertificateChainEngine *engine, int i; BOOL pathLengthConstraintViolated = FALSE; CERT_BASIC_CONSTRAINTS2_INFO constraints = { FALSE, FALSE, 0 }; + DWORD type; TRACE_(chain)("checking chain with %d elements for time %s\n", chain->cElement, filetime_to_str(time)); @@ -1897,7 +1912,7 @@ static void CRYPT_CheckSimpleChain(CertificateChainEngine *engine, dump_element(chain->rgpElement[i]->pCertContext); if (i == chain->cElement - 1) isRoot = CRYPT_IsCertificateSelfSigned( - chain->rgpElement[i]->pCertContext); + chain->rgpElement[i]->pCertContext, NULL); else isRoot = FALSE; if (!CRYPT_IsCertVersionValid(chain->rgpElement[i]->pCertContext)) @@ -1973,10 +1988,10 @@ static void CRYPT_CheckSimpleChain(CertificateChainEngine *engine, } CRYPT_CheckChainNameConstraints(chain); CRYPT_CheckChainPolicies(chain); - if (CRYPT_IsCertificateSelfSigned(rootElement->pCertContext)) + if (CRYPT_IsCertificateSelfSigned(rootElement->pCertContext, &type)) { rootElement->TrustStatus.dwInfoStatus |= - CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER; + CERT_TRUST_IS_SELF_SIGNED | type; CRYPT_CheckRootCert(engine->hRoot, rootElement); } CRYPT_CombineTrustStatus(&chain->TrustStatus, &rootElement->TrustStatus); @@ -2188,7 +2203,7 @@ static BOOL CRYPT_BuildSimpleChain(const CertificateChainEngine *engine, PCCERT_CONTEXT cert = chain->rgpElement[chain->cElement - 1]->pCertContext; while (ret && !CRYPT_IsSimpleChainCyclic(chain) && - !CRYPT_IsCertificateSelfSigned(cert)) + !CRYPT_IsCertificateSelfSigned(cert, NULL)) { PCCERT_CONTEXT issuer = CRYPT_GetIssuer(engine, world, cert, NULL, flags, &chain->rgpElement[chain->cElement - 1]->TrustStatus.dwInfoStatus); diff --git a/dll/win32/crypt32/collectionstore.c b/dll/win32/crypt32/collectionstore.c index b0cdd7de34..2c2398d745 100644 --- a/dll/win32/crypt32/collectionstore.c +++ b/dll/win32/crypt32/collectionstore.c @@ -15,7 +15,11 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ - +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "wine/debug.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); @@ -160,7 +164,6 @@ static context_t *CRYPT_CollectionAdvanceEnum(WINE_COLLECTIONSTORE *store, Context_AddRef(child); child = contextFuncs->enumContext(storeEntry->store, child); Context_Release(prev); - prev = NULL; } else { diff --git a/dll/win32/crypt32/context.c b/dll/win32/crypt32/context.c index e0824f5a90..90d1afd202 100644 --- a/dll/win32/crypt32/context.c +++ b/dll/win32/crypt32/context.c @@ -15,7 +15,12 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ - +#include <assert.h> +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "wine/debug.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(context); diff --git a/dll/win32/crypt32/crl.c b/dll/win32/crypt32/crl.c index ada6bea0af..db8065192f 100644 --- a/dll/win32/crypt32/crl.c +++ b/dll/win32/crypt32/crl.c @@ -17,6 +17,14 @@ * */ +#include <assert.h> +#include <stdarg.h> +#define NONAMELESSUNION +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "wine/debug.h" +#include "wine/unicode.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/crypt32.rc b/dll/win32/crypt32/crypt32.rc index 9214e27e57..2ed4b27756 100644 --- a/dll/win32/crypt32/crypt32.rc +++ b/dll/win32/crypt32/crypt32.rc @@ -27,7 +27,7 @@ #define WINE_PRODUCTVERSION 5,131,2600,1243 #define WINE_PRODUCTVERSION_STR "5.131.2600.1243" -#include <wine/wine_common_ver.rc> +#include "wine/wine_common_ver.rc" /* UTF-8 */ #pragma code_page(65001) diff --git a/dll/win32/crypt32/crypt32.spec b/dll/win32/crypt32/crypt32.spec index 00a2d62caf..fc0955e009 100644 --- a/dll/win32/crypt32/crypt32.spec +++ b/dll/win32/crypt32/crypt32.spec @@ -92,6 +92,7 @@ @ stdcall CertSetStoreProperty(ptr long long ptr) @ stdcall CertStrToNameA(long str long ptr ptr ptr ptr) @ stdcall CertStrToNameW(long wstr long ptr ptr ptr ptr) +@ stdcall CertUnregisterPhysicalStore(ptr long wstr) @ stdcall CertUnregisterSystemStore(ptr long) @ stdcall CertVerifyCRLRevocation(long ptr long ptr) @ stdcall CertVerifyCRLTimeValidity(ptr ptr) diff --git a/dll/win32/crypt32/crypt32_private.h b/dll/win32/crypt32/crypt32_private.h index 9ef8655223..5c08369f00 100644 --- a/dll/win32/crypt32/crypt32_private.h +++ b/dll/win32/crypt32/crypt32_private.h @@ -19,36 +19,7 @@ #ifndef __CRYPT32_PRIVATE_H__ #define __CRYPT32_PRIVATE_H__ -#include <wine/config.h> -#include <wine/port.h> - -#include <assert.h> -#include <stdarg.h> -#include <stdio.h> - -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#define NONAMELESSUNION - -#include <windef.h> -#include <winbase.h> -#include <winuser.h> -#include <winreg.h> -#include <snmp.h> - -#define CERT_CHAIN_PARA_HAS_EXTRA_FIELDS -#define CERT_REVOCATION_PARA_HAS_EXTRA_FIELDS -#include <wincrypt.h> - -#include <mssip.h> - -#include <wine/unicode.h> -#include <wine/list.h> -#include <wine/exception.h> -#include <wine/debug.h> - -#include "cryptres.h" +#include "wine/list.h" /* a few asn.1 tags we need */ #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01) @@ -370,7 +341,7 @@ void CRYPT_ImportSystemRootCertsToReg(void) DECLSPEC_HIDDEN; BOOL CRYPT_SerializeContextsToReg(HKEY key, DWORD flags, const WINE_CONTEXT_INTERFACE *contextInterface, HCERTSTORE memStore) DECLSPEC_HIDDEN; -BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert) DECLSPEC_HIDDEN; +BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert, DWORD *type) DECLSPEC_HIDDEN; /* Allocates and initializes a certificate chain engine, but without creating * the root store. Instead, it uses root, and assumes the caller has done any @@ -479,4 +450,4 @@ void init_empty_store(void) DECLSPEC_HIDDEN; */ #define IS_INTOID(x) (((ULONG_PTR)(x) >> 16) == 0) -#endif /* __CRYPT32_PRIVATE_H__ */ +#endif diff --git a/dll/win32/crypt32/cryptres.h b/dll/win32/crypt32/cryptres.h index fd6bc0d145..bdb0251770 100644 --- a/dll/win32/crypt32/cryptres.h +++ b/dll/win32/crypt32/cryptres.h @@ -15,10 +15,11 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ - #ifndef __WINE_CRYPTRES_H__ #define __WINE_CRYPTRES_H__ +#include <windef.h> + #define IDS_AUTHORITY_KEY_ID 1000 #define IDS_KEY_ATTRIBUTES 1001 #define IDS_KEY_USAGE_RESTRICTION 1002 diff --git a/dll/win32/crypt32/ctl.c b/dll/win32/crypt32/ctl.c index ec2f0aa885..b8b728f387 100644 --- a/dll/win32/crypt32/ctl.c +++ b/dll/win32/crypt32/ctl.c @@ -17,6 +17,13 @@ * */ +#include <assert.h> +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "wine/debug.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/decode.c b/dll/win32/crypt32/decode.c index 5d91e3027c..cc028a9090 100644 --- a/dll/win32/crypt32/decode.c +++ b/dll/win32/crypt32/decode.c @@ -30,6 +30,23 @@ * MSDN, especially "Constants for CryptEncodeObject and CryptDecodeObject" */ +#include "config.h" +#include "wine/port.h" + +#include <assert.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +#define NONAMELESSUNION + +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "winnls.h" +#include "snmp.h" +#include "wine/debug.h" +#include "wine/exception.h" #include "crypt32_private.h" /* This is a bit arbitrary, but to set some limit: */ @@ -68,7 +85,7 @@ static BOOL CRYPT_AsnDecodeAlgorithmId(const BYTE *pbEncoded, DWORD cbEncoded, static BOOL CRYPT_AsnDecodeBool(const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo, DWORD *pcbDecoded); /* Assumes the CRYPT_DATA_BLOB's pbData member has been initialized */ -static BOOL CRYPT_AsnDecodeOctetsInternal(const BYTE *pbEncoded, +static BOOL CRYPT_AsnDecodeOctets(const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo, DWORD *pcbDecoded); /* Doesn't check the tag, assumes the caller does so */ @@ -462,6 +479,7 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[], { dataLen = cbEncoded; indefinite = TRUE; + lenBytes += 2; } else if (cbEncoded < dataLen) { @@ -1404,7 +1422,7 @@ static BOOL CRYPT_AsnDecodeExtension(const BYTE *pbEncoded, DWORD cbEncoded, { ASN_BOOL, offsetof(CERT_EXTENSION, fCritical), CRYPT_AsnDecodeBool, sizeof(BOOL), TRUE, FALSE, 0, 0 }, { ASN_OCTETSTRING, offsetof(CERT_EXTENSION, Value), - CRYPT_AsnDecodeOctetsInternal, sizeof(CRYPT_OBJID_BLOB), FALSE, TRUE, + CRYPT_AsnDecodeOctets, sizeof(CRYPT_OBJID_BLOB), FALSE, TRUE, offsetof(CERT_EXTENSION, Value.pbData) }, }; BOOL ret = TRUE; @@ -2166,7 +2184,7 @@ static BOOL CRYPT_AsnDecodeCTLEntry(const BYTE *pbEncoded, DWORD cbEncoded, { struct AsnDecodeSequenceItem items[] = { { ASN_OCTETSTRING, offsetof(CTL_ENTRY, SubjectIdentifier), - CRYPT_AsnDecodeOctetsInternal, sizeof(CRYPT_DATA_BLOB), FALSE, TRUE, + CRYPT_AsnDecodeOctets, sizeof(CRYPT_DATA_BLOB), FALSE, TRUE, offsetof(CTL_ENTRY, SubjectIdentifier.pbData), 0 }, { ASN_CONSTRUCTOR | ASN_SETOF, offsetof(CTL_ENTRY, cAttribute), CRYPT_AsnDecodeCTLEntryAttributes, @@ -2259,7 +2277,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCTL(DWORD dwCertEncodingType, CRYPT_AsnDecodeCTLUsage, sizeof(CTL_USAGE), FALSE, TRUE, offsetof(CTL_INFO, SubjectUsage.rgpszUsageIdentifier), 0 }, { ASN_OCTETSTRING, offsetof(CTL_INFO, ListIdentifier), - CRYPT_AsnDecodeOctetsInternal, sizeof(CRYPT_DATA_BLOB), TRUE, + CRYPT_AsnDecodeOctets, sizeof(CRYPT_DATA_BLOB), TRUE, TRUE, offsetof(CTL_INFO, ListIdentifier.pbData), 0 }, { ASN_INTEGER, offsetof(CTL_INFO, SequenceNumber), CRYPT_AsnDecodeIntegerInternal, sizeof(CRYPT_INTEGER_BLOB), @@ -3120,11 +3138,11 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityKeyId(DWORD dwCertEncodingType, { struct AsnDecodeSequenceItem items[] = { { ASN_CONTEXT | 0, offsetof(CERT_AUTHORITY_KEY_ID_INFO, KeyId), - CRYPT_AsnDecodeOctetsInternal, sizeof(CRYPT_DATA_BLOB), + CRYPT_AsnDecodeOctets, sizeof(CRYPT_DATA_BLOB), TRUE, TRUE, offsetof(CERT_AUTHORITY_KEY_ID_INFO, KeyId.pbData), 0 }, { ASN_CONTEXT | ASN_CONSTRUCTOR| 1, offsetof(CERT_AUTHORITY_KEY_ID_INFO, CertIssuer), - CRYPT_AsnDecodeOctetsInternal, sizeof(CERT_NAME_BLOB), TRUE, TRUE, + CRYPT_AsnDecodeOctets, sizeof(CERT_NAME_BLOB), TRUE, TRUE, offsetof(CERT_AUTHORITY_KEY_ID_INFO, CertIssuer.pbData), 0 }, { ASN_CONTEXT | 2, offsetof(CERT_AUTHORITY_KEY_ID_INFO, CertSerialNumber), CRYPT_AsnDecodeIntegerInternal, @@ -3155,7 +3173,7 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityKeyId2(DWORD dwCertEncodingType, { struct AsnDecodeSequenceItem items[] = { { ASN_CONTEXT | 0, offsetof(CERT_AUTHORITY_KEY_ID2_INFO, KeyId), - CRYPT_AsnDecodeOctetsInternal, sizeof(CRYPT_DATA_BLOB), + CRYPT_AsnDecodeOctets, sizeof(CRYPT_DATA_BLOB), TRUE, TRUE, offsetof(CERT_AUTHORITY_KEY_ID2_INFO, KeyId.pbData), 0 }, { ASN_CONTEXT | ASN_CONSTRUCTOR| 1, offsetof(CERT_AUTHORITY_KEY_ID2_INFO, AuthorityCertIssuer), @@ -3370,7 +3388,7 @@ BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded, sizeof(CRYPT_CONTENT_INFO), FALSE, TRUE, offsetof(CRYPT_DIGESTED_DATA, ContentInfo.pszObjId), 0 }, { ASN_OCTETSTRING, offsetof(CRYPT_DIGESTED_DATA, hash), - CRYPT_AsnDecodeOctetsInternal, sizeof(CRYPT_HASH_BLOB), FALSE, TRUE, + CRYPT_AsnDecodeOctets, sizeof(CRYPT_HASH_BLOB), FALSE, TRUE, offsetof(CRYPT_DIGESTED_DATA, hash.pbData), 0 }, }; @@ -4062,7 +4080,7 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPrivKey(DWORD dwCertEncodingType, return ret; } -static BOOL CRYPT_AsnDecodeOctetsInternal(const BYTE *pbEncoded, +static BOOL CRYPT_AsnDecodeOctets(const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo, DWORD *pcbDecoded) { @@ -4111,7 +4129,99 @@ static BOOL CRYPT_AsnDecodeOctetsInternal(const BYTE *pbEncoded, return ret; } -static BOOL WINAPI CRYPT_AsnDecodeOctets(DWORD dwCertEncodingType, +static BOOL CRYPT_AsnDecodeOctetStringInternal(const BYTE *encoded, DWORD encoded_size, + DWORD flags, void *buf, DWORD *buf_size, DWORD *ret_decoded) +{ + DWORD decoded = 0, indefinite_len_depth = 0, len_size, len, bytes_needed; + CRYPT_DATA_BLOB *blob; + const BYTE *string; + + while (encoded[0] == (ASN_CONSTRUCTOR | ASN_OCTETSTRING)) + { + if (!CRYPT_GetLengthIndefinite(encoded, encoded_size, &len)) + return FALSE; + + len_size = GET_LEN_BYTES(encoded[1]); + encoded += 1 + len_size; + encoded_size -= 1 + len_size; + decoded += 1 + len_size; + + if (len == CMSG_INDEFINITE_LENGTH) + { + indefinite_len_depth++; + if (encoded_size < 2) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + encoded_size -= 2; + decoded += 2; + } + } + + if (encoded[0] != ASN_OCTETSTRING) + { + WARN("Unexpected tag %02x\n", encoded[0]); + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + + if (!CRYPT_GetLen(encoded, encoded_size, &len)) + return FALSE; + len_size = GET_LEN_BYTES(encoded[1]); + decoded += 1 + len_size + len; + encoded_size -= 1 + len_size; + + if (len > encoded_size) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (ret_decoded) + *ret_decoded = decoded; + + encoded += 1 + len_size; + string = encoded; + encoded += len; + + while (indefinite_len_depth--) + { + if (encoded[0] || encoded[1]) + { + TRACE("expected 0 TLV, got %02x %02x\n", encoded[0], encoded[1]); + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + } + + bytes_needed = sizeof(*blob); + if (!(flags & CRYPT_DECODE_NOCOPY_FLAG)) bytes_needed += len; + if (!buf) + { + *buf_size = bytes_needed; + return TRUE; + } + if (*buf_size < bytes_needed) + { + SetLastError(ERROR_MORE_DATA); + *buf_size = bytes_needed; + return FALSE; + } + + *buf_size = bytes_needed; + blob = buf; + blob->cbData = len; + if (flags & CRYPT_DECODE_NOCOPY_FLAG) + blob->pbData = (BYTE*)string; + else if (blob->cbData) + memcpy(blob->pbData, string, blob->cbData); + + if (ret_decoded) + *ret_decoded = decoded; + return TRUE; +} + +static BOOL WINAPI CRYPT_AsnDecodeOctetString(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { @@ -4120,21 +4230,17 @@ static BOOL WINAPI CRYPT_AsnDecodeOctets(DWORD dwCertEncodingType, TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, *pcbStructInfo); + if (!cbEncoded) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + __TRY { DWORD bytesNeeded = 0; - if (!cbEncoded) - { - SetLastError(CRYPT_E_ASN1_CORRUPT); - ret = FALSE; - } - else if (pbEncoded[0] != ASN_OCTETSTRING) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - ret = FALSE; - } - else if ((ret = CRYPT_AsnDecodeOctetsInternal(pbEncoded, cbEncoded, + if ((ret = CRYPT_AsnDecodeOctetStringInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL))) { if (!pvStructInfo) @@ -4148,7 +4254,7 @@ static BOOL WINAPI CRYPT_AsnDecodeOctets(DWORD dwCertEncodingType, pvStructInfo = *(BYTE **)pvStructInfo; blob = pvStructInfo; blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_DATA_BLOB); - ret = CRYPT_AsnDecodeOctetsInternal(pbEncoded, cbEncoded, + ret = CRYPT_AsnDecodeOctetStringInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, pvStructInfo, &bytesNeeded, NULL); if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG)) @@ -5467,7 +5573,7 @@ static BOOL CRYPT_AsnDecodePKCSSignerInfoInternal(const BYTE *pbEncoded, FALSE, TRUE, offsetof(CMSG_SIGNER_INFO, HashEncryptionAlgorithm.pszObjId), 0 }, { ASN_OCTETSTRING, offsetof(CMSG_SIGNER_INFO, EncryptedHash), - CRYPT_AsnDecodeOctetsInternal, sizeof(CRYPT_DER_BLOB), + CRYPT_AsnDecodeOctets, sizeof(CRYPT_DER_BLOB), FALSE, TRUE, offsetof(CMSG_SIGNER_INFO, EncryptedHash.pbData), 0 }, { ASN_CONSTRUCTOR | ASN_CONTEXT | 1, offsetof(CMSG_SIGNER_INFO, UnauthAttrs), @@ -5592,7 +5698,7 @@ static BOOL CRYPT_AsnDecodeCMSSignerId(const BYTE *pbEncoded, } else if (*pbEncoded == (ASN_CONTEXT | 0)) { - ret = CRYPT_AsnDecodeOctetsInternal(pbEncoded, cbEncoded, dwFlags, + ret = CRYPT_AsnDecodeOctets(pbEncoded, cbEncoded, dwFlags, id ? &id->u.KeyId : NULL, pcbStructInfo, pcbDecoded); if (ret) { @@ -5636,7 +5742,7 @@ static BOOL CRYPT_AsnDecodeCMSSignerInfoInternal(const BYTE *pbEncoded, FALSE, TRUE, offsetof(CMSG_CMS_SIGNER_INFO, HashEncryptionAlgorithm.pszObjId), 0 }, { ASN_OCTETSTRING, offsetof(CMSG_CMS_SIGNER_INFO, EncryptedHash), - CRYPT_AsnDecodeOctetsInternal, sizeof(CRYPT_DER_BLOB), + CRYPT_AsnDecodeOctets, sizeof(CRYPT_DER_BLOB), FALSE, TRUE, offsetof(CMSG_CMS_SIGNER_INFO, EncryptedHash.pbData), 0 }, { ASN_CONSTRUCTOR | ASN_CONTEXT | 1, offsetof(CMSG_CMS_SIGNER_INFO, UnauthAttrs), @@ -5774,7 +5880,7 @@ static BOOL CRYPT_AsnDecodeRecipientInfo(const BYTE *pbEncoded, DWORD cbEncoded, offsetof(CMSG_KEY_TRANS_RECIPIENT_INFO, KeyEncryptionAlgorithm.pszObjId), 0 }, { ASN_OCTETSTRING, offsetof(CMSG_KEY_TRANS_RECIPIENT_INFO, EncryptedKey), - CRYPT_AsnDecodeOctetsInternal, sizeof(CRYPT_DATA_BLOB), FALSE, TRUE, + CRYPT_AsnDecodeOctets, sizeof(CRYPT_DATA_BLOB), FALSE, TRUE, offsetof(CMSG_KEY_TRANS_RECIPIENT_INFO, EncryptedKey.pbData), 0 }, }; @@ -5830,7 +5936,7 @@ static BOOL CRYPT_AsnDecodeEncryptedContentInfo(const BYTE *pbEncoded, offsetof(CRYPT_ENCRYPTED_CONTENT_INFO, contentEncryptionAlgorithm.pszObjId), 0 }, { ASN_CONTEXT | 0, offsetof(CRYPT_ENCRYPTED_CONTENT_INFO, - encryptedContent), CRYPT_AsnDecodeOctetsInternal, + encryptedContent), CRYPT_AsnDecodeOctets, sizeof(CRYPT_DATA_BLOB), TRUE, TRUE, offsetof(CRYPT_ENCRYPTED_CONTENT_INFO, encryptedContent.pbData) }, }; @@ -5873,6 +5979,75 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded, return ret; } +static BOOL WINAPI CRYPT_AsnDecodeObjectIdentifier(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + DWORD bytesNeeded = 0; + BOOL ret; + + __TRY + { + ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, + NULL, &bytesNeeded, NULL); + if (ret) + { + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded))) + { + LPSTR *info; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + + info = pvStructInfo; + *info = (void *)((BYTE *)info + sizeof(*info)); + ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, + pvStructInfo, &bytesNeeded, NULL); + if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + CRYPT_FreeSpace(pDecodePara, info); + } + } + } + __EXCEPT_PAGE_FAULT + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeEccSignature(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret; + struct AsnDecodeSequenceItem items[] = { + { ASN_INTEGER, offsetof(CERT_ECC_SIGNATURE, r), + CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_UINT_BLOB), FALSE, + TRUE, offsetof(CERT_ECC_SIGNATURE, r.pbData), 0 }, + { ASN_INTEGER, offsetof(CERT_ECC_SIGNATURE, s), + CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_UINT_BLOB), FALSE, + TRUE, offsetof(CERT_ECC_SIGNATURE, s.pbData), 0 }, + }; + + __TRY + { + ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), + pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, NULL, NULL); + } + __EXCEPT_PAGE_FAULT + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, LPCSTR lpszStructType) { @@ -5940,7 +6115,7 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, decodeFunc = CRYPT_AsnDecodeUnicodeNameValue; break; case LOWORD(X509_OCTET_STRING): - decodeFunc = CRYPT_AsnDecodeOctets; + decodeFunc = CRYPT_AsnDecodeOctetString; break; case LOWORD(X509_BITS): case LOWORD(X509_KEY_USAGE): @@ -6012,6 +6187,12 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, case LOWORD(CMS_SIGNER_INFO): decodeFunc = CRYPT_AsnDecodeCMSSignerInfo; break; + case LOWORD(X509_OBJECT_IDENTIFIER): + decodeFunc = CRYPT_AsnDecodeObjectIdentifier; + break; + case LOWORD(X509_ECC_SIGNATURE): + decodeFunc = CRYPT_AsnDecodeEccSignature; + break; } } else if (!strcmp(lpszStructType, szOID_CERT_EXTENSIONS)) @@ -6031,7 +6212,7 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, else if (!strcmp(lpszStructType, szOID_KEY_USAGE)) decodeFunc = CRYPT_AsnDecodeBits; else if (!strcmp(lpszStructType, szOID_SUBJECT_KEY_IDENTIFIER)) - decodeFunc = CRYPT_AsnDecodeOctets; + decodeFunc = CRYPT_AsnDecodeOctetString; else if (!strcmp(lpszStructType, szOID_BASIC_CONSTRAINTS)) decodeFunc = CRYPT_AsnDecodeBasicConstraints; else if (!strcmp(lpszStructType, szOID_BASIC_CONSTRAINTS2)) @@ -6066,6 +6247,8 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType, decodeFunc = CRYPT_AsnDecodePolicyQualifierUserNotice; else if (!strcmp(lpszStructType, szOID_CTL)) decodeFunc = CRYPT_AsnDecodeCTL; + else if (!strcmp(lpszStructType, szOID_ECC_PUBLIC_KEY)) + decodeFunc = CRYPT_AsnDecodeObjectIdentifier; return decodeFunc; } diff --git a/dll/win32/crypt32/encode.c b/dll/win32/crypt32/encode.c index b00670471d..6f9f595f4f 100644 --- a/dll/win32/crypt32/encode.c +++ b/dll/win32/crypt32/encode.c @@ -30,6 +30,23 @@ * MSDN, especially "Constants for CryptEncodeObject and CryptDecodeObject" */ +#include "config.h" +#include "wine/port.h" + +#include <assert.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +#define NONAMELESSUNION + +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "snmp.h" +#include "wine/debug.h" +#include "wine/exception.h" +#include "wine/unicode.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(cryptasn); diff --git a/dll/win32/crypt32/filestore.c b/dll/win32/crypt32/filestore.c index f3e618f693..0f7d8d5150 100644 --- a/dll/win32/crypt32/filestore.c +++ b/dll/win32/crypt32/filestore.c @@ -15,7 +15,13 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ - +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "winnls.h" +#include "wine/debug.h" +#include "wine/unicode.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/main.c b/dll/win32/crypt32/main.c index 8f2902e5c7..c03c092edd 100644 --- a/dll/win32/crypt32/main.c +++ b/dll/win32/crypt32/main.c @@ -17,9 +17,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "crypt32_private.h" - +#include "config.h" +#include <stdarg.h> +#include <stdio.h> + +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "winreg.h" +#include "winuser.h" #include "i_cryptasn1tls.h" +#include "crypt32_private.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/message.c b/dll/win32/crypt32/message.c index e7402355b6..5b77c87bc4 100644 --- a/dll/win32/crypt32/message.c +++ b/dll/win32/crypt32/message.c @@ -16,7 +16,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "crypt32_private.h" +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" + +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/msg.c b/dll/win32/crypt32/msg.c index c9a0fe1164..fd43a7baeb 100644 --- a/dll/win32/crypt32/msg.c +++ b/dll/win32/crypt32/msg.c @@ -16,6 +16,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + +#include <stdarg.h> +#define NONAMELESSUNION +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "snmp.h" + +#include "wine/debug.h" +#include "wine/exception.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); @@ -2715,12 +2727,10 @@ static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData, size += CRYPT_SizeOfAttributes(&in->UnauthAttrs); if (!pvData) { - *pcbData = size; ret = TRUE; } else if (*pcbData < size) { - *pcbData = size; SetLastError(ERROR_MORE_DATA); ret = FALSE; } @@ -2753,6 +2763,7 @@ static BOOL CRYPT_CopySignerInfo(void *pvData, DWORD *pcbData, CRYPT_CopyAttributes(&out->UnauthAttrs, &in->UnauthAttrs, &nextData); } } + *pcbData = size; TRACE("returning %d\n", ret); return ret; } diff --git a/dll/win32/crypt32/object.c b/dll/win32/crypt32/object.c index 78dea1991c..0320cfda1b 100644 --- a/dll/win32/crypt32/object.c +++ b/dll/win32/crypt32/object.c @@ -17,10 +17,18 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ - +#include <stdarg.h> +#define NONAMELESSUNION +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "mssip.h" +#include "winuser.h" +#include "wintrust.h" #include "crypt32_private.h" - -#include <wintrust.h> +#include "cryptres.h" +#include "wine/unicode.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/oid.c b/dll/win32/crypt32/oid.c index ff1c859b3f..42d998a242 100644 --- a/dll/win32/crypt32/oid.c +++ b/dll/win32/crypt32/oid.c @@ -17,7 +17,22 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + +#include <stdio.h> +#include <stdarg.h> +#define NONAMELESSUNION +#include "windef.h" +#include "winbase.h" +#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS +#include "wincrypt.h" +#include "winreg.h" +#include "winuser.h" +#include "wine/debug.h" +#include "wine/list.h" #include "crypt32_private.h" +#include "cryptres.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); @@ -1066,6 +1081,8 @@ static const WCHAR sha384RSA[] = { 's','h','a','3','8','4','R','S','A',0 }; static const WCHAR sha512RSA[] = { 's','h','a','5','1','2','R','S','A',0 }; static const WCHAR mosaicUpdatedSig[] = { 'm','o','s','a','i','c','U','p','d','a','t','e','d','S','i','g',0 }; +static const WCHAR sha256ECDSA[] = { 's','h','a','2','5','6','E','C','D','S','A',0 }; +static const WCHAR sha384ECDSA[] = { 's','h','a','3','8','4','E','C','D','S','A',0 }; static const WCHAR CN[] = { 'C','N',0 }; static const WCHAR L[] = { 'L',0 }; static const WCHAR O[] = { 'O',0 }; @@ -1112,12 +1129,16 @@ static const DWORD dssSign[2] = { CALG_DSS_SIGN, static const DWORD mosaicSign[2] = { CALG_DSS_SIGN, CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG | CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; +static const DWORD ecdsaSign[2] = { CALG_OID_INFO_PARAMETERS, + CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; static const CRYPT_DATA_BLOB rsaSignBlob = { sizeof(rsaSign), (LPBYTE)&rsaSign }; static const CRYPT_DATA_BLOB dssSignBlob = { sizeof(dssSign), (LPBYTE)dssSign }; static const CRYPT_DATA_BLOB mosaicSignBlob = { sizeof(mosaicSign), (LPBYTE)mosaicSign }; +static const CRYPT_DATA_BLOB ecdsaSignBlob = { sizeof(ecdsaSign), + (LPBYTE)ecdsaSign }; static const DWORD ia5String[] = { CERT_RDN_IA5_STRING, 0 }; static const DWORD numericString[] = { CERT_RDN_NUMERIC_STRING, 0 }; @@ -1139,6 +1160,8 @@ static const struct OIDInfoConstructor { UINT Algid; LPCWSTR pwszName; const CRYPT_DATA_BLOB *blob; + LPCWSTR pwszCNGAlgid; + LPCWSTR pwszCNGExtraAlgid; } oidInfoConstructors[] = { { 1, szOID_OIWSEC_sha1, CALG_SHA1, sha1, NULL }, { 1, szOID_OIWSEC_sha1, CALG_SHA1, sha, NULL }, @@ -1146,6 +1169,7 @@ static const struct OIDInfoConstructor { { 1, szOID_RSA_MD5, CALG_MD5, md5, NULL }, { 1, szOID_RSA_MD4, CALG_MD4, md4, NULL }, { 1, szOID_RSA_MD2, CALG_MD2, md2, NULL }, + /* NOTE: Windows Vista+ uses -1 instead of CALG_SHA_* following SHA entries. */ { 1, szOID_NIST_sha256, CALG_SHA_256, sha256, NULL }, { 1, szOID_NIST_sha384, CALG_SHA_384, sha384, NULL }, { 1, szOID_NIST_sha512, CALG_SHA_512, sha512, NULL }, @@ -1193,6 +1217,10 @@ static const struct OIDInfoConstructor { { 4, szOID_OIWSEC_dsaSHA1, CALG_SHA1, dsaSHA1, &dssSignBlob }, { 4, szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA1, mosaicUpdatedSig, &mosaicSignBlob }, + { 4, szOID_ECDSA_SHA256, CALG_OID_INFO_CNG_ONLY, sha256ECDSA, &ecdsaSignBlob, + BCRYPT_SHA256_ALGORITHM, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM }, + { 4, szOID_ECDSA_SHA384, CALG_OID_INFO_CNG_ONLY, sha384ECDSA, &ecdsaSignBlob, + BCRYPT_SHA384_ALGORITHM, CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM }, { 5, szOID_COMMON_NAME, 0, CN, NULL }, { 5, szOID_LOCALITY_NAME, 0, L, NULL }, @@ -1408,6 +1436,8 @@ static void init_oid_info(void) info->info.ExtraInfo.pbData = oidInfoConstructors[i].blob->pbData; } + info->info.pwszCNGAlgid = oidInfoConstructors[i].pwszCNGAlgid; + info->info.pwszCNGExtraAlgid = oidInfoConstructors[i].pwszCNGExtraAlgid; list_add_tail(&oidInfo, &info->entry); } } @@ -1440,6 +1470,8 @@ static void init_oid_info(void) info->info.ExtraInfo.pbData = oidInfoConstructors[i].blob->pbData; } + info->info.pwszCNGAlgid = oidInfoConstructors[i].pwszCNGAlgid; + info->info.pwszCNGExtraAlgid = oidInfoConstructors[i].pwszCNGExtraAlgid; list_add_tail(&oidInfo, &info->entry); } } diff --git a/dll/win32/crypt32/precomp.h b/dll/win32/crypt32/precomp.h new file mode 100644 index 0000000000..90336916bc --- /dev/null +++ b/dll/win32/crypt32/precomp.h @@ -0,0 +1,40 @@ + +#ifndef __CRYPT32_PRECOMP_H__ +#define __CRYPT32_PRECOMP_H__ + +#include <wine/config.h> +#include <wine/port.h> + +#include <assert.h> +#include <stdarg.h> +#include <stdio.h> + +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define NONAMELESSUNION + +#include <ntstatus.h> +#define WIN32_NO_STATUS +#include <windef.h> +#include <winbase.h> +#include <wine/winternl.h> +#include <winuser.h> +#include <winreg.h> +#include <snmp.h> + +#define CERT_CHAIN_PARA_HAS_EXTRA_FIELDS +#define CERT_REVOCATION_PARA_HAS_EXTRA_FIELDS +#define CRYPT_OID_INFO_HAS_EXTRA_FIELDS +#include <wincrypt.h> + +#include <mssip.h> + +#include <wine/unicode.h> +#include <wine/exception.h> +#include <wine/debug.h> + +#include "crypt32_private.h" +#include "cryptres.h" + +#endif /* !__CRYPT32_PRECOMP_H__ */ diff --git a/dll/win32/crypt32/proplist.c b/dll/win32/crypt32/proplist.c index 291b94c902..f5ae221352 100644 --- a/dll/win32/crypt32/proplist.c +++ b/dll/win32/crypt32/proplist.c @@ -15,7 +15,13 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ - +#include <assert.h> +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "wine/debug.h" +#include "wine/list.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/protectdata.c b/dll/win32/crypt32/protectdata.c index 6ef8b638f0..20e11f457c 100644 --- a/dll/win32/crypt32/protectdata.c +++ b/dll/win32/crypt32/protectdata.c @@ -34,7 +34,15 @@ * */ -#include "crypt32_private.h" +#include <stdarg.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/provstore.c b/dll/win32/crypt32/provstore.c index 640ea62605..a6f7130be8 100644 --- a/dll/win32/crypt32/provstore.c +++ b/dll/win32/crypt32/provstore.c @@ -16,6 +16,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <stdarg.h> +#include <assert.h> + +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "wine/debug.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/regstore.c b/dll/win32/crypt32/regstore.c index ba4b439a26..5a39a2684d 100644 --- a/dll/win32/crypt32/regstore.c +++ b/dll/win32/crypt32/regstore.c @@ -15,11 +15,16 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ - +#include <assert.h> +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "winreg.h" +#include "winuser.h" +#include "wine/debug.h" #include "crypt32_private.h" -#include <shlwapi.h> - WINE_DEFAULT_DEBUG_CHANNEL(crypt); typedef struct _WINE_HASH_TO_DELETE diff --git a/dll/win32/crypt32/rootstore.c b/dll/win32/crypt32/rootstore.c index a5e2744833..cdeec74341 100644 --- a/dll/win32/crypt32/rootstore.c +++ b/dll/win32/crypt32/rootstore.c @@ -15,9 +15,9 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ - -#include "crypt32_private.h" - +#include "config.h" +#include <stdarg.h> +#include <stdio.h> #include <sys/types.h> #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> @@ -34,6 +34,15 @@ #ifdef HAVE_SECURITY_SECURITY_H #include <Security/Security.h> #endif +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "wincrypt.h" +#include "wine/winternl.h" +#include "wine/debug.h" +#include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/serialize.c b/dll/win32/crypt32/serialize.c index b722d21de7..e8ccc4a06e 100644 --- a/dll/win32/crypt32/serialize.c +++ b/dll/win32/crypt32/serialize.c @@ -16,6 +16,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "wine/debug.h" +#include "wine/exception.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/sip.c b/dll/win32/crypt32/sip.c index 9d195e0e40..8b561fdc2c 100644 --- a/dll/win32/crypt32/sip.c +++ b/dll/win32/crypt32/sip.c @@ -18,7 +18,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "crypt32_private.h" +#include <stdarg.h> +#include <stdio.h> + +#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "winreg.h" +#include "winnls.h" +#include "mssip.h" +#include "winuser.h" + +#include "wine/debug.h" +#include "wine/list.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dll/win32/crypt32/store.c b/dll/win32/crypt32/store.c index 7910635a29..bc4ebde5f6 100644 --- a/dll/win32/crypt32/store.c +++ b/dll/win32/crypt32/store.c @@ -23,6 +23,19 @@ * - Many flags, options and whatnot are unimplemented. */ +#include "config.h" +#include "wine/port.h" + +#include <assert.h> +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "winnls.h" +#include "winreg.h" +#include "winuser.h" +#include "wincrypt.h" +#include "wine/debug.h" +#include "wine/exception.h" #include "crypt32_private.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); @@ -1371,6 +1384,13 @@ BOOL WINAPI CertRegisterPhysicalStore(const void *pvSystemStore, DWORD dwFlags, return FALSE; } +BOOL WINAPI CertUnregisterPhysicalStore(const void *pvSystemStore, DWORD dwFlags, + LPCWSTR pwszStoreName) +{ + FIXME("(%p, %08x, %s): stub\n", pvSystemStore, dwFlags, debugstr_w(pwszStoreName)); + return TRUE; +} + BOOL WINAPI CertRegisterSystemStore(const void *pvSystemStore, DWORD dwFlags, PCERT_SYSTEM_STORE_INFO pStoreInfo, void *pvReserved) { @@ -1394,7 +1414,7 @@ BOOL WINAPI CertRegisterSystemStore(const void *pvSystemStore, DWORD dwFlags, return FALSE; } -BOOL WINAPI CertUnregisterSystemStore(void *pvSystemStore, DWORD dwFlags) +BOOL WINAPI CertUnregisterSystemStore(const void *pvSystemStore, DWORD dwFlags) { HCERTSTORE hstore; diff --git a/dll/win32/crypt32/str.c b/dll/win32/crypt32/str.c index d2eee455b5..1daf29f8a0 100644 --- a/dll/win32/crypt32/str.c +++ b/dll/win32/crypt32/str.c @@ -15,8 +15,17 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <stdarg.h> -#include "crypt32_private.h" +#define NONAMELESSUNION + +#include "windef.h" +#include "winbase.h" +#include "winnls.h" +#include "winuser.h" +#include "wincrypt.h" +#include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 50402e4320..7d6bb23c99 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -58,7 +58,7 @@ reactos/dll/win32/comctl32 # Synced to Wine-3.0 reactos/dll/win32/comdlg32 # Synced to WineStaging-3.3 reactos/dll/win32/compstui # Synced to WineStaging-3.3 reactos/dll/win32/credui # Synced to WineStaging-3.3 -reactos/dll/win32/crypt32 # Synced to WineStaging-2.16 +reactos/dll/win32/crypt32 # Synced to WineStaging-3.3 reactos/dll/win32/cryptdlg # Synced to WineStaging-2.9 reactos/dll/win32/cryptdll # Synced to WineStaging-2.9 reactos/dll/win32/cryptnet # Synced to WineStaging-2.9
6 years, 9 months
1
0
0
0
01/01: [PSDK] Update bcrypt.h and wincrypt.h. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e12999505856817879a24…
commit e12999505856817879a248108f1ddf34f08d5c4f Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 12:58:19 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 12:58:19 2018 +0100 [PSDK] Update bcrypt.h and wincrypt.h. CORE-14434 --- sdk/include/psdk/bcrypt.h | 96 +++++++++++++++++++++++++++++++++++++++++++++ sdk/include/psdk/wincrypt.h | 50 +++++++++++++++++++++++ 2 files changed, 146 insertions(+) diff --git a/sdk/include/psdk/bcrypt.h b/sdk/include/psdk/bcrypt.h index 6a80528698..d4118b3f1b 100644 --- a/sdk/include/psdk/bcrypt.h +++ b/sdk/include/psdk/bcrypt.h @@ -58,6 +58,14 @@ typedef NTSTATUS *PNTSTATUS; #define BCRYPT_PROVIDER_HANDLE L"ProviderHandle" #define BCRYPT_SIGNATURE_LENGTH L"SignatureLength" +#define BCRYPT_OPAQUE_KEY_BLOB L"OpaqueKeyBlob" +#define BCRYPT_KEY_DATA_BLOB (const WCHAR []){'K','e','y','D','a','t','a','B','l','o','b',0} +#define BCRYPT_AES_WRAP_KEY_BLOB (const WCHAR []){'R','f','c','3','5','6','5','K','e','y','W','r','a','p','B','l','o','b',0} +#define BCRYPT_ECCPUBLIC_BLOB (const WCHAR []){'E','C','C','P','U','B','L','I','C','B','L','O','B',0} +#define BCRYPT_ECCPRIVATE_BLOB (const WCHAR []){'E','C','C','P','R','I','V','A','T','E','B','L','O','B',0} +#define BCRYPT_RSAPUBLIC_BLOB (const WCHAR []){'R','S','A','P','U','B','L','I','C','B','L','O','B',0} +#define BCRYPT_RSAPRIVATE_BLOB (const WCHAR []){'R','S','A','P','R','I','V','A','T','E','B','L','O','B',0} + #define MS_PRIMITIVE_PROVIDER L"Microsoft Primitive Provider" #define MS_PLATFORM_CRYPTO_PROVIDER L"Microsoft Platform Crypto Provider" @@ -67,6 +75,16 @@ typedef NTSTATUS *PNTSTATUS; #define BCRYPT_SHA256_ALGORITHM L"SHA256" #define BCRYPT_SHA384_ALGORITHM L"SHA384" #define BCRYPT_SHA512_ALGORITHM L"SHA512" +#define BCRYPT_ECDSA_P256_ALGORITHM L"ECDSA_P256" +#define BCRYPT_ECDSA_P384_ALGORITHM L"ECDSA_P384" +#define BCRYPT_ECDSA_P521_ALGORITHM L"ECDSA_P521" + +#define BCRYPT_ECDSA_PUBLIC_P256_MAGIC 0x31534345 +#define BCRYPT_ECDSA_PRIVATE_P256_MAGIC 0x32534345 +#define BCRYPT_ECDSA_PUBLIC_P384_MAGIC 0x33534345 +#define BCRYPT_ECDSA_PRIVATE_P384_MAGIC 0x34534345 +#define BCRYPT_ECDSA_PUBLIC_P521_MAGIC 0x35534345 +#define BCRYPT_ECDSA_PRIVATE_P521_MAGIC 0x36534345 typedef struct _BCRYPT_ALGORITHM_IDENTIFIER { @@ -75,7 +93,77 @@ typedef struct _BCRYPT_ALGORITHM_IDENTIFIER ULONG dwFlags; } BCRYPT_ALGORITHM_IDENTIFIER; +typedef struct __BCRYPT_KEY_LENGTHS_STRUCT +{ + ULONG dwMinLength; + ULONG dwMaxLength; + ULONG dwIncrement; +} BCRYPT_KEY_LENGTHS_STRUCT, BCRYPT_AUTH_TAG_LENGTHS_STRUCT; + +typedef struct _BCRYPT_KEY_DATA_BLOB_HEADER +{ + ULONG dwMagic; + ULONG dwVersion; + ULONG cbKeyData; +} BCRYPT_KEY_DATA_BLOB_HEADER, *PBCRYPT_KEY_DATA_BLOB_HEADER; + +typedef struct _BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO +{ + ULONG cbSize; + ULONG dwInfoVersion; + UCHAR *pbNonce; + ULONG cbNonce; + UCHAR *pbAuthData; + ULONG cbAuthData; + UCHAR *pbTag; + ULONG cbTag; + UCHAR *pbMacContext; + ULONG cbMacContext; + ULONG cbAAD; + ULONGLONG cbData; + ULONG dwFlags; +} BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO, *PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO; + +typedef struct _BCRYPT_ECCKEY_BLOB +{ + ULONG dwMagic; + ULONG cbKey; +} BCRYPT_ECCKEY_BLOB, *PBCRYPT_ECCKEY_BLOB; + +#define BCRYPT_RSAPUBLIC_MAGIC 0x31415352 +#define BCRYPT_RSAPRIVATE_MAGIC 0x32415352 +#define BCRYPT_RSAFULLPRIVATE_MAGIC 0x33415352 + +typedef struct _BCRYPT_RSAKEY_BLOB +{ + ULONG Magic; + ULONG BitLength; + ULONG cbPublicExp; + ULONG cbModulus; + ULONG cbPrime1; + ULONG cbPrime2; +} BCRYPT_RSAKEY_BLOB; + +typedef struct _BCRYPT_PKCS1_PADDING_INFO +{ + LPCWSTR pszAlgId; +} BCRYPT_PKCS1_PADDING_INFO; + +#define BCRYPT_PAD_NONE 0x00000001 +#define BCRYPT_PAD_PKCS1 0x00000002 +#define BCRYPT_PAD_OAEP 0x00000004 +#define BCRYPT_PAD_PSS 0x00000008 + +#define BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION 1 + +#define BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG 0x00000001 +#define BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG 0x00000002 + +#define BCRYPT_KEY_DATA_BLOB_MAGIC 0x4d42444b +#define BCRYPT_KEY_DATA_BLOB_VERSION1 1 + typedef PVOID BCRYPT_ALG_HANDLE; +typedef PVOID BCRYPT_KEY_HANDLE; typedef PVOID BCRYPT_HANDLE; typedef PVOID BCRYPT_HASH_HANDLE; @@ -85,14 +173,22 @@ typedef PVOID BCRYPT_HASH_HANDLE; NTSTATUS WINAPI BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE, ULONG); NTSTATUS WINAPI BCryptCreateHash(BCRYPT_ALG_HANDLE, BCRYPT_HASH_HANDLE *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG); +NTSTATUS WINAPI BCryptDecrypt(BCRYPT_KEY_HANDLE, PUCHAR, ULONG, VOID *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG *, ULONG); NTSTATUS WINAPI BCryptDestroyHash(BCRYPT_HASH_HANDLE); +NTSTATUS WINAPI BCryptDestroyKey(BCRYPT_KEY_HANDLE); +NTSTATUS WINAPI BCryptEncrypt(BCRYPT_KEY_HANDLE, PUCHAR, ULONG, VOID *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG *, ULONG); NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG, ULONG *, BCRYPT_ALGORITHM_IDENTIFIER **, ULONG); NTSTATUS WINAPI BCryptFinishHash(BCRYPT_HASH_HANDLE, PUCHAR, ULONG, ULONG); +NTSTATUS WINAPI BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE *, PUCHAR, ULONG, PUCHAR, ULONG, ULONG); NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, ULONG); NTSTATUS WINAPI BCryptGetFipsAlgorithmMode(BOOLEAN *); NTSTATUS WINAPI BCryptGetProperty(BCRYPT_HANDLE, LPCWSTR, PUCHAR, ULONG, ULONG *, ULONG); NTSTATUS WINAPI BCryptHash(BCRYPT_ALG_HANDLE, PUCHAR, ULONG, PUCHAR, ULONG, PUCHAR, ULONG); NTSTATUS WINAPI BCryptHashData(BCRYPT_HASH_HANDLE, PUCHAR, ULONG, ULONG); +NTSTATUS WINAPI BCryptImportKeyPair(BCRYPT_ALG_HANDLE, BCRYPT_KEY_HANDLE, LPCWSTR, BCRYPT_KEY_HANDLE *, UCHAR *, ULONG, ULONG); NTSTATUS WINAPI BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE *, LPCWSTR, LPCWSTR, ULONG); +NTSTATUS WINAPI BCryptSetProperty(BCRYPT_HANDLE, LPCWSTR, PUCHAR, ULONG, ULONG); +NTSTATUS WINAPI BCryptDuplicateHash(BCRYPT_HASH_HANDLE, BCRYPT_HASH_HANDLE *, UCHAR *, ULONG, ULONG); +NTSTATUS WINAPI BCryptVerifySignature(BCRYPT_KEY_HANDLE, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG); #endif /* __WINE_BCRYPT_H */ diff --git a/sdk/include/psdk/wincrypt.h b/sdk/include/psdk/wincrypt.h index 88b403f373..ffd664419b 100644 --- a/sdk/include/psdk/wincrypt.h +++ b/sdk/include/psdk/wincrypt.h @@ -295,6 +295,11 @@ typedef struct _CERT_KEY_ATTRIBUTES_INFO { PCERT_PRIVATE_KEY_VALIDITY pPrivateKeyUsagePeriod; } CERT_KEY_ATTRIBUTES_INFO, *PCERT_KEY_ATTRIBUTES_INFO; +typedef struct _CERT_ECC_SIGNATURE { + CRYPT_UINT_BLOB r; + CRYPT_UINT_BLOB s; +} CERT_ECC_SIGNATURE, *PCERT_ECC_SIGNATURE; + /* byte 0 */ #define CERT_DIGITAL_SIGNATURE_KEY_USAGE 0x80 #define CERT_NON_REPUDIATION_KEY_USAGE 0x40 @@ -1365,6 +1370,17 @@ typedef BOOL #define CRYPT_MATCH_ANY_ENCODING_TYPE 0xffffffff +#define CALG_OID_INFO_CNG_ONLY 0xffffffff +#define CALG_OID_INFO_PARAMETERS 0xfffffffe + +#define CRYPT_OID_INFO_HASH_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','H','a','s','h','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_ECC_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','E','C','C','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_MGF1_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','M','g','f','1','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_NO_SIGN_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','N','o','S','i','g','n',0} +#define CRYPT_OID_INFO_OAEP_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','O','A','E','P','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_ECC_WRAP_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','E','C','C','W','r','a','p','P','a','r','a','m','e','t','e','r','s',0} +#define CRYPT_OID_INFO_NO_PARAMETERS_ALGORITHM (const WCHAR []){'C','r','y','p','t','O','I','D','I','n','f','o','N','o','P','a','r','a','m','e','t','e','r','s',0} + typedef struct _CRYPT_OID_INFO { DWORD cbSize; LPCSTR pszOID; @@ -1376,6 +1392,10 @@ typedef struct _CRYPT_OID_INFO { DWORD dwLength; } DUMMYUNIONNAME; CRYPT_DATA_BLOB ExtraInfo; +#ifdef CRYPT_OID_INFO_HAS_EXTRA_FIELDS + LPCWSTR pwszCNGAlgid; + LPCWSTR pwszCNGExtraAlgid; +#endif } CRYPT_OID_INFO, *PCRYPT_OID_INFO; typedef const CRYPT_OID_INFO CCRYPT_OID_INFO, *PCCRYPT_OID_INFO; @@ -2191,6 +2211,12 @@ static const WCHAR MS_ENH_RSA_AES_PROV_XP_W[] = { 'M','i','c','r','o','s','o','f #define CRYPTPROTECT_AUDIT 0x0010 #define CRYPTPROTECT_VERIFY_PROTECTION 0x0040 +/* Crypt{Protect,Unprotect}Memory */ +#define CRYPTPROTECTMEMORY_BLOCK_SIZE 16 +#define CRYPTPROTECTMEMORY_SAME_PROCESS 0x0000 +#define CRYPTPROTECTMEMORY_CROSS_PROCESS 0x0001 +#define CRYPTPROTECTMEMORY_SAME_LOGON 0x0002 + /* Blob Types */ #define SIMPLEBLOB 0x1 #define PUBLICKEYBLOB 0x6 @@ -3014,6 +3040,12 @@ typedef struct _CTL_FIND_SUBJECT_PARA #define szOID_X957 "1.2.840.10040" #define szOID_X957_DSA "1.2.840.10040.4.1" #define szOID_X957_SHA1DSA "1.2.840.10040.4.3" +#define szOID_ECC_PUBLIC_KEY "1.2.840.10045.2.1" +#define szOID_ECC_CURVE_P256 "1.2.840.10045.3.1.7" +#define szOID_ECDSA_SPECIFIED "1.2.840.10045.4.3" +#define szOID_ECDSA_SHA256 "1.2.840.10045.4.3.2" +#define szOID_ECDSA_SHA384 "1.2.840.10045.4.3.3" +#define szOID_ECDSA_SHA512 "1.2.840.10045.4.3.4" #define szOID_DS "2.5" #define szOID_DSALG "2.5.8" #define szOID_DSALG_CRPT "2.5.8.1" @@ -3055,6 +3087,8 @@ typedef struct _CTL_FIND_SUBJECT_PARA #define szOID_OIWDIR_SIGN "1.3.14.7.2.3" #define szOID_OIWDIR_md2 "1.3.14.7.2.2.1" #define szOID_OIWDIR_md2RSA "1.3.14.7.2.3.1" +#define szOID_ECC_CURVE_P384 "1.3.132.0.34" +#define szOID_ECC_CURVE_P521 "1.3.132.0.35" #define szOID_INFOSEC "2.16.840.1.101.2.1" #define szOID_INFOSEC_sdnsSignature "2.16.840.1.101.2.1.1.1" #define szOID_INFOSEC_mosaicSignature "2.16.840.1.101.2.1.1.2" @@ -3360,6 +3394,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA #define X509_PKIX_POLICY_QUALIFIER_USERNOTICE ((LPCSTR)46) #define X509_DH_PUBLICKEY X509_MULTI_BYTE_UINT #define X509_DH_PARAMETERS ((LPCSTR)47) +#define X509_ECC_SIGNATURE ((LPCSTR)47) #define PKCS_ATTRIBUTES ((LPCSTR)48) #define PKCS_SORTED_CTL ((LPCSTR)49) #define X942_DH_PARAMETERS ((LPCSTR)50) @@ -3377,6 +3412,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA #define CMC_ADD_EXTENSIONS ((LPCSTR)62) #define CMC_ADD_ATTRIBUTES ((LPCSTR)63) #define X509_CERTIFICATE_TEMPLATE ((LPCSTR)64) +#define X509_OBJECT_IDENTIFIER ((LPCSTR)73) #define PKCS7_SIGNER_INFO ((LPCSTR)500) #define CMS_SIGNER_INFO ((LPCSTR)501) @@ -4710,6 +4746,20 @@ CertEnumSystemStore( _Inout_opt_ void *pvArg, __callback PFN_CERT_ENUM_SYSTEM_STORE pfnEnum); +BOOL +WINAPI +CertRegisterSystemStore( + _In_ const void *pvSystemStore, + _In_ DWORD dwFlags, + _In_opt_ PCERT_SYSTEM_STORE_INFO pStoreInfo, + _Reserved_ void *pvReserved); + +BOOL +WINAPI +CertUnregisterSystemStore( + _In_ const void *pvSystemStore, + _In_ DWORD dwFlags); + BOOL WINAPI CertEnumPhysicalStore(
6 years, 9 months
1
0
0
0
01/01: [CREDUI] Sync with Wine Staging 3.3. CORE-14434
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=98e90aa94965117880e1a…
commit 98e90aa94965117880e1aa826feb099919e545cb Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Fri Mar 9 12:57:13 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Fri Mar 9 12:57:13 2018 +0100 [CREDUI] Sync with Wine Staging 3.3. CORE-14434 --- dll/win32/credui/credui.rc | 3 --- dll/win32/credui/credui_main.c | 23 +++++++++++------------ dll/win32/credui/credui_resources.h | 3 ++- media/doc/README.WINE | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/dll/win32/credui/credui.rc b/dll/win32/credui/credui.rc index 6ed8d26641..61be6fa459 100644 --- a/dll/win32/credui/credui.rc +++ b/dll/win32/credui/credui.rc @@ -18,9 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windef.h> -#include <winuser.h> - #include "credui_resources.h" /* @makedep: banner.bmp */ diff --git a/dll/win32/credui/credui_main.c b/dll/win32/credui/credui_main.c index b5cb48c46c..a4df9fe433 100644 --- a/dll/win32/credui/credui_main.c +++ b/dll/win32/credui/credui_main.c @@ -18,23 +18,22 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define WIN32_NO_STATUS - #include <stdarg.h> -#include <windef.h> -#include <winbase.h> -//#include "winnt.h" -#include <winuser.h> -#include <wincred.h> -#include <sspi.h> -#include <commctrl.h> +#include "windef.h" +#include "winbase.h" +#include "winnt.h" +#include "winuser.h" +#include "wincred.h" +#include "rpc.h" +#include "sspi.h" +#include "commctrl.h" #include "credui_resources.h" -#include <wine/debug.h> -#include <wine/unicode.h> -#include <wine/list.h> +#include "wine/debug.h" +#include "wine/unicode.h" +#include "wine/list.h" WINE_DEFAULT_DEBUG_CHANNEL(credui); diff --git a/dll/win32/credui/credui_resources.h b/dll/win32/credui/credui_resources.h index e3994abe68..0a6ab72b09 100644 --- a/dll/win32/credui/credui_resources.h +++ b/dll/win32/credui/credui_resources.h @@ -16,7 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#pragma once +#include <windef.h> +#include <winuser.h> #define IDD_CREDDIALOG 100 #define IDC_USERNAME 101 diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 193e1ad1fd..50402e4320 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -57,7 +57,7 @@ reactos/dll/win32/comcat # Synced to WineStaging-3.3 reactos/dll/win32/comctl32 # Synced to Wine-3.0 reactos/dll/win32/comdlg32 # Synced to WineStaging-3.3 reactos/dll/win32/compstui # Synced to WineStaging-3.3 -reactos/dll/win32/credui # Synced to WineStaging-2.9 +reactos/dll/win32/credui # Synced to WineStaging-3.3 reactos/dll/win32/crypt32 # Synced to WineStaging-2.16 reactos/dll/win32/cryptdlg # Synced to WineStaging-2.9 reactos/dll/win32/cryptdll # Synced to WineStaging-2.9
6 years, 9 months
1
0
0
0
← Newer
1
...
32
33
34
35
36
37
38
...
44
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Results per page:
10
25
50
100
200