示例#1
0
        public void Decode_pkcs8_key()
        {
            var parser = new PrivateKeyParser(new Asn1Parser());

            var ps = parser.ParsePem(key).Key;

            Assert.Equal("D0BE2B629913D613660CB4E003BB78DBF3D5109AA673F1AA3A345A008D88980DD83FE940544EC710C066FAAC8BE594CB5C4FA05D4B8ACC294C2F9124056CED78822EC5899063E1E24ABDE39B567B7D44FC6A4F5B710627843C5B6025A961D06A720A8E4652669D82A7BEF3D645F95401144DA1328661067CBF1436DADBFA83224D469A4B1D5E30BAED9234118442188EF57978CEA505FFC0E26CB68B0C4114931E33CA8592AF653B6392C3115A6F12950A3239164A5EC57A3862B3B4E89E22F9DC2A85F796B912BA96B127EBF4C98409205DAE4C50DB6C20CBF3A6E0509ED3C9927D5F502FAE71C6356A7E4334010DB4C2329642B98F3501176E04779A72A477", ToHex(ps.Modulus));
            Assert.Equal("010001", ToHex(ps.Exponent));
            Assert.Equal("2BB0B1F9F81A3BC361A7A53001F7FA2AE755201D8E5B542891F825225A7D4D7E105608270BBE5551FF434E9250D1A39C10DD25AE814232CB2E0402B7EC5EC93160E6133860BD5728FB05D59ECCB21A1D174BD502499CC5269B4F70C7513584DED2B1BCE7A115934026860419441A1468096CDA216E18DEB7BB72AAAC924053B3B830FA1F422CF035C326883A91574AE753A1E0988450EB884C321D5B9E7C38237E5EB0E5E33B53B63E2C32C8AD231EE57378135E0F4C045CD2C83F80AA0EC4340CAC813CA5D95B86E616796EAB8B3E56F80F31CCD4962ECF8746CCEC6D684742C59D993CB523BD719E252DC66963998783B947CD213AA0F031AE43D8A1AFBA21", ToHex(ps.D));
            Assert.Equal("FA23B29A51C9A4423FAF390D7CB19080DBCB57AA35B67060784E1A86DAE61E1CAF248618E1FCF8F4ED316BF178E9CF580DAF534D049851F50B3F74EF4D5825D2EACD1FB15CFF826F0DDFAC3B91C05EF94A38DD422DDD4EB1BD9546E1E25859ED81E7ED2C65E5F331FCC6870BA05648A7389D02A15A461530723EB9F5ECEF53F1", ToHex(ps.P));
            Assert.Equal("D5A22E403BB8EF2F79F12D0C9F5F2E978641EF9A7AD1539855787AE03B6FB44EC8C01CD461186ACA4CC0EA0AB32F26AC576D70303482B13DDCC60978DA9B8433697829F3E6C958735E50D45F6D6531568FCCCDFA78A3037AA02395376713AE7CFF768161B93D4B8C38F628AE7E858EAAB65787FA1D345E30A2D31AD3182A46E7", ToHex(ps.Q));
            Assert.Equal("3CB4A726BE8CA23995BD0FAA8F45849D513A433742BBD90000926BEBA87A4A7A89A2E28C6D63F88370811B024A66EBF421B618104BFA2F81B9CE17B1EFE261A3936A5EB3ABAF32D782D572B62E4432886B93EB56A14CE1494F8A47DE9011031A19F9D05C830A508024298622B331DD85FFBE5322178784A2F246F8D88F3CF1F1", ToHex(ps.DP));
            Assert.Equal("D42AA8A2746DBB663C4610C68B751D31B14DC4A77838723C450E4D826AA50ABE7FD3840E4C8BD26B2D851E2B183FC8B9BA6E5ED0112686DE786759BAE3E9358755C4D86D799417BB243D445DADA8A53261C835FCFE586F3916D79FF710F0D407223350557C81EA88CD7D7373B105F565878830EC6E9AB6BCB8C8CDC83E24A69B", ToHex(ps.DQ));
            Assert.Equal("23B92EA0605DBC81E77B7637B6E710273727608DDBA696E1CA7D5D9A6F23B1A696AED06F16A09BD72D4C8DAA0BE25362F9BADD77A6E9579BB8E3B18141F1BCA372F596E5D392C44F9B087935B8575A5FE27A259CE9640BEACAFC43EBD2603280A3DE73761589BD6B3EFEFECD7D6A0594AD43701BEAF8814BB9C05D8B4FFD8571", ToHex(ps.InverseQ));
        }
