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
b6cb27ea
Commit
b6cb27ea
authored
Jul 20, 2018
by
Hans Leidekker
Committed by
Alexandre Julliard
Jul 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Move the ASN1 buffer functions to gnutls.c.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8b8a32f7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
109 deletions
+103
-109
bcrypt_internal.h
dlls/bcrypt/bcrypt_internal.h
+0
-12
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+0
-97
gnutls.c
dlls/bcrypt/gnutls.c
+103
-0
No files found.
dlls/bcrypt/bcrypt_internal.h
View file @
b6cb27ea
...
@@ -105,18 +105,6 @@ VOID WINAPI A_SHAInit(SHA_CTX *ctx);
...
@@ -105,18 +105,6 @@ VOID WINAPI A_SHAInit(SHA_CTX *ctx);
VOID
WINAPI
A_SHAUpdate
(
SHA_CTX
*
ctx
,
const
UCHAR
*
buffer
,
UINT
size
);
VOID
WINAPI
A_SHAUpdate
(
SHA_CTX
*
ctx
,
const
UCHAR
*
buffer
,
UINT
size
);
VOID
WINAPI
A_SHAFinal
(
SHA_CTX
*
ctx
,
PULONG
result
);
VOID
WINAPI
A_SHAFinal
(
SHA_CTX
*
ctx
,
PULONG
result
);
struct
buffer
{
BYTE
*
buffer
;
DWORD
length
;
DWORD
pos
;
BOOL
error
;
};
void
buffer_init
(
struct
buffer
*
)
DECLSPEC_HIDDEN
;
void
buffer_free
(
struct
buffer
*
)
DECLSPEC_HIDDEN
;
void
buffer_append_asn1_r_s
(
struct
buffer
*
,
BYTE
*
,
DWORD
,
BYTE
*
,
DWORD
)
DECLSPEC_HIDDEN
;
#define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0')
#define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0')
#define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H')
#define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H')
#define MAGIC_KEY (('K' << 24) | ('E' << 16) | ('Y' << 8) | '0')
#define MAGIC_KEY (('K' << 24) | ('E' << 16) | ('Y' << 8) | '0')
...
...
dlls/bcrypt/bcrypt_main.c
View file @
b6cb27ea
...
@@ -718,103 +718,6 @@ NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG se
...
@@ -718,103 +718,6 @@ NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG se
return
BCryptDestroyHash
(
handle
);
return
BCryptDestroyHash
(
handle
);
}
}
#if defined(HAVE_GNUTLS_CIPHER_INIT)
void
buffer_init
(
struct
buffer
*
buffer
)
{
buffer
->
buffer
=
NULL
;
buffer
->
length
=
0
;
buffer
->
pos
=
0
;
buffer
->
error
=
FALSE
;
}
void
buffer_free
(
struct
buffer
*
buffer
)
{
heap_free
(
buffer
->
buffer
);
}
static
void
buffer_append
(
struct
buffer
*
buffer
,
BYTE
*
data
,
DWORD
len
)
{
if
(
!
len
)
return
;
if
(
buffer
->
pos
+
len
>
buffer
->
length
)
{
DWORD
new_length
=
max
(
max
(
buffer
->
pos
+
len
,
buffer
->
length
*
2
),
64
);
BYTE
*
new_buffer
;
if
(
!
(
new_buffer
=
heap_realloc
(
buffer
->
buffer
,
new_length
)))
{
ERR
(
"out of memory
\n
"
);
buffer
->
error
=
TRUE
;
return
;
}
buffer
->
buffer
=
new_buffer
;
buffer
->
length
=
new_length
;
}
memcpy
(
&
buffer
->
buffer
[
buffer
->
pos
],
data
,
len
);
buffer
->
pos
+=
len
;
}
static
void
buffer_append_byte
(
struct
buffer
*
buffer
,
BYTE
value
)
{
buffer_append
(
buffer
,
&
value
,
sizeof
(
value
)
);
}
static
void
buffer_append_asn1_length
(
struct
buffer
*
buffer
,
DWORD
length
)
{
DWORD
num_bytes
;
if
(
length
<
128
)
{
buffer_append_byte
(
buffer
,
length
);
return
;
}
if
(
length
<=
0xff
)
num_bytes
=
1
;
else
if
(
length
<=
0xffff
)
num_bytes
=
2
;
else
if
(
length
<=
0xffffff
)
num_bytes
=
3
;
else
num_bytes
=
4
;
buffer_append_byte
(
buffer
,
0x80
|
num_bytes
);
while
(
num_bytes
--
)
buffer_append_byte
(
buffer
,
length
>>
(
num_bytes
*
8
)
);
}
static
void
buffer_append_asn1_integer
(
struct
buffer
*
buffer
,
BYTE
*
data
,
DWORD
len
)
{
DWORD
leading_zero
=
(
*
data
&
0x80
)
!=
0
;
buffer_append_byte
(
buffer
,
0x02
);
/* tag */
buffer_append_asn1_length
(
buffer
,
len
+
leading_zero
);
if
(
leading_zero
)
buffer_append_byte
(
buffer
,
0
);
buffer_append
(
buffer
,
data
,
len
);
}
static
void
buffer_append_asn1_sequence
(
struct
buffer
*
buffer
,
struct
buffer
*
content
)
{
if
(
content
->
error
)
{
buffer
->
error
=
TRUE
;
return
;
}
buffer_append_byte
(
buffer
,
0x30
);
/* tag */
buffer_append_asn1_length
(
buffer
,
content
->
pos
);
buffer_append
(
buffer
,
content
->
buffer
,
content
->
pos
);
}
void
buffer_append_asn1_r_s
(
struct
buffer
*
buffer
,
BYTE
*
r
,
DWORD
r_len
,
BYTE
*
s
,
DWORD
s_len
)
{
struct
buffer
value
;
buffer_init
(
&
value
);
buffer_append_asn1_integer
(
&
value
,
r
,
r_len
);
buffer_append_asn1_integer
(
&
value
,
s
,
s_len
);
buffer_append_asn1_sequence
(
buffer
,
&
value
);
buffer_free
(
&
value
);
}
#endif
#if defined(HAVE_GNUTLS_CIPHER_INIT) || defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
#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
)
BOOL
key_is_symmetric
(
struct
key
*
key
)
{
{
...
...
dlls/bcrypt/gnutls.c
View file @
b6cb27ea
...
@@ -215,6 +215,109 @@ void gnutls_uninitialize(void)
...
@@ -215,6 +215,109 @@ void gnutls_uninitialize(void)
libgnutls_handle
=
NULL
;
libgnutls_handle
=
NULL
;
}
}
struct
buffer
{
BYTE
*
buffer
;
DWORD
length
;
DWORD
pos
;
BOOL
error
;
};
static
void
buffer_init
(
struct
buffer
*
buffer
)
{
buffer
->
buffer
=
NULL
;
buffer
->
length
=
0
;
buffer
->
pos
=
0
;
buffer
->
error
=
FALSE
;
}
static
void
buffer_free
(
struct
buffer
*
buffer
)
{
heap_free
(
buffer
->
buffer
);
}
static
void
buffer_append
(
struct
buffer
*
buffer
,
BYTE
*
data
,
DWORD
len
)
{
if
(
!
len
)
return
;
if
(
buffer
->
pos
+
len
>
buffer
->
length
)
{
DWORD
new_length
=
max
(
max
(
buffer
->
pos
+
len
,
buffer
->
length
*
2
),
64
);
BYTE
*
new_buffer
;
if
(
!
(
new_buffer
=
heap_realloc
(
buffer
->
buffer
,
new_length
)))
{
ERR
(
"out of memory
\n
"
);
buffer
->
error
=
TRUE
;
return
;
}
buffer
->
buffer
=
new_buffer
;
buffer
->
length
=
new_length
;
}
memcpy
(
&
buffer
->
buffer
[
buffer
->
pos
],
data
,
len
);
buffer
->
pos
+=
len
;
}
static
void
buffer_append_byte
(
struct
buffer
*
buffer
,
BYTE
value
)
{
buffer_append
(
buffer
,
&
value
,
sizeof
(
value
)
);
}
static
void
buffer_append_asn1_length
(
struct
buffer
*
buffer
,
DWORD
length
)
{
DWORD
num_bytes
;
if
(
length
<
128
)
{
buffer_append_byte
(
buffer
,
length
);
return
;
}
if
(
length
<=
0xff
)
num_bytes
=
1
;
else
if
(
length
<=
0xffff
)
num_bytes
=
2
;
else
if
(
length
<=
0xffffff
)
num_bytes
=
3
;
else
num_bytes
=
4
;
buffer_append_byte
(
buffer
,
0x80
|
num_bytes
);
while
(
num_bytes
--
)
buffer_append_byte
(
buffer
,
length
>>
(
num_bytes
*
8
)
);
}
static
void
buffer_append_asn1_integer
(
struct
buffer
*
buffer
,
BYTE
*
data
,
DWORD
len
)
{
DWORD
leading_zero
=
(
*
data
&
0x80
)
!=
0
;
buffer_append_byte
(
buffer
,
0x02
);
/* tag */
buffer_append_asn1_length
(
buffer
,
len
+
leading_zero
);
if
(
leading_zero
)
buffer_append_byte
(
buffer
,
0
);
buffer_append
(
buffer
,
data
,
len
);
}
static
void
buffer_append_asn1_sequence
(
struct
buffer
*
buffer
,
struct
buffer
*
content
)
{
if
(
content
->
error
)
{
buffer
->
error
=
TRUE
;
return
;
}
buffer_append_byte
(
buffer
,
0x30
);
/* tag */
buffer_append_asn1_length
(
buffer
,
content
->
pos
);
buffer_append
(
buffer
,
content
->
buffer
,
content
->
pos
);
}
static
void
buffer_append_asn1_r_s
(
struct
buffer
*
buffer
,
BYTE
*
r
,
DWORD
r_len
,
BYTE
*
s
,
DWORD
s_len
)
{
struct
buffer
value
;
buffer_init
(
&
value
);
buffer_append_asn1_integer
(
&
value
,
r
,
r_len
);
buffer_append_asn1_integer
(
&
value
,
s
,
s_len
);
buffer_append_asn1_sequence
(
buffer
,
&
value
);
buffer_free
(
&
value
);
}
NTSTATUS
key_set_property
(
struct
key
*
key
,
const
WCHAR
*
prop
,
UCHAR
*
value
,
ULONG
size
,
ULONG
flags
)
NTSTATUS
key_set_property
(
struct
key
*
key
,
const
WCHAR
*
prop
,
UCHAR
*
value
,
ULONG
size
,
ULONG
flags
)
{
{
if
(
!
strcmpW
(
prop
,
BCRYPT_CHAINING_MODE
))
if
(
!
strcmpW
(
prop
,
BCRYPT_CHAINING_MODE
))
...
...
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