Deserialize() public méthode

public Deserialize ( Stream stream ) : object
stream Stream
Résultat object
 public void TestDeserializeDsaFromNewForamtWithPassphrase()
 {
     var formatter = new OpensshKeyFormatter();
     formatter.GetPassphraseCallbackMethod = passphraseCallback;
     var key = formatter.Deserialize(Resources.dsa_n_pw);
     Assert.That(key.Version, Is.EqualTo(SshVersion.SSH2));
     Assert.That(key.Algorithm, Is.EqualTo(PublicKeyAlgorithm.SSH_DSS));
     var publicKey = (DsaPublicKeyParameters)key.GetPublicKeyParameters();
     var privateKey = (DsaPrivateKeyParameters)key.GetPrivateKeyParameters();
     var param_g = new BigInteger(Resources.dsa_1_param_g.Trim(), 16);
     var param_priv = new BigInteger(Resources.dsa_1_param_priv.Trim(), 16);
     var param_pub = new BigInteger(Resources.dsa_1_param_pub.Trim(), 16);
     Assert.That(privateKey.Parameters.G, Is.EqualTo(param_g));
     Assert.That(privateKey.X, Is.EqualTo(param_priv));
     Assert.That(publicKey.Y, Is.EqualTo(param_pub));
 }
 public void TestDeserializeEd25519FromPrivateWithPassphrase()
 {
     var formatter = new OpensshKeyFormatter();
     formatter.GetPassphraseCallbackMethod = passphraseCallback;
     var key = formatter.Deserialize(Resources.ed25519_1_pw);
     Assert.That(key.Version, Is.EqualTo(SshVersion.SSH2));
     Assert.That(key.Algorithm, Is.EqualTo(PublicKeyAlgorithm.ED25519));
     var publicKey = (Ed25519PublicKeyParameter)key.GetPublicKeyParameters();
     var privateKey = (Ed25519PrivateKeyParameter)key.GetPrivateKeyParameters();
 }
 public void TestDeserializeRsaFromNewForamtWithPassphrase()
 {
     var formatter = new OpensshKeyFormatter();
     formatter.GetPassphraseCallbackMethod = passphraseCallback;
     var key = formatter.Deserialize(Resources.rsa_n_pw);
     Assert.That(key.Version, Is.EqualTo(SshVersion.SSH2));
     Assert.That(key.Algorithm, Is.EqualTo(PublicKeyAlgorithm.SSH_RSA));
     var publicKey = (RsaKeyParameters)key.GetPublicKeyParameters();
     var privateKey = (RsaPrivateCrtKeyParameters)key.GetPrivateKeyParameters();
     var param_n = new BigInteger(Resources.rsa_1_param_n.Trim(), 16);
     var param_p = new BigInteger(Resources.rsa_1_param_p.Trim(), 16);
     var param_q = new BigInteger(Resources.rsa_1_param_q.Trim(), 16);
     Assert.That(publicKey.Modulus, Is.EqualTo(param_n));
     Assert.That(privateKey.P, Is.EqualTo(param_p));
     Assert.That(privateKey.Q, Is.EqualTo(param_q));
 }
 public void TestDeserializeEcdsaFromNewFormatWithPassphrase()
 {
     var formatter = new OpensshKeyFormatter();
     formatter.GetPassphraseCallbackMethod = passphraseCallback;
     var key = formatter.Deserialize(Resources.ecdsa_n_pw);
     Assert.That(key.Version, Is.EqualTo(SshVersion.SSH2));
     Assert.That(key.Algorithm, Is.EqualTo(PublicKeyAlgorithm.ECDSA_SHA2_NISTP256));
     var publicKey = (ECPublicKeyParameters)key.GetPublicKeyParameters();
     var privateKey = (ECPrivateKeyParameters)key.GetPrivateKeyParameters();
     var param_curve = X962NamedCurves.GetByName(Resources.ecdsa_1_param_curve.Trim());
     var param_priv = new BigInteger(Resources.ecdsa_1_param_priv.Trim(), 16);
     var param_pub = new BigInteger(Resources.ecdsa_1_param_pub.Trim(), 16);
     Assert.That(privateKey.Parameters.Curve, Is.EqualTo(param_curve.Curve));
     Assert.That(privateKey.D, Is.EqualTo(param_priv));
     // TODO: figure out how to convert public key to BigInteger that matches param_pub
     //Assert.That(publicKey.Q, Is.EqualTo(param_pub));
 }