winehq.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
2025
February
January
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
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
September 2020
----- 2025 -----
February 2025
January 2025
----- 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
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
703 discussions
Start a n
N
ew thread
Alexandre Julliard : bcrypt: Split the key structure into generic and backend-specific parts.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: 209b968efc2336a72f5223f0c73ff46f11a2f1ba URL:
https://source.winehq.org/git/wine.git/?a=commit;h=209b968efc2336a72f5223f0…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 29 15:27:32 2020 +0200 bcrypt: Split the key structure into generic and backend-specific parts. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/bcrypt/bcrypt_internal.h | 73 ++----------------------------------------- dlls/bcrypt/gnutls.c | 48 +++++++++++++++++----------- dlls/bcrypt/macos.c | 40 +++++++++++++++--------- 3 files changed, 58 insertions(+), 103 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=209b968efc2336a72f52…
1
0
0
0
Alexandre Julliard : bcrypt: Add separate backend functions for destroying symmetric/asymmetric keys.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: f0e13847779fe058b655c8ec1a20f61b431f7df2 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f0e13847779fe058b655c8ec…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 29 14:16:17 2020 +0200 bcrypt: Add separate backend functions for destroying symmetric/asymmetric keys. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/bcrypt/bcrypt_internal.h | 4 ++-- dlls/bcrypt/bcrypt_main.c | 32 +++++++++++++++++++++----------- dlls/bcrypt/gnutls.c | 21 +++++++-------------- dlls/bcrypt/macos.c | 15 ++++++++------- 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h index 2b26fbbc9c..ca48d20f77 100644 --- a/dlls/bcrypt/bcrypt_internal.h +++ b/dlls/bcrypt/bcrypt_internal.h @@ -265,12 +265,12 @@ NTSTATUS key_symmetric_set_auth_data( struct key *, UCHAR *, ULONG ) DECLSPEC_HI NTSTATUS key_symmetric_encrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_decrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_get_tag( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN; +void key_symmetric_destroy( struct key * ) DECLSPEC_HIDDEN; NTSTATUS key_asymmetric_init( struct key * ) DECLSPEC_HIDDEN; NTSTATUS key_asymmetric_generate( struct key * ) DECLSPEC_HIDDEN; NTSTATUS key_asymmetric_sign( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_asymmetric_verify( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, DWORD ) DECLSPEC_HIDDEN; -NTSTATUS key_destroy( struct key * ) DECLSPEC_HIDDEN; -BOOL key_is_symmetric( struct key * ) DECLSPEC_HIDDEN; +void key_asymmetric_destroy( struct key * ) DECLSPEC_HIDDEN; NTSTATUS key_export_dsa_capi( struct key *, UCHAR *, ULONG, ULONG * ) DECLSPEC_HIDDEN; NTSTATUS key_export_ecc( struct key *, UCHAR *, ULONG, ULONG * ) DECLSPEC_HIDDEN; NTSTATUS key_import_dsa_capi( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN; diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index d0fc02b776..c6d2266083 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -886,12 +886,12 @@ static NTSTATUS key_asymmetric_create( struct key **ret_key, struct algorithm *a return STATUS_SUCCESS; } -#if defined(HAVE_GNUTLS_CIPHER_INIT) || defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 -BOOL key_is_symmetric( struct key *key ) +static BOOL key_is_symmetric( struct key *key ) { return builtin_algorithms[key->alg_id].class == BCRYPT_CIPHER_INTERFACE; } +#if defined(HAVE_GNUTLS_CIPHER_INIT) || defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 static BOOL is_zero_vector( const UCHAR *vector, ULONG len ) { ULONG i; @@ -1335,12 +1335,6 @@ NTSTATUS key_symmetric_init( struct key *key ) return STATUS_NOT_IMPLEMENTED; } -BOOL key_is_symmetric( struct key *key ) -{ - ERR( "support for keys not available at build time\n" ); - return FALSE; -} - NTSTATUS key_set_property( struct key *key, const WCHAR *prop, UCHAR *value, ULONG size, ULONG flags ) { ERR( "support for keys not available at build time\n" ); @@ -1392,10 +1386,14 @@ static NTSTATUS key_export( struct key *key, const WCHAR *type, UCHAR *output, U return STATUS_NOT_IMPLEMENTED; } -NTSTATUS key_destroy( struct key *key ) +void key_symmetric_destroy( struct key *key ) +{ + ERR( "support for keys not available at build time\n" ); +} + +void key_asymmetric_destroy( struct key *key ) { ERR( "support for keys not available at build time\n" ); - return STATUS_NOT_IMPLEMENTED; } static NTSTATUS key_encrypt( struct key *key, UCHAR *input, ULONG input_len, void *padding, UCHAR *iv, @@ -1628,8 +1626,20 @@ NTSTATUS WINAPI BCryptDestroyKey( BCRYPT_KEY_HANDLE handle ) TRACE( "%p\n", handle ); if (!key || key->hdr.magic != MAGIC_KEY) return STATUS_INVALID_HANDLE; + if (key_is_symmetric( key )) + { + key_symmetric_destroy( key ); + heap_free( key->u.s.vector ); + heap_free( key->u.s.secret ); + } + else + { + key_asymmetric_destroy( key ); + heap_free( key->u.a.pubkey ); + } key->hdr.magic = 0; - return key_destroy( key ); + heap_free( key ); + return STATUS_SUCCESS; } NTSTATUS WINAPI BCryptEncrypt( BCRYPT_KEY_HANDLE handle, UCHAR *input, ULONG input_len, void *padding, UCHAR *iv, diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c index 222861c18b..341089c127 100644 --- a/dlls/bcrypt/gnutls.c +++ b/dlls/bcrypt/gnutls.c @@ -593,6 +593,11 @@ NTSTATUS key_symmetric_get_tag( struct key *key, UCHAR *tag, ULONG len ) return STATUS_SUCCESS; } +void key_symmetric_destroy( struct key *key ) +{ + if (key->u.s.handle) pgnutls_cipher_deinit( key->u.s.handle ); +} + static NTSTATUS export_gnutls_pubkey_rsa( gnutls_privkey_t gnutls_key, ULONG bitlen, UCHAR **pubkey, ULONG *pubkey_len ) { BCRYPT_RSAKEY_BLOB *rsa_blob; @@ -1543,20 +1548,8 @@ NTSTATUS key_asymmetric_sign( struct key *key, void *padding, UCHAR *input, ULON return status; } -NTSTATUS key_destroy( struct key *key ) +void key_asymmetric_destroy( struct key *key ) { - if (key_is_symmetric( key )) - { - if (key->u.s.handle) pgnutls_cipher_deinit( key->u.s.handle ); - heap_free( key->u.s.vector ); - heap_free( key->u.s.secret ); - } - else - { - if (key->u.a.handle) pgnutls_privkey_deinit( key->u.a.handle ); - heap_free( key->u.a.pubkey ); - } - heap_free( key ); - return STATUS_SUCCESS; + if (key->u.a.handle) pgnutls_privkey_deinit( key->u.a.handle ); } #endif diff --git a/dlls/bcrypt/macos.c b/dlls/bcrypt/macos.c index 26af5faa0c..1a9bb88880 100644 --- a/dlls/bcrypt/macos.c +++ b/dlls/bcrypt/macos.c @@ -184,6 +184,12 @@ NTSTATUS key_symmetric_get_tag( struct key *key, UCHAR *tag, ULONG len ) return STATUS_NOT_IMPLEMENTED; } +void key_symmetric_destroy( struct key *key ) +{ + if (key->u.s.ref_encrypt) CCCryptorRelease( key->u.s.ref_encrypt ); + if (key->u.s.ref_decrypt) CCCryptorRelease( key->u.s.ref_decrypt ); +} + NTSTATUS key_asymmetric_init( struct key *key ) { FIXME( "not implemented on Mac\n" ); @@ -234,13 +240,8 @@ NTSTATUS key_asymmetric_generate( struct key *key ) return STATUS_NOT_IMPLEMENTED; } -NTSTATUS key_destroy( struct key *key ) +void key_asymmetric_destroy( struct key *key ) { - if (key->u.s.ref_encrypt) CCCryptorRelease( key->u.s.ref_encrypt ); - if (key->u.s.ref_decrypt) CCCryptorRelease( key->u.s.ref_decrypt ); - heap_free( key->u.s.vector ); - heap_free( key->u.s.secret ); - heap_free( key ); - return STATUS_SUCCESS; + FIXME( "not implemented on Mac\n" ); } #endif
1
0
0
0
Alexandre Julliard : bcrypt: Move the symmetric key initialization to the generic code.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: 459046561328735dfe75181ecd825410747c6451 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=459046561328735dfe75181e…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 29 14:08:14 2020 +0200 bcrypt: Move the symmetric key initialization to the generic code. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/bcrypt/bcrypt_internal.h | 9 ++++++--- dlls/bcrypt/bcrypt_main.c | 33 ++++++++++++++++++++++++++++----- dlls/bcrypt/gnutls.c | 28 ++++------------------------ dlls/bcrypt/macos.c | 33 ++++++--------------------------- 4 files changed, 44 insertions(+), 59 deletions(-) diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h index 079c743809..2b26fbbc9c 100644 --- a/dlls/bcrypt/bcrypt_internal.h +++ b/dlls/bcrypt/bcrypt_internal.h @@ -227,6 +227,11 @@ struct key struct key_symmetric { enum mode_id mode; + ULONG block_size; + UCHAR *vector; + ULONG vector_len; + UCHAR *secret; + ULONG secret_len; }; struct key_asymmetric @@ -253,10 +258,8 @@ struct secret struct object hdr; }; -NTSTATUS get_alg_property( const struct algorithm *, const WCHAR *, UCHAR *, ULONG, ULONG * ) DECLSPEC_HIDDEN; - NTSTATUS key_set_property( struct key *, const WCHAR *, UCHAR *, ULONG, ULONG ) DECLSPEC_HIDDEN; -NTSTATUS key_symmetric_init( struct key *, struct algorithm *, const UCHAR *, ULONG ) DECLSPEC_HIDDEN; +NTSTATUS key_symmetric_init( struct key * ) DECLSPEC_HIDDEN; void key_symmetric_vector_reset( struct key * ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_set_auth_data( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_encrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN; diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index b77cf67c46..d0fc02b776 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -550,7 +550,8 @@ static NTSTATUS get_dsa_property( enum mode_id mode, const WCHAR *prop, UCHAR *b return STATUS_NOT_IMPLEMENTED; } -NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size ) +static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop, + UCHAR *buf, ULONG size, ULONG *ret_size ) { NTSTATUS status; @@ -1328,7 +1329,7 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP return STATUS_NOT_SUPPORTED; } #else -NTSTATUS key_symmetric_init( struct key *key, struct algorithm *alg, const UCHAR *secret, ULONG secret_len ) +NTSTATUS key_symmetric_init( struct key *key ) { ERR( "support for keys not available at build time\n" ); return STATUS_NOT_IMPLEMENTED; @@ -1431,12 +1432,20 @@ NTSTATUS key_import_ecc( struct key *key, UCHAR *input, ULONG len ) } #endif +static ULONG get_block_size( struct algorithm *alg ) +{ + ULONG ret = 0, size = sizeof(ret); + get_alg_property( alg, BCRYPT_BLOCK_LENGTH, (UCHAR *)&ret, sizeof(ret), &size ); + return ret; +} + NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_KEY_HANDLE *handle, UCHAR *object, ULONG object_len, UCHAR *secret, ULONG secret_len, ULONG flags ) { struct algorithm *alg = algorithm; struct key *key; + ULONG block_size; NTSTATUS status; TRACE( "%p, %p, %p, %u, %p, %u, %08x\n", algorithm, handle, object, object_len, secret, secret_len, flags ); @@ -1444,11 +1453,25 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_ if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE; if (object) FIXME( "ignoring object buffer\n" ); - if (!(key = heap_alloc( sizeof(*key) ))) return STATUS_NO_MEMORY; - key->hdr.magic = MAGIC_KEY; + if (!(block_size = get_block_size( alg ))) return STATUS_INVALID_PARAMETER; + + if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY; + key->hdr.magic = MAGIC_KEY; + key->alg_id = alg->id; + key->u.s.mode = alg->mode; + key->u.s.block_size = block_size; + + if (!(key->u.s.secret = heap_alloc( secret_len ))) + { + heap_free( key ); + return STATUS_NO_MEMORY; + } + memcpy( key->u.s.secret, secret, secret_len ); + key->u.s.secret_len = secret_len; - if ((status = key_symmetric_init( key, alg, secret, secret_len ))) + if ((status = key_symmetric_init( key ))) { + heap_free( key->u.s.secret ); heap_free( key ); return status; } diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c index 8b4d08f528..222861c18b 100644 --- a/dlls/bcrypt/gnutls.c +++ b/dlls/bcrypt/gnutls.c @@ -455,39 +455,19 @@ NTSTATUS key_set_property( struct key *key, const WCHAR *prop, UCHAR *value, ULO return STATUS_NOT_IMPLEMENTED; } -static ULONG get_block_size( struct algorithm *alg ) -{ - ULONG ret = 0, size = sizeof(ret); - get_alg_property( alg, BCRYPT_BLOCK_LENGTH, (UCHAR *)&ret, sizeof(ret), &size ); - return ret; -} - -NTSTATUS key_symmetric_init( struct key *key, struct algorithm *alg, const UCHAR *secret, ULONG secret_len ) +NTSTATUS key_symmetric_init( struct key *key ) { if (!libgnutls_handle) return STATUS_INTERNAL_ERROR; - switch (alg->id) + switch (key->alg_id) { case ALG_ID_AES: - break; + return STATUS_SUCCESS; default: - FIXME( "algorithm %u not supported\n", alg->id ); + FIXME( "algorithm %u not supported\n", key->alg_id ); return STATUS_NOT_SUPPORTED; } - - if (!(key->u.s.block_size = get_block_size( alg ))) return STATUS_INVALID_PARAMETER; - if (!(key->u.s.secret = heap_alloc( secret_len ))) return STATUS_NO_MEMORY; - memcpy( key->u.s.secret, secret, secret_len ); - key->u.s.secret_len = secret_len; - - key->alg_id = alg->id; - key->u.s.mode = alg->mode; - key->u.s.handle = 0; /* initialized on first use */ - key->u.s.vector = NULL; - key->u.s.vector_len = 0; - - return STATUS_SUCCESS; } static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key ) diff --git a/dlls/bcrypt/macos.c b/dlls/bcrypt/macos.c index 0c5f968bc6..26af5faa0c 100644 --- a/dlls/bcrypt/macos.c +++ b/dlls/bcrypt/macos.c @@ -68,47 +68,26 @@ NTSTATUS key_set_property( struct key *key, const WCHAR *prop, UCHAR *value, ULO return STATUS_NOT_IMPLEMENTED; } -static ULONG get_block_size( struct algorithm *alg ) +NTSTATUS key_symmetric_init( struct key *key ) { - ULONG ret = 0, size = sizeof(ret); - get_alg_property( alg, BCRYPT_BLOCK_LENGTH, (UCHAR *)&ret, sizeof(ret), &size ); - return ret; -} - -NTSTATUS key_symmetric_init( struct key *key, struct algorithm *alg, const UCHAR *secret, ULONG secret_len ) -{ - switch (alg->id) + switch (key->alg_id) { case ALG_ID_AES: - switch (alg->mode) + switch (key->u.s.mode) { case MODE_ID_ECB: case MODE_ID_CBC: break; default: - FIXME( "mode %u not supported\n", alg->mode ); + FIXME( "mode %u not supported\n", key->u.s.mode ); return STATUS_NOT_SUPPORTED; } - break; + return STATUS_SUCCESS; default: - FIXME( "algorithm %u not supported\n", alg->id ); + FIXME( "algorithm %u not supported\n", key->alg_id ); return STATUS_NOT_SUPPORTED; } - - if (!(key->u.s.block_size = get_block_size( alg ))) return STATUS_INVALID_PARAMETER; - if (!(key->u.s.secret = heap_alloc( secret_len ))) return STATUS_NO_MEMORY; - memcpy( key->u.s.secret, secret, secret_len ); - key->u.s.secret_len = secret_len; - - key->alg_id = alg->id; - key->u.s.mode = alg->mode; - key->u.s.ref_encrypt = NULL; /* initialized on first use */ - key->u.s.ref_decrypt = NULL; - key->u.s.vector = NULL; - key->u.s.vector_len = 0; - - return STATUS_SUCCESS; } static CCMode get_cryptor_mode( struct key *key )
1
0
0
0
Alexandre Julliard : bcrypt: Move setting a symmetric key vector to the generic code.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: b8ada902d12f628883c790cdef3bacf5853a7f81 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b8ada902d12f628883c790cd…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 29 13:53:02 2020 +0200 bcrypt: Move setting a symmetric key vector to the generic code. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/bcrypt/bcrypt_internal.h | 5 +---- dlls/bcrypt/bcrypt_main.c | 22 ++++++++++++++++++++-- dlls/bcrypt/gnutls.c | 25 +++++-------------------- dlls/bcrypt/macos.c | 28 +++++++--------------------- 4 files changed, 33 insertions(+), 47 deletions(-) diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h index 4caaf3307e..079c743809 100644 --- a/dlls/bcrypt/bcrypt_internal.h +++ b/dlls/bcrypt/bcrypt_internal.h @@ -257,7 +257,7 @@ NTSTATUS get_alg_property( const struct algorithm *, const WCHAR *, UCHAR *, ULO NTSTATUS key_set_property( struct key *, const WCHAR *, UCHAR *, ULONG, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_init( struct key *, struct algorithm *, const UCHAR *, ULONG ) DECLSPEC_HIDDEN; -NTSTATUS key_symmetric_set_vector( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN; +void key_symmetric_vector_reset( struct key * ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_set_auth_data( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_encrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_decrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN; @@ -273,9 +273,6 @@ NTSTATUS key_export_ecc( struct key *, UCHAR *, ULONG, ULONG * ) DECLSPEC_HIDDEN NTSTATUS key_import_dsa_capi( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_import_ecc( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN; -BOOL is_zero_vector( const UCHAR *, ULONG ) DECLSPEC_HIDDEN; -BOOL is_equal_vector( const UCHAR *, ULONG, const UCHAR *, ULONG ) DECLSPEC_HIDDEN; - BOOL gnutls_initialize(void) DECLSPEC_HIDDEN; void gnutls_uninitialize(void) DECLSPEC_HIDDEN; diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index 30a1acfc0c..b77cf67c46 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -891,7 +891,7 @@ BOOL key_is_symmetric( struct key *key ) return builtin_algorithms[key->alg_id].class == BCRYPT_CIPHER_INTERFACE; } -BOOL is_zero_vector( const UCHAR *vector, ULONG len ) +static BOOL is_zero_vector( const UCHAR *vector, ULONG len ) { ULONG i; if (!vector) return FALSE; @@ -899,13 +899,31 @@ BOOL is_zero_vector( const UCHAR *vector, ULONG len ) return TRUE; } -BOOL is_equal_vector( const UCHAR *vector, ULONG len, const UCHAR *vector2, ULONG len2 ) +static BOOL is_equal_vector( const UCHAR *vector, ULONG len, const UCHAR *vector2, ULONG len2 ) { if (!vector && !vector2) return TRUE; if (len != len2) return FALSE; return !memcmp( vector, vector2, len ); } +static NTSTATUS key_symmetric_set_vector( struct key *key, UCHAR *vector, ULONG vector_len ) +{ + BOOL needs_reset = (!is_zero_vector( vector, vector_len ) || + !is_equal_vector( key->u.s.vector, key->u.s.vector_len, vector, vector_len )); + + heap_free( key->u.s.vector ); + key->u.s.vector = NULL; + key->u.s.vector_len = 0; + if (vector) + { + if (!(key->u.s.vector = heap_alloc( vector_len ))) return STATUS_NO_MEMORY; + memcpy( key->u.s.vector, vector, vector_len ); + key->u.s.vector_len = vector_len; + } + if (needs_reset) key_symmetric_vector_reset( key ); + return STATUS_SUCCESS; +} + static NTSTATUS key_import( BCRYPT_ALG_HANDLE algorithm, const WCHAR *type, BCRYPT_KEY_HANDLE *key, UCHAR *object, ULONG object_len, UCHAR *input, ULONG input_len ) { diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c index 66c8f0f3e5..8b4d08f528 100644 --- a/dlls/bcrypt/gnutls.c +++ b/dlls/bcrypt/gnutls.c @@ -520,27 +520,12 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key ) } } -NTSTATUS key_symmetric_set_vector( struct key *key, UCHAR *vector, ULONG vector_len ) +void key_symmetric_vector_reset( struct key *key ) { - if (key->u.s.handle && (!is_zero_vector( vector, vector_len ) || - !is_equal_vector( key->u.s.vector, key->u.s.vector_len, vector, vector_len ))) - { - TRACE( "invalidating cipher handle\n" ); - pgnutls_cipher_deinit( key->u.s.handle ); - key->u.s.handle = NULL; - } - - heap_free( key->u.s.vector ); - key->u.s.vector = NULL; - key->u.s.vector_len = 0; - if (vector) - { - if (!(key->u.s.vector = heap_alloc( vector_len ))) return STATUS_NO_MEMORY; - memcpy( key->u.s.vector, vector, vector_len ); - key->u.s.vector_len = vector_len; - } - - return STATUS_SUCCESS; + if (!key->u.s.handle) return; + TRACE( "invalidating cipher handle\n" ); + pgnutls_cipher_deinit( key->u.s.handle ); + key->u.s.handle = NULL; } static NTSTATUS init_cipher_handle( struct key *key ) diff --git a/dlls/bcrypt/macos.c b/dlls/bcrypt/macos.c index 8da67dc993..0c5f968bc6 100644 --- a/dlls/bcrypt/macos.c +++ b/dlls/bcrypt/macos.c @@ -123,30 +123,16 @@ static CCMode get_cryptor_mode( struct key *key ) } } -NTSTATUS key_symmetric_set_vector( struct key *key, UCHAR *vector, ULONG vector_len ) +void key_symmetric_vector_reset( struct key *key ) { - if (key->u.s.ref_encrypt && (!is_zero_vector( vector, vector_len ) || - !is_equal_vector( key->u.s.vector, key->u.s.vector_len, vector, vector_len ))) - { - TRACE( "invalidating cryptor handles\n" ); - CCCryptorRelease( key->u.s.ref_encrypt ); - key->u.s.ref_encrypt = NULL; - - CCCryptorRelease( key->u.s.ref_decrypt ); - key->u.s.ref_decrypt = NULL; - } + if (!key->u.s.ref_encrypt) return; - heap_free( key->u.s.vector ); - key->u.s.vector = NULL; - key->u.s.vector_len = 0; - if (vector) - { - if (!(key->u.s.vector = heap_alloc( vector_len ))) return STATUS_NO_MEMORY; - memcpy( key->u.s.vector, vector, vector_len ); - key->u.s.vector_len = vector_len; - } + TRACE( "invalidating cryptor handles\n" ); + CCCryptorRelease( key->u.s.ref_encrypt ); + key->u.s.ref_encrypt = NULL; - return STATUS_SUCCESS; + CCCryptorRelease( key->u.s.ref_decrypt ); + key->u.s.ref_decrypt = NULL; } static NTSTATUS init_cryptor_handles( struct key *key )
1
0
0
0
Alexandre Julliard : bcrypt: Move the public key initialization to the generic code.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: 54c1b0ac267abd0e52f23a60143999af2cd49b03 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=54c1b0ac267abd0e52f23a60…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 29 13:41:52 2020 +0200 bcrypt: Move the public key initialization to the generic code. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/bcrypt/bcrypt_internal.h | 10 +++++++++- dlls/bcrypt/bcrypt_main.c | 18 +++++++++++++++--- dlls/bcrypt/gnutls.c | 20 ++++---------------- dlls/bcrypt/macos.c | 3 +-- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h index 43be170d77..4caaf3307e 100644 --- a/dlls/bcrypt/bcrypt_internal.h +++ b/dlls/bcrypt/bcrypt_internal.h @@ -229,6 +229,13 @@ struct key_symmetric enum mode_id mode; }; +struct key_asymmetric +{ + ULONG bitlen; /* ignored for ECC keys */ + UCHAR *pubkey; + ULONG pubkey_len; +}; + struct key { struct object hdr; @@ -236,6 +243,7 @@ struct key union { struct key_symmetric s; + struct key_asymmetric a; } u; }; #endif @@ -254,7 +262,7 @@ NTSTATUS key_symmetric_set_auth_data( struct key *, UCHAR *, ULONG ) DECLSPEC_HI NTSTATUS key_symmetric_encrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_decrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_symmetric_get_tag( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN; -NTSTATUS key_asymmetric_init( struct key *, struct algorithm *, ULONG, const UCHAR *, ULONG ) DECLSPEC_HIDDEN; +NTSTATUS key_asymmetric_init( struct key * ) DECLSPEC_HIDDEN; NTSTATUS key_asymmetric_generate( struct key * ) DECLSPEC_HIDDEN; NTSTATUS key_asymmetric_sign( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, ULONG *, ULONG ) DECLSPEC_HIDDEN; NTSTATUS key_asymmetric_verify( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, DWORD ) DECLSPEC_HIDDEN; diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index 5413d486ed..30a1acfc0c 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -862,9 +862,22 @@ static NTSTATUS key_asymmetric_create( struct key **ret_key, struct algorithm *a if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY; key->hdr.magic = MAGIC_KEY; + key->alg_id = alg->id; + key->u.a.bitlen = bitlen; - if ((status = key_asymmetric_init( key, alg, bitlen, pubkey, pubkey_len ))) + if (pubkey_len) { + if (!(key->u.a.pubkey = heap_alloc( pubkey_len ))) + { + heap_free( key ); + return STATUS_NO_MEMORY; + } + memcpy( key->u.a.pubkey, pubkey, pubkey_len ); + key->u.a.pubkey_len = pubkey_len; + } + if ((status = key_asymmetric_init( key ))) + { + heap_free( key->u.a.pubkey ); heap_free( key ); return status; } @@ -1321,8 +1334,7 @@ static NTSTATUS key_duplicate( struct key *key_orig, struct key *key_copy ) return STATUS_NOT_IMPLEMENTED; } -NTSTATUS key_asymmetric_init( struct key *key, struct algorithm *alg, ULONG bitlen, const UCHAR *pubkey, - ULONG pubkey_len ) +NTSTATUS key_asymmetric_init( struct key *key ) { ERR( "support for keys not available at build time\n" ); return STATUS_NOT_IMPLEMENTED; diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c index 7acf819862..66c8f0f3e5 100644 --- a/dlls/bcrypt/gnutls.c +++ b/dlls/bcrypt/gnutls.c @@ -1121,12 +1121,11 @@ NTSTATUS key_import_dsa_capi( struct key *key, UCHAR *buf, ULONG len ) return STATUS_SUCCESS; } -NTSTATUS key_asymmetric_init( struct key *key, struct algorithm *alg, ULONG bitlen, const UCHAR *pubkey, - ULONG pubkey_len ) +NTSTATUS key_asymmetric_init( struct key *key ) { if (!libgnutls_handle) return STATUS_INTERNAL_ERROR; - switch (alg->id) + switch (key->alg_id) { case ALG_ID_ECDH_P256: case ALG_ID_ECDSA_P256: @@ -1134,23 +1133,12 @@ NTSTATUS key_asymmetric_init( struct key *key, struct algorithm *alg, ULONG bitl case ALG_ID_RSA: case ALG_ID_RSA_SIGN: case ALG_ID_DSA: - break; + return STATUS_SUCCESS; default: - FIXME( "algorithm %u not supported\n", alg->id ); + FIXME( "algorithm %u not supported\n", key->alg_id ); return STATUS_NOT_SUPPORTED; } - - if (pubkey_len) - { - if (!(key->u.a.pubkey = heap_alloc( pubkey_len ))) return STATUS_NO_MEMORY; - memcpy( key->u.a.pubkey, pubkey, pubkey_len ); - key->u.a.pubkey_len = pubkey_len; - } - key->alg_id = alg->id; - key->u.a.bitlen = bitlen; - - return STATUS_SUCCESS; } static NTSTATUS import_gnutls_pubkey_ecc( struct key *key, gnutls_pubkey_t *gnutls_key ) diff --git a/dlls/bcrypt/macos.c b/dlls/bcrypt/macos.c index 7f902535b8..8da67dc993 100644 --- a/dlls/bcrypt/macos.c +++ b/dlls/bcrypt/macos.c @@ -219,8 +219,7 @@ NTSTATUS key_symmetric_get_tag( struct key *key, UCHAR *tag, ULONG len ) return STATUS_NOT_IMPLEMENTED; } -NTSTATUS key_asymmetric_init( struct key *key, struct algorithm *alg, ULONG bitlen, const UCHAR *pubkey, - ULONG pubkey_len ) +NTSTATUS key_asymmetric_init( struct key *key ) { FIXME( "not implemented on Mac\n" ); return STATUS_NOT_IMPLEMENTED;
1
0
0
0
Alexandre Julliard : bcrypt: Add a helper function to create an asymmetric key.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: d70c8e464a56a17f5c0669ff668fb1070781faa6 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d70c8e464a56a17f5c0669ff…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 29 13:33:37 2020 +0200 bcrypt: Add a helper function to create an asymmetric key. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/bcrypt/bcrypt_main.c | 89 ++++++++++++++--------------------------------- 1 file changed, 27 insertions(+), 62 deletions(-) diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index cd3b746e29..5413d486ed 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -854,6 +854,24 @@ NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG se return BCryptDestroyHash( handle ); } +static NTSTATUS key_asymmetric_create( struct key **ret_key, struct algorithm *alg, ULONG bitlen, + const UCHAR *pubkey, ULONG pubkey_len ) +{ + struct key *key; + NTSTATUS status; + + if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY; + key->hdr.magic = MAGIC_KEY; + + if ((status = key_asymmetric_init( key, alg, bitlen, pubkey, pubkey_len ))) + { + heap_free( key ); + return status; + } + *ret_key = key; + return STATUS_SUCCESS; +} + #if defined(HAVE_GNUTLS_CIPHER_INIT) || defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 BOOL key_is_symmetric( struct key *key ) { @@ -1175,18 +1193,8 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP if (ecc_blob->cbKey != key_size || input_len < sizeof(*ecc_blob) + ecc_blob->cbKey * 2) return STATUS_INVALID_PARAMETER; - if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY; - key->hdr.magic = MAGIC_KEY; - size = sizeof(*ecc_blob) + ecc_blob->cbKey * 2; - if ((status = key_asymmetric_init( key, alg, key_size * 8, (BYTE *)ecc_blob, size ))) - { - heap_free( key ); - return status; - } - - *ret_key = key; - return STATUS_SUCCESS; + return key_asymmetric_create( (struct key **)ret_key, alg, key_size * 8, (BYTE *)ecc_blob, size ); } else if (!strcmpW( type, BCRYPT_ECCPRIVATE_BLOB )) { @@ -1215,17 +1223,10 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP if (ecc_blob->cbKey != key_size || input_len < sizeof(*ecc_blob) + ecc_blob->cbKey * 3) return STATUS_INVALID_PARAMETER; - if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY; - key->hdr.magic = MAGIC_KEY; - - if ((status = key_asymmetric_init( key, alg, key_size * 8, NULL, 0 ))) - { - heap_free( key ); - return status; - } + if ((status = key_asymmetric_create( &key, alg, key_size * 8, NULL, 0 ))) return status; if ((status = key_import_ecc( key, input, input_len ))) { - heap_free( key ); + BCryptDestroyKey( key ); return status; } @@ -1241,18 +1242,8 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP if ((alg->id != ALG_ID_RSA && alg->id != ALG_ID_RSA_SIGN) || rsa_blob->Magic != BCRYPT_RSAPUBLIC_MAGIC) return STATUS_NOT_SUPPORTED; - if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY; - key->hdr.magic = MAGIC_KEY; - size = sizeof(*rsa_blob) + rsa_blob->cbPublicExp + rsa_blob->cbModulus; - if ((status = key_asymmetric_init( key, alg, rsa_blob->BitLength, (BYTE *)rsa_blob, size ))) - { - heap_free( key ); - return status; - } - - *ret_key = key; - return STATUS_SUCCESS; + return key_asymmetric_create( (struct key **)ret_key, alg, rsa_blob->BitLength, (BYTE *)rsa_blob, size ); } else if (!strcmpW( type, BCRYPT_DSA_PUBLIC_BLOB )) { @@ -1263,18 +1254,8 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP if ((alg->id != ALG_ID_DSA) || dsa_blob->dwMagic != BCRYPT_DSA_PUBLIC_MAGIC) return STATUS_NOT_SUPPORTED; - if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY; - key->hdr.magic = MAGIC_KEY; - size = sizeof(*dsa_blob) + dsa_blob->cbKey * 3; - if ((status = key_asymmetric_init( key, alg, dsa_blob->cbKey * 8, (BYTE *)dsa_blob, size ))) - { - heap_free( key ); - return status; - } - - *ret_key = key; - return STATUS_SUCCESS; + return key_asymmetric_create( (struct key **)ret_key, alg, dsa_blob->cbKey * 8, (BYTE *)dsa_blob, size ); } else if (!strcmpW( type, LEGACY_DSA_V2_PRIVATE_BLOB )) { @@ -1301,17 +1282,10 @@ static NTSTATUS key_import_pair( struct algorithm *alg, const WCHAR *type, BCRYP if (input_len < sizeof(*hdr) + sizeof(*pubkey) + (pubkey->bitlen / 8) * 2 + 40 + sizeof(DSSSEED)) return STATUS_INVALID_PARAMETER; - if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY; - key->hdr.magic = MAGIC_KEY; - - if ((status = key_asymmetric_init( key, alg, pubkey->bitlen, NULL, 0 ))) - { - heap_free( key ); - return status; - } + if ((status = key_asymmetric_create( &key, alg, pubkey->bitlen, NULL, 0 ))) return status; if ((status = key_import_dsa_capi( key, input, input_len ))) { - heap_free( key ); + BCryptDestroyKey( key ); return status; } @@ -1465,17 +1439,8 @@ NTSTATUS WINAPI BCryptGenerateKeyPair( BCRYPT_ALG_HANDLE algorithm, BCRYPT_KEY_H if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE; if (!handle) return STATUS_INVALID_PARAMETER; - if (!(key = heap_alloc_zero( sizeof(*key) ))) return STATUS_NO_MEMORY; - key->hdr.magic = MAGIC_KEY; - - if ((status = key_asymmetric_init( key, alg, key_len, NULL, 0 ))) - { - heap_free( key ); - return status; - } - - *handle = key; - return STATUS_SUCCESS; + if (!(status = key_asymmetric_create( &key, alg, key_len, NULL, 0 ))) *handle = key; + return status; } NTSTATUS WINAPI BCryptFinalizeKeyPair( BCRYPT_KEY_HANDLE handle, ULONG flags )
1
0
0
0
Francois Gouget : d3dcompiler_43/tests: Fix the spelling of a couple of ok() messages.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: 65013aae294e888a127df1977e20c10babecdbe2 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=65013aae294e888a127df197…
Author: Francois Gouget <fgouget(a)free.fr> Date: Mon Sep 21 18:35:54 2020 +0200 d3dcompiler_43/tests: Fix the spelling of a couple of ok() messages. Signed-off-by: Francois Gouget <fgouget(a)free.fr> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3dcompiler_43/tests/reflection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/d3dcompiler_43/tests/reflection.c b/dlls/d3dcompiler_43/tests/reflection.c index 0f660aab62..362e070ede 100644 --- a/dlls/d3dcompiler_43/tests/reflection.c +++ b/dlls/d3dcompiler_43/tests/reflection.c @@ -1245,7 +1245,7 @@ static void test_reflection_bound_resources(const DWORD *blob, const D3D12_SHADE #endif ok(desc11.uFlags == expected, "Got unexpected uFlags %#x, i %u.\n", desc11.uFlags, i); ok(desc11.ReturnType == pdesc->ReturnType, "Got unexpected ReturnType %#x, i %u.\n", desc11.ReturnType, i); - ok(desc11.Dimension == pdesc->Dimension, "Got unexpected Dimenstion %#x, i %u.\n", desc11.Dimension, i); + ok(desc11.Dimension == pdesc->Dimension, "Got unexpected Dimension %#x, i %u.\n", desc11.Dimension, i); ok(desc11.NumSamples == pdesc->NumSamples, "Got unexpected NumSamples %u, i %u.\n", desc11.NumSamples, i); if (ref12) @@ -1309,7 +1309,7 @@ static void test_reflection_bound_resources(const DWORD *blob, const D3D12_SHADE ok(desc11.BindCount == pdesc->BindCount, "Got unexpected BindCount failed %u, i %u.\n", desc11.BindCount, i); ok(desc11.uFlags == pdesc->uFlags, "Got unexpected uFlags %#x, i %u.\n", desc11.uFlags, i); ok(desc11.ReturnType == pdesc->ReturnType, "Got unexpected ReturnType %#x, i %u.\n", desc11.ReturnType, i); - ok(desc11.Dimension == pdesc->Dimension, "Got unexpected Dimenstion %#x, i %u.\n", desc11.Dimension, i); + ok(desc11.Dimension == pdesc->Dimension, "Got unexpected Dimension %#x, i %u.\n", desc11.Dimension, i); ok(desc11.NumSamples == pdesc->NumSamples, "Got unexpected NumSamples %u, i %u.\n", desc11.NumSamples, i); if (ref12)
1
0
0
0
Akihiro Sagawa : kernelbase: Improve Get{, Dynamic}TimeZoneInformation() performance.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: d5edadf35a40cb7238c2068db28b6c6abc7da800 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d5edadf35a40cb7238c2068d…
Author: Akihiro Sagawa <sagawa.aki(a)gmail.com> Date: Fri Sep 25 00:07:50 2020 +0900 kernelbase: Improve Get{, Dynamic}TimeZoneInformation() performance. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=49808
Signed-off-by: Akihiro Sagawa <sagawa.aki(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/locale.c | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index 4e7bd9937b..83dd76e3c0 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -4122,6 +4122,20 @@ INT WINAPI DECLSPEC_HOTPATCH GetCalendarInfoEx( const WCHAR *locale, CALID calen return GetCalendarInfoW( lcid, calendar, type, data, count, value ); } +static CRITICAL_SECTION tzname_section; +static CRITICAL_SECTION_DEBUG tzname_section_debug = +{ + 0, 0, &locale_section, + { &tzname_section_debug.ProcessLocksList, &tzname_section_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": tzname_section") } +}; +static CRITICAL_SECTION tzname_section = { &tzname_section_debug, -1, 0, 0, 0, 0 }; +static struct { + LCID lcid; + WCHAR key_name[128]; + WCHAR standard_name[32]; + WCHAR daylight_name[32]; +} cached_tzname; /*********************************************************************** * GetDynamicTimeZoneInformation (kernelbase.@) @@ -4134,15 +4148,34 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetDynamicTimeZoneInformation( DYNAMIC_TIME_ZONE_ if (!set_ntstatus( RtlQueryDynamicTimeZoneInformation( (RTL_DYNAMIC_TIME_ZONE_INFORMATION *)info ))) return TIME_ZONE_ID_INVALID; - if (!RegOpenKeyExW( tz_key, info->TimeZoneKeyName, 0, KEY_ALL_ACCESS, &key )) + RtlEnterCriticalSection( &tzname_section ); + if (cached_tzname.lcid == GetThreadLocale() && + !wcscmp( info->TimeZoneKeyName, cached_tzname.key_name )) + { + wcscpy( info->StandardName, cached_tzname.standard_name ); + wcscpy( info->DaylightName, cached_tzname.daylight_name ); + RtlLeaveCriticalSection( &tzname_section ); + } + else { - RegLoadMUIStringW( key, L"MUI_Std", info->StandardName, - sizeof(info->StandardName), NULL, 0, system_dir ); - RegLoadMUIStringW( key, L"MUI_Dlt", info->DaylightName, - sizeof(info->DaylightName), NULL, 0, system_dir ); - RegCloseKey( key ); + RtlLeaveCriticalSection( &tzname_section ); + if (!RegOpenKeyExW( tz_key, info->TimeZoneKeyName, 0, KEY_ALL_ACCESS, &key )) + { + RegLoadMUIStringW( key, L"MUI_Std", info->StandardName, + sizeof(info->StandardName), NULL, 0, system_dir ); + RegLoadMUIStringW( key, L"MUI_Dlt", info->DaylightName, + sizeof(info->DaylightName), NULL, 0, system_dir ); + RegCloseKey( key ); + } + else return TIME_ZONE_ID_INVALID; + + RtlEnterCriticalSection( &tzname_section ); + cached_tzname.lcid = GetThreadLocale(); + wcscpy( cached_tzname.key_name, info->TimeZoneKeyName ); + wcscpy( cached_tzname.standard_name, info->StandardName ); + wcscpy( cached_tzname.daylight_name, info->DaylightName ); + RtlLeaveCriticalSection( &tzname_section ); } - else return TIME_ZONE_ID_INVALID; NtQuerySystemTime( &now ); return get_timezone_id( (TIME_ZONE_INFORMATION *)info, now, FALSE );
1
0
0
0
Zebediah Figura : netprofm: Do not use the WS_ prefix.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: d6da10f3fb97f412ccb1ea4a806b13be3a0475e2 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d6da10f3fb97f412ccb1ea4a…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Mon Sep 28 22:46:42 2020 -0500 netprofm: Do not use the WS_ prefix. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/netprofm/list.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dlls/netprofm/list.c b/dlls/netprofm/list.c index 93e9d14308..def2aa6cf6 100644 --- a/dlls/netprofm/list.c +++ b/dlls/netprofm/list.c @@ -24,7 +24,6 @@ #include <stdarg.h> #include "windef.h" #include "winbase.h" -#define USE_WS_PREFIX #include "winsock2.h" #include "ws2ipdef.h" #include "iphlpapi.h" @@ -582,14 +581,14 @@ static BOOL map_address_6to4( const SOCKADDR_IN6 *addr6, SOCKADDR_IN *addr4 ) { ULONG i; - if (addr6->sin6_family != WS_AF_INET6) return FALSE; + if (addr6->sin6_family != AF_INET6) return FALSE; for (i = 0; i < 5; i++) if (addr6->sin6_addr.u.Word[i]) return FALSE; if (addr6->sin6_addr.u.Word[5] != 0xffff) return FALSE; - addr4->sin_family = WS_AF_INET; + addr4->sin_family = AF_INET; addr4->sin_port = addr6->sin6_port; addr4->sin_addr.S_un.S_addr = addr6->sin6_addr.u.Word[6] << 16 | addr6->sin6_addr.u.Word[7]; memset( &addr4->sin_zero, 0, sizeof(addr4->sin_zero) ); @@ -610,8 +609,8 @@ static HRESULT WINAPI cost_manager_GetDataPlanStatus( if (!pDataPlanStatus) return E_POINTER; - if (dst && ((dst->sa_family == WS_AF_INET && (dst4 = (SOCKADDR_IN *)dst)) || - ((dst->sa_family == WS_AF_INET6 && map_address_6to4( (const SOCKADDR_IN6 *)dst, &addr4 ) + if (dst && ((dst->sa_family == AF_INET && (dst4 = (SOCKADDR_IN *)dst)) || + ((dst->sa_family == AF_INET6 && map_address_6to4( (const SOCKADDR_IN6 *)dst, &addr4 ) && (dst4 = &addr4))))) { if ((ret = GetBestInterface( dst4->sin_addr.S_un.S_addr, &index ))) @@ -1718,11 +1717,11 @@ static void init_networks( struct list_manager *mgr ) list_init( &mgr->networks ); list_init( &mgr->connections ); - ret = GetAdaptersAddresses( WS_AF_UNSPEC, flags, NULL, NULL, &size ); + ret = GetAdaptersAddresses( AF_UNSPEC, flags, NULL, NULL, &size ); if (ret != ERROR_BUFFER_OVERFLOW) return; if (!(buf = heap_alloc( size ))) return; - if (GetAdaptersAddresses( WS_AF_UNSPEC, flags, NULL, buf, &size )) + if (GetAdaptersAddresses( AF_UNSPEC, flags, NULL, buf, &size )) { heap_free( buf ); return;
1
0
0
0
Zebediah Figura : ws2_32: Reimplement ws_protocol_info() using the supported_protocols array.
by Alexandre Julliard
29 Sep '20
29 Sep '20
Module: wine Branch: master Commit: 0c2f556afe7b5fcc873c737512fae5b9c8c07624 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0c2f556afe7b5fcc873c7375…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Mon Sep 28 22:35:05 2020 -0500 ws2_32: Reimplement ws_protocol_info() using the supported_protocols array. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ws2_32/socket.c | 183 +++++++-------------------------------------------- 1 file changed, 23 insertions(+), 160 deletions(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 2ba74cdb19..36215cc6ef 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -185,21 +185,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(winsock); WINE_DECLARE_DEBUG_CHANNEL(winediag); -/* names of the protocols */ -static const WCHAR NameIpxW[] = {'I', 'P', 'X', '\0'}; -static const WCHAR NameSpxW[] = {'S', 'P', 'X', '\0'}; -static const WCHAR NameSpxIIW[] = {'S', 'P', 'X', ' ', 'I', 'I', '\0'}; -static const WCHAR NameTcpW[] = {'T', 'C', 'P', '/', 'I', 'P', '\0'}; -static const WCHAR NameUdpW[] = {'U', 'D', 'P', '/', 'I', 'P', '\0'}; - -/* Taken from Win2k */ -static const GUID ProviderIdIP = { 0xe70f1aa0, 0xab8b, 0x11cf, - { 0x8c, 0xa3, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 } }; -static const GUID ProviderIdIPX = { 0x11058240, 0xbe47, 0x11cf, - { 0x95, 0xc8, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 } }; -static const GUID ProviderIdSPX = { 0x11058241, 0xbe47, 0x11cf, - { 0x95, 0xc8, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 } }; - static const WSAPROTOCOL_INFOW supported_protocols[] = { { @@ -2304,149 +2289,13 @@ static INT WS_DuplicateSocket(BOOL unicode, SOCKET s, DWORD dwProcessId, LPWSAPR return 0; } -/***************************************************************************** - * WS_EnterSingleProtocolW [internal] - * - * enters the protocol information of one given protocol into the given - * buffer. - * - * RETURNS - * TRUE if a protocol was entered into the buffer. - * - * BUGS - * - only implemented for IPX, SPX, SPXII, TCP, UDP - * - there is no check that the operating system supports the returned - * protocols - */ -static BOOL WS_EnterSingleProtocolW( INT protocol, WSAPROTOCOL_INFOW* info ) -{ - memset( info, 0, sizeof(WSAPROTOCOL_INFOW) ); - info->iProtocol = protocol; - - switch (protocol) - { - case WS_IPPROTO_TCP: - info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_EXPEDITED_DATA | - XP1_GRACEFUL_CLOSE | XP1_GUARANTEED_ORDER | - XP1_GUARANTEED_DELIVERY; - info->ProviderId = ProviderIdIP; - info->dwCatalogEntryId = 0x3e9; - info->dwProviderFlags = PFL_MATCHES_PROTOCOL_ZERO; - info->ProtocolChain.ChainLen = 1; - info->iVersion = 2; - info->iAddressFamily = WS_AF_INET; - info->iMaxSockAddr = 0x10; - info->iMinSockAddr = 0x10; - info->iSocketType = WS_SOCK_STREAM; - strcpyW( info->szProtocol, NameTcpW ); - break; - - case WS_IPPROTO_UDP: - info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_SUPPORT_BROADCAST | - XP1_SUPPORT_MULTIPOINT | XP1_MESSAGE_ORIENTED | - XP1_CONNECTIONLESS; - info->ProviderId = ProviderIdIP; - info->dwCatalogEntryId = 0x3ea; - info->dwProviderFlags = PFL_MATCHES_PROTOCOL_ZERO; - info->ProtocolChain.ChainLen = 1; - info->iVersion = 2; - info->iAddressFamily = WS_AF_INET; - info->iMaxSockAddr = 0x10; - info->iMinSockAddr = 0x10; - info->iSocketType = WS_SOCK_DGRAM; - info->dwMessageSize = 0xffbb; - strcpyW( info->szProtocol, NameUdpW ); - break; - - case WS_NSPROTO_IPX: - info->dwServiceFlags1 = XP1_PARTIAL_MESSAGE | XP1_SUPPORT_BROADCAST | - XP1_SUPPORT_MULTIPOINT | XP1_MESSAGE_ORIENTED | - XP1_CONNECTIONLESS; - info->ProviderId = ProviderIdIPX; - info->dwCatalogEntryId = 0x406; - info->dwProviderFlags = PFL_MATCHES_PROTOCOL_ZERO; - info->ProtocolChain.ChainLen = 1; - info->iVersion = 2; - info->iAddressFamily = WS_AF_IPX; - info->iMaxSockAddr = 0x10; - info->iMinSockAddr = 0x0e; - info->iSocketType = WS_SOCK_DGRAM; - info->iProtocolMaxOffset = 0xff; - info->dwMessageSize = 0x240; - strcpyW( info->szProtocol, NameIpxW ); - break; - - case WS_NSPROTO_SPX: - info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_PSEUDO_STREAM | - XP1_MESSAGE_ORIENTED | XP1_GUARANTEED_ORDER | - XP1_GUARANTEED_DELIVERY; - info->ProviderId = ProviderIdSPX; - info->dwCatalogEntryId = 0x407; - info->dwProviderFlags = PFL_MATCHES_PROTOCOL_ZERO; - info->ProtocolChain.ChainLen = 1; - info->iVersion = 2; - info->iAddressFamily = WS_AF_IPX; - info->iMaxSockAddr = 0x10; - info->iMinSockAddr = 0x0e; - info->iSocketType = WS_SOCK_SEQPACKET; - info->dwMessageSize = 0xffffffff; - strcpyW( info->szProtocol, NameSpxW ); - break; - - case WS_NSPROTO_SPXII: - info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_GRACEFUL_CLOSE | - XP1_PSEUDO_STREAM | XP1_MESSAGE_ORIENTED | - XP1_GUARANTEED_ORDER | XP1_GUARANTEED_DELIVERY; - info->ProviderId = ProviderIdSPX; - info->dwCatalogEntryId = 0x409; - info->dwProviderFlags = PFL_MATCHES_PROTOCOL_ZERO; - info->ProtocolChain.ChainLen = 1; - info->iVersion = 2; - info->iAddressFamily = WS_AF_IPX; - info->iMaxSockAddr = 0x10; - info->iMinSockAddr = 0x0e; - info->iSocketType = WS_SOCK_SEQPACKET; - info->dwMessageSize = 0xffffffff; - strcpyW( info->szProtocol, NameSpxIIW ); - break; - - default: - FIXME("unknown Protocol <0x%08x>\n", protocol); - return FALSE; - } - return TRUE; -} - -/***************************************************************************** - * WS_EnterSingleProtocolA [internal] - * - * see function WS_EnterSingleProtocolW - * - */ -static BOOL WS_EnterSingleProtocolA( INT protocol, WSAPROTOCOL_INFOA* info ) -{ - WSAPROTOCOL_INFOW infow; - INT ret; - memset( info, 0, sizeof(WSAPROTOCOL_INFOA) ); - - ret = WS_EnterSingleProtocolW( protocol, &infow ); - if (ret) - { - /* convert the structure from W to A */ - memcpy( info, &infow, FIELD_OFFSET( WSAPROTOCOL_INFOA, szProtocol ) ); - WideCharToMultiByte( CP_ACP, 0, infow.szProtocol, -1, - info->szProtocol, WSAPROTOCOL_LEN+1, NULL, NULL ); - } - - return ret; -} - static BOOL ws_protocol_info(SOCKET s, int unicode, WSAPROTOCOL_INFOW *buffer, int *size) { NTSTATUS status; int address_family; int socket_type; int protocol; + unsigned int i; *size = unicode ? sizeof(WSAPROTOCOL_INFOW) : sizeof(WSAPROTOCOL_INFOA); memset(buffer, 0, *size); @@ -2471,14 +2320,28 @@ static BOOL ws_protocol_info(SOCKET s, int unicode, WSAPROTOCOL_INFOW *buffer, i return FALSE; } - if (unicode) - WS_EnterSingleProtocolW( protocol, buffer); - else - WS_EnterSingleProtocolA( protocol, (WSAPROTOCOL_INFOA *)buffer); - buffer->iAddressFamily = address_family; - buffer->iSocketType = socket_type; - buffer->iProtocol = protocol; - + for (i = 0; i < ARRAY_SIZE(supported_protocols); ++i) + { + const WSAPROTOCOL_INFOW *info = &supported_protocols[i]; + if (address_family == info->iAddressFamily && + socket_type == info->iSocketType && + protocol >= info->iProtocol && protocol <= info->iProtocol + info->iProtocolMaxOffset) + { + if (unicode) + *buffer = *info; + else + { + WSAPROTOCOL_INFOA *bufferA = (WSAPROTOCOL_INFOA *)buffer; + memcpy( bufferA, info, offsetof( WSAPROTOCOL_INFOW, szProtocol ) ); + WideCharToMultiByte( CP_ACP, 0, info->szProtocol, -1, + bufferA->szProtocol, sizeof(bufferA->szProtocol), NULL, NULL ); + } + buffer->iProtocol = protocol; + return TRUE; + } + } + FIXME("Could not fill protocol information for family %d, type %d, protocol %d.\n", + address_family, socket_type, protocol); return TRUE; }
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
71
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Results per page:
10
25
50
100
200