Ideally patching the crypto packages to support our crypto backends would be a matter of replacing the crypto/internal/fips140/... imports for github.com/microsoft/go/cryptobackend/....
We have already changed the cryptobackend packages layout to match fips140 1:1. The next piece is moving the fallback logic (all these cryptobackend.SupportsX calls) into the cryptobackend itself. Note that this should be possible in most of the cases because we have patched the linker to allow cryptobackend to call crypto/internal packages even when it being outside of the standard library.
The end goal is to replace this:
import (
"crypto/internal/fips140/sha256"
"github.com/microsoft/go/cryptobackend"
bsha256 "github.com/microsoft/go/cryptobackend/sha256"
)
func New224() hash.Hash {
if cryptobackend.Enabled && sha256.SupportsSHA224() {
return sha256.NewSHA224()
}
return sha256.New224()
}
into this:
import (
sha256 "github.com/microsoft/go/cryptobackend/sha256"
)
func New224() hash.Hash {
return sha256.New224()
}
Ideally patching the crypto packages to support our crypto backends would be a matter of replacing the
crypto/internal/fips140/...imports forgithub.com/microsoft/go/cryptobackend/....We have already changed the
cryptobackendpackages layout to matchfips1401:1. The next piece is moving the fallback logic (all thesecryptobackend.SupportsXcalls) into thecryptobackenditself. Note that this should be possible in most of the cases because we have patched the linker to allowcryptobackendto callcrypto/internalpackages even when it being outside of the standard library.The end goal is to replace this:
into this: