Beispiel #1
0
 public string SignFromText(string plaintextMessage, bool bDetached, Encoding encodingType)
 {
     CAPICOM.SignedData signedData = new CAPICOM.SignedDataClass();
     CAPICOM.Utilities  u          = new CAPICOM.UtilitiesClass();
     signedData.Content = (u.ByteArrayToBinaryString(encodingType.GetBytes(plaintextMessage)));
     CAPICOM.Signer signer = new CAPICOM.Signer();
     signer.Certificate  = ClientCert;
     this._signedContent = signedData.Sign(signer, bDetached, CAPICOM.CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64);
     return(_signedContent);
 }
Beispiel #2
0
 public bool VerifyDetachedSignature(string plaintextMessage, string signedContent, Encoding encodingType)
 {
     try
     {
         this._clearText     = plaintextMessage;
         this._signedContent = signedContent;
         CAPICOM.SignedData signedData = new CAPICOM.SignedDataClass();
         CAPICOM.Utilities  u          = new CAPICOM.UtilitiesClass();
         signedData.Content = (u.ByteArrayToBinaryString(encodingType.GetBytes(plaintextMessage)));
         signedData.Verify(_signedContent, true, CAPICOM.CAPICOM_SIGNED_DATA_VERIFY_FLAG.CAPICOM_VERIFY_SIGNATURE_ONLY);
         SignerCert = null;
         CAPICOM.Signer s = (CAPICOM.Signer)signedData.Signers[1];
         SignerCert = (CAPICOM.Certificate)s.Certificate;
         return(true);
     }
     catch (COMException e)
     {
         return(false);
     }
 }