-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
COSE: Add t_cose_key_encode() and t_cose_key_decode() APIs
Multiple partial implementations of the COSE_Key encode/decode APIs exists across the tf.org repos. To replace these with a full implementation copy the relevant functions from t_cose_psa_crypto.c from the upstream repo. On top of this, backporting two open PRs: - Only t_cose_key_decode(): laurencelundblade/t_cose#287 - laurencelundblade/t_cose#285 Signed-off-by: Tamas Ban <[email protected]> Change-Id: I6c7a67a4f2a57b90363ffeac9b023296a123e966
- Loading branch information
Showing
7 changed files
with
474 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* t_cose_key.h | ||
* | ||
* Copyright 2019-2023, Laurence Lundblade | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* Created by Laurence Lundblade on 2/6/23. | ||
* | ||
* See BSD-3-Clause license in README.md | ||
*/ | ||
|
||
#ifndef __T_COSE_KEY_H__ | ||
#define __T_COSE_KEY_H__ | ||
|
||
#include "stdbool.h" | ||
#include "stdint.h" | ||
#include "q_useful_buf.h" | ||
#include "t_cose_common.h" | ||
#include "t_cose_standard_constants.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* \brief Decode a CBOR serialized COSE_Key object and turn it to a t_cose_key. | ||
* | ||
* \param[in] cbor_encoded A buffer which holds a COSE_Key object. | ||
* \param[out] key A pointer to a t_cose_key structure. | ||
*/ | ||
enum t_cose_err_t | ||
t_cose_key_decode(struct q_useful_buf_c cbor_encoded, | ||
struct t_cose_key *key); | ||
|
||
|
||
/** | ||
* \brief Encode a t_cose_key as a CBOR serialized COSE_Key object | ||
* | ||
* \param[in] key A t_cose_key to encode it as a COSE_Key. | ||
* \param[in] key_buf A buffer to hold the COSE_Key. | ||
* \param[out] cbor_encoded Place to return pointer and length of | ||
* COSE_Key. | ||
* | ||
* The t_cose_key must be imported to the crypto library before this call. | ||
*/ | ||
enum t_cose_err_t | ||
t_cose_key_encode(struct t_cose_key key, | ||
struct q_useful_buf key_buf, | ||
struct q_useful_buf_c *cbor_encoded); | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __T_COSE_KEY_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.