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

WPA Supplicant / wrapper functions for libgcrypt. More...

#include "includes.h"
#include <gcrypt.h>
#include "common.h"
#include "crypto.h"

Data Structures

struct  crypto_cipher
 

Functions

int md4_vector (size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac)
 MD4 hash for data vector. More...
 
void des_encrypt (const u8 *clear, const u8 *key, u8 *cypher)
 Encrypt one block with DES. More...
 
int md5_vector (size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac)
 MD5 hash for data vector. More...
 
int sha1_vector (size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac)
 SHA-1 hash for data vector. More...
 
void * aes_encrypt_init (const u8 *key, size_t len)
 Initialize AES for encryption. More...
 
void aes_encrypt (void *ctx, const u8 *plain, u8 *crypt)
 Encrypt one AES block. More...
 
void aes_encrypt_deinit (void *ctx)
 Deinitialize AES encryption. More...
 
void * aes_decrypt_init (const u8 *key, size_t len)
 Initialize AES for decryption. More...
 
void aes_decrypt (void *ctx, const u8 *crypt, u8 *plain)
 Decrypt one AES block. More...
 
void aes_decrypt_deinit (void *ctx)
 Deinitialize AES decryption. More...
 
int crypto_mod_exp (const u8 *base, size_t base_len, const u8 *power, size_t power_len, const u8 *modulus, size_t modulus_len, u8 *result, size_t *result_len)
 Modular exponentiation of large integers. More...
 
struct crypto_ciphercrypto_cipher_init (enum crypto_cipher_alg alg, const u8 *iv, const u8 *key, size_t key_len)
 Initialize block/stream cipher function. More...
 
int crypto_cipher_encrypt (struct crypto_cipher *ctx, const u8 *plain, u8 *crypt, size_t len)
 Cipher encrypt. More...
 
int crypto_cipher_decrypt (struct crypto_cipher *ctx, const u8 *crypt, u8 *plain, size_t len)
 Cipher decrypt. More...
 
void crypto_cipher_deinit (struct crypto_cipher *ctx)
 Free cipher context. More...
 

Detailed Description

WPA Supplicant / wrapper functions for libgcrypt.

Function Documentation

void aes_decrypt ( void *  ctx,
const u8 *  crypt,
u8 *  plain 
)

Decrypt one AES block.

Parameters
ctxContext pointer from aes_encrypt_init()
cryptEncrypted data (16 bytes)
plainBuffer for the decrypted data (16 bytes)
void aes_decrypt_deinit ( void *  ctx)

Deinitialize AES decryption.

Parameters
ctxContext pointer from aes_encrypt_init()
void* aes_decrypt_init ( const u8 *  key,
size_t  len 
)

Initialize AES for decryption.

Parameters
keyDecryption key
lenKey length in bytes (usually 16, i.e., 128 bits)
Returns
Pointer to context data or NULL on failure
void aes_encrypt ( void *  ctx,
const u8 *  plain,
u8 *  crypt 
)

Encrypt one AES block.

Parameters
ctxContext pointer from aes_encrypt_init()
plainPlaintext data to be encrypted (16 bytes)
cryptBuffer for the encrypted data (16 bytes)
void aes_encrypt_deinit ( void *  ctx)

Deinitialize AES encryption.

Parameters
ctxContext pointer from aes_encrypt_init()
void* aes_encrypt_init ( const u8 *  key,
size_t  len 
)

Initialize AES for encryption.

Parameters
keyEncryption key
lenKey length in bytes (usually 16, i.e., 128 bits)
Returns
Pointer to context data or NULL on failure
int crypto_cipher_decrypt ( struct crypto_cipher ctx,
const u8 *  crypt,
u8 *  plain,
size_t  len 
)

Cipher decrypt.

Parameters
ctxContext pointer from crypto_cipher_init()
cryptCiphertext to decrypt
plainResulting plaintext
lenLength of the cipher text
Returns
0 on success, -1 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_cipher_deinit ( struct crypto_cipher ctx)

Free cipher context.

Parameters
ctxContext pointer from crypto_cipher_init()

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_cipher_encrypt ( struct crypto_cipher ctx,
const u8 *  plain,
u8 *  crypt,
size_t  len 
)

Cipher encrypt.

Parameters
ctxContext pointer from crypto_cipher_init()
plainPlaintext to cipher
cryptResulting ciphertext
lenLength of the plaintext
Returns
0 on success, -1 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.

struct crypto_cipher* crypto_cipher_init ( enum crypto_cipher_alg  alg,
const u8 *  iv,
const u8 *  key,
size_t  key_len 
)

Initialize block/stream cipher function.

Parameters
algCipher algorithm
ivInitialization vector for block ciphers or NULL for stream ciphers
keyCipher key
key_lenLength of key in bytes
Returns
Pointer to cipher context to use with other cipher 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.

int crypto_mod_exp ( const u8 *  base,
size_t  base_len,
const u8 *  power,
size_t  power_len,
const u8 *  modulus,
size_t  modulus_len,
u8 *  result,
size_t *  result_len 
)

Modular exponentiation of large integers.

Parameters
baseBase integer (big endian byte array)
base_lenLength of base integer in bytes
powerPower integer (big endian byte array)
power_lenLength of power integer in bytes
modulusModulus integer (big endian byte array)
modulus_lenLength of modulus integer in bytes
resultBuffer for the result
result_lenResult length (max buffer size on input, real len on output)
Returns
0 on success, -1 on failure

This function calculates result = base ^ power mod modulus. modules_len is used as the maximum size of modulus buffer. It is set to the used size on success.

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 des_encrypt ( const u8 *  clear,
const u8 *  key,
u8 *  cypher 
)

Encrypt one block with DES.

Parameters
clear8 octets (in)
key7 octets (in) (no parity bits included)
cypher8 octets (out)
int md4_vector ( size_t  num_elem,
const u8 *  addr[],
const size_t *  len,
u8 *  mac 
)

MD4 hash for data vector.

Parameters
num_elemNumber of elements in the data vector
addrPointers to the data areas
lenLengths of the data blocks
macBuffer for the hash
Returns
0 on success, -1 on failure
int md5_vector ( size_t  num_elem,
const u8 *  addr[],
const size_t *  len,
u8 *  mac 
)

MD5 hash for data vector.

Parameters
num_elemNumber of elements in the data vector
addrPointers to the data areas
lenLengths of the data blocks
macBuffer for the hash
Returns
0 on success, -1 on failure
int sha1_vector ( size_t  num_elem,
const u8 *  addr[],
const size_t *  len,
u8 *  mac 
)

SHA-1 hash for data vector.

Parameters
num_elemNumber of elements in the data vector
addrPointers to the data areas
lenLengths of the data blocks
macBuffer for the hash
Returns
0 on success, -1 on failure