I am writing a CNG provider. Specifically, stuck on implementing NCryptExportKey
API. I am trying to convert an EC key (for signing, ECDSA256) from a hardware key manager. The h/w keymanager provides key in ASN format. I referred to MSDN documentation, it's mentioned that public key X and Y values(of BCRYPT_ECCKEY_BLOB structure) are in big-endian format. But in another post on stackoverflow (Import a Public key from somewhere else to CngKey?), the Magic value also seems to be in big-endian format.
My Questions are:
Are the 'magic' and 'length' values need to be in big-endian format?
How a big number X to be converted to big-endian format? Convert each byte?