Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47432 Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/bcrypt/bcrypt_main.c | 8 ++++---- dlls/bcrypt/gnutls.c | 8 ++++---- dlls/bcrypt/macos.c | 6 +++--- dlls/bcrypt/tests/bcrypt.c | 21 ++++++++++++++++++++- 4 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c index 3846341644..79660c1cf1 100644 --- a/dlls/bcrypt/bcrypt_main.c +++ b/dlls/bcrypt/bcrypt_main.c @@ -518,24 +518,24 @@ static NTSTATUS set_alg_property( struct algorithm *alg, const WCHAR *prop, UCHA case ALG_ID_AES: if (!strcmpW( prop, BCRYPT_CHAINING_MODE )) { - if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_ECB, size )) + if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_ECB )) { alg->mode = MODE_ID_ECB; return STATUS_SUCCESS; } - else if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC, size )) + else if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC )) { alg->mode = MODE_ID_CBC; return STATUS_SUCCESS; } - else if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_GCM, size )) + else if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_GCM )) { alg->mode = MODE_ID_GCM; return STATUS_SUCCESS; } else { - FIXME( "unsupported mode %s\n", debugstr_wn( (WCHAR *)value, size ) ); + FIXME( "unsupported mode %s\n", debugstr_w((WCHAR *)value) ); return STATUS_NOT_IMPLEMENTED; } } diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c index 2a7e37ef8a..583a0e47e6 100644 --- a/dlls/bcrypt/gnutls.c +++ b/dlls/bcrypt/gnutls.c @@ -369,24 +369,24 @@ NTSTATUS key_set_property( struct key *key, const WCHAR *prop, UCHAR *value, ULO { if (!strcmpW( prop, BCRYPT_CHAINING_MODE )) { - if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_ECB, size )) + if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_ECB )) { key->u.s.mode = MODE_ID_ECB; return STATUS_SUCCESS; } - else if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC, size )) + else if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC )) { key->u.s.mode = MODE_ID_CBC; return STATUS_SUCCESS; } - else if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_GCM, size )) + else if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_GCM )) { key->u.s.mode = MODE_ID_GCM; return STATUS_SUCCESS; } else { - FIXME( "unsupported mode %s\n", debugstr_wn( (WCHAR *)value, size ) ); + FIXME( "unsupported mode %s\n", debugstr_w((WCHAR *)value) ); return STATUS_NOT_IMPLEMENTED; } } diff --git a/dlls/bcrypt/macos.c b/dlls/bcrypt/macos.c index cc99637c4b..df79f3e80d 100644 --- a/dlls/bcrypt/macos.c +++ b/dlls/bcrypt/macos.c @@ -48,19 +48,19 @@ NTSTATUS key_set_property( struct key *key, const WCHAR *prop, UCHAR *value, ULO { if (!strcmpW( prop, BCRYPT_CHAINING_MODE )) { - if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_ECB, size )) + if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_ECB )) { key->u.s.mode = MODE_ID_ECB; return STATUS_SUCCESS; } - else if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC, size )) + else if (!strcmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC )) { key->u.s.mode = MODE_ID_CBC; return STATUS_SUCCESS; } else { - FIXME( "unsupported mode %s\n", debugstr_wn( (WCHAR *)value, size ) ); + FIXME( "unsupported mode %s\n", debugstr_w((WCHAR *)value) ); return STATUS_NOT_IMPLEMENTED; } } diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c index 11e274bc5f..b8678a520d 100644 --- a/dlls/bcrypt/tests/bcrypt.c +++ b/dlls/bcrypt/tests/bcrypt.c @@ -639,7 +639,7 @@ static void test_aes(void) ok(key_lengths.dwIncrement == 64, "Expected 64, got %d\n", key_lengths.dwIncrement);
memcpy(mode, BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM)); - ret = pBCryptSetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode), 0); + ret = pBCryptSetProperty(alg, BCRYPT_CHAINING_MODE, mode, 0, 0); ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
size = 0; @@ -694,6 +694,25 @@ static void test_BCryptGenerateSymmetricKey(void) sizeof(BCRYPT_CHAIN_MODE_CBC), 0); ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ size = 0; + memset(mode, 0, sizeof(mode)); + ret = pBCryptGetProperty(key, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_CBC), "got %s\n", wine_dbgstr_w((const WCHAR *)mode)); + ok(size == 64, "got %u\n", size); + + ret = pBCryptSetProperty(key, BCRYPT_CHAINING_MODE, (UCHAR *)BCRYPT_CHAIN_MODE_ECB, 0, 0); + ok(ret == STATUS_SUCCESS || broken(ret == STATUS_NOT_SUPPORTED) /* < Win 8 */, "got %08x\n", ret); + if (ret == STATUS_SUCCESS) + { + size = 0; + memset(mode, 0, sizeof(mode)); + ret = pBCryptGetProperty(key, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0); + ok(ret == STATUS_SUCCESS, "got %08x\n", ret); + ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_ECB), "got %s\n", wine_dbgstr_w((const WCHAR *)mode)); + ok(size == 64, "got %u\n", size); + } + ret = pBCryptSetProperty(key, BCRYPT_CHAINING_MODE, (UCHAR *)BCRYPT_CHAIN_MODE_CBC, sizeof(BCRYPT_CHAIN_MODE_CBC), 0); ok(ret == STATUS_SUCCESS || broken(ret == STATUS_NOT_SUPPORTED) /* < Win 8 */, "got %08x\n", ret);