Exemplo n.º 1
0
        /// <summary>
        /// 检查印章匹配[可选-存在Seal.esl则验证,不存在不验证]
        /// 验证文件:Doc_0\Signs\Sign_0\Seal.esl、Doc_0\Signs\Sign_0\SignedValue.dat
        /// </summary>
        private static VerifyResult CheckSealMatch(OfdReader reader, Signature signature)
        {
            if (signature.SignedInfo.Seal == null)
            {
                return(VerifyResult.Success);
            }
            byte[]           sesSignatureBin = reader.ReadContent(signature.SignedValue);
            SesVersionHolder holder          = VersionParser.ParseSignatureVersion(sesSignatureBin);

            if (holder.Version == SesVersion.V4)
            {
                SesSignature v4Signature = SesSignature.GetInstance(holder.Sequence);
                SeSeal       seal        = v4Signature.TbsSign.EsSeal;
                byte[]       expect      = seal.GetDerEncoded();

                byte[] sealBytes = reader.ReadContent(signature.SignedInfo.Seal.BaseLoc.Value);
                if (!Arrays.AreEqual(expect, sealBytes))
                {
                    return(VerifyResult.SealNotMatch);
                }
            }
            return(VerifyResult.Success);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 获取电子印章二进制编码
 /// </summary>
 /// <returns></returns>
 public override byte[] GetSeal()
 {
     return(_seal.GetDerEncoded());
 }