-
Notifications
You must be signed in to change notification settings - Fork 5
/
provider.go
42 lines (36 loc) · 911 Bytes
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2021 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
package requests
// ProviderID for providers
type ProviderID uint8
// Provider UUIDs
const (
ProviderCore ProviderID = 0
ProviderMBed ProviderID = 1
ProviderPKCS11 ProviderID = 2
ProviderTPM ProviderID = 3
ProviderTrustedService ProviderID = 4
)
// HasCrypto returns true if the provider supports crypto
func (p ProviderID) HasCrypto() bool {
return p.IsValid() && p != ProviderCore
}
func (p ProviderID) IsValid() bool {
return p >= ProviderCore && p <= ProviderTrustedService
}
func (p ProviderID) String() string {
switch p {
case ProviderCore:
return "Core"
case ProviderMBed:
return "MBed"
case ProviderPKCS11:
return "PKCS11"
case ProviderTPM:
return "TPM"
case ProviderTrustedService:
return "TrustedService"
default:
return "Unknown"
}
}