This is related to .NET / C#. Lets assume there is a certificate + private key (P521 ECC one) inside a PFX or a PKCS#12 file. Would like to be able to
- Import the certificate + private key into the CNG framework/windows cert store (the default Microsoft Software KSP and CSP)
- Load the private key into the
CngKeyclass to then use it inside theECDiffieHellmanCngclass. - Also read the certificate metadata like serial #, issuer, common name etc for some bookkeeping.
Basically would want to transform the following (toy) code to a more useful one by using the real certificate and keys instead of the random runtime generated ones.
// Current test/toy code, uses on-the-fly/non-persistent
// keys instead of pulling from PFX/cert store
var alice = new ECDiffieHellmanCng
{
KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash,
HashAlgorithm = CngAlgorithm.Sha256
};
var bob = new ECDiffieHellmanCng
{
KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash,
HashAlgorithm = CngAlgorithm.Sha256
};
byte[] sharedSymmetricKeyingBits = bob.DeriveKeyMaterial(alice.PublicKey);
No comments:
Post a Comment