Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Import() [6/6]

static CngKey System.Security.Cryptography.CngKey.Import ( ReadOnlySpan< byte > keyBlob,
string curveName,
CngKeyBlobFormat format,
CngProvider provider )
inlinestaticpackage

Definition at line 593 of file CngKey.cs.

594 {
595 if (format == null)
596 {
597 throw new ArgumentNullException("format");
598 }
599 if (provider == null)
600 {
601 throw new ArgumentNullException("provider");
602 }
603 SafeNCryptProviderHandle safeNCryptProviderHandle = provider.OpenStorageProvider();
604 SafeNCryptKeyHandle phKey = null;
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 {
615 phKey = System.Security.Cryptography.ECCng.ImportKeyBlob(format.Format, keyBlob, curveName, safeNCryptProviderHandle);
616 }
617 CngKey cngKey = new CngKey(safeNCryptProviderHandle, phKey);
618 cngKey.IsEphemeral = format != CngKeyBlobFormat.OpaqueTransportBlob;
619 return cngKey;
620 }
CngKey(SafeNCryptProviderHandle providerHandle, SafeNCryptKeyHandle keyHandle)
Definition CngKey.cs:209
static SafeNCryptKeyHandle ImportKeyBlob(string blobType, ReadOnlySpan< byte > keyBlob, string curveName, SafeNCryptProviderHandle provider)
Definition ECCng.cs:307

References System.Security.Cryptography.CngKey.CngKey(), System.format, System.Security.Cryptography.ECCng.ImportKeyBlob(), System.ReadOnlySpan< T >.Length, System.Security.Cryptography.CngKeyBlobFormat.OpaqueTransportBlob, and System.IntPtr.Zero.