Merge branch 'bugfix/fix_errors_with_mbedtls_disabled_v4.0' into 'release/v4.0'
wpa_supplicant: Fix compilation errors when USE_MBEDTLS is disabled. (v4.0) See merge request espressif/esp-idf!8357
This commit is contained in:
commit
8972461611
3 changed files with 37 additions and 28 deletions
|
@ -28,6 +28,8 @@
|
||||||
#include "md5_i.h"
|
#include "md5_i.h"
|
||||||
#ifdef USE_MBEDTLS_CRYPTO
|
#ifdef USE_MBEDTLS_CRYPTO
|
||||||
#include "mbedtls/sha256.h"
|
#include "mbedtls/sha256.h"
|
||||||
|
#else
|
||||||
|
#include "sha256_i.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct crypto_hash {
|
struct crypto_hash {
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "mbedtls/sha256.h"
|
#include "mbedtls/sha256.h"
|
||||||
#else /* USE_MBEDTLS_CRYPTO */
|
#else /* USE_MBEDTLS_CRYPTO */
|
||||||
#include "sha256.h"
|
#include "sha256.h"
|
||||||
|
#include "sha256_i.h"
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
#endif /* USE_MBEDTLS_CRYPTO */
|
#endif /* USE_MBEDTLS_CRYPTO */
|
||||||
|
|
||||||
|
@ -79,20 +80,6 @@ out:
|
||||||
}
|
}
|
||||||
#else /* USE_MBEDTLS_CRYPTO */
|
#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
|
* sha256_vector - SHA256 hash for data vector
|
||||||
* @num_elem: Number of elements in the 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
|
* @mac: Buffer for the hash
|
||||||
* Returns: 0 on success, -1 of failure
|
* Returns: 0 on success, -1 of failure
|
||||||
*/
|
*/
|
||||||
int
|
int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
||||||
sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
|
|
||||||
u8 *mac)
|
u8 *mac)
|
||||||
{
|
{
|
||||||
struct sha256_state ctx;
|
struct sha256_state ctx;
|
||||||
|
@ -158,8 +144,7 @@ static const unsigned long K[64] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* compress 512-bits */
|
/* compress 512-bits */
|
||||||
static int
|
static int sha256_compress(struct sha256_state *md, unsigned char *buf)
|
||||||
sha256_compress(struct sha256_state *md, unsigned char *buf)
|
|
||||||
{
|
{
|
||||||
u32 S[8], W[64], t0, t1;
|
u32 S[8], W[64], t0, t1;
|
||||||
u32 t;
|
u32 t;
|
||||||
|
@ -202,8 +187,7 @@ sha256_compress(struct sha256_state *md, unsigned char *buf)
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the hash state */
|
/* Initialize the hash state */
|
||||||
static void
|
void sha256_init(struct sha256_state *md)
|
||||||
sha256_init(struct sha256_state *md)
|
|
||||||
{
|
{
|
||||||
md->curlen = 0;
|
md->curlen = 0;
|
||||||
md->length = 0;
|
md->length = 0;
|
||||||
|
@ -224,8 +208,7 @@ sha256_init(struct sha256_state *md)
|
||||||
@param inlen The length of the data (octets)
|
@param inlen The length of the data (octets)
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
*/
|
*/
|
||||||
static int
|
int sha256_process(struct sha256_state *md, const unsigned char *in,
|
||||||
sha256_process(struct sha256_state *md, const unsigned char *in,
|
|
||||||
unsigned long inlen)
|
unsigned long inlen)
|
||||||
{
|
{
|
||||||
unsigned long n;
|
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)
|
@param out [out] The destination of the hash (32 bytes)
|
||||||
@return CRYPT_OK if successful
|
@return CRYPT_OK if successful
|
||||||
*/
|
*/
|
||||||
static int
|
int sha256_done(struct sha256_state *md, unsigned char *out)
|
||||||
sha256_done(struct sha256_state *md, unsigned char *out)
|
|
||||||
{
|
{
|
||||||
int i;
|
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