libcoap 4.3.4
oscore_cose.c File Reference

An implementation of the CBOR Object Signing and Encryption (RFC). More...

#include "coap3/coap_internal.h"
#include "stdio.h"
+ Include dependency graph for oscore_cose.c:

Go to the source code of this file.

Data Structures

struct  cose_curve_desc
 
struct  cose_alg_desc
 
struct  cose_hkdf_alg_desc
 
struct  hkdf_hmac_algs
 

Functions

const char * cose_get_curve_name (cose_curve_t id, char *buffer, size_t buflen)
 
cose_curve_t cose_get_curve_id (const char *name)
 
const char * cose_get_alg_name (cose_alg_t id, char *buffer, size_t buflen)
 
cose_alg_t cose_get_alg_id (const char *name)
 
const char * cose_get_hkdf_alg_name (cose_hkdf_alg_t id, char *buffer, size_t buflen)
 
int cose_get_hmac_alg_for_hkdf (cose_hkdf_alg_t hkdf_alg, cose_hmac_alg_t *hmac_alg)
 
size_t cose_tag_len (cose_alg_t cose_alg)
 
size_t cose_hash_len (cose_alg_t cose_alg)
 
size_t cose_nonce_len (cose_alg_t cose_alg)
 
size_t cose_key_len (cose_alg_t cose_alg)
 
size_t cose_encrypt0_encode (cose_encrypt0_t *ptr, uint8_t *buffer, size_t buf_len)
 
int cose_encrypt0_decode (cose_encrypt0_t *ptr, uint8_t *buffer, size_t size)
 
void cose_encrypt0_init (cose_encrypt0_t *ptr)
 
void cose_encrypt0_set_alg (cose_encrypt0_t *ptr, uint8_t alg)
 
void cose_encrypt0_set_ciphertext (cose_encrypt0_t *ptr, uint8_t *buffer, size_t size)
 
void cose_encrypt0_set_plaintext (cose_encrypt0_t *ptr, uint8_t *buffer, size_t size)
 
int cose_encrypt0_get_plaintext (cose_encrypt0_t *ptr, uint8_t **buffer)
 
void cose_encrypt0_set_partial_iv (cose_encrypt0_t *ptr, coap_bin_const_t *partial_iv)
 
coap_bin_const_t cose_encrypt0_get_partial_iv (cose_encrypt0_t *ptr)
 
void cose_encrypt0_set_key_id (cose_encrypt0_t *ptr, coap_bin_const_t *key_id)
 
size_t cose_encrypt0_get_key_id (cose_encrypt0_t *ptr, const uint8_t **buffer)
 
size_t cose_encrypt0_get_kid_context (cose_encrypt0_t *ptr, const uint8_t **buffer)
 
void cose_encrypt0_set_kid_context (cose_encrypt0_t *ptr, coap_bin_const_t *kid_context)
 
void cose_encrypt0_set_external_aad (cose_encrypt0_t *ptr, coap_bin_const_t *external_aad)
 
void cose_encrypt0_set_aad (cose_encrypt0_t *ptr, coap_bin_const_t *aad)
 
int cose_encrypt0_set_key (cose_encrypt0_t *ptr, coap_bin_const_t *key)
 
void cose_encrypt0_set_nonce (cose_encrypt0_t *ptr, coap_bin_const_t *nonce)
 
int cose_encrypt0_encrypt (cose_encrypt0_t *ptr, uint8_t *ciphertext_buffer, size_t ciphertext_len)
 
int cose_encrypt0_decrypt (cose_encrypt0_t *ptr, uint8_t *plaintext_buffer, size_t plaintext_len)
 

Variables

static struct cose_curve_desc curve_mapping []
 
static struct cose_alg_desc alg_mapping []
 
static struct cose_hkdf_alg_desc hkdf_alg_mapping []
 
static struct hkdf_hmac_algs hkdf_hmacs []
 

Detailed Description

