So I am getting issues with creating a ECC Private Key then getting its Public Key in C# with Chilkat.
Chilkat Info Package: Dot Net Core DllDate: May 28 2021 ChilkatVersion: 9.5.0.87
Code
Chilkat.Ecc ecc = new Chilkat.Ecc();
Chilkat.Prng prng = new Chilkat.Prng();
string entropy = prng.GetEntropy(32, "base64");
prng.AddEntropy(entropy, "base64");
// Private Key created fine
Chilkat.PrivateKey privKey = ecc.GenEccKey("brainpoolP256r1", prng);
// Public key is created fine no indication of a problem
var publicKey = privKey.GetPublicKey();
// Set up the verbose logging
publicKey.VerboseLogging = true;
publicKey.DebugLogFilePath = @"C:\Temp\Chilkat.log";
// Get the Pkcs8 Encoded Keys
var privPkcs8 = privKey.GetPkcs8ENC("base64");
var pubPkcs8 = publicKey.GetPkcs8ENC("base64");
// The private key Encoded String generates fine, but the public key is null.
// Log follows code
Last Error Text:
ChilkatLog:
KeySize:
ChilkatVersion: 9.5.0.87
--KeySize
--ChilkatLog
Debug Log
GetPkcs8ENC:
DllDate: May 28 2021
ChilkatVersion: 9.5.0.87
UnlockPrefix: ******.*********
Architecture: Little Endian; 64-bit
VerboseLogging: 1
toPubKeyDer:
toPublicKeyDer:
DecodeToAsn:
null reference passed to BER decoder
(leaveContext)
(leaveContext)
(leaveContext)
Failed.
(leaveContext)
KeySize:
ChilkatVersion: 9.5.0.87
(leaveContext)
KeySize:
ChilkatVersion: 9.5.0.87
(leaveContext)
KeySize:
ChilkatVersion: 9.5.0.87
(leaveContext 15ms)
One of the other things I found is it works for some curves but not others.
Results of tests
"secp256r1": true,
"secp384r1": true,
"secp521r1": true,
"secp256k1": true,
"secp192r1": false,
"secp224r1": false,
"brainpoolP160r1": false,
"brainpoolP192r1": false,
"brainpoolP224r1": false,
"brainpoolP256r1": false,
"brainpoolP320r1": false,
"brainpoolP384r1": false,
"brainpoolP512r1": false
So it looks like only the NIST curves work? Which seems odd since I can use the Public key for key derivation.
Anyone have an idea what the issue might be (.Net Core limitation, Chilkat issue?)
Apricate anyone's thoughts.