示例#2
0
        public void Should_install_a_x509_certificate_and_update_bindings()
        {
            // Arrange
            var x509       = new X509Certificate2(Encoding.ASCII.GetBytes(TestCertificate), (string)null, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);
            var sut        = new IISServerConfigurationProvider();
            var asn1Parser = new Asn1Parser();
            var rsaParser  = new PrivateKeyParser(asn1Parser);
            var privateKey = rsaParser.ParsePem(TestPrivateKey).Key;
            var csp        = new CspParameters {
                KeyContainerName = x509.GetCertHashString(), Flags = CspProviderFlags.UseMachineKeyStore
            };
            var rsa2 = new RSACryptoServiceProvider(csp);

            rsa2.ImportParameters(privateKey);
            x509.PrivateKey = rsa2;

            // Act
            sut.ConfigureServer("test.startliste.info", x509.GetCertHash(), "my", null, null);
        }
示例#3
0
        public void Encode_pkcs8_key()
        {
            var parser = new PrivateKeyParser();

            var privateKey = parser.ParsePem(key);

            // What changes in our output?

            Assert.Equal(@"-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA0L4rYpkT1hNmDLTgA7t42/PVEJqmc/GqOjRaAI2ImA3YP+lA
VE7HEMBm+qyL5ZTLXE+gXUuKzClML5EkBWzteIIuxYmQY+HiSr3jm1Z7fUT8ak9b
cQYnhDxbYCWpYdBqcgqORlJmnYKnvvPWRflUARRNoTKGYQZ8vxQ22tv6gyJNRppL
HV4wuu2SNBGEQhiO9Xl4zqUF/8DibLaLDEEUkx4zyoWSr2U7Y5LDEVpvEpUKMjkW
Sl7Fejhis7ToniL53CqF95a5ErqWsSfr9MmECSBdrkxQ22wgy/Om4FCe08mSfV9Q
L65xxjVqfkM0AQ20wjKWQrmPNQEXbgR3mnKkdwIDAQABAoIBACuwsfn4GjvDYael
MAH3+irnVSAdjltUKJH4JSJafU1+EFYIJwu+VVH/Q06SUNGjnBDdJa6BQjLLLgQC
t+xeyTFg5hM4YL1XKPsF1Z7MshodF0vVAkmcxSabT3DHUTWE3tKxvOehFZNAJoYE
GUQaFGgJbNohbhjet7tyqqySQFOzuDD6H0Is8DXDJog6kVdK51Oh4JiEUOuITDId
W558OCN+XrDl4ztTtj4sMsitIx7lc3gTXg9MBFzSyD+Aqg7ENAysgTyl2VuG5hZ5
bquLPlb4DzHM1JYuz4dGzOxtaEdCxZ2ZPLUjvXGeJS3GaWOZh4O5R80hOqDwMa5D
2KGvuiECgYEA+iOymlHJpEI/rzkNfLGQgNvLV6o1tnBgeE4ahtrmHhyvJIYY4fz4
9O0xa/F46c9YDa9TTQSYUfULP3TvTVgl0urNH7Fc/4JvDd+sO5HAXvlKON1CLd1O
sb2VRuHiWFntgeftLGXl8zH8xocLoFZIpzidAqFaRhUwcj659ezvU/ECgYEA1aIu
QDu47y958S0Mn18ul4ZB75p60VOYVXh64DtvtE7IwBzUYRhqykzA6gqzLyasV21w
MDSCsT3cxgl42puEM2l4KfPmyVhzXlDUX21lMVaPzM36eKMDeqAjlTdnE658/3aB
Ybk9S4w49iiufoWOqrZXh/odNF4wotMa0xgqRucCgYA8tKcmvoyiOZW9D6qPRYSd
UTpDN0K72QAAkmvrqHpKeomi4oxtY/iDcIEbAkpm6/QhthgQS/ovgbnOF7Hv4mGj
k2pes6uvMteC1XK2LkQyiGuT61ahTOFJT4pH3pARAxoZ+dBcgwpQgCQphiKzMd2F
/75TIheHhKLyRvjYjzzx8QKBgQDUKqiidG27ZjxGEMaLdR0xsU3Ep3g4cjxFDk2C
aqUKvn/ThA5Mi9JrLYUeKxg/yLm6bl7QESaG3nhnWbrj6TWHVcTYbXmUF7skPURd
railMmHINfz+WG85Ftef9xDw1AciM1BVfIHqiM19c3OxBfVlh4gw7G6atry4yM3I
PiSmmwKBgCO5LqBgXbyB53t2N7bnECc3J2CN26aW4cp9XZpvI7Gmlq7Qbxagm9ct
TI2qC+JTYvm63Xem6VebuOOxgUHxvKNy9Zbl05LET5sIeTW4V1pf4nolnOlkC+rK
/EPr0mAygKPec3YVib1rPv7+zX1qBZStQ3Ab6viBS7nAXYtP/YVx
-----END RSA PRIVATE KEY-----".Replace("\r\n", "\n"), privateKey.ToPemString());
        }