mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-26 16:09:45 -05:00
bd63aa3c6b
sed -i '1i/*\nCopyright (c) Edgeless Systems GmbH\n\nSPDX-License-Identifier: AGPL-3.0-only\n*/\n' `grep -rL --include='*.go' 'DO NOT EDIT'` gofumpt -w .
30 lines
1009 B
Go
30 lines
1009 B
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package attestation
|
|
|
|
import (
|
|
"github.com/edgelesssys/constellation/internal/crypto"
|
|
)
|
|
|
|
const (
|
|
// clusterIDContext is the value to use for info when deriving the cluster ID.
|
|
clusterIDContext = "clusterID"
|
|
// MeasurementSecretContext is the value to use for info
|
|
// when deriving the measurement secret from the master secret.
|
|
MeasurementSecretContext = "measurementSecret"
|
|
)
|
|
|
|
// DeriveClusterID derives the cluster ID from a salt and secret value.
|
|
func DeriveClusterID(secret, salt []byte) ([]byte, error) {
|
|
return crypto.DeriveKey(secret, salt, []byte(crypto.HKDFInfoPrefix+clusterIDContext), crypto.DerivedKeyLengthDefault)
|
|
}
|
|
|
|
// DeriveMeasurementSecret derives the secret value needed to derive ClusterID.
|
|
func DeriveMeasurementSecret(masterSecret, salt []byte) ([]byte, error) {
|
|
return crypto.DeriveKey(masterSecret, salt, []byte(crypto.HKDFInfoPrefix+MeasurementSecretContext), crypto.DerivedKeyLengthDefault)
|
|
}
|