Merge branch 'bugfix/fix_errors_with_mbedtls_disabled_v4.1' into 'release/v4.1'
wpa_supplicant: Fix compilation errors when USE_MBEDTLS is disabled. (v4.1) See merge request espressif/esp-idf!8356
This commit is contained in:
commit
585d53dfa8
3 changed files with 37 additions and 28 deletions
|
@ -28,6 +28,8 @@
|
|||
#include "md5_i.h"
|
||||
#ifdef USE_MBEDTLS_CRYPTO
|
||||
#include "mbedtls/sha256.h"
|
||||
#else
|
||||
#include "sha256_i.h"
|
||||
#endif
|
||||
|
||||
struct crypto_hash {
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "mbedtls/sha256.h"
|
||||
#else /* USE_MBEDTLS_CRYPTO */
|
||||
#include "sha256.h"
|
||||
#include "sha256_i.h"
|
||||
#include "crypto.h"
|
||||
#endif /* USE_MBEDTLS_CRYPTO */
|
||||
|
||||
|
@ -79,20 +80,6 @@ out:
|
|||
}
|
||||
#else /* USE_MBEDTLS_CRYPTO */
|
||||
|
||||
#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
|
||||
* @num_elem: Number of elements in the data vector
|
||||
|
@ -101,8 +88,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out);
|
|||
* @mac: Buffer for the hash
|
||||
* Returns: 0 on success, -1 of failure
|
||||
*/
|
||||
int
|
||||
sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
||||
int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
||||
u8 *mac)
|
||||
{
|
||||
struct sha256_state ctx;
|
||||
|
@ -158,8 +144,7 @@ static const unsigned long K[64] = {
|
|||
#endif
|
||||
|
||||
/* compress 512-bits */
|
||||
static int
|
||||
sha256_compress(struct sha256_state *md, unsigned char *buf)
|
||||
static int sha256_compress(struct sha256_state *md, unsigned char *buf)
|
||||
{
|
||||
u32 S[8], W[64], t0, t1;
|
||||
u32 t;
|
||||
|
@ -202,8 +187,7 @@ 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;
|
||||
|
@ -224,9 +208,8 @@ 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;
|
||||
|
||||
|
@ -265,8 +248,7 @@ 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;
|
||||
|
||||
|
|
25
components/wpa_supplicant/src/crypto/sha256_i.h
Normal file
25
components/wpa_supplicant/src/crypto/sha256_i.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* SHA-256 internal definitions
|
||||
* Copyright (c) 2003-2011, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef SHA256_I_H
|
||||
#define SHA256_I_H
|
||||
|
||||
#define SHA256_BLOCK_SIZE 64
|
||||
|
||||
struct sha256_state {
|
||||
u64 length;
|
||||
u32 state[8], curlen;
|
||||
u8 buf[SHA256_BLOCK_SIZE];
|
||||
};
|
||||
|
||||
void sha256_init(struct sha256_state *md);
|
||||
int sha256_process(struct sha256_state *md, const unsigned char *in,
|
||||
unsigned long inlen);
|
||||
int sha256_done(struct sha256_state *md, unsigned char *out);
|
||||
|
||||
#endif /* SHA256_I_H */
|
Loading…
Reference in a new issue