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
ec85dfe3
Commit
ec85dfe3
authored
Sep 12, 2022
by
Hans Leidekker
Committed by
Alexandre Julliard
Sep 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Rename mode_id to chain_mode.
parent
6f5028dd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
63 deletions
+63
-63
bcrypt_internal.h
dlls/bcrypt/bcrypt_internal.h
+16
-16
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+35
-35
gnutls.c
dlls/bcrypt/gnutls.c
+12
-12
No files found.
dlls/bcrypt/bcrypt_internal.h
View file @
ec85dfe3
...
...
@@ -144,31 +144,31 @@ enum alg_id
ALG_ID_RNG
,
};
enum
mode_id
enum
chain_mode
{
MODE_ID
_CBC
,
MODE_ID
_ECB
,
MODE_ID
_CFB
,
MODE_ID
_CCM
,
MODE_ID
_GCM
,
CHAIN_MODE
_CBC
,
CHAIN_MODE
_ECB
,
CHAIN_MODE
_CFB
,
CHAIN_MODE
_CCM
,
CHAIN_MODE
_GCM
,
};
struct
algorithm
{
struct
object
hdr
;
enum
alg_id
id
;
enum
mode_id
mode
;
unsigned
flags
;
struct
object
hdr
;
enum
alg_id
id
;
enum
chain_mode
mode
;
unsigned
flags
;
};
struct
key_symmetric
{
enum
mode_id
mode
;
ULONG
block_size
;
UCHAR
*
vector
;
ULONG
vector_len
;
UCHAR
*
secret
;
unsigned
secret_len
;
enum
chain_mode
mode
;
ULONG
block_size
;
UCHAR
*
vector
;
ULONG
vector_len
;
UCHAR
*
secret
;
unsigned
secret_len
;
CRITICAL_SECTION
cs
;
};
...
...
dlls/bcrypt/bcrypt_main.c
View file @
ec85dfe3
...
...
@@ -197,17 +197,17 @@ static const struct algorithm pseudo_algorithms[] =
{{
0
}},
/* AES_GMAC */
{{
MAGIC_ALG
},
ALG_ID_MD2
,
0
,
BCRYPT_ALG_HANDLE_HMAC_FLAG
},
{{
MAGIC_ALG
},
ALG_ID_MD4
,
0
,
BCRYPT_ALG_HANDLE_HMAC_FLAG
},
{{
MAGIC_ALG
},
ALG_ID_3DES
,
MODE_ID
_CBC
},
{{
MAGIC_ALG
},
ALG_ID_3DES
,
MODE_ID
_ECB
},
{{
MAGIC_ALG
},
ALG_ID_3DES
,
MODE_ID
_CFB
},
{{
MAGIC_ALG
},
ALG_ID_3DES
,
CHAIN_MODE
_CBC
},
{{
MAGIC_ALG
},
ALG_ID_3DES
,
CHAIN_MODE
_ECB
},
{{
MAGIC_ALG
},
ALG_ID_3DES
,
CHAIN_MODE
_CFB
},
{{
0
}},
/* 3DES_112_CBC */
{{
0
}},
/* 3DES_112_ECB */
{{
0
}},
/* 3DES_112_CFB */
{{
MAGIC_ALG
},
ALG_ID_AES
,
MODE_ID
_CBC
},
{{
MAGIC_ALG
},
ALG_ID_AES
,
MODE_ID
_ECB
},
{{
MAGIC_ALG
},
ALG_ID_AES
,
MODE_ID
_CFB
},
{{
MAGIC_ALG
},
ALG_ID_AES
,
MODE_ID
_CCM
},
{{
MAGIC_ALG
},
ALG_ID_AES
,
MODE_ID
_GCM
},
{{
MAGIC_ALG
},
ALG_ID_AES
,
CHAIN_MODE
_CBC
},
{{
MAGIC_ALG
},
ALG_ID_AES
,
CHAIN_MODE
_ECB
},
{{
MAGIC_ALG
},
ALG_ID_AES
,
CHAIN_MODE
_CFB
},
{{
MAGIC_ALG
},
ALG_ID_AES
,
CHAIN_MODE
_CCM
},
{{
MAGIC_ALG
},
ALG_ID_AES
,
CHAIN_MODE
_GCM
},
{{
0
}},
/* DES_CBC */
{{
0
}},
/* DES_ECB */
{{
0
}},
/* DES_CFB */
...
...
@@ -309,7 +309,7 @@ NTSTATUS WINAPI BCryptGenRandom( BCRYPT_ALG_HANDLE handle, UCHAR *buffer, ULONG
return
STATUS_NOT_IMPLEMENTED
;
}
static
struct
algorithm
*
create_algorithm
(
enum
alg_id
id
,
enum
mode_id
mode
,
DWORD
flags
)
static
struct
algorithm
*
create_algorithm
(
enum
alg_id
id
,
enum
chain_mode
mode
,
DWORD
flags
)
{
struct
algorithm
*
ret
;
if
(
!
(
ret
=
calloc
(
1
,
sizeof
(
*
ret
)
)))
return
NULL
;
...
...
@@ -577,7 +577,7 @@ static NTSTATUS generic_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *
return
STATUS_NOT_IMPLEMENTED
;
}
static
NTSTATUS
get_3des_property
(
enum
mode_id
mode
,
const
WCHAR
*
prop
,
UCHAR
*
buf
,
ULONG
size
,
ULONG
*
ret_size
)
static
NTSTATUS
get_3des_property
(
enum
chain_mode
mode
,
const
WCHAR
*
prop
,
UCHAR
*
buf
,
ULONG
size
,
ULONG
*
ret_size
)
{
if
(
!
wcscmp
(
prop
,
BCRYPT_BLOCK_LENGTH
))
{
...
...
@@ -591,7 +591,7 @@ static NTSTATUS get_3des_property( enum mode_id mode, const WCHAR *prop, UCHAR *
const
WCHAR
*
str
;
switch
(
mode
)
{
case
MODE_ID
_CBC
:
str
=
BCRYPT_CHAIN_MODE_CBC
;
break
;
case
CHAIN_MODE
_CBC
:
str
=
BCRYPT_CHAIN_MODE_CBC
;
break
;
default:
return
STATUS_NOT_IMPLEMENTED
;
}
...
...
@@ -617,7 +617,7 @@ static NTSTATUS get_3des_property( enum mode_id mode, const WCHAR *prop, UCHAR *
return
STATUS_NOT_IMPLEMENTED
;
}
static
NTSTATUS
get_aes_property
(
enum
mode_id
mode
,
const
WCHAR
*
prop
,
UCHAR
*
buf
,
ULONG
size
,
ULONG
*
ret_size
)
static
NTSTATUS
get_aes_property
(
enum
chain_mode
mode
,
const
WCHAR
*
prop
,
UCHAR
*
buf
,
ULONG
size
,
ULONG
*
ret_size
)
{
if
(
!
wcscmp
(
prop
,
BCRYPT_BLOCK_LENGTH
))
{
...
...
@@ -631,10 +631,10 @@ static NTSTATUS get_aes_property( enum mode_id mode, const WCHAR *prop, UCHAR *b
const
WCHAR
*
str
;
switch
(
mode
)
{
case
MODE_ID
_ECB
:
str
=
BCRYPT_CHAIN_MODE_ECB
;
break
;
case
MODE_ID
_CBC
:
str
=
BCRYPT_CHAIN_MODE_CBC
;
break
;
case
MODE_ID
_GCM
:
str
=
BCRYPT_CHAIN_MODE_GCM
;
break
;
case
MODE_ID
_CFB
:
str
=
BCRYPT_CHAIN_MODE_CFB
;
break
;
case
CHAIN_MODE
_ECB
:
str
=
BCRYPT_CHAIN_MODE_ECB
;
break
;
case
CHAIN_MODE
_CBC
:
str
=
BCRYPT_CHAIN_MODE_CBC
;
break
;
case
CHAIN_MODE
_GCM
:
str
=
BCRYPT_CHAIN_MODE_GCM
;
break
;
case
CHAIN_MODE
_CFB
:
str
=
BCRYPT_CHAIN_MODE_CFB
;
break
;
default:
return
STATUS_NOT_IMPLEMENTED
;
}
...
...
@@ -659,7 +659,7 @@ static NTSTATUS get_aes_property( enum mode_id mode, const WCHAR *prop, UCHAR *b
if
(
!
wcscmp
(
prop
,
BCRYPT_AUTH_TAG_LENGTH
))
{
BCRYPT_AUTH_TAG_LENGTHS_STRUCT
*
tag_length
=
(
void
*
)
buf
;
if
(
mode
!=
MODE_ID
_GCM
)
return
STATUS_NOT_SUPPORTED
;
if
(
mode
!=
CHAIN_MODE
_GCM
)
return
STATUS_NOT_SUPPORTED
;
*
ret_size
=
sizeof
(
*
tag_length
);
if
(
tag_length
&&
size
<
*
ret_size
)
return
STATUS_BUFFER_TOO_SMALL
;
if
(
tag_length
)
...
...
@@ -675,7 +675,7 @@ static NTSTATUS get_aes_property( enum mode_id mode, const WCHAR *prop, UCHAR *b
return
STATUS_NOT_IMPLEMENTED
;
}
static
NTSTATUS
get_rsa_property
(
enum
mode_id
mode
,
const
WCHAR
*
prop
,
UCHAR
*
buf
,
ULONG
size
,
ULONG
*
ret_size
)
static
NTSTATUS
get_rsa_property
(
enum
chain_mode
mode
,
const
WCHAR
*
prop
,
UCHAR
*
buf
,
ULONG
size
,
ULONG
*
ret_size
)
{
if
(
!
wcscmp
(
prop
,
BCRYPT_PADDING_SCHEMES
))
{
...
...
@@ -689,7 +689,7 @@ static NTSTATUS get_rsa_property( enum mode_id mode, const WCHAR *prop, UCHAR *b
return
STATUS_NOT_IMPLEMENTED
;
}
static
NTSTATUS
get_dsa_property
(
enum
mode_id
mode
,
const
WCHAR
*
prop
,
UCHAR
*
buf
,
ULONG
size
,
ULONG
*
ret_size
)
static
NTSTATUS
get_dsa_property
(
enum
chain_mode
mode
,
const
WCHAR
*
prop
,
UCHAR
*
buf
,
ULONG
size
,
ULONG
*
ret_size
)
{
if
(
!
wcscmp
(
prop
,
BCRYPT_PADDING_SCHEMES
))
return
STATUS_NOT_SUPPORTED
;
FIXME
(
"unsupported property %s
\n
"
,
debugstr_w
(
prop
)
);
...
...
@@ -736,7 +736,7 @@ static NTSTATUS set_alg_property( struct algorithm *alg, const WCHAR *prop, UCHA
{
if
(
!
wcscmp
(
(
WCHAR
*
)
value
,
BCRYPT_CHAIN_MODE_CBC
))
{
alg
->
mode
=
MODE_ID
_CBC
;
alg
->
mode
=
CHAIN_MODE
_CBC
;
return
STATUS_SUCCESS
;
}
else
...
...
@@ -753,22 +753,22 @@ static NTSTATUS set_alg_property( struct algorithm *alg, const WCHAR *prop, UCHA
{
if
(
!
wcscmp
(
(
WCHAR
*
)
value
,
BCRYPT_CHAIN_MODE_ECB
))
{
alg
->
mode
=
MODE_ID
_ECB
;
alg
->
mode
=
CHAIN_MODE
_ECB
;
return
STATUS_SUCCESS
;
}
else
if
(
!
wcscmp
(
(
WCHAR
*
)
value
,
BCRYPT_CHAIN_MODE_CBC
))
{
alg
->
mode
=
MODE_ID
_CBC
;
alg
->
mode
=
CHAIN_MODE
_CBC
;
return
STATUS_SUCCESS
;
}
else
if
(
!
wcscmp
(
(
WCHAR
*
)
value
,
BCRYPT_CHAIN_MODE_GCM
))
{
alg
->
mode
=
MODE_ID
_GCM
;
alg
->
mode
=
CHAIN_MODE
_GCM
;
return
STATUS_SUCCESS
;
}
else
if
(
!
wcscmp
(
(
WCHAR
*
)
value
,
BCRYPT_CHAIN_MODE_CFB
))
{
alg
->
mode
=
MODE_ID
_CFB
;
alg
->
mode
=
CHAIN_MODE
_CFB
;
return
STATUS_SUCCESS
;
}
else
...
...
@@ -792,22 +792,22 @@ static NTSTATUS set_key_property( struct key *key, const WCHAR *prop, UCHAR *val
{
if
(
!
wcscmp
(
(
WCHAR
*
)
value
,
BCRYPT_CHAIN_MODE_ECB
))
{
key
->
u
.
s
.
mode
=
MODE_ID
_ECB
;
key
->
u
.
s
.
mode
=
CHAIN_MODE
_ECB
;
return
STATUS_SUCCESS
;
}
else
if
(
!
wcscmp
(
(
WCHAR
*
)
value
,
BCRYPT_CHAIN_MODE_CBC
))
{
key
->
u
.
s
.
mode
=
MODE_ID
_CBC
;
key
->
u
.
s
.
mode
=
CHAIN_MODE
_CBC
;
return
STATUS_SUCCESS
;
}
else
if
(
!
wcscmp
(
(
WCHAR
*
)
value
,
BCRYPT_CHAIN_MODE_GCM
))
{
key
->
u
.
s
.
mode
=
MODE_ID
_GCM
;
key
->
u
.
s
.
mode
=
CHAIN_MODE
_GCM
;
return
STATUS_SUCCESS
;
}
else
if
(
!
wcscmp
(
(
WCHAR
*
)
value
,
BCRYPT_CHAIN_MODE_CFB
))
{
key
->
u
.
s
.
mode
=
MODE_ID
_CFB
;
key
->
u
.
s
.
mode
=
CHAIN_MODE
_CFB
;
return
STATUS_SUCCESS
;
}
else
...
...
@@ -1131,7 +1131,7 @@ static NTSTATUS key_symmetric_set_vector( struct key *key, UCHAR *vector, ULONG
return
STATUS_SUCCESS
;
}
static
struct
key
*
create_symmetric_key
(
enum
alg_id
alg
,
enum
mode_id
mode
,
ULONG
block_size
,
UCHAR
*
secret
,
static
struct
key
*
create_symmetric_key
(
enum
alg_id
alg
,
enum
chain_mode
mode
,
ULONG
block_size
,
UCHAR
*
secret
,
ULONG
secret_len
)
{
struct
key
*
ret
;
...
...
@@ -1311,7 +1311,7 @@ static NTSTATUS key_symmetric_encrypt( struct key *key, UCHAR *input, ULONG inp
UCHAR
*
buf
;
NTSTATUS
status
;
if
(
key
->
u
.
s
.
mode
==
MODE_ID
_GCM
)
if
(
key
->
u
.
s
.
mode
==
CHAIN_MODE
_GCM
)
{
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
*
auth_info
=
padding
;
...
...
@@ -1357,7 +1357,7 @@ static NTSTATUS key_symmetric_encrypt( struct key *key, UCHAR *input, ULONG inp
if
(
!
output
)
return
STATUS_SUCCESS
;
if
(
output_len
<
*
ret_len
)
return
STATUS_BUFFER_TOO_SMALL
;
if
(
key
->
u
.
s
.
mode
==
MODE_ID
_ECB
&&
iv
)
return
STATUS_INVALID_PARAMETER
;
if
(
key
->
u
.
s
.
mode
==
CHAIN_MODE
_ECB
&&
iv
)
return
STATUS_INVALID_PARAMETER
;
if
((
status
=
key_symmetric_set_vector
(
key
,
iv
,
iv_len
,
flags
&
BCRYPT_BLOCK_PADDING
)))
return
status
;
encrypt_params
.
key
=
key
;
...
...
@@ -1369,7 +1369,7 @@ static NTSTATUS key_symmetric_encrypt( struct key *key, UCHAR *input, ULONG inp
{
if
((
status
=
UNIX_CALL
(
key_symmetric_encrypt
,
&
encrypt_params
)))
return
status
;
if
(
key
->
u
.
s
.
mode
==
MODE_ID
_ECB
&&
(
status
=
key_symmetric_set_vector
(
key
,
NULL
,
0
,
TRUE
)))
if
(
key
->
u
.
s
.
mode
==
CHAIN_MODE
_ECB
&&
(
status
=
key_symmetric_set_vector
(
key
,
NULL
,
0
,
TRUE
)))
return
status
;
bytes_left
-=
key
->
u
.
s
.
block_size
;
encrypt_params
.
input
+=
key
->
u
.
s
.
block_size
;
...
...
@@ -1398,7 +1398,7 @@ static NTSTATUS key_symmetric_decrypt( struct key *key, UCHAR *input, ULONG inpu
ULONG
bytes_left
=
input_len
;
NTSTATUS
status
;
if
(
key
->
u
.
s
.
mode
==
MODE_ID
_GCM
)
if
(
key
->
u
.
s
.
mode
==
CHAIN_MODE
_GCM
)
{
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
*
auth_info
=
padding
;
UCHAR
tag
[
16
];
...
...
@@ -1449,7 +1449,7 @@ static NTSTATUS key_symmetric_decrypt( struct key *key, UCHAR *input, ULONG inpu
}
else
if
(
output_len
<
*
ret_len
)
return
STATUS_BUFFER_TOO_SMALL
;
if
(
key
->
u
.
s
.
mode
==
MODE_ID
_ECB
&&
iv
)
return
STATUS_INVALID_PARAMETER
;
if
(
key
->
u
.
s
.
mode
==
CHAIN_MODE
_ECB
&&
iv
)
return
STATUS_INVALID_PARAMETER
;
if
((
status
=
key_symmetric_set_vector
(
key
,
iv
,
iv_len
,
flags
&
BCRYPT_BLOCK_PADDING
)))
return
status
;
decrypt_params
.
key
=
key
;
...
...
@@ -1460,7 +1460,7 @@ static NTSTATUS key_symmetric_decrypt( struct key *key, UCHAR *input, ULONG inpu
while
(
bytes_left
>=
key
->
u
.
s
.
block_size
)
{
if
((
status
=
UNIX_CALL
(
key_symmetric_decrypt
,
&
decrypt_params
)))
return
status
;
if
(
key
->
u
.
s
.
mode
==
MODE_ID
_ECB
&&
(
status
=
key_symmetric_set_vector
(
key
,
NULL
,
0
,
TRUE
)))
if
(
key
->
u
.
s
.
mode
==
CHAIN_MODE
_ECB
&&
(
status
=
key_symmetric_set_vector
(
key
,
NULL
,
0
,
TRUE
)))
return
status
;
bytes_left
-=
key
->
u
.
s
.
block_size
;
decrypt_params
.
input
+=
key
->
u
.
s
.
block_size
;
...
...
dlls/bcrypt/gnutls.c
View file @
ec85dfe3
...
...
@@ -490,7 +490,7 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
WARN
(
"handle block size
\n
"
);
switch
(
key
->
u
.
s
.
mode
)
{
case
MODE_ID
_CBC
:
case
CHAIN_MODE
_CBC
:
return
GNUTLS_CIPHER_3DES_CBC
;
default:
break
;
...
...
@@ -502,17 +502,17 @@ static gnutls_cipher_algorithm_t get_gnutls_cipher( const struct key *key )
WARN
(
"handle block size
\n
"
);
switch
(
key
->
u
.
s
.
mode
)
{
case
MODE_ID
_GCM
:
case
CHAIN_MODE
_GCM
:
if
(
key
->
u
.
s
.
secret_len
==
16
)
return
GNUTLS_CIPHER_AES_128_GCM
;
if
(
key
->
u
.
s
.
secret_len
==
32
)
return
GNUTLS_CIPHER_AES_256_GCM
;
break
;
case
MODE_ID
_ECB
:
/* can be emulated with CBC + empty IV */
case
MODE_ID
_CBC
:
case
CHAIN_MODE
_ECB
:
/* can be emulated with CBC + empty IV */
case
CHAIN_MODE
_CBC
:
if
(
key
->
u
.
s
.
secret_len
==
16
)
return
GNUTLS_CIPHER_AES_128_CBC
;
if
(
key
->
u
.
s
.
secret_len
==
24
)
return
GNUTLS_CIPHER_AES_192_CBC
;
if
(
key
->
u
.
s
.
secret_len
==
32
)
return
GNUTLS_CIPHER_AES_256_CBC
;
break
;
case
MODE_ID
_CFB
:
case
CHAIN_MODE
_CFB
:
if
(
key
->
u
.
s
.
secret_len
==
16
)
return
GNUTLS_CIPHER_AES_128_CFB8
;
if
(
key
->
u
.
s
.
secret_len
==
24
)
return
GNUTLS_CIPHER_AES_192_CFB8
;
if
(
key
->
u
.
s
.
secret_len
==
32
)
return
GNUTLS_CIPHER_AES_256_CFB8
;
...
...
@@ -2041,13 +2041,13 @@ typedef ULONG PTR32;
struct
key_symmetric32
{
enum
mode_id
mode
;
ULONG
block_size
;
PTR32
vector
;
ULONG
vector_len
;
PTR32
secret
;
ULONG
secret_len
;
ULONG
__cs
[
6
];
enum
chain_mode
mode
;
ULONG
block_size
;
PTR32
vector
;
ULONG
vector_len
;
PTR32
secret
;
ULONG
secret_len
;
ULONG
__cs
[
6
];
};
struct
key_asymmetric32
...
...
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