分组和注释

This commit is contained in:
Quan guanyu 2025-09-29 14:45:18 +08:00
parent 8464ad14f7
commit 69e446d7b2
5 changed files with 9 additions and 6 deletions

View File

@ -263,8 +263,8 @@ func (hd *BaseDrbg) setSecurityLevel(securityLevel SecurityLevel) {
} }
// Destroy 对 GM/T 0105-2021 B.2、E.2 对内部状态进行清零处理 // Destroy 对 GM/T 0105-2021 B.2、E.2 对内部状态进行清零处理
// 内部状态组成为 {V,C, reseed_counter, last_reseed_time,reseed_interval_in_counter, reseed_interval_in_time} // HASH RNG 内部状态组成为 {V,C, reseed_counter, last_reseed_time,reseed_interval_in_counter, reseed_interval_in_time}
// 内部状态组成为 {V,Key, reseed_counter, last_reseed_time,reseed_interval_in_counter, reseed_interval_in_time} // HMAC/对称加密 RNG 内部状态组成为 {V,Key, reseed_counter, last_reseed_time,reseed_interval_in_counter, reseed_interval_in_time}
func (hd *BaseDrbg) Destroy() { func (hd *BaseDrbg) Destroy() {
setZero(hd.v) setZero(hd.v)
hd.seedLength = 0 hd.seedLength = 0

View File

@ -223,6 +223,8 @@ func (cd *CtrDrbg) bcc(block cipher.Block, data []byte) []byte {
return chainingValue return chainingValue
} }
// Destroy destroys the internal state of HMAC DRBG instance
// 对称加密的RNG内部状态组成为 {V,Key, reseed_counter, last_reseed_time,reseed_interval_in_counter, reseed_interval_in_time}
func (cd *CtrDrbg) Destroy() { func (cd *CtrDrbg) Destroy() {
cd.BaseDrbg.Destroy() cd.BaseDrbg.Destroy()
setZero(cd.key) setZero(cd.key)

View File

@ -224,7 +224,7 @@ func (hd *HashDrbg) derive(seedMaterial []byte, len int) []byte {
} }
// Destroy 根据 GM/T 0105-2021 B.2 对内部状态进行清零处理 // Destroy 根据 GM/T 0105-2021 B.2 对内部状态进行清零处理
// 内部状态组成为 {V,C, reseed_counter, last_reseed_time,reseed_interval_in_counter, reseed_interval_in_time} // SM3_RNG 内部状态组成为 {V,C, reseed_counter, last_reseed_time,reseed_interval_in_counter, reseed_interval_in_time}
func (hd *HashDrbg) Destroy() { func (hd *HashDrbg) Destroy() {
hd.BaseDrbg.Destroy() hd.BaseDrbg.Destroy()
setZero(hd.c) setZero(hd.c)

View File

@ -154,8 +154,8 @@ func (hd *HmacDrbg) update(byteSlices ...[]byte) error {
return nil return nil
} }
// Destroy 根据 GM/T 0105-2021 E.2 对内部状态进行清零处理 // Destroy destroys the internal state of HMAC DRBG instance
// 内部状态组成为 {V,Key, reseed_counter, last_reseed_time,reseed_interval_in_counter, reseed_interval_in_time} // HMAC的RNG内部状态组成为 {V,Key, reseed_counter, last_reseed_time,reseed_interval_in_counter, reseed_interval_in_time}
func (hd *HmacDrbg) Destroy() { func (hd *HmacDrbg) Destroy() {
hd.BaseDrbg.Destroy() hd.BaseDrbg.Destroy()
setZero(hd.key) setZero(hd.key)

View File

@ -7,9 +7,10 @@ import (
"crypto/sha256" "crypto/sha256"
"crypto/sha512" "crypto/sha512"
"encoding/hex" "encoding/hex"
"github.com/emmansun/gmsm/sm3"
"hash" "hash"
"testing" "testing"
"github.com/emmansun/gmsm/sm3"
) )
var hmactests = []struct { var hmactests = []struct {