Commit 524c632a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

rsaenh: Use bcrypt for SHA265 hashes.

parent 78a5d660
......@@ -12,7 +12,6 @@ C_SRCS = \
rc2.c \
rc4.c \
rsa.c \
rsaenh.c \
sha2.c
rsaenh.c
RC_SRCS = rsrc.rc
......@@ -71,7 +71,7 @@ BOOL init_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext)
break;
case CALG_SHA_256:
SHA256_Init(&pHashContext->sha256);
algid = BCRYPT_SHA256_ALGORITHM;
break;
case CALG_SHA_384:
......@@ -119,10 +119,6 @@ BOOL update_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, const BYTE *pb
A_SHAUpdate(&pHashContext->sha, pbData, dwDataLen);
break;
case CALG_SHA_256:
SHA256_Update(&pHashContext->sha256, pbData, dwDataLen);
break;
default:
BCryptHashData(pHashContext->bcrypt_hash, (UCHAR*)pbData, dwDataLen, 0);
}
......@@ -152,10 +148,6 @@ BOOL finalize_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, BYTE *pbHash
A_SHAFinal(&pHashContext->sha, (PULONG)pbHashValue);
break;
case CALG_SHA_256:
SHA256_Final(pbHashValue, &pHashContext->sha256);
break;
default:
BCryptFinishHash(pHashContext->bcrypt_hash, pbHashValue, RSAENH_MAX_HASH_SIZE, 0);
BCryptDestroyHash(pHashContext->bcrypt_hash);
......
......@@ -26,7 +26,6 @@
#include "bcrypt.h"
#include "tomcrypt.h"
#include "sha2.h"
#define RSAENH_MAX_HASH_SIZE 104
......@@ -61,7 +60,6 @@ typedef union tagHASH_CONTEXT {
MD4_CTX md4;
MD5_CTX md5;
SHA_CTX sha;
SHA256_CTX sha256;
BCRYPT_HASH_HANDLE bcrypt_hash;
} HASH_CONTEXT;
......
/*
* FILE: sha2.h
* AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
*
* Copyright (c) 2000-2001, Aaron D. Gifford
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef __SHA2_H__
#define __SHA2_H__
#include <basetsd.h>
/*** SHA-256/384/512 Various Length Definitions ***********************/
#define SHA256_BLOCK_LENGTH 64
#define SHA256_DIGEST_LENGTH 32
#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
/*** SHA-256/384/512 Context Structures *******************************/
typedef UINT8 sha2_byte; /* Exactly 1 byte */
typedef UINT32 sha2_word32; /* Exactly 4 bytes */
typedef UINT64 sha2_word64; /* Exactly 8 bytes */
typedef struct _SHA256_CTX {
sha2_word32 state[8];
sha2_word64 bitcount;
sha2_byte buffer[SHA256_BLOCK_LENGTH];
} SHA256_CTX;
/*** SHA-256/384/512 Function Prototypes ******************************/
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX*, const sha2_byte*, size_t);
void SHA256_Final(sha2_byte[SHA256_DIGEST_LENGTH], SHA256_CTX*);
char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
char* SHA256_Data(const sha2_byte*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
#endif /* __SHA2_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment