-
Notifications
You must be signed in to change notification settings - Fork 24
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
base: keys
Are you sure you want to change the base?
Conversation
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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
No description provided.