Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ECDsaAdapter"/> class.
        /// </summary>
        /// <exception cref="PlatformNotSupportedException">
        /// <see cref="ECDsa"/> creation is not supported by some platforms.
        /// For more details, see https://aka.ms/IdentityModel/create-ecdsa.
        /// </exception>
        internal ECDsaAdapter()
        {
#if NETSTANDARD2_0
            if (SupportsECParameters())
            {
                CreateECDsaFunction = CreateECDsaUsingECParams;
            }
            else
            {
                CreateECDsaFunction = CreateECDsaUsingCNGKey;
            }
#elif DESKTOP
            CreateECDsaFunction = CreateECDsaUsingCNGKey;
#endif
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ECDsaAdapter"/> class.
        /// </summary>
        /// <exception cref="PlatformNotSupportedException">
        /// <see cref="ECDsa"/> creation is not supported by some platforms.
        /// For more details, see https://aka.ms/IdentityModel/create-ecdsa.
        /// </exception>
        internal ECDsaAdapter()
        {
#if NET472
            CreateECDsaFunction = CreateECDsaUsingECParams;
#elif NETSTANDARD2_0
            // Although NETSTANDARD2_0 specifies that ECParameters are supported, we still need to call SupportsECParameters()
            // as NET461 is listed as supporting NETSTANDARD2_0, but DOES NOT support ECParameters.
            // See: https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.ecparameters?view=netstandard-2.0
            if (SupportsECParameters())
            {
                CreateECDsaFunction = CreateECDsaUsingECParams;
            }
            else
            {
                CreateECDsaFunction = CreateECDsaUsingCNGKey;
            }
#else
            CreateECDsaFunction = CreateECDsaUsingCNGKey;
#endif
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ECDsaAdapter"/> class.
        /// </summary>
        /// <exception cref="PlatformNotSupportedException">
        /// <see cref="ECDsa"/> creation is not supported by NETSTANDARD1.4, when running on platforms other than Windows.
        /// For more details, see https://aka.ms/IdentityModel/create-ecdsa.
        /// </exception>
        internal ECDsaAdapter()
        {
#if NETSTANDARD2_0
            if (SupportsECParameters())
            {
                CreateECDsaFunction = CreateECDsaUsingECParams;
            }
            else
            {
                CreateECDsaFunction = CreateECDsaUsingCNGKey;
            }
#elif NETSTANDARD1_4
            if (SupportsCNGKey())
            {
                CreateECDsaFunction = CreateECDsaUsingCNGKey;
            }
            else
            {
                throw LogHelper.LogExceptionMessage(new PlatformNotSupportedException(LogMessages.IDX10690));
            }
#elif DESKTOP
            CreateECDsaFunction = CreateECDsaUsingCNGKey;
#endif
        }