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
45904656
Commit
45904656
authored
Sep 29, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Move the symmetric key initialization to the generic code.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
b8ada902
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
59 deletions
+44
-59
bcrypt_internal.h
dlls/bcrypt/bcrypt_internal.h
+6
-3
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+28
-5
gnutls.c
dlls/bcrypt/gnutls.c
+4
-24
macos.c
dlls/bcrypt/macos.c
+6
-27
No files found.
dlls/bcrypt/bcrypt_internal.h
View file @
45904656
...
...
@@ -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
;
...
...
dlls/bcrypt/bcrypt_main.c
View file @
45904656
...
...
@@ -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
;
}
...
...
dlls/bcrypt/gnutls.c
View file @
45904656
...
...
@@ -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
)
...
...
dlls/bcrypt/macos.c
View file @
45904656
...
...
@@ -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
)
...
...
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