private void DoWriteReadTest( AsymmetricKeyParameter akp, string algorithm) { StringWriter sw = new StringWriter(); PemWriter pw = new PemWriter(sw); pw.WriteObject(akp, algorithm, testPassword, random); pw.Writer.Close(); string data = sw.ToString(); PemReader pr = new PemReader(new StringReader(data), new Password(testPassword)); AsymmetricCipherKeyPair kp = pr.ReadObject() as AsymmetricCipherKeyPair; if (kp == null || !kp.Private.Equals(akp)) { Fail("Failed to read back test key encoded with: " + algorithm); } }
private void DoWriteReadTest( AsymmetricKeyParameter akp) { StringWriter sw = new StringWriter(); PemWriter pw = new PemWriter(sw); pw.WriteObject(akp); pw.Writer.Close(); string data = sw.ToString(); PemReader pr = new PemReader(new StringReader(data)); AsymmetricCipherKeyPair kp = pr.ReadObject() as AsymmetricCipherKeyPair; if (kp == null || !kp.Private.Equals(akp)) { Fail("Failed to read back test key"); } }