/// <inheritdoc /> public byte[] Export(CryptographicPrivateKeyBlobType blobType) { try { if (blobType == CryptographicPrivateKeyBlobType.BCryptPrivateKey && this.eccPrivateKeyBlob != null) { // Imported keys are always ephemeral and cannot be exported. // But we can make the API work if we have the private key data. // Copy the key data before returning it to avoid sharing an array // with the caller that would allow the caller to change our key data. return(this.eccPrivateKeyBlob.CloneArray()); } return(this.key.Export(CngAsymmetricKeyAlgorithmProvider.GetPlatformKeyBlobType(blobType))); } catch (CryptographicException ex) { if (ex.IsNotSupportedException()) { throw new NotSupportedException(ex.Message, ex); } throw; } }
/// <inheritdoc /> public byte[] ExportPublicKey(CryptographicPublicKeyBlobType blobType) { return(this.key.Export(CngAsymmetricKeyAlgorithmProvider.GetPlatformKeyBlobType(blobType))); }