x509 CheckSignature 参数
x509 CheckSignature parameter
在 x509 库中,有一个名为 CheckSignature
的函数。对于要传递给 signed
的内容,我有点不知所措。它应该是什么?
函数是
func (c *Certificate) CheckSignature(algo SignatureAlgorithm, signed, signature []byte) (err error)
https://golang.org/src/crypto/x509/x509.go?s=21660:21759#L623
我想加倍的另一件事是,如果我使用与证书关联的私钥签署某些内容,该签名会通过此 CheckSignature
功能吗?
signed
看起来是 signer.
的 ASN.1 DER 格式的证书
您需要使用父证书来检查颁发的证书上的签名。例如:
// parent is the parent x509.Certificate
// cert is the certificate signed by the parent
// alg is the algorithm used to sign, eg x509.PureEd25519
alg := cert.SignatureAlgorithm
err := parent.CheckSignature(alg, cert.RawTBSCertificate, cert.Signature)
if err != nil {
return errors.New("Signature invalid")
}
在 x509 库中,有一个名为 CheckSignature
的函数。对于要传递给 signed
的内容,我有点不知所措。它应该是什么?
函数是
func (c *Certificate) CheckSignature(algo SignatureAlgorithm, signed, signature []byte) (err error)
https://golang.org/src/crypto/x509/x509.go?s=21660:21759#L623
我想加倍的另一件事是,如果我使用与证书关联的私钥签署某些内容,该签名会通过此 CheckSignature
功能吗?
signed
看起来是 signer.
您需要使用父证书来检查颁发的证书上的签名。例如:
// parent is the parent x509.Certificate
// cert is the certificate signed by the parent
// alg is the algorithm used to sign, eg x509.PureEd25519
alg := cert.SignatureAlgorithm
err := parent.CheckSignature(alg, cert.RawTBSCertificate, cert.Signature)
if err != nil {
return errors.New("Signature invalid")
}