You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// SignASN1 signs a hash (which should be the result of hashing a larger message)// using the private key, priv. If the hash is longer than the bit-length of the// private key's curve order, the hash will be truncated to that length. It// returns the ASN.1 encoded signature.//// The signature is randomized. Most applications should use [crypto/rand.Reader]// as rand. Note that the returned signature does not depend deterministically on// the bytes read from rand, and may change between calls and/or between versions.//// If the opts argument is instance of [*SM2SignerOption], and its ForceGMSign is true,// then the hash will be treated as raw message.funcSignASN1(rand io.Reader, priv*PrivateKey, hash []byte, opts crypto.SignerOpts) ([]byte, error) {
ifsm2Opts, ok:=opts.(*SM2SignerOption); ok&&sm2Opts.forceGMSign {
newHash, err:=calculateSM2Hash(&priv.PublicKey, hash, sm2Opts.uid)
iferr!=nil {
returnnil, err
}
hash=newHash
}
randutil.MaybeReadByte(rand)
//TODO: Do we need to use this CSPRNG for SM2 DSA?//There are no standard and dependencies with sha512 and AES-CTRcsprng, err:=mixedCSPRNG(rand, &priv.PrivateKey, hash)
iferr!=nil {
returnnil, err
}
switchpriv.Curve.Params() {
caseP256().Params():
returnsignSM2EC(p256(), priv, csprng, hash)
default:
returnsignLegacy(priv, csprng, hash)
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
由于:
基于上述结论,准备在下个release(应该是v0.18.1)取消目前的CSPRNG。
Beta Was this translation helpful? Give feedback.
All reactions