RSAPrivateKey
Inheritance: Goedel.ASN1.Root
Exemplo n.º 1
0
        public static string ToPEM (RSAKeyPair RSAKeyPair) {

            var Provider = RSAKeyPair.Provider;
            Assert.Null(Provider, NoProviderSpecified.Throw);

            var RSAParameters = Provider.ExportParameters(true);
            Assert.Null(RSAParameters, PrivateKeyNotAvailable.Throw);

            var NewProvider = new RSACryptoServiceProvider();
            NewProvider.ImportParameters(RSAParameters);


            RSAParameters.Dump();

            var RSAPrivateKey = new RSAPrivateKey(RSAParameters);

            var Builder = new StringBuilder();

            Builder.Append("-----BEGIN RSA PRIVATE KEY-----");

            var KeyDER = RSAPrivateKey.DER();
            Builder.AppendBase64(KeyDER);


            Builder.Append("\n-----END RSA PRIVATE KEY-----\n");


            return Builder.ToString();

            }
Exemplo n.º 2
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;
            }