mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-08-30 12:12:40 +08:00
Compare commits
2
Commits
19fadab4ad
...
5b0da8f06b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b0da8f06b | ||
|
|
4cc24722c2 |
@@ -1668,7 +1668,7 @@ function renderSignatures() {
|
|||||||
const fragment = document.createDocumentFragment();
|
const fragment = document.createDocumentFragment();
|
||||||
for (const signature of signatures) {
|
for (const signature of signatures) {
|
||||||
const row = document.createElement("div");
|
const row = document.createElement("div");
|
||||||
row.className = `signature-row ${signature.valid ? "valid" : "invalid"}`;
|
row.className = `signature-row ${signature.integrityValid ? "valid" : "invalid"}`;
|
||||||
|
|
||||||
const head = document.createElement("div");
|
const head = document.createElement("div");
|
||||||
head.className = "signature-head";
|
head.className = "signature-head";
|
||||||
@@ -1677,7 +1677,7 @@ function renderSignatures() {
|
|||||||
|
|
||||||
const badges = document.createElement("div");
|
const badges = document.createElement("div");
|
||||||
badges.className = "signature-badges";
|
badges.className = "signature-badges";
|
||||||
badges.append(fontBadge(signature.valid ? "有效" : "无效", signature.valid ? "valid" : "invalid"));
|
badges.append(fontBadge(signature.integrityValid ? "完整" : "异常", signature.integrityValid ? "valid" : "invalid"));
|
||||||
|
|
||||||
head.append(name, badges);
|
head.append(name, badges);
|
||||||
row.append(head);
|
row.append(head);
|
||||||
@@ -1713,7 +1713,7 @@ function signatureSummary(signatures) {
|
|||||||
if (!signatures.length) {
|
if (!signatures.length) {
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
const invalid = signatures.filter((signature) => !signature.valid).length;
|
const invalid = signatures.filter((signature) => !signature.integrityValid).length;
|
||||||
if (invalid) {
|
if (invalid) {
|
||||||
return `${signatures.length} · 异常 ${invalid}`;
|
return `${signatures.length} · 异常 ${invalid}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ type FontInfo = ofdgo.FontInfo
|
|||||||
type SignatureInfo struct {
|
type SignatureInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Valid bool `json:"valid"`
|
IntegrityValid bool `json:"integrityValid"`
|
||||||
Version string `json:"version,omitempty"`
|
Version string `json:"version,omitempty"`
|
||||||
SealType string `json:"sealType,omitempty"`
|
SealType string `json:"sealType,omitempty"`
|
||||||
Signer string `json:"signer,omitempty"`
|
Signer string `json:"signer,omitempty"`
|
||||||
@@ -346,7 +346,7 @@ func signatureInfo(report ofdgo.SignatureVerifyReport) SignatureInfo {
|
|||||||
return SignatureInfo{
|
return SignatureInfo{
|
||||||
ID: report.ID,
|
ID: report.ID,
|
||||||
Type: string(report.Type),
|
Type: string(report.Type),
|
||||||
Valid: report.Valid,
|
IntegrityValid: report.IntegrityValid(),
|
||||||
Version: report.Provider.Version,
|
Version: report.Provider.Version,
|
||||||
SealType: report.SealType,
|
SealType: report.SealType,
|
||||||
Signer: signatureSigner(report),
|
Signer: signatureSigner(report),
|
||||||
|
|||||||
@@ -202,13 +202,6 @@ func cleanFontName(name string) string {
|
|||||||
return strings.ToLower(name)
|
return strings.ToLower(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// matchFontPatternRank 获取字体文件匹配等级
|
|
||||||
// 入参: pattern 匹配模式, name 字体文件名
|
|
||||||
// 返回: int 匹配等级
|
|
||||||
func matchFontPatternRank(pattern, name string) int {
|
|
||||||
return newFontPatternMatcher(pattern).rank(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
type fontFileCandidate struct {
|
type fontFileCandidate struct {
|
||||||
name string
|
name string
|
||||||
base string
|
base string
|
||||||
@@ -426,13 +419,6 @@ func fontFileStyleRank(suffix string, bold, italic bool) int {
|
|||||||
return rank
|
return rank
|
||||||
}
|
}
|
||||||
|
|
||||||
// fontFileStyle 获取字体文件样式
|
|
||||||
// 入参: pattern 匹配模式, name 字体文件名
|
|
||||||
// 返回: bool 是否粗体, bool 是否斜体
|
|
||||||
func fontFileStyle(pattern, name string) (bool, bool) {
|
|
||||||
return fontFileStyleFromSuffix(fontFileStyleSuffix(pattern, name))
|
|
||||||
}
|
|
||||||
|
|
||||||
// fontFileStyleFromSuffix 获取样式后缀对应的字体样式
|
// fontFileStyleFromSuffix 获取样式后缀对应的字体样式
|
||||||
// 入参: suffix 样式后缀
|
// 入参: suffix 样式后缀
|
||||||
// 返回: bool 是否粗体, bool 是否斜体
|
// 返回: bool 是否粗体, bool 是否斜体
|
||||||
@@ -480,27 +466,6 @@ func fontFileKnownStyleSuffix(suffix string) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fontFileStyleSuffix 获取字体文件样式后缀
|
|
||||||
// 入参: pattern 匹配模式, name 字体文件名
|
|
||||||
// 返回: string 样式后缀
|
|
||||||
func fontFileStyleSuffix(pattern, name string) string {
|
|
||||||
key := fontNormalizeName(name)
|
|
||||||
stem := fontPatternStem(pattern)
|
|
||||||
if stem == "" || key == "" {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(key, stem) {
|
|
||||||
return strings.TrimPrefix(key, stem)
|
|
||||||
}
|
|
||||||
for _, alias := range fontExactCandidateNames(stem) {
|
|
||||||
alias = fontNormalizeName(alias)
|
|
||||||
if alias != "" && strings.HasPrefix(key, alias) {
|
|
||||||
return strings.TrimPrefix(key, alias)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// fontMemFile 内存字体文件
|
// fontMemFile 内存字体文件
|
||||||
type fontMemFile struct {
|
type fontMemFile struct {
|
||||||
*bytes.Reader
|
*bytes.Reader
|
||||||
|
|||||||
+15
-2
@@ -37,6 +37,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// SignatureVerifyReport 签名验证报告
|
// SignatureVerifyReport 签名验证报告
|
||||||
|
// Valid表示签名完整性及调用方指定的证书策略均通过
|
||||||
type SignatureVerifyReport struct {
|
type SignatureVerifyReport struct {
|
||||||
ID string
|
ID string
|
||||||
BaseLoc string
|
BaseLoc string
|
||||||
@@ -67,6 +68,18 @@ type SignatureVerifyReport struct {
|
|||||||
Error string
|
Error string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IntegrityValid 判断签名完整性是否有效
|
||||||
|
// 返回: bool 是否有效
|
||||||
|
func (report SignatureVerifyReport) IntegrityValid() bool {
|
||||||
|
return report.Error == "" && report.DigestOK && report.DataHashOK && report.SignedValueOK && report.SealOK && report.SealMatchOK && report.CertOK
|
||||||
|
}
|
||||||
|
|
||||||
|
// TrustedValid 判断签名是否可信有效
|
||||||
|
// 返回: bool 签名完整性、证书信任及证书有效期是否均验证通过
|
||||||
|
func (report SignatureVerifyReport) TrustedValid() bool {
|
||||||
|
return report.IntegrityValid() && report.CertTrustChecked && report.CertTrustOK && report.CertTimeChecked && report.CertTimeOK
|
||||||
|
}
|
||||||
|
|
||||||
// SignatureCertInfo 签名证书信息
|
// SignatureCertInfo 签名证书信息
|
||||||
type SignatureCertInfo struct {
|
type SignatureCertInfo struct {
|
||||||
Subject string
|
Subject string
|
||||||
@@ -267,7 +280,7 @@ func (r *Reader) verifySignature(sigListPath string, sigRef Signature, options *
|
|||||||
report.SignCert = result.CertInfo
|
report.SignCert = result.CertInfo
|
||||||
report.Signer = result.CertInfo.CommonName
|
report.Signer = result.CertInfo.CommonName
|
||||||
report.applySignatureCertificatePolicy(options, result.SignerCerts, result.Certs)
|
report.applySignatureCertificatePolicy(options, result.SignerCerts, result.Certs)
|
||||||
report.Valid = report.DigestOK && report.DataHashOK && report.SignedValueOK && report.CertOK && report.certificatePolicyOK()
|
report.Valid = report.IntegrityValid() && report.certificatePolicyOK()
|
||||||
return report
|
return report
|
||||||
case "", SignTypeSeal:
|
case "", SignTypeSeal:
|
||||||
default:
|
default:
|
||||||
@@ -299,7 +312,7 @@ func (r *Reader) verifySignature(sigListPath string, sigRef Signature, options *
|
|||||||
}
|
}
|
||||||
report.SealMatchOK = bytes.Equal(sealData, sesResult.SealRaw)
|
report.SealMatchOK = bytes.Equal(sealData, sesResult.SealRaw)
|
||||||
}
|
}
|
||||||
report.Valid = report.DigestOK && report.DataHashOK && report.SignedValueOK && report.SealOK && report.SealMatchOK && report.CertOK && report.certificatePolicyOK()
|
report.Valid = report.IntegrityValid() && report.certificatePolicyOK()
|
||||||
return report
|
return report
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user