Beispiel #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);
        }