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

Use fake pub key #163

Merged
merged 11 commits into from
Oct 12, 2023
Merged

Use fake pub key #163

merged 11 commits into from
Oct 12, 2023

Conversation

TingDaoK
Copy link
Contributor

@TingDaoK TingDaoK commented Oct 11, 2023

We use SecCreateKeyWithData to create ECC key. Expected format for the key passed to that api is a byte buffer consisting of "0x04 | x | y | p", where x,y is public pair and p is private key.

Note that in some cases we only have private key (as we derived it as described above) and we need to construct SecKey from that.

In those cases our code just passes 0,0 point for x,y, i.e. "0x04 | 0 | 0 | p".

This used to work on Macs before 14, but in 14+ SecCreateKeyWithData returns error, which is reasonable since 0,0 is not a valid public point.

To get around the issue, we use a fake public key, which is a valid public point, but not matching the private key as a quick workaround.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@TingDaoK TingDaoK marked this pull request as ready for review October 11, 2023 21:42
source/darwin/securityframework_ecc.c Outdated Show resolved Hide resolved
source/darwin/securityframework_ecc.c Outdated Show resolved Hide resolved
Copy link
Contributor

@graebm graebm left a comment

Choose a reason for hiding this comment

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

fix & ship

source/darwin/securityframework_ecc.c Show resolved Hide resolved
break;

default:
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

raise error?

Copy link
Contributor

Choose a reason for hiding this comment

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

we can fatal assert here? curve being supported should already have been verified

Copy link
Contributor Author

@TingDaoK TingDaoK Oct 11, 2023

Choose a reason for hiding this comment

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

I thought about that, but seems like our API doesn't really raise error for the unknown enum eg: https://github.com/awslabs/aws-c-cal/blob/main/source/windows/bcrypt_ecc.c#L56. But, yeah, I can raise the error here.

source/darwin/securityframework_ecc.c Outdated Show resolved Hide resolved
source/darwin/securityframework_ecc.c Outdated Show resolved Hide resolved
source/darwin/securityframework_ecc.c Outdated Show resolved Hide resolved
break;

default:
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

we can fatal assert here? curve being supported should already have been verified

@TingDaoK TingDaoK merged commit 0f943e8 into main Oct 12, 2023
36 checks passed
@TingDaoK TingDaoK deleted the use-fake-pub-key branch October 12, 2023 02:31
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.

4 participants