2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-07-26 04:58:39 -04:00
|
|
|
package attestation
|
|
|
|
|
|
|
|
import (
|
2022-09-21 07:47:57 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/crypto"
|
2022-07-26 04:58:39 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
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.
|
2022-07-29 03:52:47 -04:00
|
|
|
func DeriveClusterID(secret, salt []byte) ([]byte, error) {
|
2022-07-26 04:58:39 -04:00
|
|
|
return crypto.DeriveKey(secret, salt, []byte(crypto.HKDFInfoPrefix+clusterIDContext), crypto.DerivedKeyLengthDefault)
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeriveMeasurementSecret derives the secret value needed to derive ClusterID.
|
2022-07-29 03:52:47 -04:00
|
|
|
func DeriveMeasurementSecret(masterSecret, salt []byte) ([]byte, error) {
|
|
|
|
return crypto.DeriveKey(masterSecret, salt, []byte(crypto.HKDFInfoPrefix+MeasurementSecretContext), crypto.DerivedKeyLengthDefault)
|
2022-07-26 04:58:39 -04:00
|
|
|
}
|