wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Functions
crypto_internal.c File Reference

Crypto wrapper for internal crypto implementation. More...

#include "includes.h"
#include "common.h"
#include "crypto.h"
#include "sha256_i.h"
#include "sha1_i.h"
#include "md5_i.h"

Data Structures

struct  crypto_hash
 

Functions

struct crypto_hashcrypto_hash_init (enum crypto_hash_alg alg, const u8 *key, size_t key_len)
 Initialize hash/HMAC function. More...
 
void crypto_hash_update (struct crypto_hash *ctx, const u8 *data, size_t len)
 Add data to hash calculation. More...
 
int crypto_hash_finish (struct crypto_hash *ctx, u8 *mac, size_t *len)
 Complete hash calculation. More...
 
int crypto_global_init (void)
 Initialize crypto wrapper. More...
 
void crypto_global_deinit (void)
 Deinitialize crypto wrapper. More...
 

Detailed Description

Crypto wrapper for internal crypto implementation.

Function Documentation

void crypto_global_deinit ( void  )

Deinitialize crypto wrapper.

This function is only used with internal TLSv1 implementation (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need to implement this.

int crypto_global_init ( void  )

Initialize crypto wrapper.

This function is only used with internal TLSv1 implementation (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need to implement this.

int crypto_hash_finish ( struct crypto_hash ctx,
u8 *  hash,
size_t *  len 
)

Complete hash calculation.

Parameters
ctxContext pointer from crypto_hash_init()
hashBuffer for hash value or NULL if caller is just freeing the hash context
lenPointer to length of the buffer or NULL if caller is just freeing the hash context; on return, this is set to the actual length of the hash value
Returns
0 on success, -1 if buffer is too small (len set to needed length), or -2 on other failures (including failed crypto_hash_update() operations)

This function calculates the hash value and frees the context buffer that was used for hash calculation.

This function is only used with internal TLSv1 implementation (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need to implement this.

struct crypto_hash* crypto_hash_init ( enum crypto_hash_alg  alg,
const u8 *  key,
size_t  key_len 
)

Initialize hash/HMAC function.

Parameters
algHash algorithm
keyKey for keyed hash (e.g., HMAC) or NULL if not needed
key_lenLength of the key in bytes
Returns
Pointer to hash context to use with other hash functions or NULL on failure

This function is only used with internal TLSv1 implementation (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need to implement this.

void crypto_hash_update ( struct crypto_hash ctx,
const u8 *  data,
size_t  len 
)

Add data to hash calculation.

Parameters
ctxContext pointer from crypto_hash_init()
dataData buffer to add
lenLength of the buffer

This function is only used with internal TLSv1 implementation (CONFIG_TLS=internal). If that is not used, the crypto wrapper does not need to implement this.