5f449a75b934beebe51084bdb348ba7a22524d2a
[squeep-mystery-box] / lib / version-parameters.js
1 'use strict';
2
3 const ALG = {
4 AES_256_GCM: 'aes-256-gcm',
5 CHACHA20_POLY1305: 'chacha20-poly1305',
6 XCHACHA20_POLY1305: 'xchacha20-poly1305',
7 };
8
9 const KD = {
10 SCRYPT: 'scrypt',
11 SHAKE256: 'shake256',
12 BLAKE2B512: 'blake2b512',
13 };
14
15 /**
16 * Supported packings/cipher types.
17 * To be useful, any cipher included here must be Authenticated Encryption with Additional Data (AEAD).
18 * More preferable versions are numbered higher.
19 */
20 const allVersions = {
21 1: {
22 version: 1,
23 algorithm: ALG.AES_256_GCM,
24 algOptions: {},
25 versionBytes: 1,
26 flagsBytes: 1,
27 ivBytes: 12,
28 saltBytes: 16,
29 tagBytes: 16,
30 keyDeriver: KD.SCRYPT,
31 keyBytes: 32,
32 },
33 2: {
34 version: 2,
35 algorithm: ALG.CHACHA20_POLY1305, // Prefer this over NIST because we stan djb
36 algOptions: {
37 authTagLength: 16,
38 },
39 versionBytes: 1,
40 flagsBytes: 1,
41 ivBytes: 12,
42 saltBytes: 16,
43 tagBytes: 16,
44 keyDeriver: KD.SCRYPT,
45 keyBytes: 32,
46 },
47 3: {
48 version: 3,
49 algorithm: ALG.XCHACHA20_POLY1305, // Not yet available, but would prefer even more...
50 algOptions: {
51 authTagLength: 16,
52 },
53 versionBytes: 1,
54 flagsBytes: 1,
55 ivBytes: 24,
56 saltBytes: 16,
57 tagBytes: 16,
58 keyDeriver: KD.SCRYPT,
59 keyBytes: 32,
60 },
61 4: {
62 version: 4,
63 algorithm: ALG.AES_256_GCM,
64 algOptions: {},
65 versionBytes: 1,
66 flagsBytes: 1,
67 ivBytes: 12,
68 saltBytes: 16,
69 tagBytes: 16,
70 keyDeriver: KD.SHAKE256,
71 keyBytes: 32,
72 },
73 5: {
74 version: 5,
75 algorithm: ALG.CHACHA20_POLY1305,
76 algOptions: {
77 authTagLength: 16,
78 },
79 versionBytes: 1,
80 flagsBytes: 1,
81 ivBytes: 12,
82 saltBytes: 16,
83 tagBytes: 16,
84 keyDeriver: KD.SHAKE256,
85 keyBytes: 32,
86 },
87 6: {
88 version: 6,
89 algorithm: ALG.XCHACHA20_POLY1305, // Not yet available, but would prefer even more...
90 algOptions: {
91 authTagLength: 16,
92 },
93 versionBytes: 1,
94 flagsBytes: 1,
95 ivBytes: 24,
96 saltBytes: 16,
97 tagBytes: 16,
98 keyDeriver: KD.SHAKE256,
99 keyBytes: 32,
100 },
101 7: {
102 version: 7,
103 algorithm: ALG.AES_256_GCM,
104 algOptions: {},
105 versionBytes: 1,
106 flagsBytes: 1,
107 ivBytes: 12,
108 saltBytes: 16,
109 tagBytes: 16,
110 keyDeriver: KD.BLAKE2B512,
111 keyBytes: 32,
112 },
113 8: {
114 version: 8,
115 algorithm: ALG.CHACHA20_POLY1305,
116 algOptions: {
117 authTagLength: 16,
118 },
119 versionBytes: 1,
120 flagsBytes: 1,
121 ivBytes: 12,
122 saltBytes: 16,
123 tagBytes: 16,
124 keyDeriver: KD.BLAKE2B512,
125 keyBytes: 32,
126 },
127 9: {
128 version: 9,
129 algorithm: ALG.XCHACHA20_POLY1305, // Not yet available, but would prefer even more...
130 algOptions: {
131 authTagLength: 16,
132 },
133 versionBytes: 1,
134 flagsBytes: 1,
135 ivBytes: 24,
136 saltBytes: 16,
137 tagBytes: 16,
138 keyDeriver: KD.BLAKE2B512,
139 keyBytes: 32,
140 },
141 };
142
143 module.exports = allVersions;