libcoap
4.3.5
Toggle main menu visibility
Loading...
Searching...
No Matches
coap_crypto_internal.h
Go to the documentation of this file.
1
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
3
/*
4
* coap_crypto_internal.h -- Structures, Enums & Functions that are not
5
* exposed to application programming
6
*
7
* Copyright (C) 2017-2024 Olaf Bergmann <bergmann@tzi.org>
8
* Copyright (C) 2021-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
9
*
10
* SPDX-License-Identifier: BSD-2-Clause
11
*
12
* This file is part of the CoAP library libcoap. Please see README for terms
13
* of use.
14
*/
15
20
21
#ifndef COAP_CRYPTO_INTERNAL_H_
22
#define COAP_CRYPTO_INTERNAL_H_
23
30
31
#include "
oscore/oscore_cose.h
"
32
33
#ifndef COAP_CRYPTO_MAX_KEY_SIZE
34
#define COAP_CRYPTO_MAX_KEY_SIZE (32)
35
#endif
/* COAP_CRYPTO_MAX_KEY_SIZE */
36
37
#ifndef COAP_OSCORE_DEFAULT_REPLAY_WINDOW
38
#define COAP_OSCORE_DEFAULT_REPLAY_WINDOW 32
39
#endif
/* COAP_OSCORE_DEFAULT_REPLAY_WINDOW */
40
44
typedef
coap_bin_const_t
coap_crypto_key_t
;
45
49
typedef
struct
coap_crypto_aes_ccm_t
{
50
coap_crypto_key_t
key
;
51
const
uint8_t *
nonce
;
52
size_t
tag_len
;
53
size_t
l
;
54
}
coap_crypto_aes_ccm_t
;
55
59
typedef
struct
coap_crypto_param_t
{
60
cose_alg_t
alg
;
61
union
{
62
coap_crypto_aes_ccm_t
aes
;
63
coap_crypto_key_t
key
;
64
}
params
;
65
}
coap_crypto_param_t
;
66
75
int
coap_crypto_check_cipher_alg
(
cose_alg_t
alg);
76
85
int
coap_crypto_check_hkdf_alg
(
cose_hkdf_alg_t
hkdf_alg);
86
99
int
coap_crypto_aead_encrypt
(
const
coap_crypto_param_t
*params,
100
coap_bin_const_t
*data,
101
coap_bin_const_t
*aad,
102
uint8_t *result,
103
size_t
*max_result_len);
104
117
int
coap_crypto_aead_decrypt
(
const
coap_crypto_param_t
*params,
118
coap_bin_const_t
*data,
119
coap_bin_const_t
*aad,
120
uint8_t *result,
121
size_t
*max_result_len);
122
135
int
coap_crypto_hmac
(
cose_hmac_alg_t
hmac_alg,
136
coap_bin_const_t
*key,
137
coap_bin_const_t
*data,
138
coap_bin_const_t
**hmac);
139
151
int
coap_crypto_hash
(
cose_alg_t
alg,
152
const
coap_bin_const_t
*data,
153
coap_bin_const_t
**hash);
154
156
157
#endif
/* COAP_CRYPTO_INTERNAL_H_ */
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.
coap_crypto_key_t
coap_bin_const_t coap_crypto_key_t
The structure that holds the Crypto Key.
Definition
coap_crypto_internal.h:44
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.
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.
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.
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.
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.
cose_hkdf_alg_t
cose_hkdf_alg_t
Definition
oscore_cose.h:165
cose_hmac_alg_t
cose_hmac_alg_t
Definition
oscore_cose.h:157
cose_alg_t
cose_alg_t
Definition
oscore_cose.h:126
oscore_cose.h
An implementation of the CBOR Object Signing and Encryption (RFC).
coap_bin_const_t
CoAP binary data definition with const data.
Definition
coap_str.h:64
coap_crypto_aes_ccm_t
The structure that holds the AES Crypto information.
Definition
coap_crypto_internal.h:49
coap_crypto_aes_ccm_t::l
size_t l
The number of bytes in the length field.
Definition
coap_crypto_internal.h:53
coap_crypto_aes_ccm_t::nonce
const uint8_t * nonce
must be exactly 15 - l bytes
Definition
coap_crypto_internal.h:51
coap_crypto_aes_ccm_t::key
coap_crypto_key_t key
The Key to use.
Definition
coap_crypto_internal.h:50
coap_crypto_aes_ccm_t::tag_len
size_t tag_len
The size of the Tag.
Definition
coap_crypto_internal.h:52
coap_crypto_param_t
The common structure that holds the Crypto information.
Definition
coap_crypto_internal.h:59
coap_crypto_param_t::params
union coap_crypto_param_t::@323105312043053065140047140057231126200165175123 params
coap_crypto_param_t::key
coap_crypto_key_t key
The key to use.
Definition
coap_crypto_internal.h:63
coap_crypto_param_t::aes
coap_crypto_aes_ccm_t aes
Used if AES type encryption.
Definition
coap_crypto_internal.h:62
coap_crypto_param_t::alg
cose_alg_t alg
The COSE algorith to use.
Definition
coap_crypto_internal.h:60
include
coap3
coap_crypto_internal.h
Generated on
for libcoap by
1.17.0