Exemplo n.º 1
0
        public void ImportFromPem_Pkcs8_Simple()
        {
            using (TAlg key = CreateKey())
            {
                key.ImportFromPem(@"
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgcKEsLbFoRe1W/2jP
whpHKz8E19aFG/Y0ny19WzRSs4qhRANCAASBAezkdGSm6tcM9ppuK9PYhpGjJi0i
y6T3Y16v8maAqNihK6YdWZI19n2ctNWPF4PTykPnjwpauqYkB5k2wMOp
-----END PRIVATE KEY-----");
                ECParameters ecParameters = ExportParameters(key, true);
                ECParameters expected     = EccTestData.GetNistP256ReferenceKey();
                EccTestBase.AssertEqual(expected, ecParameters);
            }
        }
Exemplo n.º 2
0
        public void ImportFromPem_ECPrivateKey_Simple()
        {
            using (TAlg key = CreateKey())
            {
                key.ImportFromPem(@"
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIHChLC2xaEXtVv9oz8IaRys/BNfWhRv2NJ8tfVs0UrOKoAoGCCqGSM49
AwEHoUQDQgAEgQHs5HRkpurXDPaabivT2IaRoyYtIsuk92Ner/JmgKjYoSumHVmS
NfZ9nLTVjxeD08pD548KWrqmJAeZNsDDqQ==
-----END EC PRIVATE KEY-----");
                ECParameters ecParameters = ExportParameters(key, true);
                ECParameters expected     = EccTestData.GetNistP256ReferenceKey();
                EccTestBase.AssertEqual(expected, ecParameters);
            }
        }
Exemplo n.º 3
0
        public void ImportFromEncryptedPem_Pkcs8_Char_Simple()
        {
            using (TAlg key = CreateKey())
            {
                string pem = @"
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIHgMEsGCSqGSIb3DQEFDTA+MCkGCSqGSIb3DQEFDDAcBAjVvm4KTLb0JgICCAAw
DAYIKoZIhvcNAgkFADARBgUrDgMCBwQIuHgfok8Ytl0EgZDkDSJ9vt8UvSesdyV+
Evt9yfvEjiP/6yITq59drw1Kcgp6buOCVCY7LZ06aD6WpogiqGDYMuzfvqg5hNFp
opSAJ/pvHONL5kyAJLeNyG9c/mR2qyrP2L9gL0Z5fB9NyPejKTLi0PXMGQWdDTH8
Qh0fqdrNovgFLubbJFMQN/MwwIAfIuf0Mn0WFYYeQiBJ3kg=
-----END ENCRYPTED PRIVATE KEY-----";
                key.ImportFromEncryptedPem(pem, "test");
                ECParameters ecParameters = ExportParameters(key, true);
                ECParameters expected     = EccTestData.GetNistP256ReferenceKey();
                EccTestBase.AssertEqual(expected, ecParameters);
            }
        }
Exemplo n.º 4
0
        public void ImportFromEncryptedPem_Pkcs8_Byte_Simple()
        {
            using (TAlg key = CreateKey())
            {
                string pem = @"
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIHsMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAgf9krO2ZiPvAICCAAw
DAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEEv4Re1ATH9lHzx+13GoZU0EgZAV
iE/+pIb/4quf+Y524bXUKTGYXzdSUE8Dp1qdZFcwDiCYCTtpL+065fGhmf1KZS2c
/OMt/tWvtMSj17+dJvShsu/NYJXF5fsfpSJbd3e50Y3AisW0Ob7mmF54KBfg6Y+4
aATwwQdUIKVzUZsQctsHPjbriQKKn7GKSyUOikBUNQ+TozojX8/g7JAsl+T9jGM=
-----END ENCRYPTED PRIVATE KEY-----";
                key.ImportFromEncryptedPem(pem, "test" u8);
                ECParameters ecParameters = key.ExportParameters(true);
                ECParameters expected     = EccTestData.GetNistP256ReferenceKey();
                EccTestBase.AssertEqual(expected, ecParameters);
            }
        }
Exemplo n.º 5
0
        public void ImportFromPem_Pkcs8_IgnoresUnrelatedAlgorithm()
        {
            using (TAlg key = CreateKey())
            {
                key.ImportFromPem(@"
-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBALc/WfXui9VeJLf/AprRaoVDyW0lPlQxm5NTLEHDwUd7idstLzPX
uah0WEjgao5oO1BEUR4byjYlJ+F89Cs4BhUCAwEAAQJBAK/m8jYvnK9exaSR+DAh
Ij12ip5pB+HOFOdhCbS/coNoIowa6WJGrd3Np1m9BBhouWloF8UB6Iu8/e/wAg+F
9ykCIQDzcnsehnYgVZTTxzoCJ01PGpgESilRyFzNEsb8V60ZewIhAMCyOujqUqn7
Q079SlHzXuvocqIdt4IM1EmIlrlU9GGvAh8Ijv3FFPUSLfANgfOIH9mX7ldpzzGk
rmaUzxQvyuVLAiEArCTM8dSbopUADWnD4jArhU50UhWAIaM6ZrKqC8k0RKsCIQDC
yZWUxoxAdjfrBGsx+U6BHM0Myqqe7fY7hjWzj4aBCw==
-----END RSA PRIVATE KEY-----
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgcKEsLbFoRe1W/2jP
whpHKz8E19aFG/Y0ny19WzRSs4qhRANCAASBAezkdGSm6tcM9ppuK9PYhpGjJi0i
y6T3Y16v8maAqNihK6YdWZI19n2ctNWPF4PTykPnjwpauqYkB5k2wMOp
-----END PRIVATE KEY-----");
                ECParameters ecParameters = ExportParameters(key, true);
                ECParameters expected     = EccTestData.GetNistP256ReferenceKey();
                EccTestBase.AssertEqual(expected, ecParameters);
            }
        }
Exemplo n.º 6
0
        public void ImportFromPem_ECPrivateKey_IgnoresUnrelatedAlgorithm()
        {
            using (TAlg key = CreateKey())
            {
                key.ImportFromPem(@"
-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBALc/WfXui9VeJLf/AprRaoVDyW0lPlQxm5NTLEHDwUd7idstLzPX
uah0WEjgao5oO1BEUR4byjYlJ+F89Cs4BhUCAwEAAQJBAK/m8jYvnK9exaSR+DAh
Ij12ip5pB+HOFOdhCbS/coNoIowa6WJGrd3Np1m9BBhouWloF8UB6Iu8/e/wAg+F
9ykCIQDzcnsehnYgVZTTxzoCJ01PGpgESilRyFzNEsb8V60ZewIhAMCyOujqUqn7
Q079SlHzXuvocqIdt4IM1EmIlrlU9GGvAh8Ijv3FFPUSLfANgfOIH9mX7ldpzzGk
rmaUzxQvyuVLAiEArCTM8dSbopUADWnD4jArhU50UhWAIaM6ZrKqC8k0RKsCIQDC
yZWUxoxAdjfrBGsx+U6BHM0Myqqe7fY7hjWzj4aBCw==
-----END RSA PRIVATE KEY-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIHChLC2xaEXtVv9oz8IaRys/BNfWhRv2NJ8tfVs0UrOKoAoGCCqGSM49
AwEHoUQDQgAEgQHs5HRkpurXDPaabivT2IaRoyYtIsuk92Ner/JmgKjYoSumHVmS
NfZ9nLTVjxeD08pD548KWrqmJAeZNsDDqQ==
-----END EC PRIVATE KEY-----");
                ECParameters ecParameters = ExportParameters(key, true);
                ECParameters expected     = EccTestData.GetNistP256ReferenceKey();
                EccTestBase.AssertEqual(expected, ecParameters);
            }
        }