fix(slhdsa): GenerateKey slice issue #72

This commit is contained in:
Sun Yimin 2025-09-15 10:47:33 +08:00 committed by GitHub
parent 2435170a2f
commit 0c841cd94f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -102,7 +102,7 @@ func GenerateKey(rand io.Reader, params *params) (*PrivateKey, error) {
if _, err := io.ReadFull(rand, priv.PublicKey.seed[:params.n]); err != nil {
return nil, err
}
return generateKeyInernal(priv.seed[:], priv.prf[:], priv.PublicKey.seed[:], params)
return generateKeyInernal(priv.seed[:params.n], priv.prf[:params.n], priv.PublicKey.seed[:params.n], params)
}
// NewPrivateKey creates a new PrivateKey instance from the provided priv.seed||priv.prf||pub.seed||pub.root and parameters.

View File

@ -137,3 +137,13 @@ func TestGenerateKeyInternal(t *testing.T) {
}
}
}
func TestGenerateKey(t *testing.T) {
for _, tc := range keyCases {
_, err := tc.params.GenerateKey(rand.Reader)
if err != nil {
t.Errorf("params.GenerateKey() = %v", err)
continue
}
}
}