windowscryptographycng

BCrypt: Import ECDSA public key in compressed form


Does the BCrypt (C++) API (BCryptImportKeyPair of similar) allow import of an ECDSA public key for the secp256r1 (aka P-256) curve directly in compressed form, that is 1-byte prefix 0x02 or 0x03 followed by 32-byte X coordinate (or some variant of that not containing the Y coordinate)?

I know the necessary math to recompute the Y coordinate; but I'd rather not code it.

Update: reading the doc of BCRYPT_ECCKEY_BLOB, I don't see any way.


Solution

  • Answering my own question

    NO, there is no way an ECDSA public key in compressed form can be imported in Windows BCrypt.

    It's necessary to perform the decompression externally. Which in turn requires knowing the curve parameters and modular exponentiation of large integers (256-bit for secp256r1).