Beispiel #1
0
        /// <summary>
        /// Creates a new <see cref="RSACryptoProviderAdapter"/> service with the provided <see cref="RSAKeyPair"/>
        /// data.
        /// </summary>
        /// <param name="keys">RSA keys to use for the service.</param>
        public RSACryptoProviderAdapter(RSACryptoServiceProvider cryptoProvider)
        {
            if (cryptoProvider == null)
            {
                throw new ArgumentNullException(nameof(cryptoProvider), $"{cryptoProvider} cannot be null for " + nameof(RSACryptoProviderAdapter));
            }

#if !NET35
            keyPair  = new RSAKeyPair(cryptoProvider.ExportParameters(true));
            provider = new Lazy <RSACryptoServiceProvider>(() => cryptoProvider);
#else
            provider = CreateProvider();
#endif
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new <see cref="RSACryptoProviderAdapter"/> service with the provided <see cref="RSAKeyPair"/>
        /// data.
        /// </summary>
        /// <param name="keys">RSA keys to use for the service.</param>
        public RSACryptoProviderAdapter(RSAKeyPair keys)
        {
            if (keys == null)
            {
                throw new ArgumentNullException(nameof(keys), "Key pair cannot be null for " + nameof(RSACryptoProviderAdapter));
            }

#if !NET35
            keyPair  = keys;
            provider = new Lazy <RSACryptoServiceProvider>(CreateProvider, true);
#else
            provider = CreateProvider();
#endif
        }