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
6aa5fdf9
Commit
6aa5fdf9
authored
Jun 28, 2017
by
Jacek Caban
Committed by
Alexandre Julliard
Jun 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rsaenh: Use bcrypt for SHA512 hashes.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
2164a4da
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
93 deletions
+24
-93
Makefile.in
dlls/rsaenh/Makefile.in
+1
-1
implglue.c
dlls/rsaenh/implglue.c
+19
-13
implglue.h
dlls/rsaenh/implglue.h
+4
-1
rsaenh.c
dlls/rsaenh/rsaenh.c
+0
-1
sha2.c
dlls/rsaenh/sha2.c
+0
-71
sha2.h
dlls/rsaenh/sha2.h
+0
-6
No files found.
dlls/rsaenh/Makefile.in
View file @
6aa5fdf9
MODULE
=
rsaenh.dll
IMPORTLIB
=
rsaenh
IMPORTS
=
crypt32 advapi32
IMPORTS
=
bcrypt
crypt32 advapi32
C_SRCS
=
\
aes.c
\
...
...
dlls/rsaenh/implglue.c
View file @
6aa5fdf9
...
...
@@ -50,6 +50,8 @@ BOOL WINAPI SystemFunction036(PVOID pbBuffer, ULONG dwLen);
BOOL
init_hash_impl
(
ALG_ID
aiAlgid
,
HASH_CONTEXT
*
pHashContext
)
{
const
WCHAR
*
algid
=
NULL
;
switch
(
aiAlgid
)
{
case
CALG_MD2
:
...
...
@@ -77,10 +79,22 @@ BOOL init_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext)
break
;
case
CALG_SHA_512
:
SHA512_Init
(
&
pHashContext
->
sha512
)
;
algid
=
BCRYPT_SHA512_ALGORITHM
;
break
;
}
if
(
algid
)
{
BCRYPT_ALG_HANDLE
provider
;
NTSTATUS
status
;
status
=
BCryptOpenAlgorithmProvider
(
&
provider
,
algid
,
MS_PRIMITIVE_PROVIDER
,
0
);
if
(
status
)
return
FALSE
;
status
=
BCryptCreateHash
(
provider
,
&
pHashContext
->
bcrypt_hash
,
NULL
,
0
,
NULL
,
0
,
0
);
BCryptCloseAlgorithmProvider
(
provider
,
0
);
if
(
status
)
return
FALSE
;
}
return
TRUE
;
}
...
...
@@ -113,13 +127,8 @@ BOOL update_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, const BYTE *pb
SHA384_Update
(
&
pHashContext
->
sha384
,
pbData
,
dwDataLen
);
break
;
case
CALG_SHA_512
:
SHA512_Update
(
&
pHashContext
->
sha512
,
pbData
,
dwDataLen
);
break
;
default:
SetLastError
(
NTE_BAD_ALGID
);
return
FALSE
;
BCryptHashData
(
pHashContext
->
bcrypt_hash
,
(
UCHAR
*
)
pbData
,
dwDataLen
,
0
);
}
return
TRUE
;
...
...
@@ -155,13 +164,10 @@ BOOL finalize_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, BYTE *pbHash
SHA384_Final
(
pbHashValue
,
&
pHashContext
->
sha384
);
break
;
case
CALG_SHA_512
:
SHA512_Final
(
pbHashValue
,
&
pHashContext
->
sha512
);
break
;
default:
SetLastError
(
NTE_BAD_ALGID
);
return
FALSE
;
BCryptFinishHash
(
pHashContext
->
bcrypt_hash
,
pbHashValue
,
RSAENH_MAX_HASH_SIZE
,
0
);
BCryptDestroyHash
(
pHashContext
->
bcrypt_hash
);
break
;
}
return
TRUE
;
...
...
dlls/rsaenh/implglue.h
View file @
6aa5fdf9
...
...
@@ -24,9 +24,12 @@
#ifndef __WINE_IMPLGLUE_H
#define __WINE_IMPLGLUE_H
#include "bcrypt.h"
#include "tomcrypt.h"
#include "sha2.h"
#define RSAENH_MAX_HASH_SIZE 104
/* Next typedef copied from dlls/advapi32/crypt_md4.c */
typedef
struct
tagMD4_CTX
{
unsigned
int
buf
[
4
];
...
...
@@ -60,7 +63,7 @@ typedef union tagHASH_CONTEXT {
SHA_CTX
sha
;
SHA256_CTX
sha256
;
SHA384_CTX
sha384
;
SHA512_CTX
sha512
;
BCRYPT_HASH_HANDLE
bcrypt_hash
;
}
HASH_CONTEXT
;
typedef
union
tagKEY_CONTEXT
{
...
...
dlls/rsaenh/rsaenh.c
View file @
6aa5fdf9
...
...
@@ -48,7 +48,6 @@ static HINSTANCE instance;
* CRYPTHASH - hash objects
*/
#define RSAENH_MAGIC_HASH 0x85938417u
#define RSAENH_MAX_HASH_SIZE 104
#define RSAENH_HASHSTATE_HASHING 1
#define RSAENH_HASHSTATE_FINISHED 2
typedef
struct
_RSAENH_TLS1PRF_PARAMS
...
...
dlls/rsaenh/sha2.c
View file @
6aa5fdf9
...
...
@@ -599,16 +599,6 @@ char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_S
}
/*** SHA-512: *********************************************************/
void
SHA512_Init
(
SHA512_CTX
*
context
)
{
if
(
context
==
NULL
)
{
return
;
}
MEMCPY_BCOPY
(
context
->
state
,
sha512_initial_hash_value
,
SHA512_DIGEST_LENGTH
);
MEMSET_BZERO
(
context
->
buffer
,
SHA512_BLOCK_LENGTH
);
context
->
bitcount
[
0
]
=
context
->
bitcount
[
1
]
=
0
;
}
#ifdef SHA2_UNROLL_TRANSFORM
/* Unrolled SHA-512 round macros: */
...
...
@@ -867,67 +857,6 @@ void SHA512_Last(SHA512_CTX* context) {
SHA512_Transform
(
context
,
(
sha2_word64
*
)
context
->
buffer
);
}
void
SHA512_Final
(
sha2_byte
digest
[],
SHA512_CTX
*
context
)
{
sha2_word64
*
d
=
(
sha2_word64
*
)
digest
;
/* Sanity check: */
assert
(
context
!=
NULL
);
/* If no digest buffer is passed, we don't bother doing this: */
if
(
digest
!=
NULL
)
{
SHA512_Last
(
context
);
/* Save the hash data for output: */
#ifndef WORDS_BIGENDIAN
{
/* Convert TO host byte order */
int
j
;
for
(
j
=
0
;
j
<
8
;
j
++
)
{
REVERSE64
(
context
->
state
[
j
],
context
->
state
[
j
]);
*
d
++
=
context
->
state
[
j
];
}
}
#else
MEMCPY_BCOPY
(
d
,
context
->
state
,
SHA512_DIGEST_LENGTH
);
#endif
}
/* Zero out state data */
MEMSET_BZERO
(
context
,
sizeof
(
*
context
));
}
char
*
SHA512_End
(
SHA512_CTX
*
context
,
char
buffer
[])
{
sha2_byte
digest
[
SHA512_DIGEST_LENGTH
],
*
d
=
digest
;
int
i
;
/* Sanity check: */
assert
(
context
!=
NULL
);
if
(
buffer
!=
NULL
)
{
SHA512_Final
(
digest
,
context
);
for
(
i
=
0
;
i
<
SHA512_DIGEST_LENGTH
;
i
++
)
{
*
buffer
++
=
sha2_hex_digits
[(
*
d
&
0xf0
)
>>
4
];
*
buffer
++
=
sha2_hex_digits
[
*
d
&
0x0f
];
d
++
;
}
*
buffer
=
0
;
}
else
{
MEMSET_BZERO
(
context
,
sizeof
(
*
context
));
}
MEMSET_BZERO
(
digest
,
SHA512_DIGEST_LENGTH
);
return
buffer
;
}
char
*
SHA512_Data
(
const
sha2_byte
*
data
,
size_t
len
,
char
digest
[
SHA512_DIGEST_STRING_LENGTH
])
{
SHA512_CTX
context
;
SHA512_Init
(
&
context
);
SHA512_Update
(
&
context
,
data
,
len
);
return
SHA512_End
(
&
context
,
digest
);
}
/*** SHA-384: *********************************************************/
void
SHA384_Init
(
SHA384_CTX
*
context
)
{
if
(
context
==
NULL
)
{
...
...
dlls/rsaenh/sha2.h
View file @
6aa5fdf9
...
...
@@ -80,10 +80,4 @@ void SHA384_Final(sha2_byte[SHA384_DIGEST_LENGTH], SHA384_CTX*);
char
*
SHA384_End
(
SHA384_CTX
*
,
char
[
SHA384_DIGEST_STRING_LENGTH
]);
char
*
SHA384_Data
(
const
sha2_byte
*
,
size_t
,
char
[
SHA384_DIGEST_STRING_LENGTH
]);
void
SHA512_Init
(
SHA512_CTX
*
);
void
SHA512_Update
(
SHA512_CTX
*
,
const
sha2_byte
*
,
size_t
);
void
SHA512_Final
(
sha2_byte
[
SHA512_DIGEST_LENGTH
],
SHA512_CTX
*
);
char
*
SHA512_End
(
SHA512_CTX
*
,
char
[
SHA512_DIGEST_STRING_LENGTH
]);
char
*
SHA512_Data
(
const
sha2_byte
*
,
size_t
,
char
[
SHA512_DIGEST_STRING_LENGTH
]);
#endif
/* __SHA2_H__ */
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