public bool VerifyData(SignedData signedData)
 {
     if (signedData == null)
     {
         throw new ArgumentNullException(
                   MyNameof.GetLocalVarName(() => signedData)
                   );
     }
     if (signedData.Signature == null)
     {
         throw new ArgumentNullException(
                   "signedData.Signature"
                   );
     }
     if (signedData.Signature.SignerCertificateId != Id)
     {
         throw new InvalidOperationException(
                   "Signer id != certificate id"
                   );
     }
     if (SignType == (int)ELightCertificateSignType.Rsa)
     {
         var publicRsaParameters = ReadRsaParameters(
             PublicSignParameters,
             false
             );
         using (var csp = GetRsaCsp())
         {
             csp.ImportParameters(publicRsaParameters);
             using (var hashAlg = new SHA256Managed())
             {
                 return(csp.VerifyData(
                            signedData.Data,
                            hashAlg,
                            signedData.Signature.SignatureBytes
                            ));
             }
         }
     }
     throw new ArgumentOutOfRangeException(
               this.MyNameOfProperty(e => e.SignType)
               );
 }
Пример #2
0
 public SignedData(SignedData data)
 {
     Data      = data.Data;
     Signature = data.Signature;
 }