Ejemplo n.º 1
0
        public override bool VerifySignature(byte[] documentToSign, byte[] signature, string publicKey)
        {
            var pubKey = BouncyKeyFactory.FromPublicKeyString(publicKey);

            var signer = SignerUtilities.GetSigner(signatureAlgorithm);

            signer.Init(false, pubKey);
            signer.BlockUpdate(documentToSign, 0, documentToSign.Length);

            return(signer.VerifySignature(signature));
        }
Ejemplo n.º 2
0
        public override byte[] Sign(byte[] documentToSign, string privateKey, string passPhrase)
        {
            var privKey = BouncyKeyFactory.FromEncryptedPrivateKeyString(privateKey, passPhrase);

            var signer = SignerUtilities.GetSigner(signatureAlgorithm);

            signer.Init(true, privKey);
            signer.BlockUpdate(documentToSign, 0, documentToSign.Length);
            var signature = signer.GenerateSignature();

            return(signature);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the DER encoded public key.
 /// </summary>
 /// <returns>The public key.</returns>
 public override string ToPublicKeyString()
 {
     return(BouncyKeyFactory.ToPublicKeyString(keyPair.Public));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the encrypted and DER encoded private key.
 /// </summary>
 /// <param name="passPhrase">The pass phrase to encrypt the private key.</param>
 /// <returns>The encrypted private key.</returns>
 public override string ToEncryptedPrivateKeyString(string passPhrase)
 {
     return(BouncyKeyFactory.ToEncryptedPrivateKeyString(keyPair.Private, passPhrase));
 }