You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
package profile
|
|
|
|
import "encoding/hex"
|
|
|
|
// Status is the state of a Provider Profile in the registry of profiles of
|
|
// DateKeys (spec §71).
|
|
type Status int
|
|
|
|
const (
|
|
// Active: capsules are written and opened with the profile.
|
|
Active Status = iota
|
|
// ReadOnly: no new capsule is written with the profile, because its
|
|
// provider announces its end or is suspected; the capsules that exist
|
|
// still open.
|
|
ReadOnly
|
|
// Compromised: there is proof that the confidentiality of the profile
|
|
// failed. The capsules that exist still open, and the official SDK warns
|
|
// that their content may have been read before their date.
|
|
Compromised
|
|
)
|
|
|
|
func (s Status) String() string {
|
|
switch s {
|
|
case Active:
|
|
return "active"
|
|
case ReadOnly:
|
|
return "read-only"
|
|
case Compromised:
|
|
return "compromised"
|
|
}
|
|
return "unknown"
|
|
}
|
|
|
|
// statuses are the states of the profiles that this release of the module
|
|
// pins, by profile_hash: DateKeys does not publish the signed registry of
|
|
// §71 yet, so a change of state comes with a new release of the module.
|
|
var statuses = map[string]Status{
|
|
QuicknetProfileHash: Active,
|
|
}
|
|
|
|
// StatusOf returns the state of the profile whose profile_hash is hash, and
|
|
// whether this release of the module knows it.
|
|
func StatusOf(hash [32]byte) (Status, bool) {
|
|
s, ok := statuses[hex.EncodeToString(hash[:])]
|
|
return s, ok
|
|
}
|