An implementation of the CBOR Object Signing and Encryption (RFC).

Author
Martin Gunnarsson marti.nosp@m.n.gu.nosp@m.nnars.nosp@m.son@.nosp@m.ri.se added sign1 addition for coaplib Peter van der Stok <consu.nosp@m.ltan.nosp@m.cy@va.nosp@m.nder.nosp@m.stok..nosp@m.org > adapted for libcoap integration Jon Shallow supjp.nosp@m.s-li.nosp@m.bcoap.nosp@m.@jps.nosp@m.hallo.nosp@m.w.co.nosp@m.m

Definition in file oscore_cose.c.

Function Documentation

◆ cose_encrypt0_decode()

int cose_encrypt0_decode ( cose_encrypt0_t ptr,
uint8_t *  buffer,
size_t  size 
)

◆ cose_encrypt0_get_plaintext()

int cose_encrypt0_get_plaintext ( cose_encrypt0_t ptr,
uint8_t **  buffer 
)

Variable Documentation

◆ alg_mapping

struct cose_alg_desc alg_mapping[]
static
Initial value:
= {
{ "ES256K", COSE_ALGORITHM_ES256K },
{ "SHA-512", COSE_ALGORITHM_SHA_512 },
{ "SHA-384", COSE_ALGORITHM_SHA_384 },
{ "ES512", COSE_ALGORITHM_ES512 },
{ "ES384", COSE_ALGORITHM_ES384 },
{ "ECDH-SS + HKDF-256", COSE_ALGORITHM_ECDH_SS_HKDF_256 },
{ "SHA-512/256", COSE_ALGORITHM_SHA_512_256 },
{ "SHA-256/64", COSE_ALGORITHM_SHA_256_64 },
{ "SHA-1", COSE_ALGORITHM_SHA_1 },
{ "direct+HKDF-SHA-512", COSE_ALGORITHM_HKDF_SHA_512 },
{ "direct+HKDF-SHA-256", COSE_ALGORITHM_HKDF_SHA_256 },
{ "EdDSA", COSE_ALGORITHM_EDDSA },
{ "ES256", COSE_ALGORITHM_ES256 },
{ "HMAC 256/64", COSE_ALGORITHM_HMAC256_64 },
{ "HMAC 256/256", COSE_ALGORITHM_HMAC256_256 },
{ "HMAC 384/384", COSE_ALGORITHM_HMAC384_384 },
{ "HMAC 512/512", COSE_ALGORITHM_HMAC512_512 },
{ "AES-CCM-16-64-128", COSE_ALGORITHM_AES_CCM_16_64_128 },
{ "AES-CCM-16-64-256", COSE_ALGORITHM_AES_CCM_16_64_256 },
{ "AES-CCM-64-64-128", COSE_ALGORITHM_AES_CCM_64_64_128 },
{ "AES-CCM-64-64-256", COSE_ALGORITHM_AES_CCM_64_64_256 },
{ "ChaCha20/Poly1305", COSE_ALGORITHM_CHACHA20_P1035 },
{ "AES-CCM-16-128-128", COSE_ALGORITHM_AES_CCM_16_128_128 },
{ "AES-CCM-16-128-256", COSE_ALGORITHM_AES_CCM_16_128_256 },
{ "AES-CCM-64-128-128", COSE_ALGORITHM_AES_CCM_64_128_128 },
{ "AES-CCM-64-128-256", COSE_ALGORITHM_AES_CCM_64_128_256 },
}
@ COSE_ALGORITHM_HMAC256_256
Definition: oscore_cose.h:142
@ COSE_ALGORITHM_AES_CCM_16_128_256
Definition: oscore_cose.h:151
@ COSE_ALGORITHM_ECDH_SS_HKDF_256
Definition: oscore_cose.h:132
@ COSE_ALGORITHM_HMAC512_512
Definition: oscore_cose.h:144
@ COSE_ALGORITHM_SHA_256_64
Definition: oscore_cose.h:135
@ COSE_ALGORITHM_SHA_512_256
Definition: oscore_cose.h:133
@ COSE_ALGORITHM_ES384
Definition: oscore_cose.h:131
@ COSE_ALGORITHM_AES_CCM_64_64_128
Definition: oscore_cose.h:147
@ COSE_ALGORITHM_CHACHA20_P1035
Definition: oscore_cose.h:149
@ COSE_ALGORITHM_HKDF_SHA_512
Definition: oscore_cose.h:137
@ COSE_ALGORITHM_AES_CCM_16_128_128
Definition: oscore_cose.h:150
@ COSE_ALGORITHM_AES_CCM_64_128_256
Definition: oscore_cose.h:153
@ COSE_ALGORITHM_SHA_256_256
Definition: oscore_cose.h:134
@ COSE_ALGORITHM_SHA_1
Definition: oscore_cose.h:136
@ COSE_ALGORITHM_EDDSA
Definition: oscore_cose.h:139
@ COSE_ALGORITHM_HMAC256_64
Definition: oscore_cose.h:141
@ COSE_ALGORITHM_ES256
Definition: oscore_cose.h:140
@ COSE_ALGORITHM_AES_CCM_64_64_256
Definition: oscore_cose.h:148
@ COSE_ALGORITHM_HKDF_SHA_256
Definition: oscore_cose.h:138
@ COSE_ALGORITHM_AES_CCM_16_64_128
Definition: oscore_cose.h:145
@ COSE_ALGORITHM_ES512
Definition: oscore_cose.h:130
@ COSE_ALGORITHM_HMAC384_384
Definition: oscore_cose.h:143
@ COSE_ALGORITHM_SHA_512
Definition: oscore_cose.h:128
@ COSE_ALGORITHM_AES_CCM_64_128_128
Definition: oscore_cose.h:152
@ COSE_ALGORITHM_AES_CCM_16_64_256
Definition: oscore_cose.h:146
@ COSE_ALGORITHM_ES256K
Definition: oscore_cose.h:127
@ COSE_ALGORITHM_SHA_384
Definition: oscore_cose.h:129

