Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add t_cose_key_encode API #287

Open
wants to merge 1 commit into
base: keys
Choose a base branch
from
Open

Conversation

tamasban
Copy link

No description provided.

Signed-off-by: Tamas Ban <[email protected]>
Change-Id: I732db4fc4003c3895af342ec953bd1bdf1da28c0
* 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,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name seems a bit too generic. I suggest adding an "ec2" infix somewhere, e.g., t_cose_key_encode_ec2

QCBOREncodeContext cbor_encoder;
QCBORError qcbor_result;

result = t_cose_crypto_export_ec2_key(key,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume all the relevant checks from rfc9053 (point on curve, etc.) are done here, right?

QCBOREncode_AddInt64ToMapN(&cbor_encoder, T_COSE_KEY_COMMON_KTY, T_COSE_KEY_TYPE_EC2);
QCBOREncode_AddInt64ToMapN(&cbor_encoder, T_COSE_KEY_PARAM_CRV, cose_curve);
QCBOREncode_AddBytesToMapN(&cbor_encoder, T_COSE_KEY_PARAM_X_COORDINATE, x_coord);
if (q_useful_buf_c_is_null(y_coord)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this function is limited to EC2, both coordinates are needed - i.e., the compressed form x + y-sign is not allowed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this comment is wrong. RFC9053 recommends not to use compressed (due to potential IPR), but it doesn't forbid it.

openci-bot pushed a commit to TrustedFirmware-M/trusted-firmware-m that referenced this pull request Oct 15, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants