Add SHA256-hash functions to generic crypto_hash_* functions
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
b32a8d1dfe
commit
dcff088df7
5 changed files with 115 additions and 20 deletions
|
@ -16,21 +16,9 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "sha256.h"
|
||||
#include "sha256_i.h"
|
||||
#include "crypto.h"
|
||||
|
||||
#define SHA256_BLOCK_SIZE 64
|
||||
|
||||
struct sha256_state {
|
||||
u64 length;
|
||||
u32 state[8], curlen;
|
||||
u8 buf[SHA256_BLOCK_SIZE];
|
||||
};
|
||||
|
||||
static void sha256_init(struct sha256_state *md);
|
||||
static int sha256_process(struct sha256_state *md, const unsigned char *in,
|
||||
unsigned long inlen);
|
||||
static int sha256_done(struct sha256_state *md, unsigned char *out);
|
||||
|
||||
|
||||
/**
|
||||
* sha256_vector - SHA256 hash for data vector
|
||||
|
@ -139,7 +127,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf)
|
|||
|
||||
|
||||
/* Initialize the hash state */
|
||||
static void sha256_init(struct sha256_state *md)
|
||||
void sha256_init(struct sha256_state *md)
|
||||
{
|
||||
md->curlen = 0;
|
||||
md->length = 0;
|
||||
|
@ -160,8 +148,8 @@ static void sha256_init(struct sha256_state *md)
|
|||
@param inlen The length of the data (octets)
|
||||
@return CRYPT_OK if successful
|
||||
*/
|
||||
static int sha256_process(struct sha256_state *md, const unsigned char *in,
|
||||
unsigned long inlen)
|
||||
int sha256_process(struct sha256_state *md, const unsigned char *in,
|
||||
unsigned long inlen)
|
||||
{
|
||||
unsigned long n;
|
||||
|
||||
|
@ -200,7 +188,7 @@ static int sha256_process(struct sha256_state *md, const unsigned char *in,
|
|||
@param out [out] The destination of the hash (32 bytes)
|
||||
@return CRYPT_OK if successful
|
||||
*/
|
||||
static int sha256_done(struct sha256_state *md, unsigned char *out)
|
||||
int sha256_done(struct sha256_state *md, unsigned char *out)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue