Skip to content

Move crypto fallback logic to cryptobackend #2489

Description

@qmuntal

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()
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions