Deserialize() public method

public Deserialize ( Stream aStream ) : object
aStream Stream
return object
示例#1
0
 public void TestDeserializeRsaFromPrivate()
 {
     var formatter = new Ssh1KeyFormatter();
     var key = formatter.Deserialize(Resources.rsa1_1);
     Assert.That(key.Version, Is.EqualTo(SshVersion.SSH1));
     Assert.That(key.Algorithm, Is.EqualTo(PublicKeyAlgorithm.SSH_RSA));
     var publicKey = (RsaKeyParameters)key.GetPublicKeyParameters();
     var expected = new BigInteger(Resources.rsa1_1_param_n.Trim(), 16);
     Assert.That(publicKey.Modulus, Is.EqualTo(expected));
 }
示例#2
0
        public void GetFingerprintTest()
        {
            var formatter1 = new Ssh1KeyFormatter();

            var rsaSsh1Target = formatter1.Deserialize(Resources.rsa1_1);
            var rsaSsh1ExpectedFingerprint = Resources.rsa1_1_fp.Trim();
            var rsaSsh1Actual = "MD5:" + rsaSsh1Target.GetMD5Fingerprint().ToHexString();
            Assert.That(rsaSsh1ExpectedFingerprint, Is.EqualTo(rsaSsh1Actual));

            var formatter2 = new PpkFormatter();

            var rsaTarget = formatter2.Deserialize(Resources.ssh2_rsa_no_passphrase_ppk);
            var rsaExpectedFingerprint = "57:95:98:7f:c2:4e:98:1d:b9:5b:45:fe:6d:a4:6b:17";
            var rsaActual = rsaTarget.GetMD5Fingerprint().ToHexString();
            Assert.That(rsaExpectedFingerprint, Is.EqualTo(rsaActual));

            var dsaTarget = formatter2.Deserialize(Resources.ssh2_dsa_no_passphrase_ppk);
            var dsaExpectedFingerprint = "4e:f1:fc:5d:80:5b:37:b6:13:67:ce:df:4e:83:7b:0b";
            var dsaActual = dsaTarget.GetMD5Fingerprint().ToHexString();
            Assert.That(dsaExpectedFingerprint, Is.EqualTo(dsaActual));
        }