Beispiel #1
0
 /// <exception cref="Org.BouncyCastle.Security.GeneralSecurityException"/>
 /// <exception cref="System.IO.IOException"/>
 public virtual ICipherParameters GetPrivateKey()
 {
     if (privateKey == null) {
         privateKey = CryptoUtil.ReadPrivateKeyFromPkcs12KeyStore(new FileStream(PRIVATE_KEY, FileMode.Open, FileAccess.Read
             ), "sandbox", PRIVATE_KEY_PASS);
     }
     return privateKey;
 }
Beispiel #2
0
 public virtual void OpenEncryptedDocWithWrongPrivateKey()
 {
     NUnit.Framework.Assert.That(() =>  {
         PdfReader reader = new PdfReader(sourceFolder + "encryptedWithCertificateAes128.pdf", new ReaderProperties
             ().SetPublicKeySecurityParams(GetPublicCertificate(CERT), CryptoUtil.ReadPrivateKeyFromPkcs12KeyStore(
             new FileStream(sourceFolder + "wrong.p12", FileMode.Open, FileAccess.Read), "demo", "password".ToCharArray
             ())));
         PdfDocument doc = new PdfDocument(reader);
         doc.Close();
     }
     , NUnit.Framework.Throws.InstanceOf<PdfException>().With.Message.EqualTo(PdfException.PdfDecryption))
     ;
 }