mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 08:20:07 +01:00
Compare commits
960 Commits
v2.3.x
...
v2.5.0-rc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf2e48e404 | ||
|
|
d943b2efb9 | ||
|
|
02d5c5ce38 | ||
|
|
bdc97ef389 | ||
|
|
6540ffd1a6 | ||
|
|
c7a8c9a620 | ||
|
|
d96dcff883 | ||
|
|
4034c548c2 | ||
|
|
8eff391a66 | ||
|
|
dae6aa0384 | ||
|
|
a2afe0396f | ||
|
|
fec2517386 | ||
|
|
c413434715 | ||
|
|
aa126ac10a | ||
|
|
56d4e9924e | ||
|
|
a60fd0a81b | ||
|
|
af68e8a1da | ||
|
|
13f6dfa61f | ||
|
|
8493f6afd5 | ||
|
|
1a55b69a0f | ||
|
|
914f621251 | ||
|
|
5904516122 | ||
|
|
4507ced868 | ||
|
|
b4603f1e28 | ||
|
|
1c21c24f7b | ||
|
|
0009d9532e | ||
|
|
47cb9b0ee2 | ||
|
|
0ffd105cb8 | ||
|
|
24d498e393 | ||
|
|
3c8b3201d7 | ||
|
|
f531b567e0 | ||
|
|
7c76881921 | ||
|
|
f642417ed7 | ||
|
|
1c1df24258 | ||
|
|
b3e8e1a9d4 | ||
|
|
d22b003640 | ||
|
|
a485f44b57 | ||
|
|
f182d73001 | ||
|
|
05fc7b172d | ||
|
|
66c5b52b42 | ||
|
|
af3559a0f6 | ||
|
|
bcde337a42 | ||
|
|
83103627b2 | ||
|
|
8f8703f1c3 | ||
|
|
857d17d210 | ||
|
|
62a3954c9d | ||
|
|
c72aecf86d | ||
|
|
d9b66afe5e | ||
|
|
18ada2b7de | ||
|
|
279490b622 | ||
|
|
dfd96d8a39 | ||
|
|
ba9e36ceae | ||
|
|
f97af5dcfe | ||
|
|
b4e9bca354 | ||
|
|
c36f9899cf | ||
|
|
f3a46b8e93 | ||
|
|
b84132c140 | ||
|
|
90ff707bff | ||
|
|
f00d897240 | ||
|
|
daa2b60d62 | ||
|
|
4892b24d6a | ||
|
|
369a18cd3b | ||
|
|
2240e75bb9 | ||
|
|
3a4e38736c | ||
|
|
dff34a1251 | ||
|
|
c08aa21a93 | ||
|
|
cbf82733ae | ||
|
|
75e429b8d1 | ||
|
|
e23992d531 | ||
|
|
f881092bbc | ||
|
|
ba37298e4f | ||
|
|
98ca9c61d6 | ||
|
|
ee5a7d19c9 | ||
|
|
7b4d5fe067 | ||
|
|
07f8dfc46d | ||
|
|
99a3d328f0 | ||
|
|
e8ec3e1005 | ||
|
|
007e56727c | ||
|
|
4de09ace8f | ||
|
|
97b88d878e | ||
|
|
b43ca18c64 | ||
|
|
0768d3be84 | ||
|
|
828cfdb6a2 | ||
|
|
582f2c3449 | ||
|
|
bf0d0203e8 | ||
|
|
b75a6d2b64 | ||
|
|
450265c153 | ||
|
|
cfb54be9a3 | ||
|
|
828ddad7c2 | ||
|
|
dd3fe9f5fd | ||
|
|
692bb8a455 | ||
|
|
6ac27f50ad | ||
|
|
93f90bf0f7 | ||
|
|
e921991ba5 | ||
|
|
4913de11fc | ||
|
|
82a6ae3c25 | ||
|
|
ddc8c9c441 | ||
|
|
fc49a258bd | ||
|
|
a1734e2d52 | ||
|
|
8f97d9b6e6 | ||
|
|
fa12a0a490 | ||
|
|
d9dad29149 | ||
|
|
fc4b2cab25 | ||
|
|
d9eff7ffd7 | ||
|
|
2820626f5e | ||
|
|
1cdb7da2ad | ||
|
|
e00eecf9ca | ||
|
|
346f104f26 | ||
|
|
082d23af92 | ||
|
|
392b0136dc | ||
|
|
3a4ced84a6 | ||
|
|
16c35d155a | ||
|
|
97a22c27dd | ||
|
|
bce9bd3a3b | ||
|
|
59692e3ca2 | ||
|
|
39fda3bed1 | ||
|
|
2d2f230c9d | ||
|
|
4dd514a12f | ||
|
|
7e6c48f67c | ||
|
|
360bd7f68d | ||
|
|
f1fd38c726 | ||
|
|
795b37d128 | ||
|
|
5aa01da2b5 | ||
|
|
3341bfd6c5 | ||
|
|
6c73057156 | ||
|
|
5d9e362553 | ||
|
|
4d6e9e7c32 | ||
|
|
227fdb7393 | ||
|
|
251eb37c4a | ||
|
|
0009089855 | ||
|
|
41d61df667 | ||
|
|
8945f3e9e2 | ||
|
|
8606865e15 | ||
|
|
9e7894081f | ||
|
|
0c80ee6c28 | ||
|
|
853abf53f5 | ||
|
|
3173595fc9 | ||
|
|
ede2a8a45f | ||
|
|
6631033d8a | ||
|
|
fe3878199c | ||
|
|
2bf0f537f6 | ||
|
|
4f44bb40b7 | ||
|
|
3ee0b37303 | ||
|
|
a25d10407d | ||
|
|
ae3ce2a207 | ||
|
|
2d8cdb2e35 | ||
|
|
ceed3c0c3b | ||
|
|
e161cd1859 | ||
|
|
ff14c17de7 | ||
|
|
1ac6a58475 | ||
|
|
2dbd96ebbf | ||
|
|
a29f74b5ad | ||
|
|
cc107ee20e | ||
|
|
c67db10c22 | ||
|
|
65a5943ee5 | ||
|
|
5a8b95aa45 | ||
|
|
f391f4baf1 | ||
|
|
4cdcd908f4 | ||
|
|
1d6a445e43 | ||
|
|
ed13852899 | ||
|
|
efc1590405 | ||
|
|
4b1ba47ca1 | ||
|
|
e4a0d25315 | ||
|
|
81a63aca22 | ||
|
|
ebabf3ffee | ||
|
|
3363bad8c2 | ||
|
|
773fc0195f | ||
|
|
d3ad18ad81 | ||
|
|
5c7858883c | ||
|
|
c9da460b6c | ||
|
|
38d1f01b12 | ||
|
|
624026a98f | ||
|
|
f6452e1656 | ||
|
|
2388777763 | ||
|
|
be5c5788d4 | ||
|
|
f1eea3a4b3 | ||
|
|
2857e10083 | ||
|
|
99c4c3adbf | ||
|
|
f34b3b27ec | ||
|
|
ab6762b849 | ||
|
|
3fbc480e32 | ||
|
|
ce1c39dc54 | ||
|
|
9b60e2d959 | ||
|
|
e89071e73f | ||
|
|
dbd4dc1dc0 | ||
|
|
acd2601bd7 | ||
|
|
d56ccc97b8 | ||
|
|
412de7dc25 | ||
|
|
8c350b65a3 | ||
|
|
83ef36bd59 | ||
|
|
c07cfa20de | ||
|
|
6d8587c137 | ||
|
|
d43b495f21 | ||
|
|
e97238fb6d | ||
|
|
c9ead0482d | ||
|
|
9c26a73d96 | ||
|
|
ea35573c82 | ||
|
|
d3079c2fb3 | ||
|
|
b661452e3a | ||
|
|
31c4afbc17 | ||
|
|
496a0e37c4 | ||
|
|
8c04264fb3 | ||
|
|
db1ff4cf88 | ||
|
|
3e4368feeb | ||
|
|
faee0e694f | ||
|
|
7a38f16cef | ||
|
|
08aa2ca242 | ||
|
|
3a56cf05bf | ||
|
|
b6c36f50ba | ||
|
|
b050448db9 | ||
|
|
68796e12dd | ||
|
|
650c7e8b67 | ||
|
|
0dc18fba22 | ||
|
|
1116289de4 | ||
|
|
1595fcf479 | ||
|
|
c4c1ca2224 | ||
|
|
2b42968e92 | ||
|
|
e2a5af9e64 | ||
|
|
e4ed545cbf | ||
|
|
65be641f20 | ||
|
|
ce55fa4d1c | ||
|
|
92baacadad | ||
|
|
2e59229e5a | ||
|
|
3f42b69fc8 | ||
|
|
b10c0b6a02 | ||
|
|
f388662418 | ||
|
|
8bc10ee853 | ||
|
|
b663b9305c | ||
|
|
828555db97 | ||
|
|
ba08f02a40 | ||
|
|
a55b0530a4 | ||
|
|
a2f30ebd4c | ||
|
|
d20d41c7a5 | ||
|
|
4eba55c73e | ||
|
|
29ddd68a0f | ||
|
|
9707b71f98 | ||
|
|
36cdda870b | ||
|
|
9b8a872006 | ||
|
|
45b808c186 | ||
|
|
87afb9d783 | ||
|
|
86402a1102 | ||
|
|
64e7c3d3b1 | ||
|
|
f6c1445c6b | ||
|
|
f5724a30f9 | ||
|
|
47f31205cf | ||
|
|
5bd5462a9e | ||
|
|
d1f0376c77 | ||
|
|
dae91fd9ec | ||
|
|
df4ed89141 | ||
|
|
559012b6a7 | ||
|
|
6534e86c22 | ||
|
|
70c1eb7352 | ||
|
|
dee2fa7159 | ||
|
|
3af754b5eb | ||
|
|
3b85ab2dc1 | ||
|
|
2a5483d8c3 | ||
|
|
8340d0cb1a | ||
|
|
3cd5d83ee9 | ||
|
|
6852c49d0c | ||
|
|
63c79256e4 | ||
|
|
75622b332b | ||
|
|
c1e94abbab | ||
|
|
1af7eefbc0 | ||
|
|
bf4a039d50 | ||
|
|
0085985419 | ||
|
|
12c35da768 | ||
|
|
677e06c48a | ||
|
|
c27d6a89bb | ||
|
|
e5ce189db8 | ||
|
|
3407cbbad1 | ||
|
|
2c91590d52 | ||
|
|
c5e500ea0f | ||
|
|
5efe03ddd7 | ||
|
|
8ab41e0776 | ||
|
|
f671febe64 | ||
|
|
0a9f14c658 | ||
|
|
6b774e617b | ||
|
|
0d6b63a6a2 | ||
|
|
6018d2bcd8 | ||
|
|
d5dbde5dd1 | ||
|
|
ef7559bad9 | ||
|
|
e9e994fb0d | ||
|
|
c5d9f3f380 | ||
|
|
d23943f989 | ||
|
|
b47b89adac | ||
|
|
452467661e | ||
|
|
bef46c950d | ||
|
|
5c323e9146 | ||
|
|
33d8605924 | ||
|
|
76086dbe95 | ||
|
|
7eb44f32a3 | ||
|
|
cef0dc059a | ||
|
|
e4091fe8a5 | ||
|
|
685148af00 | ||
|
|
8798aa0a75 | ||
|
|
7ca1a233f1 | ||
|
|
ab295b1159 | ||
|
|
fea648cb1d | ||
|
|
ce6f6a48e8 | ||
|
|
416f1343fe | ||
|
|
388ba9f00d | ||
|
|
e38a184907 | ||
|
|
f2dbab7043 | ||
|
|
2938c1f077 | ||
|
|
95d35ecf4b | ||
|
|
a1baa01ddd | ||
|
|
7ab7365020 | ||
|
|
43a636d809 | ||
|
|
8531a8a753 | ||
|
|
c0cef43a4e | ||
|
|
06b6542b28 | ||
|
|
03adc091ce | ||
|
|
f85921497c | ||
|
|
ab975bc1c4 | ||
|
|
0cb4f59006 | ||
|
|
230b80404d | ||
|
|
46efbc0a36 | ||
|
|
903dae1b6c | ||
|
|
0b2c4187b0 | ||
|
|
c11a83bf0f | ||
|
|
a68eb60be9 | ||
|
|
48872e9f2e | ||
|
|
bb35a284e8 | ||
|
|
793b7cddaf | ||
|
|
161eeb7473 | ||
|
|
71f33418d2 | ||
|
|
f4e2daec94 | ||
|
|
34f033b254 | ||
|
|
91db91352f | ||
|
|
05a237be2a | ||
|
|
cb9a204a98 | ||
|
|
bec18489c7 | ||
|
|
f596e48cc4 | ||
|
|
ae213537ba | ||
|
|
c4e60a7037 | ||
|
|
12a07dcdbd | ||
|
|
6e47fb6d85 | ||
|
|
e12ce642a1 | ||
|
|
9a1b3a8aff | ||
|
|
f1c7a9896d | ||
|
|
c210c3a665 | ||
|
|
8e27541a3b | ||
|
|
1592511fdb | ||
|
|
cbc143bf95 | ||
|
|
3e160447eb | ||
|
|
5ab106465c | ||
|
|
79720dabb9 | ||
|
|
0bff50a31a | ||
|
|
c2291a1b9b | ||
|
|
f1d7d30dbb | ||
|
|
00feca3ce0 | ||
|
|
ea47937187 | ||
|
|
f77b26b42b | ||
|
|
6c8314b297 | ||
|
|
59e39e484a | ||
|
|
b61ec23e48 | ||
|
|
7420f879e0 | ||
|
|
7de8ff5ccf | ||
|
|
b4ba1d8758 | ||
|
|
139d663541 | ||
|
|
665816ae4d | ||
|
|
c522996edc | ||
|
|
750afe309f | ||
|
|
eb220d834d | ||
|
|
0113ac2d88 | ||
|
|
5a17d677c4 | ||
|
|
629fb68aa8 | ||
|
|
31b36a410b | ||
|
|
80b2cb213c | ||
|
|
f996b9b9e8 | ||
|
|
c4b66283fe | ||
|
|
feb4d24327 | ||
|
|
8a3716d18c | ||
|
|
e5534c47e9 | ||
|
|
03e4cc6f6d | ||
|
|
7940563131 | ||
|
|
6eae9f6e91 | ||
|
|
1c36ddfe73 | ||
|
|
db9991d471 | ||
|
|
6bc1378ddb | ||
|
|
d4e49f9988 | ||
|
|
2e23913e3b | ||
|
|
8d7bce164c | ||
|
|
2cf11a2fa4 | ||
|
|
bd4405ada6 | ||
|
|
c46fd35e56 | ||
|
|
957c58db41 | ||
|
|
06fd461bd8 | ||
|
|
686acf82a2 | ||
|
|
cade8201d2 | ||
|
|
390f3f5b73 | ||
|
|
d5fdf47b19 | ||
|
|
7d77e0dcbd | ||
|
|
eb0f9b4f29 | ||
|
|
7b10f71373 | ||
|
|
c82c3509cf | ||
|
|
74ad0d71b9 | ||
|
|
98cd52c8d7 | ||
|
|
a9bf78adc3 | ||
|
|
83efc03426 | ||
|
|
bfc39f68d8 | ||
|
|
ff51d5a8fa | ||
|
|
949ed8c9e2 | ||
|
|
31698f8388 | ||
|
|
c400a84987 | ||
|
|
ce52bb2f5a | ||
|
|
bf374ca9e6 | ||
|
|
17ca463767 | ||
|
|
aa8d8ec0ae | ||
|
|
1b08d47045 | ||
|
|
0f656105e2 | ||
|
|
0b3a7ecd01 | ||
|
|
a364355c16 | ||
|
|
7086c414bc | ||
|
|
0bb193d487 | ||
|
|
80b57c6e24 | ||
|
|
9576549fee | ||
|
|
0cc5f2fdf9 | ||
|
|
26a3f3b058 | ||
|
|
e03f3bb36e | ||
|
|
be5ab79c9d | ||
|
|
083cdb9310 | ||
|
|
ca30d3cda9 | ||
|
|
5c17722854 | ||
|
|
49177aac46 | ||
|
|
d20beacba0 | ||
|
|
26cc1644b4 | ||
|
|
9ed0036286 | ||
|
|
00f7d92514 | ||
|
|
43674b2903 | ||
|
|
5cfd5fc4cd | ||
|
|
9f252d4bf8 | ||
|
|
321057eed5 | ||
|
|
1a3d049454 | ||
|
|
9d1f29a9fd | ||
|
|
da31341d5d | ||
|
|
10b1d6493e | ||
|
|
a76310b53f | ||
|
|
26d26d7134 | ||
|
|
a1b577c085 | ||
|
|
8a0682650e | ||
|
|
85e5ccec17 | ||
|
|
3da5352b89 | ||
|
|
1569558503 | ||
|
|
ce704859b8 | ||
|
|
fd18e0b1c9 | ||
|
|
ba4d5680d6 | ||
|
|
75e45462f0 | ||
|
|
f8eb7b225a | ||
|
|
29ea07ef66 | ||
|
|
6c9d386303 | ||
|
|
bf84ead85c | ||
|
|
ca2ba1a6f5 | ||
|
|
284d1615c8 | ||
|
|
b4181ffa3b | ||
|
|
8c0caf9a1f | ||
|
|
d2682c4841 | ||
|
|
39ddcfaaa0 | ||
|
|
669ad1933a | ||
|
|
84fa6ffbde | ||
|
|
2206f7f108 | ||
|
|
ec946b17eb | ||
|
|
a619cc1757 | ||
|
|
6c3e2e2bee | ||
|
|
621dcea8ee | ||
|
|
f6fb530121 | ||
|
|
0066f9dd83 | ||
|
|
46b70d7317 | ||
|
|
8c28774917 | ||
|
|
e5d84156e4 | ||
|
|
5f2c751dd8 | ||
|
|
53b22cc32e | ||
|
|
26679e223c | ||
|
|
9b7d3be5c6 | ||
|
|
358dec19b2 | ||
|
|
863fd08305 | ||
|
|
93481d1566 | ||
|
|
3a79b2b09b | ||
|
|
246d306eeb | ||
|
|
03943acbb1 | ||
|
|
20b678c9f3 | ||
|
|
e008a88b98 | ||
|
|
5efa782567 | ||
|
|
ab37ad0dc9 | ||
|
|
03208167b2 | ||
|
|
0f8e7f317f | ||
|
|
c5b0a4dd32 | ||
|
|
5c5551d1d3 | ||
|
|
aa324567a8 | ||
|
|
0ee752c42d | ||
|
|
4746717b75 | ||
|
|
3ad942e338 | ||
|
|
b5190da581 | ||
|
|
5fa8e84ef0 | ||
|
|
63adb3b0cf | ||
|
|
20774374a9 | ||
|
|
d169020001 | ||
|
|
76766f11c0 | ||
|
|
5d6d65ce86 | ||
|
|
24ab0871e7 | ||
|
|
11e325a112 | ||
|
|
6ea32db1fa | ||
|
|
49c8a8b9ef | ||
|
|
a480c388b8 | ||
|
|
5406064f55 | ||
|
|
9b66d0d039 | ||
|
|
adff844c46 | ||
|
|
f702246d78 | ||
|
|
8606342b53 | ||
|
|
ccb0f7c0b2 | ||
|
|
72384b43bd | ||
|
|
5ef3de8945 | ||
|
|
ad913cf437 | ||
|
|
7820f07e85 | ||
|
|
01bda280ee | ||
|
|
b40f31fb8c | ||
|
|
066d651210 | ||
|
|
b00946d449 | ||
|
|
6a14f52e5d | ||
|
|
3c68e3f5b1 | ||
|
|
ec1ef8f19d | ||
|
|
6a64c2e932 | ||
|
|
835c603b13 | ||
|
|
a718b90ac6 | ||
|
|
089edb74b4 | ||
|
|
8c60cf8645 | ||
|
|
f364990b9b | ||
|
|
3b826d0fa3 | ||
|
|
cab332c367 | ||
|
|
9ee74f59d7 | ||
|
|
46afee6299 | ||
|
|
90bba399ab | ||
|
|
c403f73ad0 | ||
|
|
470b99a647 | ||
|
|
a68968af8f | ||
|
|
ee9c7855ca | ||
|
|
1a156458f2 | ||
|
|
796b901912 | ||
|
|
508284cd28 | ||
|
|
5d1972bb97 | ||
|
|
7c76d17a9c | ||
|
|
8ff663a761 | ||
|
|
d3ad9fe25f | ||
|
|
cc374ee10d | ||
|
|
06f132066b | ||
|
|
82816cb52f | ||
|
|
426cab3aeb | ||
|
|
152ed1fb44 | ||
|
|
c6ff9f8bd7 | ||
|
|
c104bccc3f | ||
|
|
4654e6f578 | ||
|
|
2cf38465c4 | ||
|
|
3428296186 | ||
|
|
877afd2281 | ||
|
|
2f320f3148 | ||
|
|
a0277d3ff6 | ||
|
|
531ebba50b | ||
|
|
d8bac63e5c | ||
|
|
b408b8238c | ||
|
|
2e80962501 | ||
|
|
43827ba380 | ||
|
|
cd374664d4 | ||
|
|
3694f9c099 | ||
|
|
06249b8e99 | ||
|
|
bf915e82f4 | ||
|
|
bfe0c7fc5f | ||
|
|
0eb8493156 | ||
|
|
9736f533bb | ||
|
|
cc6df5fa39 | ||
|
|
62896c20ff | ||
|
|
ea5fb82a48 | ||
|
|
25c29b80b5 | ||
|
|
f8caa82186 | ||
|
|
c35b896209 | ||
|
|
5a36a1f3a2 | ||
|
|
afb7cd6d01 | ||
|
|
c9af248c38 | ||
|
|
95eb986206 | ||
|
|
b4670ce7f0 | ||
|
|
6633fa626a | ||
|
|
df7a995fa2 | ||
|
|
ca2e93b69d | ||
|
|
3589f9578a | ||
|
|
07d23c2ee8 | ||
|
|
eadbcac115 | ||
|
|
3dc7dff2b2 | ||
|
|
35793c24f0 | ||
|
|
ff958d376e | ||
|
|
6545523df3 | ||
|
|
3e52aa820c | ||
|
|
73cd60b1cc | ||
|
|
c7b0f8fcda | ||
|
|
057af1e20a | ||
|
|
aea841eeb0 | ||
|
|
5b9e98f941 | ||
|
|
c645045adb | ||
|
|
224555aaf9 | ||
|
|
d9fc45de04 | ||
|
|
db77541790 | ||
|
|
e884fe93bd | ||
|
|
c2507f02cf | ||
|
|
fc6982f577 | ||
|
|
06fff68255 | ||
|
|
8f752a2bd7 | ||
|
|
07e687106a | ||
|
|
9125df1398 | ||
|
|
52cc01c977 | ||
|
|
b8d2218720 | ||
|
|
05a4d3fe0a | ||
|
|
df5e54545e | ||
|
|
f79ef935a7 | ||
|
|
cd3cb945ab | ||
|
|
f1d624b6c8 | ||
|
|
3f268c3052 | ||
|
|
0ec7027d83 | ||
|
|
0ae5240f55 | ||
|
|
51f5f71ee0 | ||
|
|
5784692218 | ||
|
|
f82d3ee51a | ||
|
|
d02c809bc7 | ||
|
|
b7a07efdcf | ||
|
|
a8bb07ae9f | ||
|
|
897e798fc0 | ||
|
|
2d0b19b359 | ||
|
|
702f9b1cf4 | ||
|
|
1d20a60e4a | ||
|
|
71422b411e | ||
|
|
f446dbb896 | ||
|
|
975425d0eb | ||
|
|
c020fafd66 | ||
|
|
2954b46d43 | ||
|
|
4cdd826282 | ||
|
|
413b484774 | ||
|
|
351d7fefca | ||
|
|
a7872ab856 | ||
|
|
c1613285e7 | ||
|
|
8805eb2b45 | ||
|
|
a3f919bd25 | ||
|
|
4f6f7404df | ||
|
|
5776c52bcf | ||
|
|
db44e9de22 | ||
|
|
c40be6cc7a | ||
|
|
b047b8ae20 | ||
|
|
e9434dc9e3 | ||
|
|
c6149c9cd8 | ||
|
|
8f2b23cd94 | ||
|
|
8d449aa9a6 | ||
|
|
e6089dd9c9 | ||
|
|
bc488fd4f1 | ||
|
|
ec3a9746a9 | ||
|
|
530bcfd4fa | ||
|
|
bd4f374b47 | ||
|
|
0a7c13207d | ||
|
|
c5fc3fe84a | ||
|
|
8d0e90b90a | ||
|
|
1aeb0a1f6e | ||
|
|
ce80f7c5b1 | ||
|
|
25cd2b2fb7 | ||
|
|
78797ae078 | ||
|
|
96d83455ca | ||
|
|
36805b3cfe | ||
|
|
5d0a11a21b | ||
|
|
d4cd675f33 | ||
|
|
c3328a123c | ||
|
|
2cc320f180 | ||
|
|
6f26d7a77f | ||
|
|
9d559bba8f | ||
|
|
cb9cb7154d | ||
|
|
da15a67c96 | ||
|
|
69efb9177d | ||
|
|
f9ce835e58 | ||
|
|
3dd6e222c8 | ||
|
|
04b8c4ff32 | ||
|
|
9b2adfede9 | ||
|
|
520aea9de0 | ||
|
|
9f233a68f3 | ||
|
|
476cd2f764 | ||
|
|
ca87b74333 | ||
|
|
25a943ad01 | ||
|
|
f22a6613eb | ||
|
|
8914ae468b | ||
|
|
3e712b2dcd | ||
|
|
17e0e9fd27 | ||
|
|
e7f67f8928 | ||
|
|
4b049fe848 | ||
|
|
fea4074e8f | ||
|
|
9209d7e3b5 | ||
|
|
ca2e1fc956 | ||
|
|
1592f1e274 | ||
|
|
74027ca922 | ||
|
|
1910960364 | ||
|
|
2708021e6f | ||
|
|
8e8ecd50de | ||
|
|
3ebf7fa3bd | ||
|
|
68130ef2f5 | ||
|
|
a77acb21c9 | ||
|
|
6e6e9f169e | ||
|
|
6a8bade7e6 | ||
|
|
3367b78958 | ||
|
|
28603e4de7 | ||
|
|
d8cf203d46 | ||
|
|
9faa602f6c | ||
|
|
c9b727e9ea | ||
|
|
1534dc6c61 | ||
|
|
dd6d6cfa1c | ||
|
|
8e564bbb5c | ||
|
|
284a49443e | ||
|
|
61abbc6e5d | ||
|
|
1fe2d3d92b | ||
|
|
b0da623c8a | ||
|
|
ff1502edd0 | ||
|
|
2d9c0b507d | ||
|
|
20320dfd0e | ||
|
|
6483fb027a | ||
|
|
030d50f6ba | ||
|
|
dc8bbbf352 | ||
|
|
c72030d25a | ||
|
|
4309294c2a | ||
|
|
f5dd3c8e32 | ||
|
|
6dd347ddb4 | ||
|
|
e15e09025d | ||
|
|
caf71248df | ||
|
|
7b327509b4 | ||
|
|
83138b7803 | ||
|
|
cea7a1489a | ||
|
|
f6e2fbb366 | ||
|
|
2e4a3a9888 | ||
|
|
639ffa36a5 | ||
|
|
05f9297141 | ||
|
|
28baeca882 | ||
|
|
b1558ec973 | ||
|
|
4862c38ca9 | ||
|
|
bec7394722 | ||
|
|
42479bd1df | ||
|
|
01f896711e | ||
|
|
ed2117c724 | ||
|
|
bc7511762f | ||
|
|
03cc8a9ce4 | ||
|
|
a4d7c46d80 | ||
|
|
7d912c7d3e | ||
|
|
65b43d5d12 | ||
|
|
36fd8d6b3c | ||
|
|
f28e159ff2 | ||
|
|
633ffbf8b7 | ||
|
|
4359973586 | ||
|
|
0dfeb304cc | ||
|
|
12cc7ea745 | ||
|
|
1ff2b85252 | ||
|
|
76301cef4c | ||
|
|
4471452105 | ||
|
|
d703301fe8 | ||
|
|
85f7ee59f8 | ||
|
|
fe71fd469a | ||
|
|
f05c9833ee | ||
|
|
11e7e267f7 | ||
|
|
0738ba2451 | ||
|
|
12ff94c02f | ||
|
|
da2f6e9d93 | ||
|
|
49b246193b | ||
|
|
1862a991d8 | ||
|
|
89839cb1cf | ||
|
|
07bb8b3023 | ||
|
|
56d55a4585 | ||
|
|
3cd158b983 | ||
|
|
d1ffca3189 | ||
|
|
e21e3b298a | ||
|
|
f47f6b7fb4 | ||
|
|
1e7521c056 | ||
|
|
bb6d522198 | ||
|
|
c0b2f99b04 | ||
|
|
89b3105493 | ||
|
|
37cc06444d | ||
|
|
2d10545e70 | ||
|
|
04b781d613 | ||
|
|
5a252c9166 | ||
|
|
373d4c9848 | ||
|
|
fa84d60586 | ||
|
|
7dc4a336bd | ||
|
|
362d523fa6 | ||
|
|
586b0a39d8 | ||
|
|
6df3488654 | ||
|
|
10e4d8fbac | ||
|
|
81c44b5eee | ||
|
|
aa9eef28c4 | ||
|
|
0a2c6fccc3 | ||
|
|
88a95c7f03 | ||
|
|
90c1873134 | ||
|
|
d1d9dd8e20 | ||
|
|
39dc77d825 | ||
|
|
24d349f491 | ||
|
|
0eff642d2f | ||
|
|
b7c1f1e13d | ||
|
|
c27123cf61 | ||
|
|
0edfeb19f1 | ||
|
|
f069c256a6 | ||
|
|
670d08b406 | ||
|
|
0c29321407 | ||
|
|
b4643cb5be | ||
|
|
3c886ccff8 | ||
|
|
eddc3b0381 | ||
|
|
83cc90be5d | ||
|
|
ba92a5e865 | ||
|
|
8a12f6dc2c | ||
|
|
9fad8a8c92 | ||
|
|
57eab17262 | ||
|
|
fc5f9cc46d | ||
|
|
38e631d174 | ||
|
|
3283135f16 | ||
|
|
bd491b4479 | ||
|
|
6dbfe52c35 | ||
|
|
9da23371d5 | ||
|
|
29c5deb4f1 | ||
|
|
9bc45ae15f | ||
|
|
08abc0eb77 | ||
|
|
fea3a76c38 | ||
|
|
3a7f03bae6 | ||
|
|
652081426b | ||
|
|
406d2d8b0a | ||
|
|
7a1df1c323 | ||
|
|
5a44d14d97 | ||
|
|
b444d1ecd7 | ||
|
|
0456670328 | ||
|
|
eff4da95a1 | ||
|
|
ad7d16a1b4 | ||
|
|
f5abfde1fa | ||
|
|
02d13d7257 | ||
|
|
941b82a8be | ||
|
|
482fcd0602 | ||
|
|
14c7148edd | ||
|
|
a00722e80c | ||
|
|
42f4dcef88 | ||
|
|
37188482fe | ||
|
|
eb3228233a | ||
|
|
8dec7eac05 | ||
|
|
e9c2aaccb5 | ||
|
|
112c0ff08b | ||
|
|
e431cbdfa7 | ||
|
|
6514d1bc2e | ||
|
|
53d3ca0062 | ||
|
|
3062a9ba91 | ||
|
|
dcc2b252dd | ||
|
|
66b3aa9582 | ||
|
|
32a141d548 | ||
|
|
69e7d64c49 | ||
|
|
7d5025a865 | ||
|
|
c65cd4eb74 | ||
|
|
8ff3b0cd63 | ||
|
|
cc2d29dbf4 | ||
|
|
6ed739d9ca | ||
|
|
5d07b0730c | ||
|
|
fe05e47656 | ||
|
|
8399bd8309 | ||
|
|
a730d56e66 | ||
|
|
6599ae1f2f | ||
|
|
0b5426da12 | ||
|
|
be9c3cd979 | ||
|
|
02106c3292 | ||
|
|
e078650435 | ||
|
|
7d6b4d9936 | ||
|
|
ab087f7342 | ||
|
|
962735cf7a | ||
|
|
4ce7766e14 | ||
|
|
cdc70991f7 | ||
|
|
a1fe799afd | ||
|
|
157f72f611 | ||
|
|
c97080cee7 | ||
|
|
5b623d2314 | ||
|
|
26f87c284b | ||
|
|
8cddcb76b2 | ||
|
|
6199fed6bb | ||
|
|
96da06430b | ||
|
|
752c9a5279 | ||
|
|
46ee71edcd | ||
|
|
bcfb7731ab | ||
|
|
57d0f19bda | ||
|
|
4cf663a661 | ||
|
|
0b9893c640 | ||
|
|
ba4c028f5f | ||
|
|
52f5cb8ced | ||
|
|
f3ec1e2254 | ||
|
|
d5729bdf01 | ||
|
|
3c54d8a239 | ||
|
|
f647333f49 | ||
|
|
fcddbf5c03 | ||
|
|
1bce69cfde | ||
|
|
32d4f243e6 | ||
|
|
8e6b8cd6e6 | ||
|
|
6a6c4d0887 | ||
|
|
737ecd9d42 | ||
|
|
191d8a0716 | ||
|
|
cfcc908cae | ||
|
|
cf2e099087 | ||
|
|
d6cc88cabb | ||
|
|
42692418c2 | ||
|
|
a985c12659 | ||
|
|
5ebf128023 | ||
|
|
911b16bab8 | ||
|
|
693f61c47f | ||
|
|
3a8c866393 | ||
|
|
0851c2cfb0 | ||
|
|
958eaf4b24 | ||
|
|
07f9248448 | ||
|
|
c2371f95c6 | ||
|
|
379322f0b8 | ||
|
|
b30b17d1eb | ||
|
|
ef3beeb390 | ||
|
|
48e0b20e62 | ||
|
|
018680046c | ||
|
|
aebe14a6e9 | ||
|
|
c4b7bf8635 | ||
|
|
3973f6a57c | ||
|
|
5906ca25f7 | ||
|
|
2ce8573f04 | ||
|
|
f6706ce124 | ||
|
|
31ebf3dc2c | ||
|
|
cb183de1da | ||
|
|
c867f2e8a0 | ||
|
|
c9ff83bfa3 | ||
|
|
05c997da1f | ||
|
|
f677bdc12f | ||
|
|
2178461c89 | ||
|
|
d438151f25 | ||
|
|
7d475266b6 | ||
|
|
367cb7a761 | ||
|
|
4604f00218 | ||
|
|
8eff9151ac | ||
|
|
50797c7948 | ||
|
|
c34a3e2c5b | ||
|
|
35211cdc8f | ||
|
|
4a8a1f2dde | ||
|
|
f2ab443cca | ||
|
|
abc15094c6 | ||
|
|
f390695767 | ||
|
|
f092bcdfdb | ||
|
|
1633f030e8 | ||
|
|
4451df15b4 | ||
|
|
f50062517e | ||
|
|
967e3de552 | ||
|
|
d95472e757 | ||
|
|
3e0e5bac2a | ||
|
|
08cb76bbfd | ||
|
|
281dd51f5a | ||
|
|
1c7c815108 | ||
|
|
d177af8842 | ||
|
|
544129d240 | ||
|
|
9f79678723 | ||
|
|
a491b938ba | ||
|
|
588c8cf5b3 | ||
|
|
876ca59234 | ||
|
|
f5910d83c4 | ||
|
|
e43a22abcf | ||
|
|
2a7aa8992b | ||
|
|
e36597e2c6 | ||
|
|
6403de2109 | ||
|
|
9b49e47b13 | ||
|
|
8540be5b82 | ||
|
|
ae6d6261a1 | ||
|
|
ce4fcd2009 | ||
|
|
76620881f4 | ||
|
|
f99efd6166 |
29
.github/workflows/cibuild-setup-ubuntu.sh
vendored
Executable file
29
.github/workflows/cibuild-setup-ubuntu.sh
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
PACKAGES=(
|
||||
git make autoconf automake autopoint pkg-config libtool libtool-bin
|
||||
gettext libssl-dev libdevmapper-dev libpopt-dev uuid-dev libsepol1-dev
|
||||
libjson-c-dev libssh-dev libblkid-dev tar libargon2-0-dev libpwquality-dev
|
||||
sharutils dmsetup jq xxd expect keyutils netcat passwd openssh-client sshpass
|
||||
asciidoctor
|
||||
)
|
||||
|
||||
COMPILER="${COMPILER:?}"
|
||||
COMPILER_VERSION="${COMPILER_VERSION:?}"
|
||||
RELEASE="$(lsb_release -cs)"
|
||||
|
||||
bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse' >>/etc/apt/sources.list"
|
||||
|
||||
# Latest gcc stack deb packages provided by
|
||||
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
|
||||
add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
PACKAGES+=(gcc-$COMPILER_VERSION)
|
||||
|
||||
# scsi_debug, gost crypto
|
||||
PACKAGES+=(dkms linux-headers-$(uname -r) linux-modules-extra-$(uname -r) gost-crypto-dkms)
|
||||
|
||||
apt-get -y update --fix-missing
|
||||
apt-get -y install "${PACKAGES[@]}"
|
||||
apt-get -y build-dep cryptsetup
|
||||
38
.github/workflows/cibuild.sh
vendored
Executable file
38
.github/workflows/cibuild.sh
vendored
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
PHASES=(${@:-CONFIGURE MAKE CHECK})
|
||||
COMPILER="${COMPILER:?}"
|
||||
COMPILER_VERSION="${COMPILER_VERSION}"
|
||||
CFLAGS=(-O1 -g)
|
||||
CXXFLAGS=(-O1 -g)
|
||||
|
||||
CC="gcc${COMPILER_VERSION:+-$COMPILER_VERSION}"
|
||||
CXX="g++${COMPILER_VERSION:+-$COMPILER_VERSION}"
|
||||
|
||||
set -ex
|
||||
|
||||
for phase in "${PHASES[@]}"; do
|
||||
case $phase in
|
||||
CONFIGURE)
|
||||
opts=(
|
||||
--enable-libargon2
|
||||
)
|
||||
|
||||
sudo -E git clean -xdf
|
||||
|
||||
./autogen.sh
|
||||
CC="$CC" CXX="$CXX" CFLAGS="${CFLAGS[@]}" CXXFLAGS="${CXXFLAGS[@]}" ./configure "${opts[@]}"
|
||||
;;
|
||||
MAKE)
|
||||
make -j
|
||||
make -j -C tests check-programs
|
||||
;;
|
||||
CHECK)
|
||||
make check
|
||||
;;
|
||||
|
||||
*)
|
||||
echo >&2 "Unknown phase '$phase'"
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
30
.github/workflows/cibuild.yml
vendored
Normal file
30
.github/workflows/cibuild.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Build test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
- 'wip-luks2'
|
||||
- 'v2.3.x'
|
||||
- 'v2.4.x'
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'mbroz/cryptsetup'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
env:
|
||||
- { COMPILER: "gcc", COMPILER_VERSION: "11", RUN_SSH_PLUGIN_TEST: "1" }
|
||||
env: ${{ matrix.env }}
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: Ubuntu setup
|
||||
run: sudo -E .github/workflows/cibuild-setup-ubuntu.sh
|
||||
- name: Configure & Make
|
||||
run: .github/workflows/cibuild.sh CONFIGURE MAKE
|
||||
- name: Check
|
||||
run: sudo -E .github/workflows/cibuild.sh CHECK
|
||||
48
.github/workflows/coverity.yml
vendored
Normal file
48
.github/workflows/coverity.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
name: Coverity test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'coverity_scan'
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
|
||||
jobs:
|
||||
latest:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'mbroz/cryptsetup'
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: Ubuntu setup
|
||||
run: sudo -E .github/workflows/cibuild-setup-ubuntu.sh
|
||||
env:
|
||||
COMPILER: "gcc"
|
||||
COMPILER_VERSION: "11"
|
||||
- name: Install Coverity
|
||||
run: |
|
||||
wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=mbroz/cryptsetup" -O cov-analysis-linux64.tar.gz
|
||||
mkdir cov-analysis-linux64
|
||||
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
|
||||
env:
|
||||
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
||||
- name: Run autoconf & configure
|
||||
run: |
|
||||
./autogen.sh
|
||||
./configure
|
||||
- name: Run cov-build
|
||||
run: |
|
||||
export PATH=`pwd`/cov-analysis-linux64/bin:$PATH
|
||||
cov-build --dir cov-int make
|
||||
- name: Submit to Coverity Scan
|
||||
run: |
|
||||
tar czvf cryptsetup.tgz cov-int
|
||||
curl \
|
||||
--form project=mbroz/cryptsetup \
|
||||
--form token=$TOKEN \
|
||||
--form email=gmazyland@gmail.com \
|
||||
--form file=@cryptsetup.tgz \
|
||||
--form version=trunk \
|
||||
--form description="`./cryptsetup --version`" \
|
||||
https://scan.coverity.com/builds?project=mbroz/cryptsetup
|
||||
env:
|
||||
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -6,6 +6,8 @@ Makefile.in.in
|
||||
*.lo
|
||||
*.la
|
||||
*.o
|
||||
*.so
|
||||
*.8
|
||||
**/*.dirstamp
|
||||
.deps/
|
||||
.libs/
|
||||
@@ -25,6 +27,7 @@ config.sub
|
||||
configure
|
||||
cryptsetup
|
||||
cryptsetup-reencrypt
|
||||
cryptsetup-ssh
|
||||
depcomp
|
||||
install-sh
|
||||
integritysetup
|
||||
@@ -53,3 +56,5 @@ tests/luks1-images
|
||||
tests/tcrypt-images
|
||||
tests/unit-utils-io
|
||||
tests/vectors-test
|
||||
tests/test-symbols-list.h
|
||||
tests/all-symbols-test
|
||||
|
||||
20
.gitlab-ci.yml
Normal file
20
.gitlab-ci.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
stages:
|
||||
- test
|
||||
|
||||
.dump_kernel_log:
|
||||
after_script:
|
||||
- sudo dmesg > /mnt/artifacts/dmesg.log
|
||||
- sudo journalctl > /mnt/artifacts/journalctl.log
|
||||
- '[ "$(ls -A /var/coredumps)" ] && exit 1 || true'
|
||||
|
||||
include:
|
||||
- local: .gitlab/ci/debian.yml
|
||||
- local: .gitlab/ci/fedora.yml
|
||||
- local: .gitlab/ci/rhel.yml
|
||||
- local: .gitlab/ci/centos.yml
|
||||
- local: .gitlab/ci/annocheck.yml
|
||||
- local: .gitlab/ci/csmock.yml
|
||||
- local: .gitlab/ci/gitlab-shared-docker.yml
|
||||
- local: .gitlab/ci/compilation-gcc.gitlab-ci.yml
|
||||
- local: .gitlab/ci/compilation-clang.gitlab-ci.yml
|
||||
- local: .gitlab/ci/alpinelinux.yml
|
||||
53
.gitlab/ci/alpinelinux.yml
Normal file
53
.gitlab/ci/alpinelinux.yml
Normal file
@@ -0,0 +1,53 @@
|
||||
.alpinelinux-dependencies:
|
||||
after_script:
|
||||
- sudo dmesg > /mnt/artifacts/dmesg.log
|
||||
- sudo cp /var/log/messages /mnt/artifacts/
|
||||
- '[ "$(ls -A /var/coredumps)" ] && exit 1 || true'
|
||||
before_script:
|
||||
- >
|
||||
sudo apk add
|
||||
lvm2-dev openssl1.1-compat-dev popt-dev util-linux-dev json-c-dev
|
||||
argon2-dev device-mapper which sharutils gettext gettext-dev automake
|
||||
autoconf libtool build-base keyutils tar jq expect git asciidoctor
|
||||
- ./autogen.sh
|
||||
- ./configure --prefix=/usr --libdir=/lib --sbindir=/sbin --disable-static --enable-libargon2 --with-crypto_backend=openssl --disable-external-tokens --disable-ssh-token --enable-asciidoc
|
||||
|
||||
test-main-commit-job-alpinelinux:
|
||||
extends:
|
||||
- .alpinelinux-dependencies
|
||||
tags:
|
||||
- libvirt
|
||||
- alpinelinux
|
||||
stage: test
|
||||
interruptible: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "0"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
|
||||
test-mergerq-job-alpinelinux:
|
||||
extends:
|
||||
- .alpinelinux-dependencies
|
||||
tags:
|
||||
- libvirt
|
||||
- alpinelinux
|
||||
stage: test
|
||||
interruptible: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "0"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
19
.gitlab/ci/annocheck.yml
Normal file
19
.gitlab/ci/annocheck.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
test-main-commit-job-annocheck:
|
||||
extends:
|
||||
- .dump_kernel_log
|
||||
tags:
|
||||
- libvirt
|
||||
- rhel9-annocheck
|
||||
stage: test
|
||||
interruptible: true
|
||||
allow_failure: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
script:
|
||||
- /opt/build-rpm-script.sh > /dev/null 2>&1
|
||||
- annocheck /var/lib/mock/rhel-9.0.0-candidate-x86_64/result/*.rpm --profile=el9
|
||||
- annocheck /var/lib/mock/rhel-9.0.0-candidate-x86_64/result/*.rpm --profile=el8
|
||||
55
.gitlab/ci/centos.yml
Normal file
55
.gitlab/ci/centos.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
.centos-openssl-backend:
|
||||
extends:
|
||||
- .dump_kernel_log
|
||||
before_script:
|
||||
- >
|
||||
sudo dnf -y -q install
|
||||
autoconf automake device-mapper-devel gcc gettext-devel json-c-devel
|
||||
libblkid-devel libpwquality-devel libselinux-devel libssh-devel libtool
|
||||
libuuid-devel make popt-devel libsepol-devel nc openssh-clients passwd
|
||||
pkgconfig sharutils sshpass tar uuid-devel vim-common device-mapper
|
||||
expect gettext git jq keyutils openssl-devel openssl gem
|
||||
- sudo gem install asciidoctor
|
||||
- sudo -E git clean -xdf
|
||||
- ./autogen.sh
|
||||
- ./configure --enable-fips --enable-pwquality --with-crypto_backend=openssl --enable-asciidoc
|
||||
|
||||
# non-FIPS jobs
|
||||
|
||||
test-main-commit-centos-stream9:
|
||||
extends:
|
||||
- .centos-openssl-backend
|
||||
tags:
|
||||
- libvirt
|
||||
- centos-stream9
|
||||
stage: test
|
||||
interruptible: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
|
||||
test-mergerq-centos-stream9:
|
||||
extends:
|
||||
- .centos-openssl-backend
|
||||
tags:
|
||||
- libvirt
|
||||
- centos-stream9
|
||||
stage: test
|
||||
interruptible: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
50
.gitlab/ci/cibuild-setup-ubuntu.sh
Executable file
50
.gitlab/ci/cibuild-setup-ubuntu.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
PACKAGES=(
|
||||
git make autoconf automake autopoint pkg-config libtool libtool-bin
|
||||
gettext libssl-dev libdevmapper-dev libpopt-dev uuid-dev libsepol1-dev
|
||||
libjson-c-dev libssh-dev libblkid-dev tar libargon2-0-dev libpwquality-dev
|
||||
sharutils dmsetup jq xxd expect keyutils netcat passwd openssh-client sshpass
|
||||
asciidoctor
|
||||
)
|
||||
|
||||
COMPILER="${COMPILER:?}"
|
||||
COMPILER_VERSION="${COMPILER_VERSION:?}"
|
||||
|
||||
grep -E '^deb' /etc/apt/sources.list > /etc/apt/sources.list~
|
||||
sed -Ei 's/^deb /deb-src /' /etc/apt/sources.list~
|
||||
cat /etc/apt/sources.list~ >> /etc/apt/sources.list
|
||||
|
||||
apt-get -y update --fix-missing
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -yq install software-properties-common wget lsb-release
|
||||
RELEASE="$(lsb_release -cs)"
|
||||
|
||||
if [[ $COMPILER == "gcc" ]]; then
|
||||
# Latest gcc stack deb packages provided by
|
||||
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
|
||||
add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
PACKAGES+=(gcc-$COMPILER_VERSION)
|
||||
elif [[ $COMPILER == "clang" ]]; then
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
|
||||
add-apt-repository "deb http://apt.llvm.org/${RELEASE}/ llvm-toolchain-${RELEASE}-${COMPILER_VERSION} main"
|
||||
|
||||
# scan-build
|
||||
PACKAGES+=(clang-tools-$COMPILER_VERSION clang-$COMPILER_VERSION lldb-$COMPILER_VERSION lld-$COMPILER_VERSION clangd-$COMPILER_VERSION)
|
||||
PACKAGES+=(perl)
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
apt-get -y update --fix-missing
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -yq install "${PACKAGES[@]}"
|
||||
apt-get -y build-dep cryptsetup
|
||||
|
||||
echo "====================== VERSIONS ==================="
|
||||
if [[ $COMPILER == "clang" ]]; then
|
||||
echo "Using scan-build${COMPILER_VERSION:+-$COMPILER_VERSION}"
|
||||
fi
|
||||
|
||||
${COMPILER}-$COMPILER_VERSION -v
|
||||
echo "====================== END VERSIONS ==================="
|
||||
49
.gitlab/ci/clang-Wall
Executable file
49
.gitlab/ci/clang-Wall
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
# clang -Wall plus other important warnings not included in -Wall
|
||||
|
||||
for arg in "$@"
|
||||
do
|
||||
case $arg in
|
||||
-O*) Wuninitialized=-Wuninitialized;; # only makes sense with `-O'
|
||||
esac
|
||||
done
|
||||
|
||||
CLANG="clang${COMPILER_VERSION:+-$COMPILER_VERSION}"
|
||||
|
||||
#PEDANTIC="-std=gnu99"
|
||||
#PEDANTIC="-pedantic -std=gnu99"
|
||||
#PEDANTIC="-pedantic -std=gnu99 -Wno-variadic-macros"
|
||||
#CONVERSION="-Wconversion"
|
||||
|
||||
EXTRA="\
|
||||
-Wextra \
|
||||
-Wsign-compare \
|
||||
-Wcast-align
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wpointer-arith \
|
||||
-Wwrite-strings \
|
||||
-Wswitch \
|
||||
-Wmissing-format-attribute \
|
||||
-Winit-self \
|
||||
-Wdeclaration-after-statement \
|
||||
-Wold-style-definition \
|
||||
-Wno-missing-field-initializers \
|
||||
-Wno-unused-parameter \
|
||||
-Wno-long-long"
|
||||
|
||||
exec $CLANG $PEDANTIC $CONVERSION \
|
||||
-Wall $Wuninitialized \
|
||||
-Wno-switch \
|
||||
-Wdisabled-optimization \
|
||||
-Wwrite-strings \
|
||||
-Wpointer-arith \
|
||||
-Wbad-function-cast \
|
||||
-Wmissing-prototypes \
|
||||
-Wmissing-declarations \
|
||||
-Wstrict-prototypes \
|
||||
-Wnested-externs \
|
||||
-Wcomment \
|
||||
-Winline \
|
||||
-Wcast-qual \
|
||||
-Wredundant-decls $EXTRA \
|
||||
"$@"
|
||||
27
.gitlab/ci/compilation-clang.gitlab-ci.yml
Normal file
27
.gitlab/ci/compilation-clang.gitlab-ci.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
test-clang-compilation:
|
||||
extends:
|
||||
- .gitlab-shared-clang
|
||||
script:
|
||||
- export CFLAGS="-Wall -Werror"
|
||||
- ./configure
|
||||
- make -j
|
||||
- make -j check-programs
|
||||
|
||||
test-clang-Wall-script:
|
||||
extends:
|
||||
- .gitlab-shared-clang
|
||||
script:
|
||||
- export CFLAGS="-g -O0"
|
||||
- export CC="$CI_PROJECT_DIR/.gitlab/ci/clang-Wall"
|
||||
- ./configure
|
||||
- make -j CFLAGS="-g -O0 -Werror"
|
||||
- make -j CFLAGS="-g -O0 -Werror" check-programs
|
||||
|
||||
test-scan-build:
|
||||
extends:
|
||||
- .gitlab-shared-clang
|
||||
script:
|
||||
- scan-build${COMPILER_VERSION:+-$COMPILER_VERSION} -V ./configure CFLAGS="-g -O0"
|
||||
- make clean
|
||||
- scan-build${COMPILER_VERSION:+-$COMPILER_VERSION} --status-bugs -maxloop 10 make -j
|
||||
- scan-build${COMPILER_VERSION:+-$COMPILER_VERSION} --status-bugs -maxloop 10 make -j check-programs
|
||||
27
.gitlab/ci/compilation-gcc.gitlab-ci.yml
Normal file
27
.gitlab/ci/compilation-gcc.gitlab-ci.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
test-gcc-compilation:
|
||||
extends:
|
||||
- .gitlab-shared-gcc
|
||||
script:
|
||||
- export CFLAGS="-Wall -Werror"
|
||||
- ./configure
|
||||
- make -j
|
||||
- make -j check-programs
|
||||
|
||||
test-gcc-Wall-script:
|
||||
extends:
|
||||
- .gitlab-shared-gcc
|
||||
script:
|
||||
- export CFLAGS="-g -O0"
|
||||
- export CC="$CI_PROJECT_DIR/.gitlab/ci/gcc-Wall"
|
||||
- ./configure
|
||||
- make -j CFLAGS="-g -O0 -Werror"
|
||||
- make -j CFLAGS="-g -O0 -Werror" check-programs
|
||||
|
||||
test-gcc-fanalyzer:
|
||||
extends:
|
||||
- .gitlab-shared-gcc
|
||||
script:
|
||||
- export CFLAGS="-Wall -Werror -g -O0 -fanalyzer -fdiagnostics-path-format=separate-events"
|
||||
- ./configure
|
||||
- make -j
|
||||
- make -j check-programs
|
||||
17
.gitlab/ci/csmock.yml
Normal file
17
.gitlab/ci/csmock.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
test-commit-job-csmock:
|
||||
extends:
|
||||
- .dump_kernel_log
|
||||
tags:
|
||||
- libvirt
|
||||
- rhel7-csmock
|
||||
stage: test
|
||||
interruptible: true
|
||||
allow_failure: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/ || $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
script:
|
||||
- /opt/csmock-run-script.sh
|
||||
53
.gitlab/ci/debian.yml
Normal file
53
.gitlab/ci/debian.yml
Normal file
@@ -0,0 +1,53 @@
|
||||
.debian-prep:
|
||||
extends:
|
||||
- .dump_kernel_log
|
||||
before_script:
|
||||
- >
|
||||
sudo apt-get -y install -y -qq git gcc make
|
||||
autoconf automake autopoint pkg-config libtool libtool-bin gettext
|
||||
libssl-dev libdevmapper-dev libpopt-dev uuid-dev libsepol1-dev
|
||||
libjson-c-dev libssh-dev libblkid-dev tar libargon2-0-dev
|
||||
libpwquality-dev sharutils dmsetup jq xxd expect keyutils
|
||||
netcat passwd openssh-client sshpass asciidoctor
|
||||
- sudo apt-get -y build-dep cryptsetup
|
||||
- sudo -E git clean -xdf
|
||||
- ./autogen.sh
|
||||
- ./configure --enable-libargon2 --enable-asciidoc
|
||||
|
||||
test-mergerq-job-debian:
|
||||
extends:
|
||||
- .debian-prep
|
||||
tags:
|
||||
- libvirt
|
||||
- debian10
|
||||
stage: test
|
||||
interruptible: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
|
||||
test-main-commit-job-debian:
|
||||
extends:
|
||||
- .debian-prep
|
||||
tags:
|
||||
- libvirt
|
||||
- debian10
|
||||
stage: test
|
||||
interruptible: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
55
.gitlab/ci/fedora.yml
Normal file
55
.gitlab/ci/fedora.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
.dnf-openssl-backend:
|
||||
extends:
|
||||
- .dump_kernel_log
|
||||
before_script:
|
||||
- >
|
||||
sudo dnf -y -q install
|
||||
autoconf automake device-mapper-devel gcc gettext-devel json-c-devel
|
||||
libargon2-devel libblkid-devel libpwquality-devel libselinux-devel
|
||||
libssh-devel libtool libuuid-devel make popt-devel
|
||||
libsepol-devel.x86_64 netcat openssh-clients passwd pkgconfig sharutils
|
||||
sshpass tar uuid-devel vim-common device-mapper expect gettext git jq
|
||||
keyutils openssl-devel openssl asciidoctor
|
||||
- sudo -E git clean -xdf
|
||||
- ./autogen.sh
|
||||
- ./configure --enable-fips --enable-pwquality --enable-libargon2 --with-crypto_backend=openssl --enable-asciidoc
|
||||
|
||||
test-main-commit-job-rawhide:
|
||||
extends:
|
||||
- .dnf-openssl-backend
|
||||
tags:
|
||||
- libvirt
|
||||
- fedora-rawhide
|
||||
stage: test
|
||||
interruptible: true
|
||||
allow_failure: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
|
||||
test-mergerq-job-rawhide:
|
||||
extends:
|
||||
- .dnf-openssl-backend
|
||||
tags:
|
||||
- libvirt
|
||||
- fedora-rawhide
|
||||
stage: test
|
||||
interruptible: true
|
||||
allow_failure: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
57
.gitlab/ci/gcc-Wall
Executable file
57
.gitlab/ci/gcc-Wall
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
# gcc -Wall plus other important warnings not included in -Wall
|
||||
|
||||
for arg in "$@"
|
||||
do
|
||||
case $arg in
|
||||
-O*) Wuninitialized=-Wuninitialized;; # only makes sense with `-O'
|
||||
esac
|
||||
done
|
||||
|
||||
GCC="gcc${COMPILER_VERSION:+-$COMPILER_VERSION}"
|
||||
|
||||
#PEDANTIC="-std=gnu99"
|
||||
#PEDANTIC="-pedantic -std=gnu99"
|
||||
#PEDANTIC="-pedantic -std=gnu99 -Wno-variadic-macros"
|
||||
#CONVERSION="-Wconversion"
|
||||
# -Wpacked \
|
||||
|
||||
# This does more than expected for gcc (mixed code with declarations)
|
||||
# -Wdeclaration-after-statement \
|
||||
|
||||
EXTRA="-Wextra \
|
||||
-Wsign-compare \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wpointer-arith \
|
||||
-Wwrite-strings \
|
||||
-Wswitch \
|
||||
-Wmissing-format-attribute \
|
||||
-Wstrict-aliasing=3 \
|
||||
-Winit-self \
|
||||
-Wunsafe-loop-optimizations \
|
||||
-Wold-style-definition \
|
||||
-Wno-missing-field-initializers \
|
||||
-Wno-unused-parameter \
|
||||
-Wno-long-long \
|
||||
-Wmaybe-uninitialized \
|
||||
-Wvla \
|
||||
-Wformat-overflow \
|
||||
-Wformat-truncation"
|
||||
|
||||
exec $GCC $PEDANTIC $CONVERSION \
|
||||
-Wall $Wuninitialized \
|
||||
-Wno-switch \
|
||||
-Wdisabled-optimization \
|
||||
-Wwrite-strings \
|
||||
-Wpointer-arith \
|
||||
-Wbad-function-cast \
|
||||
-Wmissing-prototypes \
|
||||
-Wmissing-declarations \
|
||||
-Wstrict-prototypes \
|
||||
-Wnested-externs \
|
||||
-Wcomment \
|
||||
-Winline \
|
||||
-Wcast-align=strict \
|
||||
-Wcast-qual \
|
||||
-Wredundant-decls $EXTRA \
|
||||
"$@"
|
||||
31
.gitlab/ci/gitlab-shared-docker.yml
Normal file
31
.gitlab/ci/gitlab-shared-docker.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
.gitlab-shared-docker:
|
||||
image: ubuntu:focal
|
||||
tags:
|
||||
- gitlab-org-docker
|
||||
stage: test
|
||||
interruptible: true
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
before_script:
|
||||
- .gitlab/ci/cibuild-setup-ubuntu.sh
|
||||
- export CC="${COMPILER}${COMPILER_VERSION:+-$COMPILER_VERSION}"
|
||||
- export CXX="${COMPILER}++${COMPILER_VERSION:+-$COMPILER_VERSION}"
|
||||
- ./autogen.sh
|
||||
|
||||
.gitlab-shared-gcc:
|
||||
extends:
|
||||
- .gitlab-shared-docker
|
||||
variables:
|
||||
COMPILER: "gcc"
|
||||
COMPILER_VERSION: "11"
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
|
||||
.gitlab-shared-clang:
|
||||
extends:
|
||||
- .gitlab-shared-docker
|
||||
variables:
|
||||
COMPILER: "clang"
|
||||
COMPILER_VERSION: "13"
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
96
.gitlab/ci/rhel.yml
Normal file
96
.gitlab/ci/rhel.yml
Normal file
@@ -0,0 +1,96 @@
|
||||
.rhel-openssl-backend:
|
||||
extends:
|
||||
- .dump_kernel_log
|
||||
before_script:
|
||||
- >
|
||||
sudo yum -y -q install
|
||||
autoconf automake device-mapper-devel gcc gettext-devel json-c-devel
|
||||
libblkid-devel libpwquality-devel libselinux-devel libssh-devel libtool
|
||||
libuuid-devel make popt-devel libsepol-devel nc openssh-clients passwd
|
||||
pkgconfig sharutils sshpass tar uuid-devel vim-common device-mapper
|
||||
expect gettext git jq keyutils openssl-devel openssl gem > /dev/null 2>&1
|
||||
- sudo gem install asciidoctor
|
||||
- sudo -E git clean -xdf
|
||||
- ./autogen.sh
|
||||
- ./configure --enable-fips --enable-pwquality --with-crypto_backend=openssl --enable-asciidoc
|
||||
|
||||
# non-FIPS jobs
|
||||
|
||||
test-main-commit-rhel8:
|
||||
extends:
|
||||
- .rhel-openssl-backend
|
||||
tags:
|
||||
- libvirt
|
||||
- rhel8
|
||||
stage: test
|
||||
interruptible: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
|
||||
test-main-commit-rhel9:
|
||||
extends:
|
||||
- .rhel-openssl-backend
|
||||
tags:
|
||||
- libvirt
|
||||
- rhel9
|
||||
stage: test
|
||||
interruptible: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
|
||||
# FIPS jobs
|
||||
|
||||
test-main-commit-rhel8-fips:
|
||||
extends:
|
||||
- .rhel-openssl-backend
|
||||
tags:
|
||||
- libvirt
|
||||
- rhel8-fips
|
||||
stage: test
|
||||
interruptible: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
|
||||
test-main-commit-rhel9-fips:
|
||||
extends:
|
||||
- .rhel-openssl-backend
|
||||
tags:
|
||||
- libvirt
|
||||
- rhel9-fips
|
||||
stage: test
|
||||
interruptible: true
|
||||
allow_failure: true
|
||||
variables:
|
||||
RUN_SSH_PLUGIN_TEST: "1"
|
||||
rules:
|
||||
- if: $CI_PROJECT_PATH != "cryptsetup/cryptsetup"
|
||||
when: never
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /v2\..\.x$/
|
||||
script:
|
||||
- make -j
|
||||
- make -j -C tests check-programs
|
||||
- sudo -E make check
|
||||
11
.lgtm.yml
Normal file
11
.lgtm.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
queries:
|
||||
- exclude: cpp/fixme-comment
|
||||
- exclude: cpp/empty-block
|
||||
# symver attribute detection cannot be used, disable it for lgtm
|
||||
extraction:
|
||||
cpp:
|
||||
configure:
|
||||
command:
|
||||
- "./autogen.sh"
|
||||
- "./configure --enable-external-tokens --enable-ssh-token"
|
||||
- "echo \"#undef HAVE_ATTRIBUTE_SYMVER\" >> config.h"
|
||||
@@ -1,160 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# .travis-functions.sh:
|
||||
# - helper functions to be sourced from .travis.yml
|
||||
# - designed to respect travis' environment but testing locally is possible
|
||||
# - modified copy from util-linux project
|
||||
#
|
||||
|
||||
if [ ! -f "configure.ac" ]; then
|
||||
echo ".travis-functions.sh must be sourced from source dir" >&2
|
||||
return 1 || exit 1
|
||||
fi
|
||||
|
||||
## some config settings
|
||||
# travis docs say we get 1.5 CPUs
|
||||
MAKE="make -j2"
|
||||
DUMP_CONFIG_LOG="short"
|
||||
export TS_OPT_parsable="yes"
|
||||
|
||||
function configure_travis
|
||||
{
|
||||
./configure "$@"
|
||||
err=$?
|
||||
if [ "$DUMP_CONFIG_LOG" = "short" ]; then
|
||||
grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE="
|
||||
elif [ "$DUMP_CONFIG_LOG" = "full" ]; then
|
||||
cat config.log
|
||||
fi
|
||||
return $err
|
||||
}
|
||||
|
||||
function check_nonroot
|
||||
{
|
||||
local cfg_opts="$1"
|
||||
|
||||
[ -z "$cfg_opts" ] && return
|
||||
|
||||
configure_travis \
|
||||
--enable-cryptsetup-reencrypt \
|
||||
--enable-internal-sse-argon2 \
|
||||
"$cfg_opts" \
|
||||
|| return
|
||||
|
||||
$MAKE || return
|
||||
|
||||
make check
|
||||
}
|
||||
|
||||
function check_root
|
||||
{
|
||||
local cfg_opts="$1"
|
||||
|
||||
[ -z "$cfg_opts" ] && return
|
||||
|
||||
configure_travis \
|
||||
--enable-cryptsetup-reencrypt \
|
||||
--enable-internal-sse-argon2 \
|
||||
"$cfg_opts" \
|
||||
|| return
|
||||
|
||||
$MAKE || return
|
||||
|
||||
# FIXME: we should use -E option here
|
||||
sudo make check
|
||||
}
|
||||
|
||||
function check_nonroot_compile_only
|
||||
{
|
||||
local cfg_opts="$1"
|
||||
|
||||
[ -z "$cfg_opts" ] && return
|
||||
|
||||
configure_travis \
|
||||
--enable-cryptsetup-reencrypt \
|
||||
--enable-internal-sse-argon2 \
|
||||
"$cfg_opts" \
|
||||
|| return
|
||||
|
||||
$MAKE
|
||||
}
|
||||
|
||||
function travis_install_script
|
||||
{
|
||||
# install some packages from Ubuntu's default sources
|
||||
sudo apt-get -qq update
|
||||
sudo apt-get install -qq >/dev/null \
|
||||
sharutils \
|
||||
libgcrypt20-dev \
|
||||
libssl-dev \
|
||||
libdevmapper-dev \
|
||||
libpopt-dev \
|
||||
uuid-dev \
|
||||
libsepol1-dev \
|
||||
libtool \
|
||||
dmsetup \
|
||||
autoconf \
|
||||
automake \
|
||||
pkg-config \
|
||||
autopoint \
|
||||
gettext \
|
||||
expect \
|
||||
keyutils \
|
||||
libjson-c-dev \
|
||||
libblkid-dev \
|
||||
|| return
|
||||
}
|
||||
|
||||
function travis_before_script
|
||||
{
|
||||
set -o xtrace
|
||||
|
||||
./autogen.sh
|
||||
ret=$?
|
||||
|
||||
set +o xtrace
|
||||
return $ret
|
||||
}
|
||||
|
||||
function travis_script
|
||||
{
|
||||
local ret
|
||||
set -o xtrace
|
||||
|
||||
case "$MAKE_CHECK" in
|
||||
gcrypt)
|
||||
check_nonroot "--with-crypto_backend=gcrypt" && \
|
||||
check_root "--with-crypto_backend=gcrypt"
|
||||
;;
|
||||
gcrypt_compile)
|
||||
check_nonroot_compile_only "--with-crypto_backend=gcrypt"
|
||||
;;
|
||||
openssl)
|
||||
check_nonroot "--with-crypto_backend=openssl" && \
|
||||
check_root "--with-crypto_backend=openssl"
|
||||
;;
|
||||
openssl_compile)
|
||||
check_nonroot_compile_only "--with-crypto_backend=openssl"
|
||||
;;
|
||||
kernel)
|
||||
check_nonroot "--with-crypto_backend=kernel" && \
|
||||
check_root "--with-crypto_backend=kernel"
|
||||
;;
|
||||
kernel_compile)
|
||||
check_nonroot_compile_only "--with-crypto_backend=kernel"
|
||||
;;
|
||||
*)
|
||||
echo "error, check environment (travis.yml)" >&2
|
||||
false
|
||||
;;
|
||||
esac
|
||||
|
||||
ret=$?
|
||||
set +o xtrace
|
||||
return $ret
|
||||
}
|
||||
|
||||
function travis_after_script
|
||||
{
|
||||
return 0
|
||||
}
|
||||
39
.travis.yml
39
.travis.yml
@@ -1,39 +0,0 @@
|
||||
language: c
|
||||
|
||||
sudo: required
|
||||
dist: bionic
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
env:
|
||||
- MAKE_CHECK="gcrypt"
|
||||
- MAKE_CHECK="openssl"
|
||||
- MAKE_CHECK="kernel"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- wip-luks2
|
||||
|
||||
before_install:
|
||||
- uname -a
|
||||
- $CC --version
|
||||
- which $CC
|
||||
# workaround clang not system wide, fail on sudo make install
|
||||
- export CC=`which $CC`
|
||||
# workaround travis-ci issue #5301
|
||||
- unset PYTHON_CFLAGS
|
||||
|
||||
install:
|
||||
- source ./.travis-functions.sh
|
||||
- travis_install_script
|
||||
|
||||
before_script:
|
||||
- travis_before_script
|
||||
|
||||
script:
|
||||
- travis_script
|
||||
|
||||
after_script:
|
||||
- travis_after_script
|
||||
@@ -1,6 +0,0 @@
|
||||
Since version 1.6 this file is no longer maintained.
|
||||
|
||||
See docs/*ReleaseNotes for release changes documentation.
|
||||
|
||||
See version control history for full commit messages.
|
||||
https://gitlab.com/cryptsetup/cryptsetup/commits/master
|
||||
947
FAQ → FAQ.md
947
FAQ → FAQ.md
File diff suppressed because it is too large
Load Diff
229
INSTALL
229
INSTALL
@@ -1,229 +0,0 @@
|
||||
Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes a while. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
24
Makefile.am
24
Makefile.am
@@ -1,4 +1,4 @@
|
||||
EXTRA_DIST = COPYING.LGPL FAQ docs misc
|
||||
EXTRA_DIST = README.md COPYING.LGPL FAQ.md docs misc autogen.sh
|
||||
SUBDIRS = po tests
|
||||
CLEANFILES =
|
||||
DISTCLEAN_TARGETS =
|
||||
@@ -11,18 +11,23 @@ AM_CPPFLAGS = \
|
||||
-DLIBDIR=\""$(libdir)"\" \
|
||||
-DPREFIX=\""$(prefix)"\" \
|
||||
-DSYSCONFDIR=\""$(sysconfdir)"\" \
|
||||
-DVERSION=\""$(VERSION)"\"
|
||||
-DVERSION=\""$(VERSION)"\" \
|
||||
-DEXTERNAL_LUKS2_TOKENS_PATH=\"${EXTERNAL_LUKS2_TOKENS_PATH}\"
|
||||
AM_CFLAGS = -Wall
|
||||
AM_LDFLAGS =
|
||||
|
||||
LDADD = $(LTLIBINTL) -lm
|
||||
LDADD = $(LTLIBINTL)
|
||||
|
||||
tmpfilesddir = @DEFAULT_TMPFILESDIR@
|
||||
|
||||
include_HEADERS =
|
||||
lib_LTLIBRARIES =
|
||||
noinst_LTLIBRARIES =
|
||||
sbin_PROGRAMS =
|
||||
man8_MANS =
|
||||
tmpfilesd_DATA =
|
||||
pkgconfig_DATA =
|
||||
dist_noinst_DATA =
|
||||
|
||||
include man/Makemodule.am
|
||||
|
||||
@@ -35,12 +40,14 @@ include lib/crypto_backend/Makemodule.am
|
||||
include lib/Makemodule.am
|
||||
|
||||
include src/Makemodule.am
|
||||
include tokens/Makemodule.am
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = \
|
||||
--with-tmpfilesdir=$$dc_install_base/usr/lib/tmpfiles.d \
|
||||
--enable-internal-argon2 --enable-internal-sse-argon2
|
||||
--enable-internal-argon2 --enable-internal-sse-argon2 \
|
||||
--enable-external-tokens --enable-ssh-token --enable-asciidoc
|
||||
|
||||
distclean-local:
|
||||
-find . -name \*~ -o -name \*.orig -o -name \*.rej | xargs rm -f
|
||||
@@ -48,3 +55,12 @@ distclean-local:
|
||||
|
||||
clean-local:
|
||||
-rm -rf docs/doxygen_api_docs libargon2.la
|
||||
|
||||
install-data-local:
|
||||
$(MKDIR_P) -m 0755 $(DESTDIR)/${EXTERNAL_LUKS2_TOKENS_PATH}
|
||||
|
||||
uninstall-local:
|
||||
rmdir $(DESTDIR)/${EXTERNAL_LUKS2_TOKENS_PATH} 2>/dev/null || :
|
||||
|
||||
check-programs: libcryptsetup.la
|
||||
$(MAKE) -C tests $@
|
||||
|
||||
31
README
31
README
@@ -1,31 +0,0 @@
|
||||
|
||||
cryptsetup
|
||||
|
||||
setup cryptographic volumes for dm-crypt (including LUKS extension)
|
||||
|
||||
WEB PAGE:
|
||||
|
||||
https://gitlab.com/cryptsetup/cryptsetup/
|
||||
|
||||
FAQ:
|
||||
|
||||
https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions
|
||||
|
||||
MAILING LIST:
|
||||
|
||||
E-MAIL: dm-crypt@saout.de
|
||||
URL: http://www.saout.de/mailman/listinfo/dm-crypt
|
||||
|
||||
DOWNLOAD:
|
||||
|
||||
https://www.kernel.org/pub/linux/utils/cryptsetup/
|
||||
|
||||
SOURCE CODE:
|
||||
|
||||
URL: https://gitlab.com/cryptsetup/cryptsetup/tree/master
|
||||
Checkout: git clone https://gitlab.com/cryptsetup/cryptsetup.git
|
||||
|
||||
NLS (PO TRANSLATIONS):
|
||||
|
||||
PO files are maintained by:
|
||||
http://translationproject.org/domain/cryptsetup.html
|
||||
78
README.md
78
README.md
@@ -10,16 +10,17 @@ These include **plain** **dm-crypt** volumes, **LUKS** volumes, **loop-AES**,
|
||||
|
||||
The project also includes a **veritysetup** utility used to conveniently setup
|
||||
[DMVerity](https://gitlab.com/cryptsetup/cryptsetup/wikis/DMVerity) block integrity checking kernel module
|
||||
and, since version 2.0, **integritysetup** to setup
|
||||
and **integritysetup** to setup
|
||||
[DMIntegrity](https://gitlab.com/cryptsetup/cryptsetup/wikis/DMIntegrity) block integrity kernel module.
|
||||
|
||||
|
||||
LUKS Design
|
||||
-----------
|
||||
**LUKS** is the standard for Linux hard disk encryption. By providing a standard on-disk-format, it does not
|
||||
only facilitate compatibility among distributions, but also provides secure management of multiple user passwords.
|
||||
LUKS stores all necessary setup information in the partition header, enabling to transport or migrate data seamlessly.
|
||||
|
||||
### Specifications
|
||||
|
||||
Last version of the LUKS2 format specification is
|
||||
[available here](https://gitlab.com/cryptsetup/LUKS2-docs).
|
||||
|
||||
@@ -44,22 +45,22 @@ Download
|
||||
--------
|
||||
All release tarballs and release notes are hosted on [kernel.org](https://www.kernel.org/pub/linux/utils/cryptsetup/).
|
||||
|
||||
**The latest stable cryptsetup version is 2.3.2**
|
||||
* [cryptsetup-2.3.2.tar.xz](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/cryptsetup-2.3.2.tar.xz)
|
||||
* Signature [cryptsetup-2.3.2.tar.sign](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/cryptsetup-2.3.2.tar.sign)
|
||||
**The latest stable release candidate cryptsetup version is 2.5.0-rc1**
|
||||
* [cryptsetup-2.5.0-rc1.tar.xz](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.5/cryptsetup-2.5.0-rc1.tar.xz)
|
||||
* Signature [cryptsetup-2.5.0-rc1.tar.sign](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.5/cryptsetup-2.5.0-rc1.tar.sign)
|
||||
_(You need to decompress file first to check signature.)_
|
||||
* [Cryptsetup 2.3.2 Release Notes](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/v2.3.2-ReleaseNotes).
|
||||
* [Cryptsetup 2.5.0-rc1 Release Notes](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.5/v2.5.0-rc1-ReleaseNotes).
|
||||
|
||||
**The latest stable cryptsetup version is 2.4.3**
|
||||
* [cryptsetup-2.4.3.tar.xz](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.4/cryptsetup-2.4.3.tar.xz)
|
||||
* Signature [cryptsetup-2.4.3.tar.sign](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.4/cryptsetup-2.4.3.tar.sign)
|
||||
_(You need to decompress file first to check signature.)_
|
||||
* [Cryptsetup 2.4.3 Release Notes](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.4/v2.4.3-ReleaseNotes).
|
||||
|
||||
Previous versions
|
||||
* [Version 2.3.1](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/cryptsetup-2.3.1.tar.xz) -
|
||||
[Signature](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/cryptsetup-2.3.1.tar.sign) -
|
||||
[Release Notes](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/v2.3.1-ReleaseNotes).
|
||||
* [Version 2.2.2](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.2/cryptsetup-2.2.2.tar.xz) -
|
||||
[Signature](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.2/cryptsetup-2.2.2.tar.sign) -
|
||||
[Release Notes](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.2/v2.2.2-ReleaseNotes).
|
||||
* [Version 2.0.6](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.0/cryptsetup-2.0.6.tar.xz) -
|
||||
[Signature](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.0/cryptsetup-2.0.6.tar.sign) -
|
||||
[Release Notes](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.0/v2.0.6-ReleaseNotes).
|
||||
* [Version 2.3.7](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/cryptsetup-2.3.7.tar.xz) -
|
||||
[Signature](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/cryptsetup-2.3.7.tar.sign) -
|
||||
[Release Notes](https://www.kernel.org/pub/linux/utils/cryptsetup/v2.3/v2.3.7-ReleaseNotes).
|
||||
* [Version 1.7.5](https://www.kernel.org/pub/linux/utils/cryptsetup/v1.7/cryptsetup-1.7.5.tar.xz) -
|
||||
[Signature](https://www.kernel.org/pub/linux/utils/cryptsetup/v1.7/cryptsetup-1.7.5.tar.sign) -
|
||||
[Release Notes](https://www.kernel.org/pub/linux/utils/cryptsetup/v1.7/v1.7.5-ReleaseNotes).
|
||||
@@ -73,14 +74,49 @@ For libcryptsetup documentation see [libcryptsetup API](https://mbroz.fedorapeop
|
||||
|
||||
The libcryptsetup API/ABI changes are tracked in [compatibility report](https://abi-laboratory.pro/tracker/timeline/cryptsetup/).
|
||||
|
||||
NLS PO files are maintained by [TranslationProject](http://translationproject.org/domain/cryptsetup.html).
|
||||
NLS PO files are maintained by [TranslationProject](https://translationproject.org/domain/cryptsetup.html).
|
||||
|
||||
Required packages
|
||||
-----------------
|
||||
All distributions provide cryptsetup as distro package. If you need to compile cryptsetup yourself, some packages are required for compilation. Please always prefer distro specific build tools to manually configuring cryptsetup.
|
||||
|
||||
Here is the list of packages needed for the compilation of project for particular distributions:
|
||||
* For Fedora: `git gcc make autoconf automake gettext-devel pkgconfig openssl-devel popt-devel device-mapper-devel libuuid-devel json-c-devel libblkid-devel findutils libtool libssh-devel tar`. Optionally `libargon2-devel libpwquality-devel`. To run the internal testsuite you also need to install `sharutils device-mapper jq vim-common expect keyutils netcat shadow-utils openssh-clients openssh sshpass`.
|
||||
|
||||
* For Debian and Ubuntu: `git gcc make autoconf automake autopoint pkg-config libtool gettext libssl-dev libdevmapper-dev libpopt-dev uuid-dev libsepol1-dev libjson-c-dev libssh-dev libblkid-dev tar`. Optionally `libargon2-0-dev libpwquality-dev`. To run the internal testsuite you also need to install `sharutils dmsetup jq xxd expect keyutils netcat passwd openssh-client sshpass`
|
||||
|
||||
Note that the list could change as the distributions evolve.
|
||||
|
||||
Compilation
|
||||
-----------
|
||||
The cryptsetup project uses **automake** and **autoconf** system to generate all needed files for compilation. If you check it from the git snapshot, use ``./autogen.sh && ./configure && make`` to compile the project. If you use downloaded released ``*.tar.xz`` archive, the configure script is already pre-generated (no need to run ``autoconf.sh``).
|
||||
See ``./configure --help`` and use ``--disable-*`` and ``--enable-*`` options.
|
||||
|
||||
For running the test suite that come with the project, type ``make check``.
|
||||
Note that most tests will need root user privileges and run many dangerous storage fail simulations.
|
||||
Do **not** run tests with root privilege on production systems! Some tests will need scsi_debug kernel module to be available.
|
||||
|
||||
For more details, please refer to [automake](https://www.gnu.org/software/automake/manual/automake.html) and [autoconf](https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf.html) manuals.
|
||||
|
||||
Help!
|
||||
-----
|
||||
Please always read [FAQ](https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions) first.
|
||||
For cryptsetup and LUKS related questions, please use the dm-crypt mailing list, [dm-crypt@saout.de](mailto:dm-crypt@saout.de).
|
||||
|
||||
If you want to subscribe just send an empty mail to [dm-crypt-subscribe@saout.de](mailto:dm-crypt-subscribe@saout.de).
|
||||
### Documentation
|
||||
|
||||
You can also browse [list archive](http://www.saout.de/pipermail/dm-crypt/) or read it through
|
||||
[web interface](https://marc.info/?l=dm-crypt).
|
||||
Please read the following documentation before posting questions in the mailing list. You will be able to ask better questions and better understand the answers.
|
||||
|
||||
* [FAQ](https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions)
|
||||
* LUKS Specifications
|
||||
* manuals (aka man page, man pages, man-page)
|
||||
|
||||
The FAQ is online and in the source code for the project. The Specifications are referenced above in this document. The man pages are in source and should be available after installation using standard man commands. e.g. man cryptsetup
|
||||
|
||||
### Mailing List
|
||||
|
||||
For cryptsetup and LUKS related questions, please use the cryptsetup mailing list [cryptsetup@lists.linux.dev](mailto:cryptsetup@lists.linux.dev), hosted at [kernel.org subspace](https://subspace.kernel.org/lists.linux.dev.html).
|
||||
To subscribe send an empty mail to [cryptsetup+subscribe@lists.linux.dev](mailto:cryptsetup+subscribe@lists.linux.dev).
|
||||
|
||||
You can also browse and/or search the mailing [list archive](https://lore.kernel.org/cryptsetup/).
|
||||
News (NNTP), Atom feed and git access to public inbox is available through [lore.kernel.org](https://lore.kernel.org) service.
|
||||
|
||||
The former dm-crypt [list archive](https://lore.kernel.org/dm-crypt/) is also available.
|
||||
|
||||
10
SECURITY.md
Normal file
10
SECURITY.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Reporting a Security Bug in cryptsetup project
|
||||
|
||||
If you think you have discovered a security issue, please report it through
|
||||
the project issue tracker [New issue](https://gitlab.com/cryptsetup/cryptsetup/issues)
|
||||
as a confidential issue (select confidential checkbox).
|
||||
|
||||
An alternative is to send PGP encrypted mail to the cryptsetup maintainer.
|
||||
Current maintainer is [Milan Broz](mailto:gmazyland@gmail.com), use PGP key
|
||||
with fingerprint 2A29 1824 3FDE 4664 8D06 86F9 D9B0 577B D93E 98FC.
|
||||
|
||||
1
TODO
1
TODO
@@ -1 +0,0 @@
|
||||
Please see issues tracked at https://gitlab.com/cryptsetup/cryptsetup/issues.
|
||||
31
autogen.sh
31
autogen.sh
@@ -9,25 +9,31 @@ DIE=0
|
||||
(autopoint --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Error**: You must have autopoint installed."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or see http://www.gnu.org/software/gettext"
|
||||
echo "Download the appropriate package for your distribution."
|
||||
DIE=1
|
||||
}
|
||||
|
||||
|
||||
(msgfmt --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Warning**: You should have gettext installed."
|
||||
echo "Download the appropriate package for your distribution."
|
||||
echo "To disable translation, you can also use --disable-nls"
|
||||
echo "configure option."
|
||||
}
|
||||
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Error**: You must have autoconf installed to."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
echo "**Error**: You must have autoconf installed."
|
||||
echo "Download the appropriate package for your distribution."
|
||||
DIE=1
|
||||
}
|
||||
|
||||
(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && {
|
||||
(libtool --version) < /dev/null > /dev/null 2>&1 || {
|
||||
(grep "^LT_INIT" $srcdir/configure.ac >/dev/null) && {
|
||||
(libtoolize --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Error**: You must have libtool installed."
|
||||
echo "Get ftp://ftp.gnu.org/pub/gnu/"
|
||||
echo "(or a newer version if it is available)"
|
||||
echo "**Error**: You must have libtoolize installed."
|
||||
echo "Download the appropriate package for your distribution."
|
||||
DIE=1
|
||||
}
|
||||
}
|
||||
@@ -35,8 +41,7 @@ DIE=0
|
||||
(automake --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Error**: You must have automake installed."
|
||||
echo "Get ftp://ftp.gnu.org/pub/gnu/"
|
||||
echo "(or a newer version if it is available)"
|
||||
echo "Download the appropriate package for your distribution."
|
||||
DIE=1
|
||||
NO_AUTOMAKE=yes
|
||||
}
|
||||
@@ -47,8 +52,6 @@ test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Error**: Missing aclocal. The version of automake"
|
||||
echo "installed doesn't appear recent enough."
|
||||
echo "Get ftp://ftp.gnu.org/pub/gnu/"
|
||||
echo "(or a newer version if it is available)"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
|
||||
124
configure.ac
124
configure.ac
@@ -1,9 +1,9 @@
|
||||
AC_PREREQ([2.67])
|
||||
AC_INIT([cryptsetup],[2.3.3])
|
||||
AC_INIT([cryptsetup],[2.5.0-rc1])
|
||||
|
||||
dnl library version from <major>.<minor>.<release>[-<suffix>]
|
||||
LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
|
||||
LIBCRYPTSETUP_VERSION_INFO=18:0:6
|
||||
LIBCRYPTSETUP_VERSION_INFO=20:0:8
|
||||
|
||||
AM_SILENT_RULES([yes])
|
||||
AC_CONFIG_SRCDIR(src/cryptsetup.c)
|
||||
@@ -16,7 +16,7 @@ AC_CONFIG_HEADERS([config.h:config.h.in])
|
||||
|
||||
# For old automake use this
|
||||
#AM_INIT_AUTOMAKE(dist-xz subdir-objects)
|
||||
AM_INIT_AUTOMAKE([dist-xz 1.12 serial-tests subdir-objects])
|
||||
AM_INIT_AUTOMAKE([dist-xz 1.12 serial-tests subdir-objects foreign])
|
||||
|
||||
if test "x$prefix" = "xNONE"; then
|
||||
sysconfdir=/etc
|
||||
@@ -30,10 +30,10 @@ AM_PROG_CC_C_O
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_MKDIR_P
|
||||
AC_ENABLE_STATIC(no)
|
||||
LT_INIT
|
||||
PKG_PROG_PKG_CONFIG
|
||||
AM_ICONV
|
||||
|
||||
dnl ==========================================================================
|
||||
dnl define PKG_CHECK_VAR for old pkg-config <= 0.28
|
||||
@@ -52,13 +52,33 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
|
||||
AS_VAR_IF([$1], [""], [$5], [$4])
|
||||
])
|
||||
])
|
||||
dnl ==========================================================================
|
||||
dnl AsciiDoc manual pages
|
||||
|
||||
AC_ARG_ENABLE([asciidoc],
|
||||
AS_HELP_STRING([--disable-asciidoc], [do not generate man pages from asciidoc]),
|
||||
[], [enable_asciidoc=yes]
|
||||
)
|
||||
|
||||
AC_PATH_PROG([ASCIIDOCTOR], [asciidoctor])
|
||||
if test "x$enable_asciidoc" = xyes -a "x$ASCIIDOCTOR" = x; then
|
||||
AC_MSG_ERROR([Building man pages requires asciidoctor installed.])
|
||||
fi
|
||||
AM_CONDITIONAL([ENABLE_ASCIIDOC], [test "x$enable_asciidoc" = xyes])
|
||||
|
||||
have_manpages=no
|
||||
AS_IF([test -f "$srcdir/man/cryptsetup-open.8"], [
|
||||
AC_MSG_NOTICE([re-use already generated man-pages.])
|
||||
have_manpages=yes]
|
||||
)
|
||||
AM_CONDITIONAL([HAVE_MANPAGES], [test "x$have_manpages" = xyes])
|
||||
|
||||
dnl ==========================================================================
|
||||
|
||||
AC_C_RESTRICT
|
||||
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h sys/ioctl.h sys/mman.h \
|
||||
AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h uchar.h sys/ioctl.h sys/mman.h \
|
||||
sys/sysmacros.h sys/statvfs.h ctype.h unistd.h locale.h byteswap.h endian.h stdint.h)
|
||||
AC_CHECK_DECLS([O_CLOEXEC],,[AC_DEFINE([O_CLOEXEC],[0], [Defined to 0 if not provided])],
|
||||
[[
|
||||
@@ -115,6 +135,39 @@ AC_FUNC_FSEEKO
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_FUNC_STRERROR_R
|
||||
|
||||
dnl ==========================================================================
|
||||
dnl LUKS2 external tokens
|
||||
|
||||
AC_ARG_ENABLE([external-tokens],
|
||||
AS_HELP_STRING([--disable-external-tokens], [disable external LUKS2 tokens]),
|
||||
[], [enable_external_tokens=yes])
|
||||
if test "x$enable_external_tokens" = "xyes"; then
|
||||
AC_DEFINE(USE_EXTERNAL_TOKENS, 1, [Use external tokens])
|
||||
dnl we need dynamic library loading here
|
||||
saved_LIBS=$LIBS
|
||||
AC_SEARCH_LIBS([dlsym],[dl])
|
||||
AC_CHECK_FUNCS([dlvsym])
|
||||
AC_SUBST(DL_LIBS, $LIBS)
|
||||
LIBS=$saved_LIBS
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([ssh-token],
|
||||
AS_HELP_STRING([--disable-ssh-token], [disable LUKS2 ssh-token]),
|
||||
[], [enable_ssh_token=yes])
|
||||
AM_CONDITIONAL(SSHPLUGIN_TOKEN, test "x$enable_ssh_token" = "xyes")
|
||||
|
||||
if test "x$enable_ssh_token" = "xyes" -a "x$enable_external_tokens" = "xno"; then
|
||||
AC_MSG_ERROR([Requested LUKS2 ssh-token build, but external tokens are disabled.])
|
||||
fi
|
||||
|
||||
dnl LUKS2 online reencryption
|
||||
AC_ARG_ENABLE([luks2-reencryption],
|
||||
AS_HELP_STRING([--disable-luks2-reencryption], [disable LUKS2 online reencryption extension]),
|
||||
[], [enable_luks2_reencryption=yes])
|
||||
if test "x$enable_luks2_reencryption" = "xyes"; then
|
||||
AC_DEFINE(USE_LUKS2_REENCRYPTION, 1, [Use LUKS2 online reencryption extension])
|
||||
fi
|
||||
|
||||
dnl ==========================================================================
|
||||
|
||||
AM_GNU_GETTEXT([external],[need-ngettext])
|
||||
@@ -176,7 +229,15 @@ AC_DEFINE_UNQUOTED([PASSWDQC_CONFIG_FILE], ["$use_passwdqc_config"], [passwdqc l
|
||||
if test "x$enable_passwdqc" = "xyes"; then
|
||||
AC_DEFINE(ENABLE_PASSWDQC, 1, [Enable password quality checking using passwdqc library])
|
||||
|
||||
PASSWDQC_LIBS="-lpasswdqc"
|
||||
saved_LIBS="$LIBS"
|
||||
AC_SEARCH_LIBS([passwdqc_check], [passwdqc])
|
||||
case "$ac_cv_search_passwdqc_check" in
|
||||
no) AC_MSG_ERROR([failed to find passwdqc_check]) ;;
|
||||
-l*) PASSWDQC_LIBS="$ac_cv_search_passwdqc_check" ;;
|
||||
*) PASSWDQC_LIBS= ;;
|
||||
esac
|
||||
AC_CHECK_FUNCS([passwdqc_params_free])
|
||||
LIBS="$saved_LIBS"
|
||||
fi
|
||||
|
||||
if test "x$enable_pwquality$enable_passwdqc" = "xyesyes"; then
|
||||
@@ -321,11 +382,6 @@ AC_ARG_ENABLE([veritysetup],
|
||||
[], [enable_veritysetup=yes])
|
||||
AM_CONDITIONAL(VERITYSETUP, test "x$enable_veritysetup" = "xyes")
|
||||
|
||||
AC_ARG_ENABLE([cryptsetup-reencrypt],
|
||||
AS_HELP_STRING([--disable-cryptsetup-reencrypt], [disable cryptsetup-reencrypt tool]),
|
||||
[], [enable_cryptsetup_reencrypt=yes])
|
||||
AM_CONDITIONAL(REENCRYPT, test "x$enable_cryptsetup_reencrypt" = "xyes")
|
||||
|
||||
AC_ARG_ENABLE([integritysetup],
|
||||
AS_HELP_STRING([--disable-integritysetup], [disable integritysetup support]),
|
||||
[], [enable_integritysetup=yes])
|
||||
@@ -372,6 +428,17 @@ PKG_CHECK_MODULES([JSON_C], [json-c])
|
||||
AC_CHECK_DECLS([json_object_object_add_ex], [], [], [#include <json-c/json.h>])
|
||||
AC_CHECK_DECLS([json_object_deep_copy], [], [], [#include <json-c/json.h>])
|
||||
|
||||
dnl Check for libssh and argp for SSH plugin
|
||||
if test "x$enable_ssh_token" = "xyes"; then
|
||||
PKG_CHECK_MODULES([LIBSSH], [libssh])
|
||||
AC_CHECK_DECLS([ssh_session_is_known_server], [], [], [#include <libssh/libssh.h>])
|
||||
AC_CHECK_HEADER([argp.h], [], AC_MSG_ERROR([You need argp library.]))
|
||||
saved_LIBS=$LIBS
|
||||
AC_SEARCH_LIBS([argp_parse],[argp])
|
||||
AC_SUBST(ARGP_LIBS, $LIBS)
|
||||
LIBS=$saved_LIBS
|
||||
fi
|
||||
|
||||
dnl Crypto backend configuration.
|
||||
AC_ARG_WITH([crypto_backend],
|
||||
AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [openssl]]),
|
||||
@@ -508,6 +575,23 @@ if test "x$enable_static_cryptsetup" = "xyes"; then
|
||||
PKG_CONFIG=$saved_PKG_CONFIG
|
||||
fi
|
||||
|
||||
dnl Check compiler support for symver function attribute
|
||||
AC_MSG_CHECKING([for symver attribute support])
|
||||
saved_CFLAGS=$CFLAGS
|
||||
CFLAGS="-O0 -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
void _test_sym(void);
|
||||
__attribute__((__symver__("sym@VERSION_4.2"))) void _test_sym(void) {}
|
||||
]],
|
||||
[[ _test_sym() ]]
|
||||
)],[
|
||||
AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], 1, [Define to 1 to use __attribute__((symver))])
|
||||
AC_MSG_RESULT([yes])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
CFLAGS=$saved_CFLAGS
|
||||
|
||||
AC_MSG_CHECKING([for systemd tmpfiles config directory])
|
||||
PKG_CHECK_VAR([systemd_tmpfilesdir], [systemd], [tmpfilesdir], [], [systemd_tmpfilesdir=no])
|
||||
AC_MSG_RESULT([$systemd_tmpfilesdir])
|
||||
@@ -528,6 +612,8 @@ AC_SUBST([JSON_C_LIBS])
|
||||
AC_SUBST([LIBARGON2_LIBS])
|
||||
AC_SUBST([BLKID_LIBS])
|
||||
|
||||
AC_SUBST([LIBSSH_LIBS])
|
||||
|
||||
AC_SUBST([LIBCRYPTSETUP_VERSION])
|
||||
AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
|
||||
|
||||
@@ -583,7 +669,7 @@ if test "x$enable_luks_adjust_xts_keysize" = "xyes"; then
|
||||
AC_DEFINE(ENABLE_LUKS_ADJUST_XTS_KEYSIZE, 1, [XTS mode - double default LUKS keysize if needed])
|
||||
fi
|
||||
|
||||
CS_STR_WITH([luks2-pbkdf], [Default PBKDF algorithm (pbkdf2 or argon2i/argon2id) for LUKS2], [argon2i])
|
||||
CS_STR_WITH([luks2-pbkdf], [Default PBKDF algorithm (pbkdf2 or argon2i/argon2id) for LUKS2], [argon2id])
|
||||
CS_NUM_WITH([luks1-iter-time], [PBKDF2 iteration time for LUKS1 (in ms)], [2000])
|
||||
CS_NUM_WITH([luks2-iter-time], [Argon2 PBKDF iteration time for LUKS2 (in ms)], [2000])
|
||||
CS_NUM_WITH([luks2-memory-kb], [Argon2 PBKDF memory cost for LUKS2 (in kB)], [1048576])
|
||||
@@ -596,7 +682,8 @@ CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
|
||||
CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
|
||||
|
||||
CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in KiB)], [8192])
|
||||
CS_NUM_WITH([passphrase-size-max],[maximum keyfile size (in characters)], [512])
|
||||
CS_NUM_WITH([integrity-keyfile-size-maxkb],[maximum integritysetup keyfile size (in KiB)], [4])
|
||||
CS_NUM_WITH([passphrase-size-max],[maximum passphrase size (in characters)], [512])
|
||||
|
||||
CS_STR_WITH([verity-hash], [hash function for verity mode], [sha256])
|
||||
CS_NUM_WITH([verity-data-block], [data block size for verity mode], [4096])
|
||||
@@ -624,6 +711,15 @@ test -z "$with_luks2_lock_dir_perms" && with_luks2_lock_dir_perms=0700
|
||||
DEFAULT_LUKS2_LOCK_DIR_PERMS=$with_luks2_lock_dir_perms
|
||||
AC_SUBST(DEFAULT_LUKS2_LOCK_DIR_PERMS)
|
||||
|
||||
CS_STR_WITH([luks2-external-tokens-path], [path to directory with LUKSv2 external token handlers (plugins)], [LIBDIR/cryptsetup])
|
||||
if test -n "$with_luks2_external_tokens_path"; then
|
||||
CS_ABSPATH([${with_luks2_external_tokens_path}],[with-luks2-external-tokens-path])
|
||||
EXTERNAL_LUKS2_TOKENS_PATH=$with_luks2_external_tokens_path
|
||||
else
|
||||
EXTERNAL_LUKS2_TOKENS_PATH="\${libdir}/cryptsetup"
|
||||
fi
|
||||
AC_SUBST(EXTERNAL_LUKS2_TOKENS_PATH)
|
||||
|
||||
dnl Override default LUKS format version (for cryptsetup or cryptsetup-reencrypt format actions only).
|
||||
AC_ARG_WITH([default_luks_format],
|
||||
AS_HELP_STRING([--with-default-luks-format=FORMAT], [default LUKS format version (LUKS1/LUKS2) [LUKS2]]),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Doxyfile 1.8.8
|
||||
# Doxyfile 1.9.1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
@@ -12,6 +12,7 @@ OUTPUT_DIRECTORY = doxygen_api_docs
|
||||
CREATE_SUBDIRS = NO
|
||||
ALLOW_UNICODE_NAMES = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
OUTPUT_TEXT_DIRECTION = None
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
@@ -22,40 +23,47 @@ STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
JAVADOC_BANNER = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
PYTHON_DOCSTRING = YES
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
TCL_SUBST =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
OPTIMIZE_OUTPUT_SLICE = NO
|
||||
EXTENSION_MAPPING =
|
||||
MARKDOWN_SUPPORT = YES
|
||||
TOC_INCLUDE_HEADINGS = 5
|
||||
AUTOLINK_SUPPORT = YES
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
GROUP_NESTED_COMPOUNDS = NO
|
||||
SUBGROUPING = YES
|
||||
INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
TYPEDEF_HIDES_STRUCT = YES
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
NUM_PROC_THREADS = 1
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_PRIV_VIRTUAL = NO
|
||||
EXTRACT_PACKAGE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
RESOLVE_UNNAMED_PARAMS = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
@@ -63,6 +71,7 @@ HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
HIDE_COMPOUND_REFERENCE= NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
SHOW_GROUPED_MEMB_INC = NO
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
@@ -93,13 +102,14 @@ WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_AS_ERROR = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = "doxygen_index.h" \
|
||||
"../lib/libcryptsetup.h"
|
||||
INPUT = doxygen_index.h \
|
||||
../lib/libcryptsetup.h
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS =
|
||||
RECURSIVE = NO
|
||||
@@ -107,7 +117,7 @@ EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH = "examples"
|
||||
EXAMPLE_PATH = examples
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
@@ -129,12 +139,13 @@ SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
CLANG_ASSISTED_PARSING = NO
|
||||
CLANG_ADD_INC_PATHS = YES
|
||||
CLANG_OPTIONS =
|
||||
CLANG_DATABASE_PATH =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the HTML output
|
||||
@@ -151,6 +162,7 @@ HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_TIMESTAMP = YES
|
||||
HTML_DYNAMIC_MENUS = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
HTML_INDEX_NUM_ENTRIES = 100
|
||||
GENERATE_DOCSET = NO
|
||||
@@ -180,8 +192,10 @@ GENERATE_TREEVIEW = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
TREEVIEW_WIDTH = 250
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
HTML_FORMULA_FORMAT = png
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
FORMULA_MACROFILE =
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_FORMAT = HTML-CSS
|
||||
MATHJAX_RELPATH = http://www.mathjax.org/mathjax
|
||||
@@ -201,11 +215,13 @@ GENERATE_LATEX = YES
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
LATEX_MAKEINDEX_CMD = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
LATEX_FOOTER =
|
||||
LATEX_EXTRA_STYLESHEET =
|
||||
LATEX_EXTRA_FILES =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
@@ -213,6 +229,8 @@ LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
LATEX_SOURCE_CODE = NO
|
||||
LATEX_BIB_STYLE = plain
|
||||
LATEX_TIMESTAMP = NO
|
||||
LATEX_EMOJI_DIRECTORY =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -222,6 +240,7 @@ COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
RTF_SOURCE_CODE = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -236,6 +255,7 @@ MAN_LINKS = NO
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_PROGRAMLISTING = YES
|
||||
XML_NS_MEMB_FILE_SCOPE = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the DOCBOOK output
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -273,12 +293,10 @@ GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
EXTERNAL_PAGES = YES
|
||||
PERL_PATH =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
MSCGEN_PATH =
|
||||
DIA_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
@@ -291,6 +309,8 @@ COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
UML_LIMIT_NUM_FIELDS = 10
|
||||
DOT_UML_DETAILS = NO
|
||||
DOT_WRAP_THRESHOLD = 17
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
@@ -305,6 +325,8 @@ DOTFILE_DIRS =
|
||||
MSCFILE_DIRS =
|
||||
DIAFILE_DIRS =
|
||||
PLANTUML_JAR_PATH =
|
||||
PLANTUML_CFG_FILE =
|
||||
PLANTUML_INCLUDE_PATH =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* libcryptsetup API log example
|
||||
*
|
||||
* Copyright (C) 2011-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2011-2022 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* libcryptsetup API - using LUKS device example
|
||||
*
|
||||
* Copyright (C) 2011-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2011-2022 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
||||
Binary file not shown.
@@ -89,7 +89,7 @@ Important features
|
||||
|
||||
Integritysetup is intended to be used for settings that require
|
||||
non-cryptographic data integrity protection with no data encryption.
|
||||
Fo setting integrity protected encrypted devices, see disk authenticated
|
||||
For setting integrity protected encrypted devices, see disk authenticated
|
||||
encryption below.
|
||||
|
||||
Note that after formatting the checksums need to be initialized;
|
||||
@@ -583,7 +583,7 @@ Unfinished things & TODO for next releases
|
||||
in kernel (more on this later).
|
||||
NOTE: Currently available authenticated modes (GCM, Chacha20-poly1305)
|
||||
in kernel have too small 96-bit nonces that are problematic with
|
||||
randomly generated IVs (the collison probability is not negligible).
|
||||
randomly generated IVs (the collision probability is not negligible).
|
||||
For the GCM, nonce collision is a fatal problem.
|
||||
|
||||
* Authenticated encryption do not set encryption for dm-integrity journal.
|
||||
|
||||
112
docs/v2.3.4-ReleaseNotes
Normal file
112
docs/v2.3.4-ReleaseNotes
Normal file
@@ -0,0 +1,112 @@
|
||||
Cryptsetup 2.3.4 Release Notes
|
||||
==============================
|
||||
Stable bug-fix release with a security fix (32-bit only).
|
||||
|
||||
All users of cryptsetup 2.2.x and later should upgrade to this version.
|
||||
|
||||
Changes since version 2.3.3
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Fix a possible out-of-bounds memory write while validating LUKS2 data
|
||||
segments metadata (CVE-2020-14382).
|
||||
|
||||
This problem can be triggered only on 32-bit builds (64-bit systems
|
||||
are not affected).
|
||||
|
||||
LUKS2 format validation code contains a bug in segments validation code
|
||||
where the code does not check for possible overflow on memory allocation.
|
||||
|
||||
Due to the bug, the libcryptsetup can be tricked to expect such allocation
|
||||
was successful. Later it may read data from image crafted by an attacker and
|
||||
actually write such data beyond allocated memory.
|
||||
|
||||
The bug was introduced in cryptsetup 2.2.0. All later releases until 2.3.4
|
||||
are affected.
|
||||
|
||||
If you only backport the fix for this CVE, these master branch git commits
|
||||
should be backported:
|
||||
52f5cb8cedf22fb3e14c744814ec8af7614146c7
|
||||
46ee71edcd13e1dad50815ad65c28779aa6f7503
|
||||
752c9a52798f11d3b765b673ebaa3058eb25316e
|
||||
|
||||
Thanks to Tobias Stoeckmann for discovering this issue.
|
||||
|
||||
* Ignore reported optimal IO size if not aligned to minimal page size.
|
||||
|
||||
Some USB enclosures report bogus block device topology (see lsblk -t) that
|
||||
prevents LUKS2 format with 4k sector size (reported values are not correctly
|
||||
aligned). The code now ignores such values and uses the default alignment.
|
||||
|
||||
* Added support for new no_read/write_wrokqueue dm-crypt options (kernel 5.9).
|
||||
|
||||
These performance options, introduced in kernel 5.9, configure dm-crypt
|
||||
to bypass read or write workqueues and run encryption synchronously.
|
||||
|
||||
Use --perf-no_read_workqueue or --perf-no_write_workqueue cryptsetup arguments
|
||||
to use these dm-crypt flags.
|
||||
|
||||
These options are available only for low-level dm-crypt performance tuning,
|
||||
use only if you need a change to default dm-crypt behavior.
|
||||
|
||||
For LUKS2, these flags can be persistently stored in metadata with
|
||||
the --persistent option.
|
||||
|
||||
* Added support panic_on_corruption option for dm-verity devices (kernel 5.9).
|
||||
|
||||
Veritysetup now supports --panic-on-corruption argument that configures
|
||||
the dm-verity device to panics kernel if a corruption is detected.
|
||||
|
||||
This option is intended for specific configurations, do not use it in
|
||||
standard configurations.
|
||||
|
||||
* Support --master-key-file option for online LUKS2 reencryption
|
||||
|
||||
This can be used for reencryption of devices that uses protected key AES cipher
|
||||
on some mainframes crypto accelerators.
|
||||
|
||||
* Always return EEXIST error code if a device already exists.
|
||||
|
||||
Some libcryptsetup functions (activate_by*) now return EEXIST error code,
|
||||
so the caller can distinguish that call fails because some parallel process
|
||||
already activated the device.
|
||||
Previously all fails returned EINVAL (invalid value).
|
||||
|
||||
* Fix a problem in integritysetup if a hash algorithm has dash in the name.
|
||||
|
||||
If users want to use blake2b/blake2s, the kernel algorithm name includes
|
||||
a dash (like "blake2s-256").
|
||||
These algorithms can now be used for integritysetup devices.
|
||||
|
||||
* Fix crypto backend to properly handle ECB mode.
|
||||
|
||||
Even though it should never be used, it should still work for testing :)
|
||||
This fixes a bug introduced in cryptsetup version 2.3.2.
|
||||
|
||||
* TrueCrypt/VeraCrypt compatible mode now supports the activation of devices
|
||||
with a larger sector.
|
||||
|
||||
TrueCrypt/VeraCrypt always uses 512-byte sector for encryption, but for devices
|
||||
with a larger native sector, it stores this value in the header.
|
||||
|
||||
This patch allows activation of such devices, basically ignoring
|
||||
the mentioned sector size.
|
||||
|
||||
* LUKS2: Do not create excessively large headers.
|
||||
|
||||
When creating a LUKS2 header with a specified --offset larger than
|
||||
the LUKS2 header size, do not create a larger file than needed.
|
||||
|
||||
* Fix unspecified sector size for BitLocker compatible mode.
|
||||
|
||||
Some BitLocker devices can contain zeroed sector size in the header.
|
||||
In this case, the 512-byte sector should be used.
|
||||
The bug was introduced in version 2.3.3.
|
||||
|
||||
* Fix reading key data size in metadata for BitLocker compatible mode.
|
||||
|
||||
Such devices with an unexpected entry in metadata can now be activated.
|
||||
|
||||
Thanks to all users reporting these problems, BitLocker metadata documentation
|
||||
is not publicly available, and we depend only on these reports.
|
||||
|
||||
* Fix typos in documentation.
|
||||
181
docs/v2.3.5-ReleaseNotes
Normal file
181
docs/v2.3.5-ReleaseNotes
Normal file
@@ -0,0 +1,181 @@
|
||||
Cryptsetup 2.3.5 Release Notes
|
||||
==============================
|
||||
Stable bug-fix release with minor extensions.
|
||||
|
||||
All users of cryptsetup 2.x and later should upgrade to this version.
|
||||
|
||||
Changes since version 2.3.4
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Fix partial reads of passphrase from an interactive terminal.
|
||||
Some stable kernels (5.3.11) started to return buffer from a terminal
|
||||
in parts of maximal size 64 bytes.
|
||||
This breaks the reading of passphrases longer than 64 characters
|
||||
entered through an interactive terminal. The change is already fixed
|
||||
in later kernel releases, but tools now support such partial read from
|
||||
terminal properly.
|
||||
|
||||
* Fix maximal length of password entered through a terminal.
|
||||
Now the maximal interactive passphrase length is exactly
|
||||
512 characters (not 511).
|
||||
|
||||
* integritysetup: support new dm-integrity HMAC recalculation options.
|
||||
|
||||
In older kernels (since version 4.19), an attacker can force
|
||||
an automatic recalculation of integrity tags by modifying
|
||||
the dm-integrity superblock.
|
||||
This is a problem with a keyed algorithms (HMAC), where it expects
|
||||
nobody can trigger such recalculation without the key.
|
||||
(Automatic recalculation will start after the next activation.)
|
||||
|
||||
Note that dm-integrity in standalone mode was *not* supposed
|
||||
to provide cryptographic data integrity protection.
|
||||
Despite that, we try to keep the system secure if keyed algorithms
|
||||
are used.
|
||||
Thank Daniel Glöckner for the original report of this problem.
|
||||
|
||||
Authenticated encryption that provides data integrity protection (in
|
||||
combination with dm-crypt and LUKS2) is not affected by this problem.
|
||||
|
||||
The fix in the kernel for this problem contains two parts.
|
||||
|
||||
Firstly, the dm-integrity kernel module disables integrity
|
||||
recalculation if keyed algorithms (HMAC) are used.
|
||||
This change is included in long-term stable kernels.
|
||||
|
||||
Secondly, since the kernel version 5.11, dm-integrity introduces
|
||||
modified protection where a journal-integrity algorithm guards
|
||||
superblock; also, journal sections are protected. An attacker cannot
|
||||
copy sectors from one journal section to another, and the superblock
|
||||
also contains salt to prevent header replacement from another device.
|
||||
|
||||
If you want to protect data with HMAC, you should always also use HMAC
|
||||
for --journal-integrity. Keys can be independent.
|
||||
If HMAC is used for data but not for the journal, the recalculation
|
||||
option is disabled.
|
||||
|
||||
If you need to use (insecure) backward compatibility implementation,
|
||||
two new integritysetup options are introduced:
|
||||
- Use --integrity-legacy-recalc (instead of --integrity-recalc)
|
||||
to allow recalculation on legacy devices.
|
||||
- Use --integrity-legacy-hmac in format action to force old insecure
|
||||
HMAC format.
|
||||
|
||||
Libcryptsetup API also introduces flags
|
||||
CRYPT_COMPAT_LEGACY_INTEGRITY_HMAC and
|
||||
CRYPT_COMPAT_LEGACY_INTEGRITY_RECALC
|
||||
to set these through crypt_set_compatibility() call.
|
||||
|
||||
* integritysetup: display of recalculating sector in dump command.
|
||||
|
||||
* veritysetup: fix verity FEC if stored in the same image with hashes.
|
||||
|
||||
Optional FEC (Forward Error Correction) data should cover the whole
|
||||
data area, hashes (Merkle tree), and optionally additional metadata
|
||||
(located after hash area).
|
||||
|
||||
Unfortunately, if FEC data is stored in the same file as hash,
|
||||
the calculation wrongly used the whole file size, thus overlaps with
|
||||
the FEC area itself. This produced unusable and too large FEC data.
|
||||
There is no problem if the FEC image is a separate image.
|
||||
|
||||
The problem is now fixed, introducing FEC blocks calculation as:
|
||||
- If the hash device is in a separate image, metadata covers the
|
||||
whole rest of the image after the hash area. (Unchanged behavior.)
|
||||
- If hash and FEC device is in the image, metadata ends on the FEC
|
||||
area offset.
|
||||
|
||||
Note: there is also a fix for FEC in the dm-verity kernel (on the way
|
||||
to stable kernels) that fixes error correction with larger RS roots.
|
||||
|
||||
* veritysetup: run FEC repair check even if root hash fails.
|
||||
|
||||
Note: The userspace FEC verify command reports are only informational
|
||||
for now. Code does not check verity hash after FEC recovery in
|
||||
userspace. The Reed-Solomon decoder can then report the possibility
|
||||
that it fixed data even if parity is too damaged.
|
||||
This will be fixed in the next major release.
|
||||
|
||||
* veritysetup: do not process hash image if hash area is empty.
|
||||
|
||||
Sometimes the device is so small that there is only a root hash
|
||||
needed, and the hash area is not used.
|
||||
Also, the size of the hash image is not increased for hash block
|
||||
alignment in this case.
|
||||
|
||||
* veritysetup: store verity hash algorithm in superblock in lowercase.
|
||||
|
||||
Otherwise, the kernel could refuse the activation of the device.
|
||||
|
||||
* bitlk: fix a crash if the device disappears during BitLocker scan.
|
||||
|
||||
* bitlk: show a better error when trying to open an NTFS device.
|
||||
|
||||
Both BitLocker version 1 and NTFS have the same signature.
|
||||
If a user opens an NTFS device without BitLocker, it now correctly
|
||||
informs that it is not a BITLK device.
|
||||
|
||||
* bitlk: add support for startup key protected VMKs.
|
||||
|
||||
The startup key can be provided in --key-file option for open command.
|
||||
|
||||
* Fix LUKS1 repair code (regression since version 1.7.x).
|
||||
|
||||
We cannot trust possibly broken keyslots metadata in repair, so the
|
||||
code recalculates them instead.
|
||||
This makes the repair code working again when the master boot record
|
||||
signature overwrites the LUKS header.
|
||||
|
||||
* Fix luksKeyChange for LUKS2 with assigned tokens.
|
||||
|
||||
The token references are now correctly assigned to the new keyslot
|
||||
number.
|
||||
|
||||
* Fix cryptsetup resize using LUKS2 tokens.
|
||||
|
||||
Code needlessly asked for passphrase even though volume key was
|
||||
already unlocked via LUKS2 token.
|
||||
|
||||
* Print a visible error if device resize is not supported.
|
||||
|
||||
* Add error message when suspending wrong non-LUKS device.
|
||||
|
||||
* Fix default XTS mode key size in reencryption.
|
||||
|
||||
The same luksFormat logic (double key size because XTS uses two keys)
|
||||
is applied in the reencryption code.
|
||||
|
||||
* Rephrase missing locking directory warning and move it to debug level.
|
||||
|
||||
The system should later provide a safe transition to tempdir
|
||||
configuration, so creating locking directory inside libcryptsetup
|
||||
call is safe.
|
||||
|
||||
* Many fixes for the use of cipher_null (empty debug cipher).
|
||||
|
||||
Support for this empty cipher was intended as a debug feature and for
|
||||
measuring performance overhead. Unfortunately, many systems started to
|
||||
use it as an "empty shell" for LUKS (to enable encryption later).
|
||||
|
||||
This use is very dangerous and it creates a false sense of security.
|
||||
|
||||
Anyway, to not break such systems, we try to support these
|
||||
configurations.
|
||||
Using cipher_null in any production system is strongly discouraged!
|
||||
|
||||
Fixes include:
|
||||
- allow LUKS resume for a device with cipher_null.
|
||||
- do not upload key in keyring when data cipher is null.
|
||||
- switch to default cipher when reencrypting cipher_null device.
|
||||
- replace possible bogus cipher_null keyslots before reencryption.
|
||||
- fix broken detection of null cipher in LUKS2.
|
||||
cipher_null is no longer possible to be used in keyslot encryption
|
||||
in LUKS2, it can be used only for data for debugging purposes.
|
||||
|
||||
* Fixes for libpasswdqc 2.0.x (optional passphrase quality check).
|
||||
|
||||
* Fixes for problems discovered by various tools for code analysis.
|
||||
|
||||
Fixes include a rework of libpopt command line option string leaks.
|
||||
|
||||
* Various fixes to man pages.
|
||||
56
docs/v2.3.6-ReleaseNotes
Normal file
56
docs/v2.3.6-ReleaseNotes
Normal file
@@ -0,0 +1,56 @@
|
||||
Cryptsetup 2.3.6 Release Notes
|
||||
==============================
|
||||
Stable bug-fix release with minor extensions.
|
||||
|
||||
All users of cryptsetup 2.x and later should upgrade to this version.
|
||||
|
||||
Changes since version 2.3.5
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* integritysetup: Fix possible dm-integrity mapping table truncation.
|
||||
|
||||
While integritysetup in standalone mode (no encryption) was not
|
||||
designed to provide keyed (and cryptographically strong) data
|
||||
integrity protection, some options can use such algorithms (HMAC).
|
||||
|
||||
If a key is used, it is directly sent to the kernel dm-integrity as
|
||||
a mapping table option (no key derivation is performed).
|
||||
For HMAC, such a key could be quite long (up to 4096 bytes in
|
||||
integritysetup CLI).
|
||||
|
||||
Unfortunately, due to fixed buffers and not correctly checking string
|
||||
truncation, some parameter combinations could cause truncation
|
||||
of the dm-integrity mapping table.
|
||||
In most cases, the table was rejected by the kernel.
|
||||
The worst possible case was key truncation for HMAC options
|
||||
(internal_hash and journal_mac dm-integrity table options).
|
||||
|
||||
This release fixes possible truncation and also adds more sanity
|
||||
checks to reject truncated options.
|
||||
Also, integritysetup now mentions maximal allowed key size
|
||||
in --help output.
|
||||
|
||||
For old standalone dm-integrity devices where the key length was
|
||||
truncated, you have to modify (shorten) --integrity-key-size
|
||||
resp. --journal-integrity-key-size option now.
|
||||
|
||||
This bug is _not_ present for dm-crypt/LUKS, LUKS2 (including
|
||||
integrity protection), or dm-verity devices; it affects only
|
||||
standalone dm-integrity with HMAC integrity protection.
|
||||
|
||||
* cryptsetup: Backup header can be used to activate TCRYPT device.
|
||||
Use --header option to specify the header.
|
||||
|
||||
* cryptsetup: Avoid LUKS2 decryption without detached header.
|
||||
This feature will be added later and is currently not supported.
|
||||
|
||||
* Additional fixes and workarounds for common warnings produced
|
||||
by some static analysis tools (like gcc-11 analyzer) and additional
|
||||
code hardening.
|
||||
|
||||
* Fix standalone libintl detection for compiled tests.
|
||||
|
||||
* Add Blake2b and Blake2s hash support for crypto backends.
|
||||
Kernel and gcrypt crypto backend support all variants.
|
||||
OpenSSL supports only Blake2b-512 and Blake2s-256.
|
||||
Crypto backend supports kernel notation e.g. "blake2b-512".
|
||||
302
docs/v2.4.0-ReleaseNotes
Normal file
302
docs/v2.4.0-ReleaseNotes
Normal file
@@ -0,0 +1,302 @@
|
||||
Cryptsetup 2.4.0 Release Notes
|
||||
==============================
|
||||
Stable release with new features and bug fixes.
|
||||
|
||||
This version introduces support for external libraries
|
||||
(plugins) for handling LUKS2 token objects.
|
||||
|
||||
Changes since version 2.3.6
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* External LUKS token plugins
|
||||
|
||||
A LUKS2 token is an object that can describe how to get a passphrase
|
||||
to unlock a particular keyslot. The generic metadata format is part
|
||||
of the LUKS2 specification.
|
||||
|
||||
Cryptsetup 2.4 adds the possibility to implement token handlers
|
||||
in external libraries (possibly provided by other projects).
|
||||
|
||||
A token library allows cryptsetup to understand metadata and provide
|
||||
basic operations. Currently external tokens may be used to unlock
|
||||
keyslots for following CLI actions: open (luksOpen),
|
||||
refresh (open --refresh), resize and dump (prints token specific
|
||||
content).
|
||||
|
||||
LUKS2 devices cannot be resumed (luksResume action) via tokens yet.
|
||||
Support for resume and other actions will be added later.
|
||||
|
||||
The library now provides an interface that automatically tries to load
|
||||
an external library for a token object in LUKS2 metadata.
|
||||
|
||||
Token libraries should be installed in the cryptsetup subdirectory
|
||||
(usually /lib*/cryptsetup). This path is configurable through
|
||||
--with-luks2-external-tokens-path configure option.
|
||||
|
||||
The external plugin loading can be compiled entirely out if
|
||||
--disable-external-tokens configure option is used. The external token
|
||||
interface can also be disabled runtime on the command line by
|
||||
--disable-external-tokens cryptsetup switch or by calling
|
||||
crypt_token_external_disable() API function.
|
||||
|
||||
The name of the loaded token library is determined from the JSON LUKS
|
||||
metadata token object type. For example, "ssh" token will load library
|
||||
"libcryptsetup-token-ssh.so".
|
||||
|
||||
External projects can use this interface to handle specific hardware
|
||||
without introducing additional dependencies to libcryptsetup core.
|
||||
|
||||
As of cryptsetup 2.4.0 release systemd project already merged upstream
|
||||
native cryptsetup token handler for its systemd-tpm2 LUKS2 token
|
||||
released originally in systemd-v248. The token can be created using
|
||||
systemd-cryptenroll utility and devices may be manipulated either by
|
||||
systemd-cryptsetup cli or by cryptsetup for actions listed above.
|
||||
|
||||
Other tokens like systemd-fido2 and systemd-pkcs11 are currently
|
||||
in-review.
|
||||
|
||||
* Experimental SSH token
|
||||
|
||||
As a demonstration of the external LUKS2 token interface, a new SSH
|
||||
token handler and cryptsetup-ssh utility is now provided and compiled
|
||||
by default.
|
||||
|
||||
Crypsetup SSH token allows using remote keyfile through SSH protocol
|
||||
(it will authenticate through SSH certificates).
|
||||
|
||||
You can disable the build of this token library with
|
||||
--disable-ssh-token configure option.
|
||||
|
||||
To configure the token metadata, you need cryptsetup-ssh utility.
|
||||
|
||||
Activation of the device is then performed by the cryptsetup utility.
|
||||
|
||||
Example (how to activate LUKS2 through remote keyfile):
|
||||
|
||||
- configure existing LUKS2 device with keyslot activated by a keyfile
|
||||
# cryptsetup luksAddKey <device> keyfile --key-slot 2
|
||||
|
||||
- store that keyfile on a remote system accessible through SSH
|
||||
|
||||
- configure SSH to use certificate for authentication
|
||||
|
||||
- add a LUKS2 token with cryptsetup-ssh utility:
|
||||
# cryptsetup-ssh add <device>1 --key-slot 2 \
|
||||
--ssh-server test-vm \
|
||||
--ssh-user test \
|
||||
--ssh-path /home/test/keyfile \
|
||||
--ssh-keypath /home/test/.ssh/test_rsa_key
|
||||
|
||||
- you should see token metadata now with "cryptsetup luksDump ..."
|
||||
...
|
||||
Tokens:
|
||||
0: ssh
|
||||
ssh_server: test-vm
|
||||
ssh_user: test
|
||||
ssh_path: /home/test/keyfile
|
||||
ssh_key_path: /home/test/.ssh/test_rsa_key
|
||||
Keyslot: 2
|
||||
|
||||
|
||||
- activation now should be automatic
|
||||
# cryptsetup open <device> test --verbose
|
||||
SSH token initiating ssh session.
|
||||
Key slot 2 unlocked.
|
||||
Command successful.
|
||||
|
||||
- to remove a token, you can use "cryptsetup token remove" command
|
||||
(no plugin library required)
|
||||
|
||||
Please note SSH token is just demonstration of plugin interface API,
|
||||
it is an EXPERIMENTAL feature.
|
||||
|
||||
* Add cryptsetup --token-type parameter.
|
||||
|
||||
It restricts token type to the parameter value in case no specific
|
||||
token-id is selected.
|
||||
|
||||
* Support for token based activation with PIN.
|
||||
|
||||
If specific token requires PIN to unlock keyslot passphrase and
|
||||
--token-only parameter was used cryptsetup asks for additional
|
||||
token PIN.
|
||||
|
||||
* Respect keyslot priority with token-based activation.
|
||||
|
||||
* Default LUKS2 PBKDF is now Argon2id
|
||||
|
||||
Cryptsetup LUKS2 was using Argon2 while there were two versions,
|
||||
data-independent (Argon2i) suitable for the KDF use case and
|
||||
Argon2d (data-dependent). Later Argon2id was introduced as a new
|
||||
mandatory algorithm.
|
||||
|
||||
We switched the password-based key derivation algorithms
|
||||
following the latest version of Argon2 RFC draft
|
||||
(https://datatracker.ietf.org/doc/draft-irtf-cfrg-argon2/) to Argon2id
|
||||
(from Argon2i) as it is the mandatory and primary version
|
||||
of the Argon2 algorithm.
|
||||
|
||||
There is no need to modify older containers; the main reason is that
|
||||
RFC makes Argon2id the primary variant, while Argon2i subvariant is
|
||||
only optional.
|
||||
Argon2id provides better protection to side-channel attacks while
|
||||
still providing protection to time-memory tradeoffs.
|
||||
|
||||
We will switch to OpenSSL implementation once it is available.
|
||||
With a crystal ball as a reference, it could happen early in
|
||||
OpenSSL 3.1 release.
|
||||
Watch https://github.com/openssl/openssl/issues/4091.
|
||||
|
||||
* Increase minimal memory cost for Argon2 benchmark to 64MiB.
|
||||
|
||||
This patch increases the benchmarking value to 64 MiB (as minimal
|
||||
suggested values in Argon2 RFC). For compatibility reasons, we still
|
||||
allow older limits if set by a parameter.
|
||||
|
||||
NOTE: Argon2 RFC draft defines suggested parameters for disk
|
||||
encryption, but the LUKS2 approach is slightly different. We need to
|
||||
provide platform-independent values. The values in the draft expect
|
||||
64bit systems (suggesting using 6 GiB of RAM). In comparison, we need
|
||||
to provide compatibility with all 32bit systems, so allocating more
|
||||
than 4GiB memory is not an option for LUKS2.
|
||||
|
||||
The maximal limit in LUKS2 stays for 4 GiB, and by default LUKS2 PBKDF
|
||||
benchmarking sets maximum to 1 GIB, preferring an increase of CPU cost
|
||||
while running benchmark
|
||||
|
||||
* Autodetect optimal encryption sector size on LUKS2 format.
|
||||
|
||||
While the support for larger encryption sectors is supported
|
||||
for several releases, it required an additional parameter.
|
||||
|
||||
Code now uses automatic detection of 4096-bytes native sector devices
|
||||
and automatically enables 4096-bytes encryption size for LUKS2.
|
||||
|
||||
If no setor size option is used, sector size is detected
|
||||
automatically by cryptsetup. For libcryptsetup API, autodetection
|
||||
happens once you specify sector_size to 0.
|
||||
|
||||
NOTE: crypt_format() function runs autodetection ONLY if you
|
||||
recompile your application to the new API symbol version.
|
||||
For backward compatibility, older applications ignore this parameter.
|
||||
|
||||
* Use VeraCrypt option by default and add --disable-veracrypt option.
|
||||
|
||||
While TrueCrypt is no longer developed and supported since 2014,
|
||||
VeraCrypt devices (a successor of TrueCrypt) are much more used today.
|
||||
|
||||
Default is now to support VeraCrypt format (in addition to TrueCrypt),
|
||||
making the --veracrypt option obsolete (ignored as it is the default).
|
||||
|
||||
If you need to disable VeraCrypt support, use the new option
|
||||
--disable-veracrypt.
|
||||
|
||||
This option increases the time to recognize wrong passwords because
|
||||
some VeraCrypt modes use a high PBKDF2 iteration count, and the code
|
||||
must try all variants. This could be limited by using --hash and
|
||||
--cipher options mentioned below.
|
||||
|
||||
* Support --hash and --cipher to limit opening time for TCRYPT type
|
||||
|
||||
If a user knows which particular PBKDF2 hash or cipher is used for
|
||||
TrueCrypt/VeraCrypt container, TCRYPT format now supports --hash and
|
||||
--cipher option.
|
||||
|
||||
Note the value means substring (all cipher chains containing
|
||||
the cipher substring are tried).
|
||||
|
||||
For example, you can use
|
||||
# cryptsetup tcryptDump --hash sha512 <container>
|
||||
|
||||
Note: to speed up the scan, the hash option (used for PBKDF)2 matters.
|
||||
Cipher variants are scanned very quickly.
|
||||
|
||||
Use with care.
|
||||
It can reveal some sensitive attributes of the container!
|
||||
|
||||
* Fixed default OpenSSL crypt backend support for OpenSSL3.
|
||||
|
||||
For OpenSSL version 3, we need to load legacy provider for older hash
|
||||
and ciphers. For example, RIPEMD160 and Whirlpool hash algorithms are
|
||||
no longer available by default.
|
||||
|
||||
NOTE: the plain format still uses RIPEMD160 for password hashing by
|
||||
default. Changing the default would cause incompatibilities for many
|
||||
old systems. Nevertheless, such a change will be needed very soon.
|
||||
|
||||
* integritysetup: add integrity-recalculate-reset flag.
|
||||
|
||||
The new dm-integrity option in kernel 5.13 can restart recalculation
|
||||
from the beginning of the device.
|
||||
It can be used to change the integrity checksum function.
|
||||
|
||||
New integritysetup --integrity-recalculate-reset option is added to
|
||||
integritysetup, and CRYPT_ACTIVATE_RECALCULATE_RESET flag to API.
|
||||
|
||||
* cryptsetup: retains keyslot number in luksChangeKey for LUKS2.
|
||||
|
||||
In LUKS1, any change in keyslot means keyslot number change.
|
||||
|
||||
In LUKS2, we can retain the keyslot number.
|
||||
Now luksKeyChange and crypt_keyslot_change_by_passphrase() API
|
||||
retains keyslot number for LUKS2 by default.
|
||||
|
||||
* Fix cryptsetup resize using LUKS2 tokens.
|
||||
|
||||
Fix a bug where cryptsetup needlessly asked for a passphrase even
|
||||
though the volume key was already unlocked via LUKS2 token.
|
||||
|
||||
* Add close --deferred and --cancel-deferred options.
|
||||
|
||||
All command-line utilities now understand deferred options for the
|
||||
close command. Deferred close means that the device is removed
|
||||
automagically after the last user closed the device.
|
||||
Cancel deferred means to cancel this operation (so the device remains
|
||||
active even if there a no longer active users).
|
||||
|
||||
CRYPT_DEACTIVATE_DEFERRED and CRYPT_DEACTIVATE_DEFERRED_CANCEL flags
|
||||
are now available for API.
|
||||
|
||||
* Rewritten command-line option parsing to avoid libpopt arguments
|
||||
memory leaks.
|
||||
|
||||
Note: some distributions use patched lipopt that still leaks memory
|
||||
inside internal code (see Debian bug 941814).
|
||||
|
||||
* Add --test-args option.
|
||||
|
||||
New --test-args option can be used for syntax checking for valid
|
||||
command-line arguments with no actions performed.
|
||||
Note that it cannot detect unknown algorithm names and similar where
|
||||
we need call API functions.
|
||||
|
||||
* veritysetup: add --root-hash-file option
|
||||
Allow passing the root hash via a file, rather than verbatim on
|
||||
the command line, for the open, verify, and format actions.
|
||||
|
||||
* libcryptsetup C API extensions (see libcryptsetup.h for details)
|
||||
|
||||
- crypt_logf - a printf like log function
|
||||
- crypt_dump_json - dump LUKS2 metadata in JSON format
|
||||
- crypt_header_is_detached - check if context use detached header
|
||||
- crypt_token_max - get maximal tokens number
|
||||
- crypt_token_external_path - get path for plugins (or NULL)
|
||||
- crypt_token_external_disable - disable runtime support for plugins
|
||||
- crypt_activate_by_token_pin - activate by token with additional PIN
|
||||
- crypt_reencrypt_run - fixed API for deprecated crypt_reencrypt
|
||||
|
||||
The token plugin library interface cosists from these versioned
|
||||
exported symbols (for details see header file and SSH token example):
|
||||
cryptsetup_token_open
|
||||
cryptsetup_token_open_pin
|
||||
cryptsetup_token_buffer_free
|
||||
cryptsetup_token_validate
|
||||
cryptsetup_token_dump
|
||||
cryptsetup_token_version
|
||||
|
||||
Since version 2.4 libcryptsetup uses exact symbol versioning
|
||||
Newly introduced functions have CRYPTSETUP_2.4 namespace (the old
|
||||
symbol always used CRYPTSETUP_2.0).
|
||||
There is no change in soname (the library is backward compatible).
|
||||
|
||||
* Many fixes and additions to documentation and man pages.
|
||||
47
docs/v2.4.1-ReleaseNotes
Normal file
47
docs/v2.4.1-ReleaseNotes
Normal file
@@ -0,0 +1,47 @@
|
||||
Cryptsetup 2.4.1 Release Notes
|
||||
==============================
|
||||
Stable bug-fix release with minor extensions.
|
||||
|
||||
All users of cryptsetup 2.4.0 should upgrade to this version.
|
||||
|
||||
Changes since version 2.4.0
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Fix compilation for libc implementations without dlvsym().
|
||||
|
||||
Some alternative libc implementations (like musl) do not provide
|
||||
versioned symbols dlvsym function. Code now fallbacks to dlsym
|
||||
operation for dynamic LUKS2 token load.
|
||||
It is up to maintainers to ensure that LUKS2 token plugins are
|
||||
compiled for the supported version.
|
||||
|
||||
* Fix compilation and tests on systems with non-standard libraries
|
||||
(standalone argp library, external gettext library, BusyBox
|
||||
implementations of standard tools).
|
||||
|
||||
* Try to workaround some issues on systems without udev support.
|
||||
NOTE: non-udev systems cannot provide all functionality for kernel
|
||||
device-mapper, and some operations can fail.
|
||||
|
||||
* Fixes for OpenSSL3 crypto backend (including FIPS mode).
|
||||
Because cryptsetup still requires some hash functions implemented
|
||||
in OpenSSL3 legacy provider, crypto backend now uses its library
|
||||
context and tries to load both default and legacy OpenSSL3 providers.
|
||||
|
||||
If FIPS mode is detected, no library context is used, and it is up
|
||||
to the OpenSSL system-wide policy to load proper providers.
|
||||
|
||||
NOTE: We still use some deprecated API in the OpenSSL3 backend,
|
||||
and there are some known problems in OpenSSL 3.0.0.
|
||||
|
||||
* Print error message when assigning a token to an inactive keyslot.
|
||||
|
||||
* Fix offset bug in LUKS2 encryption code if --offset option was used.
|
||||
|
||||
* Do not allow LUKS2 decryption for devices with data offset.
|
||||
Such devices cannot be used after decryption.
|
||||
|
||||
* Fix LUKS1 cryptsetup repair command for some specific problems.
|
||||
Repair code can now fix wrongly used initialization vector
|
||||
specification in ECB mode (that is insecure anyway!) and repair
|
||||
the upper-case hash specification in the LUKS1 header.
|
||||
37
docs/v2.4.2-ReleaseNotes
Normal file
37
docs/v2.4.2-ReleaseNotes
Normal file
@@ -0,0 +1,37 @@
|
||||
Cryptsetup 2.4.2 Release Notes
|
||||
==============================
|
||||
Stable bug-fix release.
|
||||
|
||||
All users of cryptsetup 2.4.1 should upgrade to this version.
|
||||
|
||||
Changes since version 2.4.1
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Fix possible large memory allocation if LUKS2 header size is invalid.
|
||||
LUKS2 code read the full header to buffer to verify the checksum.
|
||||
The maximal supported header size now limits the memory allocation.
|
||||
|
||||
* Fix memory corruption in debug message printing LUKS2 checksum.
|
||||
|
||||
* veritysetup: remove link to the UUID library for the static build.
|
||||
|
||||
* Remove link to pwquality library for integritysetup and veritysetup.
|
||||
These tools do not read passphrases.
|
||||
|
||||
* OpenSSL3 backend: avoid remaining deprecated calls in API.
|
||||
Crypto backend no longer use API deprecated in OpenSSL 3.0
|
||||
|
||||
|
||||
* Check if kernel device-mapper create device failed in an early phase.
|
||||
This happens when a concurrent creation of device-mapper devices
|
||||
meets in the very early state.
|
||||
|
||||
* Do not set compiler optimization flag for Argon2 KDF if the memory
|
||||
wipe is implemented in libc.
|
||||
|
||||
* Do not attempt to unload LUKS2 tokens if external tokens are disabled.
|
||||
This allows building a static binary with --disable-external-tokens.
|
||||
|
||||
* LUKS convert: also check sysfs for device activity.
|
||||
If udev symlink is missing, code fallbacks to sysfs scan to prevent
|
||||
data corruption for the active device.
|
||||
101
docs/v2.4.3-ReleaseNotes
Normal file
101
docs/v2.4.3-ReleaseNotes
Normal file
@@ -0,0 +1,101 @@
|
||||
Cryptsetup 2.4.3 Release Notes
|
||||
==============================
|
||||
Stable security bug-fix release that fixes CVE-2021-4122.
|
||||
|
||||
All users of cryptsetup 2.4.x must upgrade to this version.
|
||||
|
||||
Changes since version 2.4.2
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Fix possible attacks against data confidentiality through LUKS2 online
|
||||
reencryption extension crash recovery (CVE-2021-4122).
|
||||
|
||||
An attacker can modify on-disk metadata to simulate decryption in
|
||||
progress with crashed (unfinished) reencryption step and persistently
|
||||
decrypt part of the LUKS device.
|
||||
|
||||
This attack requires repeated physical access to the LUKS device but
|
||||
no knowledge of user passphrases.
|
||||
|
||||
The decryption step is performed after a valid user activates
|
||||
the device with a correct passphrase and modified metadata.
|
||||
There are no visible warnings for the user that such recovery happened
|
||||
(except using the luksDump command). The attack can also be reversed
|
||||
afterward (simulating crashed encryption from a plaintext) with
|
||||
possible modification of revealed plaintext.
|
||||
|
||||
The size of possible decrypted data depends on configured LUKS2 header
|
||||
size (metadata size is configurable for LUKS2).
|
||||
With the default parameters (16 MiB LUKS2 header) and only one
|
||||
allocated keyslot (512 bit key for AES-XTS), simulated decryption with
|
||||
checksum resilience SHA1 (20 bytes checksum for 4096-byte blocks),
|
||||
the maximal decrypted size can be over 3GiB.
|
||||
|
||||
The attack is not applicable to LUKS1 format, but the attacker can
|
||||
update metadata in place to LUKS2 format as an additional step.
|
||||
For such a converted LUKS2 header, the keyslot area is limited to
|
||||
decrypted size (with SHA1 checksums) over 300 MiB.
|
||||
|
||||
The issue is present in all cryptsetup releases since 2.2.0.
|
||||
Versions 1.x, 2.0.x, and 2.1.x are not affected, as these do not
|
||||
contain LUKS2 reencryption extension.
|
||||
|
||||
The problem was caused by reusing a mechanism designed for actual
|
||||
reencryption operation without reassessing the security impact for new
|
||||
encryption and decryption operations. While the reencryption requires
|
||||
calculating and verifying both key digests, no digest was needed to
|
||||
initiate decryption recovery if the destination is plaintext (no
|
||||
encryption key). Also, some metadata (like encryption cipher) is not
|
||||
protected, and an attacker could change it. Note that LUKS2 protects
|
||||
visible metadata only when a random change occurs. It does not protect
|
||||
against intentional modification but such modification must not cause
|
||||
a violation of data confidentiality.
|
||||
|
||||
The fix introduces additional digest protection of reencryption
|
||||
metadata. The digest is calculated from known keys and critical
|
||||
reencryption metadata. Now an attacker cannot create correct metadata
|
||||
digest without knowledge of a passphrase for used keyslots.
|
||||
For more details, see LUKS2 On-Disk Format Specification version 1.1.0.
|
||||
|
||||
The former reencryption operation (without the additional digest) is no
|
||||
longer supported (reencryption with the digest is not backward
|
||||
compatible). You need to finish in-progress reencryption before
|
||||
updating to new packages. The alternative approach is to perform
|
||||
a repair command from the updated package to recalculate reencryption
|
||||
digest and fix metadata.
|
||||
The reencryption repair operation always require a user passphrase.
|
||||
|
||||
WARNING: Devices with older reencryption in progress can be no longer
|
||||
activated without performing the action mentioned above.
|
||||
|
||||
Encryption in progress can be detected by running the luksDump command
|
||||
(output includes reencrypt keyslot with reencryption parameters). Also,
|
||||
during the active reencryption, no keyslot operations are available
|
||||
(change of passphrases, etc.).
|
||||
|
||||
The issue was found by Milan Broz as cryptsetup maintainer.
|
||||
|
||||
Other changes
|
||||
~~~~~~~~~~~~~
|
||||
* Add configure option --disable-luks2-reencryption to completely disable
|
||||
LUKS2 reencryption code.
|
||||
|
||||
When used, the libcryptsetup library can read metadata with
|
||||
reencryption code, but all reencryption API calls and cryptsetup
|
||||
reencrypt commands are disabled.
|
||||
|
||||
Devices with online reencryption in progress cannot be activated.
|
||||
This option can cause some incompatibilities. Please use with care.
|
||||
|
||||
* Improve internal metadata validation code for reencryption metadata.
|
||||
|
||||
* Add updated documentation for LUKS2 On-Disk Format Specification
|
||||
version 1.1.0 (with reencryption extension description and updated
|
||||
metadata description). See docs/on-disk-format-luks2.pdf or online
|
||||
version in https://gitlab.com/cryptsetup/LUKS2-docs repository.
|
||||
|
||||
* Fix support for bitlk (BitLocker compatible) startup key with new
|
||||
metadata entry introduced in Windows 11.
|
||||
|
||||
* Fix space restriction for LUKS2 reencryption with data shift.
|
||||
The code required more space than was needed.
|
||||
281
docs/v2.5.0-rc1-ReleaseNotes
Normal file
281
docs/v2.5.0-rc1-ReleaseNotes
Normal file
@@ -0,0 +1,281 @@
|
||||
Cryptsetup 2.5.0-rc1 Release Notes
|
||||
==================================
|
||||
Stable release candidate with new features and bug fixes.
|
||||
|
||||
Changes since version 2.4.3
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Split manual pages into per-action pages and use AsciiDoc format.
|
||||
|
||||
Manual pages are now generated from AsciiDoc format, allowing easy
|
||||
conditional modifications for per-action options.
|
||||
|
||||
Generation of man pages requires the asciidoctor tool installed.
|
||||
|
||||
Pre-generated man pages are also included in the distribution tarball.
|
||||
You can use --disable-asciidoc configure option to skip man page
|
||||
generation completely. In this case, pre-generated man pages will be
|
||||
used for installation.
|
||||
|
||||
For cryptsetup, there is main man page (cryptsetup.8) that references
|
||||
separate man pages for each command (for example, cryptsetup-open.8).
|
||||
You can open such a man page by simply running "man cryptsetup open".
|
||||
Also, man pages for action aliases are available (cryptsetup-luksOpen.8
|
||||
is an alias for cryptsetup-open.8, etc.)
|
||||
|
||||
LUKS volume reencryption changes
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Remove cryptsetup-reencrypt tool from the project and move reencryption
|
||||
to already existing "cryptsetup reencrypt" command.
|
||||
|
||||
Cryptsetup reencrypt now handles both LUKS1 and LUKS2 reencryption,
|
||||
encryption, and decryption.
|
||||
|
||||
If you need to emulate the old cryptsetup-reencrypt binary, use simple
|
||||
wrappers script running "exec cryptsetup reencrypt $@".
|
||||
|
||||
All command line options should be compatible. An exception is the
|
||||
reencryption of LUKS2 volumes with old LUKS1 reencryption code that was
|
||||
replaced by native and more resilient LUKS2 reencryption.
|
||||
|
||||
* LUKS2: implement --decryption option that allows LUKS removal. The
|
||||
operation can run online or offline and supports the data shift option.
|
||||
|
||||
During the initialization, the LUKS2 header is exported to a file.
|
||||
The first data segment is moved to the head of the data device in place
|
||||
of the original header.
|
||||
|
||||
The feature internally introduces several new resilience modes
|
||||
(combination of existing modes datashift and "checksum" or "journal").
|
||||
Datashift resilience mode is applied for data moved towards the first
|
||||
segment, and the first segment is then decrypted in place.
|
||||
|
||||
This decryption mode is not backward compatible with prior LUKS2
|
||||
reencryption. Interrupted operations in progress cannot be resumed
|
||||
using older cryptsetup releases.
|
||||
|
||||
* Reencryption metadata options that are not compatible with recent code
|
||||
(features implemented in more recent releases) are now only read, but
|
||||
code will not activate or modify such metadata.
|
||||
Reencryption metadata contains a version that is validated when
|
||||
reencryption is resumed.
|
||||
For more info, see the updated LUKS2 on-disk format specification.
|
||||
|
||||
Safe operation of reencryption is to always finish the operation with
|
||||
only one version of the tools.
|
||||
|
||||
* Fix decryption operation with --active-name option and restrict
|
||||
it to be used only with LUKS2.
|
||||
|
||||
* Do not refresh reencryption digest when not needed.
|
||||
This should speed up the reencryption resume process.
|
||||
|
||||
* Store proper resilience data in LUKS2 reencrypt initialization.
|
||||
Resuming reencryption now does not require specification of resilience
|
||||
type parameters if these are the same as during initialization.
|
||||
|
||||
* Properly wipe the unused area after reencryption with datashift in
|
||||
the forward direction.
|
||||
|
||||
* Check datashift value against larger sector size.
|
||||
For example, it could cause an issue if misaligned 4K sector appears
|
||||
during decryption.
|
||||
|
||||
* Do not allow sector size increase reencryption in offline mode.
|
||||
The eventual logical block size increase on the dm-crypt device above
|
||||
may lead to an unusable filesystem. Do not allow offline reencryption
|
||||
when sector size increase is requested.
|
||||
|
||||
You can use --force-offline-reencrypt option to override this check
|
||||
(and potentially destroy the data).
|
||||
|
||||
* Do not allow dangerous sector size change during reencryption.
|
||||
By changing the encryption sector size during reencryption, a user
|
||||
may increase the effective logical block size for the dm-crypt active
|
||||
device.
|
||||
|
||||
Do not allow encryption sector size to be increased over the value
|
||||
provided by fs superblock in BLOCK_SIZE property.
|
||||
|
||||
* Ask the user for confirmation before resuming reencryption.
|
||||
The prompt is not shown in batch mode or when the user explicitly asks
|
||||
for a reencryption resume via --resume-only.
|
||||
|
||||
* Do not resume reencryption with conflicting parameters.
|
||||
For example, if the operation was initialized as --encrypt, do not
|
||||
allow resume with opposing parameter --decrypt and vice versa.
|
||||
Also, the code now checks for conflicting resilience parameters
|
||||
(datashift cannot be changed after initialization).
|
||||
|
||||
* Add --force-offline-reencrypt option.
|
||||
It can be used to enforce offline reencryption in batch mode when
|
||||
the device is a regular file; therefore, cryptsetup cannot detect
|
||||
properly active devices using it.
|
||||
Also, it may be useful to override the active device auto-detection
|
||||
for specific storage configurations (dangerous!).
|
||||
|
||||
* Do not allow nested encryption in LUKS reencrypt.
|
||||
Avoid accidental nested encryption via cryptsetup reencrypt --encrypt.
|
||||
|
||||
* Fix --test-passphrase when the device is in reencryption.
|
||||
|
||||
* Do not upload keys in keyring during offline reencryption.
|
||||
Reencryption runs in userspace, so the kernel does not need the key.
|
||||
|
||||
* Support all options allowed with luksFormat with encrypt action.
|
||||
|
||||
Other changes
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
* Add resize action to integritysetup.
|
||||
This allows resizing of standalone integrity devices.
|
||||
|
||||
* Support --device-size option (that allows unit specification) for plain
|
||||
devices (existing --size option requires 512-byte sectors units).
|
||||
|
||||
* Fix detection of encryption sector size if a detached header is used.
|
||||
|
||||
* Remove obsolete dracut plugin reencryption example.
|
||||
|
||||
* Fix possible keyslot area size overflow during conversion to LUKS2.
|
||||
If keyslots are not sorted according to binary area offset, the area
|
||||
size calculation was wrong and could overflow.
|
||||
|
||||
* Hardening and fixes to LUKS2 validation functions:
|
||||
|
||||
* Log a visible error if convert fails due to validation check.
|
||||
|
||||
* Check for interval (keyslot and segment area) overflow.
|
||||
|
||||
* Check cipher availability before LUKS conversion to LUKS2.
|
||||
Some historic incompatibilities are ignored for LUKS1 but do not
|
||||
work for LUKS2.
|
||||
|
||||
* Add empty string check to LUKS2 metadata JSON validation.
|
||||
Most of the LUKS2 fields cannot be empty.
|
||||
|
||||
* Fix JSON objects validation to check JSON object type properly.
|
||||
|
||||
* TCRYPT: Properly apply retry count and continue if some PBKDF variant
|
||||
is unavailable.
|
||||
|
||||
* BITLK: Add a warning when activating a device with the wrong size
|
||||
stored in metadata.
|
||||
|
||||
* BITLK: Add BitLocker volume size to dump command.
|
||||
|
||||
* BITLK: Fix possible UTF16 buffer overflow in volume key dump.
|
||||
|
||||
* BITLK: Skip question if the batch mode is set for volume key dump.
|
||||
|
||||
* BITLK: Check dm-zero availability in the kernel.
|
||||
Bitlocker compatible mode uses dm-zero to mask metadata area.
|
||||
The device cannot be activated if dm-zero is not available.
|
||||
|
||||
* Fix error message for LUKS2-only cryptsetup commands to explicitly
|
||||
state LUKS2 version is required.
|
||||
|
||||
* Fix error message for incompatible dm-integrity metadata.
|
||||
If the integritysetup tool is too old, kernel dm-integrity may use
|
||||
a more recent version of dm-integrity metadata.
|
||||
|
||||
* Properly deactivate the integrity device even if the LUKS2 header
|
||||
is no longer available.
|
||||
If LUKS2 is used with integrity protection, there is always
|
||||
a dm-integrity device underneath that must be deactivated.
|
||||
|
||||
* Allow use of --header option for cryptsetup close.
|
||||
This can be used to check that the activated device has the same UUID.
|
||||
|
||||
* Fix activation of LUKS2 device with integrity and detached header.
|
||||
The kernel-parsed dm-integrity superblock is always located on the
|
||||
data device, the incorrectly used detached header device here.
|
||||
|
||||
* Add ZEROOUT IOCTL support for crypt_wipe API call.
|
||||
For block devices, we can use optimized in-kernel BLKZEROOUT ioctl.
|
||||
|
||||
* VERITY: set loopback sector size according to dm-verity block sizes.
|
||||
Verity block size has the same limits, so we can optimize the loop
|
||||
device to increase performance.
|
||||
|
||||
* Other Documentation and man page improvements:
|
||||
|
||||
* Update LUKS2 on-disk format description.
|
||||
|
||||
* Add per-keyslot LUKS2 options to the man page.
|
||||
Some options were missing for LUKS2 luksAddKey and luksChangeKey.
|
||||
|
||||
* Fix cryptsetup manpage to use PBKDF consistently.
|
||||
|
||||
* Add compile info to README. This information was lost when we removed
|
||||
the default automake INSTALL file.
|
||||
|
||||
* Use volume key consistently in FAQ and man pages.
|
||||
|
||||
* Use markdown version of FAQ directly for installation.
|
||||
|
||||
* Clarify graceful reencryption interruption.
|
||||
Currently, it can be interrupted by both SIGINT and SIGTERM signals.
|
||||
|
||||
* Add new mailing list info.
|
||||
|
||||
* Mention non-cryptographic xxhash64 hash for integrity protection.
|
||||
|
||||
* veritysetup: dump device sizes.
|
||||
Calculating device sizes for verity devices is a little bit tricky.
|
||||
Data, hash, and FEC can share devices or be separate devices.
|
||||
Now dump command prints used device sizes, but it requires that
|
||||
the user specifies all values that are not stored in superblock
|
||||
(like FEC device and FEC roots).
|
||||
|
||||
* Fix check for argp_usage in configure if argp-standalone lib is used.
|
||||
|
||||
* Add constant time memcmp and hexa print implementation and use it for
|
||||
cryptographic keys handling.
|
||||
|
||||
* Display progress when wiping the end of the resized device.
|
||||
|
||||
* LUKS2 token: prefer token PIN query before passphrase in some cases.
|
||||
When a user provides --token-type or specific --token-id, a token PIN
|
||||
query is preferred to a passphrase query.
|
||||
|
||||
* LUKS2 token: allow tokens to be replaced with --token-replace option
|
||||
for cryptsetup token command.
|
||||
|
||||
* LUKS2 token: do not continue operation when interrupted in PIN prompt.
|
||||
|
||||
* Add --progress-json parameter to utilities.
|
||||
Progress data can now be printed out in JSON format suitable for
|
||||
machine processing.
|
||||
|
||||
* Embedded Argon2 PBKDF: optimize and simplify thread exit.
|
||||
|
||||
* Avoid using SHA1 in tests and fix new enforcements introduced in FIPS
|
||||
provider for OpenSSL3 (like minimal parameters for PBKDF2).
|
||||
|
||||
* Use custom UTF conversion and avoid linking to iconv as a dependency.
|
||||
|
||||
* Reimplement BASE64 with simplified code instead of coreutils version.
|
||||
|
||||
Libcryptsetup API extensions and changes
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Properly define uint32_t constants in API.
|
||||
This is not a real change, but it avoids strict compiler warnings.
|
||||
|
||||
* crypt_resume_by_token_pin() - Resume crypt device using LUKS2 token.
|
||||
|
||||
* crypt_get_label() - Get the label of the LUKS2 device.
|
||||
|
||||
* crypt_get_subsystem() - Get the subsystem label of the LUKS2 device.
|
||||
|
||||
* Make CRYPT_WIPE_ENCRYPTED_ZERO crypt_wipe() option obsolete.
|
||||
It was never implemented (the idea was to speed up wipe), but with
|
||||
the recent RNG performance changes, it makes no longer sense.
|
||||
|
||||
* Add struct crypt_params_reencrypt changes related to decryption.
|
||||
|
||||
* Improve crypt_reencrypt_status() return values.
|
||||
Empty or any non-LUKS types now returns CRYPT_REENCRYPT_INVALID status.
|
||||
For LUKS1 devices, it returns CRYPT_REENCRYPT_NONE.
|
||||
@@ -1,11 +1,11 @@
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = lib/libcryptsetup.pc
|
||||
pkgconfig_DATA += lib/libcryptsetup.pc
|
||||
|
||||
lib_LTLIBRARIES = libcryptsetup.la
|
||||
lib_LTLIBRARIES += libcryptsetup.la
|
||||
|
||||
noinst_LTLIBRARIES += libutils_io.la
|
||||
|
||||
include_HEADERS = lib/libcryptsetup.h
|
||||
include_HEADERS += lib/libcryptsetup.h
|
||||
|
||||
EXTRA_DIST += lib/libcryptsetup.pc.in lib/libcryptsetup.sym
|
||||
|
||||
@@ -15,15 +15,7 @@ libutils_io_la_SOURCES = \
|
||||
lib/utils_io.c \
|
||||
lib/utils_io.h
|
||||
|
||||
libcryptsetup_la_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||
-I $(top_srcdir)/lib/crypto_backend \
|
||||
-I $(top_srcdir)/lib/luks1 \
|
||||
-I $(top_srcdir)/lib/luks2 \
|
||||
-I $(top_srcdir)/lib/loopaes \
|
||||
-I $(top_srcdir)/lib/verity \
|
||||
-I $(top_srcdir)/lib/tcrypt \
|
||||
-I $(top_srcdir)/lib/integrity \
|
||||
-I $(top_srcdir)/lib/bitlk
|
||||
libcryptsetup_la_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
libcryptsetup_la_DEPENDENCIES = libutils_io.la libcrypto_backend.la lib/libcryptsetup.sym
|
||||
|
||||
@@ -40,7 +32,8 @@ libcryptsetup_la_LIBADD = \
|
||||
@LIBARGON2_LIBS@ \
|
||||
@JSON_C_LIBS@ \
|
||||
@BLKID_LIBS@ \
|
||||
$(LTLIBICONV) \
|
||||
@DL_LIBS@ \
|
||||
$(LTLIBINTL) \
|
||||
libcrypto_backend.la \
|
||||
libutils_io.la
|
||||
|
||||
@@ -50,6 +43,8 @@ libcryptsetup_la_SOURCES = \
|
||||
lib/bitops.h \
|
||||
lib/nls.h \
|
||||
lib/libcryptsetup.h \
|
||||
lib/libcryptsetup_macros.h \
|
||||
lib/libcryptsetup_symver.h \
|
||||
lib/utils.c \
|
||||
lib/utils_benchmark.c \
|
||||
lib/utils_crypt.c \
|
||||
@@ -74,8 +69,6 @@ libcryptsetup_la_SOURCES = \
|
||||
lib/volumekey.c \
|
||||
lib/random.c \
|
||||
lib/crypt_plain.c \
|
||||
lib/base64.h \
|
||||
lib/base64.c \
|
||||
lib/integrity/integrity.h \
|
||||
lib/integrity/integrity.c \
|
||||
lib/loopaes/loopaes.h \
|
||||
@@ -104,6 +97,7 @@ libcryptsetup_la_SOURCES = \
|
||||
lib/luks2/luks2_keyslot_luks2.c \
|
||||
lib/luks2/luks2_keyslot_reenc.c \
|
||||
lib/luks2/luks2_reencrypt.c \
|
||||
lib/luks2/luks2_reencrypt_digest.c \
|
||||
lib/luks2/luks2_segment.c \
|
||||
lib/luks2/luks2_token_keyring.c \
|
||||
lib/luks2/luks2_token.c \
|
||||
|
||||
605
lib/base64.c
605
lib/base64.c
@@ -1,605 +0,0 @@
|
||||
/* base64.c -- Encode binary data using printable characters.
|
||||
Copyright (C) 1999-2001, 2004-2006, 2009-2019 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Simon Josefsson. Partially adapted from GNU MailUtils
|
||||
* (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
|
||||
* from Paul Eggert, Bruno Haible, and Stepan Kasal.
|
||||
*
|
||||
* See also RFC 4648 <https://www.ietf.org/rfc/rfc4648.txt>.
|
||||
*
|
||||
* Be careful with error checking. Here is how you would typically
|
||||
* use these functions:
|
||||
*
|
||||
* bool ok = base64_decode_alloc (in, inlen, &out, &outlen);
|
||||
* if (!ok)
|
||||
* FAIL: input was not valid base64
|
||||
* if (out == NULL)
|
||||
* FAIL: memory allocation error
|
||||
* OK: data in OUT/OUTLEN
|
||||
*
|
||||
* size_t outlen = base64_encode_alloc (in, inlen, &out);
|
||||
* if (out == NULL && outlen == 0 && inlen != 0)
|
||||
* FAIL: input too long
|
||||
* if (out == NULL)
|
||||
* FAIL: memory allocation error
|
||||
* OK: data in OUT/OUTLEN.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Get prototype. */
|
||||
#include "base64.h"
|
||||
|
||||
/* Get malloc. */
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Get UCHAR_MAX. */
|
||||
#include <limits.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* C89 compliant way to cast 'char' to 'unsigned char'. */
|
||||
static unsigned char
|
||||
to_uchar (char ch)
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
|
||||
static const char b64c[64] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
/* Base64 encode IN array of size INLEN into OUT array. OUT needs
|
||||
to be of length >= BASE64_LENGTH(INLEN), and INLEN needs to be
|
||||
a multiple of 3. */
|
||||
static void
|
||||
base64_encode_fast (const char *restrict in, size_t inlen, char *restrict out)
|
||||
{
|
||||
while (inlen)
|
||||
{
|
||||
*out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f];
|
||||
*out++ = b64c[((to_uchar (in[0]) << 4) + (to_uchar (in[1]) >> 4)) & 0x3f];
|
||||
*out++ = b64c[((to_uchar (in[1]) << 2) + (to_uchar (in[2]) >> 6)) & 0x3f];
|
||||
*out++ = b64c[to_uchar (in[2]) & 0x3f];
|
||||
|
||||
inlen -= 3;
|
||||
in += 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN.
|
||||
If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as
|
||||
possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero
|
||||
terminate the output buffer. */
|
||||
void
|
||||
base64_encode (const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t outlen)
|
||||
{
|
||||
/* Note this outlen constraint can be enforced at compile time.
|
||||
I.E. that the output buffer is exactly large enough to hold
|
||||
the encoded inlen bytes. The inlen constraints (of corresponding
|
||||
to outlen, and being a multiple of 3) can change at runtime
|
||||
at the end of input. However the common case when reading
|
||||
large inputs is to have both constraints satisfied, so we depend
|
||||
on both in base_encode_fast(). */
|
||||
if (outlen % 4 == 0 && inlen == outlen / 4 * 3)
|
||||
{
|
||||
base64_encode_fast (in, inlen, out);
|
||||
return;
|
||||
}
|
||||
|
||||
while (inlen && outlen)
|
||||
{
|
||||
*out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f];
|
||||
if (!--outlen)
|
||||
break;
|
||||
*out++ = b64c[((to_uchar (in[0]) << 4)
|
||||
+ (--inlen ? to_uchar (in[1]) >> 4 : 0))
|
||||
& 0x3f];
|
||||
if (!--outlen)
|
||||
break;
|
||||
*out++ =
|
||||
(inlen
|
||||
? b64c[((to_uchar (in[1]) << 2)
|
||||
+ (--inlen ? to_uchar (in[2]) >> 6 : 0))
|
||||
& 0x3f]
|
||||
: '=');
|
||||
if (!--outlen)
|
||||
break;
|
||||
*out++ = inlen ? b64c[to_uchar (in[2]) & 0x3f] : '=';
|
||||
if (!--outlen)
|
||||
break;
|
||||
if (inlen)
|
||||
inlen--;
|
||||
if (inlen)
|
||||
in += 3;
|
||||
}
|
||||
|
||||
if (outlen)
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
/* Allocate a buffer and store zero terminated base64 encoded data
|
||||
from array IN of size INLEN, returning BASE64_LENGTH(INLEN), i.e.,
|
||||
the length of the encoded data, excluding the terminating zero. On
|
||||
return, the OUT variable will hold a pointer to newly allocated
|
||||
memory that must be deallocated by the caller. If output string
|
||||
length would overflow, 0 is returned and OUT is set to NULL. If
|
||||
memory allocation failed, OUT is set to NULL, and the return value
|
||||
indicates length of the requested memory block, i.e.,
|
||||
BASE64_LENGTH(inlen) + 1. */
|
||||
size_t
|
||||
base64_encode_alloc (const char *in, size_t inlen, char **out)
|
||||
{
|
||||
size_t outlen = 1 + BASE64_LENGTH (inlen);
|
||||
|
||||
/* Check for overflow in outlen computation.
|
||||
*
|
||||
* If there is no overflow, outlen >= inlen.
|
||||
*
|
||||
* If the operation (inlen + 2) overflows then it yields at most +1, so
|
||||
* outlen is 0.
|
||||
*
|
||||
* If the multiplication overflows, we lose at least half of the
|
||||
* correct value, so the result is < ((inlen + 2) / 3) * 2, which is
|
||||
* less than (inlen + 2) * 0.66667, which is less than inlen as soon as
|
||||
* (inlen > 4).
|
||||
*/
|
||||
if (inlen > outlen)
|
||||
{
|
||||
*out = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*out = malloc (outlen);
|
||||
if (!*out)
|
||||
return outlen;
|
||||
|
||||
base64_encode (in, inlen, *out, outlen);
|
||||
|
||||
return outlen - 1;
|
||||
}
|
||||
|
||||
/* With this approach this file works independent of the charset used
|
||||
(think EBCDIC). However, it does assume that the characters in the
|
||||
Base64 alphabet (A-Za-z0-9+/) are encoded in 0..255. POSIX
|
||||
1003.1-2001 require that char and unsigned char are 8-bit
|
||||
quantities, though, taking care of that problem. But this may be a
|
||||
potential problem on non-POSIX C99 platforms.
|
||||
|
||||
IBM C V6 for AIX mishandles "#define B64(x) ...'x'...", so use "_"
|
||||
as the formal parameter rather than "x". */
|
||||
#define B64(_) \
|
||||
((_) == 'A' ? 0 \
|
||||
: (_) == 'B' ? 1 \
|
||||
: (_) == 'C' ? 2 \
|
||||
: (_) == 'D' ? 3 \
|
||||
: (_) == 'E' ? 4 \
|
||||
: (_) == 'F' ? 5 \
|
||||
: (_) == 'G' ? 6 \
|
||||
: (_) == 'H' ? 7 \
|
||||
: (_) == 'I' ? 8 \
|
||||
: (_) == 'J' ? 9 \
|
||||
: (_) == 'K' ? 10 \
|
||||
: (_) == 'L' ? 11 \
|
||||
: (_) == 'M' ? 12 \
|
||||
: (_) == 'N' ? 13 \
|
||||
: (_) == 'O' ? 14 \
|
||||
: (_) == 'P' ? 15 \
|
||||
: (_) == 'Q' ? 16 \
|
||||
: (_) == 'R' ? 17 \
|
||||
: (_) == 'S' ? 18 \
|
||||
: (_) == 'T' ? 19 \
|
||||
: (_) == 'U' ? 20 \
|
||||
: (_) == 'V' ? 21 \
|
||||
: (_) == 'W' ? 22 \
|
||||
: (_) == 'X' ? 23 \
|
||||
: (_) == 'Y' ? 24 \
|
||||
: (_) == 'Z' ? 25 \
|
||||
: (_) == 'a' ? 26 \
|
||||
: (_) == 'b' ? 27 \
|
||||
: (_) == 'c' ? 28 \
|
||||
: (_) == 'd' ? 29 \
|
||||
: (_) == 'e' ? 30 \
|
||||
: (_) == 'f' ? 31 \
|
||||
: (_) == 'g' ? 32 \
|
||||
: (_) == 'h' ? 33 \
|
||||
: (_) == 'i' ? 34 \
|
||||
: (_) == 'j' ? 35 \
|
||||
: (_) == 'k' ? 36 \
|
||||
: (_) == 'l' ? 37 \
|
||||
: (_) == 'm' ? 38 \
|
||||
: (_) == 'n' ? 39 \
|
||||
: (_) == 'o' ? 40 \
|
||||
: (_) == 'p' ? 41 \
|
||||
: (_) == 'q' ? 42 \
|
||||
: (_) == 'r' ? 43 \
|
||||
: (_) == 's' ? 44 \
|
||||
: (_) == 't' ? 45 \
|
||||
: (_) == 'u' ? 46 \
|
||||
: (_) == 'v' ? 47 \
|
||||
: (_) == 'w' ? 48 \
|
||||
: (_) == 'x' ? 49 \
|
||||
: (_) == 'y' ? 50 \
|
||||
: (_) == 'z' ? 51 \
|
||||
: (_) == '0' ? 52 \
|
||||
: (_) == '1' ? 53 \
|
||||
: (_) == '2' ? 54 \
|
||||
: (_) == '3' ? 55 \
|
||||
: (_) == '4' ? 56 \
|
||||
: (_) == '5' ? 57 \
|
||||
: (_) == '6' ? 58 \
|
||||
: (_) == '7' ? 59 \
|
||||
: (_) == '8' ? 60 \
|
||||
: (_) == '9' ? 61 \
|
||||
: (_) == '+' ? 62 \
|
||||
: (_) == '/' ? 63 \
|
||||
: -1)
|
||||
|
||||
static const signed char b64[0x100] = {
|
||||
B64 (0), B64 (1), B64 (2), B64 (3),
|
||||
B64 (4), B64 (5), B64 (6), B64 (7),
|
||||
B64 (8), B64 (9), B64 (10), B64 (11),
|
||||
B64 (12), B64 (13), B64 (14), B64 (15),
|
||||
B64 (16), B64 (17), B64 (18), B64 (19),
|
||||
B64 (20), B64 (21), B64 (22), B64 (23),
|
||||
B64 (24), B64 (25), B64 (26), B64 (27),
|
||||
B64 (28), B64 (29), B64 (30), B64 (31),
|
||||
B64 (32), B64 (33), B64 (34), B64 (35),
|
||||
B64 (36), B64 (37), B64 (38), B64 (39),
|
||||
B64 (40), B64 (41), B64 (42), B64 (43),
|
||||
B64 (44), B64 (45), B64 (46), B64 (47),
|
||||
B64 (48), B64 (49), B64 (50), B64 (51),
|
||||
B64 (52), B64 (53), B64 (54), B64 (55),
|
||||
B64 (56), B64 (57), B64 (58), B64 (59),
|
||||
B64 (60), B64 (61), B64 (62), B64 (63),
|
||||
B64 (64), B64 (65), B64 (66), B64 (67),
|
||||
B64 (68), B64 (69), B64 (70), B64 (71),
|
||||
B64 (72), B64 (73), B64 (74), B64 (75),
|
||||
B64 (76), B64 (77), B64 (78), B64 (79),
|
||||
B64 (80), B64 (81), B64 (82), B64 (83),
|
||||
B64 (84), B64 (85), B64 (86), B64 (87),
|
||||
B64 (88), B64 (89), B64 (90), B64 (91),
|
||||
B64 (92), B64 (93), B64 (94), B64 (95),
|
||||
B64 (96), B64 (97), B64 (98), B64 (99),
|
||||
B64 (100), B64 (101), B64 (102), B64 (103),
|
||||
B64 (104), B64 (105), B64 (106), B64 (107),
|
||||
B64 (108), B64 (109), B64 (110), B64 (111),
|
||||
B64 (112), B64 (113), B64 (114), B64 (115),
|
||||
B64 (116), B64 (117), B64 (118), B64 (119),
|
||||
B64 (120), B64 (121), B64 (122), B64 (123),
|
||||
B64 (124), B64 (125), B64 (126), B64 (127),
|
||||
B64 (128), B64 (129), B64 (130), B64 (131),
|
||||
B64 (132), B64 (133), B64 (134), B64 (135),
|
||||
B64 (136), B64 (137), B64 (138), B64 (139),
|
||||
B64 (140), B64 (141), B64 (142), B64 (143),
|
||||
B64 (144), B64 (145), B64 (146), B64 (147),
|
||||
B64 (148), B64 (149), B64 (150), B64 (151),
|
||||
B64 (152), B64 (153), B64 (154), B64 (155),
|
||||
B64 (156), B64 (157), B64 (158), B64 (159),
|
||||
B64 (160), B64 (161), B64 (162), B64 (163),
|
||||
B64 (164), B64 (165), B64 (166), B64 (167),
|
||||
B64 (168), B64 (169), B64 (170), B64 (171),
|
||||
B64 (172), B64 (173), B64 (174), B64 (175),
|
||||
B64 (176), B64 (177), B64 (178), B64 (179),
|
||||
B64 (180), B64 (181), B64 (182), B64 (183),
|
||||
B64 (184), B64 (185), B64 (186), B64 (187),
|
||||
B64 (188), B64 (189), B64 (190), B64 (191),
|
||||
B64 (192), B64 (193), B64 (194), B64 (195),
|
||||
B64 (196), B64 (197), B64 (198), B64 (199),
|
||||
B64 (200), B64 (201), B64 (202), B64 (203),
|
||||
B64 (204), B64 (205), B64 (206), B64 (207),
|
||||
B64 (208), B64 (209), B64 (210), B64 (211),
|
||||
B64 (212), B64 (213), B64 (214), B64 (215),
|
||||
B64 (216), B64 (217), B64 (218), B64 (219),
|
||||
B64 (220), B64 (221), B64 (222), B64 (223),
|
||||
B64 (224), B64 (225), B64 (226), B64 (227),
|
||||
B64 (228), B64 (229), B64 (230), B64 (231),
|
||||
B64 (232), B64 (233), B64 (234), B64 (235),
|
||||
B64 (236), B64 (237), B64 (238), B64 (239),
|
||||
B64 (240), B64 (241), B64 (242), B64 (243),
|
||||
B64 (244), B64 (245), B64 (246), B64 (247),
|
||||
B64 (248), B64 (249), B64 (250), B64 (251),
|
||||
B64 (252), B64 (253), B64 (254), B64 (255)
|
||||
};
|
||||
|
||||
#if UCHAR_MAX == 255
|
||||
# define uchar_in_range(c) true
|
||||
#else
|
||||
# define uchar_in_range(c) ((c) <= 255)
|
||||
#endif
|
||||
|
||||
/* Return true if CH is a character from the Base64 alphabet, and
|
||||
false otherwise. Note that '=' is padding and not considered to be
|
||||
part of the alphabet. */
|
||||
bool
|
||||
isbase64 (char ch)
|
||||
{
|
||||
return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)];
|
||||
}
|
||||
|
||||
/* Initialize decode-context buffer, CTX. */
|
||||
void
|
||||
base64_decode_ctx_init (struct base64_decode_context *ctx)
|
||||
{
|
||||
ctx->i = 0;
|
||||
}
|
||||
|
||||
/* If CTX->i is 0 or 4, there are four or more bytes in [*IN..IN_END), and
|
||||
none of those four is a newline, then return *IN. Otherwise, copy up to
|
||||
4 - CTX->i non-newline bytes from that range into CTX->buf, starting at
|
||||
index CTX->i and setting CTX->i to reflect the number of bytes copied,
|
||||
and return CTX->buf. In either case, advance *IN to point to the byte
|
||||
after the last one processed, and set *N_NON_NEWLINE to the number of
|
||||
verified non-newline bytes accessible through the returned pointer. */
|
||||
static const char *
|
||||
get_4 (struct base64_decode_context *ctx,
|
||||
char const *restrict *in, char const *restrict in_end,
|
||||
size_t *n_non_newline)
|
||||
{
|
||||
if (ctx->i == 4)
|
||||
ctx->i = 0;
|
||||
|
||||
if (ctx->i == 0)
|
||||
{
|
||||
char const *t = *in;
|
||||
if (4 <= in_end - *in && memchr (t, '\n', 4) == NULL)
|
||||
{
|
||||
/* This is the common case: no newline. */
|
||||
*in += 4;
|
||||
*n_non_newline = 4;
|
||||
return (const char *) t;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* Copy non-newline bytes into BUF. */
|
||||
char const *p = *in;
|
||||
while (p < in_end)
|
||||
{
|
||||
char c = *p++;
|
||||
if (c != '\n')
|
||||
{
|
||||
ctx->buf[ctx->i++] = c;
|
||||
if (ctx->i == 4)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*in = p;
|
||||
*n_non_newline = ctx->i;
|
||||
return ctx->buf;
|
||||
}
|
||||
}
|
||||
|
||||
#define return_false \
|
||||
do \
|
||||
{ \
|
||||
*outp = out; \
|
||||
return false; \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
/* Decode up to four bytes of base64-encoded data, IN, of length INLEN
|
||||
into the output buffer, *OUT, of size *OUTLEN bytes. Return true if
|
||||
decoding is successful, false otherwise. If *OUTLEN is too small,
|
||||
as many bytes as possible are written to *OUT. On return, advance
|
||||
*OUT to point to the byte after the last one written, and decrement
|
||||
*OUTLEN to reflect the number of bytes remaining in *OUT. */
|
||||
static bool
|
||||
decode_4 (char const *restrict in, size_t inlen,
|
||||
char *restrict *outp, size_t *outleft)
|
||||
{
|
||||
char *out = *outp;
|
||||
if (inlen < 2)
|
||||
return false;
|
||||
|
||||
if (!isbase64 (in[0]) || !isbase64 (in[1]))
|
||||
return false;
|
||||
|
||||
if (*outleft)
|
||||
{
|
||||
*out++ = ((b64[to_uchar (in[0])] << 2)
|
||||
| (b64[to_uchar (in[1])] >> 4));
|
||||
--*outleft;
|
||||
}
|
||||
|
||||
if (inlen == 2)
|
||||
return_false;
|
||||
|
||||
if (in[2] == '=')
|
||||
{
|
||||
if (inlen != 4)
|
||||
return_false;
|
||||
|
||||
if (in[3] != '=')
|
||||
return_false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isbase64 (in[2]))
|
||||
return_false;
|
||||
|
||||
if (*outleft)
|
||||
{
|
||||
*out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0)
|
||||
| (b64[to_uchar (in[2])] >> 2));
|
||||
--*outleft;
|
||||
}
|
||||
|
||||
if (inlen == 3)
|
||||
return_false;
|
||||
|
||||
if (in[3] == '=')
|
||||
{
|
||||
if (inlen != 4)
|
||||
return_false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isbase64 (in[3]))
|
||||
return_false;
|
||||
|
||||
if (*outleft)
|
||||
{
|
||||
*out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0)
|
||||
| b64[to_uchar (in[3])]);
|
||||
--*outleft;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*outp = out;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Decode base64-encoded input array IN of length INLEN to output array
|
||||
OUT that can hold *OUTLEN bytes. The input data may be interspersed
|
||||
with newlines. Return true if decoding was successful, i.e. if the
|
||||
input was valid base64 data, false otherwise. If *OUTLEN is too
|
||||
small, as many bytes as possible will be written to OUT. On return,
|
||||
*OUTLEN holds the length of decoded bytes in OUT. Note that as soon
|
||||
as any non-alphabet, non-newline character is encountered, decoding
|
||||
is stopped and false is returned. If INLEN is zero, then process
|
||||
only whatever data is stored in CTX.
|
||||
|
||||
Initially, CTX must have been initialized via base64_decode_ctx_init.
|
||||
Subsequent calls to this function must reuse whatever state is recorded
|
||||
in that buffer. It is necessary for when a quadruple of base64 input
|
||||
bytes spans two input buffers.
|
||||
|
||||
If CTX is NULL then newlines are treated as garbage and the input
|
||||
buffer is processed as a unit. */
|
||||
|
||||
bool
|
||||
base64_decode_ctx (struct base64_decode_context *ctx,
|
||||
const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t *outlen)
|
||||
{
|
||||
size_t outleft = *outlen;
|
||||
bool ignore_newlines = ctx != NULL;
|
||||
bool flush_ctx = false;
|
||||
unsigned int ctx_i = 0;
|
||||
|
||||
if (ignore_newlines)
|
||||
{
|
||||
ctx_i = ctx->i;
|
||||
flush_ctx = inlen == 0;
|
||||
}
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
size_t outleft_save = outleft;
|
||||
if (ctx_i == 0 && !flush_ctx)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
/* Save a copy of outleft, in case we need to re-parse this
|
||||
block of four bytes. */
|
||||
outleft_save = outleft;
|
||||
if (!decode_4 (in, inlen, &out, &outleft))
|
||||
break;
|
||||
|
||||
in += 4;
|
||||
inlen -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (inlen == 0 && !flush_ctx)
|
||||
break;
|
||||
|
||||
/* Handle the common case of 72-byte wrapped lines.
|
||||
This also handles any other multiple-of-4-byte wrapping. */
|
||||
if (inlen && *in == '\n' && ignore_newlines)
|
||||
{
|
||||
++in;
|
||||
--inlen;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Restore OUT and OUTLEFT. */
|
||||
out -= outleft_save - outleft;
|
||||
outleft = outleft_save;
|
||||
|
||||
{
|
||||
char const *in_end = in + inlen;
|
||||
char const *non_nl;
|
||||
|
||||
if (ignore_newlines)
|
||||
non_nl = get_4 (ctx, &in, in_end, &inlen);
|
||||
else
|
||||
non_nl = in; /* Might have nl in this case. */
|
||||
|
||||
/* If the input is empty or consists solely of newlines (0 non-newlines),
|
||||
then we're done. Likewise if there are fewer than 4 bytes when not
|
||||
flushing context and not treating newlines as garbage. */
|
||||
if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines))
|
||||
{
|
||||
inlen = 0;
|
||||
break;
|
||||
}
|
||||
if (!decode_4 (non_nl, inlen, &out, &outleft))
|
||||
break;
|
||||
|
||||
inlen = in_end - in;
|
||||
}
|
||||
}
|
||||
|
||||
*outlen -= outleft;
|
||||
|
||||
return inlen == 0;
|
||||
}
|
||||
|
||||
/* Allocate an output buffer in *OUT, and decode the base64 encoded
|
||||
data stored in IN of size INLEN to the *OUT buffer. On return, the
|
||||
size of the decoded data is stored in *OUTLEN. OUTLEN may be NULL,
|
||||
if the caller is not interested in the decoded length. *OUT may be
|
||||
NULL to indicate an out of memory error, in which case *OUTLEN
|
||||
contains the size of the memory block needed. The function returns
|
||||
true on successful decoding and memory allocation errors. (Use the
|
||||
*OUT and *OUTLEN parameters to differentiate between successful
|
||||
decoding and memory error.) The function returns false if the
|
||||
input was invalid, in which case *OUT is NULL and *OUTLEN is
|
||||
undefined. */
|
||||
bool
|
||||
base64_decode_alloc_ctx (struct base64_decode_context *ctx,
|
||||
const char *in, size_t inlen, char **out,
|
||||
size_t *outlen)
|
||||
{
|
||||
/* This may allocate a few bytes too many, depending on input,
|
||||
but it's not worth the extra CPU time to compute the exact size.
|
||||
The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
|
||||
input ends with "=" and minus another 1 if the input ends with "==".
|
||||
Dividing before multiplying avoids the possibility of overflow. */
|
||||
size_t needlen = 3 * (inlen / 4) + 3;
|
||||
|
||||
*out = malloc (needlen);
|
||||
if (!*out)
|
||||
return true;
|
||||
|
||||
if (!base64_decode_ctx (ctx, in, inlen, *out, &needlen))
|
||||
{
|
||||
free (*out);
|
||||
*out = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (outlen)
|
||||
*outlen = needlen;
|
||||
|
||||
return true;
|
||||
}
|
||||
68
lib/base64.h
68
lib/base64.h
@@ -1,68 +0,0 @@
|
||||
/* base64.h -- Encode binary data using printable characters.
|
||||
Copyright (C) 2004-2006, 2009-2019 Free Software Foundation, Inc.
|
||||
Written by Simon Josefsson.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef BASE64_H
|
||||
# define BASE64_H
|
||||
|
||||
/* Get size_t. */
|
||||
# include <stddef.h>
|
||||
|
||||
/* Get bool. */
|
||||
# include <stdbool.h>
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* This uses that the expression (n+(k-1))/k means the smallest
|
||||
integer >= n/k, i.e., the ceiling of n/k. */
|
||||
# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
|
||||
|
||||
struct base64_decode_context
|
||||
{
|
||||
unsigned int i;
|
||||
char buf[4];
|
||||
};
|
||||
|
||||
extern bool isbase64 (char ch) __attribute__ ((__const__));
|
||||
|
||||
extern void base64_encode (const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t outlen);
|
||||
|
||||
extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
|
||||
|
||||
extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
|
||||
|
||||
extern bool base64_decode_ctx (struct base64_decode_context *ctx,
|
||||
const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t *outlen);
|
||||
|
||||
extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
|
||||
const char *in, size_t inlen,
|
||||
char **out, size_t *outlen);
|
||||
|
||||
#define base64_decode(in, inlen, out, outlen) \
|
||||
base64_decode_ctx (NULL, in, inlen, out, outlen)
|
||||
|
||||
#define base64_decode_alloc(in, inlen, out, outlen) \
|
||||
base64_decode_alloc_ctx (NULL, in, inlen, out, outlen)
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* BASE64_H */
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* BITLK (BitLocker-compatible) volume handling
|
||||
*
|
||||
* Copyright (C) 2019-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2019-2020 Milan Broz
|
||||
* Copyright (C) 2019-2020 Vojtech Trefny
|
||||
* Copyright (C) 2019-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2019-2022 Milan Broz
|
||||
* Copyright (C) 2019-2022 Vojtech Trefny
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <string.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <time.h>
|
||||
#include <iconv.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "bitlk.h"
|
||||
@@ -54,6 +53,9 @@
|
||||
#define BITLK_RECOVERY_PARTS 8
|
||||
#define BITLK_RECOVERY_PART_LEN 6
|
||||
|
||||
#define BITLK_BEK_FILE_HEADER_LEN 48
|
||||
#define BITLK_STARTUP_KEY_HEADER_LEN 24
|
||||
|
||||
#define BITLK_KDF_HASH "sha256"
|
||||
#define BITLK_KDF_ITERATION_COUNT 0x100000
|
||||
|
||||
@@ -162,6 +164,18 @@ struct bitlk_kdf_data {
|
||||
uint64_t count;
|
||||
};
|
||||
|
||||
struct bitlk_bek_header {
|
||||
uint32_t metadata_size;
|
||||
uint32_t metadata_version;
|
||||
uint32_t metadata_header_size;
|
||||
uint32_t metada_size_copy;
|
||||
struct bitlk_guid guid;
|
||||
uint32_t next_nonce;
|
||||
uint16_t encryption;
|
||||
uint16_t unknown;
|
||||
uint64_t creation_time;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
static BITLKVMKProtection get_vmk_protection(uint16_t protection)
|
||||
{
|
||||
switch (protection) {
|
||||
@@ -219,86 +233,11 @@ static const char* get_bitlk_type_string(BITLKEncryptionType type)
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO -- move to some utils file */
|
||||
static void hexprint(struct crypt_device *cd, const char *d, int n, const char *sep)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < n; i++)
|
||||
log_std(cd, "%02hhx%s", (const char)d[i], sep);
|
||||
}
|
||||
|
||||
static uint64_t filetime_to_unixtime(uint64_t time)
|
||||
{
|
||||
return (time - EPOCH_AS_FILETIME) / HUNDREDS_OF_NANOSECONDS;
|
||||
}
|
||||
|
||||
static int convert_to_utf8(struct crypt_device *cd, uint8_t *input, size_t inlen, char **out)
|
||||
{
|
||||
char *outbuf = NULL;
|
||||
iconv_t ic;
|
||||
size_t ic_inlen = inlen;
|
||||
size_t ic_outlen = inlen;
|
||||
char *ic_outbuf = NULL;
|
||||
size_t r = 0;
|
||||
|
||||
outbuf = malloc(inlen);
|
||||
if (outbuf == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(outbuf, 0, inlen);
|
||||
ic_outbuf = outbuf;
|
||||
|
||||
ic = iconv_open("UTF-8", "UTF-16LE");
|
||||
r = iconv(ic, (char **) &input, &ic_inlen, &ic_outbuf, &ic_outlen);
|
||||
iconv_close(ic);
|
||||
|
||||
if (r == 0)
|
||||
*out = strdup(outbuf);
|
||||
else {
|
||||
*out = NULL;
|
||||
log_dbg(cd, "Failed to convert volume description: %s", strerror(errno));
|
||||
r = 0;
|
||||
}
|
||||
|
||||
free(outbuf);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int passphrase_to_utf16(struct crypt_device *cd, char *input, size_t inlen, char **out)
|
||||
{
|
||||
char *outbuf = NULL;
|
||||
iconv_t ic;
|
||||
size_t ic_inlen = inlen;
|
||||
size_t ic_outlen = inlen * 2;
|
||||
char *ic_outbuf = NULL;
|
||||
size_t r = 0;
|
||||
|
||||
if (inlen == 0)
|
||||
return r;
|
||||
|
||||
outbuf = crypt_safe_alloc(inlen * 2);
|
||||
if (outbuf == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(outbuf, 0, inlen * 2);
|
||||
ic_outbuf = outbuf;
|
||||
|
||||
ic = iconv_open("UTF-16LE", "UTF-8");
|
||||
r = iconv(ic, &input, &ic_inlen, &ic_outbuf, &ic_outlen);
|
||||
iconv_close(ic);
|
||||
|
||||
if (r == 0) {
|
||||
*out = outbuf;
|
||||
} else {
|
||||
*out = NULL;
|
||||
crypt_safe_free(outbuf);
|
||||
log_dbg(cd, "Failed to convert passphrase: %s", strerror(errno));
|
||||
r = -errno;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int parse_vmk_entry(struct crypt_device *cd, uint8_t *data, int start, int end, struct bitlk_vmk **vmk)
|
||||
{
|
||||
uint16_t key_entry_size = 0;
|
||||
@@ -309,9 +248,12 @@ static int parse_vmk_entry(struct crypt_device *cd, uint8_t *data, int start, in
|
||||
const char *key = NULL;
|
||||
struct volume_key *vk = NULL;
|
||||
bool supported = false;
|
||||
int r = 0;
|
||||
|
||||
/* only passphrase or recovery passphrase vmks are supported (can be used to activate) */
|
||||
supported = (*vmk)->protection == BITLK_PROTECTION_PASSPHRASE || (*vmk)->protection == BITLK_PROTECTION_RECOVERY_PASSPHRASE;
|
||||
supported = (*vmk)->protection == BITLK_PROTECTION_PASSPHRASE ||
|
||||
(*vmk)->protection == BITLK_PROTECTION_RECOVERY_PASSPHRASE ||
|
||||
(*vmk)->protection == BITLK_PROTECTION_STARTUP_KEY;
|
||||
|
||||
while (end - start > 2) {
|
||||
/* size of this entry */
|
||||
@@ -376,9 +318,14 @@ static int parse_vmk_entry(struct crypt_device *cd, uint8_t *data, int start, in
|
||||
} else if (key_entry_value == BITLK_ENTRY_VALUE_RECOVERY_TIME) {
|
||||
;
|
||||
} else if (key_entry_value == BITLK_ENTRY_VALUE_STRING) {
|
||||
if (convert_to_utf8(cd, data + start + BITLK_ENTRY_HEADER_LEN, key_entry_size - BITLK_ENTRY_HEADER_LEN, &string) < 0) {
|
||||
log_err(cd, _("Invalid string found when parsing Volume Master Key."));
|
||||
string = malloc((key_entry_size - BITLK_ENTRY_HEADER_LEN) * 2 + 1);
|
||||
if (!string)
|
||||
return -ENOMEM;
|
||||
r = crypt_utf16_to_utf8(&string, CONST_CAST(char16_t *)(data + start + BITLK_ENTRY_HEADER_LEN),
|
||||
key_entry_size - BITLK_ENTRY_HEADER_LEN);
|
||||
if (r < 0 || !string) {
|
||||
free(string);
|
||||
log_err(cd, _("Invalid string found when parsing Volume Master Key."));
|
||||
return -EINVAL;
|
||||
} else if ((*vmk)->name != NULL) {
|
||||
if (supported) {
|
||||
@@ -394,6 +341,9 @@ static int parse_vmk_entry(struct crypt_device *cd, uint8_t *data, int start, in
|
||||
(*vmk)->name = string;
|
||||
string = NULL;
|
||||
}
|
||||
/* no idea what this is, lets hope it's not important */
|
||||
} else if (key_entry_value == BITLK_ENTRY_VALUE_USE_KEY && (*vmk)->protection == BITLK_PROTECTION_STARTUP_KEY) {
|
||||
;
|
||||
} else {
|
||||
if (supported) {
|
||||
log_err(cd, _("Unexpected metadata entry value '%u' found when parsing supported Volume Master Key."), key_entry_value);
|
||||
@@ -436,6 +386,9 @@ void BITLK_bitlk_vmk_free(struct bitlk_vmk *vmk)
|
||||
|
||||
void BITLK_bitlk_metadata_free(struct bitlk_metadata *metadata)
|
||||
{
|
||||
if (!metadata)
|
||||
return;
|
||||
|
||||
free(metadata->guid);
|
||||
if (metadata->description)
|
||||
free(metadata->description);
|
||||
@@ -463,6 +416,7 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
||||
int end = 0;
|
||||
size_t key_size = 0;
|
||||
const char *key = NULL;
|
||||
char *description = NULL;
|
||||
|
||||
struct bitlk_vmk *vmk = NULL;
|
||||
struct bitlk_vmk *vmk_p = params->vmks;
|
||||
@@ -476,7 +430,19 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
||||
/* read and check the signature */
|
||||
if (read_lseek_blockwise(devfd, device_block_size(cd, device),
|
||||
device_alignment(device), &sig, sizeof(sig), 0) != sizeof(sig)) {
|
||||
log_err(cd, _("Failed to read BITLK signature from %s."), device_path(device));
|
||||
log_dbg(cd, "Failed to read BITLK signature from %s.", device_path(device));
|
||||
r = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (memcmp(sig.signature, BITLK_SIGNATURE, sizeof(sig.signature)) == 0) {
|
||||
params->togo = false;
|
||||
fve_offset = BITLK_HEADER_METADATA_OFFSET;
|
||||
} else if (memcmp(sig.signature, BITLK_SIGNATURE_TOGO, sizeof(sig.signature)) == 0) {
|
||||
params->togo = true;
|
||||
fve_offset = BITLK_HEADER_METADATA_OFFSET_TOGO;
|
||||
} else {
|
||||
log_dbg(cd, "Invalid or unknown signature for BITLK device.");
|
||||
r = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@@ -493,19 +459,12 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (memcmp(sig.signature, BITLK_SIGNATURE, sizeof(sig.signature)) == 0) {
|
||||
params->togo = false;
|
||||
fve_offset = BITLK_HEADER_METADATA_OFFSET;
|
||||
} else if (memcmp(sig.signature, BITLK_SIGNATURE_TOGO, sizeof(sig.signature)) == 0) {
|
||||
params->togo = true;
|
||||
fve_offset = BITLK_HEADER_METADATA_OFFSET_TOGO;
|
||||
} else {
|
||||
log_err(cd, _("Invalid or unknown signature for BITLK device."));
|
||||
r = -EINVAL;
|
||||
goto out;
|
||||
params->sector_size = le16_to_cpu(sig.sector_size);
|
||||
if (params->sector_size == 0) {
|
||||
log_dbg(cd, "Got sector size 0, assuming 512.");
|
||||
params->sector_size = SECTOR_SIZE;
|
||||
}
|
||||
|
||||
params->sector_size = le16_to_cpu(sig.sector_size);
|
||||
if (!(params->sector_size == 512 || params->sector_size == 4096)) {
|
||||
log_err(cd, _("Unsupported sector size %" PRIu16 "."), params->sector_size);
|
||||
r = -EINVAL;
|
||||
@@ -553,18 +512,19 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
||||
le16_to_cpu(fve.curr_state), le16_to_cpu(fve.next_state));
|
||||
}
|
||||
|
||||
params->volume_size = le64_to_cpu(fve.volume_size);
|
||||
params->metadata_version = le16_to_cpu(fve.fve_version);
|
||||
fve_metadata_size = le32_to_cpu(fve.metadata_size);
|
||||
|
||||
switch (le16_to_cpu(fve.encryption)) {
|
||||
/* AES-CBC with Elephant difuser */
|
||||
case 0x8000:
|
||||
params->key_size = 128;
|
||||
params->key_size = 256;
|
||||
params->cipher = "aes";
|
||||
params->cipher_mode = "cbc-elephant";
|
||||
break;
|
||||
case 0x8001:
|
||||
params->key_size = 256;
|
||||
params->key_size = 512;
|
||||
params->cipher = "aes";
|
||||
params->cipher_mode = "cbc-elephant";
|
||||
break;
|
||||
@@ -581,12 +541,12 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
||||
break;
|
||||
/* AES-XTS */
|
||||
case 0x8004:
|
||||
params->key_size = 128;
|
||||
params->key_size = 256;
|
||||
params->cipher = "aes";
|
||||
params->cipher_mode = "xts-plain64";
|
||||
break;
|
||||
case 0x8005:
|
||||
params->key_size = 256;
|
||||
params->key_size = 512;
|
||||
params->cipher = "aes";
|
||||
params->cipher_mode = "xts-plain64";
|
||||
break;
|
||||
@@ -623,7 +583,7 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
||||
|
||||
if (read_lseek_blockwise(devfd, device_block_size(cd, device),
|
||||
device_alignment(device), fve_entries, fve_metadata_size - BITLK_FVE_METADATA_HEADER_LEN,
|
||||
params->metadata_offset[0] + BITLK_FVE_METADATA_HEADERS_LEN) != fve_metadata_size - BITLK_FVE_METADATA_HEADER_LEN) {
|
||||
params->metadata_offset[0] + BITLK_FVE_METADATA_HEADERS_LEN) != (ssize_t)(fve_metadata_size - BITLK_FVE_METADATA_HEADER_LEN)) {
|
||||
log_err(cd, _("Failed to read BITLK metadata entries from %s."), device_path(device));
|
||||
r = -EINVAL;
|
||||
goto out;
|
||||
@@ -649,6 +609,10 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
||||
sizeof(entry_vmk));
|
||||
|
||||
vmk = malloc(sizeof(struct bitlk_vmk));
|
||||
if (!vmk) {
|
||||
r = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
memset(vmk, 0, sizeof(struct bitlk_vmk));
|
||||
|
||||
guid_to_string(&entry_vmk.guid, guid_buf);
|
||||
@@ -677,6 +641,10 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
||||
/* FVEK */
|
||||
} else if (entry_type == BITLK_ENTRY_TYPE_FVEK) {
|
||||
params->fvek = malloc(sizeof(struct bitlk_fvek));
|
||||
if (!params->fvek) {
|
||||
r = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
memcpy(params->fvek->nonce,
|
||||
fve_entries + start + BITLK_ENTRY_HEADER_LEN,
|
||||
sizeof(params->fvek->nonce));
|
||||
@@ -702,13 +670,18 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
||||
params->volume_header_size = le64_to_cpu(entry_header.size);
|
||||
/* volume description (utf-16 string) */
|
||||
} else if (entry_type == BITLK_ENTRY_TYPE_DESCRIPTION) {
|
||||
r = convert_to_utf8(cd, fve_entries + start + BITLK_ENTRY_HEADER_LEN,
|
||||
entry_size - BITLK_ENTRY_HEADER_LEN,
|
||||
&(params->description));
|
||||
if (r < 0) {
|
||||
description = malloc((entry_size - BITLK_ENTRY_HEADER_LEN - BITLK_ENTRY_HEADER_LEN) * 2 + 1);
|
||||
if (!description)
|
||||
return -ENOMEM;
|
||||
r = crypt_utf16_to_utf8(&description, CONST_CAST(char16_t *)(fve_entries + start + BITLK_ENTRY_HEADER_LEN),
|
||||
entry_size - BITLK_ENTRY_HEADER_LEN);
|
||||
if (r < 0 || !description) {
|
||||
free(description);
|
||||
BITLK_bitlk_vmk_free(vmk);
|
||||
log_err(cd, _("Failed to convert BITLK volume description"));
|
||||
goto out;
|
||||
}
|
||||
params->description = description;
|
||||
}
|
||||
|
||||
start += entry_size;
|
||||
@@ -731,6 +704,7 @@ int BITLK_dump(struct crypt_device *cd, struct device *device, struct bitlk_meta
|
||||
log_std(cd, "Version: \t%u\n", params->metadata_version);
|
||||
log_std(cd, "GUID: \t%s\n", params->guid);
|
||||
log_std(cd, "Sector size: \t%u [bytes]\n", params->sector_size);
|
||||
log_std(cd, "Volume size: \t%" PRIu64 " [bytes]\n", params->volume_size);
|
||||
log_std(cd, "Created: \t%s", ctime((time_t *)&(params->creation_time)));
|
||||
log_std(cd, "Description: \t%s\n", params->description);
|
||||
log_std(cd, "Cipher name: \t%s\n", params->cipher);
|
||||
@@ -749,7 +723,7 @@ int BITLK_dump(struct crypt_device *cd, struct device *device, struct bitlk_meta
|
||||
log_std(cd, "\tGUID: \t%s\n", vmk_p->guid);
|
||||
log_std(cd, "\tProtection: \t%s\n", get_vmk_protection_string (vmk_p->protection));
|
||||
log_std(cd, "\tSalt: \t");
|
||||
hexprint(cd, (const char *) vmk_p->salt, 16, "");
|
||||
crypt_log_hex(cd, (const char *) vmk_p->salt, 16, "", 0, NULL);
|
||||
log_std(cd, "\n");
|
||||
|
||||
vk_p = vmk_p->vk;
|
||||
@@ -833,6 +807,135 @@ static int get_recovery_key(struct crypt_device *cd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_external_key_entry(struct crypt_device *cd,
|
||||
const char *data,
|
||||
int start,
|
||||
int end,
|
||||
struct volume_key **vk,
|
||||
const struct bitlk_metadata *params)
|
||||
{
|
||||
uint16_t key_entry_size = 0;
|
||||
uint16_t key_entry_type = 0;
|
||||
uint16_t key_entry_value = 0;
|
||||
size_t key_size = 0;
|
||||
const char *key = NULL;
|
||||
struct bitlk_guid guid;
|
||||
char guid_buf[UUID_STR_LEN] = {0};
|
||||
|
||||
while (end - start > 2) {
|
||||
/* size of this entry */
|
||||
memcpy(&key_entry_size, data + start, sizeof(key_entry_size));
|
||||
key_entry_size = le16_to_cpu(key_entry_size);
|
||||
if (key_entry_size == 0)
|
||||
break;
|
||||
|
||||
/* type and value of this entry */
|
||||
memcpy(&key_entry_type, data + start + sizeof(key_entry_size), sizeof(key_entry_type));
|
||||
memcpy(&key_entry_value,
|
||||
data + start + sizeof(key_entry_size) + sizeof(key_entry_type),
|
||||
sizeof(key_entry_value));
|
||||
key_entry_type = le16_to_cpu(key_entry_type);
|
||||
key_entry_value = le16_to_cpu(key_entry_value);
|
||||
|
||||
if (key_entry_type != BITLK_ENTRY_TYPE_PROPERTY && key_entry_type != BITLK_ENTRY_TYPE_VOLUME_GUID) {
|
||||
log_err(cd, _("Unexpected metadata entry type '%u' found when parsing external key."), key_entry_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (key_entry_value == BITLK_ENTRY_VALUE_KEY) {
|
||||
key_size = key_entry_size - (BITLK_ENTRY_HEADER_LEN + 4);
|
||||
key = (const char *) data + start + BITLK_ENTRY_HEADER_LEN + 4;
|
||||
*vk = crypt_alloc_volume_key(key_size, key);
|
||||
if (*vk == NULL)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
/* optional "ExternalKey" string, we can safely ignore it */
|
||||
} else if (key_entry_value == BITLK_ENTRY_VALUE_STRING)
|
||||
;
|
||||
/* GUID of the BitLocker device we are trying to open with this key */
|
||||
else if (key_entry_value == BITLK_ENTRY_VALUE_GUID) {
|
||||
memcpy(&guid, data + start + BITLK_ENTRY_HEADER_LEN, sizeof(struct bitlk_guid));
|
||||
guid_to_string(&guid, guid_buf);
|
||||
if (strcmp(guid_buf, params->guid) != 0) {
|
||||
log_err(cd, _("BEK file GUID '%s' does not match GUID of the volume."), guid_buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
log_err(cd, _("Unexpected metadata entry value '%u' found when parsing external key."), key_entry_value);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
start += key_entry_size;
|
||||
}
|
||||
|
||||
/* if we got here we failed to parse the metadata */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* check if given passphrase can be a startup key (has right format) and convert it */
|
||||
static int get_startup_key(struct crypt_device *cd,
|
||||
const char *password,
|
||||
size_t passwordLen,
|
||||
const struct bitlk_vmk *vmk,
|
||||
struct volume_key **su_key,
|
||||
const struct bitlk_metadata *params)
|
||||
{
|
||||
struct bitlk_bek_header bek_header = {0};
|
||||
char guid_buf[UUID_STR_LEN] = {0};
|
||||
|
||||
uint16_t key_entry_size = 0;
|
||||
uint16_t key_entry_type = 0;
|
||||
uint16_t key_entry_value = 0;
|
||||
|
||||
if (passwordLen < BITLK_BEK_FILE_HEADER_LEN)
|
||||
return -EPERM;
|
||||
|
||||
memcpy(&bek_header, password, BITLK_BEK_FILE_HEADER_LEN);
|
||||
|
||||
/* metadata should contain GUID of the VMK this startup key is used for */
|
||||
guid_to_string(&bek_header.guid, guid_buf);
|
||||
if (strcmp(guid_buf, vmk->guid) == 0)
|
||||
log_dbg(cd, "Found matching startup key for VMK %s", vmk->guid);
|
||||
else
|
||||
return -EPERM;
|
||||
|
||||
if (bek_header.metadata_version != 1) {
|
||||
log_err(cd, _("Unsupported BEK metadata version %" PRIu32), bek_header.metadata_version);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (bek_header.metadata_size != passwordLen) {
|
||||
log_err(cd, _("Unexpected BEK metadata size %" PRIu32 " does not match BEK file length"), bek_header.metadata_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* we are expecting exactly one metadata entry starting immediately after the header */
|
||||
memcpy(&key_entry_size, password + BITLK_BEK_FILE_HEADER_LEN, sizeof(key_entry_size));
|
||||
key_entry_size = le16_to_cpu(key_entry_size);
|
||||
if (key_entry_size < BITLK_ENTRY_HEADER_LEN) {
|
||||
log_dbg(cd, "Unexpected metadata entry size %" PRIu16 " when parsing BEK file", key_entry_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* type and value of this entry */
|
||||
memcpy(&key_entry_type, password + BITLK_BEK_FILE_HEADER_LEN + sizeof(key_entry_size), sizeof(key_entry_type));
|
||||
memcpy(&key_entry_value,
|
||||
password + BITLK_BEK_FILE_HEADER_LEN + sizeof(key_entry_size) + sizeof(key_entry_type),
|
||||
sizeof(key_entry_value));
|
||||
key_entry_type = le16_to_cpu(key_entry_type);
|
||||
key_entry_value = le16_to_cpu(key_entry_value);
|
||||
|
||||
if (key_entry_type == BITLK_ENTRY_TYPE_STARTUP_KEY && key_entry_value == BITLK_ENTRY_VALUE_EXTERNAL_KEY) {
|
||||
return parse_external_key_entry(cd, password,
|
||||
BITLK_BEK_FILE_HEADER_LEN + BITLK_ENTRY_HEADER_LEN + BITLK_STARTUP_KEY_HEADER_LEN,
|
||||
passwordLen, su_key, params);
|
||||
} else {
|
||||
log_err(cd, _("Unexpected metadata entry found when parsing startup key."));
|
||||
log_dbg(cd, "Entry type: %u, entry value: %u", key_entry_type, key_entry_value);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static int bitlk_kdf(struct crypt_device *cd,
|
||||
const char *password,
|
||||
size_t passwordLen,
|
||||
@@ -843,7 +946,7 @@ static int bitlk_kdf(struct crypt_device *cd,
|
||||
struct bitlk_kdf_data kdf = {};
|
||||
struct crypt_hash *hd = NULL;
|
||||
int len = 0;
|
||||
char *utf16Password = NULL;
|
||||
char16_t *utf16Password = NULL;
|
||||
int i = 0;
|
||||
int r = 0;
|
||||
|
||||
@@ -860,11 +963,16 @@ static int bitlk_kdf(struct crypt_device *cd,
|
||||
|
||||
if (!recovery) {
|
||||
/* passphrase: convert to UTF-16 first, then sha256(sha256(pw)) */
|
||||
r = passphrase_to_utf16(cd, CONST_CAST(char*)password, passwordLen, &utf16Password);
|
||||
utf16Password = crypt_safe_alloc(sizeof(char16_t) * (passwordLen + 1));
|
||||
if (!utf16Password) {
|
||||
r = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
r = crypt_utf8_to_utf16(&utf16Password, CONST_CAST(char*)password, passwordLen);
|
||||
if (r < 0)
|
||||
goto out;
|
||||
|
||||
crypt_hash_write(hd, utf16Password, passwordLen * 2);
|
||||
crypt_hash_write(hd, (char*)utf16Password, passwordLen * 2);
|
||||
r = crypt_hash_final(hd, kdf.initial_sha256, len);
|
||||
if (r < 0)
|
||||
goto out;
|
||||
@@ -908,7 +1016,7 @@ static int decrypt_key(struct crypt_device *cd,
|
||||
{
|
||||
char *outbuf;
|
||||
int r;
|
||||
uint32_t key_size = 0;
|
||||
uint16_t key_size = 0;
|
||||
|
||||
outbuf = crypt_safe_alloc(enc_key->keylength);
|
||||
if (!outbuf)
|
||||
@@ -923,16 +1031,18 @@ static int decrypt_key(struct crypt_device *cd,
|
||||
}
|
||||
|
||||
/* key_data has it's size as part of the metadata */
|
||||
memcpy(&key_size, outbuf, 4);
|
||||
key_size = le32_to_cpu(key_size);
|
||||
memcpy(&key_size, outbuf, 2);
|
||||
key_size = le16_to_cpu(key_size);
|
||||
if (enc_key->keylength != key_size) {
|
||||
log_err(cd, _("Wrong key size."));
|
||||
log_err(cd, _("Unexpected key data size."));
|
||||
log_dbg(cd, "Expected key data size: %zu, got %" PRIu16 "", enc_key->keylength, key_size);
|
||||
|
||||
r = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (is_fvek && strcmp(crypt_get_cipher_mode(cd), "cbc-elephant") == 0 &&
|
||||
crypt_get_volume_key_size(cd) == 16) {
|
||||
crypt_get_volume_key_size(cd) == 32) {
|
||||
/* 128bit AES-CBC with Elephant -- key size is 256 bit (2 keys) but key data is 512 bits,
|
||||
data: 16B CBC key, 16B empty, 16B elephant key, 16B empty */
|
||||
memcpy(outbuf + 16 + BITLK_OPEN_KEY_METADATA_LEN,
|
||||
@@ -949,56 +1059,34 @@ out:
|
||||
return r;
|
||||
}
|
||||
|
||||
int BITLK_activate(struct crypt_device *cd,
|
||||
const char *name,
|
||||
const char *password,
|
||||
size_t passwordLen,
|
||||
const struct bitlk_metadata *params,
|
||||
uint32_t flags)
|
||||
int BITLK_get_volume_key(struct crypt_device *cd,
|
||||
const char *password,
|
||||
size_t passwordLen,
|
||||
const struct bitlk_metadata *params,
|
||||
struct volume_key **open_fvek_key)
|
||||
{
|
||||
int r = 0;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int min = 0;
|
||||
int num_segments = 0;
|
||||
struct crypt_dm_active_device dmd = {
|
||||
.flags = flags,
|
||||
};
|
||||
struct dm_target *next_segment = NULL;
|
||||
struct volume_key *open_vmk_key = NULL;
|
||||
struct volume_key *open_fvek_key = NULL;
|
||||
struct volume_key *vmk_dec_key = NULL;
|
||||
struct volume_key *recovery_key = NULL;
|
||||
const struct bitlk_vmk *next_vmk = NULL;
|
||||
struct segment segments[MAX_BITLK_SEGMENTS] = {};
|
||||
struct segment temp;
|
||||
uint64_t next_start = 0;
|
||||
uint64_t next_end = 0;
|
||||
uint64_t last_segment = 0;
|
||||
uint32_t dmt_flags;
|
||||
|
||||
if (!params->state) {
|
||||
log_err(cd, _("This BITLK device is in an unsupported state and cannot be activated."));
|
||||
r = -ENOTSUP;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (params->type != BITLK_ENCRYPTION_TYPE_NORMAL) {
|
||||
log_err(cd, _("BITLK devices with type '%s' cannot be activated."), get_bitlk_type_string(params->type));
|
||||
r = -ENOTSUP;
|
||||
goto out;
|
||||
}
|
||||
|
||||
next_vmk = params->vmks;
|
||||
while (next_vmk) {
|
||||
if (next_vmk->protection == BITLK_PROTECTION_PASSPHRASE) {
|
||||
r = bitlk_kdf(cd, password, passwordLen, false, next_vmk->salt, &vmk_dec_key);
|
||||
if (r)
|
||||
return r;
|
||||
if (r) {
|
||||
/* something wrong happened, but we still want to check other key slots */
|
||||
next_vmk = next_vmk->next;
|
||||
continue;
|
||||
}
|
||||
} else if (next_vmk->protection == BITLK_PROTECTION_RECOVERY_PASSPHRASE) {
|
||||
r = get_recovery_key(cd, password, passwordLen, &recovery_key);
|
||||
if (r)
|
||||
return r;
|
||||
if (r) {
|
||||
/* something wrong happened, but we still want to check other key slots */
|
||||
next_vmk = next_vmk->next;
|
||||
continue;
|
||||
}
|
||||
if (recovery_key == NULL) {
|
||||
/* r = 0 but no key -> given passphrase is not a recovery passphrase */
|
||||
r = -EPERM;
|
||||
@@ -1011,8 +1099,15 @@ int BITLK_activate(struct crypt_device *cd,
|
||||
crypt_free_volume_key(recovery_key);
|
||||
if (r)
|
||||
return r;
|
||||
} else if (next_vmk->protection == BITLK_PROTECTION_STARTUP_KEY) {
|
||||
r = get_startup_key(cd, password, passwordLen, next_vmk, &vmk_dec_key, params);
|
||||
if (r) {
|
||||
next_vmk = next_vmk->next;
|
||||
continue;
|
||||
}
|
||||
log_dbg(cd, "Trying to use external key found in provided password.");
|
||||
} else {
|
||||
/* only passphrase and recovery passphrase VMKs supported right now */
|
||||
/* only passphrase, recovery passphrase and startup key VMKs supported right now */
|
||||
log_dbg(cd, "Skipping %s", get_vmk_protection_string(next_vmk->protection));
|
||||
next_vmk = next_vmk->next;
|
||||
if (r == 0)
|
||||
@@ -1035,7 +1130,7 @@ int BITLK_activate(struct crypt_device *cd,
|
||||
}
|
||||
crypt_free_volume_key(vmk_dec_key);
|
||||
|
||||
r = decrypt_key(cd, &open_fvek_key, params->fvek->vk, open_vmk_key,
|
||||
r = decrypt_key(cd, open_fvek_key, params->fvek->vk, open_vmk_key,
|
||||
params->fvek->mac_tag, BITLK_VMK_MAC_TAG_SIZE,
|
||||
params->fvek->nonce, BITLK_NONCE_SIZE, true);
|
||||
if (r < 0) {
|
||||
@@ -1056,28 +1151,71 @@ int BITLK_activate(struct crypt_device *cd,
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Password verify only */
|
||||
if (!name) {
|
||||
crypt_free_volume_key(open_fvek_key);
|
||||
return r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _activate_check(struct crypt_device *cd,
|
||||
const struct bitlk_metadata *params)
|
||||
{
|
||||
const struct bitlk_vmk *next_vmk = NULL;
|
||||
|
||||
if (!params->state) {
|
||||
log_err(cd, _("This BITLK device is in an unsupported state and cannot be activated."));
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (params->type != BITLK_ENCRYPTION_TYPE_NORMAL) {
|
||||
log_err(cd, _("BITLK devices with type '%s' cannot be activated."), get_bitlk_type_string(params->type));
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
next_vmk = params->vmks;
|
||||
while (next_vmk) {
|
||||
if (next_vmk->protection == BITLK_PROTECTION_CLEAR_KEY) {
|
||||
crypt_free_volume_key(open_fvek_key);
|
||||
log_err(cd, _("Activation of partially decrypted BITLK device is not supported."));
|
||||
return -ENOTSUP;
|
||||
}
|
||||
next_vmk = next_vmk->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _activate(struct crypt_device *cd,
|
||||
const char *name,
|
||||
struct volume_key *open_fvek_key,
|
||||
const struct bitlk_metadata *params,
|
||||
uint32_t flags)
|
||||
{
|
||||
int r = 0;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int min = 0;
|
||||
int num_segments = 0;
|
||||
struct crypt_dm_active_device dmd = {
|
||||
.flags = flags,
|
||||
};
|
||||
struct dm_target *next_segment = NULL;
|
||||
struct segment segments[MAX_BITLK_SEGMENTS] = {};
|
||||
struct segment temp;
|
||||
uint64_t next_start = 0;
|
||||
uint64_t next_end = 0;
|
||||
uint64_t last_segment = 0;
|
||||
uint32_t dmt_flags = 0;
|
||||
|
||||
r = _activate_check(cd, params);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
r = device_block_adjust(cd, crypt_data_device(cd), DEV_EXCL,
|
||||
0, &dmd.size, &dmd.flags);
|
||||
if (r) {
|
||||
crypt_free_volume_key(open_fvek_key);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (dmd.size * SECTOR_SIZE != params->volume_size)
|
||||
log_std(cd, _("WARNING: BitLocker volume size %" PRIu64 " does not match the underlying device size %" PRIu64 ""),
|
||||
params->volume_size,
|
||||
dmd.size * SECTOR_SIZE);
|
||||
|
||||
/* there will be always 4 dm-zero segments: 3x metadata, 1x FS header */
|
||||
for (i = 0; i < 3; i++) {
|
||||
@@ -1209,9 +1347,68 @@ int BITLK_activate(struct crypt_device *cd,
|
||||
log_err(cd, _("Cannot activate device, kernel dm-crypt is missing support for BITLK Elephant diffuser."));
|
||||
r = -ENOTSUP;
|
||||
}
|
||||
if ((dmd.flags & CRYPT_ACTIVATE_IV_LARGE_SECTORS) && !(dmt_flags & DM_SECTOR_SIZE_SUPPORTED)) {
|
||||
log_err(cd, _("Cannot activate device, kernel dm-crypt is missing support for large sector size."));
|
||||
r = -ENOTSUP;
|
||||
}
|
||||
if (dm_flags(cd, DM_ZERO, &dmt_flags) < 0) {
|
||||
log_err(cd, _("Cannot activate device, kernel dm-zero module is missing."));
|
||||
r = -ENOTSUP;
|
||||
}
|
||||
}
|
||||
out:
|
||||
dm_targets_free(cd, &dmd);
|
||||
return r;
|
||||
}
|
||||
|
||||
int BITLK_activate_by_passphrase(struct crypt_device *cd,
|
||||
const char *name,
|
||||
const char *password,
|
||||
size_t passwordLen,
|
||||
const struct bitlk_metadata *params,
|
||||
uint32_t flags)
|
||||
{
|
||||
int r = 0;
|
||||
struct volume_key *open_fvek_key = NULL;
|
||||
|
||||
r = _activate_check(cd, params);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
r = BITLK_get_volume_key(cd, password, passwordLen, params, &open_fvek_key);
|
||||
if (r < 0)
|
||||
goto out;
|
||||
|
||||
/* Password verify only */
|
||||
if (!name)
|
||||
goto out;
|
||||
|
||||
r = _activate(cd, name, open_fvek_key, params, flags);
|
||||
out:
|
||||
crypt_free_volume_key(open_fvek_key);
|
||||
return r;
|
||||
}
|
||||
|
||||
int BITLK_activate_by_volume_key(struct crypt_device *cd,
|
||||
const char *name,
|
||||
const char *volume_key,
|
||||
size_t volume_key_size,
|
||||
const struct bitlk_metadata *params,
|
||||
uint32_t flags)
|
||||
{
|
||||
int r = 0;
|
||||
struct volume_key *open_fvek_key = NULL;
|
||||
|
||||
r = _activate_check(cd, params);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
open_fvek_key = crypt_alloc_volume_key(volume_key_size, volume_key);
|
||||
if (!open_fvek_key)
|
||||
return -ENOMEM;
|
||||
|
||||
r = _activate(cd, name, open_fvek_key, params, flags);
|
||||
|
||||
crypt_free_volume_key(open_fvek_key);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* BITLK (BitLocker-compatible) header definition
|
||||
*
|
||||
* Copyright (C) 2019-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2019-2020 Milan Broz
|
||||
* Copyright (C) 2019-2020 Vojtech Trefny
|
||||
* Copyright (C) 2019-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2019-2022 Milan Broz
|
||||
* Copyright (C) 2019-2022 Vojtech Trefny
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
struct crypt_device;
|
||||
struct device;
|
||||
struct volume_key;
|
||||
|
||||
#define BITLK_NONCE_SIZE 12
|
||||
#define BITLK_SALT_SIZE 16
|
||||
@@ -60,6 +61,7 @@ typedef enum {
|
||||
BITLK_ENTRY_TYPE_STARTUP_KEY = 0x0006,
|
||||
BITLK_ENTRY_TYPE_DESCRIPTION = 0x0007,
|
||||
BITLK_ENTRY_TYPE_VOLUME_HEADER = 0x000f,
|
||||
BITLK_ENTRY_TYPE_VOLUME_GUID = 0x0019,
|
||||
} BITLKFVEEntryType;
|
||||
|
||||
typedef enum {
|
||||
@@ -75,6 +77,7 @@ typedef enum {
|
||||
BITLK_ENTRY_VALUE_EXTERNAL_KEY = 0x0009,
|
||||
BITLK_ENTRY_VALUE_OFFSET_SIZE = 0x000f,
|
||||
BITLK_ENTRY_VALUE_RECOVERY_TIME = 0x015,
|
||||
BITLK_ENTRY_VALUE_GUID = 0x0017,
|
||||
} BITLKFVEEntryValue;
|
||||
|
||||
struct bitlk_vmk {
|
||||
@@ -96,6 +99,7 @@ struct bitlk_fvek {
|
||||
|
||||
struct bitlk_metadata {
|
||||
uint16_t sector_size;
|
||||
uint64_t volume_size;
|
||||
bool togo;
|
||||
bool state;
|
||||
BITLKEncryptionType type;
|
||||
@@ -117,12 +121,25 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params);
|
||||
|
||||
int BITLK_dump(struct crypt_device *cd, struct device *device, struct bitlk_metadata *params);
|
||||
|
||||
int BITLK_activate(struct crypt_device *cd,
|
||||
const char *name,
|
||||
const char *password,
|
||||
size_t passwordLen,
|
||||
const struct bitlk_metadata *params,
|
||||
uint32_t flags);
|
||||
int BITLK_get_volume_key(struct crypt_device *cd,
|
||||
const char *password,
|
||||
size_t passwordLen,
|
||||
const struct bitlk_metadata *params,
|
||||
struct volume_key **open_fvek_key);
|
||||
|
||||
int BITLK_activate_by_passphrase(struct crypt_device *cd,
|
||||
const char *name,
|
||||
const char *password,
|
||||
size_t passwordLen,
|
||||
const struct bitlk_metadata *params,
|
||||
uint32_t flags);
|
||||
|
||||
int BITLK_activate_by_volume_key(struct crypt_device *cd,
|
||||
const char *name,
|
||||
const char *volume_key,
|
||||
size_t volume_key_size,
|
||||
const struct bitlk_metadata *params,
|
||||
uint32_t flags);
|
||||
|
||||
void BITLK_bitlk_fvek_free(struct bitlk_fvek *fvek);
|
||||
void BITLK_bitlk_vmk_free(struct bitlk_vmk *vmk);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* cryptsetup plain device helper functions
|
||||
*
|
||||
* Copyright (C) 2004 Jana Saout <jana@saout.de>
|
||||
* Copyright (C) 2010-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2020 Milan Broz
|
||||
* Copyright (C) 2010-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2022 Milan Broz
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -9,6 +9,8 @@ libcrypto_backend_la_SOURCES = \
|
||||
lib/crypto_backend/crypto_storage.c \
|
||||
lib/crypto_backend/pbkdf_check.c \
|
||||
lib/crypto_backend/crc32.c \
|
||||
lib/crypto_backend/base64.c \
|
||||
lib/crypto_backend/utf8.c \
|
||||
lib/crypto_backend/argon2_generic.c \
|
||||
lib/crypto_backend/cipher_generic.c \
|
||||
lib/crypto_backend/cipher_check.c
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
@@ -450,6 +450,8 @@ const char *argon2_error_message(int error_code) {
|
||||
|
||||
size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost, uint32_t parallelism,
|
||||
uint32_t saltlen, uint32_t hashlen, argon2_type type) {
|
||||
if (!argon2_type2string(type, 0))
|
||||
return 0;
|
||||
return strlen("$$v=$m=,t=,p=$$") + strlen(argon2_type2string(type, 0)) +
|
||||
numlen(t_cost) + numlen(m_cost) + numlen(parallelism) +
|
||||
b64len(saltlen) + b64len(hashlen) + numlen(ARGON2_VERSION_NUMBER) + 1;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
@@ -120,18 +120,24 @@ void free_memory(const argon2_context *context, uint8_t *memory,
|
||||
}
|
||||
}
|
||||
|
||||
void NOT_OPTIMIZED secure_wipe_memory(void *v, size_t n) {
|
||||
#if defined(_MSC_VER) && VC_GE_2005(_MSC_VER)
|
||||
void secure_wipe_memory(void *v, size_t n) {
|
||||
SecureZeroMemory(v, n);
|
||||
}
|
||||
#elif defined memset_s
|
||||
void secure_wipe_memory(void *v, size_t n) {
|
||||
memset_s(v, n, 0, n);
|
||||
}
|
||||
#elif defined(HAVE_EXPLICIT_BZERO)
|
||||
void secure_wipe_memory(void *v, size_t n) {
|
||||
explicit_bzero(v, n);
|
||||
}
|
||||
#else
|
||||
void NOT_OPTIMIZED secure_wipe_memory(void *v, size_t n) {
|
||||
static void *(*const volatile memset_sec)(void *, int, size_t) = &memset;
|
||||
memset_sec(v, 0, n);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Memory clear flag defaults to true. */
|
||||
int FLAG_clear_internal_memory = 1;
|
||||
@@ -273,7 +279,6 @@ static void *fill_segment_thr(void *thread_data)
|
||||
{
|
||||
argon2_thread_data *my_data = thread_data;
|
||||
fill_segment(my_data->instance_ptr, my_data->pos);
|
||||
argon2_thread_exit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
@@ -46,12 +46,4 @@ int argon2_thread_join(argon2_thread_handle_t handle) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void argon2_thread_exit(void) {
|
||||
#if defined(_WIN32)
|
||||
_endthreadex(0);
|
||||
#else
|
||||
pthread_exit(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ARGON2_NO_THREADS */
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
@@ -58,10 +58,5 @@ int argon2_thread_create(argon2_thread_handle_t *handle,
|
||||
*/
|
||||
int argon2_thread_join(argon2_thread_handle_t handle);
|
||||
|
||||
/* Terminate the current thread. Must be run inside a thread created by
|
||||
* argon2_thread_create.
|
||||
*/
|
||||
void argon2_thread_exit(void);
|
||||
|
||||
#endif /* ARGON2_NO_THREADS */
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Argon2 PBKDF2 library wrapper
|
||||
*
|
||||
* Copyright (C) 2016-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2016-2020 Milan Broz
|
||||
* Copyright (C) 2016-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2016-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
||||
277
lib/crypto_backend/base64.c
Normal file
277
lib/crypto_backend/base64.c
Normal file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Base64 "Not encryption" helpers, copied and adapted from systemd project.
|
||||
*
|
||||
* Copyright (C) 2010 Lennart Poettering
|
||||
*
|
||||
* cryptsetup related changes
|
||||
* Copyright (C) 2021-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this file; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "crypto_backend.h"
|
||||
|
||||
#define WHITESPACE " \t\n\r"
|
||||
|
||||
/* https://tools.ietf.org/html/rfc4648#section-4 */
|
||||
static char base64char(int x)
|
||||
{
|
||||
static const char table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
return table[x & 63];
|
||||
}
|
||||
|
||||
static int unbase64char(char c)
|
||||
{
|
||||
unsigned offset;
|
||||
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
return c - 'A';
|
||||
|
||||
offset = 'Z' - 'A' + 1;
|
||||
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return c - 'a' + offset;
|
||||
|
||||
offset += 'z' - 'a' + 1;
|
||||
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0' + offset;
|
||||
|
||||
offset += '9' - '0' + 1;
|
||||
|
||||
if (c == '+')
|
||||
return offset;
|
||||
|
||||
offset++;
|
||||
|
||||
if (c == '/')
|
||||
return offset;
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int crypt_base64_encode(char **out, size_t *out_length, const char *in, size_t in_length)
|
||||
{
|
||||
char *r, *z;
|
||||
const uint8_t *x;
|
||||
|
||||
assert(in || in_length == 0);
|
||||
assert(out);
|
||||
|
||||
/* three input bytes makes four output bytes, padding is added so we must round up */
|
||||
z = r = malloc(4 * (in_length + 2) / 3 + 1);
|
||||
if (!r)
|
||||
return -ENOMEM;
|
||||
|
||||
for (x = (const uint8_t *)in; x < (const uint8_t*)in + (in_length / 3) * 3; x += 3) {
|
||||
/* x[0] == XXXXXXXX; x[1] == YYYYYYYY; x[2] == ZZZZZZZZ */
|
||||
*(z++) = base64char(x[0] >> 2); /* 00XXXXXX */
|
||||
*(z++) = base64char((x[0] & 3) << 4 | x[1] >> 4); /* 00XXYYYY */
|
||||
*(z++) = base64char((x[1] & 15) << 2 | x[2] >> 6); /* 00YYYYZZ */
|
||||
*(z++) = base64char(x[2] & 63); /* 00ZZZZZZ */
|
||||
}
|
||||
|
||||
switch (in_length % 3) {
|
||||
case 2:
|
||||
*(z++) = base64char(x[0] >> 2); /* 00XXXXXX */
|
||||
*(z++) = base64char((x[0] & 3) << 4 | x[1] >> 4); /* 00XXYYYY */
|
||||
*(z++) = base64char((x[1] & 15) << 2); /* 00YYYY00 */
|
||||
*(z++) = '=';
|
||||
|
||||
break;
|
||||
case 1:
|
||||
*(z++) = base64char(x[0] >> 2); /* 00XXXXXX */
|
||||
*(z++) = base64char((x[0] & 3) << 4); /* 00XX0000 */
|
||||
*(z++) = '=';
|
||||
*(z++) = '=';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*z = 0;
|
||||
*out = r;
|
||||
if (out_length)
|
||||
*out_length = z - r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int unbase64_next(const char **p, size_t *l)
|
||||
{
|
||||
int ret;
|
||||
|
||||
assert(p);
|
||||
assert(l);
|
||||
|
||||
/* Find the next non-whitespace character, and decode it. If we find padding, we return it as INT_MAX. We
|
||||
* greedily skip all preceding and all following whitespace. */
|
||||
|
||||
for (;;) {
|
||||
if (*l == 0)
|
||||
return -EPIPE;
|
||||
|
||||
if (!strchr(WHITESPACE, **p))
|
||||
break;
|
||||
|
||||
/* Skip leading whitespace */
|
||||
(*p)++, (*l)--;
|
||||
}
|
||||
|
||||
if (**p == '=')
|
||||
ret = INT_MAX; /* return padding as INT_MAX */
|
||||
else {
|
||||
ret = unbase64char(**p);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
(*p)++, (*l)--;
|
||||
|
||||
if (*l == 0)
|
||||
break;
|
||||
if (!strchr(WHITESPACE, **p))
|
||||
break;
|
||||
|
||||
/* Skip following whitespace */
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int crypt_base64_decode(char **out, size_t *out_length, const char *in, size_t in_length)
|
||||
{
|
||||
uint8_t *buf = NULL;
|
||||
const char *x;
|
||||
uint8_t *z;
|
||||
size_t len;
|
||||
int r;
|
||||
|
||||
assert(in || in_length == 0);
|
||||
assert(out);
|
||||
assert(out_length);
|
||||
|
||||
if (in_length == (size_t) -1)
|
||||
in_length = strlen(in);
|
||||
|
||||
/* A group of four input bytes needs three output bytes, in case of padding we need to add two or three extra
|
||||
* bytes. Note that this calculation is an upper boundary, as we ignore whitespace while decoding */
|
||||
len = (in_length / 4) * 3 + (in_length % 4 != 0 ? (in_length % 4) - 1 : 0);
|
||||
|
||||
buf = malloc(len + 1);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
for (x = in, z = buf;;) {
|
||||
int a, b, c, d; /* a == 00XXXXXX; b == 00YYYYYY; c == 00ZZZZZZ; d == 00WWWWWW */
|
||||
|
||||
a = unbase64_next(&x, &in_length);
|
||||
if (a == -EPIPE) /* End of string */
|
||||
break;
|
||||
if (a < 0) {
|
||||
r = a;
|
||||
goto err;
|
||||
}
|
||||
if (a == INT_MAX) { /* Padding is not allowed at the beginning of a 4ch block */
|
||||
r = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
b = unbase64_next(&x, &in_length);
|
||||
if (b < 0) {
|
||||
r = b;
|
||||
goto err;
|
||||
}
|
||||
if (b == INT_MAX) { /* Padding is not allowed at the second character of a 4ch block either */
|
||||
r = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
c = unbase64_next(&x, &in_length);
|
||||
if (c < 0) {
|
||||
r = c;
|
||||
goto err;
|
||||
}
|
||||
|
||||
d = unbase64_next(&x, &in_length);
|
||||
if (d < 0) {
|
||||
r = d;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (c == INT_MAX) { /* Padding at the third character */
|
||||
|
||||
if (d != INT_MAX) { /* If the third character is padding, the fourth must be too */
|
||||
r = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* b == 00YY0000 */
|
||||
if (b & 15) {
|
||||
r = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (in_length > 0) { /* Trailing rubbish? */
|
||||
r = -ENAMETOOLONG;
|
||||
goto err;
|
||||
}
|
||||
|
||||
*(z++) = (uint8_t) a << 2 | (uint8_t) (b >> 4); /* XXXXXXYY */
|
||||
break;
|
||||
}
|
||||
|
||||
if (d == INT_MAX) {
|
||||
/* c == 00ZZZZ00 */
|
||||
if (c & 3) {
|
||||
r = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (in_length > 0) { /* Trailing rubbish? */
|
||||
r = -ENAMETOOLONG;
|
||||
goto err;
|
||||
}
|
||||
|
||||
*(z++) = (uint8_t) a << 2 | (uint8_t) b >> 4; /* XXXXXXYY */
|
||||
*(z++) = (uint8_t) b << 4 | (uint8_t) c >> 2; /* YYYYZZZZ */
|
||||
break;
|
||||
}
|
||||
|
||||
*(z++) = (uint8_t) a << 2 | (uint8_t) b >> 4; /* XXXXXXYY */
|
||||
*(z++) = (uint8_t) b << 4 | (uint8_t) c >> 2; /* YYYYZZZZ */
|
||||
*(z++) = (uint8_t) c << 6 | (uint8_t) d; /* ZZWWWWWW */
|
||||
}
|
||||
|
||||
*z = 0;
|
||||
|
||||
*out_length = (size_t) (z - buf);
|
||||
*out = (char *)buf;
|
||||
return 0;
|
||||
err:
|
||||
free(buf);
|
||||
|
||||
/* Ignore other errors in crypt_backend */
|
||||
if (r != -ENOMEM)
|
||||
r = -EINVAL;
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Cipher performance check
|
||||
*
|
||||
* Copyright (C) 2018-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2018-2020 Milan Broz
|
||||
* Copyright (C) 2018-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2018-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Linux kernel cipher generic utilities
|
||||
*
|
||||
* Copyright (C) 2018-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2018-2020 Milan Broz
|
||||
* Copyright (C) 2018-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2018-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -31,7 +31,6 @@ struct cipher_alg {
|
||||
bool wrapped_key;
|
||||
};
|
||||
|
||||
/* FIXME: Getting block size should be dynamic from cipher backend. */
|
||||
static const struct cipher_alg cipher_algs[] = {
|
||||
{ "cipher_null", NULL, 16, false },
|
||||
{ "aes", NULL, 16, false },
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* crypto backend implementation
|
||||
*
|
||||
* Copyright (C) 2010-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2020 Milan Broz
|
||||
* Copyright (C) 2010-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -25,13 +25,19 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UCHAR_H
|
||||
#include <uchar.h>
|
||||
#else
|
||||
#define char32_t uint32_t
|
||||
#define char16_t uint16_t
|
||||
#endif
|
||||
|
||||
struct crypt_hash;
|
||||
struct crypt_hmac;
|
||||
struct crypt_cipher;
|
||||
struct crypt_storage;
|
||||
|
||||
int crypt_backend_init(void);
|
||||
int crypt_backend_init(bool fips);
|
||||
void crypt_backend_destroy(void);
|
||||
|
||||
#define CRYPT_BACKEND_KERNEL (1 << 0) /* Crypto uses kernel part, for benchmark */
|
||||
@@ -62,7 +68,7 @@ int crypt_backend_rng(char *buffer, size_t length, int quality, int fips);
|
||||
/* PBKDF*/
|
||||
struct crypt_pbkdf_limits {
|
||||
uint32_t min_iterations, max_iterations;
|
||||
uint32_t min_memory, max_memory;
|
||||
uint32_t min_memory, max_memory, min_bench_memory;
|
||||
uint32_t min_parallel, max_parallel;
|
||||
};
|
||||
|
||||
@@ -83,6 +89,14 @@ int crypt_pbkdf_perf(const char *kdf, const char *hash,
|
||||
/* CRC32 */
|
||||
uint32_t crypt_crc32(uint32_t seed, const unsigned char *buf, size_t len);
|
||||
|
||||
/* Base64 */
|
||||
int crypt_base64_encode(char **out, size_t *out_length, const char *in, size_t in_length);
|
||||
int crypt_base64_decode(char **out, size_t *out_length, const char *in, size_t in_length);
|
||||
|
||||
/* UTF8/16 */
|
||||
int crypt_utf16_to_utf8(char **out, const char16_t *s, size_t length /* bytes! */);
|
||||
int crypt_utf8_to_utf16(char16_t **out, const char *s, size_t length);
|
||||
|
||||
/* Block ciphers */
|
||||
int crypt_cipher_ivsize(const char *name, const char *mode);
|
||||
int crypt_cipher_wrapped_key(const char *name, const char *mode);
|
||||
@@ -109,7 +123,7 @@ int crypt_cipher_check_kernel(const char *name, const char *mode,
|
||||
/* Storage encryption wrappers */
|
||||
int crypt_storage_init(struct crypt_storage **ctx, size_t sector_size,
|
||||
const char *cipher, const char *cipher_mode,
|
||||
const void *key, size_t key_length);
|
||||
const void *key, size_t key_length, bool large_iv);
|
||||
void crypt_storage_destroy(struct crypt_storage *ctx);
|
||||
int crypt_storage_decrypt(struct crypt_storage *ctx, uint64_t iv_offset,
|
||||
uint64_t length, char *buffer);
|
||||
@@ -135,4 +149,7 @@ static inline void crypt_backend_memzero(void *s, size_t n)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Memcmp helper (memcmp in constant time) */
|
||||
int crypt_backend_memeq(const void *m1, const void *m2, size_t n);
|
||||
|
||||
#endif /* _CRYPTO_BACKEND_H */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* crypto backend implementation
|
||||
*
|
||||
* Copyright (C) 2010-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2020 Milan Broz
|
||||
* Copyright (C) 2010-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include "crypto_backend.h"
|
||||
|
||||
#if USE_INTERNAL_PBKDF2
|
||||
/* internal PBKDF2 implementation */
|
||||
int pkcs5_pbkdf2(const char *hash,
|
||||
const char *P, size_t Plen,
|
||||
@@ -31,7 +30,6 @@ int pkcs5_pbkdf2(const char *hash,
|
||||
unsigned int c,
|
||||
unsigned int dkLen, char *DK,
|
||||
unsigned int hash_block_size);
|
||||
#endif
|
||||
|
||||
/* Argon2 implementation wrapper */
|
||||
int argon2(const char *type, const char *password, size_t password_length,
|
||||
@@ -60,4 +58,18 @@ int crypt_bitlk_decrypt_key_kernel(const void *key, size_t key_length,
|
||||
const char *iv, size_t iv_length,
|
||||
const char *tag, size_t tag_length);
|
||||
|
||||
/* Internal implementation for constant time memory comparison */
|
||||
static inline int crypt_internal_memeq(const void *m1, const void *m2, size_t n)
|
||||
{
|
||||
const unsigned char *_m1 = (const unsigned char *) m1;
|
||||
const unsigned char *_m2 = (const unsigned char *) m2;
|
||||
unsigned char result = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
result |= _m1[i] ^ _m2[i];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* _CRYPTO_BACKEND_INTERNAL_H */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Linux kernel userspace API crypto backend implementation (skcipher)
|
||||
*
|
||||
* Copyright (C) 2012-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2012-2020 Milan Broz
|
||||
* Copyright (C) 2012-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2012-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -96,11 +96,14 @@ int crypt_cipher_init_kernel(struct crypt_cipher_kernel *ctx, const char *name,
|
||||
.salg_family = AF_ALG,
|
||||
.salg_type = "skcipher",
|
||||
};
|
||||
int r;
|
||||
|
||||
if (!strcmp(name, "cipher_null"))
|
||||
key_length = 0;
|
||||
|
||||
snprintf((char *)sa.salg_name, sizeof(sa.salg_name), "%s(%s)", mode, name);
|
||||
r = snprintf((char *)sa.salg_name, sizeof(sa.salg_name), "%s(%s)", mode, name);
|
||||
if (r < 0 || (size_t)r >= sizeof(sa.salg_name))
|
||||
return -EINVAL;
|
||||
|
||||
return _crypt_cipher_init(ctx, key, key_length, 0, &sa);
|
||||
}
|
||||
@@ -152,6 +155,9 @@ static int _crypt_cipher_crypt(struct crypt_cipher_kernel *ctx,
|
||||
/* Set IV */
|
||||
if (iv) {
|
||||
header = CMSG_NXTHDR(&msg, header);
|
||||
if (!header)
|
||||
return -EINVAL;
|
||||
|
||||
header->cmsg_level = SOL_ALG;
|
||||
header->cmsg_type = ALG_SET_IV;
|
||||
header->cmsg_len = iv_msg_size;
|
||||
@@ -161,15 +167,14 @@ static int _crypt_cipher_crypt(struct crypt_cipher_kernel *ctx,
|
||||
}
|
||||
|
||||
len = sendmsg(ctx->opfd, &msg, 0);
|
||||
if (len != (ssize_t)(in_length)) {
|
||||
if (len != (ssize_t)(in_length))
|
||||
r = -EIO;
|
||||
goto bad;
|
||||
else {
|
||||
len = read(ctx->opfd, out, out_length);
|
||||
if (len != (ssize_t)out_length)
|
||||
r = -EIO;
|
||||
}
|
||||
|
||||
len = read(ctx->opfd, out, out_length);
|
||||
if (len != (ssize_t)out_length)
|
||||
r = -EIO;
|
||||
bad:
|
||||
crypt_backend_memzero(buffer, sizeof(buffer));
|
||||
return r;
|
||||
}
|
||||
@@ -227,7 +232,10 @@ int crypt_cipher_check_kernel(const char *name, const char *mode,
|
||||
}
|
||||
|
||||
salg_type = aead ? "aead" : "skcipher";
|
||||
snprintf((char *)sa.salg_type, sizeof(sa.salg_type), "%s", salg_type);
|
||||
r = snprintf((char *)sa.salg_type, sizeof(sa.salg_type), "%s", salg_type);
|
||||
if (r < 0 || (size_t)r >= sizeof(sa.salg_name))
|
||||
return -EINVAL;
|
||||
|
||||
memset(tmp_salg_name, 0, sizeof(tmp_salg_name));
|
||||
|
||||
/* FIXME: this is duplicating a part of devmapper backend */
|
||||
@@ -240,7 +248,7 @@ int crypt_cipher_check_kernel(const char *name, const char *mode,
|
||||
else
|
||||
r = snprintf(tmp_salg_name, sizeof(tmp_salg_name), "%s(%s)", real_mode, name);
|
||||
|
||||
if (r <= 0 || r > (int)(sizeof(sa.salg_name) - 1))
|
||||
if (r < 0 || (size_t)r >= sizeof(tmp_salg_name))
|
||||
return -EINVAL;
|
||||
|
||||
memcpy(sa.salg_name, tmp_salg_name, sizeof(sa.salg_name));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* GCRYPT crypto backend implementation
|
||||
*
|
||||
* Copyright (C) 2010-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2020 Milan Broz
|
||||
* Copyright (C) 2010-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -51,9 +51,14 @@ struct crypt_cipher {
|
||||
} u;
|
||||
};
|
||||
|
||||
struct hash_alg {
|
||||
const char *name;
|
||||
const char *gcrypt_name;
|
||||
};
|
||||
|
||||
/*
|
||||
* Test for wrong Whirlpool variant,
|
||||
* Ref: http://lists.gnupg.org/pipermail/gcrypt-devel/2014-January/002889.html
|
||||
* Ref: https://lists.gnupg.org/pipermail/gcrypt-devel/2014-January/002889.html
|
||||
*/
|
||||
static void crypt_hash_test_whirlpool_bug(void)
|
||||
{
|
||||
@@ -89,8 +94,10 @@ static void crypt_hash_test_whirlpool_bug(void)
|
||||
crypto_backend_whirlpool_bug = 1;
|
||||
}
|
||||
|
||||
int crypt_backend_init(void)
|
||||
int crypt_backend_init(bool fips __attribute__((unused)))
|
||||
{
|
||||
int r;
|
||||
|
||||
if (crypto_backend_initialised)
|
||||
return 0;
|
||||
|
||||
@@ -99,7 +106,7 @@ int crypt_backend_init(void)
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
/* FIXME: If gcrypt compiled to support POSIX 1003.1e capabilities,
|
||||
/* If gcrypt compiled to support POSIX 1003.1e capabilities,
|
||||
* it drops all privileges during secure memory initialisation.
|
||||
* For now, the only workaround is to disable secure memory in gcrypt.
|
||||
* cryptsetup always need at least cap_sys_admin privilege for dm-ioctl
|
||||
@@ -120,11 +127,12 @@ int crypt_backend_init(void)
|
||||
crypto_backend_initialised = 1;
|
||||
crypt_hash_test_whirlpool_bug();
|
||||
|
||||
snprintf(version, 64, "gcrypt %s%s%s",
|
||||
r = snprintf(version, sizeof(version), "gcrypt %s%s%s",
|
||||
gcry_check_version(NULL),
|
||||
crypto_backend_secmem ? "" : ", secmem disabled",
|
||||
crypto_backend_whirlpool_bug > 0 ? ", flawed whirlpool" : ""
|
||||
);
|
||||
crypto_backend_whirlpool_bug > 0 ? ", flawed whirlpool" : "");
|
||||
if (r < 0 || (size_t)r >= sizeof(version))
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -150,10 +158,24 @@ uint32_t crypt_backend_flags(void)
|
||||
static const char *crypt_hash_compat_name(const char *name, unsigned int *flags)
|
||||
{
|
||||
const char *hash_name = name;
|
||||
int i;
|
||||
static struct hash_alg hash_algs[] = {
|
||||
{ "blake2b-160", "blake2b_160" },
|
||||
{ "blake2b-256", "blake2b_256" },
|
||||
{ "blake2b-384", "blake2b_384" },
|
||||
{ "blake2b-512", "blake2b_512" },
|
||||
{ "blake2s-128", "blake2s_128" },
|
||||
{ "blake2s-160", "blake2s_160" },
|
||||
{ "blake2s-224", "blake2s_224" },
|
||||
{ "blake2s-256", "blake2s_256" },
|
||||
{ NULL, NULL, }};
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
/* "whirlpool_gcryptbug" is out shortcut to flawed whirlpool
|
||||
* in libgcrypt < 1.6.0 */
|
||||
if (name && !strcasecmp(name, "whirlpool_gcryptbug")) {
|
||||
if (!strcasecmp(name, "whirlpool_gcryptbug")) {
|
||||
#if GCRYPT_VERSION_NUMBER >= 0x010601
|
||||
if (flags)
|
||||
*flags |= GCRY_MD_FLAG_BUGEMU1;
|
||||
@@ -161,6 +183,15 @@ static const char *crypt_hash_compat_name(const char *name, unsigned int *flags)
|
||||
hash_name = "whirlpool";
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (hash_algs[i].name) {
|
||||
if (!strcasecmp(name, hash_algs[i].name)) {
|
||||
hash_name = hash_algs[i].gcrypt_name;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return hash_name;
|
||||
}
|
||||
|
||||
@@ -316,7 +347,7 @@ void crypt_hmac_destroy(struct crypt_hmac *ctx)
|
||||
}
|
||||
|
||||
/* RNG */
|
||||
int crypt_backend_rng(char *buffer, size_t length, int quality, int fips)
|
||||
int crypt_backend_rng(char *buffer, size_t length, int quality, int fips __attribute__((unused)))
|
||||
{
|
||||
switch(quality) {
|
||||
case CRYPT_RND_NORMAL:
|
||||
@@ -519,3 +550,8 @@ out:
|
||||
return -ENOTSUP;
|
||||
#endif
|
||||
}
|
||||
|
||||
int crypt_backend_memeq(const void *m1, const void *m2, size_t n)
|
||||
{
|
||||
return crypt_internal_memeq(m1, m2, n);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Linux kernel userspace API crypto backend implementation
|
||||
*
|
||||
* Copyright (C) 2010-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2020 Milan Broz
|
||||
* Copyright (C) 2010-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <linux/if_alg.h>
|
||||
#include "crypto_backend_internal.h"
|
||||
|
||||
/* FIXME: remove later */
|
||||
#ifndef AF_ALG
|
||||
#define AF_ALG 38
|
||||
#endif
|
||||
@@ -62,6 +61,14 @@ static struct hash_alg hash_algs[] = {
|
||||
{ "stribog256","streebog256", 32, 64 },
|
||||
{ "stribog512","streebog512", 64, 64 },
|
||||
{ "sm3", "sm3", 32, 64 },
|
||||
{ "blake2b-160","blake2b-160",20, 128 },
|
||||
{ "blake2b-256","blake2b-256",32, 128 },
|
||||
{ "blake2b-384","blake2b-384",48, 128 },
|
||||
{ "blake2b-512","blake2b-512",64, 128 },
|
||||
{ "blake2s-128","blake2s-128",16, 64 },
|
||||
{ "blake2s-160","blake2s-160",20, 64 },
|
||||
{ "blake2s-224","blake2s-224",28, 64 },
|
||||
{ "blake2s-256","blake2s-256",32, 64 },
|
||||
{ NULL, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
@@ -110,7 +117,7 @@ static int crypt_kernel_socket_init(struct sockaddr_alg *sa, int *tfmfd, int *op
|
||||
return 0;
|
||||
}
|
||||
|
||||
int crypt_backend_init(void)
|
||||
int crypt_backend_init(bool fips __attribute__((unused)))
|
||||
{
|
||||
struct utsname uts;
|
||||
struct sockaddr_alg sa = {
|
||||
@@ -118,7 +125,7 @@ int crypt_backend_init(void)
|
||||
.salg_type = "hash",
|
||||
.salg_name = "sha256",
|
||||
};
|
||||
int tfmfd = -1, opfd = -1;
|
||||
int r, tfmfd = -1, opfd = -1;
|
||||
|
||||
if (crypto_backend_initialised)
|
||||
return 0;
|
||||
@@ -126,15 +133,17 @@ int crypt_backend_init(void)
|
||||
if (uname(&uts) == -1 || strcmp(uts.sysname, "Linux"))
|
||||
return -EINVAL;
|
||||
|
||||
r = snprintf(version, sizeof(version), "%s %s kernel cryptoAPI",
|
||||
uts.sysname, uts.release);
|
||||
if (r < 0 || (size_t)r >= sizeof(version))
|
||||
return -EINVAL;
|
||||
|
||||
if (crypt_kernel_socket_init(&sa, &tfmfd, &opfd, NULL, 0) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
close(tfmfd);
|
||||
close(opfd);
|
||||
|
||||
snprintf(version, sizeof(version), "%s %s kernel cryptoAPI",
|
||||
uts.sysname, uts.release);
|
||||
|
||||
crypto_backend_initialised = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -255,6 +264,7 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
|
||||
.salg_family = AF_ALG,
|
||||
.salg_type = "hash",
|
||||
};
|
||||
int r;
|
||||
|
||||
h = malloc(sizeof(*h));
|
||||
if (!h)
|
||||
@@ -267,8 +277,12 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
|
||||
}
|
||||
h->hash_len = ha->length;
|
||||
|
||||
snprintf((char *)sa.salg_name, sizeof(sa.salg_name),
|
||||
r = snprintf((char *)sa.salg_name, sizeof(sa.salg_name),
|
||||
"hmac(%s)", ha->kernel_name);
|
||||
if (r < 0 || (size_t)r >= sizeof(sa.salg_name)) {
|
||||
free(h);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (crypt_kernel_socket_init(&sa, &h->tfmfd, &h->opfd, key, key_length) < 0) {
|
||||
free(h);
|
||||
@@ -315,7 +329,8 @@ void crypt_hmac_destroy(struct crypt_hmac *ctx)
|
||||
}
|
||||
|
||||
/* RNG - N/A */
|
||||
int crypt_backend_rng(char *buffer, size_t length, int quality, int fips)
|
||||
int crypt_backend_rng(char *buffer __attribute__((unused)), size_t length __attribute__((unused)),
|
||||
int quality __attribute__((unused)), int fips __attribute__((unused)))
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -388,7 +403,7 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx,
|
||||
return crypt_cipher_decrypt_kernel(&ctx->ck, in, out, length, iv, iv_length);
|
||||
}
|
||||
|
||||
bool crypt_cipher_kernel_only(struct crypt_cipher *ctx)
|
||||
bool crypt_cipher_kernel_only(struct crypt_cipher *ctx __attribute__((unused)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -401,3 +416,8 @@ int crypt_bitlk_decrypt_key(const void *key, size_t key_length,
|
||||
return crypt_bitlk_decrypt_key_kernel(key, key_length, in, out, length,
|
||||
iv, iv_length, tag, tag_length);
|
||||
}
|
||||
|
||||
int crypt_backend_memeq(const void *m1, const void *m2, size_t n)
|
||||
{
|
||||
return crypt_internal_memeq(m1, m2, n);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Nettle crypto backend implementation
|
||||
*
|
||||
* Copyright (C) 2011-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2011-2020 Milan Broz
|
||||
* Copyright (C) 2011-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2011-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <nettle/sha3.h>
|
||||
#include <nettle/hmac.h>
|
||||
#include <nettle/pbkdf2.h>
|
||||
#include <nettle/memops.h>
|
||||
#include "crypto_backend_internal.h"
|
||||
|
||||
#if HAVE_NETTLE_VERSION_H
|
||||
@@ -213,7 +214,7 @@ static struct hash_alg *_get_alg(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int crypt_backend_init(void)
|
||||
int crypt_backend_init(bool fips __attribute__((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -301,12 +302,16 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
|
||||
|
||||
|
||||
h->hash = _get_alg(name);
|
||||
if (!h->hash)
|
||||
goto bad;
|
||||
if (!h->hash) {
|
||||
free(h);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
h->key = malloc(key_length);
|
||||
if (!h->key)
|
||||
goto bad;
|
||||
if (!h->key) {
|
||||
free(h);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(h->key, key, key_length);
|
||||
h->key_length = key_length;
|
||||
@@ -316,9 +321,6 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
|
||||
|
||||
*ctx = h;
|
||||
return 0;
|
||||
bad:
|
||||
free(h);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void crypt_hmac_restart(struct crypt_hmac *ctx)
|
||||
@@ -351,7 +353,10 @@ void crypt_hmac_destroy(struct crypt_hmac *ctx)
|
||||
}
|
||||
|
||||
/* RNG - N/A */
|
||||
int crypt_backend_rng(char *buffer, size_t length, int quality, int fips)
|
||||
int crypt_backend_rng(char *buffer __attribute__((unused)),
|
||||
size_t length __attribute__((unused)),
|
||||
int quality __attribute__((unused)),
|
||||
int fips __attribute__((unused)))
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -429,7 +434,7 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx,
|
||||
return crypt_cipher_decrypt_kernel(&ctx->ck, in, out, length, iv, iv_length);
|
||||
}
|
||||
|
||||
bool crypt_cipher_kernel_only(struct crypt_cipher *ctx)
|
||||
bool crypt_cipher_kernel_only(struct crypt_cipher *ctx __attribute__((unused)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -442,3 +447,9 @@ int crypt_bitlk_decrypt_key(const void *key, size_t key_length,
|
||||
return crypt_bitlk_decrypt_key_kernel(key, key_length, in, out, length,
|
||||
iv, iv_length, tag, tag_length);
|
||||
}
|
||||
|
||||
int crypt_backend_memeq(const void *m1, const void *m2, size_t n)
|
||||
{
|
||||
/* The logic is inverse to memcmp... */
|
||||
return !memeql_sec(m1, m2, n);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* NSS crypto backend implementation
|
||||
*
|
||||
* Copyright (C) 2010-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2020 Milan Broz
|
||||
* Copyright (C) 2010-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -75,8 +75,10 @@ static struct hash_alg *_get_alg(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int crypt_backend_init(void)
|
||||
int crypt_backend_init(bool fips __attribute__((unused)))
|
||||
{
|
||||
int r;
|
||||
|
||||
if (crypto_backend_initialised)
|
||||
return 0;
|
||||
|
||||
@@ -84,10 +86,13 @@ int crypt_backend_init(void)
|
||||
return -EINVAL;
|
||||
|
||||
#if HAVE_DECL_NSS_GETVERSION
|
||||
snprintf(version, 64, "NSS %s", NSS_GetVersion());
|
||||
r = snprintf(version, sizeof(version), "NSS %s", NSS_GetVersion());
|
||||
#else
|
||||
snprintf(version, 64, "NSS");
|
||||
r = snprintf(version, sizeof(version), "NSS");
|
||||
#endif
|
||||
if (r < 0 || (size_t)r >= sizeof(version))
|
||||
return -EINVAL;
|
||||
|
||||
crypto_backend_initialised = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -220,28 +225,28 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
|
||||
|
||||
h->hash = _get_alg(name);
|
||||
if (!h->hash)
|
||||
goto bad;
|
||||
goto err;
|
||||
|
||||
h->slot = PK11_GetInternalKeySlot();
|
||||
if (!h->slot)
|
||||
goto bad;
|
||||
goto err;
|
||||
|
||||
h->key = PK11_ImportSymKey(h->slot, h->hash->ck_type, PK11_OriginUnwrap,
|
||||
CKA_SIGN, &keyItem, NULL);
|
||||
if (!h->key)
|
||||
goto bad;
|
||||
goto err;
|
||||
|
||||
h->md = PK11_CreateContextBySymKey(h->hash->ck_type, CKA_SIGN, h->key,
|
||||
&noParams);
|
||||
if (!h->md)
|
||||
goto bad;
|
||||
goto err;
|
||||
|
||||
if (PK11_DigestBegin(h->md) != SECSuccess)
|
||||
goto bad;
|
||||
goto err;
|
||||
|
||||
*ctx = h;
|
||||
return 0;
|
||||
bad:
|
||||
err:
|
||||
crypt_hmac_destroy(h);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -298,7 +303,7 @@ void crypt_hmac_destroy(struct crypt_hmac *ctx)
|
||||
}
|
||||
|
||||
/* RNG */
|
||||
int crypt_backend_rng(char *buffer, size_t length, int quality, int fips)
|
||||
int crypt_backend_rng(char *buffer, size_t length, int quality __attribute__((unused)), int fips)
|
||||
{
|
||||
if (fips)
|
||||
return -EINVAL;
|
||||
@@ -377,7 +382,7 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx,
|
||||
return crypt_cipher_decrypt_kernel(&ctx->ck, in, out, length, iv, iv_length);
|
||||
}
|
||||
|
||||
bool crypt_cipher_kernel_only(struct crypt_cipher *ctx)
|
||||
bool crypt_cipher_kernel_only(struct crypt_cipher *ctx __attribute__((unused)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -390,3 +395,8 @@ int crypt_bitlk_decrypt_key(const void *key, size_t key_length,
|
||||
return crypt_bitlk_decrypt_key_kernel(key, key_length, in, out, length,
|
||||
iv, iv_length, tag, tag_length);
|
||||
}
|
||||
|
||||
int crypt_backend_memeq(const void *m1, const void *m2, size_t n)
|
||||
{
|
||||
return NSS_SecureMemcmp(m1, m2, n);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* OPENSSL crypto backend implementation
|
||||
*
|
||||
* Copyright (C) 2010-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2020 Milan Broz
|
||||
* Copyright (C) 2010-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2010-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -30,10 +30,20 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/rand.h>
|
||||
#include "crypto_backend_internal.h"
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include <openssl/core_names.h>
|
||||
static OSSL_PROVIDER *ossl_legacy = NULL;
|
||||
static OSSL_PROVIDER *ossl_default = NULL;
|
||||
static OSSL_LIB_CTX *ossl_ctx = NULL;
|
||||
static char backend_version[256] = "OpenSSL";
|
||||
#endif
|
||||
|
||||
#define CONST_CAST(x) (x)(uintptr_t)
|
||||
|
||||
@@ -46,8 +56,14 @@ struct crypt_hash {
|
||||
};
|
||||
|
||||
struct crypt_hmac {
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
EVP_MAC *mac;
|
||||
EVP_MAC_CTX *md;
|
||||
EVP_MAC_CTX *md_org;
|
||||
#else
|
||||
HMAC_CTX *md;
|
||||
const EVP_MD *hash_id;
|
||||
#endif
|
||||
int hash_len;
|
||||
};
|
||||
|
||||
@@ -58,20 +74,31 @@ struct crypt_cipher {
|
||||
struct {
|
||||
EVP_CIPHER_CTX *hd_enc;
|
||||
EVP_CIPHER_CTX *hd_dec;
|
||||
const EVP_CIPHER *cipher_type;
|
||||
size_t iv_length;
|
||||
} lib;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct hash_alg {
|
||||
const char *name;
|
||||
const char *openssl_name;
|
||||
};
|
||||
|
||||
/*
|
||||
* Compatible wrappers for OpenSSL < 1.1.0 and LibreSSL < 2.7.0
|
||||
*/
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
|
||||
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
|
||||
|
||||
static void openssl_backend_init(void)
|
||||
static int openssl_backend_init(bool fips __attribute__((unused)))
|
||||
{
|
||||
OpenSSL_add_all_algorithms();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void openssl_backend_exit(void)
|
||||
{
|
||||
}
|
||||
|
||||
static const char *openssl_backend_version(void)
|
||||
@@ -111,22 +138,79 @@ static void HMAC_CTX_free(HMAC_CTX *md)
|
||||
free(md);
|
||||
}
|
||||
#else
|
||||
static void openssl_backend_init(void)
|
||||
static void openssl_backend_exit(void)
|
||||
{
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
if (ossl_legacy)
|
||||
OSSL_PROVIDER_unload(ossl_legacy);
|
||||
if (ossl_default)
|
||||
OSSL_PROVIDER_unload(ossl_default);
|
||||
if (ossl_ctx)
|
||||
OSSL_LIB_CTX_free(ossl_ctx);
|
||||
|
||||
ossl_legacy = NULL;
|
||||
ossl_default = NULL;
|
||||
ossl_ctx = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int openssl_backend_init(bool fips)
|
||||
{
|
||||
/*
|
||||
* OpenSSL >= 3.0.0 provides some algorithms in legacy provider
|
||||
*/
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
int r;
|
||||
|
||||
/*
|
||||
* In FIPS mode we keep default OpenSSL context & global config
|
||||
*/
|
||||
if (!fips) {
|
||||
ossl_ctx = OSSL_LIB_CTX_new();
|
||||
if (!ossl_ctx)
|
||||
return -EINVAL;
|
||||
|
||||
ossl_default = OSSL_PROVIDER_try_load(ossl_ctx, "default", 0);
|
||||
if (!ossl_default) {
|
||||
OSSL_LIB_CTX_free(ossl_ctx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Optional */
|
||||
ossl_legacy = OSSL_PROVIDER_try_load(ossl_ctx, "legacy", 0);
|
||||
}
|
||||
|
||||
r = snprintf(backend_version, sizeof(backend_version), "%s %s%s%s",
|
||||
OpenSSL_version(OPENSSL_VERSION),
|
||||
ossl_default ? "[default]" : "",
|
||||
ossl_legacy ? "[legacy]" : "",
|
||||
fips ? "[fips]" : "");
|
||||
|
||||
if (r < 0 || (size_t)r >= sizeof(backend_version)) {
|
||||
openssl_backend_exit();
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *openssl_backend_version(void)
|
||||
{
|
||||
return OpenSSL_version(OPENSSL_VERSION);
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
return backend_version;
|
||||
#else
|
||||
return OpenSSL_version(OPENSSL_VERSION);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
int crypt_backend_init(void)
|
||||
int crypt_backend_init(bool fips)
|
||||
{
|
||||
if (crypto_backend_initialised)
|
||||
return 0;
|
||||
|
||||
openssl_backend_init();
|
||||
if (openssl_backend_init(fips))
|
||||
return -EINVAL;
|
||||
|
||||
crypto_backend_initialised = 1;
|
||||
return 0;
|
||||
@@ -134,7 +218,15 @@ int crypt_backend_init(void)
|
||||
|
||||
void crypt_backend_destroy(void)
|
||||
{
|
||||
/*
|
||||
* If Destructor was already called, we must not call it again
|
||||
*/
|
||||
if (!crypto_backend_initialised)
|
||||
return;
|
||||
|
||||
crypto_backend_initialised = 0;
|
||||
|
||||
openssl_backend_exit();
|
||||
}
|
||||
|
||||
uint32_t crypt_backend_flags(void)
|
||||
@@ -147,15 +239,75 @@ const char *crypt_backend_version(void)
|
||||
return openssl_backend_version();
|
||||
}
|
||||
|
||||
static const char *crypt_hash_compat_name(const char *name)
|
||||
{
|
||||
const char *hash_name = name;
|
||||
int i;
|
||||
static struct hash_alg hash_algs[] = {
|
||||
{ "blake2b-512", "blake2b512" },
|
||||
{ "blake2s-256", "blake2s256" },
|
||||
{ NULL, NULL, }};
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
i = 0;
|
||||
while (hash_algs[i].name) {
|
||||
if (!strcasecmp(name, hash_algs[i].name)) {
|
||||
hash_name = hash_algs[i].openssl_name;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return hash_name;
|
||||
}
|
||||
|
||||
static const EVP_MD *hash_id_get(const char *name)
|
||||
{
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
return EVP_MD_fetch(ossl_ctx, crypt_hash_compat_name(name), NULL);
|
||||
#else
|
||||
return EVP_get_digestbyname(crypt_hash_compat_name(name));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void hash_id_free(const EVP_MD *hash_id)
|
||||
{
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
EVP_MD_free(CONST_CAST(EVP_MD*)hash_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const EVP_CIPHER *cipher_type_get(const char *name)
|
||||
{
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
return EVP_CIPHER_fetch(ossl_ctx, name, NULL);
|
||||
#else
|
||||
return EVP_get_cipherbyname(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cipher_type_free(const EVP_CIPHER *cipher_type)
|
||||
{
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
EVP_CIPHER_free(CONST_CAST(EVP_CIPHER*)cipher_type);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* HASH */
|
||||
int crypt_hash_size(const char *name)
|
||||
{
|
||||
const EVP_MD *hash_id = EVP_get_digestbyname(name);
|
||||
int size;
|
||||
const EVP_MD *hash_id;
|
||||
|
||||
hash_id = hash_id_get(name);
|
||||
if (!hash_id)
|
||||
return -EINVAL;
|
||||
|
||||
return EVP_MD_size(hash_id);
|
||||
size = EVP_MD_size(hash_id);
|
||||
hash_id_free(hash_id);
|
||||
return size;
|
||||
}
|
||||
|
||||
int crypt_hash_init(struct crypt_hash **ctx, const char *name)
|
||||
@@ -172,7 +324,7 @@ int crypt_hash_init(struct crypt_hash **ctx, const char *name)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
h->hash_id = EVP_get_digestbyname(name);
|
||||
h->hash_id = hash_id_get(name);
|
||||
if (!h->hash_id) {
|
||||
EVP_MD_CTX_free(h->md);
|
||||
free(h);
|
||||
@@ -180,6 +332,7 @@ int crypt_hash_init(struct crypt_hash **ctx, const char *name)
|
||||
}
|
||||
|
||||
if (EVP_DigestInit_ex(h->md, h->hash_id, NULL) != 1) {
|
||||
hash_id_free(h->hash_id);
|
||||
EVP_MD_CTX_free(h->md);
|
||||
free(h);
|
||||
return -EINVAL;
|
||||
@@ -231,6 +384,7 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length)
|
||||
|
||||
void crypt_hash_destroy(struct crypt_hash *ctx)
|
||||
{
|
||||
hash_id_free(ctx->hash_id);
|
||||
EVP_MD_CTX_free(ctx->md);
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
free(ctx);
|
||||
@@ -246,7 +400,39 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
|
||||
const void *key, size_t key_length)
|
||||
{
|
||||
struct crypt_hmac *h;
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
OSSL_PARAM params[] = {
|
||||
OSSL_PARAM_utf8_string(OSSL_MAC_PARAM_DIGEST, CONST_CAST(void*)name, 0),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
|
||||
h = malloc(sizeof(*h));
|
||||
if (!h)
|
||||
return -ENOMEM;
|
||||
|
||||
h->mac = EVP_MAC_fetch(ossl_ctx, OSSL_MAC_NAME_HMAC, NULL);
|
||||
if (!h->mac) {
|
||||
free(h);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
h->md = EVP_MAC_CTX_new(h->mac);
|
||||
if (!h->md) {
|
||||
EVP_MAC_free(h->mac);
|
||||
free(h);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (EVP_MAC_init(h->md, key, key_length, params) != 1) {
|
||||
EVP_MAC_CTX_free(h->md);
|
||||
EVP_MAC_free(h->mac);
|
||||
free(h);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
h->hash_len = EVP_MAC_CTX_get_mac_size(h->md);
|
||||
h->md_org = EVP_MAC_CTX_dup(h->md);
|
||||
#else
|
||||
h = malloc(sizeof(*h));
|
||||
if (!h)
|
||||
return -ENOMEM;
|
||||
@@ -257,7 +443,7 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
h->hash_id = EVP_get_digestbyname(name);
|
||||
h->hash_id = hash_id_get(name);
|
||||
if (!h->hash_id) {
|
||||
HMAC_CTX_free(h->md);
|
||||
free(h);
|
||||
@@ -267,51 +453,82 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
|
||||
HMAC_Init_ex(h->md, key, key_length, h->hash_id, NULL);
|
||||
|
||||
h->hash_len = EVP_MD_size(h->hash_id);
|
||||
#endif
|
||||
*ctx = h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void crypt_hmac_restart(struct crypt_hmac *ctx)
|
||||
static int crypt_hmac_restart(struct crypt_hmac *ctx)
|
||||
{
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
EVP_MAC_CTX_free(ctx->md);
|
||||
ctx->md = EVP_MAC_CTX_dup(ctx->md_org);
|
||||
if (!ctx->md)
|
||||
return -EINVAL;
|
||||
#else
|
||||
HMAC_Init_ex(ctx->md, NULL, 0, ctx->hash_id, NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int crypt_hmac_write(struct crypt_hmac *ctx, const char *buffer, size_t length)
|
||||
{
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
return EVP_MAC_update(ctx->md, (const unsigned char *)buffer, length) == 1 ? 0 : -EINVAL;
|
||||
#else
|
||||
HMAC_Update(ctx->md, (const unsigned char *)buffer, length);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length)
|
||||
{
|
||||
unsigned char tmp[EVP_MAX_MD_SIZE];
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
size_t tmp_len = 0;
|
||||
|
||||
if (length > (size_t)ctx->hash_len)
|
||||
return -EINVAL;
|
||||
|
||||
if (EVP_MAC_final(ctx->md, tmp, &tmp_len, sizeof(tmp)) != 1)
|
||||
return -EINVAL;
|
||||
#else
|
||||
unsigned int tmp_len = 0;
|
||||
|
||||
if (length > (size_t)ctx->hash_len)
|
||||
return -EINVAL;
|
||||
|
||||
HMAC_Final(ctx->md, tmp, &tmp_len);
|
||||
|
||||
#endif
|
||||
memcpy(buffer, tmp, length);
|
||||
crypt_backend_memzero(tmp, sizeof(tmp));
|
||||
|
||||
if (tmp_len < length)
|
||||
return -EINVAL;
|
||||
|
||||
crypt_hmac_restart(ctx);
|
||||
if (crypt_hmac_restart(ctx))
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void crypt_hmac_destroy(struct crypt_hmac *ctx)
|
||||
{
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
EVP_MAC_CTX_free(ctx->md);
|
||||
EVP_MAC_CTX_free(ctx->md_org);
|
||||
EVP_MAC_free(ctx->mac);
|
||||
#else
|
||||
hash_id_free(ctx->hash_id);
|
||||
HMAC_CTX_free(ctx->md);
|
||||
#endif
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
/* RNG */
|
||||
int crypt_backend_rng(char *buffer, size_t length, int quality, int fips)
|
||||
int crypt_backend_rng(char *buffer, size_t length,
|
||||
int quality __attribute__((unused)), int fips __attribute__((unused)))
|
||||
{
|
||||
if (RAND_bytes((unsigned char *)buffer, length) != 1)
|
||||
return -EINVAL;
|
||||
@@ -319,48 +536,91 @@ int crypt_backend_rng(char *buffer, size_t length, int quality, int fips)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int openssl_pbkdf2(const char *password, size_t password_length,
|
||||
const char *salt, size_t salt_length, uint32_t iterations,
|
||||
const char *hash, char *key, size_t key_length)
|
||||
{
|
||||
int r;
|
||||
#if OPENSSL_VERSION_MAJOR >= 3
|
||||
EVP_KDF_CTX *ctx;
|
||||
EVP_KDF *pbkdf2;
|
||||
OSSL_PARAM params[] = {
|
||||
OSSL_PARAM_octet_string(OSSL_KDF_PARAM_PASSWORD,
|
||||
CONST_CAST(void*)password, password_length),
|
||||
OSSL_PARAM_octet_string(OSSL_KDF_PARAM_SALT,
|
||||
CONST_CAST(void*)salt, salt_length),
|
||||
OSSL_PARAM_uint32(OSSL_KDF_PARAM_ITER, &iterations),
|
||||
OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_DIGEST,
|
||||
CONST_CAST(void*)hash, 0),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
|
||||
pbkdf2 = EVP_KDF_fetch(ossl_ctx, "pbkdf2", NULL);
|
||||
if (!pbkdf2)
|
||||
return -EINVAL;
|
||||
|
||||
ctx = EVP_KDF_CTX_new(pbkdf2);
|
||||
if (!ctx) {
|
||||
EVP_KDF_free(pbkdf2);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
r = EVP_KDF_derive(ctx, (unsigned char*)key, key_length, params);
|
||||
|
||||
EVP_KDF_CTX_free(ctx);
|
||||
EVP_KDF_free(pbkdf2);
|
||||
#else
|
||||
const EVP_MD *hash_id = EVP_get_digestbyname(crypt_hash_compat_name(hash));
|
||||
if (!hash_id)
|
||||
return -EINVAL;
|
||||
|
||||
r = PKCS5_PBKDF2_HMAC(password, (int)password_length, (const unsigned char *)salt,
|
||||
(int)salt_length, iterations, hash_id, (int)key_length, (unsigned char*) key);
|
||||
#endif
|
||||
return r == 1 ? 0 : -EINVAL;
|
||||
}
|
||||
|
||||
static int openssl_argon2(const char *type, const char *password, size_t password_length,
|
||||
const char *salt, size_t salt_length, char *key, size_t key_length,
|
||||
uint32_t iterations, uint32_t memory, uint32_t parallel)
|
||||
{
|
||||
return argon2(type, password, password_length, salt, salt_length,
|
||||
key, key_length, iterations, memory, parallel);
|
||||
}
|
||||
|
||||
/* PBKDF */
|
||||
int crypt_pbkdf(const char *kdf, const char *hash,
|
||||
const char *password, size_t password_length,
|
||||
const char *salt, size_t salt_length,
|
||||
char *key, size_t key_length,
|
||||
uint32_t iterations, uint32_t memory, uint32_t parallel)
|
||||
|
||||
{
|
||||
const EVP_MD *hash_id;
|
||||
|
||||
if (!kdf)
|
||||
return -EINVAL;
|
||||
|
||||
if (!strcmp(kdf, "pbkdf2")) {
|
||||
hash_id = EVP_get_digestbyname(hash);
|
||||
if (!hash_id)
|
||||
return -EINVAL;
|
||||
|
||||
if (!PKCS5_PBKDF2_HMAC(password, (int)password_length,
|
||||
(const unsigned char *)salt, (int)salt_length,
|
||||
(int)iterations, hash_id, (int)key_length, (unsigned char *)key))
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
} else if (!strncmp(kdf, "argon2", 6)) {
|
||||
return argon2(kdf, password, password_length, salt, salt_length,
|
||||
key, key_length, iterations, memory, parallel);
|
||||
}
|
||||
|
||||
if (!strcmp(kdf, "pbkdf2"))
|
||||
return openssl_pbkdf2(password, password_length, salt, salt_length,
|
||||
iterations, hash, key, key_length);
|
||||
if (!strncmp(kdf, "argon2", 6))
|
||||
return openssl_argon2(kdf, password, password_length, salt, salt_length,
|
||||
key, key_length, iterations, memory, parallel);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Block ciphers */
|
||||
static void _cipher_destroy(EVP_CIPHER_CTX **hd_enc, EVP_CIPHER_CTX **hd_dec)
|
||||
static void _cipher_destroy(EVP_CIPHER_CTX **hd_enc, EVP_CIPHER_CTX **hd_dec, const EVP_CIPHER **cipher_type)
|
||||
{
|
||||
EVP_CIPHER_CTX_free(*hd_enc);
|
||||
*hd_enc = NULL;
|
||||
|
||||
EVP_CIPHER_CTX_free(*hd_dec);
|
||||
*hd_dec = NULL;
|
||||
|
||||
cipher_type_free(*cipher_type);
|
||||
*cipher_type = NULL;
|
||||
}
|
||||
|
||||
static int _cipher_init(EVP_CIPHER_CTX **hd_enc, EVP_CIPHER_CTX **hd_dec, const char *name,
|
||||
static int _cipher_init(EVP_CIPHER_CTX **hd_enc, EVP_CIPHER_CTX **hd_dec, const EVP_CIPHER **cipher_type, const char *name,
|
||||
const char *mode, const void *key, size_t key_length, size_t *iv_length)
|
||||
{
|
||||
char cipher_name[256];
|
||||
@@ -372,35 +632,41 @@ static int _cipher_init(EVP_CIPHER_CTX **hd_enc, EVP_CIPHER_CTX **hd_dec, const
|
||||
key_bits /= 2;
|
||||
|
||||
r = snprintf(cipher_name, sizeof(cipher_name), "%s-%d-%s", name, key_bits, mode);
|
||||
if (r < 0 || r >= (int)sizeof(cipher_name))
|
||||
if (r < 0 || (size_t)r >= sizeof(cipher_name))
|
||||
return -EINVAL;
|
||||
|
||||
type = EVP_get_cipherbyname(cipher_name);
|
||||
type = cipher_type_get(cipher_name);
|
||||
if (!type)
|
||||
return -ENOENT;
|
||||
|
||||
if (EVP_CIPHER_key_length(type) != (int)key_length)
|
||||
if (EVP_CIPHER_key_length(type) != (int)key_length) {
|
||||
cipher_type_free(type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*hd_enc = EVP_CIPHER_CTX_new();
|
||||
*hd_dec = EVP_CIPHER_CTX_new();
|
||||
*iv_length = EVP_CIPHER_iv_length(type);
|
||||
|
||||
if (!*hd_enc || !*hd_dec)
|
||||
if (!*hd_enc || !*hd_dec) {
|
||||
cipher_type_free(type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (EVP_EncryptInit_ex(*hd_enc, type, NULL, key, NULL) != 1 ||
|
||||
EVP_DecryptInit_ex(*hd_dec, type, NULL, key, NULL) != 1) {
|
||||
_cipher_destroy(hd_enc, hd_dec);
|
||||
_cipher_destroy(hd_enc, hd_dec, &type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (EVP_CIPHER_CTX_set_padding(*hd_enc, 0) != 1 ||
|
||||
EVP_CIPHER_CTX_set_padding(*hd_dec, 0) != 1) {
|
||||
_cipher_destroy(hd_enc, hd_dec);
|
||||
_cipher_destroy(hd_enc, hd_dec, &type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*cipher_type = type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -414,7 +680,7 @@ int crypt_cipher_init(struct crypt_cipher **ctx, const char *name,
|
||||
if (!h)
|
||||
return -ENOMEM;
|
||||
|
||||
if (!_cipher_init(&h->u.lib.hd_enc, &h->u.lib.hd_dec, name, mode, key,
|
||||
if (!_cipher_init(&h->u.lib.hd_enc, &h->u.lib.hd_dec, &h->u.lib.cipher_type, name, mode, key,
|
||||
key_length, &h->u.lib.iv_length)) {
|
||||
h->use_kernel = false;
|
||||
*ctx = h;
|
||||
@@ -437,7 +703,7 @@ void crypt_cipher_destroy(struct crypt_cipher *ctx)
|
||||
if (ctx->use_kernel)
|
||||
crypt_cipher_destroy_kernel(&ctx->u.kernel);
|
||||
else
|
||||
_cipher_destroy(&ctx->u.lib.hd_enc, &ctx->u.lib.hd_dec);
|
||||
_cipher_destroy(&ctx->u.lib.hd_enc, &ctx->u.lib.hd_dec, &ctx->u.lib.cipher_type);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
@@ -508,7 +774,7 @@ bool crypt_cipher_kernel_only(struct crypt_cipher *ctx)
|
||||
return ctx->use_kernel;
|
||||
}
|
||||
|
||||
int crypt_bitlk_decrypt_key(const void *key, size_t key_length,
|
||||
int crypt_bitlk_decrypt_key(const void *key, size_t key_length __attribute__((unused)),
|
||||
const char *in, char *out, size_t length,
|
||||
const char *iv, size_t iv_length,
|
||||
const char *tag, size_t tag_length)
|
||||
@@ -524,9 +790,6 @@ int crypt_bitlk_decrypt_key(const void *key, size_t key_length,
|
||||
if (EVP_DecryptInit_ex(ctx, EVP_aes_256_ccm(), NULL, NULL, NULL) != 1)
|
||||
goto out;
|
||||
|
||||
//EVP_CIPHER_CTX_key_length(ctx)
|
||||
//EVP_CIPHER_CTX_iv_length(ctx)
|
||||
|
||||
if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_IVLEN, iv_length, NULL) != 1)
|
||||
goto out;
|
||||
if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG, tag_length, CONST_CAST(void*)tag) != 1)
|
||||
@@ -544,3 +807,8 @@ out:
|
||||
return -ENOTSUP;
|
||||
#endif
|
||||
}
|
||||
|
||||
int crypt_backend_memeq(const void *m1, const void *m2, size_t n)
|
||||
{
|
||||
return CRYPTO_memcmp(m1, m2, n);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Generic wrapper for storage encryption modes and Initial Vectors
|
||||
* (reimplementation of some functions from Linux dm-crypt kernel)
|
||||
*
|
||||
* Copyright (C) 2014-2020 Milan Broz
|
||||
* Copyright (C) 2014-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <strings.h>
|
||||
#include "bitops.h"
|
||||
#include "crypto_backend.h"
|
||||
|
||||
@@ -40,7 +41,7 @@ struct crypt_sector_iv {
|
||||
|
||||
/* Block encryption storage context */
|
||||
struct crypt_storage {
|
||||
unsigned sector_shift;
|
||||
size_t sector_size;
|
||||
unsigned iv_shift;
|
||||
struct crypt_cipher *cipher;
|
||||
struct crypt_sector_iv cipher_iv;
|
||||
@@ -56,14 +57,15 @@ static int int_log2(unsigned int x)
|
||||
|
||||
static int crypt_sector_iv_init(struct crypt_sector_iv *ctx,
|
||||
const char *cipher_name, const char *mode_name,
|
||||
const char *iv_name, const void *key, size_t key_length, size_t sector_size)
|
||||
const char *iv_name, const void *key, size_t key_length,
|
||||
size_t sector_size)
|
||||
{
|
||||
int r;
|
||||
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
|
||||
ctx->iv_size = crypt_cipher_ivsize(cipher_name, mode_name);
|
||||
if (ctx->iv_size < 8)
|
||||
if (ctx->iv_size < 0 || (strcmp(mode_name, "ecb") && ctx->iv_size < 8))
|
||||
return -ENOENT;
|
||||
|
||||
if (!strcmp(cipher_name, "cipher_null") ||
|
||||
@@ -149,7 +151,8 @@ static int crypt_sector_iv_init(struct crypt_sector_iv *ctx,
|
||||
|
||||
static int crypt_sector_iv_generate(struct crypt_sector_iv *ctx, uint64_t sector)
|
||||
{
|
||||
uint64_t val;
|
||||
uint64_t val, *u64_iv;
|
||||
uint32_t *u32_iv;
|
||||
|
||||
switch (ctx->type) {
|
||||
case IV_NONE:
|
||||
@@ -159,19 +162,24 @@ static int crypt_sector_iv_generate(struct crypt_sector_iv *ctx, uint64_t sector
|
||||
break;
|
||||
case IV_PLAIN:
|
||||
memset(ctx->iv, 0, ctx->iv_size);
|
||||
*(uint32_t *)ctx->iv = cpu_to_le32(sector & 0xffffffff);
|
||||
u32_iv = (void *)ctx->iv;
|
||||
*u32_iv = cpu_to_le32(sector & 0xffffffff);
|
||||
break;
|
||||
case IV_PLAIN64:
|
||||
memset(ctx->iv, 0, ctx->iv_size);
|
||||
*(uint64_t *)ctx->iv = cpu_to_le64(sector);
|
||||
u64_iv = (void *)ctx->iv;
|
||||
*u64_iv = cpu_to_le64(sector);
|
||||
break;
|
||||
case IV_PLAIN64BE:
|
||||
memset(ctx->iv, 0, ctx->iv_size);
|
||||
*(uint64_t *)&ctx->iv[ctx->iv_size - sizeof(uint64_t)] = cpu_to_be64(sector);
|
||||
/* iv_size is at least of size u64; usually it is 16 bytes */
|
||||
u64_iv = (void *)&ctx->iv[ctx->iv_size - sizeof(uint64_t)];
|
||||
*u64_iv = cpu_to_be64(sector);
|
||||
break;
|
||||
case IV_ESSIV:
|
||||
memset(ctx->iv, 0, ctx->iv_size);
|
||||
*(uint64_t *)ctx->iv = cpu_to_le64(sector);
|
||||
u64_iv = (void *)ctx->iv;
|
||||
*u64_iv = cpu_to_le64(sector);
|
||||
return crypt_cipher_encrypt(ctx->cipher,
|
||||
ctx->iv, ctx->iv, ctx->iv_size, NULL, 0);
|
||||
break;
|
||||
@@ -182,7 +190,8 @@ static int crypt_sector_iv_generate(struct crypt_sector_iv *ctx, uint64_t sector
|
||||
break;
|
||||
case IV_EBOIV:
|
||||
memset(ctx->iv, 0, ctx->iv_size);
|
||||
*(uint64_t *)ctx->iv = cpu_to_le64(sector << ctx->shift);
|
||||
u64_iv = (void *)ctx->iv;
|
||||
*u64_iv = cpu_to_le64(sector << ctx->shift);
|
||||
return crypt_cipher_encrypt(ctx->cipher,
|
||||
ctx->iv, ctx->iv, ctx->iv_size, NULL, 0);
|
||||
break;
|
||||
@@ -212,7 +221,8 @@ int crypt_storage_init(struct crypt_storage **ctx,
|
||||
size_t sector_size,
|
||||
const char *cipher,
|
||||
const char *cipher_mode,
|
||||
const void *key, size_t key_length)
|
||||
const void *key, size_t key_length,
|
||||
bool large_iv)
|
||||
{
|
||||
struct crypt_storage *s;
|
||||
char mode_name[64];
|
||||
@@ -250,8 +260,8 @@ int crypt_storage_init(struct crypt_storage **ctx,
|
||||
return r;
|
||||
}
|
||||
|
||||
s->sector_shift = int_log2(sector_size);
|
||||
s->iv_shift = s->sector_shift - SECTOR_SHIFT;
|
||||
s->sector_size = sector_size;
|
||||
s->iv_shift = large_iv ? int_log2(sector_size) - SECTOR_SHIFT : 0;
|
||||
|
||||
*ctx = s;
|
||||
return 0;
|
||||
@@ -264,19 +274,20 @@ int crypt_storage_decrypt(struct crypt_storage *ctx,
|
||||
uint64_t i;
|
||||
int r = 0;
|
||||
|
||||
if (length & ((1 << ctx->sector_shift) - 1))
|
||||
if (length & (ctx->sector_size - 1))
|
||||
return -EINVAL;
|
||||
|
||||
length >>= ctx->sector_shift;
|
||||
if (iv_offset & ((ctx->sector_size >> SECTOR_SHIFT) - 1))
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
r = crypt_sector_iv_generate(&ctx->cipher_iv, iv_offset + (uint64_t)(i << ctx->iv_shift));
|
||||
for (i = 0; i < length; i += ctx->sector_size) {
|
||||
r = crypt_sector_iv_generate(&ctx->cipher_iv, (iv_offset + (i >> SECTOR_SHIFT)) >> ctx->iv_shift);
|
||||
if (r)
|
||||
break;
|
||||
r = crypt_cipher_decrypt(ctx->cipher,
|
||||
&buffer[i << ctx->sector_shift],
|
||||
&buffer[i << ctx->sector_shift],
|
||||
1 << ctx->sector_shift,
|
||||
&buffer[i],
|
||||
&buffer[i],
|
||||
ctx->sector_size,
|
||||
ctx->cipher_iv.iv,
|
||||
ctx->cipher_iv.iv_size);
|
||||
if (r)
|
||||
@@ -293,19 +304,20 @@ int crypt_storage_encrypt(struct crypt_storage *ctx,
|
||||
uint64_t i;
|
||||
int r = 0;
|
||||
|
||||
if (length & ((1 << ctx->sector_shift) - 1))
|
||||
if (length & (ctx->sector_size - 1))
|
||||
return -EINVAL;
|
||||
|
||||
length >>= ctx->sector_shift;
|
||||
if (iv_offset & ((ctx->sector_size >> SECTOR_SHIFT) - 1))
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
r = crypt_sector_iv_generate(&ctx->cipher_iv, iv_offset + (i << ctx->iv_shift));
|
||||
for (i = 0; i < length; i += ctx->sector_size) {
|
||||
r = crypt_sector_iv_generate(&ctx->cipher_iv, (iv_offset + (i >> SECTOR_SHIFT)) >> ctx->iv_shift);
|
||||
if (r)
|
||||
break;
|
||||
r = crypt_cipher_encrypt(ctx->cipher,
|
||||
&buffer[i << ctx->sector_shift],
|
||||
&buffer[i << ctx->sector_shift],
|
||||
1 << ctx->sector_shift,
|
||||
&buffer[i],
|
||||
&buffer[i],
|
||||
ctx->sector_size,
|
||||
ctx->cipher_iv.iv,
|
||||
ctx->cipher_iv.iv_size);
|
||||
if (r)
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Copyright (C) 2004 Free Software Foundation
|
||||
*
|
||||
* cryptsetup related changes
|
||||
* Copyright (C) 2012-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2012-2020 Milan Broz
|
||||
* Copyright (C) 2012-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2012-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* PBKDF performance check
|
||||
* Copyright (C) 2012-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2012-2020 Milan Broz
|
||||
* Copyright (C) 2012-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2012-2022 Milan Broz
|
||||
* Copyright (C) 2016-2020 Ondrej Mosnacek
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
@@ -48,6 +48,7 @@ int crypt_pbkdf_get_limits(const char *kdf, struct crypt_pbkdf_limits *limits)
|
||||
limits->min_iterations = 1000; /* recommendation in NIST SP 800-132 */
|
||||
limits->max_iterations = UINT32_MAX;
|
||||
limits->min_memory = 0; /* N/A */
|
||||
limits->min_bench_memory=0; /* N/A */
|
||||
limits->max_memory = 0; /* N/A */
|
||||
limits->min_parallel = 0; /* N/A */
|
||||
limits->max_parallel = 0; /* N/A */
|
||||
@@ -55,7 +56,8 @@ int crypt_pbkdf_get_limits(const char *kdf, struct crypt_pbkdf_limits *limits)
|
||||
} else if (!strcmp(kdf, "argon2i") || !strcmp(kdf, "argon2id")) {
|
||||
limits->min_iterations = 4;
|
||||
limits->max_iterations = UINT32_MAX;
|
||||
limits->min_memory = 32;
|
||||
limits->min_memory = 32; /* hard limit */
|
||||
limits->min_bench_memory=64*1024; /* 64 MiB minimum for benchmark */
|
||||
limits->max_memory = 4*1024*1024; /* 4GiB */
|
||||
limits->min_parallel = 1;
|
||||
limits->max_parallel = 4;
|
||||
@@ -74,7 +76,7 @@ static long time_ms(struct rusage *start, struct rusage *end)
|
||||
count_kernel_time = 1;
|
||||
|
||||
/*
|
||||
* FIXME: if there is no self usage info, count system time.
|
||||
* If there is no self usage info, count system time.
|
||||
* This seem like getrusage() bug in some hypervisors...
|
||||
*/
|
||||
if (!end->ru_utime.tv_sec && !start->ru_utime.tv_sec &&
|
||||
@@ -361,8 +363,10 @@ static int crypt_pbkdf_check(const char *kdf, const char *hash,
|
||||
ms = time_ms(&rstart, &rend);
|
||||
if (ms) {
|
||||
PBKDF2_temp = (double)iterations * target_ms / ms;
|
||||
if (PBKDF2_temp > UINT32_MAX)
|
||||
return -EINVAL;
|
||||
if (PBKDF2_temp > UINT32_MAX) {
|
||||
r = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
*iter_secs = (uint32_t)PBKDF2_temp;
|
||||
}
|
||||
|
||||
@@ -406,15 +410,19 @@ int crypt_pbkdf_perf(const char *kdf, const char *hash,
|
||||
{
|
||||
struct crypt_pbkdf_limits pbkdf_limits;
|
||||
int r = -EINVAL;
|
||||
uint32_t min_memory;
|
||||
|
||||
if (!kdf || !iterations_out || !memory_out)
|
||||
return -EINVAL;
|
||||
|
||||
/* FIXME: whole limits propagation should be more clear here */
|
||||
r = crypt_pbkdf_get_limits(kdf, &pbkdf_limits);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
min_memory = pbkdf_limits.min_bench_memory;
|
||||
if (min_memory > max_memory_kb)
|
||||
min_memory = max_memory_kb;
|
||||
|
||||
*memory_out = 0;
|
||||
*iterations_out = 0;
|
||||
|
||||
@@ -427,7 +435,7 @@ int crypt_pbkdf_perf(const char *kdf, const char *hash,
|
||||
r = crypt_argon2_check(kdf, password, password_size,
|
||||
salt, salt_size, volume_key_size,
|
||||
pbkdf_limits.min_iterations,
|
||||
pbkdf_limits.min_memory,
|
||||
min_memory,
|
||||
max_memory_kb,
|
||||
parallel_threads, time_ms, iterations_out,
|
||||
memory_out, progress, usrptr);
|
||||
|
||||
289
lib/crypto_backend/utf8.c
Normal file
289
lib/crypto_backend/utf8.c
Normal file
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* UTF8/16 helpers, copied and adapted from systemd project.
|
||||
*
|
||||
* Copyright (C) 2010 Lennart Poettering
|
||||
*
|
||||
* cryptsetup related changes
|
||||
* Copyright (C) 2021-2022 Vojtech Trefny
|
||||
|
||||
* Parts of the original systemd implementation are based on the GLIB utf8
|
||||
* validation functions.
|
||||
* gutf8.c - Operations on UTF-8 strings.
|
||||
*
|
||||
* Copyright (C) 1999 Tom Tromey
|
||||
* Copyright (C) 2000 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <endian.h>
|
||||
|
||||
#include "crypto_backend.h"
|
||||
|
||||
static inline bool utf16_is_surrogate(char16_t c)
|
||||
{
|
||||
return c >= 0xd800U && c <= 0xdfffU;
|
||||
}
|
||||
|
||||
static inline bool utf16_is_trailing_surrogate(char16_t c)
|
||||
{
|
||||
return c >= 0xdc00U && c <= 0xdfffU;
|
||||
}
|
||||
|
||||
static inline char32_t utf16_surrogate_pair_to_unichar(char16_t lead, char16_t trail)
|
||||
{
|
||||
return ((((char32_t) lead - 0xd800U) << 10) + ((char32_t) trail - 0xdc00U) + 0x10000U);
|
||||
}
|
||||
|
||||
/**
|
||||
* utf8_encode_unichar() - Encode single UCS-4 character as UTF-8
|
||||
* @out_utf8: output buffer of at least 4 bytes or NULL
|
||||
* @g: UCS-4 character to encode
|
||||
*
|
||||
* This encodes a single UCS-4 character as UTF-8 and writes it into @out_utf8.
|
||||
* The length of the character is returned. It is not zero-terminated! If the
|
||||
* output buffer is NULL, only the length is returned.
|
||||
*
|
||||
* Returns: The length in bytes that the UTF-8 representation does or would
|
||||
* occupy.
|
||||
*/
|
||||
static size_t utf8_encode_unichar(char *out_utf8, char32_t g)
|
||||
{
|
||||
if (g < (1 << 7)) {
|
||||
if (out_utf8)
|
||||
out_utf8[0] = g & 0x7f;
|
||||
return 1;
|
||||
} else if (g < (1 << 11)) {
|
||||
if (out_utf8) {
|
||||
out_utf8[0] = 0xc0 | ((g >> 6) & 0x1f);
|
||||
out_utf8[1] = 0x80 | (g & 0x3f);
|
||||
}
|
||||
return 2;
|
||||
} else if (g < (1 << 16)) {
|
||||
if (out_utf8) {
|
||||
out_utf8[0] = 0xe0 | ((g >> 12) & 0x0f);
|
||||
out_utf8[1] = 0x80 | ((g >> 6) & 0x3f);
|
||||
out_utf8[2] = 0x80 | (g & 0x3f);
|
||||
}
|
||||
return 3;
|
||||
} else if (g < (1 << 21)) {
|
||||
if (out_utf8) {
|
||||
out_utf8[0] = 0xf0 | ((g >> 18) & 0x07);
|
||||
out_utf8[1] = 0x80 | ((g >> 12) & 0x3f);
|
||||
out_utf8[2] = 0x80 | ((g >> 6) & 0x3f);
|
||||
out_utf8[3] = 0x80 | (g & 0x3f);
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* crypt_utf16_to_utf8()
|
||||
* @out: output buffer, should be 2 * @length + 1 long
|
||||
* @s: string to convert
|
||||
* @length: length of @s in bytes
|
||||
*
|
||||
* Converts a UTF16LE encoded string to a UTF8 encoded string.
|
||||
*
|
||||
* Returns: 0 on success, negative errno otherwise
|
||||
*/
|
||||
int crypt_utf16_to_utf8(char **out, const char16_t *s, size_t length /* bytes! */)
|
||||
{
|
||||
const uint8_t *f;
|
||||
char *t;
|
||||
|
||||
assert(s);
|
||||
assert(out);
|
||||
assert(*out);
|
||||
|
||||
/* Input length is in bytes, i.e. the shortest possible character takes 2 bytes. Each unicode character may
|
||||
* take up to 4 bytes in UTF-8. Let's also account for a trailing NUL byte. */
|
||||
if (length * 2 < length)
|
||||
return -EOVERFLOW; /* overflow */
|
||||
|
||||
f = (const uint8_t*) s;
|
||||
t = *out;
|
||||
|
||||
while (f + 1 < (const uint8_t*) s + length) {
|
||||
char16_t w1, w2;
|
||||
|
||||
/* see RFC 2781 section 2.2 */
|
||||
|
||||
w1 = f[1] << 8 | f[0];
|
||||
f += 2;
|
||||
|
||||
if (!utf16_is_surrogate(w1)) {
|
||||
t += utf8_encode_unichar(t, w1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (utf16_is_trailing_surrogate(w1))
|
||||
continue; /* spurious trailing surrogate, ignore */
|
||||
|
||||
if (f + 1 >= (const uint8_t*) s + length)
|
||||
break;
|
||||
|
||||
w2 = f[1] << 8 | f[0];
|
||||
f += 2;
|
||||
|
||||
if (!utf16_is_trailing_surrogate(w2)) {
|
||||
f -= 2;
|
||||
continue; /* surrogate missing its trailing surrogate, ignore */
|
||||
}
|
||||
|
||||
t += utf8_encode_unichar(t, utf16_surrogate_pair_to_unichar(w1, w2));
|
||||
}
|
||||
|
||||
*t = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* count of characters used to encode one unicode char */
|
||||
static size_t utf8_encoded_expected_len(uint8_t c)
|
||||
{
|
||||
if (c < 0x80)
|
||||
return 1;
|
||||
if ((c & 0xe0) == 0xc0)
|
||||
return 2;
|
||||
if ((c & 0xf0) == 0xe0)
|
||||
return 3;
|
||||
if ((c & 0xf8) == 0xf0)
|
||||
return 4;
|
||||
if ((c & 0xfc) == 0xf8)
|
||||
return 5;
|
||||
if ((c & 0xfe) == 0xfc)
|
||||
return 6;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* decode one unicode char */
|
||||
static int utf8_encoded_to_unichar(const char *str, char32_t *ret_unichar)
|
||||
{
|
||||
char32_t unichar;
|
||||
size_t len, i;
|
||||
|
||||
assert(str);
|
||||
|
||||
len = utf8_encoded_expected_len(str[0]);
|
||||
|
||||
switch (len) {
|
||||
case 1:
|
||||
*ret_unichar = (char32_t)str[0];
|
||||
return 0;
|
||||
case 2:
|
||||
unichar = str[0] & 0x1f;
|
||||
break;
|
||||
case 3:
|
||||
unichar = (char32_t)str[0] & 0x0f;
|
||||
break;
|
||||
case 4:
|
||||
unichar = (char32_t)str[0] & 0x07;
|
||||
break;
|
||||
case 5:
|
||||
unichar = (char32_t)str[0] & 0x03;
|
||||
break;
|
||||
case 6:
|
||||
unichar = (char32_t)str[0] & 0x01;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 1; i < len; i++) {
|
||||
if (((char32_t)str[i] & 0xc0) != 0x80)
|
||||
return -EINVAL;
|
||||
|
||||
unichar <<= 6;
|
||||
unichar |= (char32_t)str[i] & 0x3f;
|
||||
}
|
||||
|
||||
*ret_unichar = unichar;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t utf16_encode_unichar(char16_t *out, char32_t c)
|
||||
{
|
||||
/* Note that this encodes as little-endian. */
|
||||
|
||||
switch (c) {
|
||||
|
||||
case 0 ... 0xd7ffU:
|
||||
case 0xe000U ... 0xffffU:
|
||||
out[0] = htole16(c);
|
||||
return 1;
|
||||
|
||||
case 0x10000U ... 0x10ffffU:
|
||||
c -= 0x10000U;
|
||||
out[0] = htole16((c >> 10) + 0xd800U);
|
||||
out[1] = htole16((c & 0x3ffU) + 0xdc00U);
|
||||
return 2;
|
||||
|
||||
default: /* A surrogate (invalid) */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* crypt_utf8_to_utf16()
|
||||
* @out: output buffer, should be @length + 1 long
|
||||
* @s: string to convert
|
||||
* @length: length of @s in bytes
|
||||
*
|
||||
* Converts a UTF8 encoded string to a UTF16LE encoded string.
|
||||
*
|
||||
* Returns: 0 on success, negative errno otherwise
|
||||
*/
|
||||
int crypt_utf8_to_utf16(char16_t **out, const char *s, size_t length)
|
||||
{
|
||||
char16_t *p;
|
||||
size_t i;
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
|
||||
p = *out;
|
||||
|
||||
for (i = 0; i < length;) {
|
||||
char32_t unichar;
|
||||
size_t e;
|
||||
|
||||
e = utf8_encoded_expected_len(s[i]);
|
||||
if (e <= 1) /* Invalid and single byte characters are copied as they are */
|
||||
goto copy;
|
||||
|
||||
if (i + e > length) /* sequence longer than input buffer, then copy as-is */
|
||||
goto copy;
|
||||
|
||||
r = utf8_encoded_to_unichar(s + i, &unichar);
|
||||
if (r < 0) /* sequence invalid, then copy as-is */
|
||||
goto copy;
|
||||
|
||||
p += utf16_encode_unichar(p, unichar);
|
||||
i += e;
|
||||
continue;
|
||||
|
||||
copy:
|
||||
*(p++) = htole16(s[i++]);
|
||||
}
|
||||
|
||||
*p = 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Integrity volume handling
|
||||
*
|
||||
* Copyright (C) 2016-2020 Milan Broz
|
||||
* Copyright (C) 2016-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -27,6 +27,17 @@
|
||||
#include "integrity.h"
|
||||
#include "internal.h"
|
||||
|
||||
/* For LUKS2, integrity metadata are on DATA device even for detached header! */
|
||||
static struct device *INTEGRITY_metadata_device(struct crypt_device *cd)
|
||||
{
|
||||
const char *type = crypt_get_type(cd);
|
||||
|
||||
if (type && !strcmp(type, CRYPT_LUKS2))
|
||||
return crypt_data_device(cd);
|
||||
|
||||
return crypt_metadata_device(cd);
|
||||
}
|
||||
|
||||
static int INTEGRITY_read_superblock(struct crypt_device *cd,
|
||||
struct device *device,
|
||||
uint64_t offset, struct superblock *sb)
|
||||
@@ -38,11 +49,13 @@ static int INTEGRITY_read_superblock(struct crypt_device *cd,
|
||||
return -EINVAL;
|
||||
|
||||
if (read_lseek_blockwise(devfd, device_block_size(cd, device),
|
||||
device_alignment(device), sb, sizeof(*sb), offset) != sizeof(*sb) ||
|
||||
memcmp(sb->magic, SB_MAGIC, sizeof(sb->magic)) ||
|
||||
sb->version < SB_VERSION_1 || sb->version > SB_VERSION_4) {
|
||||
log_std(cd, "No integrity superblock detected on %s.\n",
|
||||
device_path(device));
|
||||
device_alignment(device), sb, sizeof(*sb), offset) != sizeof(*sb) ||
|
||||
memcmp(sb->magic, SB_MAGIC, sizeof(sb->magic))) {
|
||||
log_dbg(cd, "No kernel dm-integrity metadata detected on %s.", device_path(device));
|
||||
r = -EINVAL;
|
||||
} else if (sb->version < SB_VERSION_1 || sb->version > SB_VERSION_5) {
|
||||
log_err(cd, _("Incompatible kernel dm-integrity metadata (version %u) detected on %s."),
|
||||
sb->version, device_path(device));
|
||||
r = -EINVAL;
|
||||
} else {
|
||||
sb->integrity_tag_size = le16toh(sb->integrity_tag_size);
|
||||
@@ -63,7 +76,7 @@ int INTEGRITY_read_sb(struct crypt_device *cd,
|
||||
struct superblock sb;
|
||||
int r;
|
||||
|
||||
r = INTEGRITY_read_superblock(cd, crypt_metadata_device(cd), 0, &sb);
|
||||
r = INTEGRITY_read_superblock(cd, INTEGRITY_metadata_device(cd), 0, &sb);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
@@ -92,14 +105,15 @@ int INTEGRITY_dump(struct crypt_device *cd, struct device *device, uint64_t offs
|
||||
log_std(cd, "journal_sections %u\n", sb.journal_sections);
|
||||
log_std(cd, "provided_data_sectors %" PRIu64 "\n", sb.provided_data_sectors);
|
||||
log_std(cd, "sector_size %u\n", SECTOR_SIZE << sb.log2_sectors_per_block);
|
||||
if (sb.version == SB_VERSION_2 && (sb.flags & SB_FLAG_RECALCULATING))
|
||||
if (sb.version >= SB_VERSION_2 && (sb.flags & SB_FLAG_RECALCULATING))
|
||||
log_std(cd, "recalc_sector %" PRIu64 "\n", sb.recalc_sector);
|
||||
log_std(cd, "log2_blocks_per_bitmap %u\n", sb.log2_blocks_per_bitmap_bit);
|
||||
log_std(cd, "flags %s%s%s%s\n",
|
||||
log_std(cd, "flags %s%s%s%s%s\n",
|
||||
sb.flags & SB_FLAG_HAVE_JOURNAL_MAC ? "have_journal_mac " : "",
|
||||
sb.flags & SB_FLAG_RECALCULATING ? "recalculating " : "",
|
||||
sb.flags & SB_FLAG_DIRTY_BITMAP ? "dirty_bitmap " : "",
|
||||
sb.flags & SB_FLAG_FIXED_PADDING ? "fix_padding " : "");
|
||||
sb.flags & SB_FLAG_FIXED_PADDING ? "fix_padding " : "",
|
||||
sb.flags & SB_FLAG_FIXED_HMAC ? "fix_hmac " : "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -119,7 +133,7 @@ int INTEGRITY_data_sectors(struct crypt_device *cd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int INTEGRITY_key_size(struct crypt_device *cd, const char *integrity)
|
||||
int INTEGRITY_key_size(const char *integrity)
|
||||
{
|
||||
if (!integrity)
|
||||
return 0;
|
||||
@@ -153,6 +167,9 @@ int INTEGRITY_hash_tag_size(const char *integrity)
|
||||
if (!strcmp(integrity, "crc32") || !strcmp(integrity, "crc32c"))
|
||||
return 4;
|
||||
|
||||
if (!strcmp(integrity, "xxhash64"))
|
||||
return 8;
|
||||
|
||||
r = sscanf(integrity, "hmac(%" MAX_CIPHER_LEN_STR "[^)]s", hash);
|
||||
if (r == 1)
|
||||
r = crypt_hash_size(hash);
|
||||
@@ -162,8 +179,7 @@ int INTEGRITY_hash_tag_size(const char *integrity)
|
||||
return r < 0 ? 0 : r;
|
||||
}
|
||||
|
||||
int INTEGRITY_tag_size(struct crypt_device *cd,
|
||||
const char *integrity,
|
||||
int INTEGRITY_tag_size(const char *integrity,
|
||||
const char *cipher,
|
||||
const char *cipher_mode)
|
||||
{
|
||||
@@ -188,7 +204,7 @@ int INTEGRITY_tag_size(struct crypt_device *cd,
|
||||
if (!integrity || !strcmp(integrity, "none"))
|
||||
auth_tag_size = 0;
|
||||
else if (!strcmp(integrity, "aead"))
|
||||
auth_tag_size = 16; //FIXME gcm- mode only
|
||||
auth_tag_size = 16; /* gcm- mode only */
|
||||
else if (!strcmp(integrity, "cmac(aes)"))
|
||||
auth_tag_size = 16;
|
||||
else if (!strcmp(integrity, "hmac(sha1)"))
|
||||
@@ -227,13 +243,13 @@ int INTEGRITY_create_dmd_device(struct crypt_device *cd,
|
||||
if (sb_flags & SB_FLAG_RECALCULATING)
|
||||
dmd->flags |= CRYPT_ACTIVATE_RECALCULATE;
|
||||
|
||||
r = INTEGRITY_data_sectors(cd, crypt_metadata_device(cd),
|
||||
r = INTEGRITY_data_sectors(cd, INTEGRITY_metadata_device(cd),
|
||||
crypt_get_data_offset(cd) * SECTOR_SIZE, &dmd->size);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return dm_integrity_target_set(cd, &dmd->segment, 0, dmd->size,
|
||||
crypt_metadata_device(cd), crypt_data_device(cd),
|
||||
INTEGRITY_metadata_device(cd), crypt_data_device(cd),
|
||||
crypt_get_integrity_tag_size(cd), crypt_get_data_offset(cd),
|
||||
crypt_get_sector_size(cd), vk, journal_crypt_key,
|
||||
journal_mac_key, params);
|
||||
@@ -255,18 +271,8 @@ int INTEGRITY_activate_dmd_device(struct crypt_device *cd,
|
||||
log_dbg(cd, "Trying to activate INTEGRITY device on top of %s, using name %s, tag size %d, provided sectors %" PRIu64".",
|
||||
device_path(tgt->data_device), name, tgt->u.integrity.tag_size, dmd->size);
|
||||
|
||||
r = device_block_adjust(cd, tgt->data_device, DEV_EXCL,
|
||||
tgt->u.integrity.offset, NULL, &dmd->flags);
|
||||
if (r)
|
||||
return r;
|
||||
r = create_or_reload_device(cd, name, type, dmd);
|
||||
|
||||
if (tgt->u.integrity.meta_device) {
|
||||
r = device_block_adjust(cd, tgt->u.integrity.meta_device, DEV_EXCL, 0, NULL, NULL);
|
||||
if (r)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = dm_create_device(cd, name, type, dmd);
|
||||
if (r < 0 && (dm_flags(cd, DM_INTEGRITY, &dmi_flags) || !(dmi_flags & DM_INTEGRITY_SUPPORTED))) {
|
||||
log_err(cd, _("Kernel does not support dm-integrity mapping."));
|
||||
return -ENOTSUP;
|
||||
@@ -278,6 +284,15 @@ int INTEGRITY_activate_dmd_device(struct crypt_device *cd,
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (r < 0 && (dmd->flags & CRYPT_ACTIVATE_RECALCULATE) &&
|
||||
!(crypt_get_compatibility(cd) & CRYPT_COMPAT_LEGACY_INTEGRITY_RECALC) &&
|
||||
((sb_flags & SB_FLAG_FIXED_HMAC) ?
|
||||
(tgt->u.integrity.vk && !tgt->u.integrity.journal_integrity_key) :
|
||||
(tgt->u.integrity.vk || tgt->u.integrity.journal_integrity_key))) {
|
||||
log_err(cd, _("Kernel refuses to activate insecure recalculate option (see legacy activation options to override)."));
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -289,14 +304,33 @@ int INTEGRITY_activate(struct crypt_device *cd,
|
||||
struct volume_key *journal_mac_key,
|
||||
uint32_t flags, uint32_t sb_flags)
|
||||
{
|
||||
struct crypt_dm_active_device dmd = {};
|
||||
int r = INTEGRITY_create_dmd_device(cd, params, vk, journal_crypt_key,
|
||||
journal_mac_key, &dmd, flags, sb_flags);
|
||||
struct crypt_dm_active_device dmdq = {}, dmd = {};
|
||||
int r;
|
||||
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (flags & CRYPT_ACTIVATE_REFRESH) {
|
||||
r = dm_query_device(cd, name, DM_ACTIVE_CRYPT_KEYSIZE |
|
||||
DM_ACTIVE_CRYPT_KEY |
|
||||
DM_ACTIVE_INTEGRITY_PARAMS |
|
||||
DM_ACTIVE_JOURNAL_CRYPT_KEY |
|
||||
DM_ACTIVE_JOURNAL_MAC_KEY, &dmdq);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = INTEGRITY_activate_dmd_device(cd, name, CRYPT_INTEGRITY, &dmd, sb_flags);
|
||||
r = INTEGRITY_create_dmd_device(cd, params, vk ?: dmdq.segment.u.integrity.vk,
|
||||
journal_crypt_key ?: dmdq.segment.u.integrity.journal_crypt_key,
|
||||
journal_mac_key ?: dmdq.segment.u.integrity.journal_integrity_key,
|
||||
&dmd, flags, sb_flags);
|
||||
|
||||
if (!r)
|
||||
dmd.size = dmdq.size;
|
||||
} else
|
||||
r = INTEGRITY_create_dmd_device(cd, params, vk, journal_crypt_key,
|
||||
journal_mac_key, &dmd, flags, sb_flags);
|
||||
|
||||
if (!r)
|
||||
r = INTEGRITY_activate_dmd_device(cd, name, CRYPT_INTEGRITY, &dmd, sb_flags);
|
||||
|
||||
dm_targets_free(cd, &dmdq);
|
||||
dm_targets_free(cd, &dmd);
|
||||
return r;
|
||||
}
|
||||
@@ -320,13 +354,15 @@ int INTEGRITY_format(struct crypt_device *cd,
|
||||
uuid_generate(tmp_uuid_bin);
|
||||
uuid_unparse(tmp_uuid_bin, tmp_uuid);
|
||||
|
||||
snprintf(tmp_name, sizeof(tmp_name), "temporary-cryptsetup-%s", tmp_uuid);
|
||||
r = snprintf(tmp_name, sizeof(tmp_name), "temporary-cryptsetup-%s", tmp_uuid);
|
||||
if (r < 0 || (size_t)r >= sizeof(tmp_name))
|
||||
return -EINVAL;
|
||||
|
||||
/* There is no data area, we can actually use fake zeroed key */
|
||||
if (params && params->integrity_key_size)
|
||||
vk = crypt_alloc_volume_key(params->integrity_key_size, NULL);
|
||||
|
||||
r = dm_integrity_target_set(cd, tgt, 0, dmdi.size, crypt_metadata_device(cd),
|
||||
r = dm_integrity_target_set(cd, tgt, 0, dmdi.size, INTEGRITY_metadata_device(cd),
|
||||
crypt_data_device(cd), crypt_get_integrity_tag_size(cd),
|
||||
crypt_get_data_offset(cd), crypt_get_sector_size(cd), vk,
|
||||
journal_crypt_key, journal_mac_key, params);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Integrity header definition
|
||||
*
|
||||
* Copyright (C) 2016-2020 Milan Broz
|
||||
* Copyright (C) 2016-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -35,11 +35,13 @@ struct crypt_dm_active_device;
|
||||
#define SB_VERSION_2 2
|
||||
#define SB_VERSION_3 3
|
||||
#define SB_VERSION_4 4
|
||||
#define SB_VERSION_5 5
|
||||
|
||||
#define SB_FLAG_HAVE_JOURNAL_MAC (1 << 0)
|
||||
#define SB_FLAG_RECALCULATING (1 << 1) /* V2 only */
|
||||
#define SB_FLAG_DIRTY_BITMAP (1 << 2) /* V3 only */
|
||||
#define SB_FLAG_FIXED_PADDING (1 << 3) /* V4 only */
|
||||
#define SB_FLAG_FIXED_HMAC (1 << 4) /* V5 only */
|
||||
|
||||
struct superblock {
|
||||
uint8_t magic[8];
|
||||
@@ -64,10 +66,8 @@ int INTEGRITY_dump(struct crypt_device *cd, struct device *device, uint64_t offs
|
||||
int INTEGRITY_data_sectors(struct crypt_device *cd,
|
||||
struct device *device, uint64_t offset,
|
||||
uint64_t *data_sectors);
|
||||
int INTEGRITY_key_size(struct crypt_device *cd,
|
||||
const char *integrity);
|
||||
int INTEGRITY_tag_size(struct crypt_device *cd,
|
||||
const char *integrity,
|
||||
int INTEGRITY_key_size(const char *integrity);
|
||||
int INTEGRITY_tag_size(const char *integrity,
|
||||
const char *cipher,
|
||||
const char *cipher_mode);
|
||||
int INTEGRITY_hash_tag_size(const char *integrity);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* Copyright (C) 2004 Jana Saout <jana@saout.de>
|
||||
* Copyright (C) 2004-2007 Clemens Fruhwirth <clemens@endorphin.org>
|
||||
* Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2009-2020 Milan Broz
|
||||
* Copyright (C) 2009-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2009-2022 Milan Broz
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -41,49 +41,25 @@
|
||||
#include "utils_fips.h"
|
||||
#include "utils_keyring.h"
|
||||
#include "utils_io.h"
|
||||
#include "crypto_backend.h"
|
||||
#include "crypto_backend/crypto_backend.h"
|
||||
#include "utils_storage_wrappers.h"
|
||||
|
||||
#include "libcryptsetup.h"
|
||||
|
||||
/* to silent gcc -Wcast-qual for const cast */
|
||||
#define CONST_CAST(x) (x)(uintptr_t)
|
||||
#include "libcryptsetup_macros.h"
|
||||
#include "libcryptsetup_symver.h"
|
||||
|
||||
#define SHIFT_4K 12
|
||||
#define SECTOR_SHIFT 9
|
||||
#define SECTOR_SIZE (1 << SECTOR_SHIFT)
|
||||
#define MAX_SECTOR_SIZE 4096 /* min page size among all platforms */
|
||||
#define DEFAULT_DISK_ALIGNMENT 1048576 /* 1MiB */
|
||||
#define DEFAULT_MEM_ALIGNMENT 4096
|
||||
#define LOG_MAX_LEN 4096
|
||||
#define MAX_DM_DEPS 32
|
||||
|
||||
#define CRYPT_SUBDEV "SUBDEV" /* prefix for sublayered devices underneath public crypt types */
|
||||
|
||||
#define at_least(a, b) ({ __typeof__(a) __at_least = (a); (__at_least >= (b))?__at_least:(b); })
|
||||
|
||||
#define MISALIGNED(a, b) ((a) & ((b) - 1))
|
||||
#define MISALIGNED_4K(a) MISALIGNED((a), 1 << SHIFT_4K)
|
||||
#define MISALIGNED_512(a) MISALIGNED((a), 1 << SECTOR_SHIFT)
|
||||
#define NOTPOW2(a) MISALIGNED((a), (a))
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#endif
|
||||
|
||||
#define MOVE_REF(x, y) \
|
||||
do { \
|
||||
typeof (x) *_px = &(x), *_py = &(y); \
|
||||
*_px = *_py; \
|
||||
*_py = NULL; \
|
||||
} while (0)
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
struct crypt_device;
|
||||
struct luks2_reenc_context;
|
||||
struct luks2_reencrypt;
|
||||
|
||||
struct volume_key {
|
||||
int id;
|
||||
@@ -144,6 +120,8 @@ void device_sync(struct crypt_device *cd, struct device *device);
|
||||
int device_check_size(struct crypt_device *cd,
|
||||
struct device *device,
|
||||
uint64_t req_offset, int falloc);
|
||||
void device_set_block_size(struct device *device, size_t size);
|
||||
size_t device_optimal_encryption_sector_size(struct crypt_device *cd, struct device *device);
|
||||
|
||||
int device_open_locked(struct crypt_device *cd, struct device *device, int flags);
|
||||
int device_read_lock(struct crypt_device *cd, struct device *device);
|
||||
@@ -184,7 +162,7 @@ char *crypt_get_partition_device(const char *dev_path, uint64_t offset, uint64_t
|
||||
char *crypt_get_base_device(const char *dev_path);
|
||||
uint64_t crypt_dev_partition_offset(const char *dev_path);
|
||||
int lookup_by_disk_id(const char *dm_uuid);
|
||||
int lookup_by_sysfs_uuid_field(const char *dm_uuid, size_t max_len);
|
||||
int lookup_by_sysfs_uuid_field(const char *dm_uuid);
|
||||
int crypt_uuid_cmp(const char *dm_uuid, const char *hdr_uuid);
|
||||
|
||||
size_t crypt_getpagesize(void);
|
||||
@@ -193,11 +171,10 @@ uint64_t crypt_getphysmemory_kb(void);
|
||||
|
||||
int init_crypto(struct crypt_device *ctx);
|
||||
|
||||
void logger(struct crypt_device *cd, int level, const char *file, int line, const char *format, ...) __attribute__ ((format (printf, 5, 6)));
|
||||
#define log_dbg(c, x...) logger(c, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x)
|
||||
#define log_std(c, x...) logger(c, CRYPT_LOG_NORMAL, __FILE__, __LINE__, x)
|
||||
#define log_verbose(c, x...) logger(c, CRYPT_LOG_VERBOSE, __FILE__, __LINE__, x)
|
||||
#define log_err(c, x...) logger(c, CRYPT_LOG_ERROR, __FILE__, __LINE__, x)
|
||||
#define log_dbg(c, x...) crypt_logf(c, CRYPT_LOG_DEBUG, x)
|
||||
#define log_std(c, x...) crypt_logf(c, CRYPT_LOG_NORMAL, x)
|
||||
#define log_verbose(c, x...) crypt_logf(c, CRYPT_LOG_VERBOSE, x)
|
||||
#define log_err(c, x...) crypt_logf(c, CRYPT_LOG_ERROR, x)
|
||||
|
||||
int crypt_get_debug_level(void);
|
||||
|
||||
@@ -222,8 +199,8 @@ int PLAIN_activate(struct crypt_device *cd,
|
||||
uint32_t flags);
|
||||
|
||||
void *crypt_get_hdr(struct crypt_device *cd, const char *type);
|
||||
void crypt_set_reenc_context(struct crypt_device *cd, struct luks2_reenc_context *rh);
|
||||
struct luks2_reenc_context *crypt_get_reenc_context(struct crypt_device *cd);
|
||||
void crypt_set_luks2_reencrypt(struct crypt_device *cd, struct luks2_reencrypt *rh);
|
||||
struct luks2_reencrypt *crypt_get_luks2_reencrypt(struct crypt_device *cd);
|
||||
|
||||
int onlyLUKS2(struct crypt_device *cd);
|
||||
int onlyLUKS2mask(struct crypt_device *cd, uint32_t mask);
|
||||
@@ -249,7 +226,7 @@ int crypt_use_keyring_for_vk(struct crypt_device *cd);
|
||||
void crypt_drop_keyring_key_by_description(struct crypt_device *cd, const char *key_description, key_type_t ktype);
|
||||
void crypt_drop_keyring_key(struct crypt_device *cd, struct volume_key *vks);
|
||||
|
||||
static inline uint64_t version(uint16_t major, uint16_t minor, uint16_t patch, uint16_t release)
|
||||
static inline uint64_t compact_version(uint16_t major, uint16_t minor, uint16_t patch, uint16_t release)
|
||||
{
|
||||
return (uint64_t)release | ((uint64_t)patch << 16) | ((uint64_t)minor << 32) | ((uint64_t)major << 48);
|
||||
}
|
||||
@@ -266,4 +243,12 @@ int crypt_compare_dm_devices(struct crypt_device *cd,
|
||||
const struct crypt_dm_active_device *tgt);
|
||||
static inline void *crypt_zalloc(size_t size) { return calloc(1, size); }
|
||||
|
||||
static inline bool uint64_mult_overflow(uint64_t *u, uint64_t b, size_t size)
|
||||
{
|
||||
*u = (uint64_t)b * size;
|
||||
if ((uint64_t)(*u / size) != b)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* INTERNAL_H */
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* Copyright (C) 2004 Jana Saout <jana@saout.de>
|
||||
* Copyright (C) 2004-2007 Clemens Fruhwirth <clemens@endorphin.org>
|
||||
* Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2009-2020 Milan Broz
|
||||
* Copyright (C) 2009-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2009-2022 Milan Broz
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -129,9 +129,10 @@ void crypt_free(struct crypt_device *cd);
|
||||
* other values mean accepted.
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
* @param confirm user defined confirm callback reference
|
||||
* @param confirm user defined confirm callback reference; use
|
||||
* @p msg for message for user to confirm and
|
||||
* @p usrptr for identification in callback
|
||||
* @param usrptr provided identification in callback
|
||||
* @param msg Message for user to confirm
|
||||
*
|
||||
* @note Current version of cryptsetup API requires confirmation for UUID change and
|
||||
* LUKS header restore only.
|
||||
@@ -196,10 +197,11 @@ int crypt_set_data_offset(struct crypt_device *cd, uint64_t data_offset);
|
||||
* Set log function.
|
||||
*
|
||||
* @param cd crypt device handle (can be @e NULL to set default log function)
|
||||
* @param log user defined log function reference
|
||||
* @param log user defined log function reference; use
|
||||
* @p level for log level,
|
||||
* @p msg for message, and
|
||||
* @p usrptr for identification in callback
|
||||
* @param usrptr provided identification in callback
|
||||
* @param level log level below (debug messages can uses other levels)
|
||||
* @param msg log message
|
||||
*/
|
||||
void crypt_set_log_callback(struct crypt_device *cd,
|
||||
void (*log)(int level, const char *msg, void *usrptr),
|
||||
@@ -215,6 +217,15 @@ void crypt_set_log_callback(struct crypt_device *cd,
|
||||
* @param msg log message
|
||||
*/
|
||||
void crypt_log(struct crypt_device *cd, int level, const char *msg);
|
||||
|
||||
/**
|
||||
* Log function with variable arguments.
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
* @param level log level
|
||||
* @param format formatted log message
|
||||
*/
|
||||
void crypt_logf(struct crypt_device *cd, int level, const char *format, ...);
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@@ -260,9 +271,9 @@ struct crypt_pbkdf_type {
|
||||
};
|
||||
|
||||
/** Iteration time set by crypt_set_iteration_time(), for compatibility only. */
|
||||
#define CRYPT_PBKDF_ITER_TIME_SET (1 << 0)
|
||||
#define CRYPT_PBKDF_ITER_TIME_SET (UINT32_C(1) << 0)
|
||||
/** Never run benchmarks, use pre-set value or defaults. */
|
||||
#define CRYPT_PBKDF_NO_BENCHMARK (1 << 1)
|
||||
#define CRYPT_PBKDF_NO_BENCHMARK (UINT32_C(1) << 1)
|
||||
|
||||
/** PBKDF2 according to RFC2898, LUKS1 legacy */
|
||||
#define CRYPT_KDF_PBKDF2 "pbkdf2"
|
||||
@@ -502,13 +513,13 @@ struct crypt_params_verity {
|
||||
};
|
||||
|
||||
/** No on-disk header (only hashes) */
|
||||
#define CRYPT_VERITY_NO_HEADER (1 << 0)
|
||||
#define CRYPT_VERITY_NO_HEADER (UINT32_C(1) << 0)
|
||||
/** Verity hash in userspace before activation */
|
||||
#define CRYPT_VERITY_CHECK_HASH (1 << 1)
|
||||
#define CRYPT_VERITY_CHECK_HASH (UINT32_C(1) << 1)
|
||||
/** Create hash - format hash device */
|
||||
#define CRYPT_VERITY_CREATE_HASH (1 << 2)
|
||||
#define CRYPT_VERITY_CREATE_HASH (UINT32_C(1) << 2)
|
||||
/** Root hash signature required for activation */
|
||||
#define CRYPT_VERITY_ROOT_HASH_SIGNATURE (1 << 3)
|
||||
#define CRYPT_VERITY_ROOT_HASH_SIGNATURE (UINT32_C(1) << 3)
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -531,18 +542,18 @@ struct crypt_params_tcrypt {
|
||||
};
|
||||
|
||||
/** Include legacy modes when scanning for header */
|
||||
#define CRYPT_TCRYPT_LEGACY_MODES (1 << 0)
|
||||
#define CRYPT_TCRYPT_LEGACY_MODES (UINT32_C(1) << 0)
|
||||
/** Try to load hidden header (describing hidden device) */
|
||||
#define CRYPT_TCRYPT_HIDDEN_HEADER (1 << 1)
|
||||
#define CRYPT_TCRYPT_HIDDEN_HEADER (UINT32_C(1) << 1)
|
||||
/** Try to load backup header */
|
||||
#define CRYPT_TCRYPT_BACKUP_HEADER (1 << 2)
|
||||
#define CRYPT_TCRYPT_BACKUP_HEADER (UINT32_C(1) << 2)
|
||||
/** Device contains encrypted system (with boot loader) */
|
||||
#define CRYPT_TCRYPT_SYSTEM_HEADER (1 << 3)
|
||||
#define CRYPT_TCRYPT_SYSTEM_HEADER (UINT32_C(1) << 3)
|
||||
/** Include VeraCrypt modes when scanning for header,
|
||||
* all other TCRYPT flags applies as well.
|
||||
* VeraCrypt device is reported as TCRYPT type.
|
||||
*/
|
||||
#define CRYPT_TCRYPT_VERA_MODES (1 << 4)
|
||||
#define CRYPT_TCRYPT_VERA_MODES (UINT32_C(1) << 4)
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -590,7 +601,7 @@ struct crypt_params_luks2 {
|
||||
const struct crypt_params_integrity *integrity_params; /**< Data integrity parameters or @e NULL*/
|
||||
size_t data_alignment; /**< data area alignment in 512B sectors, data offset is multiple of this */
|
||||
const char *data_device; /**< detached encrypted data device or @e NULL */
|
||||
uint32_t sector_size; /**< encryption sector size */
|
||||
uint32_t sector_size; /**< encryption sector size, 0 triggers auto-detection for optimal encryption sector size */
|
||||
const char *label; /**< header label or @e NULL*/
|
||||
const char *subsystem; /**< header subsystem label or @e NULL*/
|
||||
};
|
||||
@@ -651,7 +662,11 @@ void crypt_set_compatibility(struct crypt_device *cd, uint32_t flags);
|
||||
uint32_t crypt_get_compatibility(struct crypt_device *cd);
|
||||
|
||||
/** dm-integrity device uses less effective (legacy) padding (old kernels) */
|
||||
#define CRYPT_COMPAT_LEGACY_INTEGRITY_PADDING (1 << 0)
|
||||
#define CRYPT_COMPAT_LEGACY_INTEGRITY_PADDING (UINT32_C(1) << 0)
|
||||
/** dm-integrity device does not protect superblock with HMAC (old kernels) */
|
||||
#define CRYPT_COMPAT_LEGACY_INTEGRITY_HMAC (UINT32_C(1) << 1)
|
||||
/** dm-integrity allow recalculating of volumes with HMAC keys (old kernels) */
|
||||
#define CRYPT_COMPAT_LEGACY_INTEGRITY_RECALC (UINT32_C(1) << 2)
|
||||
|
||||
/**
|
||||
* Convert to new type for already existing device.
|
||||
@@ -703,6 +718,24 @@ int crypt_set_label(struct crypt_device *cd,
|
||||
const char *label,
|
||||
const char *subsystem);
|
||||
|
||||
/**
|
||||
* Get the label of an existing device.
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
*
|
||||
* @return label, or @e NULL otherwise
|
||||
*/
|
||||
const char *crypt_get_label(struct crypt_device *cd);
|
||||
|
||||
/**
|
||||
* Get the subsystem of an existing device.
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
*
|
||||
* @return subsystem, or @e NULL otherwise
|
||||
*/
|
||||
const char *crypt_get_subsystem(struct crypt_device *cd);
|
||||
|
||||
/**
|
||||
* Enable or disable loading of volume keys via kernel keyring. When set to
|
||||
* 'enabled' library loads key in kernel keyring first and pass the key
|
||||
@@ -734,7 +767,8 @@ int crypt_volume_key_keyring(struct crypt_device *cd, int enable);
|
||||
* @post In case LUKS header is read successfully but payload device is too small
|
||||
* error is returned and device type in context is set to @e NULL
|
||||
*
|
||||
* @note Note that in current version load works only for LUKS and VERITY device type.
|
||||
* @note Note that load works only for device types with on-disk metadata.
|
||||
* @note Function does not print visible error message if metadata is not present.
|
||||
*
|
||||
*/
|
||||
int crypt_load(struct crypt_device *cd,
|
||||
@@ -866,6 +900,43 @@ int crypt_resume_by_volume_key(struct crypt_device *cd,
|
||||
const char *name,
|
||||
const char *volume_key,
|
||||
size_t volume_key_size);
|
||||
/**
|
||||
* Resume crypt device using LUKS2 token.
|
||||
*
|
||||
* @param cd LUKS2 crypt device handle
|
||||
* @param name name of device to resume
|
||||
* @param type restrict type of token, if @e NULL all types are allowed
|
||||
* @param pin passphrase (or PIN) to unlock token (may be binary data)
|
||||
* @param pin_size size of @e pin
|
||||
* @param usrptr provided identification in callback
|
||||
*
|
||||
* @return unlocked key slot number or negative errno otherwise.
|
||||
*
|
||||
* @note EPERM errno means token provided passphrase successfully, but
|
||||
* passphrase did not unlock any keyslot associated with the token.
|
||||
*
|
||||
* @note ENOENT errno means no token (or subsequently assigned keyslot) was
|
||||
* eligible to resume LUKS2 device.
|
||||
*
|
||||
* @note ENOANO errno means that token is PIN protected and was either missing
|
||||
* (NULL) or wrong.
|
||||
*
|
||||
* @note Negative EAGAIN errno means token handler requires additional hardware
|
||||
* not present in the system to unlock keyslot.
|
||||
*
|
||||
* @note with @param token set to CRYPT_ANY_TOKEN libcryptsetup runs best effort loop
|
||||
* to resume device using any available token. It may happen that various token handlers
|
||||
* return different error codes. At the end loop returns error codes in the following
|
||||
* order (from the most significant to the least) any negative errno except those
|
||||
* listed below, non negative token id (success), -ENOANO, -EAGAIN, -EPERM, -ENOENT.
|
||||
*/
|
||||
int crypt_resume_by_token_pin(struct crypt_device *cd,
|
||||
const char *name,
|
||||
const char *type,
|
||||
int token,
|
||||
const char *pin,
|
||||
size_t pin_size,
|
||||
void *usrptr);
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@@ -990,13 +1061,13 @@ int crypt_keyslot_add_by_volume_key(struct crypt_device *cd,
|
||||
size_t passphrase_size);
|
||||
|
||||
/** create keyslot with volume key not associated with current dm-crypt segment */
|
||||
#define CRYPT_VOLUME_KEY_NO_SEGMENT (1 << 0)
|
||||
#define CRYPT_VOLUME_KEY_NO_SEGMENT (UINT32_C(1) << 0)
|
||||
|
||||
/** create keyslot with new volume key and assign it to current dm-crypt segment */
|
||||
#define CRYPT_VOLUME_KEY_SET (1 << 1)
|
||||
#define CRYPT_VOLUME_KEY_SET (UINT32_C(1) << 1)
|
||||
|
||||
/** Assign key to first matching digest before creating new digest */
|
||||
#define CRYPT_VOLUME_KEY_DIGEST_REUSE (1 << 2)
|
||||
#define CRYPT_VOLUME_KEY_DIGEST_REUSE (UINT32_C(1) << 2)
|
||||
|
||||
/**
|
||||
* Add key slot using provided key.
|
||||
@@ -1058,51 +1129,59 @@ int crypt_keyslot_destroy(struct crypt_device *cd, int keyslot);
|
||||
*/
|
||||
|
||||
/** device is read only */
|
||||
#define CRYPT_ACTIVATE_READONLY (1 << 0)
|
||||
#define CRYPT_ACTIVATE_READONLY (UINT32_C(1) << 0)
|
||||
/** only reported for device without uuid */
|
||||
#define CRYPT_ACTIVATE_NO_UUID (1 << 1)
|
||||
#define CRYPT_ACTIVATE_NO_UUID (UINT32_C(1) << 1)
|
||||
/** activate even if cannot grant exclusive access (DANGEROUS) */
|
||||
#define CRYPT_ACTIVATE_SHARED (1 << 2)
|
||||
#define CRYPT_ACTIVATE_SHARED (UINT32_C(1) << 2)
|
||||
/** enable discards aka TRIM */
|
||||
#define CRYPT_ACTIVATE_ALLOW_DISCARDS (1 << 3)
|
||||
#define CRYPT_ACTIVATE_ALLOW_DISCARDS (UINT32_C(1) << 3)
|
||||
/** skip global udev rules in activation ("private device"), input only */
|
||||
#define CRYPT_ACTIVATE_PRIVATE (1 << 4)
|
||||
#define CRYPT_ACTIVATE_PRIVATE (UINT32_C(1) << 4)
|
||||
/** corruption detected (verity), output only */
|
||||
#define CRYPT_ACTIVATE_CORRUPTED (1 << 5)
|
||||
#define CRYPT_ACTIVATE_CORRUPTED (UINT32_C(1) << 5)
|
||||
/** use same_cpu_crypt option for dm-crypt */
|
||||
#define CRYPT_ACTIVATE_SAME_CPU_CRYPT (1 << 6)
|
||||
#define CRYPT_ACTIVATE_SAME_CPU_CRYPT (UINT32_C(1) << 6)
|
||||
/** use submit_from_crypt_cpus for dm-crypt */
|
||||
#define CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS (1 << 7)
|
||||
#define CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS (UINT32_C(1) << 7)
|
||||
/** dm-verity: ignore_corruption flag - ignore corruption, log it only */
|
||||
#define CRYPT_ACTIVATE_IGNORE_CORRUPTION (1 << 8)
|
||||
#define CRYPT_ACTIVATE_IGNORE_CORRUPTION (UINT32_C(1) << 8)
|
||||
/** dm-verity: restart_on_corruption flag - restart kernel on corruption */
|
||||
#define CRYPT_ACTIVATE_RESTART_ON_CORRUPTION (1 << 9)
|
||||
#define CRYPT_ACTIVATE_RESTART_ON_CORRUPTION (UINT32_C(1) << 9)
|
||||
/** dm-verity: ignore_zero_blocks - do not verify zero blocks */
|
||||
#define CRYPT_ACTIVATE_IGNORE_ZERO_BLOCKS (1 << 10)
|
||||
#define CRYPT_ACTIVATE_IGNORE_ZERO_BLOCKS (UINT32_C(1) << 10)
|
||||
/** key loaded in kernel keyring instead directly in dm-crypt */
|
||||
#define CRYPT_ACTIVATE_KEYRING_KEY (1 << 11)
|
||||
#define CRYPT_ACTIVATE_KEYRING_KEY (UINT32_C(1) << 11)
|
||||
/** dm-integrity: direct writes, do not use journal */
|
||||
#define CRYPT_ACTIVATE_NO_JOURNAL (1 << 12)
|
||||
#define CRYPT_ACTIVATE_NO_JOURNAL (UINT32_C(1) << 12)
|
||||
/** dm-integrity: recovery mode - no journal, no integrity checks */
|
||||
#define CRYPT_ACTIVATE_RECOVERY (1 << 13)
|
||||
#define CRYPT_ACTIVATE_RECOVERY (UINT32_C(1) << 13)
|
||||
/** ignore persistently stored flags */
|
||||
#define CRYPT_ACTIVATE_IGNORE_PERSISTENT (1 << 14)
|
||||
#define CRYPT_ACTIVATE_IGNORE_PERSISTENT (UINT32_C(1) << 14)
|
||||
/** dm-verity: check_at_most_once - check data blocks only the first time */
|
||||
#define CRYPT_ACTIVATE_CHECK_AT_MOST_ONCE (1 << 15)
|
||||
#define CRYPT_ACTIVATE_CHECK_AT_MOST_ONCE (UINT32_C(1) << 15)
|
||||
/** allow activation check including unbound keyslots (keyslots without segments) */
|
||||
#define CRYPT_ACTIVATE_ALLOW_UNBOUND_KEY (1 << 16)
|
||||
#define CRYPT_ACTIVATE_ALLOW_UNBOUND_KEY (UINT32_C(1) << 16)
|
||||
/** dm-integrity: activate automatic recalculation */
|
||||
#define CRYPT_ACTIVATE_RECALCULATE (1 << 17)
|
||||
#define CRYPT_ACTIVATE_RECALCULATE (UINT32_C(1) << 17)
|
||||
/** reactivate existing and update flags, input only */
|
||||
#define CRYPT_ACTIVATE_REFRESH (1 << 18)
|
||||
#define CRYPT_ACTIVATE_REFRESH (UINT32_C(1) << 18)
|
||||
/** Use global lock to serialize memory hard KDF on activation (OOM workaround) */
|
||||
#define CRYPT_ACTIVATE_SERIALIZE_MEMORY_HARD_PBKDF (1 << 19)
|
||||
#define CRYPT_ACTIVATE_SERIALIZE_MEMORY_HARD_PBKDF (UINT32_C(1) << 19)
|
||||
/** dm-integrity: direct writes, use bitmap to track dirty sectors */
|
||||
#define CRYPT_ACTIVATE_NO_JOURNAL_BITMAP (1 << 20)
|
||||
#define CRYPT_ACTIVATE_NO_JOURNAL_BITMAP (UINT32_C(1) << 20)
|
||||
/** device is suspended (key should be wiped from memory), output only */
|
||||
#define CRYPT_ACTIVATE_SUSPENDED (1 << 21)
|
||||
#define CRYPT_ACTIVATE_SUSPENDED (UINT32_C(1) << 21)
|
||||
/** use IV sector counted in sector_size instead of default 512 bytes sectors */
|
||||
#define CRYPT_ACTIVATE_IV_LARGE_SECTORS (1 << 22)
|
||||
#define CRYPT_ACTIVATE_IV_LARGE_SECTORS (UINT32_C(1) << 22)
|
||||
/** dm-verity: panic_on_corruption flag - panic kernel on corruption */
|
||||
#define CRYPT_ACTIVATE_PANIC_ON_CORRUPTION (UINT32_C(1) << 23)
|
||||
/** dm-crypt: bypass internal workqueue and process read requests synchronously. */
|
||||
#define CRYPT_ACTIVATE_NO_READ_WORKQUEUE (UINT32_C(1) << 24)
|
||||
/** dm-crypt: bypass internal workqueue and process write requests synchronously. */
|
||||
#define CRYPT_ACTIVATE_NO_WRITE_WORKQUEUE (UINT32_C(1) << 25)
|
||||
/** dm-integrity: reset automatic recalculation */
|
||||
#define CRYPT_ACTIVATE_RECALCULATE_RESET (UINT32_C(1) << 26)
|
||||
|
||||
/**
|
||||
* Active device runtime attributes
|
||||
@@ -1151,11 +1230,11 @@ uint64_t crypt_get_active_integrity_failures(struct crypt_device *cd,
|
||||
* LUKS2 header requirements
|
||||
*/
|
||||
/** Unfinished offline reencryption */
|
||||
#define CRYPT_REQUIREMENT_OFFLINE_REENCRYPT (1 << 0)
|
||||
#define CRYPT_REQUIREMENT_OFFLINE_REENCRYPT (UINT32_C(1) << 0)
|
||||
/** Online reencryption in-progress */
|
||||
#define CRYPT_REQUIREMENT_ONLINE_REENCRYPT (1 << 1)
|
||||
#define CRYPT_REQUIREMENT_ONLINE_REENCRYPT (UINT32_C(1) << 1)
|
||||
/** unknown requirement in header (output only) */
|
||||
#define CRYPT_REQUIREMENT_UNKNOWN (1 << 31)
|
||||
#define CRYPT_REQUIREMENT_UNKNOWN (UINT32_C(1) << 31)
|
||||
|
||||
/**
|
||||
* Persistent flags type
|
||||
@@ -1285,8 +1364,8 @@ int crypt_activate_by_keyfile(struct crypt_device *cd,
|
||||
* @note For VERITY the volume key means root hash required for activation.
|
||||
* Because kernel dm-verity is always read only, you have to provide
|
||||
* CRYPT_ACTIVATE_READONLY flag always.
|
||||
* @note For TCRYPT the volume key should be always NULL and because master
|
||||
* key from decrypted header is used instead.
|
||||
* @note For TCRYPT the volume key should be always NULL
|
||||
* the key from decrypted header is used instead.
|
||||
*/
|
||||
int crypt_activate_by_volume_key(struct crypt_device *cd,
|
||||
const char *name,
|
||||
@@ -1342,9 +1421,11 @@ int crypt_activate_by_keyring(struct crypt_device *cd,
|
||||
uint32_t flags);
|
||||
|
||||
/** lazy deactivation - remove once last user releases it */
|
||||
#define CRYPT_DEACTIVATE_DEFERRED (1 << 0)
|
||||
#define CRYPT_DEACTIVATE_DEFERRED (UINT32_C(1) << 0)
|
||||
/** force deactivation - if the device is busy, it is replaced by error device */
|
||||
#define CRYPT_DEACTIVATE_FORCE (1 << 1)
|
||||
#define CRYPT_DEACTIVATE_FORCE (UINT32_C(1) << 1)
|
||||
/** if set, remove lazy deactivation */
|
||||
#define CRYPT_DEACTIVATE_DEFERRED_CANCEL (UINT32_C(1) << 2)
|
||||
|
||||
/**
|
||||
* Deactivate crypt device. This function tries to remove active device-mapper
|
||||
@@ -1406,6 +1487,10 @@ int crypt_volume_key_get(struct crypt_device *cd,
|
||||
* @param volume_key_size size of @e volume_key
|
||||
*
|
||||
* @return @e 0 on success or negative errno value otherwise.
|
||||
*
|
||||
* @note Negative EPERM return value means that passed volume_key
|
||||
* did not pass digest verification routine (not a valid volume
|
||||
* key).
|
||||
*/
|
||||
int crypt_volume_key_verify(struct crypt_device *cd,
|
||||
const char *volume_key,
|
||||
@@ -1448,6 +1533,17 @@ crypt_status_info crypt_status(struct crypt_device *cd, const char *name);
|
||||
*/
|
||||
int crypt_dump(struct crypt_device *cd);
|
||||
|
||||
/**
|
||||
* Dump JSON-formatted information about LUKS2 device
|
||||
*
|
||||
* @param cd crypt device handle (only LUKS2 format supported)
|
||||
* @param json buffer with JSON, if NULL use log callback for output
|
||||
* @param flags dump flags (reserved)
|
||||
*
|
||||
* @return @e 0 on success or negative errno value otherwise.
|
||||
*/
|
||||
int crypt_dump_json(struct crypt_device *cd, const char **json, uint32_t flags);
|
||||
|
||||
/**
|
||||
* Get cipher used in device.
|
||||
*
|
||||
@@ -1479,11 +1575,11 @@ const char *crypt_get_cipher_mode(struct crypt_device *cd);
|
||||
const char *crypt_get_uuid(struct crypt_device *cd);
|
||||
|
||||
/**
|
||||
* Get path to underlaying device.
|
||||
* Get path to underlying device.
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
*
|
||||
* @return path to underlaying device name
|
||||
* @return path to underlying device name
|
||||
*
|
||||
*/
|
||||
const char *crypt_get_device_name(struct crypt_device *cd);
|
||||
@@ -1493,7 +1589,7 @@ const char *crypt_get_device_name(struct crypt_device *cd);
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
*
|
||||
* @return path to underlaying device name
|
||||
* @return path to underlying device name
|
||||
*
|
||||
*/
|
||||
const char *crypt_get_metadata_device_name(struct crypt_device *cd);
|
||||
@@ -1540,6 +1636,21 @@ int crypt_get_volume_key_size(struct crypt_device *cd);
|
||||
*/
|
||||
int crypt_get_sector_size(struct crypt_device *cd);
|
||||
|
||||
/**
|
||||
* Check if initialized LUKS context uses detached header
|
||||
* (LUKS header located on a different device than data.)
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
*
|
||||
* @return @e 1 if detached header is used, @e 0 if not
|
||||
* or negative errno value otherwise.
|
||||
*
|
||||
* @note This is a runtime attribute, it does not say
|
||||
* if a LUKS device requires detached header.
|
||||
* This function works only with LUKS devices.
|
||||
*/
|
||||
int crypt_header_is_detached(struct crypt_device *cd);
|
||||
|
||||
/**
|
||||
* Get device parameters for VERITY device.
|
||||
*
|
||||
@@ -1872,7 +1983,7 @@ int crypt_keyfile_read(struct crypt_device *cd,
|
||||
uint32_t flags);
|
||||
|
||||
/** Read key only to the first end of line (\\n). */
|
||||
#define CRYPT_KEYFILE_STOP_EOL (1 << 0)
|
||||
#define CRYPT_KEYFILE_STOP_EOL (UINT32_C(1) << 0)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@@ -1886,7 +1997,7 @@ int crypt_keyfile_read(struct crypt_device *cd,
|
||||
typedef enum {
|
||||
CRYPT_WIPE_ZERO, /**< Fill with zeroes */
|
||||
CRYPT_WIPE_RANDOM, /**< Use RNG to fill data */
|
||||
CRYPT_WIPE_ENCRYPTED_ZERO, /**< Add encryption and fill with zeroes as plaintext */
|
||||
CRYPT_WIPE_ENCRYPTED_ZERO, /**< Obsolete, same as CRYPT_WIPE_RANDOM */
|
||||
CRYPT_WIPE_SPECIAL, /**< Compatibility only, do not use (Gutmann method) */
|
||||
} crypt_wipe_pattern;
|
||||
|
||||
@@ -1922,7 +2033,7 @@ int crypt_wipe(struct crypt_device *cd,
|
||||
);
|
||||
|
||||
/** Use direct-io */
|
||||
#define CRYPT_WIPE_NO_DIRECT_IO (1 << 0)
|
||||
#define CRYPT_WIPE_NO_DIRECT_IO (UINT32_C(1) << 0)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@@ -1937,6 +2048,19 @@ int crypt_wipe(struct crypt_device *cd,
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get number of tokens supported for device type.
|
||||
*
|
||||
* @param type crypt device type
|
||||
*
|
||||
* @return token count or negative errno otherwise if device
|
||||
* doesn't not support tokens.
|
||||
*
|
||||
* @note Real number of supported tokens for a particular device depends
|
||||
* on usable metadata area size.
|
||||
*/
|
||||
int crypt_token_max(const char *type);
|
||||
|
||||
/** Iterate through all tokens */
|
||||
#define CRYPT_ANY_TOKEN -1
|
||||
|
||||
@@ -2094,6 +2218,15 @@ int crypt_token_is_assigned(struct crypt_device *cd,
|
||||
* @param buffer returned allocated buffer with password
|
||||
* @param buffer_len length of the buffer
|
||||
* @param usrptr user data in @link crypt_activate_by_token @endlink
|
||||
*
|
||||
* @return 0 on success (token passed LUKS2 keyslot passphrase in buffer) or
|
||||
* negative errno otherwise.
|
||||
*
|
||||
* @note Negative ENOANO errno means that token is PIN protected and caller should
|
||||
* use @link crypt_activate_by_token_pin @endlink with PIN provided.
|
||||
*
|
||||
* @note Negative EAGAIN errno means token handler requires additional hardware
|
||||
* not present in the system.
|
||||
*/
|
||||
typedef int (*crypt_token_open_func) (
|
||||
struct crypt_device *cd,
|
||||
@@ -2102,6 +2235,38 @@ typedef int (*crypt_token_open_func) (
|
||||
size_t *buffer_len,
|
||||
void *usrptr);
|
||||
|
||||
/**
|
||||
* Token handler open with passphrase/PIN function prototype.
|
||||
* This function retrieves password from a token and return allocated buffer
|
||||
* containing this password. This buffer has to be deallocated by calling
|
||||
* free() function and content should be wiped before deallocation.
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
* @param token token id
|
||||
* @param pin passphrase (or PIN) to unlock token (may be binary data)
|
||||
* @param pin_size size of @e pin
|
||||
* @param buffer returned allocated buffer with password
|
||||
* @param buffer_len length of the buffer
|
||||
* @param usrptr user data in @link crypt_activate_by_token @endlink
|
||||
*
|
||||
* @return 0 on success (token passed LUKS2 keyslot passphrase in buffer) or
|
||||
* negative errno otherwise.
|
||||
*
|
||||
* @note Negative ENOANO errno means that token is PIN protected and PIN was
|
||||
* missing or wrong.
|
||||
*
|
||||
* @note Negative EAGAIN errno means token handler requires additional hardware
|
||||
* not present in the system.
|
||||
*/
|
||||
typedef int (*crypt_token_open_pin_func) (
|
||||
struct crypt_device *cd,
|
||||
int token,
|
||||
const char *pin,
|
||||
size_t pin_size,
|
||||
char **buffer,
|
||||
size_t *buffer_len,
|
||||
void *usrptr);
|
||||
|
||||
/**
|
||||
* Token handler buffer free function prototype.
|
||||
* This function is used by library to free the buffer with keyslot
|
||||
@@ -2139,6 +2304,16 @@ typedef int (*crypt_token_validate_func) (struct crypt_device *cd, const char *j
|
||||
*/
|
||||
typedef void (*crypt_token_dump_func) (struct crypt_device *cd, const char *json);
|
||||
|
||||
/**
|
||||
* Token handler version function prototype.
|
||||
* This function is supposed to return pointer to version string information.
|
||||
*
|
||||
* @note The returned string is advised to contain only version.
|
||||
* For example '1.0.0' or 'v1.2.3.4'.
|
||||
*
|
||||
*/
|
||||
typedef const char * (*crypt_token_version_func) (void);
|
||||
|
||||
/**
|
||||
* Token handler
|
||||
*/
|
||||
@@ -2159,6 +2334,35 @@ typedef struct {
|
||||
*/
|
||||
int crypt_token_register(const crypt_token_handler *handler);
|
||||
|
||||
/**
|
||||
* Report configured path where library searches for external token handlers
|
||||
*
|
||||
* @return @e absolute path when external tokens are enabled or @e NULL otherwise.
|
||||
*/
|
||||
const char *crypt_token_external_path(void);
|
||||
|
||||
/**
|
||||
* Disable external token handlers (plugins) support
|
||||
* If disabled, it cannot be enabled again.
|
||||
*/
|
||||
void crypt_token_external_disable(void);
|
||||
|
||||
/** ABI version for external token in libcryptsetup-token-[name].so */
|
||||
#define CRYPT_TOKEN_ABI_VERSION1 "CRYPTSETUP_TOKEN_1.0"
|
||||
|
||||
/** open by token - ABI exported symbol for external token (mandatory) */
|
||||
#define CRYPT_TOKEN_ABI_OPEN "cryptsetup_token_open"
|
||||
/** open by token with PIN - ABI exported symbol for external token */
|
||||
#define CRYPT_TOKEN_ABI_OPEN_PIN "cryptsetup_token_open_pin"
|
||||
/** deallocate callback - ABI exported symbol for external token */
|
||||
#define CRYPT_TOKEN_ABI_BUFFER_FREE "cryptsetup_token_buffer_free"
|
||||
/** validate token metadata - ABI exported symbol for external token */
|
||||
#define CRYPT_TOKEN_ABI_VALIDATE "cryptsetup_token_validate"
|
||||
/** dump token metadata - ABI exported symbol for external token */
|
||||
#define CRYPT_TOKEN_ABI_DUMP "cryptsetup_token_dump"
|
||||
/** token version - ABI exported symbol for external token */
|
||||
#define CRYPT_TOKEN_ABI_VERSION "cryptsetup_token_version"
|
||||
|
||||
/**
|
||||
* Activate device or check key using a token.
|
||||
*
|
||||
@@ -2169,12 +2373,71 @@ int crypt_token_register(const crypt_token_handler *handler);
|
||||
* @param flags activation flags
|
||||
*
|
||||
* @return unlocked key slot number or negative errno otherwise.
|
||||
*
|
||||
* @note EPERM errno means token provided passphrase successfully, but
|
||||
* passphrase did not unlock any keyslot associated with the token.
|
||||
*
|
||||
* @note ENOENT errno means no token (or subsequently assigned keyslot) was
|
||||
* eligible to unlock device.
|
||||
*
|
||||
* @note ENOANO errno means that token is PIN protected and you should call
|
||||
* @link crypt_activate_by_token_pin @endlink with PIN
|
||||
*
|
||||
* @note Negative EAGAIN errno means token handler requires additional hardware
|
||||
* not present in the system.
|
||||
*
|
||||
* @note with @e token set to CRYPT_ANY_TOKEN libcryptsetup runs best effort loop
|
||||
* to unlock device using any available token. It may happen that various token handlers
|
||||
* return different error codes. At the end loop returns error codes in the following
|
||||
* order (from the most significant to the least) any negative errno except those
|
||||
* listed below, non negative token id (success), -ENOANO, -EAGAIN, -EPERM, -ENOENT.
|
||||
*/
|
||||
int crypt_activate_by_token(struct crypt_device *cd,
|
||||
const char *name,
|
||||
int token,
|
||||
void *usrptr,
|
||||
uint32_t flags);
|
||||
|
||||
/**
|
||||
* Activate device or check key using a token with PIN.
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
* @param name name of device to create, if @e NULL only check token
|
||||
* @param type restrict type of token, if @e NULL all types are allowed
|
||||
* @param token requested token to check or CRYPT_ANY_TOKEN to check all
|
||||
* @param pin passphrase (or PIN) to unlock token (may be binary data)
|
||||
* @param pin_size size of @e pin
|
||||
* @param usrptr provided identification in callback
|
||||
* @param flags activation flags
|
||||
*
|
||||
* @return unlocked key slot number or negative errno otherwise.
|
||||
*
|
||||
* @note EPERM errno means token provided passphrase successfully, but
|
||||
* passphrase did not unlock any keyslot associated with the token.
|
||||
*
|
||||
* @note ENOENT errno means no token (or subsequently assigned keyslot) was
|
||||
* eligible to unlock device.
|
||||
*
|
||||
* @note ENOANO errno means that token is PIN protected and was either missing
|
||||
* (NULL) or wrong.
|
||||
*
|
||||
* @note Negative EAGAIN errno means token handler requires additional hardware
|
||||
* not present in the system.
|
||||
*
|
||||
* @note with @e token set to CRYPT_ANY_TOKEN libcryptsetup runs best effort loop
|
||||
* to unlock device using any available token. It may happen that various token handlers
|
||||
* return different error codes. At the end loop returns error codes in the following
|
||||
* order (from the most significant to the least) any negative errno except those
|
||||
* listed below, non negative token id (success), -ENOANO, -EAGAIN, -EPERM, -ENOENT.
|
||||
*/
|
||||
int crypt_activate_by_token_pin(struct crypt_device *cd,
|
||||
const char *name,
|
||||
const char *type,
|
||||
int token,
|
||||
const char *pin,
|
||||
size_t pin_size,
|
||||
void *usrptr,
|
||||
uint32_t flags);
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@@ -2187,13 +2450,16 @@ int crypt_activate_by_token(struct crypt_device *cd,
|
||||
*/
|
||||
|
||||
/** Initialize reencryption metadata but do not run reencryption yet. (in) */
|
||||
#define CRYPT_REENCRYPT_INITIALIZE_ONLY (1 << 0)
|
||||
/** Move the first segment, used only with data shift. (in/out) */
|
||||
#define CRYPT_REENCRYPT_MOVE_FIRST_SEGMENT (1 << 1)
|
||||
#define CRYPT_REENCRYPT_INITIALIZE_ONLY (UINT32_C(1) << 0)
|
||||
/** Move the first segment, used only with datashift resilience mode
|
||||
* and subvariants. (in/out) */
|
||||
#define CRYPT_REENCRYPT_MOVE_FIRST_SEGMENT (UINT32_C(1) << 1)
|
||||
/** Resume already initialized reencryption only. (in) */
|
||||
#define CRYPT_REENCRYPT_RESUME_ONLY (1 << 2)
|
||||
#define CRYPT_REENCRYPT_RESUME_ONLY (UINT32_C(1) << 2)
|
||||
/** Run reencryption recovery only. (in) */
|
||||
#define CRYPT_REENCRYPT_RECOVERY (1 << 3)
|
||||
#define CRYPT_REENCRYPT_RECOVERY (UINT32_C(1) << 3)
|
||||
/** Reencryption requires metadata protection. (in/out) */
|
||||
#define CRYPT_REENCRYPT_REPAIR_NEEDED (UINT32_C(1) << 4)
|
||||
|
||||
/**
|
||||
* Reencryption direction
|
||||
@@ -2218,10 +2484,15 @@ typedef enum {
|
||||
struct crypt_params_reencrypt {
|
||||
crypt_reencrypt_mode_info mode; /**< Reencryption mode, immutable after first init. */
|
||||
crypt_reencrypt_direction_info direction; /**< Reencryption direction, immutable after first init. */
|
||||
const char *resilience; /**< Resilience mode: "none", "checksum", "journal" or "shift" (only "shift" is immutable after init) */
|
||||
const char *resilience; /**< Resilience mode: "none", "checksum", "journal", "datashift",
|
||||
"datashift-checksum" or "datashift-journal".
|
||||
"datashift" mode is immutable, "datashift-" subvariant can be only
|
||||
changed to other "datashift-" subvariant */
|
||||
const char *hash; /**< Used hash for "checksum" resilience type, ignored otherwise. */
|
||||
uint64_t data_shift; /**< Used in "shift" mode, must be non-zero, immutable after first init. */
|
||||
uint64_t max_hotzone_size; /**< Exact hotzone size for "none" mode. Maximum hotzone size for "checksum" and "journal" modes. */
|
||||
uint64_t data_shift; /**< Used in "datashift" mode (and subvariants), must be non-zero,
|
||||
immutable after first init. */
|
||||
uint64_t max_hotzone_size; /**< Maximum hotzone size (may be lowered by library). For "datashift-" subvariants
|
||||
it is used to set size of moved segment (decryption only). */
|
||||
uint64_t device_size; /**< Reencrypt only initial part of the data device. */
|
||||
const struct crypt_params_luks2 *luks2; /**< LUKS2 parameters for the final reencryption volume.*/
|
||||
uint32_t flags; /**< Reencryption flags. */
|
||||
@@ -2286,16 +2557,33 @@ int crypt_reencrypt_init_by_keyring(struct crypt_device *cd,
|
||||
const struct crypt_params_reencrypt *params);
|
||||
|
||||
/**
|
||||
* Run data reencryption.
|
||||
* Legacy data reencryption function.
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
* @param progress is a callback funtion reporting device \b size,
|
||||
* @param progress is a callback function reporting device \b size,
|
||||
* current \b offset of reencryption and provided \b usrptr identification
|
||||
*
|
||||
* @return @e 0 on success or negative errno value otherwise.
|
||||
*
|
||||
* @deprecated Use @link crypt_reencrypt_run @endlink instead.
|
||||
*/
|
||||
int crypt_reencrypt(struct crypt_device *cd,
|
||||
int (*progress)(uint64_t size, uint64_t offset, void *usrptr));
|
||||
int (*progress)(uint64_t size, uint64_t offset, void *usrptr))
|
||||
__attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* Run data reencryption.
|
||||
*
|
||||
* @param cd crypt device handle
|
||||
* @param progress is a callback function reporting device \b size,
|
||||
* current \b offset of reencryption and provided \b usrptr identification
|
||||
* @param usrptr progress specific data
|
||||
*
|
||||
* @return @e 0 on success or negative errno value otherwise.
|
||||
*/
|
||||
int crypt_reencrypt_run(struct crypt_device *cd,
|
||||
int (*progress)(uint64_t size, uint64_t offset, void *usrptr),
|
||||
void *usrptr);
|
||||
|
||||
/**
|
||||
* Reencryption status info
|
||||
@@ -2330,17 +2618,15 @@ crypt_reencrypt_info crypt_reencrypt_status(struct crypt_device *cd,
|
||||
*
|
||||
* @param size size of memory in bytes
|
||||
*
|
||||
* @return pointer to allocate memory or @e NULL.
|
||||
* @return pointer to allocated memory or @e NULL.
|
||||
*/
|
||||
void *crypt_safe_alloc(size_t size);
|
||||
|
||||
/**
|
||||
* Release safe memory, content is safely wiped
|
||||
* Release safe memory, content is safely wiped.
|
||||
* The pointer must be allocated with @link crypt_safe_alloc @endlink
|
||||
*
|
||||
* @param data pointer to memory to be deallocated
|
||||
*
|
||||
* @return pointer to allocate memory or @e NULL.
|
||||
*/
|
||||
void crypt_safe_free(void *data);
|
||||
|
||||
@@ -2350,17 +2636,15 @@ void crypt_safe_free(void *data);
|
||||
* @param data pointer to memory to be deallocated
|
||||
* @param size new size of memory in bytes
|
||||
*
|
||||
* @return pointer to allocate memory or @e NULL.
|
||||
* @return pointer to allocated memory or @e NULL.
|
||||
*/
|
||||
void *crypt_safe_realloc(void *data, size_t size);
|
||||
|
||||
/**
|
||||
* Safe clear memory area (compile should not compile this call out).
|
||||
*
|
||||
* @param data pointer to memory to cleared
|
||||
* @param size new size of memory in bytes
|
||||
*
|
||||
* @return pointer to allocate memory or @e NULL.
|
||||
* @param data pointer to memory to be cleared
|
||||
* @param size size of memory in bytes
|
||||
*/
|
||||
void crypt_safe_memzero(void *data, size_t size);
|
||||
|
||||
|
||||
@@ -131,3 +131,23 @@ CRYPTSETUP_2.0 {
|
||||
local:
|
||||
*;
|
||||
};
|
||||
|
||||
CRYPTSETUP_2.4 {
|
||||
global:
|
||||
crypt_reencrypt_run;
|
||||
crypt_token_max;
|
||||
crypt_header_is_detached;
|
||||
crypt_logf;
|
||||
crypt_activate_by_token_pin;
|
||||
crypt_dump_json;
|
||||
crypt_format;
|
||||
crypt_token_external_disable;
|
||||
crypt_token_external_path;
|
||||
} CRYPTSETUP_2.0;
|
||||
|
||||
CRYPTSETUP_2.5 {
|
||||
global:
|
||||
crypt_get_label;
|
||||
crypt_get_subsystem;
|
||||
crypt_resume_by_token_pin;
|
||||
} CRYPTSETUP_2.4;
|
||||
|
||||
70
lib/libcryptsetup_macros.h
Normal file
70
lib/libcryptsetup_macros.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Definitions of common constant and generic macros of libcryptsetup
|
||||
*
|
||||
* Copyright (C) 2009-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2009-2022 Milan Broz
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef _LIBCRYPTSETUP_MACROS_H
|
||||
#define _LIBCRYPTSETUP_MACROS_H
|
||||
|
||||
/* to silent gcc -Wcast-qual for const cast */
|
||||
#define CONST_CAST(x) (x)(uintptr_t)
|
||||
|
||||
/* to silent clang -Wcast-align when working with byte arrays */
|
||||
#define VOIDP_CAST(x) (x)(void*)
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#endif
|
||||
|
||||
#define BITFIELD_SIZE(BF_PTR) (sizeof(*(BF_PTR)) * 8)
|
||||
|
||||
#define MOVE_REF(x, y) \
|
||||
do { \
|
||||
__typeof__(x) *_px = &(x), *_py = &(y); \
|
||||
*_px = *_py; \
|
||||
*_py = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define FREE_AND_NULL(x) do { free(x); x = NULL; } while (0)
|
||||
|
||||
#define AT_LEAST(a, b) ({ __typeof__(a) __at_least = (a); (__at_least >= (b))?__at_least:(b); })
|
||||
|
||||
#define SHIFT_4K 12
|
||||
#define SECTOR_SHIFT 9
|
||||
#define SECTOR_SIZE (1 << SECTOR_SHIFT)
|
||||
#define MAX_SECTOR_SIZE 4096 /* min page size among all platforms */
|
||||
#define ROUND_SECTOR(x) (((x) + SECTOR_SIZE - 1) / SECTOR_SIZE)
|
||||
|
||||
#define MISALIGNED(a, b) ((a) & ((b) - 1))
|
||||
#define MISALIGNED_4K(a) MISALIGNED((a), 1 << SHIFT_4K)
|
||||
#define MISALIGNED_512(a) MISALIGNED((a), 1 << SECTOR_SHIFT)
|
||||
#define NOTPOW2(a) MISALIGNED((a), (a))
|
||||
|
||||
#define DEFAULT_DISK_ALIGNMENT 1048576 /* 1MiB */
|
||||
#define DEFAULT_MEM_ALIGNMENT 4096
|
||||
|
||||
#define DM_UUID_LEN 129
|
||||
#define DM_BY_ID_PREFIX "dm-uuid-"
|
||||
#define DM_BY_ID_PREFIX_LEN 8
|
||||
#define DM_UUID_PREFIX "CRYPT-"
|
||||
#define DM_UUID_PREFIX_LEN 6
|
||||
|
||||
#endif /* _LIBCRYPTSETUP_MACROS_H */
|
||||
103
lib/libcryptsetup_symver.h
Normal file
103
lib/libcryptsetup_symver.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Helpers for defining versioned symbols
|
||||
*
|
||||
* Copyright (C) 2021-2022 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef _LIBCRYPTSETUP_SYMVER_H
|
||||
#define _LIBCRYPTSETUP_SYMVER_H
|
||||
|
||||
/*
|
||||
* Note on usage:
|
||||
*
|
||||
* Do not use CRYPT_SYMBOL_EXPORT_NEW and CRYPT_SYMBOL_EXPORT_OLD on public
|
||||
* symbols being exported only once. Linker will handle it automatically as
|
||||
* always.
|
||||
*
|
||||
* It's supposed to be used only with symbols that are exported in at least
|
||||
* two versions simultaneously as follows:
|
||||
*
|
||||
* - the latest version is marked with _NEW variant and all other compatible
|
||||
* symbols should be marked with _OLD variant
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* - int crypt_func_X(unsigned *x, long y) gets introduced in CRYPTSETUP_2.4.
|
||||
*
|
||||
* No need to use any macro referenced here, just add proper version
|
||||
* mapping in libcryptsetup.sym file.
|
||||
*
|
||||
* In later version CRYPTSETUP_2.5 symbol crypt_func_X has to fixed
|
||||
* in incompatible way by adding new function parameter. The new version
|
||||
* has to be added in mapping file libcryptsetup.sym as well.
|
||||
*
|
||||
* The definition of compatible function gets prefixed with following macro:
|
||||
*
|
||||
* CRYPT_SYMBOL_EXPORT_OLD(int, crypt_func_X, 2, 4,
|
||||
* unsigned *x, long y)
|
||||
* {
|
||||
* function body
|
||||
* }
|
||||
*
|
||||
* Whereas new version introduced in CRYPTSETUP_2.5 is defined as follows:
|
||||
*
|
||||
* CRYPT_SYMBOL_EXPORT_NEW(int, crypt_func_X, 2, 5,
|
||||
* unsigned *x, long y, void *new_parameter)
|
||||
* {
|
||||
* function body
|
||||
* }
|
||||
*
|
||||
* If in later version CRYPTSETUP_2.6 yet another version of crypt_func_X gets
|
||||
* introduced it will be prefixed with CRYPT_SYMBOL_EXPORT_NEW(int, crypt_func_X, 2, 6...)
|
||||
* macro and all previous versions CRYPTSETUP_2.4 and CRYPTSETUP_2.5 will be
|
||||
* under CRYPT_SYMBOL_EXPORT_OLD(int, crypt_func_X, ...) macro
|
||||
*/
|
||||
|
||||
#if HAVE_ATTRIBUTE_SYMVER
|
||||
# define _CRYPT_SYMVER(_local_sym, _public_sym, _ver_str, _maj, _min) \
|
||||
__attribute__((__symver__(#_public_sym _ver_str #_maj "." #_min)))
|
||||
#endif
|
||||
|
||||
#if !defined(_CRYPT_SYMVER) && defined(__GNUC__)
|
||||
# define _CRYPT_SYMVER(_local_sym, _public_sym, _ver_str, _maj, _min) \
|
||||
asm(".symver " #_local_sym "," #_public_sym _ver_str #_maj "." #_min);
|
||||
#endif
|
||||
|
||||
#define _CRYPT_FUNC(_public_sym, _prefix_str, _maj, _min, _ret, ...) \
|
||||
_ret __##_public_sym##_v##_maj##_##_min(__VA_ARGS__); \
|
||||
_CRYPT_SYMVER(__##_public_sym##_v##_maj##_##_min, _public_sym, _prefix_str "CRYPTSETUP_", _maj, _min) \
|
||||
_ret __##_public_sym##_v##_maj##_##_min(__VA_ARGS__)
|
||||
|
||||
#ifdef _CRYPT_SYMVER
|
||||
|
||||
# define CRYPT_SYMBOL_EXPORT_OLD(_ret, _public_sym, _maj, _min, ...) \
|
||||
_CRYPT_FUNC(_public_sym, "@", _maj, _min, _ret, __VA_ARGS__)
|
||||
# define CRYPT_SYMBOL_EXPORT_NEW(_ret, _public_sym, _maj, _min, ...) \
|
||||
_CRYPT_FUNC(_public_sym, "@@", _maj, _min, _ret, __VA_ARGS__)
|
||||
|
||||
#else /* no support for symbol versioning at all */
|
||||
|
||||
# define CRYPT_SYMBOL_EXPORT_OLD(_ret, _public_sym, _maj, _min, ...) \
|
||||
static inline __attribute__((unused)) \
|
||||
_ret __##_public_sym##_v##_maj##_##_min(__VA_ARGS__)
|
||||
|
||||
# define CRYPT_SYMBOL_EXPORT_NEW(_ret, _public_sym, _maj, _min, ...) \
|
||||
_ret _public_sym(__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _LIBCRYPTSETUP_SYMVER_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* loop-AES compatible volume handling
|
||||
*
|
||||
* Copyright (C) 2011-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2011-2020 Milan Broz
|
||||
* Copyright (C) 2011-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2011-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* loop-AES compatible volume handling
|
||||
*
|
||||
* Copyright (C) 2011-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2011-2020 Milan Broz
|
||||
* Copyright (C) 2011-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2011-2022 Milan Broz
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -23,7 +23,7 @@
|
||||
#define _LOOPAES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
|
||||
struct crypt_device;
|
||||
struct volume_key;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* AFsplitter - Anti forensic information splitter
|
||||
*
|
||||
* Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org>
|
||||
* Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2009-2022 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* AFsplitter diffuses information over a large stripe of data,
|
||||
* therefore supporting secure data destruction.
|
||||
@@ -131,7 +131,7 @@ out:
|
||||
return r;
|
||||
}
|
||||
|
||||
int AF_merge(struct crypt_device *ctx __attribute__((unused)), const char *src, char *dst,
|
||||
int AF_merge(const char *src, char *dst,
|
||||
size_t blocksize, unsigned int blocknumbers, const char *hash)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -142,7 +142,7 @@ int AF_merge(struct crypt_device *ctx __attribute__((unused)), const char *src,
|
||||
if (!bufblock)
|
||||
return -ENOMEM;
|
||||
|
||||
for(i = 0; i < blocknumbers - 1; i++) {
|
||||
for (i = 0; i < blocknumbers - 1; i++) {
|
||||
XORblock(src + blocksize * i, bufblock, bufblock, blocksize);
|
||||
r = diffuse(bufblock, bufblock, blocksize, hash);
|
||||
if (r < 0)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* AFsplitter - Anti forensic information splitter
|
||||
*
|
||||
* Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org>
|
||||
* Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2009-2022 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* AFsplitter diffuses information over a large stripe of data,
|
||||
* therefore supporting secure data destruction.
|
||||
@@ -26,6 +26,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct crypt_device;
|
||||
struct volume_key;
|
||||
|
||||
/*
|
||||
* AF_split operates on src and produces information split data in
|
||||
* dst. src is assumed to be of the length blocksize. The data stripe
|
||||
@@ -41,7 +44,7 @@
|
||||
|
||||
int AF_split(struct crypt_device *ctx, const char *src, char *dst,
|
||||
size_t blocksize, unsigned int blocknumbers, const char *hash);
|
||||
int AF_merge(struct crypt_device *ctx, const char *src, char *dst, size_t blocksize,
|
||||
int AF_merge(const char *src, char *dst, size_t blocksize,
|
||||
unsigned int blocknumbers, const char *hash);
|
||||
size_t AF_split_sectors(size_t blocksize, unsigned int blocknumbers);
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* LUKS - Linux Unified Key Setup
|
||||
*
|
||||
* Copyright (C) 2004-2006 Clemens Fruhwirth <clemens@endorphin.org>
|
||||
* Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2012-2020 Milan Broz
|
||||
* Copyright (C) 2009-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2012-2022 Milan Broz
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -153,7 +153,7 @@ int LUKS_encrypt_to_storage(char *src, size_t srcLength,
|
||||
return -EINVAL;
|
||||
|
||||
/* Encrypt buffer */
|
||||
r = crypt_storage_init(&s, SECTOR_SIZE, cipher, cipher_mode, vk->key, vk->keylength);
|
||||
r = crypt_storage_init(&s, SECTOR_SIZE, cipher, cipher_mode, vk->key, vk->keylength, false);
|
||||
|
||||
if (r)
|
||||
log_dbg(ctx, "Userspace crypto wrapper cannot use %s-%s (%d).",
|
||||
@@ -218,7 +218,7 @@ int LUKS_decrypt_from_storage(char *dst, size_t dstLength,
|
||||
if (MISALIGNED_512(dstLength))
|
||||
return -EINVAL;
|
||||
|
||||
r = crypt_storage_init(&s, SECTOR_SIZE, cipher, cipher_mode, vk->key, vk->keylength);
|
||||
r = crypt_storage_init(&s, SECTOR_SIZE, cipher, cipher_mode, vk->key, vk->keylength, false);
|
||||
|
||||
if (r)
|
||||
log_dbg(ctx, "Userspace crypto wrapper cannot use %s-%s (%d).",
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* LUKS - Linux Unified Key Setup
|
||||
*
|
||||
* Copyright (C) 2004-2006 Clemens Fruhwirth <clemens@endorphin.org>
|
||||
* Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2013-2020 Milan Broz
|
||||
* Copyright (C) 2009-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2013-2022 Milan Broz
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <netinet/in.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
@@ -66,6 +65,27 @@ static void LUKS_sort_keyslots(const struct luks_phdr *hdr, int *array)
|
||||
}
|
||||
}
|
||||
|
||||
static int _is_not_lower(char *str, unsigned max_len)
|
||||
{
|
||||
for(; *str && max_len; str++, max_len--)
|
||||
if (isupper(*str))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _to_lower(char *str, unsigned max_len)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
for(; *str && max_len; str++, max_len--)
|
||||
if (isupper(*str)) {
|
||||
*str = tolower(*str);
|
||||
r = 1;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
size_t LUKS_device_sectors(const struct luks_phdr *hdr)
|
||||
{
|
||||
int sorted_areas[LUKS_NUMKEYS] = { 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||
@@ -375,17 +395,48 @@ static int _keyslot_repair(struct luks_phdr *phdr, struct crypt_device *ctx)
|
||||
log_err(ctx, _("Non standard key size, manual repair required."));
|
||||
return -EINVAL;
|
||||
}
|
||||
/* cryptsetup 1.0 did not align to 4k, cannot repair this one */
|
||||
if (LUKS_keyslots_offset(phdr) < (LUKS_ALIGN_KEYSLOTS / SECTOR_SIZE)) {
|
||||
|
||||
/*
|
||||
* cryptsetup 1.0 did not align keyslots to 4k, cannot repair this one
|
||||
* Also we cannot trust possibly broken keyslots metadata here through LUKS_keyslots_offset().
|
||||
* Expect first keyslot is aligned, if not, then manual repair is necessary.
|
||||
*/
|
||||
if (phdr->keyblock[0].keyMaterialOffset < (LUKS_ALIGN_KEYSLOTS / SECTOR_SIZE)) {
|
||||
log_err(ctx, _("Non standard keyslots alignment, manual repair required."));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* ECB mode does not use IV but legacy dmcrypt silently allows it.
|
||||
* Today device cannot be activated anyway, so we need to fix it here.
|
||||
*/
|
||||
if (!strncmp(phdr->cipherMode, "ecb-", 4)) {
|
||||
log_err(ctx, _("Cipher mode repaired (%s -> %s)."), phdr->cipherMode, "ecb");
|
||||
memset(phdr->cipherMode, 0, LUKS_CIPHERMODE_L);
|
||||
strcpy(phdr->cipherMode, "ecb");
|
||||
need_write = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Old cryptsetup expects "sha1", gcrypt allows case insensitive names,
|
||||
* so always convert hash to lower case in header
|
||||
*/
|
||||
if (_to_lower(phdr->hashSpec, LUKS_HASHSPEC_L)) {
|
||||
log_err(ctx, _("Cipher hash repaired to lowercase (%s)."), phdr->hashSpec);
|
||||
if (crypt_hmac_size(phdr->hashSpec) < LUKS_DIGESTSIZE) {
|
||||
log_err(ctx, _("Requested LUKS hash %s is not supported."), phdr->hashSpec);
|
||||
return -EINVAL;
|
||||
}
|
||||
need_write = 1;
|
||||
}
|
||||
|
||||
r = LUKS_check_cipher(ctx, phdr->keyBytes, phdr->cipherName, phdr->cipherMode);
|
||||
if (r < 0)
|
||||
return -EINVAL;
|
||||
|
||||
vk = crypt_alloc_volume_key(phdr->keyBytes, NULL);
|
||||
if (!vk)
|
||||
return -ENOMEM;
|
||||
|
||||
log_verbose(ctx, _("Repairing keyslots."));
|
||||
|
||||
@@ -466,12 +517,13 @@ static int _check_and_convert_hdr(const char *device,
|
||||
unsigned int i;
|
||||
char luksMagic[] = LUKS_MAGIC;
|
||||
|
||||
if(memcmp(hdr->magic, luksMagic, LUKS_MAGIC_L)) { /* Check magic */
|
||||
hdr->version = be16_to_cpu(hdr->version);
|
||||
if (memcmp(hdr->magic, luksMagic, LUKS_MAGIC_L)) { /* Check magic */
|
||||
log_dbg(ctx, "LUKS header not detected.");
|
||||
if (require_luks_device)
|
||||
log_err(ctx, _("Device %s is not a valid LUKS device."), device);
|
||||
return -EINVAL;
|
||||
} else if((hdr->version = ntohs(hdr->version)) != 1) { /* Convert every uint16/32_t item from network byte order */
|
||||
} else if (hdr->version != 1) {
|
||||
log_err(ctx, _("Unsupported LUKS version %d."), hdr->version);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -479,19 +531,19 @@ static int _check_and_convert_hdr(const char *device,
|
||||
hdr->hashSpec[LUKS_HASHSPEC_L - 1] = '\0';
|
||||
if (crypt_hmac_size(hdr->hashSpec) < LUKS_DIGESTSIZE) {
|
||||
log_err(ctx, _("Requested LUKS hash %s is not supported."), hdr->hashSpec);
|
||||
return -EINVAL;
|
||||
r = -EINVAL;
|
||||
}
|
||||
|
||||
/* Header detected */
|
||||
hdr->payloadOffset = ntohl(hdr->payloadOffset);
|
||||
hdr->keyBytes = ntohl(hdr->keyBytes);
|
||||
hdr->mkDigestIterations = ntohl(hdr->mkDigestIterations);
|
||||
hdr->payloadOffset = be32_to_cpu(hdr->payloadOffset);
|
||||
hdr->keyBytes = be32_to_cpu(hdr->keyBytes);
|
||||
hdr->mkDigestIterations = be32_to_cpu(hdr->mkDigestIterations);
|
||||
|
||||
for(i = 0; i < LUKS_NUMKEYS; ++i) {
|
||||
hdr->keyblock[i].active = ntohl(hdr->keyblock[i].active);
|
||||
hdr->keyblock[i].passwordIterations = ntohl(hdr->keyblock[i].passwordIterations);
|
||||
hdr->keyblock[i].keyMaterialOffset = ntohl(hdr->keyblock[i].keyMaterialOffset);
|
||||
hdr->keyblock[i].stripes = ntohl(hdr->keyblock[i].stripes);
|
||||
for (i = 0; i < LUKS_NUMKEYS; ++i) {
|
||||
hdr->keyblock[i].active = be32_to_cpu(hdr->keyblock[i].active);
|
||||
hdr->keyblock[i].passwordIterations = be32_to_cpu(hdr->keyblock[i].passwordIterations);
|
||||
hdr->keyblock[i].keyMaterialOffset = be32_to_cpu(hdr->keyblock[i].keyMaterialOffset);
|
||||
hdr->keyblock[i].stripes = be32_to_cpu(hdr->keyblock[i].stripes);
|
||||
}
|
||||
|
||||
if (LUKS_check_keyslots(ctx, hdr))
|
||||
@@ -503,6 +555,16 @@ static int _check_and_convert_hdr(const char *device,
|
||||
hdr->uuid[UUID_STRING_L - 1] = '\0';
|
||||
|
||||
if (repair) {
|
||||
if (!strncmp(hdr->cipherMode, "ecb-", 4)) {
|
||||
log_err(ctx, _("LUKS cipher mode %s is invalid."), hdr->cipherMode);
|
||||
r = -EINVAL;
|
||||
}
|
||||
|
||||
if (_is_not_lower(hdr->hashSpec, LUKS_HASHSPEC_L)) {
|
||||
log_err(ctx, _("LUKS hash %s is invalid."), hdr->hashSpec);
|
||||
r = -EINVAL;
|
||||
}
|
||||
|
||||
if (r == -EINVAL)
|
||||
r = _keyslot_repair(hdr, ctx);
|
||||
else
|
||||
@@ -512,27 +574,6 @@ static int _check_and_convert_hdr(const char *device,
|
||||
return r;
|
||||
}
|
||||
|
||||
static void _to_lower(char *str, unsigned max_len)
|
||||
{
|
||||
for(; *str && max_len; str++, max_len--)
|
||||
if (isupper(*str))
|
||||
*str = tolower(*str);
|
||||
}
|
||||
|
||||
static void LUKS_fix_header_compatible(struct luks_phdr *header)
|
||||
{
|
||||
/* Old cryptsetup expects "sha1", gcrypt allows case insensitive names,
|
||||
* so always convert hash to lower case in header */
|
||||
_to_lower(header->hashSpec, LUKS_HASHSPEC_L);
|
||||
|
||||
/* ECB mode does not use IV but dmcrypt silently allows it.
|
||||
* Drop any IV here if ECB is used (that is not secure anyway).*/
|
||||
if (!strncmp(header->cipherMode, "ecb-", 4)) {
|
||||
memset(header->cipherMode, 0, LUKS_CIPHERMODE_L);
|
||||
strcpy(header->cipherMode, "ecb");
|
||||
}
|
||||
}
|
||||
|
||||
int LUKS_read_phdr_backup(const char *backup_file,
|
||||
struct luks_phdr *hdr,
|
||||
int require_luks_device,
|
||||
@@ -552,11 +593,9 @@ int LUKS_read_phdr_backup(const char *backup_file,
|
||||
|
||||
if (read_buffer(devfd, hdr, hdr_size) < hdr_size)
|
||||
r = -EIO;
|
||||
else {
|
||||
LUKS_fix_header_compatible(hdr);
|
||||
else
|
||||
r = _check_and_convert_hdr(backup_file, hdr,
|
||||
require_luks_device, 0, ctx);
|
||||
}
|
||||
|
||||
close(devfd);
|
||||
return r;
|
||||
@@ -643,15 +682,15 @@ int LUKS_write_phdr(struct luks_phdr *hdr,
|
||||
memset(&convHdr._padding, 0, sizeof(convHdr._padding));
|
||||
|
||||
/* Convert every uint16/32_t item to network byte order */
|
||||
convHdr.version = htons(hdr->version);
|
||||
convHdr.payloadOffset = htonl(hdr->payloadOffset);
|
||||
convHdr.keyBytes = htonl(hdr->keyBytes);
|
||||
convHdr.mkDigestIterations = htonl(hdr->mkDigestIterations);
|
||||
convHdr.version = cpu_to_be16(hdr->version);
|
||||
convHdr.payloadOffset = cpu_to_be32(hdr->payloadOffset);
|
||||
convHdr.keyBytes = cpu_to_be32(hdr->keyBytes);
|
||||
convHdr.mkDigestIterations = cpu_to_be32(hdr->mkDigestIterations);
|
||||
for(i = 0; i < LUKS_NUMKEYS; ++i) {
|
||||
convHdr.keyblock[i].active = htonl(hdr->keyblock[i].active);
|
||||
convHdr.keyblock[i].passwordIterations = htonl(hdr->keyblock[i].passwordIterations);
|
||||
convHdr.keyblock[i].keyMaterialOffset = htonl(hdr->keyblock[i].keyMaterialOffset);
|
||||
convHdr.keyblock[i].stripes = htonl(hdr->keyblock[i].stripes);
|
||||
convHdr.keyblock[i].active = cpu_to_be32(hdr->keyblock[i].active);
|
||||
convHdr.keyblock[i].passwordIterations = cpu_to_be32(hdr->keyblock[i].passwordIterations);
|
||||
convHdr.keyblock[i].keyMaterialOffset = cpu_to_be32(hdr->keyblock[i].keyMaterialOffset);
|
||||
convHdr.keyblock[i].stripes = cpu_to_be32(hdr->keyblock[i].stripes);
|
||||
}
|
||||
|
||||
r = write_lseek_blockwise(devfd, device_block_size(ctx, device), device_alignment(device),
|
||||
@@ -764,11 +803,10 @@ int LUKS_generate_phdr(struct luks_phdr *header,
|
||||
strncpy(header->cipherName,cipherName,LUKS_CIPHERNAME_L-1);
|
||||
strncpy(header->cipherMode,cipherMode,LUKS_CIPHERMODE_L-1);
|
||||
strncpy(header->hashSpec,hashSpec,LUKS_HASHSPEC_L-1);
|
||||
_to_lower(header->hashSpec, LUKS_HASHSPEC_L);
|
||||
|
||||
header->keyBytes=vk->keylength;
|
||||
|
||||
LUKS_fix_header_compatible(header);
|
||||
|
||||
log_dbg(ctx, "Generating LUKS header version %d using hash %s, %s, %s, MK %d bytes",
|
||||
header->version, header->hashSpec ,header->cipherName, header->cipherMode,
|
||||
header->keyBytes);
|
||||
@@ -779,7 +817,7 @@ int LUKS_generate_phdr(struct luks_phdr *header,
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Compute master key digest */
|
||||
/* Compute volume key digest */
|
||||
pbkdf = crypt_get_pbkdf(ctx);
|
||||
r = crypt_benchmark_pbkdf_internal(ctx, pbkdf, vk->keylength);
|
||||
if (r < 0)
|
||||
@@ -793,7 +831,7 @@ int LUKS_generate_phdr(struct luks_phdr *header,
|
||||
|
||||
if (PBKDF2_temp > (double)UINT32_MAX)
|
||||
return -EINVAL;
|
||||
header->mkDigestIterations = at_least((uint32_t)PBKDF2_temp, LUKS_MKD_ITERATIONS_MIN);
|
||||
header->mkDigestIterations = AT_LEAST((uint32_t)PBKDF2_temp, LUKS_MKD_ITERATIONS_MIN);
|
||||
assert(header->mkDigestIterations);
|
||||
|
||||
r = crypt_pbkdf(CRYPT_KDF_PBKDF2, header->hashSpec, vk->key,vk->keylength,
|
||||
@@ -867,7 +905,7 @@ int LUKS_set_key(unsigned int keyIndex,
|
||||
* Final iteration count is at least LUKS_SLOT_ITERATIONS_MIN
|
||||
*/
|
||||
hdr->keyblock[keyIndex].passwordIterations =
|
||||
at_least(pbkdf->iterations, LUKS_SLOT_ITERATIONS_MIN);
|
||||
AT_LEAST(pbkdf->iterations, LUKS_SLOT_ITERATIONS_MIN);
|
||||
log_dbg(ctx, "Key slot %d use %" PRIu32 " password iterations.", keyIndex,
|
||||
hdr->keyblock[keyIndex].passwordIterations);
|
||||
|
||||
@@ -888,7 +926,7 @@ int LUKS_set_key(unsigned int keyIndex,
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* AF splitting, the masterkey stored in vk->key is split to AfKey
|
||||
* AF splitting, the volume key stored in vk->key is split to AfKey
|
||||
*/
|
||||
assert(vk->keylength == hdr->keyBytes);
|
||||
AFEKSize = AF_split_sectors(vk->keylength, hdr->keyblock[keyIndex].stripes) * SECTOR_SIZE;
|
||||
@@ -944,7 +982,7 @@ int LUKS_verify_volume_key(const struct luks_phdr *hdr,
|
||||
hdr->mkDigestIterations, 0, 0) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (memcmp(checkHashBuf, hdr->mkDigest, LUKS_DIGESTSIZE))
|
||||
if (crypt_backend_memeq(checkHashBuf, hdr->mkDigest, LUKS_DIGESTSIZE))
|
||||
return -EPERM;
|
||||
|
||||
return 0;
|
||||
@@ -955,12 +993,12 @@ static int LUKS_open_key(unsigned int keyIndex,
|
||||
const char *password,
|
||||
size_t passwordLen,
|
||||
struct luks_phdr *hdr,
|
||||
struct volume_key *vk,
|
||||
struct volume_key **vk,
|
||||
struct crypt_device *ctx)
|
||||
{
|
||||
crypt_keyslot_info ki = LUKS_keyslot_info(hdr, keyIndex);
|
||||
struct volume_key *derived_key;
|
||||
char *AfKey;
|
||||
char *AfKey = NULL;
|
||||
size_t AFEKSize;
|
||||
int r;
|
||||
|
||||
@@ -974,8 +1012,13 @@ static int LUKS_open_key(unsigned int keyIndex,
|
||||
if (!derived_key)
|
||||
return -ENOMEM;
|
||||
|
||||
assert(vk->keylength == hdr->keyBytes);
|
||||
AFEKSize = AF_split_sectors(vk->keylength, hdr->keyblock[keyIndex].stripes) * SECTOR_SIZE;
|
||||
*vk = crypt_alloc_volume_key(hdr->keyBytes, NULL);
|
||||
if (!*vk) {
|
||||
r = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
AFEKSize = AF_split_sectors(hdr->keyBytes, hdr->keyblock[keyIndex].stripes) * SECTOR_SIZE;
|
||||
AfKey = crypt_safe_alloc(AFEKSize);
|
||||
if (!AfKey) {
|
||||
r = -ENOMEM;
|
||||
@@ -1001,16 +1044,20 @@ static int LUKS_open_key(unsigned int keyIndex,
|
||||
if (r < 0)
|
||||
goto out;
|
||||
|
||||
r = AF_merge(ctx, AfKey, vk->key, vk->keylength, hdr->keyblock[keyIndex].stripes, hdr->hashSpec);
|
||||
r = AF_merge(AfKey, (*vk)->key, (*vk)->keylength, hdr->keyblock[keyIndex].stripes, hdr->hashSpec);
|
||||
if (r < 0)
|
||||
goto out;
|
||||
|
||||
r = LUKS_verify_volume_key(hdr, vk);
|
||||
r = LUKS_verify_volume_key(hdr, *vk);
|
||||
|
||||
/* Allow only empty passphrase with null cipher */
|
||||
if (!r && !strcmp(hdr->cipherName, "cipher_null") && passwordLen)
|
||||
if (!r && crypt_is_cipher_null(hdr->cipherName) && passwordLen)
|
||||
r = -EPERM;
|
||||
out:
|
||||
if (r < 0) {
|
||||
crypt_free_volume_key(*vk);
|
||||
*vk = NULL;
|
||||
}
|
||||
crypt_safe_free(AfKey);
|
||||
crypt_free_volume_key(derived_key);
|
||||
return r;
|
||||
@@ -1026,16 +1073,14 @@ int LUKS_open_key_with_hdr(int keyIndex,
|
||||
unsigned int i, tried = 0;
|
||||
int r;
|
||||
|
||||
*vk = crypt_alloc_volume_key(hdr->keyBytes, NULL);
|
||||
|
||||
if (keyIndex >= 0) {
|
||||
r = LUKS_open_key(keyIndex, password, passwordLen, hdr, *vk, ctx);
|
||||
r = LUKS_open_key(keyIndex, password, passwordLen, hdr, vk, ctx);
|
||||
return (r < 0) ? r : keyIndex;
|
||||
}
|
||||
|
||||
for (i = 0; i < LUKS_NUMKEYS; i++) {
|
||||
r = LUKS_open_key(i, password, passwordLen, hdr, *vk, ctx);
|
||||
if(r == 0)
|
||||
r = LUKS_open_key(i, password, passwordLen, hdr, vk, ctx);
|
||||
if (r == 0)
|
||||
return i;
|
||||
|
||||
/* Do not retry for errors that are no -EPERM or -ENOENT,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* LUKS - Linux Unified Key Setup
|
||||
*
|
||||
* Copyright (C) 2004-2006 Clemens Fruhwirth <clemens@endorphin.org>
|
||||
* Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2009-2022 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* LUKS - Linux Unified Key Setup v2
|
||||
*
|
||||
* Copyright (C) 2015-2020 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2015-2020 Milan Broz
|
||||
* Copyright (C) 2015-2022 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2015-2022 Milan Broz
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -23,6 +23,8 @@
|
||||
#define _CRYPTSETUP_LUKS2_ONDISK_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "libcryptsetup.h"
|
||||
|
||||
@@ -42,6 +44,8 @@
|
||||
#define LUKS2_BUILTIN_TOKEN_PREFIX "luks2-"
|
||||
#define LUKS2_BUILTIN_TOKEN_PREFIX_LEN 6
|
||||
|
||||
#define LUKS2_TOKEN_NAME_MAX 64
|
||||
|
||||
#define LUKS2_TOKEN_KEYRING LUKS2_BUILTIN_TOKEN_PREFIX "keyring"
|
||||
|
||||
#define LUKS2_DIGEST_MAX 8
|
||||
@@ -58,7 +62,19 @@
|
||||
/* 1 GiB */
|
||||
#define LUKS2_REENCRYPT_MAX_HOTZONE_LENGTH 0x40000000
|
||||
|
||||
/* supported reencryption requirement versions */
|
||||
#define LUKS2_REENCRYPT_REQ_VERSION UINT8_C(2)
|
||||
#define LUKS2_DECRYPT_DATASHIFT_REQ_VERSION UINT8_C(3)
|
||||
|
||||
/* see reencrypt_assembly_verification_data() in luks2_reencrypt_digest.c */
|
||||
/* LUKS2_REENCRYPT_MAX_VERSION UINT8_C(207) */
|
||||
|
||||
struct device;
|
||||
struct luks2_reencrypt;
|
||||
struct reenc_protection;
|
||||
struct crypt_lock_handle;
|
||||
struct crypt_dm_active_device;
|
||||
struct luks_phdr; /* LUKS1 for conversion */
|
||||
|
||||
/*
|
||||
* LUKS2 header on-disk.
|
||||
@@ -94,7 +110,6 @@ struct luks2_hdr_disk {
|
||||
/*
|
||||
* LUKS2 header in-memory.
|
||||
*/
|
||||
typedef struct json_object json_object;
|
||||
struct luks2_hdr {
|
||||
size_t hdr_size;
|
||||
uint64_t seqid;
|
||||
@@ -105,7 +120,7 @@ struct luks2_hdr {
|
||||
uint8_t salt1[LUKS2_SALT_L];
|
||||
uint8_t salt2[LUKS2_SALT_L];
|
||||
char uuid[LUKS2_UUID_L];
|
||||
json_object *jobj;
|
||||
void *jobj;
|
||||
};
|
||||
|
||||
struct luks2_keyslot_params {
|
||||
@@ -127,77 +142,6 @@ struct luks2_keyslot_params {
|
||||
} area;
|
||||
};
|
||||
|
||||
struct reenc_protection {
|
||||
enum { REENC_PROTECTION_NONE = 0, /* none should be 0 always */
|
||||
REENC_PROTECTION_CHECKSUM,
|
||||
REENC_PROTECTION_JOURNAL,
|
||||
REENC_PROTECTION_DATASHIFT } type;
|
||||
|
||||
union {
|
||||
struct {
|
||||
} none;
|
||||
struct {
|
||||
char hash[LUKS2_CHECKSUM_ALG_L]; // or include luks.h
|
||||
struct crypt_hash *ch;
|
||||
size_t hash_size;
|
||||
/* buffer for checksums */
|
||||
void *checksums;
|
||||
size_t checksums_len;
|
||||
} csum;
|
||||
struct {
|
||||
} ds;
|
||||
} p;
|
||||
};
|
||||
|
||||
struct luks2_reenc_context {
|
||||
/* reencryption window attributes */
|
||||
uint64_t offset;
|
||||
uint64_t progress;
|
||||
uint64_t length;
|
||||
uint64_t data_shift;
|
||||
size_t alignment;
|
||||
uint64_t device_size;
|
||||
bool online;
|
||||
bool fixed_length;
|
||||
crypt_reencrypt_direction_info direction;
|
||||
crypt_reencrypt_mode_info mode;
|
||||
|
||||
char *device_name;
|
||||
char *hotzone_name;
|
||||
char *overlay_name;
|
||||
uint32_t flags;
|
||||
|
||||
/* reencryption window persistence attributes */
|
||||
struct reenc_protection rp;
|
||||
|
||||
int reenc_keyslot;
|
||||
|
||||
/* already running reencryption */
|
||||
json_object *jobj_segs_hot;
|
||||
json_object *jobj_segs_post;
|
||||
|
||||
/* backup segments */
|
||||
json_object *jobj_segment_new;
|
||||
int digest_new;
|
||||
json_object *jobj_segment_old;
|
||||
int digest_old;
|
||||
json_object *jobj_segment_moved;
|
||||
|
||||
struct volume_key *vks;
|
||||
|
||||
void *reenc_buffer;
|
||||
ssize_t read;
|
||||
|
||||
struct crypt_storage_wrapper *cw1;
|
||||
struct crypt_storage_wrapper *cw2;
|
||||
|
||||
uint32_t wflags1;
|
||||
uint32_t wflags2;
|
||||
|
||||
struct crypt_lock_handle *reenc_lock;
|
||||
};
|
||||
|
||||
crypt_reencrypt_info LUKS2_reenc_status(struct luks2_hdr *hdr);
|
||||
/*
|
||||
* Supportable header sizes (hdr_disk + JSON area)
|
||||
* Also used as offset for the 2nd header.
|
||||
@@ -220,13 +164,11 @@ crypt_reencrypt_info LUKS2_reenc_status(struct luks2_hdr *hdr);
|
||||
int LUKS2_hdr_version_unlocked(struct crypt_device *cd,
|
||||
const char *backup_file);
|
||||
|
||||
int LUKS2_device_write_lock(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr, struct device *device);
|
||||
|
||||
int LUKS2_hdr_read(struct crypt_device *cd, struct luks2_hdr *hdr, int repair);
|
||||
int LUKS2_hdr_write(struct crypt_device *cd, struct luks2_hdr *hdr);
|
||||
int LUKS2_hdr_write_force(struct crypt_device *cd, struct luks2_hdr *hdr);
|
||||
int LUKS2_hdr_dump(struct crypt_device *cd, struct luks2_hdr *hdr);
|
||||
int LUKS2_hdr_dump_json(struct crypt_device *cd, struct luks2_hdr *hdr, const char **json);
|
||||
|
||||
int LUKS2_hdr_uuid(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
@@ -247,9 +189,9 @@ int LUKS2_hdr_restore(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
const char *backup_file);
|
||||
|
||||
uint64_t LUKS2_hdr_and_areas_size(json_object *jobj);
|
||||
uint64_t LUKS2_keyslots_size(json_object *jobj);
|
||||
uint64_t LUKS2_metadata_size(json_object *jobj);
|
||||
uint64_t LUKS2_hdr_and_areas_size(struct luks2_hdr *hdr);
|
||||
uint64_t LUKS2_keyslots_size(struct luks2_hdr *hdr);
|
||||
uint64_t LUKS2_metadata_size(struct luks2_hdr *hdr);
|
||||
|
||||
int LUKS2_keyslot_cipher_incompatible(struct crypt_device *cd, const char *cipher_spec);
|
||||
|
||||
@@ -278,31 +220,12 @@ int LUKS2_keyslot_store(struct crypt_device *cd,
|
||||
const struct volume_key *vk,
|
||||
const struct luks2_keyslot_params *params);
|
||||
|
||||
int LUKS2_keyslot_reencrypt_store(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int keyslot,
|
||||
const void *buffer,
|
||||
size_t buffer_length);
|
||||
|
||||
int LUKS2_keyslot_reencrypt_create(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int keyslot,
|
||||
const struct crypt_params_reencrypt *params);
|
||||
|
||||
int reenc_keyslot_update(struct crypt_device *cd,
|
||||
const struct luks2_reenc_context *rh);
|
||||
|
||||
int LUKS2_keyslot_wipe(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int keyslot,
|
||||
int wipe_area_only);
|
||||
|
||||
int LUKS2_keyslot_dump(struct crypt_device *cd,
|
||||
int keyslot);
|
||||
|
||||
crypt_keyslot_priority LUKS2_keyslot_priority_get(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int keyslot);
|
||||
crypt_keyslot_priority LUKS2_keyslot_priority_get(struct luks2_hdr *hdr, int keyslot);
|
||||
|
||||
int LUKS2_keyslot_priority_set(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
@@ -310,11 +233,15 @@ int LUKS2_keyslot_priority_set(struct crypt_device *cd,
|
||||
crypt_keyslot_priority priority,
|
||||
int commit);
|
||||
|
||||
int LUKS2_keyslot_swap(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int keyslot,
|
||||
int keyslot2);
|
||||
|
||||
/*
|
||||
* Generic LUKS2 token
|
||||
*/
|
||||
int LUKS2_token_json_get(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int LUKS2_token_json_get(struct luks2_hdr *hdr,
|
||||
int token,
|
||||
const char **json);
|
||||
|
||||
@@ -325,11 +252,16 @@ int LUKS2_token_assign(struct crypt_device *cd,
|
||||
int assign,
|
||||
int commit);
|
||||
|
||||
int LUKS2_token_is_assigned(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int LUKS2_token_is_assigned(struct luks2_hdr *hdr,
|
||||
int keyslot,
|
||||
int token);
|
||||
|
||||
int LUKS2_token_assignment_copy(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int keyslot_from,
|
||||
int keyslot_to,
|
||||
int commit);
|
||||
|
||||
int LUKS2_token_create(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int token,
|
||||
@@ -341,89 +273,34 @@ crypt_token_info LUKS2_token_status(struct crypt_device *cd,
|
||||
int token,
|
||||
const char **type);
|
||||
|
||||
int LUKS2_builtin_token_get(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int token,
|
||||
const char *type,
|
||||
void *params);
|
||||
|
||||
int LUKS2_builtin_token_create(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int token,
|
||||
const char *type,
|
||||
const void *params,
|
||||
int commit);
|
||||
|
||||
int LUKS2_token_open_and_activate(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int token,
|
||||
const char *name,
|
||||
uint32_t flags,
|
||||
void *usrptr);
|
||||
|
||||
int LUKS2_token_open_and_activate_any(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int token,
|
||||
const char *name,
|
||||
uint32_t flags);
|
||||
const char *type,
|
||||
const char *pin,
|
||||
size_t pin_size,
|
||||
uint32_t flags,
|
||||
void *usrptr);
|
||||
|
||||
int LUKS2_tokens_count(struct luks2_hdr *hdr);
|
||||
|
||||
/*
|
||||
* Generic LUKS2 segment
|
||||
*/
|
||||
uint64_t json_segment_get_offset(json_object *jobj_segment, unsigned blockwise);
|
||||
const char *json_segment_type(json_object *jobj_segment);
|
||||
uint64_t json_segment_get_iv_offset(json_object *jobj_segment);
|
||||
uint64_t json_segment_get_size(json_object *jobj_segment, unsigned blockwise);
|
||||
const char *json_segment_get_cipher(json_object *jobj_segment);
|
||||
int json_segment_get_sector_size(json_object *jobj_segment);
|
||||
bool json_segment_is_backup(json_object *jobj_segment);
|
||||
json_object *json_segments_get_segment(json_object *jobj_segments, int segment);
|
||||
unsigned json_segments_count(json_object *jobj_segments);
|
||||
void json_segment_remove_flag(json_object *jobj_segment, const char *flag);
|
||||
uint64_t json_segments_get_minimal_offset(json_object *jobj_segments, unsigned blockwise);
|
||||
json_object *json_segment_create_linear(uint64_t offset, const uint64_t *length, unsigned reencryption);
|
||||
json_object *json_segment_create_crypt(uint64_t offset, uint64_t iv_offset, const uint64_t *length, const char *cipher, uint32_t sector_size, unsigned reencryption);
|
||||
int json_segments_segment_in_reencrypt(json_object *jobj_segments);
|
||||
|
||||
int LUKS2_segments_count(struct luks2_hdr *hdr);
|
||||
|
||||
int LUKS2_segment_first_unused_id(struct luks2_hdr *hdr);
|
||||
|
||||
int LUKS2_segment_set_flag(json_object *jobj_segment, const char *flag);
|
||||
|
||||
json_object *LUKS2_get_segment_by_flag(struct luks2_hdr *hdr, const char *flag);
|
||||
|
||||
int LUKS2_get_segment_id_by_flag(struct luks2_hdr *hdr, const char *flag);
|
||||
|
||||
int LUKS2_segments_set(struct crypt_device *cd,
|
||||
int LUKS2_token_unlock_volume_key(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
json_object *jobj_segments,
|
||||
int commit);
|
||||
int token,
|
||||
const char *type,
|
||||
const char *pin,
|
||||
size_t pin_size,
|
||||
uint32_t flags,
|
||||
void *usrptr,
|
||||
struct volume_key **vk);
|
||||
|
||||
uint64_t LUKS2_segment_offset(struct luks2_hdr *hdr,
|
||||
int segment,
|
||||
unsigned blockwise);
|
||||
int LUKS2_token_keyring_get(struct luks2_hdr *hdr,
|
||||
int token,
|
||||
struct crypt_token_params_luks2_keyring *keyring_params);
|
||||
|
||||
uint64_t LUKS2_segment_size(struct luks2_hdr *hdr,
|
||||
int segment,
|
||||
unsigned blockwise);
|
||||
int LUKS2_token_keyring_json(char *buffer, size_t buffer_size,
|
||||
const struct crypt_token_params_luks2_keyring *keyring_params);
|
||||
|
||||
int LUKS2_segment_is_type(struct luks2_hdr *hdr,
|
||||
int segment,
|
||||
const char *type);
|
||||
|
||||
int LUKS2_segment_by_type(struct luks2_hdr *hdr,
|
||||
const char *type);
|
||||
|
||||
int LUKS2_last_segment_by_type(struct luks2_hdr *hdr,
|
||||
const char *type);
|
||||
|
||||
int LUKS2_get_default_segment(struct luks2_hdr *hdr);
|
||||
|
||||
int LUKS2_reencrypt_digest_new(struct luks2_hdr *hdr);
|
||||
int LUKS2_reencrypt_digest_old(struct luks2_hdr *hdr);
|
||||
int LUKS2_reencrypt_data_offset(struct luks2_hdr *hdr, bool blockwise);
|
||||
void crypt_token_unload_external_all(struct crypt_device *cd);
|
||||
|
||||
/*
|
||||
* Generic LUKS2 digest
|
||||
@@ -432,29 +309,16 @@ int LUKS2_digest_any_matching(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
const struct volume_key *vk);
|
||||
|
||||
int LUKS2_digest_by_segment(struct luks2_hdr *hdr, int segment);
|
||||
|
||||
int LUKS2_digest_verify_by_digest(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int digest,
|
||||
const struct volume_key *vk);
|
||||
|
||||
int LUKS2_digest_verify_by_segment(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int segment,
|
||||
const struct volume_key *vk);
|
||||
|
||||
void LUKS2_digests_erase_unused(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr);
|
||||
|
||||
int LUKS2_digest_verify(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
const struct volume_key *vk,
|
||||
int keyslot);
|
||||
|
||||
int LUKS2_digest_dump(struct crypt_device *cd,
|
||||
int digest);
|
||||
|
||||
int LUKS2_digest_assign(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
int keyslot,
|
||||
@@ -471,6 +335,8 @@ int LUKS2_digest_segment_assign(struct crypt_device *cd,
|
||||
|
||||
int LUKS2_digest_by_keyslot(struct luks2_hdr *hdr, int keyslot);
|
||||
|
||||
int LUKS2_digest_by_segment(struct luks2_hdr *hdr, int segment);
|
||||
|
||||
int LUKS2_digest_create(struct crypt_device *cd,
|
||||
const char *type,
|
||||
struct luks2_hdr *hdr,
|
||||
@@ -490,20 +356,12 @@ int LUKS2_activate_multi(struct crypt_device *cd,
|
||||
uint64_t device_size,
|
||||
uint32_t flags);
|
||||
|
||||
struct crypt_dm_active_device;
|
||||
|
||||
int LUKS2_deactivate(struct crypt_device *cd,
|
||||
const char *name,
|
||||
struct luks2_hdr *hdr,
|
||||
struct crypt_dm_active_device *dmd,
|
||||
uint32_t flags);
|
||||
|
||||
int LUKS2_reload(struct crypt_device *cd,
|
||||
const char *name,
|
||||
struct volume_key *vks,
|
||||
uint64_t device_size,
|
||||
uint32_t flags);
|
||||
|
||||
int LUKS2_generate_hdr(
|
||||
struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
@@ -523,11 +381,11 @@ int LUKS2_check_metadata_area_size(uint64_t metadata_size);
|
||||
int LUKS2_check_keyslots_area_size(uint64_t keyslots_size);
|
||||
|
||||
int LUKS2_wipe_header_areas(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr);
|
||||
struct luks2_hdr *hdr, bool detached_header);
|
||||
|
||||
uint64_t LUKS2_get_data_offset(struct luks2_hdr *hdr);
|
||||
int LUKS2_get_data_size(struct luks2_hdr *hdr, uint64_t *size, bool *dynamic);
|
||||
int LUKS2_get_sector_size(struct luks2_hdr *hdr);
|
||||
uint32_t LUKS2_get_sector_size(struct luks2_hdr *hdr);
|
||||
const char *LUKS2_get_cipher(struct luks2_hdr *hdr, int segment);
|
||||
const char *LUKS2_get_integrity(struct luks2_hdr *hdr, int segment);
|
||||
int LUKS2_keyslot_params_default(struct crypt_device *cd, struct luks2_hdr *hdr,
|
||||
@@ -535,19 +393,14 @@ int LUKS2_keyslot_params_default(struct crypt_device *cd, struct luks2_hdr *hdr,
|
||||
int LUKS2_get_volume_key_size(struct luks2_hdr *hdr, int segment);
|
||||
int LUKS2_get_keyslot_stored_key_size(struct luks2_hdr *hdr, int keyslot);
|
||||
const char *LUKS2_get_keyslot_cipher(struct luks2_hdr *hdr, int keyslot, size_t *key_size);
|
||||
int LUKS2_keyslot_find_empty(struct luks2_hdr *hdr);
|
||||
int LUKS2_keyslot_find_empty(struct crypt_device *cd, struct luks2_hdr *hdr, size_t keylength);
|
||||
int LUKS2_keyslot_active_count(struct luks2_hdr *hdr, int segment);
|
||||
int LUKS2_keyslot_for_segment(struct luks2_hdr *hdr, int keyslot, int segment);
|
||||
int LUKS2_find_keyslot(struct luks2_hdr *hdr, const char *type);
|
||||
crypt_keyslot_info LUKS2_keyslot_info(struct luks2_hdr *hdr, int keyslot);
|
||||
int LUKS2_keyslot_area(struct luks2_hdr *hdr,
|
||||
int keyslot,
|
||||
uint64_t *offset,
|
||||
uint64_t *length);
|
||||
int LUKS2_keyslot_pbkdf(struct luks2_hdr *hdr, int keyslot, struct crypt_pbkdf_type *pbkdf);
|
||||
int LUKS2_set_keyslots_size(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
uint64_t data_offset);
|
||||
|
||||
/*
|
||||
* Permanent activation flags stored in header
|
||||
@@ -560,6 +413,11 @@ int LUKS2_config_set_flags(struct crypt_device *cd, struct luks2_hdr *hdr, uint3
|
||||
*/
|
||||
int LUKS2_config_get_requirements(struct crypt_device *cd, struct luks2_hdr *hdr, uint32_t *reqs);
|
||||
int LUKS2_config_set_requirements(struct crypt_device *cd, struct luks2_hdr *hdr, uint32_t reqs, bool commit);
|
||||
int LUKS2_config_set_requirement_version(struct crypt_device *cd, struct luks2_hdr *hdr, uint32_t req_id, uint8_t req_version, bool commit);
|
||||
|
||||
int LUKS2_config_get_reencrypt_version(struct luks2_hdr *hdr, uint8_t *version);
|
||||
|
||||
bool LUKS2_reencrypt_requirement_candidate(struct luks2_hdr *hdr);
|
||||
|
||||
int LUKS2_unmet_requirements(struct crypt_device *cd, struct luks2_hdr *hdr, uint32_t reqs_mask, int quiet);
|
||||
|
||||
@@ -568,9 +426,8 @@ int LUKS2_key_description_by_segment(struct crypt_device *cd,
|
||||
int LUKS2_volume_key_load_in_keyring_by_keyslot(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr, struct volume_key *vk, int keyslot);
|
||||
int LUKS2_volume_key_load_in_keyring_by_digest(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr, struct volume_key *vk, int digest);
|
||||
struct volume_key *vk, int digest);
|
||||
|
||||
struct luks_phdr;
|
||||
int LUKS2_luks1_to_luks2(struct crypt_device *cd,
|
||||
struct luks_phdr *hdr1,
|
||||
struct luks2_hdr *hdr2);
|
||||
@@ -586,24 +443,43 @@ int LUKS2_reencrypt_locked_recovery_by_passphrase(struct crypt_device *cd,
|
||||
int keyslot_new,
|
||||
const char *passphrase,
|
||||
size_t passphrase_size,
|
||||
uint32_t flags,
|
||||
struct volume_key **vks);
|
||||
|
||||
void LUKS2_reenc_context_free(struct crypt_device *cd, struct luks2_reenc_context *rh);
|
||||
void LUKS2_reencrypt_free(struct crypt_device *cd,
|
||||
struct luks2_reencrypt *rh);
|
||||
|
||||
int LUKS2_assembly_multisegment_dmd(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
struct volume_key *vks,
|
||||
json_object *jobj_segments,
|
||||
struct crypt_dm_active_device *dmd);
|
||||
crypt_reencrypt_info LUKS2_reencrypt_status(struct luks2_hdr *hdr);
|
||||
|
||||
crypt_reencrypt_info LUKS2_reencrypt_status(struct crypt_device *cd,
|
||||
crypt_reencrypt_info LUKS2_reencrypt_get_params(struct luks2_hdr *hdr,
|
||||
struct crypt_params_reencrypt *params);
|
||||
|
||||
int crypt_reencrypt_lock(struct crypt_device *cd, struct crypt_lock_handle **reencrypt_lock);
|
||||
int crypt_reencrypt_lock_by_dm_uuid(struct crypt_device *cd, const char *dm_uuid, struct crypt_lock_handle **reencrypt_lock);
|
||||
void crypt_reencrypt_unlock(struct crypt_device *cd, struct crypt_lock_handle *reencrypt_lock);
|
||||
int LUKS2_reencrypt_lock(struct crypt_device *cd,
|
||||
struct crypt_lock_handle **reencrypt_lock);
|
||||
|
||||
int luks2_check_device_size(struct crypt_device *cd, struct luks2_hdr *hdr, uint64_t check_size, uint64_t *dev_size, bool activation, bool dynamic);
|
||||
int LUKS2_reencrypt_lock_by_dm_uuid(struct crypt_device *cd,
|
||||
const char *dm_uuid,
|
||||
struct crypt_lock_handle **reencrypt_lock);
|
||||
|
||||
void LUKS2_reencrypt_unlock(struct crypt_device *cd,
|
||||
struct crypt_lock_handle *reencrypt_lock);
|
||||
|
||||
int LUKS2_reencrypt_check_device_size(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
uint64_t check_size,
|
||||
uint64_t *dev_size,
|
||||
bool activation,
|
||||
bool dynamic);
|
||||
|
||||
int LUKS2_reencrypt_digest_verify(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
struct volume_key *vks);
|
||||
|
||||
int LUKS2_reencrypt_max_hotzone_size(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
const struct reenc_protection *rp,
|
||||
int reencrypt_keyslot,
|
||||
uint64_t *r_length);
|
||||
|
||||
void LUKS2_reencrypt_protection_erase(struct reenc_protection *rp);
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user