-
Notifications
You must be signed in to change notification settings - Fork 0
/
encryption_alg.ts
57 lines (54 loc) · 1.38 KB
/
encryption_alg.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as proto from "../../bridge/proto/encryption_entities";
/**
* Represents encryption algorithm types.
*/
export enum EncryptionAlg {
/**
* Represents the AES-256-GCM encryption algorithm.
*/
AES256GCM = 0,
/**
* Represents the AES-256-GCM with managed key encryption algorithm.
*/
AES256GCM_M = 1,
/**
* Represents the RSA encryption algorithm.
*/
RSA = 2,
/**
* Represents the RSA with managed key encryption algorithm.
*/
RSA_M = 3,
/**
* Represents an unrecognized encryption algorithm.
*/
UNRECOGNIZED = -1
}
export namespace EncryptionAlg {
export function toProto(alg: EncryptionAlg): proto.EncryptionAlg {
switch (alg) {
case EncryptionAlg.AES256GCM:
return proto.EncryptionAlg.A256GCM;
case EncryptionAlg.AES256GCM_M:
return proto.EncryptionAlg.A256GCM_M;
case EncryptionAlg.RSA:
return proto.EncryptionAlg.RSA;
case EncryptionAlg.RSA_M:
return proto.EncryptionAlg.RSA_M;
default:
return proto.EncryptionAlg.UNRECOGNIZED;
}
}
export function fromProto(
alg: proto.EncryptionAlg | undefined
): EncryptionAlg {
switch (alg) {
case proto.EncryptionAlg.A256GCM:
return EncryptionAlg.AES256GCM;
case proto.EncryptionAlg.RSA:
return EncryptionAlg.RSA;
default:
return EncryptionAlg.UNRECOGNIZED;
}
}
}