Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
65b90ab3
Commit
65b90ab3
authored
Aug 08, 2023
by
Piotr Caban
Committed by
Alexandre Julliard
Aug 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Add BCRYPT_KEY_STRENGTH key property implementation.
parent
a632ac55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+13
-1
bcrypt.c
dlls/bcrypt/tests/bcrypt.c
+25
-0
No files found.
dlls/bcrypt/bcrypt_main.c
View file @
65b90ab3
...
...
@@ -122,7 +122,7 @@ builtin_algorithms[] =
{
BCRYPT_RNG_ALGORITHM
,
BCRYPT_RNG_INTERFACE
,
0
,
0
,
0
},
};
static
inline
BOOL
is_symmetric_key
(
struct
key
*
key
)
static
inline
BOOL
is_symmetric_key
(
const
struct
key
*
key
)
{
return
builtin_algorithms
[
key
->
alg_id
].
class
==
BCRYPT_CIPHER_INTERFACE
;
}
...
...
@@ -902,6 +902,18 @@ static NTSTATUS get_hash_property( const struct hash *hash, const WCHAR *prop, U
static
NTSTATUS
get_key_property
(
const
struct
key
*
key
,
const
WCHAR
*
prop
,
UCHAR
*
buf
,
ULONG
size
,
ULONG
*
ret_size
)
{
if
(
!
wcscmp
(
prop
,
BCRYPT_KEY_STRENGTH
))
{
*
ret_size
=
sizeof
(
DWORD
);
if
(
size
<
sizeof
(
DWORD
))
return
STATUS_BUFFER_TOO_SMALL
;
if
(
buf
)
{
if
(
is_symmetric_key
(
key
))
*
(
DWORD
*
)
buf
=
key
->
u
.
s
.
block_size
*
8
;
else
*
(
DWORD
*
)
buf
=
key
->
u
.
a
.
bitlen
;
}
return
STATUS_SUCCESS
;
}
switch
(
key
->
alg_id
)
{
case
ALG_ID_3DES
:
...
...
dlls/bcrypt/tests/bcrypt.c
View file @
65b90ab3
...
...
@@ -781,6 +781,12 @@ static void test_BCryptGenerateSymmetricKey(void)
ok
(
ret
==
STATUS_SUCCESS
,
"got %#lx
\n
"
,
ret
);
ok
(
key
!=
NULL
,
"key not set
\n
"
);
keylen
=
0
;
ret
=
BCryptGetProperty
(
key
,
BCRYPT_KEY_STRENGTH
,
(
UCHAR
*
)
&
keylen
,
sizeof
(
keylen
),
&
size
,
0
);
ok
(
!
ret
,
"got %#lx
\n
"
,
ret
);
ok
(
size
==
sizeof
(
keylen
),
"got %lu
\n
"
,
size
);
ok
(
keylen
==
128
,
"got %lu
\n
"
,
keylen
);
ret
=
BCryptSetProperty
(
aes
,
BCRYPT_CHAINING_MODE
,
(
UCHAR
*
)
BCRYPT_CHAIN_MODE_CBC
,
sizeof
(
BCRYPT_CHAIN_MODE_CBC
),
0
);
ok
(
ret
==
STATUS_SUCCESS
,
"got %#lx
\n
"
,
ret
);
...
...
@@ -2176,6 +2182,7 @@ static void test_ECDSA(void)
BCRYPT_ALG_HANDLE
alg
;
BCRYPT_KEY_HANDLE
key
;
NTSTATUS
status
;
DWORD
keylen
;
ULONG
size
;
status
=
BCryptOpenAlgorithmProvider
(
&
alg
,
BCRYPT_ECDSA_P256_ALGORITHM
,
NULL
,
0
);
...
...
@@ -2211,6 +2218,12 @@ static void test_ECDSA(void)
status
=
BCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
&
key
,
buffer
,
size
,
0
);
ok
(
!
status
,
"BCryptImportKeyPair failed: %#lx
\n
"
,
status
);
keylen
=
0
;
status
=
BCryptGetProperty
(
key
,
BCRYPT_KEY_STRENGTH
,
(
UCHAR
*
)
&
keylen
,
sizeof
(
keylen
),
&
size
,
0
);
ok
(
!
status
,
"got %#lx
\n
"
,
status
);
ok
(
size
==
sizeof
(
keylen
),
"got %lu
\n
"
,
size
);
ok
(
keylen
==
256
,
"got %lu
\n
"
,
keylen
);
memset
(
buffer
,
0xcc
,
sizeof
(
buffer
));
status
=
BCryptExportKey
(
key
,
NULL
,
BCRYPT_ECCPUBLIC_BLOB
,
buffer
,
sizeof
(
buffer
),
&
size
,
0
);
ok
(
!
status
,
"Got unexpected status %#lx
\n
"
,
status
);
...
...
@@ -2542,6 +2555,12 @@ static void test_RSA(void)
ret
=
BCryptImportKeyPair
(
alg
,
NULL
,
BCRYPT_RSAPUBLIC_BLOB
,
&
key
,
rsaPublicBlob
,
sizeof
(
rsaPublicBlob
),
0
);
ok
(
!
ret
,
"BCryptImportKeyPair failed: %#lx
\n
"
,
ret
);
keylen
=
0
;
ret
=
BCryptGetProperty
(
key
,
BCRYPT_KEY_STRENGTH
,
(
UCHAR
*
)
&
keylen
,
sizeof
(
keylen
),
&
size
,
0
);
ok
(
!
ret
,
"got %#lx
\n
"
,
ret
);
ok
(
size
==
sizeof
(
keylen
),
"got %lu
\n
"
,
size
);
ok
(
keylen
==
2048
,
"got %lu
\n
"
,
keylen
);
pad
.
pszAlgId
=
BCRYPT_SHA1_ALGORITHM
;
ret
=
BCryptVerifySignature
(
key
,
&
pad
,
rsaHash
,
sizeof
(
rsaHash
),
rsaSignature
,
sizeof
(
rsaSignature
),
BCRYPT_PAD_PKCS1
);
ok
(
!
ret
,
"BCryptVerifySignature failed: %#lx
\n
"
,
ret
);
...
...
@@ -2580,6 +2599,12 @@ static void test_RSA(void)
ret
=
BCryptFinalizeKeyPair
(
key
,
0
);
ok
(
ret
==
STATUS_SUCCESS
,
"got %#lx
\n
"
,
ret
);
keylen
=
0
;
ret
=
BCryptGetProperty
(
key
,
BCRYPT_KEY_STRENGTH
,
(
UCHAR
*
)
&
keylen
,
sizeof
(
keylen
),
&
size
,
0
);
ok
(
!
ret
,
"got %#lx
\n
"
,
ret
);
ok
(
size
==
sizeof
(
keylen
),
"got %lu
\n
"
,
size
);
ok
(
keylen
==
2048
,
"got %lu
\n
"
,
keylen
);
ret
=
BCryptSetProperty
(
key
,
BCRYPT_KEY_LENGTH
,
(
UCHAR
*
)
&
keylen
,
sizeof
(
keylen
),
0
);
ok
(
ret
==
STATUS_SUCCESS
,
"got %#lx
\n
"
,
ret
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment