private byte[] ExportFullKeyBlob(bool includePrivateParameters) { #if NETNATIVE return(null); #else return(ECCng.ExportFullKeyBlob(Key, includePrivateParameters)); #endif //NETNATIVE }
/// <summary> /// Exports the key and explicit curve parameters used by the ECC object into an <see cref="ECParameters"/> object. /// </summary> /// <exception cref="CryptographicException"> /// if there was an issue obtaining the curve values. /// </exception> /// <exception cref="PlatformNotSupportedException"> /// if explicit export is not supported by this platform. Windows 10 or higher is required. /// </exception> /// <returns>The key and explicit curve parameters used by the ECC object.</returns> public override ECParameters ExportExplicitParameters() { using (CngKey key = Import()) { ECParameters ecparams = default; byte[] blob = ECCng.ExportFullKeyBlob(key, includePrivateParameters: false); ECCng.ExportPrimeCurveParameters(ref ecparams, blob, includePrivateParameters: false); return(ecparams); } }
internal static void ExportParameters( CngKey key, bool includePrivateParameters, ref ECParameters ecparams) { string curveName = key.GetCurveName(); if (string.IsNullOrEmpty(curveName)) { byte[] fullKeyBlob = ECCng.ExportFullKeyBlob(key, includePrivateParameters); ECCng.ExportPrimeCurveParameters(ref ecparams, fullKeyBlob, includePrivateParameters); } else { byte[] keyBlob = ECCng.ExportKeyBlob(key, includePrivateParameters); ECCng.ExportNamedCurveParameters(ref ecparams, keyBlob, includePrivateParameters); ecparams.Curve = ECCurve.CreateFromFriendlyName(curveName); } }
/// <summary> /// Exports the key used by the ECC object into an <see cref="ECParameters"/> object. /// If the key was created as a named curve, the Curve property will contain named curve parameters /// otherwise it will contain explicit parameters. /// </summary> /// <exception cref="CryptographicException"> /// if there was an issue obtaining the curve values. /// </exception> /// <returns>The key and named curve parameters used by the ECC object.</returns> public override ECParameters ExportParameters() { using (CngKey key = Import()) { ECParameters ecparams = default; string? curveName = key.GetCurveName(out _); if (string.IsNullOrEmpty(curveName)) { byte[] fullKeyBlob = ECCng.ExportFullKeyBlob(key, includePrivateParameters: false); ECCng.ExportPrimeCurveParameters(ref ecparams, fullKeyBlob, includePrivateParameters: false); } else { byte[] keyBlob = ECCng.ExportKeyBlob(key, includePrivateParameters: false); ECCng.ExportNamedCurveParameters(ref ecparams, keyBlob, includePrivateParameters: false); ecparams.Curve = ECCurve.CreateFromFriendlyName(curveName); } return(ecparams); } }
private byte[] ExportFullKeyBlob(bool includePrivateParameters) { return(ECCng.ExportFullKeyBlob(Key, includePrivateParameters)); }