awslabs / aws-c-cal

Aws Crypto Abstraction Layer: Cross-Platform, C99 wrapper for cryptography primitives.
Apache License 2.0
33 stars 36 forks source link

Use fake pub key #163

Closed TingDaoK closed 9 months ago

TingDaoK commented 9 months ago

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.