Skip to content

x-pack/libbeat/common/cloudfoundry: Use xxhash instead of SHA1 #43964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 28, 2025
Merged
8 changes: 0 additions & 8 deletions x-pack/libbeat/common/cloudfoundry/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
package cloudfoundry

import (
"crypto/sha1"
"encoding/base64"
"fmt"
"time"

Expand Down Expand Up @@ -139,9 +137,3 @@ func (c *clientCacheWrap) Close() error {
}
return nil
}

// sanitizeCacheName returns a unique string that can be used safely as part of a file name
func sanitizeCacheName(name string) string {
hash := sha1.Sum([]byte(name))
return base64.RawURLEncoding.EncodeToString(hash[:])
}
18 changes: 18 additions & 0 deletions x-pack/libbeat/common/cloudfoundry/cache_utils_fips.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

//go:build requirefips

package cloudfoundry

import (
"crypto/sha256"
"encoding/base64"
)

// sanitizeCacheName returns a unique string that can be used safely as part of a file name
func sanitizeCacheName(name string) string {
hash := sha256.Sum224([]byte(name))
return base64.RawURLEncoding.EncodeToString(hash[:])
}
18 changes: 18 additions & 0 deletions x-pack/libbeat/common/cloudfoundry/cache_utils_nofips.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

//go:build !requirefips

package cloudfoundry

import (
"crypto/sha1"
"encoding/base64"
)

// sanitizeCacheName returns a unique string that can be used safely as part of a file name
func sanitizeCacheName(name string) string {
hash := sha1.Sum([]byte(name))
return base64.RawURLEncoding.EncodeToString(hash[:])
}