Skip to content

crypto.NewGCMWithRandomNonce error for go >= 1.24 in FIPS mode #1648

Open
@simitt

Description

@simitt

Problem Description

Calling crypto.NewGCMWithRandomNonce in FIPS mode returns an error.

When building a go program with the Microsoft build of Go and GOEXPERIMENT=systemcrypto and running it with GOFIPS=1, the following code

cipher, err := aes.NewCipher(key)
if err != nil {
  return  err
}
aesgcm, err := cipher.NewGCMWithRandomNonce(cipher)
if err != nil {
  return  err
}

leads to this error:

cipher: NewGCMWithRandomNonce requires aes.Block

The error seems to come from a concrete type check. When using microsoft/go in FIPS mode, the cipher is not of this concrete type.

Expectations

With the introduction of crypto.NewGCMWithRandomNonce as part of the go std-lib crypto package, microsoft/go 1.24 should also support this functionality.

Related Issues

Similar issue to what was reported for usage with boringcrypto in golang/go#72016.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions