public override void ImportEncryptedPkcs8PrivateKey( ReadOnlySpan <byte> passwordBytes, ReadOnlySpan <byte> source, out int bytesRead) { CngPkcs8.Pkcs8Response response = CngPkcs8.ImportEncryptedPkcs8PrivateKey( passwordBytes, source, out int localRead); ProcessPkcs8Response(response); bytesRead = localRead; }
private void AcceptImport(CngPkcs8.Pkcs8Response response) { SafeNCryptKeyHandle keyHandle = response.KeyHandle; _key.SetHandle( keyHandle, CngKeyLite.GetPropertyAsString( keyHandle, CngKeyLite.KeyPropertyName.Algorithm, CngPropertyOptions.None)); ForceSetKeySize(_key.KeySize); }
public override void ImportEncryptedPkcs8PrivateKey( ReadOnlySpan <char> password, ReadOnlySpan <byte> source, out int bytesRead) { ThrowIfDisposed(); CngPkcs8.Pkcs8Response response = CngPkcs8.ImportEncryptedPkcs8PrivateKey( password, source, out int localRead); ProcessPkcs8Response(response); bytesRead = localRead; }
private void ProcessPkcs8Response(CngPkcs8.Pkcs8Response response) { // Wrong algorithm? switch (response.GetAlgorithmGroup()) { // CNG ECDH and ECDSA keys can both do ECDSA. case BCryptNative.AlgorithmName.ECDsa: case BCryptNative.AlgorithmName.ECDH: AcceptImport(response); return; } response.FreeKey(); throw new CryptographicException(SR.Cryptography_NotValidPublicOrPrivateKey); }
private void AcceptImport(CngPkcs8.Pkcs8Response response) { Key = response.Key; }
private void AcceptImport(CngPkcs8.Pkcs8Response response) { SafeNCryptKeyHandle keyHandle = response.KeyHandle; SetKeyHandle(keyHandle); }