Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
test:
strategy:
matrix:
go: ["1.20", "1.21"]
go: ["1.24", "1.25"]

runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 9 additions & 1 deletion client_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package tokens

import (
"crypto/ed25519"
"crypto/fips140"
"crypto/md5"
"crypto/sha256"
"encoding/hex"
"fmt"
"os"
Expand Down Expand Up @@ -92,7 +94,13 @@ var (

// UniqueID returns the caller id and unique id used to generate private inboxes
func (c *ClientIDClaims) UniqueID() (id string, uid string) {
return c.CallerID, fmt.Sprintf("%x", md5.Sum([]byte(c.CallerID)))
var hash any
if fips140.Enabled() {
hash = sha256.Sum256([]byte(c.CallerID))
} else {
hash = md5.Sum([]byte(c.CallerID))
}
return c.CallerID, fmt.Sprintf("%x", hash)
}

// NewClientIDClaims generates new ClientIDClaims
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/choria-io/tokens

go 1.20
go 1.24.0

require (
github.com/golang-jwt/jwt/v4 v4.5.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOW
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand Down
10 changes: 9 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ package tokens
import (
"bytes"
"crypto/ed25519"
"crypto/fips140"
"crypto/md5"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
Expand Down Expand Up @@ -57,7 +59,13 @@ var (

// UniqueID returns the identity and unique id used to generate private inboxes
func (c *ServerClaims) UniqueID() (id string, uid string) {
return c.ChoriaIdentity, fmt.Sprintf("%x", md5.Sum([]byte(c.ChoriaIdentity)))
var hash any
if fips140.Enabled() {
hash = sha256.Sum256([]byte(c.ChoriaIdentity))
} else {
hash = md5.Sum([]byte(c.ChoriaIdentity))
}
return c.ChoriaIdentity, fmt.Sprintf("%x", hash)
}

// IsMatchingPublicKey checks that the stored public key matches the supplied one
Expand Down