c# - CNG Import ECC Pub/Priv Keyfrom file -
i've been trying find how import ecc key file means ages. have tried accessing ecc cert windows certificate store, .p12 file, , pkcs#8 openssl key file no success.
just 1 of many things have tried is:
streamreader fs = new streamreader("key.pem"); string key = fs.readtoend(); byte[] tempkey = system.text.encoding.ascii.getbytes(key); cngkey cngkey = cngkey.import(tempkey, cngkeyblobformat.pkcs8privateblob);
but no discriptive error messages given, last line either has invalid parameters
or in case of code above an error occurred during encode or decode operation.
i using sample program msdn ecdh , altered it use gcm mode of aes. of works fine until try , use pre-generated ecc keys instead of ones created default @ runtime microsoft example. have randomly tried of cngkeyblobformat
s honest, can't debug because don't know specific formats in raw data.
my key in following format willing use format work (.p12, microsoft store, pkcs#8, etc.)
key.pem
-----begin ec parameters----- ############################## -----end ec parameters----- -----begin ec private key----- ############################## -----end ec private key-----
resources
although may not issue, cannot ascii encode pem file , act pkcs#8 encoded blob. pkcs#8 specified in asn.1, ber/der encoded. pem base 64 encodes binary encoding , puts header , footer around base 64 indicate type of data encoded.
note encoded parameters may have skipped. these parameters present in encoding of private key.
Comments
Post a Comment