-
Notifications
You must be signed in to change notification settings - Fork 1
/
form_factor.go
53 lines (44 loc) · 1.95 KB
/
form_factor.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
43
44
45
46
47
48
49
50
51
52
53
// SPDX-FileCopyrightText: 2020 Google LLC
// SPDX-License-Identifier: Apache-2.0
package piv
import "fmt"
// FormFactor enumerates the physical set of forms a key can take. USB-A vs.
// USB-C and Keychain vs. Nano (and FIPS variants for these).
type FormFactor int
// The mapping between known form factor values and their descriptions.
//
//nolint:gochecknoglobals
var formFactorStrings = map[FormFactor]string{
FormFactorUSBAKeychain: "USB-A Keychain",
FormFactorUSBANano: "USB-A Nano",
FormFactorUSBCKeychain: "USB-C Keychain",
FormFactorUSBCNano: "USB-C Nano",
FormFactorUSBCLightningKeychain: "USB-C/Lightning Keychain",
FormFactorUSBAKeychainFIPS: "USB-A Keychain FIPS",
FormFactorUSBANanoFIPS: "USB-A Nano FIPS",
FormFactorUSBCKeychainFIPS: "USB-C Keychain FIPS",
FormFactorUSBCNanoFIPS: "USB-C Nano FIPS",
FormFactorUSBCLightningKeychainFIPS: "USB-C/Lightning Keychain FIPS",
}
// String returns the human-readable description for the given form-factor
// value, or a fallback value for any other, unknown form-factor.
func (f FormFactor) String() string {
if s, ok := formFactorStrings[f]; ok {
return s
}
return fmt.Sprintf("unknown(0x%02x)", int(f))
}
// Formfactors recognized by this package. See the reference for more information:
// https://developers.yubico.com/yubikey-manager/Config_Reference.html#_form_factor
const (
FormFactorUSBAKeychain = 0x1
FormFactorUSBANano = 0x2
FormFactorUSBCKeychain = 0x3
FormFactorUSBCNano = 0x4
FormFactorUSBCLightningKeychain = 0x5
FormFactorUSBAKeychainFIPS = 0x80 + FormFactorUSBAKeychain
FormFactorUSBANanoFIPS = 0x80 + FormFactorUSBANano
FormFactorUSBCKeychainFIPS = 0x80 + FormFactorUSBCKeychain
FormFactorUSBCNanoFIPS = 0x80 + FormFactorUSBCNano
FormFactorUSBCLightningKeychainFIPS = 0x80 + FormFactorUSBCLightningKeychain
)