12#ifndef __T_COSE_SIGN1_H__
13#define __T_COSE_SIGN1_H__
17#include "qcbor/qcbor.h"
71 struct q_useful_buf_c protected_parameters;
72 int32_t cose_algorithm_id;
74 uint32_t option_flags;
75 struct q_useful_buf_c kid;
76#ifndef T_COSE_DISABLE_CONTENT_TYPE
77 uint32_t content_type_uint;
78 const char * content_type_tstr;
81#ifndef T_COSE_DISABLE_EDDSA
93 size_t auxiliary_buffer_size;
120#define T_COSE_OPT_SHORT_CIRCUIT_SIG 0x00000001
133#define T_COSE_OPT_OMIT_CBOR_TAG 0x00000002
162 uint32_t option_flags,
163 int32_t cose_algorithm_id);
187 struct q_useful_buf_c kid);
212 struct q_useful_buf auxiliary_buffer);
238#ifndef T_COSE_DISABLE_CONTENT_TYPE
256 uint16_t content_type);
276 const char *content_type);
330 struct q_useful_buf_c payload,
331 struct q_useful_buf out_buf,
332 struct q_useful_buf_c *result);
356 struct q_useful_buf_c aad,
357 struct q_useful_buf_c payload,
358 struct q_useful_buf out_buf,
359 struct q_useful_buf_c *result);
384 struct q_useful_buf_c aad,
385 struct q_useful_buf_c detached_payload,
386 struct q_useful_buf out_buf,
387 struct q_useful_buf_c *result);
428 QCBOREncodeContext *cbor_encode_ctx);
449 QCBOREncodeContext *cbor_encode_ctx);
473 struct q_useful_buf_c aad,
474 QCBOREncodeContext *cbor_encode_ctx);
486 uint32_t option_flags,
487 int32_t cose_algorithm_id)
489 memset(me, 0,
sizeof(*me));
490#ifndef T_COSE_DISABLE_CONTENT_TYPE
494 me->cose_algorithm_id = cose_algorithm_id;
495 me->option_flags = option_flags;
497#ifndef T_COSE_DISABLE_EDDSA
509 struct q_useful_buf_c kid)
512 me->signing_key = signing_key;
517 struct q_useful_buf auxiliary_buffer)
519#ifndef T_COSE_DISABLE_EDDSA
523 (void)auxiliary_buffer;
530#ifndef T_COSE_DISABLE_EDDSA
531 return me->auxiliary_buffer_size;
557 bool payload_is_detached,
558 QCBOREncodeContext *cbor_encode_ctx);
563 QCBOREncodeContext *cbor_encode_ctx)
593 struct q_useful_buf_c aad,
594 struct q_useful_buf_c detached_payload,
595 QCBOREncodeContext *cbor_encode_ctx);
620 bool payload_is_detached,
621 struct q_useful_buf_c aad,
622 struct q_useful_buf_c payload,
623 struct q_useful_buf out_buf,
624 struct q_useful_buf_c *result);
629 struct q_useful_buf_c aad,
630 struct q_useful_buf_c payload,
631 struct q_useful_buf out_buf,
632 struct q_useful_buf_c *result)
645 struct q_useful_buf_c payload,
646 struct q_useful_buf out_buf,
647 struct q_useful_buf_c *result)
660 struct q_useful_buf_c aad,
661 struct q_useful_buf_c detached_payload,
662 struct q_useful_buf out_buf,
663 struct q_useful_buf_c *result)
676 struct q_useful_buf_c aad,
677 QCBOREncodeContext *cbor_encode_ctx)
688 QCBOREncodeContext *cbor_encode_ctx)
697#ifndef T_COSE_DISABLE_CONTENT_TYPE
700 uint16_t content_type)
702 me->content_type_uint = content_type;
708 const char *content_type)
710 me->content_type_tstr = content_type;
This is a TF-M coding style version of UsefulBuf. See UsefulBuf for documentation of these functions.
Definition t_cose_common.h:186
Definition t_cose_sign1_sign.h:69
struct q_useful_buf auxiliary_buffer
Definition t_cose_sign1_sign.h:87
This file contains definitions common to all public t_cose interfaces.
t_cose_err_t
Definition t_cose_common.h:250
#define T_COSE_EMPTY_UINT_CONTENT_TYPE
Definition t_cose_common.h:441
static void t_cose_sign1_set_signing_key(struct t_cose_sign1_sign_ctx *context, struct t_cose_key signing_key, struct q_useful_buf_c kid)
Set the key and kid (key ID) for signing.
Definition t_cose_sign1_sign.h:507
static enum t_cose_err_t t_cose_sign1_sign(struct t_cose_sign1_sign_ctx *context, struct q_useful_buf_c payload, struct q_useful_buf out_buf, struct q_useful_buf_c *result)
Create and sign a COSE_Sign1 message with a payload in one call.
Definition t_cose_sign1_sign.h:644
enum t_cose_err_t t_cose_sign1_sign_aad_internal(struct t_cose_sign1_sign_ctx *context, bool payload_is_detached, struct q_useful_buf_c aad, struct q_useful_buf_c payload, struct q_useful_buf out_buf, struct q_useful_buf_c *result)
Semi-private function that does a complete signing in one call.
static enum t_cose_err_t t_cose_sign1_sign_detached(struct t_cose_sign1_sign_ctx *context, struct q_useful_buf_c aad, struct q_useful_buf_c detached_payload, struct q_useful_buf out_buf, struct q_useful_buf_c *result)
Create and sign a COSE_Sign1 message with detached payload in one call.
Definition t_cose_sign1_sign.h:659
static enum t_cose_err_t t_cose_sign1_encode_signature(struct t_cose_sign1_sign_ctx *context, QCBOREncodeContext *cbor_encode_ctx)
Finish a COSE_Sign1 message by outputting the signature.
Definition t_cose_sign1_sign.h:687
static void t_cose_sign1_set_content_type_uint(struct t_cose_sign1_sign_ctx *context, uint16_t content_type)
Set the payload content type using CoAP content types.
Definition t_cose_sign1_sign.h:699
static void t_cose_sign1_sign_set_auxiliary_buffer(struct t_cose_sign1_sign_ctx *context, struct q_useful_buf auxiliary_buffer)
Configure an auxiliary buffer used to serialize the Sig_Structure.
Definition t_cose_sign1_sign.h:516
static size_t t_cose_sign1_sign_auxiliary_buffer_size(struct t_cose_sign1_sign_ctx *context)
Get the required auxiliary buffer size for the most recent signing operation.
Definition t_cose_sign1_sign.h:528
static void t_cose_sign1_sign_init(struct t_cose_sign1_sign_ctx *context, uint32_t option_flags, int32_t cose_algorithm_id)
Initialize to start creating a COSE_Sign1.
Definition t_cose_sign1_sign.h:485
static enum t_cose_err_t t_cose_sign1_sign_aad(struct t_cose_sign1_sign_ctx *context, struct q_useful_buf_c aad, struct q_useful_buf_c payload, struct q_useful_buf out_buf, struct q_useful_buf_c *result)
Create and sign a COSE_Sign1 message with a payload in one call.
Definition t_cose_sign1_sign.h:628
enum t_cose_err_t t_cose_sign1_encode_parameters_internal(struct t_cose_sign1_sign_ctx *context, bool payload_is_detached, QCBOREncodeContext *cbor_encode_ctx)
Semi-private function that ouputs the COSE parameters, startng a COSE_Sign1 message.
static void t_cose_sign1_set_content_type_tstr(struct t_cose_sign1_sign_ctx *context, const char *content_type)
Set the payload content type using MIME content types.
Definition t_cose_sign1_sign.h:707
enum t_cose_err_t t_cose_sign1_encode_signature_aad_internal(struct t_cose_sign1_sign_ctx *context, struct q_useful_buf_c aad, struct q_useful_buf_c detached_payload, QCBOREncodeContext *cbor_encode_ctx)
Semi-private function that ouputs the signature, finishing a COSE_Sign1 message.
static enum t_cose_err_t t_cose_sign1_encode_signature_aad(struct t_cose_sign1_sign_ctx *context, struct q_useful_buf_c aad, QCBOREncodeContext *cbor_encode_ctx)
Finish a COSE_Sign1 message with AAD by outputting the signature.
Definition t_cose_sign1_sign.h:675
static enum t_cose_err_t t_cose_sign1_encode_parameters(struct t_cose_sign1_sign_ctx *context, QCBOREncodeContext *cbor_encode_ctx)
Output first part and parameters for a COSE_Sign1 message.
Definition t_cose_sign1_sign.h:562