Beispiel #1
0
        public void Sign()
        {
            string text = "hello world!";

            byte[] bytes          = Encoding.ASCII.GetBytes(text);
            byte[] signatureBytes = PGPUtilities.Sign(bytes, privKey, PrivKeyPassword);

            string signature = Encoding.ASCII.GetString(signatureBytes);

            Assert.NotNull(signature);
            Assert.AreNotEqual(string.Empty, signature);
        }
Beispiel #2
0
        public void SignZeroBytes()
        {
            byte[] signature = PGPUtilities.Sign(new byte[0], privKey, PrivKeyPassword);

            Assert.NotNull(Encoding.ASCII.GetString(signature));
        }
Beispiel #3
0
 public void SignNullPassword()
 {
     Assert.Throws(typeof(NullReferenceException), () => { PGPUtilities.Sign(new byte[0], privKey, null); });
 }
Beispiel #4
0
 public void SignNullKey()
 {
     Assert.Throws(typeof(PgpKeyValidationException), () => { PGPUtilities.Sign(new byte[0], null, PrivKeyPassword); });
 }
Beispiel #5
0
 public void SignNullBytes()
 {
     Assert.Throws(typeof(NullReferenceException), () => { PGPUtilities.Sign(null, privKey, PrivKeyPassword); });
 }
Beispiel #6
0
 public void SignBlankKey()
 {
     Assert.Throws(typeof(PgpKeyValidationException), () => { PGPUtilities.Sign(new byte[0], string.Empty, PrivKeyPassword); });
 }
Beispiel #7
0
 public void SignBadPassword()
 {
     Assert.Throws(typeof(PgpException), () => { PGPUtilities.Sign(new byte[0], privKey, string.Empty); });
 }
Beispiel #8
0
 /// <summary>
 ///     Returns a PGP signature of the specified text using the default private key.
 /// </summary>
 /// <param name="text">The text for which the signature will be generated.</param>
 /// <returns>The generated PGP signature.</returns>
 private byte[] GetSignature(string text)
 {
     byte[] bytes = Encoding.ASCII.GetBytes(text);
     return(PGPUtilities.Sign(bytes, privKey, PrivKeyPassword));
 }