Exemplo n.º 1
0
        /// <summary>
        /// Construct from the spcified RSA Key
        /// </summary>
        /// <param name="KeyPair">An RSA key Pair.</param>
        public PublicKeyRSA(RSAKeyPair KeyPair) {
            kid = KeyPair.UDF;
            var Provider = KeyPair.Provider;
            var Parameters = Provider.ExportParameters(false);

            n = Parameters.Modulus;
            e = Parameters.Exponent;
            }
Exemplo n.º 2
0
 /// <summary>
 /// Locate private key in local key store.
 /// </summary>
 /// <param name="UDF">Fingerprint of key</param>
 /// <returns>true if found, otherwise false.</returns>
 public override bool FindLocal(string UDF) {
     _RSAKeyPair = new RSAKeyPair(UDF);
     return _RSAKeyPair.Provider != null;
     }
Exemplo n.º 3
0
        /// <summary>
        /// Construct from the spcified RSA Key
        /// </summary>
        /// <param name="KeyPair">An RSA key Pair.</param>
        public PrivateKeyRSA(RSAKeyPair KeyPair) {
            kid = KeyPair.UDF;
            var Provider = KeyPair.Provider;
            var Parameters = Provider.ExportParameters(true);

            n = Parameters.Modulus;
            e = Parameters.Exponent;
            d = Parameters.D;
            p = Parameters.P;
            q = Parameters.Q;
            dp = Parameters.DP;
            dq = Parameters.DQ;
            qi = Parameters.InverseQ;
            }
Exemplo n.º 4
0
 /// <summary>
 /// Generate a new RSA Key Pair with the Key size specified when the 
 /// instance was created.
 /// </summary>
 public override void Generate(KeySecurity KeySecurity) {
 _RSAKeyPair = new RSAKeyPair(KeySize);
 _RSAKeyPair.Persist(KeySecurity);
     }
Exemplo n.º 5
0
 /// <summary>
 /// Create an instance of the RSA crypto provider.
 /// </summary>
 /// <param name="RSAKeyPair">RSAKeyPair to use.</param>
 public CryptoProviderExchangeRSA(RSAKeyPair RSAKeyPair) {
     this.KeyPair = RSAKeyPair;
     this.OAEP = true;
     }
Exemplo n.º 6
0
        static KeyPair DecodeRSAKeyPair (byte[] Data) {

            var PrivateKey = new RSAPrivateKey(Data);

            var RSAParameters = PrivateKey.RSAParameters;
            RSAParameters.Dump();


            //PrivateKey.Dump();

            var RSAKeyPair = new RSAKeyPair(RSAParameters);


            return RSAKeyPair;
            }
Exemplo n.º 7
0
 /// <summary>
 /// Create an instance of the RSA crypto provider from an RSA Key Pair.
 /// </summary>
 /// <param name="RSAKeyPair">The RSA Key Pair</param>
 public CryptoProviderSignatureRSA(RSAKeyPair RSAKeyPair)  {
     this._RSAKeyPair = RSAKeyPair;
     this.DigestAlgorithm = CryptoCatalog.Default.AlgorithmDigest;
     }
Exemplo n.º 8
0
        /// <summary>
        /// Create a provider object that includes the private key parameters and add this
        /// to the certificate.
        /// </summary>
        public void ImportPrivateParameters() {
            if (KeyPair.GetType() == typeof(RSAKeyPair)) {
                if (PrivateParameters.GetType() != typeof(PrivateKeyRSA)) {
                    throw new Exception("Invalid key description");
                    }

                //var RSAKeyPair = KeyPair as RSAKeyPair;
                var PrivateKeyRSA = PrivateParameters as PrivateKeyRSA;
                //var RSAKeyPair = KeyPair as RSAKeyPair;

                var RSAParameters = PrivateKeyRSA.Parameters;
                KeyPair = new RSAKeyPair(RSAParameters);
                Certificate.KeyPair = KeyPair;

                if (X509Chain != null) {
                    foreach (var cert in X509Chain) {
                        CertificateStore.RegisterTrustedRoot(cert);
                        }
                    }

                CertificateStore.Register(Certificate);
                }
            }