-
Notifications
You must be signed in to change notification settings - Fork 0
/
key_protection_level.ts
41 lines (38 loc) · 1.08 KB
/
key_protection_level.ts
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
import * as keysEntitiesProto from "../../bridge/proto/keys_entities";
/**
* Represents the protection level of a cryptographic key.
*/
export enum KeyProtectionLevel {
/**
* Indicates that the key is protected by software.
*/
SOFTWARE,
/**
* Indicates that the key is protected by a Hardware Security Module (HSM).
*/
HSM
}
export namespace KeyProtectionLevel {
export function toProto(
type: KeyProtectionLevel
): keysEntitiesProto.KeyProtectionLevel {
switch (type) {
case KeyProtectionLevel.SOFTWARE:
return keysEntitiesProto.KeyProtectionLevel.SOFTWARE;
case KeyProtectionLevel.HSM:
return keysEntitiesProto.KeyProtectionLevel.HSM;
}
}
export function fromProto(
type: keysEntitiesProto.KeyProtectionLevel | undefined
): KeyProtectionLevel {
switch (type) {
case keysEntitiesProto.KeyProtectionLevel.SOFTWARE:
return KeyProtectionLevel.SOFTWARE;
case keysEntitiesProto.KeyProtectionLevel.HSM:
return KeyProtectionLevel.HSM;
default:
return KeyProtectionLevel.SOFTWARE;
}
}
}