Definition at line 89 of file oscore_cose.c.

◆ curve_mapping

struct cose_curve_desc curve_mapping[]
static
Initial value:
= {
{ "P-256", COSE_CURVE_P_256 },
{ "X25519", COSE_CURVE_X25519 },
{ "X448", COSE_CURVE_X448 },
{ "Ed25519", COSE_CURVE_ED25519 },
{ "Ed448", COSE_CURVE_ED448 },
{ "secp256k1", COSE_CURVE_SECP256K1 },
}
@ COSE_CURVE_X25519
Definition: oscore_cose.h:62
@ COSE_CURVE_ED448
Definition: oscore_cose.h:65
@ COSE_CURVE_P_256
Definition: oscore_cose.h:61
@ COSE_CURVE_SECP256K1
Definition: oscore_cose.h:66
@ COSE_CURVE_ED25519
Definition: oscore_cose.h:64
@ COSE_CURVE_X448
Definition: oscore_cose.h:63

Definition at line 54 of file oscore_cose.c.

◆ hkdf_alg_mapping

struct cose_hkdf_alg_desc hkdf_alg_mapping[]
static
Initial value:
= {
{ "direct+HKDF-SHA-512", COSE_HKDF_ALG_HKDF_SHA_512 },
{ "direct+HKDF-SHA-256", COSE_HKDF_ALG_HKDF_SHA_256 },
}
@ COSE_HKDF_ALG_HKDF_SHA_256
Definition: oscore_cose.h:167
@ COSE_HKDF_ALG_HKDF_SHA_512
Definition: oscore_cose.h:166

Definition at line 145 of file oscore_cose.c.

◆ hkdf_hmacs

struct hkdf_hmac_algs hkdf_hmacs[]
static