libcoap 4.3.2rc2

Data Structures | Macros | Typedefs | Functions
OSCORE Crypto Support
Libcoap Internal API

Internal API for interfacing with Crypto libraries. More...

## Data Structures
struct | coap_crypto_aes_ccm_t
| The structure that holds the AES Crypto information. More...
struct | coap_crypto_param_t
| The common structure that holds the Crypto information. More...

## Macros
#define | COAP_CRYPTO_MAX_KEY_SIZE (32)
#define | COAP_OSCORE_DEFAULT_REPLAY_WINDOW 32

## Typedefs
typedef coap_bin_const_t | coap_crypto_key_t
| The structure that holds the Crypto Key. More...
typedef struct coap_crypto_aes_ccm_t | coap_crypto_aes_ccm_t
| The structure that holds the AES Crypto information. More...
typedef struct coap_crypto_param_t | coap_crypto_param_t
| The common structure that holds the Crypto information. More...

## Functions
int | coap_crypto_check_cipher_alg (cose_alg_t alg)
| Check whether the defined cipher algorithm is supported by the underlying crypto library. More...
int | coap_crypto_check_hkdf_alg (cose_hkdf_alg_t hkdf_alg)
| Check whether the defined hkdf algorithm is supported by the underlying crypto library. More...
int | coap_crypto_aead_encrypt (const coap_crypto_param_t *params, coap_bin_const_t *data, coap_bin_const_t *aad, uint8_t *result, size_t *max_result_len)
| Encrypt the provided plaintext data. More...
int | coap_crypto_aead_decrypt (const coap_crypto_param_t *params, coap_bin_const_t *data, coap_bin_const_t *aad, uint8_t *result, size_t *max_result_len)
| Decrypt the provided encrypted data into plaintext. More...
int | coap_crypto_hmac (cose_hmac_alg_t hmac_alg, coap_bin_const_t *key, coap_bin_const_t *data, coap_bin_const_t **hmac)
| Create a HMAC hash of the provided data. More...
int | coap_crypto_hash (cose_alg_t alg, const coap_bin_const_t *data, coap_bin_const_t **hash)
| Create a hash of the provided data. More...

## Detailed Description

Internal API for interfacing with Crypto libraries.

## Macro Definition Documentation

## ◆ COAP_CRYPTO_MAX_KEY_SIZE

#define COAP_CRYPTO_MAX_KEY_SIZE (32)

Definition at line 34 of file coap_crypto_internal.h.

## ◆ COAP_OSCORE_DEFAULT_REPLAY_WINDOW

#define COAP_OSCORE_DEFAULT_REPLAY_WINDOW 32

Definition at line 38 of file coap_crypto_internal.h.

## Typedef Documentation

## ◆ coap_crypto_aes_ccm_t

typedef struct coap_crypto_aes_ccm_t coap_crypto_aes_ccm_t

The structure that holds the AES Crypto information.

## ◆ coap_crypto_key_t

typedef coap_bin_const_t coap_crypto_key_t

The structure that holds the Crypto Key.

Definition at line 44 of file coap_crypto_internal.h.

## ◆ coap_crypto_param_t

typedef struct coap_crypto_param_t coap_crypto_param_t

The common structure that holds the Crypto information.

## Function Documentation

## ◆ coap_crypto_aead_decrypt()

int coap_crypto_aead_decrypt | ( | const coap_crypto_param_t * | params,
|  | coap_bin_const_t * | data,
|  | coap_bin_const_t * | aad,
|  | uint8_t * | result,
|  | size_t * | max_result_len
| ) |  |

Decrypt the provided encrypted data into plaintext.

Parameters

  params | The Encrypt/Decrypt/Hash paramaters.
  data | The data to decrypt.
  aad | The additional AAD information.
  result | Where to put the decrypted data.
  max_result_len | The maximum size for `result` (updated with actual size).

Returns
  `1` if the data was successfully decrypted, else `0`.

## ◆ coap_crypto_aead_encrypt()

int coap_crypto_aead_encrypt | ( | const coap_crypto_param_t * | params,
|  | coap_bin_const_t * | data,
|  | coap_bin_const_t * | aad,
|  | uint8_t * | result,
|  | size_t * | max_result_len
| ) |  |

Encrypt the provided plaintext data.

Parameters

  params | The Encrypt/Decrypt/Hash paramaters.
  data | The data to encrypt.
  aad | The additional AAD information.
  result | Where to put the encrypted data.
  max_result_len | The maximum size for `result` (updated with actual size).

Returns
  `1` if the data was successfully encrypted, else `0`.

## ◆ coap_crypto_check_cipher_alg()

int coap_crypto_check_cipher_alg | ( | cose_alg_t | alg | ) |

Check whether the defined cipher algorithm is supported by the underlying crypto library.

Parameters

  alg | The COSE algorithm to check.

Returns
  `1` if there is support, else `0`.

## ◆ coap_crypto_check_hkdf_alg()

int coap_crypto_check_hkdf_alg | ( | cose_hkdf_alg_t | hkdf_alg | ) |

Check whether the defined hkdf algorithm is supported by the underlying crypto library.

Parameters

  hkdf_alg | The COSE HKDF algorithm to check.

Returns
  `1` if there is support, else `0`.

## ◆ coap_crypto_hash()

int coap_crypto_hash | ( | cose_alg_t | alg,
|  | const coap_bin_const_t * | data,
|  | coap_bin_const_t ** | hash
| ) |  |

Create a hash of the provided data.

Parameters

  alg | The hash algorithm.
  data | The data to hash.
  hash | Where to put the hash result if successful.

Returns
  `1` if the data was successfully hashed, else `0`. It is the responsibility of the caller to release the created hash.

## ◆ coap_crypto_hmac()

int coap_crypto_hmac | ( | cose_hmac_alg_t | hmac_alg,
|  | coap_bin_const_t * | key,
|  | coap_bin_const_t * | data,
|  | coap_bin_const_t ** | hmac
| ) |  |

Create a HMAC hash of the provided data.

Parameters

  hmac_alg | The COSE HMAC algorithm to use.
  key | The key to use for the hash.
  data | The data to hash.
  hmac | Where to put the created hmac result if successful.

Returns
  `1` if the hmac of the data was successful, else `0`. It is the responsibility of the caller to release the created hmac.