Skip to content

Update crypto and go-jose - #1732

Open
maraino wants to merge 9 commits into
masterfrom
mariano/jose
Open

maraino wants to merge 9 commits into
masterfrom
mariano/jose

Conversation

@maraino

@maraino maraino commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

This PR updates crypto and migrates to go-jose v4, fixes the regressions the migration introduced, and moves the development tools to go tool.

Note that this branch syncs certificates@master. We will change this to a release tag before releasing the new version.

Breaking changes

go-jose v4 is stricter about oct keys, which affects existing keys:

  • HMAC keys: keys must be at least 32 bytes for HS256, 48 for HS384, and 64 for HS512. Shorter keys no longer work with step crypto jwt and step crypto jws sign and verify, and --insecure does not override the minimum in jwk create.
  • AES key wrap keys: the key size must match the algorithm exactly, which is 16, 24, or 32 bytes. jwk create enforces this, and jwe decrypt rejects existing keys that do not match. This includes keys that earlier versions created with --alg A128KW, A192KW, A128GCMKW, or A192GCMKW and no --size, which were 32 bytes.

Fixes

  • Token inspection: go-jose v4 rejects unlisted algorithms when parsing, so jwt inspect, jws inspect, and jose format could no longer show tokens using none, ES256K, or unknown algorithms. They now use the new internal/joseutil parsers, which only relax the algorithm check. jws verify and jwt verify stay strict, and tests cover this. These helpers could move to crypto later.
  • jwk create --size: oct sizes are validated with errors that point at the flag and name the unit. The 16-byte minimum for algorithms with no size of their own, like dir, is restored. The help now says bits for RSA and bytes for oct, and the shared --size flag only describes RSA, as the other commands do not support oct.
  • jwe encrypt with oct keys: it always failed with unsupported key type '<nil>', also on master, because JSONWebKey.Public() returns an empty key for symmetric keys.
  • jose format: it reordered the protected header when serializing, also on master, which invalidated the signature or authentication tag. It now keeps the original header.
  • --size errors: a size of 0 no longer reports "must be greater than or equal to 0" for RSA.

Tools

golangci-lint, goimports, govulncheck, and gotestsum are now defined in go.mod and run with go tool, as in other smallstep repositories. make bootstrap only installs GoReleaser Pro, and CI uses the same golangci-lint version. The modules compiled into step do not change.

A local go.work that uses this module fails with an ambiguous import of cloud.google.com/go/compute/metadata, because golangci-lint brings in an old compute through viper. Builds without a workspace, including CI, are not affected.

Reviewing

The commits are separate to make this easier to review. Format imports using the local prefix only changes import grouping in 85 files, after make fmt started using github.com/smallstep/cli as the local prefix, so it can be skipped.

Related: smallstep/crypto#1157

This commit updates crypto and go-jose to v4.
@maraino
maraino requested a review from a team November 6, 2026 01:20
@github-actions github-actions Bot added the needs triage Waiting for discussion / prioritization by team label Nov 6, 2026
Key IDs that are UUIDs, like the ones in step-ca-pro, are 36 characters
long and left no space before the provisioner name. Increase the column
width to 40 in `step ca acme eab list` and `step ca acme eab add`.
@maraino
maraino marked this pull request as draft November 6, 2026 01:41
dopey
dopey previously approved these changes Nov 6, 2026
Fix Key ID column width in ACME EAB output
maraino and others added 5 commits November 6, 2026 17:58
Require the minimum HMAC key lengths from RFC 7518 §3.2 and exact sizes
for AES key wrap algorithms in `step crypto jwk create`. Update the
integration tests and changelog for the new behavior.
Allow step crypto jwt inspect, jws inspect, and jose format to display
tokens with algorithms that go-jose v4 rejects when parsing, like none or
ES256K. The verify commands keep rejecting them.

Validate the --size of oct keys in jwk create in terms of the flag, in
bytes, including the minimum for algorithms without a size of their own,
like dir. Its help now states the units, and the shared flag only
describes RSA keys, as the other commands do not support oct keys.

Fix jwe encrypt with oct keys, which failed because JSONWebKey.Public()
returns an empty key for symmetric keys.

Keep the original protected header in jose format, which was reordered
when serialized, invalidating the signature or authentication tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Define golangci-lint, goimports, govulncheck, and gotestsum in go.mod and
run them with go tool, like other smallstep repositories, so their
versions are pinned and they do not need to be installed. Bootstrapping
only installs GoReleaser Pro now.

Use the same version of golangci-lint in CI, and use this module as the
local prefix in make fmt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run make fmt, which now uses github.com/smallstep/cli as the local prefix.
This only changes the grouping of imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maraino
maraino marked this pull request as ready for review November 7, 2026 02:22
@maraino
maraino requested review from a team and dopey November 7, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs triage Waiting for discussion / prioritization by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants