Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
0c9b94ee
Commit
0c9b94ee
authored
Jan 06, 2016
by
Hans Leidekker
Committed by
Alexandre Julliard
Jan 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Implement BCryptCreateHash and BCryptDestroyHash.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
eaf9e415
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
101 additions
and
5 deletions
+101
-5
configure
configure
+1
-0
configure.ac
configure.ac
+1
-0
bcrypt.spec
dlls/bcrypt/bcrypt.spec
+1
-1
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+95
-4
config.h.in
include/config.h.in
+3
-0
No files found.
configure
View file @
0c9b94ee
...
...
@@ -6675,6 +6675,7 @@ for ac_header in \
AudioUnit/AudioComponent.h
\
CL/cl.h
\
Carbon/Carbon.h
\
CommonCrypto/CommonDigest.h
\
CoreAudio/CoreAudio.h
\
CoreServices/CoreServices.h
\
DiskArbitration/DiskArbitration.h
\
...
...
configure.ac
View file @
0c9b94ee
...
...
@@ -393,6 +393,7 @@ AC_CHECK_HEADERS(\
AudioUnit/AudioComponent.h \
CL/cl.h \
Carbon/Carbon.h \
CommonCrypto/CommonDigest.h \
CoreAudio/CoreAudio.h \
CoreServices/CoreServices.h \
DiskArbitration/DiskArbitration.h \
...
...
dlls/bcrypt/bcrypt.spec
View file @
0c9b94ee
...
...
@@ -8,7 +8,7 @@
@ stub BCryptDecrypt
@ stub BCryptDeleteContext
@ stub BCryptDeriveKey
@ st
ub BCryptDestroyHash
@ st
dcall BCryptDestroyHash(ptr)
@ stub BCryptDestroyKey
@ stub BCryptDestroySecret
@ stub BCryptDuplicateHash
...
...
dlls/bcrypt/bcrypt_main.c
View file @
0c9b94ee
...
...
@@ -20,6 +20,9 @@
#include "config.h"
#include <stdarg.h>
#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
#include <CommonCrypto/CommonDigest.h>
#endif
#include "ntstatus.h"
#define WIN32_NO_STATUS
...
...
@@ -81,6 +84,7 @@ NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE algorithm, UCHAR *buffer, ULON
}
#define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0')
#define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H')
struct
object
{
ULONG
magic
;
...
...
@@ -159,6 +163,59 @@ NTSTATUS WINAPI BCryptGetFipsAlgorithmMode(BOOLEAN *enabled)
return
STATUS_SUCCESS
;
}
#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
struct
hash
{
struct
object
hdr
;
enum
alg_id
alg_id
;
union
{
CC_SHA1_CTX
sha1_ctx
;
CC_SHA256_CTX
sha256_ctx
;
CC_SHA512_CTX
sha512_ctx
;
}
u
;
};
static
NTSTATUS
hash_init
(
struct
hash
*
hash
)
{
switch
(
hash
->
alg_id
)
{
case
ALG_ID_SHA1
:
CC_SHA1_Init
(
&
hash
->
u
.
sha1_ctx
);
break
;
case
ALG_ID_SHA256
:
CC_SHA256_Init
(
&
hash
->
u
.
sha256_ctx
);
break
;
case
ALG_ID_SHA384
:
CC_SHA384_Init
(
&
hash
->
u
.
sha512_ctx
);
break
;
case
ALG_ID_SHA512
:
CC_SHA512_Init
(
&
hash
->
u
.
sha512_ctx
);
break
;
default:
ERR
(
"unhandled id %u
\n
"
,
hash
->
alg_id
);
return
STATUS_NOT_IMPLEMENTED
;
}
return
STATUS_SUCCESS
;
}
#else
struct
hash
{
struct
object
hdr
;
enum
alg_id
alg_id
;
};
static
NTSTATUS
hash_init
(
struct
hash
*
hash
)
{
ERR
(
"support for hashes not available at build time
\n
"
);
return
STATUS_NOT_IMPLEMENTED
;
}
#endif
NTSTATUS
WINAPI
BCryptGetProperty
(
BCRYPT_HANDLE
obj
,
LPCWSTR
prop
,
UCHAR
*
buffer
,
ULONG
count
,
ULONG
*
res
,
ULONG
flags
)
{
FIXME
(
"%p, %s, %p, %u, %p, %08x - stub
\n
"
,
obj
,
wine_dbgstr_w
(
prop
),
buffer
,
count
,
res
,
flags
);
...
...
@@ -166,10 +223,44 @@ NTSTATUS WINAPI BCryptGetProperty(BCRYPT_HANDLE obj, LPCWSTR prop, UCHAR *buffer
return
STATUS_NOT_IMPLEMENTED
;
}
NTSTATUS
WINAPI
BCryptCreateHash
(
BCRYPT_ALG_HANDLE
algorithm
,
BCRYPT_HASH_HANDLE
*
hash
,
UCHAR
*
hashobject
,
ULONG
hashobjectlen
,
UCHAR
*
secret
,
ULONG
secretlen
,
ULONG
flags
)
NTSTATUS
WINAPI
BCryptCreateHash
(
BCRYPT_ALG_HANDLE
algorithm
,
BCRYPT_HASH_HANDLE
*
handle
,
UCHAR
*
object
,
ULONG
objectlen
,
UCHAR
*
secret
,
ULONG
secretlen
,
ULONG
flags
)
{
FIXME
(
"%p, %p, %p, %u, %p, %u, %08x - stub
\n
"
,
algorithm
,
hash
,
hashobject
,
hashobjectlen
,
secret
,
secretlen
,
flags
);
struct
algorithm
*
alg
=
algorithm
;
struct
hash
*
hash
;
NTSTATUS
status
;
return
STATUS_NOT_IMPLEMENTED
;
TRACE
(
"%p, %p, %p, %u, %p, %u, %08x - stub
\n
"
,
algorithm
,
handle
,
object
,
objectlen
,
secret
,
secretlen
,
flags
);
if
(
flags
)
{
FIXME
(
"unimplemented flags %08x
\n
"
,
flags
);
return
STATUS_NOT_IMPLEMENTED
;
}
if
(
!
alg
||
alg
->
hdr
.
magic
!=
MAGIC_ALG
)
return
STATUS_INVALID_HANDLE
;
if
(
object
)
FIXME
(
"ignoring object buffer
\n
"
);
if
(
!
(
hash
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
hash
)
)))
return
STATUS_NO_MEMORY
;
hash
->
hdr
.
magic
=
MAGIC_HASH
;
hash
->
alg_id
=
alg
->
id
;
if
((
status
=
hash_init
(
hash
))
!=
STATUS_SUCCESS
)
{
HeapFree
(
GetProcessHeap
(),
0
,
hash
);
return
status
;
}
*
handle
=
hash
;
return
STATUS_SUCCESS
;
}
NTSTATUS
WINAPI
BCryptDestroyHash
(
BCRYPT_HASH_HANDLE
handle
)
{
struct
hash
*
hash
=
handle
;
TRACE
(
"%p
\n
"
,
handle
);
if
(
!
hash
||
hash
->
hdr
.
magic
!=
MAGIC_HASH
)
return
STATUS_INVALID_HANDLE
;
HeapFree
(
GetProcessHeap
(),
0
,
hash
);
return
STATUS_SUCCESS
;
}
include/config.h.in
View file @
0c9b94ee
...
...
@@ -71,6 +71,9 @@
/* Define to 1 if you have the <CL/cl.h> header file. */
#undef HAVE_CL_CL_H
/* Define to 1 if you have the <CommonCrypto/CommonDigest.h> header file. */
#undef HAVE_COMMONCRYPTO_COMMONDIGEST_H
/* Define to 1 if you have the <CoreAudio/CoreAudio.h> header file. */
#undef HAVE_COREAUDIO_COREAUDIO_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