594 {
596 {
597 throw new ArgumentNullException("format");
598 }
599 if (provider == null)
600 {
601 throw new ArgumentNullException("provider");
602 }
605 if (curveName == null)
606 {
607 global::Interop.NCrypt.ErrorCode errorCode = global::Interop.NCrypt.NCryptImportKey(safeNCryptProviderHandle,
IntPtr.Zero,
format.Format,
IntPtr.Zero, out phKey, ref
MemoryMarshal.GetReference(keyBlob), keyBlob.
Length, 0);
608 if (errorCode != 0)
609 {
610 throw errorCode.ToCryptographicException();
611 }
612 }
613 else
614 {
616 }
617 CngKey cngKey =
new CngKey(safeNCryptProviderHandle, phKey);
618 cngKey.IsEphemeral =
format != CngKeyBlobFormat.OpaqueTransportBlob;
619 return cngKey;
620 }
CngKey(SafeNCryptProviderHandle providerHandle, SafeNCryptKeyHandle keyHandle)
static SafeNCryptKeyHandle ImportKeyBlob(string blobType, ReadOnlySpan< byte > keyBlob, string curveName, SafeNCryptProviderHandle provider)