Skip to content

Commit 6a6c6c8

Browse files
gdamsqmuntal
andauthored
Apply suggestions from code review
Co-authored-by: Quim Muntal <qmuntaldiaz@microsoft.com>
1 parent f68ee16 commit 6a6c6c8

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

cng/mlkem.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func SupportsMLKEM() bool {
8181
func generateMLKEMKey(paramSet string, dst []byte) error {
8282
alg, err := loadMLKEM()
8383
if err != nil {
84-
return errors.New("mlkem: failed to open algorithm provider")
84+
return err
8585
}
8686

8787
var hKey bcrypt.KEY_HANDLE
@@ -92,12 +92,9 @@ func generateMLKEMKey(paramSet string, dst []byte) error {
9292
defer bcrypt.DestroyKey(hKey)
9393

9494
// Set the parameter set
95-
paramSetUTF16 := utf16FromString(paramSet)
96-
paramSetBytes := make([]byte, len(paramSetUTF16)*2)
97-
for i, v := range paramSetUTF16 {
98-
putUint16LE(paramSetBytes[i*2:], v)
95+
if err := setString(bcrypt.HANDLE(hKey), bcrypt.PARAMETER_SET_NAME, paramSet); err != nil {
96+
return err
9997
}
100-
err = bcrypt.SetProperty(bcrypt.HANDLE(hKey), utf16PtrFromString(bcrypt.PARAMETER_SET_NAME), paramSetBytes, 0)
10198
if err != nil {
10299
return errors.New("mlkem: failed to set parameter set")
103100
}

0 commit comments

Comments
 (0)