Line data Source code
1 116 : GQuark bd_crypto_error_quark (void) {
2 116 : return g_quark_from_static_string ("g-bd-crypto-error-quark");
3 : }
4 :
5 : /**
6 : * BDCryptoLUKSPBKDF
7 : * @type: PBKDF algorithm
8 : * @hash: hash for LUKS header or NULL
9 : * @max_memory_kb: requested memory cost (in KiB) or 0 for default (benchmark)
10 : * @iterations: requested iterations or 0 for default (benchmark)
11 : * @time_ms: requested time cost or 0 for default (benchmark)
12 : * @parallel_threads: requested parallel cost (threads) or 0 for default (benchmark)
13 : */
14 : /**
15 : * bd_crypto_luks_pbkdf_copy: (skip)
16 : * @pbkdf: (nullable): %BDCryptoLUKSPBKDF to copy
17 : *
18 : * Creates a new copy of @pbkdf.
19 : */
20 41 : BDCryptoLUKSPBKDF* bd_crypto_luks_pbkdf_copy (BDCryptoLUKSPBKDF *pbkdf) {
21 41 : if (pbkdf == NULL)
22 0 : return NULL;
23 :
24 41 : BDCryptoLUKSPBKDF *new_pbkdf = g_new0 (BDCryptoLUKSPBKDF, 1);
25 41 : new_pbkdf->type = g_strdup (pbkdf->type);
26 41 : new_pbkdf->hash = g_strdup (pbkdf->hash);
27 41 : new_pbkdf->max_memory_kb = pbkdf->max_memory_kb;
28 41 : new_pbkdf->iterations = pbkdf->iterations;
29 41 : new_pbkdf->time_ms = pbkdf->time_ms;
30 41 : new_pbkdf->parallel_threads = pbkdf->parallel_threads;
31 :
32 41 : return new_pbkdf;
33 : }
34 :
35 : /**
36 : * bd_crypto_luks_pbkdf_free: (skip)
37 : * @pbkdf: (nullable): %BDCryptoLUKSPBKDF to free
38 : *
39 : * Frees @pbkdf.
40 : */
41 82 : void bd_crypto_luks_pbkdf_free (BDCryptoLUKSPBKDF *pbkdf) {
42 82 : if (pbkdf == NULL)
43 0 : return;
44 :
45 82 : g_free (pbkdf->type);
46 82 : g_free (pbkdf->hash);
47 82 : g_free (pbkdf);
48 : }
49 :
50 : /**
51 : * bd_crypto_luks_pbkdf_new: (constructor)
52 : * @type: (nullable): PBKDF algorithm
53 : * @hash: (nullable): hash for LUKS header or NULL for default
54 : * @max_memory_kb: requested memory cost (in KiB) or 0 for default (benchmark)
55 : * @iterations: requested iterations or 0 for default (benchmark)
56 : * @time_ms: requested time cost or 0 for default (benchmark)
57 : * @parallel_threads: requested parallel cost (threads) or 0 for default (benchmark)
58 : *
59 : * Returns: (transfer full): a new pbkdf argument
60 : */
61 41 : BDCryptoLUKSPBKDF* bd_crypto_luks_pbkdf_new (const gchar *type, const gchar *hash, guint32 max_memory_kb, guint32 iterations, guint32 time_ms, guint32 parallel_threads) {
62 41 : BDCryptoLUKSPBKDF *ret = g_new0 (BDCryptoLUKSPBKDF, 1);
63 41 : ret->type = g_strdup (type);
64 41 : ret->hash = g_strdup (hash);
65 41 : ret->max_memory_kb = max_memory_kb;
66 41 : ret->iterations = iterations;
67 41 : ret->time_ms = time_ms;
68 41 : ret->parallel_threads = parallel_threads;
69 :
70 41 : return ret;
71 : }
72 :
73 6 : GType bd_crypto_luks_pbkdf_get_type () {
74 : static GType type = 0;
75 :
76 6 : if (G_UNLIKELY(type == 0)) {
77 1 : type = g_boxed_type_register_static("BDCryptoLUKSPBKDF",
78 : (GBoxedCopyFunc) bd_crypto_luks_pbkdf_copy,
79 : (GBoxedFreeFunc) bd_crypto_luks_pbkdf_free);
80 : }
81 :
82 6 : return type;
83 : }
84 :
85 : /**
86 : * BDCryptoLUKSExtra:
87 : * @data_alignment: data alignment in sectors, 0 for default/auto detection
88 : * @data_device: detached encrypted data device or NULL
89 : * @integrity: integrity algorithm (e.g. "hmac-sha256") or NULL for no integrity support
90 : * Note: this field is valid only for LUKS 2
91 : * @sector_size: encryption sector size, 0 for default (512)
92 : * Note: this field is valid only for LUKS 2
93 : * @label: LUKS header label or NULL
94 : * Note: this field is valid only for LUKS 2
95 : * @subsystem: LUKS header subsystem or NULL
96 : * Note: this field is valid only for LUKS 2
97 : * @pbkdf: key derivation function specification or NULL for default
98 : * Note: this field is valid only for LUKS 2
99 : */
100 : /**
101 : * bd_crypto_luks_extra_copy: (skip)
102 : * @extra: (nullable): %BDCryptoLUKSExtra to copy
103 : *
104 : * Creates a new copy of @extra.
105 : */
106 0 : BDCryptoLUKSExtra* bd_crypto_luks_extra_copy (BDCryptoLUKSExtra *extra) {
107 0 : if (extra == NULL)
108 0 : return NULL;
109 :
110 0 : BDCryptoLUKSExtra *new_extra = g_new0 (BDCryptoLUKSExtra, 1);
111 :
112 0 : new_extra->integrity = g_strdup (extra->integrity);
113 0 : new_extra->data_alignment = extra->data_alignment;
114 0 : new_extra->data_device = g_strdup (extra->data_device);
115 0 : new_extra->sector_size = extra->sector_size;
116 0 : new_extra->label = g_strdup (extra->label);
117 0 : new_extra->subsystem = g_strdup (extra->subsystem);
118 0 : new_extra->pbkdf = bd_crypto_luks_pbkdf_copy (extra->pbkdf);
119 :
120 0 : return new_extra;
121 : }
122 :
123 : /**
124 : * bd_crypto_luks_extra_free: (skip)
125 : * @extra: (nullable): %BDCryptoLUKSExtra to free
126 : *
127 : * Frees @extra.
128 : */
129 41 : void bd_crypto_luks_extra_free (BDCryptoLUKSExtra *extra) {
130 41 : if (extra == NULL)
131 0 : return;
132 :
133 41 : g_free (extra->integrity);
134 41 : g_free (extra->data_device);
135 41 : g_free (extra->label);
136 41 : g_free (extra->subsystem);
137 41 : bd_crypto_luks_pbkdf_free (extra->pbkdf);
138 41 : g_free (extra);
139 : }
140 :
141 : /**
142 : * bd_crypto_luks_extra_new: (constructor)
143 : * @data_alignment: data alignment in sectors, 0 for default/auto detection
144 : * @data_device: (nullable): detached encrypted data device or NULL
145 : * @integrity: (nullable): integrity algorithm (e.g. "hmac-sha256") or NULL for no integrity support
146 : * @sector_size: encryption sector size, 0 for default (512)
147 : * @label: (nullable): LUKS header label or NULL
148 : * @subsystem: (nullable): LUKS header subsystem or NULL
149 : * @pbkdf: (nullable): key derivation function specification or NULL for default
150 : *
151 : * Returns: (transfer full): a new LUKS extra argument
152 : */
153 41 : BDCryptoLUKSExtra* bd_crypto_luks_extra_new (guint64 data_alignment, const gchar *data_device, const gchar *integrity, guint32 sector_size, const gchar *label, const gchar *subsystem, BDCryptoLUKSPBKDF *pbkdf) {
154 41 : BDCryptoLUKSExtra *ret = g_new0 (BDCryptoLUKSExtra, 1);
155 41 : ret->integrity = g_strdup (integrity);
156 41 : ret->data_alignment = data_alignment;
157 41 : ret->data_device = g_strdup (data_device);
158 41 : ret->sector_size = sector_size;
159 41 : ret->label = g_strdup (label);
160 41 : ret->subsystem = g_strdup (subsystem);
161 41 : ret->pbkdf = bd_crypto_luks_pbkdf_copy (pbkdf);
162 :
163 41 : return ret;
164 : }
165 :
166 9 : GType bd_crypto_luks_extra_get_type () {
167 : static GType type = 0;
168 :
169 9 : if (G_UNLIKELY(type == 0)) {
170 1 : type = g_boxed_type_register_static("BDCryptoLUKSExtra",
171 : (GBoxedCopyFunc) bd_crypto_luks_extra_copy,
172 : (GBoxedFreeFunc) bd_crypto_luks_extra_free);
173 : }
174 :
175 9 : return type;
176 : }
177 :
178 : /**
179 : * BDCryptoIntegrityExtra:
180 : * @sector_size: integrity sector size
181 : * @journal_size: size of journal in bytes
182 : * @journal_watermark: journal flush watermark in percents; in bitmap mode sectors-per-bit
183 : * @journal_commit_time: journal commit time (or bitmap flush time) in ms
184 : * @interleave_sectors: number of interleave sectors (power of two)
185 : * @tag_size: tag size per-sector in bytes
186 : * @buffer_sectors: number of sectors in one buffer
187 : */
188 : /**
189 : * bd_crypto_integrity_extra_copy: (skip)
190 : * @extra: (nullable): %BDCryptoIntegrityExtra to copy
191 : *
192 : * Creates a new copy of @extra.
193 : */
194 0 : BDCryptoIntegrityExtra* bd_crypto_integrity_extra_copy (BDCryptoIntegrityExtra *extra) {
195 0 : if (extra == NULL)
196 0 : return NULL;
197 :
198 0 : BDCryptoIntegrityExtra *new_extra = g_new0 (BDCryptoIntegrityExtra, 1);
199 :
200 0 : new_extra->sector_size = extra->sector_size;
201 0 : new_extra->journal_size = extra->journal_size;
202 0 : new_extra->journal_watermark = extra->journal_watermark;
203 0 : new_extra->journal_commit_time = extra->journal_commit_time;
204 0 : new_extra->interleave_sectors = extra->interleave_sectors;
205 0 : new_extra->tag_size = extra->tag_size;
206 0 : new_extra->buffer_sectors = extra->buffer_sectors;
207 :
208 0 : return new_extra;
209 : }
210 :
211 : /**
212 : * bd_crypto_integrity_extra_free: (skip)
213 : * @extra: (nullable): %BDCryptoIntegrityExtra to free
214 : *
215 : * Frees @extra.
216 : */
217 1 : void bd_crypto_integrity_extra_free (BDCryptoIntegrityExtra *extra) {
218 1 : if (extra == NULL)
219 0 : return;
220 :
221 1 : g_free (extra);
222 : }
223 :
224 : /**
225 : * bd_crypto_integrity_extra_new: (constructor)
226 : * @sector_size: integrity sector size, 0 for default (512)
227 : * @journal_size: size of journal in bytes
228 : * @journal_watermark: journal flush watermark in percents; in bitmap mode sectors-per-bit
229 : * @journal_commit_time: journal commit time (or bitmap flush time) in ms
230 : * @interleave_sectors: number of interleave sectors (power of two)
231 : * @tag_size: tag size per-sector in bytes
232 : * @buffer_sectors: number of sectors in one buffer
233 : *
234 : * Returns: (transfer full): a new Integrity extra argument
235 : */
236 1 : BDCryptoIntegrityExtra* bd_crypto_integrity_extra_new (guint32 sector_size, guint64 journal_size, guint journal_watermark, guint journal_commit_time, guint64 interleave_sectors, guint64 tag_size, guint64 buffer_sectors) {
237 1 : BDCryptoIntegrityExtra *ret = g_new0 (BDCryptoIntegrityExtra, 1);
238 1 : ret->sector_size = sector_size;
239 1 : ret->journal_size = journal_size;
240 1 : ret->journal_watermark = journal_watermark;
241 1 : ret->journal_commit_time = journal_commit_time;
242 1 : ret->interleave_sectors = interleave_sectors;
243 1 : ret->tag_size = tag_size;
244 1 : ret->buffer_sectors = buffer_sectors;
245 :
246 1 : return ret;
247 : }
248 :
249 7 : GType bd_crypto_integrity_extra_get_type () {
250 : static GType type = 0;
251 :
252 7 : if (G_UNLIKELY(type == 0)) {
253 1 : type = g_boxed_type_register_static("BDCryptoIntegrityExtra",
254 : (GBoxedCopyFunc) bd_crypto_integrity_extra_copy,
255 : (GBoxedFreeFunc) bd_crypto_integrity_extra_free);
256 : }
257 :
258 7 : return type;
259 : }
260 :
261 : /**
262 : * BDCryptoLUKSHWEncryptionType:
263 : * @BD_CRYPTO_LUKS_HW_ENCRYPTION_UNKNOWN: used for unknown/unsupported hardware encryption or when
264 : * error was detected when getting the information
265 : * @BD_CRYPTO_LUKS_HW_ENCRYPTION_SW_ONLY: hardware encryption is not configured on this device
266 : * @BD_CRYPTO_LUKS_HW_ENCRYPTION_OPAL_HW_ONLY: only OPAL hardware encryption is configured on this device
267 : * @BD_CRYPTO_LUKS_HW_ENCRYPTION_OPAL_HW_AND_SW: both OPAL hardware encryption and software encryption
268 : * (using LUKS/dm-crypt) is configured on this device
269 : */
270 : /**
271 : * BDCryptoLUKSInfo:
272 : * @version: LUKS version
273 : * @cipher: used cipher (e.g. "aes")
274 : * @mode: used cipher mode (e.g. "xts-plain")
275 : * @uuid: UUID of the LUKS device
276 : * @backing_device: name of the underlying block device
277 : * @sector_size: size (in bytes) of encryption sector
278 : * Note: sector size is valid only for LUKS 2
279 : * @metadata_size: LUKS metadata size
280 : * @label: label of the LUKS device (valid only for LUKS 2)
281 : * @subsystem: subsystem of the LUKS device (valid only for LUKS 2)
282 : * @hw_encryption: hardware encryption type
283 : */
284 : /**
285 : * bd_crypto_luks_info_free: (skip)
286 : * @info: (nullable): %BDCryptoLUKSInfo to free
287 : *
288 : * Frees @info.
289 : */
290 22 : void bd_crypto_luks_info_free (BDCryptoLUKSInfo *info) {
291 22 : if (info == NULL)
292 0 : return;
293 :
294 22 : g_free (info->cipher);
295 22 : g_free (info->mode);
296 22 : g_free (info->uuid);
297 22 : g_free (info->backing_device);
298 22 : g_free (info->label);
299 22 : g_free (info->subsystem);
300 22 : g_free (info);
301 : }
302 :
303 : /**
304 : * bd_crypto_luks_info_copy: (skip)
305 : * @info: (nullable): %BDCryptoLUKSInfo to copy
306 : *
307 : * Creates a new copy of @info.
308 : */
309 0 : BDCryptoLUKSInfo* bd_crypto_luks_info_copy (BDCryptoLUKSInfo *info) {
310 0 : if (info == NULL)
311 0 : return NULL;
312 :
313 0 : BDCryptoLUKSInfo *new_info = g_new0 (BDCryptoLUKSInfo, 1);
314 :
315 0 : new_info->version = info->version;
316 0 : new_info->cipher = g_strdup (info->cipher);
317 0 : new_info->mode = g_strdup (info->mode);
318 0 : new_info->uuid = g_strdup (info->uuid);
319 0 : new_info->backing_device = g_strdup (info->backing_device);
320 0 : new_info->sector_size = info->sector_size;
321 0 : new_info->metadata_size = info->metadata_size;
322 0 : new_info->label = g_strdup (info->label);
323 0 : new_info->subsystem = g_strdup (info->subsystem);
324 0 : new_info->hw_encryption = info->hw_encryption;
325 :
326 0 : return new_info;
327 : }
328 :
329 60 : GType bd_crypto_luks_info_get_type () {
330 : static GType type = 0;
331 :
332 60 : if (G_UNLIKELY(type == 0)) {
333 1 : type = g_boxed_type_register_static("BDCryptoLUKSInfo",
334 : (GBoxedCopyFunc) bd_crypto_luks_info_copy,
335 : (GBoxedFreeFunc) bd_crypto_luks_info_free);
336 : }
337 :
338 60 : return type;
339 : }
340 :
341 : /**
342 : * BDCryptoBITLKInfo:
343 : * @cipher: used cipher (e.g. "aes")
344 : * @mode: used cipher mode (e.g. "xts-plain")
345 : * @uuid: UUID of the BITLK device
346 : * @backing_device: name of the underlying block device
347 : * @sector_size: size (in bytes) of encryption sector
348 : */
349 : /**
350 : * bd_crypto_bitlk_info_free: (skip)
351 : * @info: (nullable): %BDCryptoBITLKInfo to free
352 : *
353 : * Frees @info.
354 : */
355 6 : void bd_crypto_bitlk_info_free (BDCryptoBITLKInfo *info) {
356 6 : if (info == NULL)
357 0 : return;
358 :
359 6 : g_free (info->cipher);
360 6 : g_free (info->mode);
361 6 : g_free (info->uuid);
362 6 : g_free (info->backing_device);
363 6 : g_free (info);
364 : }
365 :
366 : /**
367 : * bd_crypto_bitlk_info_copy: (skip)
368 : * @info: (nullable): %BDCryptoBITLKInfo to copy
369 : *
370 : * Creates a new copy of @info.
371 : */
372 0 : BDCryptoBITLKInfo* bd_crypto_bitlk_info_copy (BDCryptoBITLKInfo *info) {
373 0 : if (info == NULL)
374 0 : return NULL;
375 :
376 0 : BDCryptoBITLKInfo *new_info = g_new0 (BDCryptoBITLKInfo, 1);
377 :
378 0 : new_info->cipher = g_strdup (info->cipher);
379 0 : new_info->mode = g_strdup (info->mode);
380 0 : new_info->uuid = g_strdup (info->uuid);
381 0 : new_info->backing_device = g_strdup (info->backing_device);
382 0 : new_info->sector_size = info->sector_size;
383 :
384 0 : return new_info;
385 : }
386 :
387 21 : GType bd_crypto_bitlk_info_get_type () {
388 : static GType type = 0;
389 :
390 21 : if (G_UNLIKELY(type == 0)) {
391 1 : type = g_boxed_type_register_static("BDCryptoBITLKInfo",
392 : (GBoxedCopyFunc) bd_crypto_bitlk_info_copy,
393 : (GBoxedFreeFunc) bd_crypto_bitlk_info_free);
394 : }
395 :
396 21 : return type;
397 : }
398 :
399 : /**
400 : * BDCryptoIntegrityInfo:
401 : * @algorithm: integrity algorithm
402 : * @key_size: integrity key size in bytes
403 : * @sector_size: sector size in bytes
404 : * @tag_size: tag size per-sector in bytes
405 : * @interleave_sectors: number of interleave sectors
406 : * @journal_size: size of journal in bytes
407 : * @journal_crypt: journal encryption algorithm
408 : * @journal_integrity: journal integrity algorithm
409 : */
410 : /**
411 : * bd_crypto_integrity_info_free: (skip)
412 : * @info: (nullable): %BDCryptoIntegrityInfo to free
413 : *
414 : * Frees @info.
415 : */
416 6 : void bd_crypto_integrity_info_free (BDCryptoIntegrityInfo *info) {
417 6 : if (info == NULL)
418 0 : return;
419 :
420 6 : g_free (info->algorithm);
421 6 : g_free (info->journal_crypt);
422 6 : g_free (info->journal_integrity);
423 6 : g_free (info);
424 : }
425 :
426 : /**
427 : * bd_crypto_integrity_info_copy: (skip)
428 : * @info: (nullable): %BDCryptoIntegrityInfo to copy
429 : *
430 : * Creates a new copy of @info.
431 : */
432 0 : BDCryptoIntegrityInfo* bd_crypto_integrity_info_copy (BDCryptoIntegrityInfo *info) {
433 0 : if (info == NULL)
434 0 : return NULL;
435 :
436 0 : BDCryptoIntegrityInfo *new_info = g_new0 (BDCryptoIntegrityInfo, 1);
437 :
438 0 : new_info->algorithm = g_strdup (info->algorithm);
439 0 : new_info->key_size = info->key_size;
440 0 : new_info->sector_size = info->sector_size;
441 0 : new_info->tag_size = info->tag_size;
442 0 : new_info->interleave_sectors = info->interleave_sectors;
443 0 : new_info->journal_size = info->journal_size;
444 0 : new_info->journal_crypt = g_strdup (info->journal_crypt);
445 0 : new_info->journal_integrity = g_strdup (info->journal_integrity);
446 :
447 0 : return new_info;
448 : }
449 :
450 12 : GType bd_crypto_integrity_info_get_type () {
451 : static GType type = 0;
452 :
453 12 : if (G_UNLIKELY(type == 0)) {
454 1 : type = g_boxed_type_register_static("BDCryptoIntegrityInfo",
455 : (GBoxedCopyFunc) bd_crypto_integrity_info_copy,
456 : (GBoxedFreeFunc) bd_crypto_integrity_info_free);
457 : }
458 :
459 12 : return type;
460 : }
461 :
462 : /**
463 : * BDCryptoLUKSTokenInfo:
464 : * @id: ID of the token
465 : * @type: type of the token
466 : * @keyslot: keyslot this token is assigned to or -1 for inactive/unassigned tokens
467 : */
468 : /**
469 : * bd_crypto_luks_token_info_free: (skip)
470 : * @info: (nullable): %BDCryptoLUKSTokenInfo to free
471 : *
472 : * Frees @info.
473 : */
474 3 : void bd_crypto_luks_token_info_free (BDCryptoLUKSTokenInfo *info) {
475 3 : if (info == NULL)
476 0 : return;
477 :
478 3 : g_free (info->type);
479 3 : g_free (info);
480 : }
481 :
482 : /**
483 : * bd_crypto_luks_token_info_copy: (skip)
484 : * @info: (nullable): %BDCryptoLUKSTokenInfo to copy
485 : *
486 : * Creates a new copy of @info.
487 : */
488 0 : BDCryptoLUKSTokenInfo* bd_crypto_luks_token_info_copy (BDCryptoLUKSTokenInfo *info) {
489 0 : if (info == NULL)
490 0 : return NULL;
491 :
492 0 : BDCryptoLUKSTokenInfo *new_info = g_new0 (BDCryptoLUKSTokenInfo, 1);
493 :
494 0 : new_info->id = info->id;
495 0 : new_info->type = g_strdup (info->type);
496 0 : new_info->keyslot = info->keyslot;
497 :
498 0 : return new_info;
499 : }
500 :
501 12 : GType bd_crypto_luks_token_info_get_type () {
502 : static GType type = 0;
503 :
504 12 : if (G_UNLIKELY(type == 0)) {
505 1 : type = g_boxed_type_register_static("BDCryptoLUKSTokenInfo",
506 : (GBoxedCopyFunc) bd_crypto_luks_token_info_copy,
507 : (GBoxedFreeFunc) bd_crypto_luks_token_info_free);
508 : }
509 :
510 12 : return type;
511 : }
512 :
513 : /**
514 : * bd_crypto_keyslot_context_free: (skip)
515 : * @context: (nullable): %BDCryptoKeyslotContext to free
516 : *
517 : * Frees @context.
518 : */
519 156 : void bd_crypto_keyslot_context_free (BDCryptoKeyslotContext *context) {
520 156 : if (context == NULL)
521 0 : return;
522 :
523 156 : if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_PASSPHRASE)
524 125 : g_free (context->u.passphrase.pass_data);
525 31 : else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE)
526 23 : g_free (context->u.keyfile.keyfile);
527 8 : else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYRING)
528 4 : g_free (context->u.keyring.key_desc);
529 4 : else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_VOLUME_KEY)
530 4 : g_free (context->u.volume_key.volume_key);
531 :
532 156 : g_free (context);
533 : }
534 :
535 : /**
536 : * bd_crypto_keyslot_context_copy: (skip)
537 : * @context: (nullable): %BDCryptoKeyslotContext to copy
538 : *
539 : * Creates a new copy of @context.
540 : */
541 0 : BDCryptoKeyslotContext* bd_crypto_keyslot_context_copy (BDCryptoKeyslotContext *context) {
542 0 : if (context == NULL)
543 0 : return NULL;
544 :
545 0 : BDCryptoKeyslotContext *new_context = g_new0 (BDCryptoKeyslotContext, 1);
546 0 : new_context->type = context->type;
547 :
548 0 : if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_PASSPHRASE) {
549 0 : new_context->u.passphrase.pass_data = g_new0 (guint8, context->u.passphrase.data_len);
550 0 : memcpy (new_context->u.passphrase.pass_data, context->u.passphrase.pass_data, context->u.passphrase.data_len);
551 0 : new_context->u.passphrase.data_len = context->u.passphrase.data_len;
552 0 : } else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE) {
553 0 : new_context->u.keyfile.keyfile = g_strdup (context->u.keyfile.keyfile);
554 0 : new_context->u.keyfile.keyfile_offset = context->u.keyfile.keyfile_offset;
555 0 : new_context->u.keyfile.key_size = context->u.keyfile.key_size;
556 0 : } else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYRING)
557 0 : new_context->u.keyring.key_desc = g_strdup (context->u.keyring.key_desc);
558 0 : else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_VOLUME_KEY) {
559 0 : new_context->u.volume_key.volume_key = g_new0 (guint8, context->u.volume_key.volume_key_size);
560 0 : memcpy (new_context->u.volume_key.volume_key, context->u.volume_key.volume_key, context->u.volume_key.volume_key_size);
561 0 : new_context->u.volume_key.volume_key_size = context->u.volume_key.volume_key_size;
562 : }
563 :
564 0 : return new_context;
565 : }
566 :
567 34 : GType bd_crypto_keyslot_context_get_type () {
568 : static GType type = 0;
569 :
570 34 : if (G_UNLIKELY(type == 0)) {
571 1 : type = g_boxed_type_register_static("BDCryptoKeyslotContext",
572 : (GBoxedCopyFunc) bd_crypto_keyslot_context_copy,
573 : (GBoxedFreeFunc) bd_crypto_keyslot_context_free);
574 : }
575 :
576 34 : return type;
577 : }
578 :
579 0 : static gboolean bd_crypto_is_tech_avail_stub (BDCryptoTech tech G_GNUC_UNUSED, guint64 mode G_GNUC_UNUSED, GError **error) {
580 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_is_tech_avail' called, but not implemented!");
581 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
582 : "The function 'bd_crypto_is_tech_avail' called, but not implemented!");
583 0 : return FALSE;
584 : }
585 :
586 : static gboolean (*_bd_crypto_is_tech_avail) (BDCryptoTech tech, guint64 mode, GError **error) = bd_crypto_is_tech_avail_stub;
587 :
588 : /**
589 : * bd_crypto_is_tech_avail:
590 : * @tech: the queried tech
591 : * @mode: a bit mask of queried modes of operation (#BDCryptoTechMode) for @tech
592 : * @error: (out) (optional): place to store error (details about why the @tech-@mode combination is not available)
593 : *
594 : * Returns: whether the @tech-@mode combination is available -- supported by the
595 : * plugin implementation and having all the runtime dependencies available
596 : */
597 5 : gboolean bd_crypto_is_tech_avail (BDCryptoTech tech, guint64 mode, GError **error) {
598 5 : return _bd_crypto_is_tech_avail (tech, mode, error);
599 : }
600 :
601 :
602 0 : static gchar* bd_crypto_generate_backup_passphrase_stub (GError **error) {
603 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_generate_backup_passphrase' called, but not implemented!");
604 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
605 : "The function 'bd_crypto_generate_backup_passphrase' called, but not implemented!");
606 0 : return NULL;
607 : }
608 :
609 : static gchar* (*_bd_crypto_generate_backup_passphrase) (GError **error) = bd_crypto_generate_backup_passphrase_stub;
610 :
611 : /**
612 : * bd_crypto_generate_backup_passphrase:
613 : * @error: (out) (optional): place to store error (if any)
614 : *
615 : * Returns: A newly generated %BD_CRYPTO_BACKUP_PASSPHRASE_LENGTH-long passphrase.
616 : *
617 : * See %BD_CRYPTO_BACKUP_PASSPHRASE_CHARSET for the definition of the charset used for the passphrase.
618 : *
619 : * Tech category: always available
620 : */
621 101 : gchar* bd_crypto_generate_backup_passphrase (GError **error) {
622 101 : return _bd_crypto_generate_backup_passphrase (error);
623 : }
624 :
625 :
626 0 : static gboolean bd_crypto_device_is_luks_stub (const gchar *device G_GNUC_UNUSED, GError **error) {
627 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_device_is_luks' called, but not implemented!");
628 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
629 : "The function 'bd_crypto_device_is_luks' called, but not implemented!");
630 0 : return FALSE;
631 : }
632 :
633 : static gboolean (*_bd_crypto_device_is_luks) (const gchar *device, GError **error) = bd_crypto_device_is_luks_stub;
634 :
635 : /**
636 : * bd_crypto_device_is_luks:
637 : * @device: the queried device
638 : * @error: (out) (optional): place to store error (if any)
639 : *
640 : * Returns: %TRUE if the given @device is a LUKS device or %FALSE if not or
641 : * failed to determine (the @error) is populated with the error in such
642 : * cases)
643 : *
644 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_QUERY
645 : */
646 4 : gboolean bd_crypto_device_is_luks (const gchar *device, GError **error) {
647 4 : return _bd_crypto_device_is_luks (device, error);
648 : }
649 :
650 :
651 0 : static const gchar* bd_crypto_luks_status_stub (const gchar *luks_device G_GNUC_UNUSED, GError **error) {
652 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_status' called, but not implemented!");
653 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
654 : "The function 'bd_crypto_luks_status' called, but not implemented!");
655 0 : return NULL;
656 : }
657 :
658 : static const gchar* (*_bd_crypto_luks_status) (const gchar *luks_device, GError **error) = bd_crypto_luks_status_stub;
659 :
660 : /**
661 : * bd_crypto_luks_status:
662 : * @luks_device: the queried LUKS device
663 : * @error: (out) (optional): place to store error (if any)
664 : *
665 : * Returns: (transfer none): one of "invalid", "inactive", "active" or "busy" or
666 : * %NULL if failed to determine (@error is populated with the error in
667 : * such cases)
668 : *
669 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_QUERY
670 : */
671 8 : const gchar* bd_crypto_luks_status (const gchar *luks_device, GError **error) {
672 8 : return _bd_crypto_luks_status (luks_device, error);
673 : }
674 :
675 :
676 0 : static BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_passphrase_stub (const guint8 *pass_data G_GNUC_UNUSED, gsize data_len G_GNUC_UNUSED, GError **error) {
677 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_keyslot_context_new_passphrase' called, but not implemented!");
678 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
679 : "The function 'bd_crypto_keyslot_context_new_passphrase' called, but not implemented!");
680 0 : return NULL;
681 : }
682 :
683 : static BDCryptoKeyslotContext* (*_bd_crypto_keyslot_context_new_passphrase) (const guint8 *pass_data, gsize data_len, GError **error) = bd_crypto_keyslot_context_new_passphrase_stub;
684 :
685 : /**
686 : * bd_crypto_keyslot_context_new_passphrase:
687 : * @pass_data: (array length=data_len): a passphrase for the new context (may contain arbitrary binary data)
688 : * @data_len: length of the @pass_data buffer
689 : * @error: (out) (optional): place to store error (if any)
690 : *
691 : * Returns (transfer full): new %BDCryptoKeyslotContext initialized by passphrase or
692 : * %NULL in case of error
693 : *
694 : * Tech category: always available
695 : */
696 125 : BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_passphrase (const guint8 *pass_data, gsize data_len, GError **error) {
697 125 : return _bd_crypto_keyslot_context_new_passphrase (pass_data, data_len, error);
698 : }
699 :
700 :
701 0 : static BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyfile_stub (const gchar *keyfile G_GNUC_UNUSED, guint64 keyfile_offset G_GNUC_UNUSED, gsize key_size G_GNUC_UNUSED, GError **error) {
702 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_keyslot_context_new_keyfile' called, but not implemented!");
703 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
704 : "The function 'bd_crypto_keyslot_context_new_keyfile' called, but not implemented!");
705 0 : return NULL;
706 : }
707 :
708 : static BDCryptoKeyslotContext* (*_bd_crypto_keyslot_context_new_keyfile) (const gchar *keyfile, guint64 keyfile_offset, gsize key_size, GError **error) = bd_crypto_keyslot_context_new_keyfile_stub;
709 :
710 : /**
711 : * bd_crypto_keyslot_context_new_keyfile:
712 : * @keyfile: a key file for the new context
713 : * @keyfile_offset: number of bytes to read from @keyfile or 0 for unlimited
714 : * @key_size: number of bytes to skip at start of @keyfile
715 : * @error: (out) (optional): place to store error (if any)
716 : *
717 : * Returns (transfer full): new %BDCryptoKeyslotContext initialized by key file or
718 : * %NULL in case of error
719 : *
720 : * Tech category: always available
721 : */
722 23 : BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyfile (const gchar *keyfile, guint64 keyfile_offset, gsize key_size, GError **error) {
723 23 : return _bd_crypto_keyslot_context_new_keyfile (keyfile, keyfile_offset, key_size, error);
724 : }
725 :
726 :
727 0 : static BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyring_stub (const gchar *key_desc G_GNUC_UNUSED, GError **error) {
728 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_keyslot_context_new_keyring' called, but not implemented!");
729 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
730 : "The function 'bd_crypto_keyslot_context_new_keyring' called, but not implemented!");
731 0 : return NULL;
732 : }
733 :
734 : static BDCryptoKeyslotContext* (*_bd_crypto_keyslot_context_new_keyring) (const gchar *key_desc, GError **error) = bd_crypto_keyslot_context_new_keyring_stub;
735 :
736 : /**
737 : * bd_crypto_keyslot_context_new_keyring:
738 : * @key_desc: kernel keyring key description
739 : * @error: (out) (optional): place to store error (if any)
740 : *
741 : * Returns (transfer full): new %BDCryptoKeyslotContext initialized by @key_desc or
742 : * %NULL in case of error
743 : *
744 : * Note: Keyslot passphrase must be stored in 'user' key type and the key has to be reachable
745 : * by process context on behalf of which this function is called.
746 : *
747 : * Tech category: always available
748 : */
749 4 : BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_keyring (const gchar *key_desc, GError **error) {
750 4 : return _bd_crypto_keyslot_context_new_keyring (key_desc, error);
751 : }
752 :
753 :
754 0 : static BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_volume_key_stub (const guint8 *volume_key G_GNUC_UNUSED, gsize volume_key_size G_GNUC_UNUSED, GError **error) {
755 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_keyslot_context_new_volume_key' called, but not implemented!");
756 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
757 : "The function 'bd_crypto_keyslot_context_new_volume_key' called, but not implemented!");
758 0 : return NULL;
759 : }
760 :
761 : static BDCryptoKeyslotContext* (*_bd_crypto_keyslot_context_new_volume_key) (const guint8 *volume_key, gsize volume_key_size, GError **error) = bd_crypto_keyslot_context_new_volume_key_stub;
762 :
763 : /**
764 : * bd_crypto_keyslot_context_new_volume_key:
765 : * @volume_key: (array length=volume_key_size): a volume key for the new context (may contain arbitrary binary data)
766 : * @volume_key_size: length of the @volume_key_size buffer
767 : * @error: (out) (optional): place to store error (if any)
768 : *
769 : * Returns (transfer full): new %BDCryptoKeyslotContext initialized by volume key or
770 : * %NULL in case of error
771 : *
772 : * Tech category: always available
773 : */
774 4 : BDCryptoKeyslotContext* bd_crypto_keyslot_context_new_volume_key (const guint8 *volume_key, gsize volume_key_size, GError **error) {
775 4 : return _bd_crypto_keyslot_context_new_volume_key (volume_key, volume_key_size, error);
776 : }
777 :
778 :
779 0 : static gboolean bd_crypto_luks_format_stub (const gchar *device G_GNUC_UNUSED, const gchar *cipher G_GNUC_UNUSED, guint64 key_size G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, guint64 min_entropy G_GNUC_UNUSED, BDCryptoLUKSVersion luks_version G_GNUC_UNUSED, BDCryptoLUKSExtra *extra G_GNUC_UNUSED,GError **error) {
780 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_format' called, but not implemented!");
781 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
782 : "The function 'bd_crypto_luks_format' called, but not implemented!");
783 0 : return FALSE;
784 : }
785 :
786 : static gboolean (*_bd_crypto_luks_format) (const gchar *device, const gchar *cipher, guint64 key_size, BDCryptoKeyslotContext *context, guint64 min_entropy, BDCryptoLUKSVersion luks_version, BDCryptoLUKSExtra *extra,GError **error) = bd_crypto_luks_format_stub;
787 :
788 : /**
789 : * bd_crypto_luks_format:
790 : * @device: a device to format as LUKS
791 : * @cipher: (nullable): cipher specification (type-mode, e.g. "aes-xts-plain64") or %NULL to use the default
792 : * @key_size: size of the volume key in bits or 0 to use the default
793 : * @context: key slot context (passphrase/keyfile/token...) for this LUKS device
794 : * @min_entropy: minimum random data entropy (in bits) required to format @device as LUKS
795 : * @luks_version: whether to use LUKS v1 or LUKS v2
796 : * @extra: (nullable): extra arguments for LUKS format creation
797 : * @error: (out) (optional): place to store error (if any)
798 : *
799 : * Formats the given @device as LUKS according to the other parameters given. If
800 : * @min_entropy is specified (greater than 0), the function waits for enough
801 : * entropy to be available in the random data pool (WHICH MAY POTENTIALLY TAKE
802 : * FOREVER).
803 : *
804 : * Supported @context types for this function: passphrase, key file
805 : *
806 : * Returns: whether the given @device was successfully formatted as LUKS or not
807 : * (the @error) contains the error in such cases)
808 : *
809 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_CREATE
810 : */
811 52 : gboolean bd_crypto_luks_format (const gchar *device, const gchar *cipher, guint64 key_size, BDCryptoKeyslotContext *context, guint64 min_entropy, BDCryptoLUKSVersion luks_version, BDCryptoLUKSExtra *extra,GError **error) {
812 52 : return _bd_crypto_luks_format (device, cipher, key_size, context, min_entropy, luks_version, extra, error);
813 : }
814 :
815 :
816 0 : static gboolean bd_crypto_luks_open_stub (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, gboolean read_only G_GNUC_UNUSED, GError **error) {
817 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_open' called, but not implemented!");
818 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
819 : "The function 'bd_crypto_luks_open' called, but not implemented!");
820 0 : return FALSE;
821 : }
822 :
823 : static gboolean (*_bd_crypto_luks_open) (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, gboolean read_only, GError **error) = bd_crypto_luks_open_stub;
824 :
825 : /**
826 : * bd_crypto_luks_open:
827 : * @device: the device to open
828 : * @name: name for the LUKS device
829 : * @context: key slot context (passphrase/keyfile/token...) to open this LUKS @device
830 : * @read_only: whether to open as read-only or not (meaning read-write)
831 : * @error: (out) (optional): place to store error (if any)
832 : *
833 : * Supported @context types for this function: passphrase, key file, keyring
834 : *
835 : * Returns: whether the @device was successfully opened or not
836 : *
837 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
838 : *
839 : * Example of using %bd_crypto_luks_open with %BDCryptoKeyslotContext:
840 : *
841 : * |[<!-- language="C" -->
842 : * BDCryptoKeyslotContext *context = NULL;
843 : *
844 : * context = bd_crypto_keyslot_context_new_passphrase ("passphrase", 10, NULL);
845 : * bd_crypto_luks_open ("/dev/vda1", "luks-device", context, FALSE, NULL);
846 : * ]|
847 : */
848 55 : gboolean bd_crypto_luks_open (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, gboolean read_only, GError **error) {
849 55 : return _bd_crypto_luks_open (device, name, context, read_only, error);
850 : }
851 :
852 :
853 0 : static gboolean bd_crypto_luks_open_flags_stub (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, BDCryptoOpenFlags flags G_GNUC_UNUSED, GError **error) {
854 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_open_flags' called, but not implemented!");
855 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
856 : "The function 'bd_crypto_luks_open_flags' called, but not implemented!");
857 0 : return FALSE;
858 : }
859 :
860 : static gboolean (*_bd_crypto_luks_open_flags) (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, BDCryptoOpenFlags flags, GError **error) = bd_crypto_luks_open_flags_stub;
861 :
862 : /**
863 : * bd_crypto_luks_open_flags:
864 : * @device: the device to open
865 : * @name: name for the LUKS device
866 : * @context: key slot context (passphrase/keyfile/token...) to open this LUKS @device
867 : * @flags: activation flags for the LUKS device
868 : * @error: (out) (optional): place to store error (if any)
869 : *
870 : * Supported @context types for this function: passphrase, key file, keyring
871 : *
872 : * Returns: whether the @device was successfully opened or not
873 : *
874 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
875 : *
876 : * Example of using %bd_crypto_luks_open_flags with %BDCryptoKeyslotContext:
877 : *
878 : * |[<!-- language="C" -->
879 : * BDCryptoKeyslotContext *context = NULL;
880 : *
881 : * context = bd_crypto_keyslot_context_new_passphrase ("passphrase", 10, NULL);
882 : * bd_crypto_luks_open_flags ("/dev/vda1", "luks-device", context, 0, NULL);
883 : * ]|
884 : */
885 57 : gboolean bd_crypto_luks_open_flags (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, BDCryptoOpenFlags flags, GError **error) {
886 57 : return _bd_crypto_luks_open_flags (device, name, context, flags, error);
887 : }
888 :
889 :
890 0 : static gboolean bd_crypto_luks_close_stub (const gchar *luks_device G_GNUC_UNUSED, GError **error) {
891 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_close' called, but not implemented!");
892 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
893 : "The function 'bd_crypto_luks_close' called, but not implemented!");
894 0 : return FALSE;
895 : }
896 :
897 : static gboolean (*_bd_crypto_luks_close) (const gchar *luks_device, GError **error) = bd_crypto_luks_close_stub;
898 :
899 : /**
900 : * bd_crypto_luks_close:
901 : * @luks_device: LUKS device to close
902 : * @error: (out) (optional): place to store error (if any)
903 : *
904 : * Returns: whether the given @luks_device was successfully closed or not
905 : *
906 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
907 : */
908 82 : gboolean bd_crypto_luks_close (const gchar *luks_device, GError **error) {
909 82 : return _bd_crypto_luks_close (luks_device, error);
910 : }
911 :
912 :
913 0 : static gboolean bd_crypto_luks_add_key_stub (const gchar *device G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, BDCryptoKeyslotContext *ncontext G_GNUC_UNUSED, GError **error) {
914 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_add_key' called, but not implemented!");
915 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
916 : "The function 'bd_crypto_luks_add_key' called, but not implemented!");
917 0 : return FALSE;
918 : }
919 :
920 : static gboolean (*_bd_crypto_luks_add_key) (const gchar *device, BDCryptoKeyslotContext *context, BDCryptoKeyslotContext *ncontext, GError **error) = bd_crypto_luks_add_key_stub;
921 :
922 : /**
923 : * bd_crypto_luks_add_key:
924 : * @device: device to add new key to
925 : * @context: key slot context (passphrase/keyfile/token...) to for this LUKS @device
926 : * @ncontext: new key slot context (passphrase/keyfile/token...) to add to this LUKS @device
927 : * @error: (out) (optional): place to store error (if any)
928 : *
929 : * Supported @context types for this function: passphrase, key file
930 : *
931 : * Returns: whether the @ncontext was successfully added to @device
932 : * or not
933 : *
934 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_ADD_KEY
935 : */
936 15 : gboolean bd_crypto_luks_add_key (const gchar *device, BDCryptoKeyslotContext *context, BDCryptoKeyslotContext *ncontext, GError **error) {
937 15 : return _bd_crypto_luks_add_key (device, context, ncontext, error);
938 : }
939 :
940 :
941 0 : static gboolean bd_crypto_luks_remove_key_stub (const gchar *device G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, GError **error) {
942 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_remove_key' called, but not implemented!");
943 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
944 : "The function 'bd_crypto_luks_remove_key' called, but not implemented!");
945 0 : return FALSE;
946 : }
947 :
948 : static gboolean (*_bd_crypto_luks_remove_key) (const gchar *device, BDCryptoKeyslotContext *context, GError **error) = bd_crypto_luks_remove_key_stub;
949 :
950 : /**
951 : * bd_crypto_luks_remove_key:
952 : * @device: device to add new key to
953 : * @context: key slot context (passphrase/keyfile/token...) to remove from this LUKS @device
954 : * @error: (out) (optional): place to store error (if any)
955 : *
956 : * Supported @context types for this function: passphrase, key file
957 : *
958 : * Returns: whether the key was successfully removed or not
959 : *
960 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_REMOVE_KEY
961 : */
962 15 : gboolean bd_crypto_luks_remove_key (const gchar *device, BDCryptoKeyslotContext *context, GError **error) {
963 15 : return _bd_crypto_luks_remove_key (device, context, error);
964 : }
965 :
966 :
967 0 : static gboolean bd_crypto_luks_change_key_stub (const gchar *device G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, BDCryptoKeyslotContext *ncontext G_GNUC_UNUSED, GError **error) {
968 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_change_key' called, but not implemented!");
969 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
970 : "The function 'bd_crypto_luks_change_key' called, but not implemented!");
971 0 : return FALSE;
972 : }
973 :
974 : static gboolean (*_bd_crypto_luks_change_key) (const gchar *device, BDCryptoKeyslotContext *context, BDCryptoKeyslotContext *ncontext, GError **error) = bd_crypto_luks_change_key_stub;
975 :
976 : /**
977 : * bd_crypto_luks_change_key:
978 : * @device: device to change key of
979 : * @context: key slot context (passphrase/keyfile/token...) for this LUKS @device
980 : * @ncontext: new key slot context (passphrase/keyfile/token...) to add to this LUKS @device
981 : * @error: (out) (optional): place to store error (if any)
982 : *
983 : * Supported @context types for this function: passphrase, key file
984 : *
985 : * Returns: whether the key was successfully changed or not
986 : *
987 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_ADD_KEY&%BD_CRYPTO_TECH_MODE_REMOVE_KEY
988 : */
989 8 : gboolean bd_crypto_luks_change_key (const gchar *device, BDCryptoKeyslotContext *context, BDCryptoKeyslotContext *ncontext, GError **error) {
990 8 : return _bd_crypto_luks_change_key (device, context, ncontext, error);
991 : }
992 :
993 :
994 0 : static gboolean bd_crypto_luks_resize_stub (const gchar *luks_device G_GNUC_UNUSED, guint64 size G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, GError **error) {
995 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_resize' called, but not implemented!");
996 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
997 : "The function 'bd_crypto_luks_resize' called, but not implemented!");
998 0 : return FALSE;
999 : }
1000 :
1001 : static gboolean (*_bd_crypto_luks_resize) (const gchar *luks_device, guint64 size, BDCryptoKeyslotContext *context, GError **error) = bd_crypto_luks_resize_stub;
1002 :
1003 : /**
1004 : * bd_crypto_luks_resize:
1005 : * @luks_device: opened LUKS device to resize
1006 : * @size: requested size in sectors or 0 to adapt to the backing device
1007 : * @context: (nullable): key slot context (passphrase/keyfile/token...) for this LUKS @device
1008 : * @error: (out) (optional): place to store error (if any)
1009 : *
1010 : * Supported @context types for this function: passphrase, key file
1011 : *
1012 : * Returns: whether the @luks_device was successfully resized or not
1013 : *
1014 : * You need to specify either @context for LUKS 2 devices that
1015 : * don't have verified key loaded in kernel.
1016 : * For LUKS 1 devices you can set @context %NULL.
1017 : *
1018 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_RESIZE
1019 : */
1020 6 : gboolean bd_crypto_luks_resize (const gchar *luks_device, guint64 size, BDCryptoKeyslotContext *context, GError **error) {
1021 6 : return _bd_crypto_luks_resize (luks_device, size, context, error);
1022 : }
1023 :
1024 :
1025 0 : static gboolean bd_crypto_luks_suspend_stub (const gchar *luks_device G_GNUC_UNUSED, GError **error) {
1026 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_suspend' called, but not implemented!");
1027 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1028 : "The function 'bd_crypto_luks_suspend' called, but not implemented!");
1029 0 : return FALSE;
1030 : }
1031 :
1032 : static gboolean (*_bd_crypto_luks_suspend) (const gchar *luks_device, GError **error) = bd_crypto_luks_suspend_stub;
1033 :
1034 : /**
1035 : * bd_crypto_luks_suspend:
1036 : * @luks_device: LUKS device to suspend
1037 : * @error: (out) (optional): place to store error (if any)
1038 : *
1039 : * Returns: whether the given @luks_device was successfully suspended or not
1040 : *
1041 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_SUSPEND_RESUME
1042 : */
1043 8 : gboolean bd_crypto_luks_suspend (const gchar *luks_device, GError **error) {
1044 8 : return _bd_crypto_luks_suspend (luks_device, error);
1045 : }
1046 :
1047 :
1048 0 : static gboolean bd_crypto_luks_resume_stub (const gchar *luks_device G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, GError **error) {
1049 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_resume' called, but not implemented!");
1050 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1051 : "The function 'bd_crypto_luks_resume' called, but not implemented!");
1052 0 : return FALSE;
1053 : }
1054 :
1055 : static gboolean (*_bd_crypto_luks_resume) (const gchar *luks_device, BDCryptoKeyslotContext *context, GError **error) = bd_crypto_luks_resume_stub;
1056 :
1057 : /**
1058 : * bd_crypto_luks_resume:
1059 : * @luks_device: LUKS device to resume
1060 : * @context: (nullable): key slot context (passphrase/keyfile/token...) for @luks_device
1061 : * @error: (out) (optional): place to store error (if any)
1062 : *
1063 : * Supported @context types for this function: passphrase, key file
1064 : *
1065 : * Returns: whether the given @luks_device was successfully resumed or not
1066 : *
1067 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_SUSPEND_RESUME
1068 : */
1069 10 : gboolean bd_crypto_luks_resume (const gchar *luks_device, BDCryptoKeyslotContext *context, GError **error) {
1070 10 : return _bd_crypto_luks_resume (luks_device, context, error);
1071 : }
1072 :
1073 :
1074 0 : static gboolean bd_crypto_luks_kill_slot_stub (const gchar *device G_GNUC_UNUSED, gint slot G_GNUC_UNUSED, GError **error) {
1075 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_kill_slot' called, but not implemented!");
1076 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1077 : "The function 'bd_crypto_luks_kill_slot' called, but not implemented!");
1078 0 : return FALSE;
1079 : }
1080 :
1081 : static gboolean (*_bd_crypto_luks_kill_slot) (const gchar *device, gint slot, GError **error) = bd_crypto_luks_kill_slot_stub;
1082 :
1083 : /**
1084 : * bd_crypto_luks_kill_slot:
1085 : * @device: device to kill slot on
1086 : * @slot: keyslot to destroy
1087 : * @error: (out) (optional): place to store error (if any)
1088 : *
1089 : * Note: This can destroy last remaining keyslot without confirmation making
1090 : * the LUKS device permanently inaccessible.
1091 : *
1092 : * Returns: whether the given @slot was successfully destroyed or not
1093 : *
1094 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_REMOVE_KEY
1095 : */
1096 8 : gboolean bd_crypto_luks_kill_slot (const gchar *device, gint slot, GError **error) {
1097 8 : return _bd_crypto_luks_kill_slot (device, slot, error);
1098 : }
1099 :
1100 :
1101 0 : static gboolean bd_crypto_luks_header_backup_stub (const gchar *device G_GNUC_UNUSED, const gchar *backup_file G_GNUC_UNUSED, GError **error) {
1102 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_header_backup' called, but not implemented!");
1103 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1104 : "The function 'bd_crypto_luks_header_backup' called, but not implemented!");
1105 0 : return FALSE;
1106 : }
1107 :
1108 : static gboolean (*_bd_crypto_luks_header_backup) (const gchar *device, const gchar *backup_file, GError **error) = bd_crypto_luks_header_backup_stub;
1109 :
1110 : /**
1111 : * bd_crypto_luks_header_backup:
1112 : * @device: device to backup the LUKS header
1113 : * @backup_file: file to save the header backup to
1114 : * @error: (out) (optional): place to store error (if any)
1115 : *
1116 : * Returns: whether the given backup of @device was successfully written to
1117 : * @backup_file or not
1118 : *
1119 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_BACKUP_RESTORE
1120 : */
1121 2 : gboolean bd_crypto_luks_header_backup (const gchar *device, const gchar *backup_file, GError **error) {
1122 2 : return _bd_crypto_luks_header_backup (device, backup_file, error);
1123 : }
1124 :
1125 :
1126 0 : static gboolean bd_crypto_luks_header_restore_stub (const gchar *device G_GNUC_UNUSED, const gchar *backup_file G_GNUC_UNUSED, GError **error) {
1127 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_header_restore' called, but not implemented!");
1128 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1129 : "The function 'bd_crypto_luks_header_restore' called, but not implemented!");
1130 0 : return FALSE;
1131 : }
1132 :
1133 : static gboolean (*_bd_crypto_luks_header_restore) (const gchar *device, const gchar *backup_file, GError **error) = bd_crypto_luks_header_restore_stub;
1134 :
1135 : /**
1136 : * bd_crypto_luks_header_restore:
1137 : * @device: device to restore the LUKS header to
1138 : * @backup_file: existing file with a LUKS header backup
1139 : * @error: (out) (optional): place to store error (if any)
1140 : *
1141 : * Returns: whether the given @device LUKS header was successfully restored
1142 : * from @backup_file
1143 : *
1144 : *
1145 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_BACKUP_RESTORE
1146 : */
1147 2 : gboolean bd_crypto_luks_header_restore (const gchar *device, const gchar *backup_file, GError **error) {
1148 2 : return _bd_crypto_luks_header_restore (device, backup_file, error);
1149 : }
1150 :
1151 :
1152 0 : static gboolean bd_crypto_luks_set_label_stub (const gchar *device G_GNUC_UNUSED, const gchar *label G_GNUC_UNUSED, const gchar *subsystem G_GNUC_UNUSED, GError **error) {
1153 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_set_label' called, but not implemented!");
1154 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1155 : "The function 'bd_crypto_luks_set_label' called, but not implemented!");
1156 0 : return FALSE;
1157 : }
1158 :
1159 : static gboolean (*_bd_crypto_luks_set_label) (const gchar *device, const gchar *label, const gchar *subsystem, GError **error) = bd_crypto_luks_set_label_stub;
1160 :
1161 : /**
1162 : * bd_crypto_luks_set_label:
1163 : * @device: device to set label on
1164 : * @label: (nullable): label to set
1165 : * @subsystem: (nullable): subsystem to set
1166 : * @error: (out) (optional): place to store error (if any)
1167 : *
1168 : * Returns: whether the given @label and @subsystem were successfully set or not
1169 : *
1170 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_MODIFY
1171 : */
1172 3 : gboolean bd_crypto_luks_set_label (const gchar *device, const gchar *label, const gchar *subsystem, GError **error) {
1173 3 : return _bd_crypto_luks_set_label (device, label, subsystem, error);
1174 : }
1175 :
1176 :
1177 0 : static gboolean bd_crypto_luks_check_label_stub (const gchar *label G_GNUC_UNUSED, const gchar *subsystem G_GNUC_UNUSED, GError **error) {
1178 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_check_label' called, but not implemented!");
1179 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1180 : "The function 'bd_crypto_luks_check_label' called, but not implemented!");
1181 0 : return FALSE;
1182 : }
1183 :
1184 : static gboolean (*_bd_crypto_luks_check_label) (const gchar *label, const gchar *subsystem, GError **error) = bd_crypto_luks_check_label_stub;
1185 :
1186 : /**
1187 : * bd_crypto_luks_check_label:
1188 : * @label: (nullable): label to check
1189 : * @subsystem: (nullable): subsystem to check
1190 : * @error: (out) (optional): place to store error
1191 : *
1192 : * Returns: whether @label and @subsystem are valid for LUKS2 or not
1193 : * (reason is provided in @error)
1194 : *
1195 : * Tech category: always available
1196 : */
1197 3 : gboolean bd_crypto_luks_check_label (const gchar *label, const gchar *subsystem, GError **error) {
1198 3 : return _bd_crypto_luks_check_label (label, subsystem, error);
1199 : }
1200 :
1201 :
1202 0 : static gboolean bd_crypto_luks_set_uuid_stub (const gchar *device G_GNUC_UNUSED, const gchar *uuid G_GNUC_UNUSED, GError **error) {
1203 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_set_uuid' called, but not implemented!");
1204 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1205 : "The function 'bd_crypto_luks_set_uuid' called, but not implemented!");
1206 0 : return FALSE;
1207 : }
1208 :
1209 : static gboolean (*_bd_crypto_luks_set_uuid) (const gchar *device, const gchar *uuid, GError **error) = bd_crypto_luks_set_uuid_stub;
1210 :
1211 : /**
1212 : * bd_crypto_luks_set_uuid:
1213 : * @device: device to set UUID on
1214 : * @uuid: (nullable): UUID to set or %NULL to generate a new one
1215 : * @error: (out) (optional): place to store error (if any)
1216 : *
1217 : * Returns: whether the given @uuid was successfully set or not
1218 : *
1219 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_MODIFY
1220 : */
1221 4 : gboolean bd_crypto_luks_set_uuid (const gchar *device, const gchar *uuid, GError **error) {
1222 4 : return _bd_crypto_luks_set_uuid (device, uuid, error);
1223 : }
1224 :
1225 :
1226 0 : static gboolean bd_crypto_luks_convert_stub (const gchar *device G_GNUC_UNUSED, BDCryptoLUKSVersion target_version G_GNUC_UNUSED, GError **error) {
1227 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_convert' called, but not implemented!");
1228 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1229 : "The function 'bd_crypto_luks_convert' called, but not implemented!");
1230 0 : return FALSE;
1231 : }
1232 :
1233 : static gboolean (*_bd_crypto_luks_convert) (const gchar *device, BDCryptoLUKSVersion target_version, GError **error) = bd_crypto_luks_convert_stub;
1234 :
1235 : /**
1236 : * bd_crypto_luks_convert:
1237 : * @device: a LUKS device to convert to a different version of LUKS
1238 : * @target_version: the LUKS version to convert to
1239 : * @error: (out) (optional): place to store error (if any)
1240 : *
1241 : * Returns: whether the @device was converted to @target_version.
1242 : * False, if the @device is already in the @target_version format.
1243 : *
1244 : * Warning: LUKS header loss is possible. See bd_crypto_luks_header_backup() and bd_crypto_luks_header_restore()
1245 : *
1246 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_MODIFY
1247 : */
1248 4 : gboolean bd_crypto_luks_convert (const gchar *device, BDCryptoLUKSVersion target_version, GError **error) {
1249 4 : return _bd_crypto_luks_convert (device, target_version, error);
1250 : }
1251 :
1252 :
1253 0 : static gboolean bd_crypto_luks_set_persistent_flags_stub (const gchar *device G_GNUC_UNUSED, BDCryptoLUKSPersistentFlags flags G_GNUC_UNUSED, GError **error) {
1254 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_set_persistent_flags' called, but not implemented!");
1255 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1256 : "The function 'bd_crypto_luks_set_persistent_flags' called, but not implemented!");
1257 0 : return FALSE;
1258 : }
1259 :
1260 : static gboolean (*_bd_crypto_luks_set_persistent_flags) (const gchar *device, BDCryptoLUKSPersistentFlags flags, GError **error) = bd_crypto_luks_set_persistent_flags_stub;
1261 :
1262 : /**
1263 : * bd_crypto_luks_set_persistent_flags:
1264 : * @device: a LUKS device to set the persistent flags on
1265 : * @flags: flags to set
1266 : * @error: (out) (optional): place to store error (if any)
1267 : *
1268 : * Note: This function is valid only for LUKS2.
1269 : *
1270 : * Returns: whether the given @flags were successfully set or not
1271 : *
1272 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_MODIFY
1273 : */
1274 2 : gboolean bd_crypto_luks_set_persistent_flags (const gchar *device, BDCryptoLUKSPersistentFlags flags, GError **error) {
1275 2 : return _bd_crypto_luks_set_persistent_flags (device, flags, error);
1276 : }
1277 :
1278 :
1279 0 : static BDCryptoLUKSInfo* bd_crypto_luks_info_stub (const gchar *device G_GNUC_UNUSED, GError **error) {
1280 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_info' called, but not implemented!");
1281 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1282 : "The function 'bd_crypto_luks_info' called, but not implemented!");
1283 0 : return NULL;
1284 : }
1285 :
1286 : static BDCryptoLUKSInfo* (*_bd_crypto_luks_info) (const gchar *device, GError **error) = bd_crypto_luks_info_stub;
1287 :
1288 : /**
1289 : * bd_crypto_luks_info:
1290 : * @device: a device to get information about
1291 : * @error: (out) (optional): place to store error (if any)
1292 : *
1293 : * Returns: (transfer full): information about the @device or %NULL in case of error
1294 : *
1295 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_QUERY
1296 : */
1297 22 : BDCryptoLUKSInfo* bd_crypto_luks_info (const gchar *device, GError **error) {
1298 22 : return _bd_crypto_luks_info (device, error);
1299 : }
1300 :
1301 :
1302 0 : static BDCryptoBITLKInfo* bd_crypto_bitlk_info_stub (const gchar *device G_GNUC_UNUSED, GError **error) {
1303 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_bitlk_info' called, but not implemented!");
1304 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1305 : "The function 'bd_crypto_bitlk_info' called, but not implemented!");
1306 0 : return NULL;
1307 : }
1308 :
1309 : static BDCryptoBITLKInfo* (*_bd_crypto_bitlk_info) (const gchar *device, GError **error) = bd_crypto_bitlk_info_stub;
1310 :
1311 : /**
1312 : * bd_crypto_bitlk_info:
1313 : * @device: a device to get information about
1314 : * @error: (out) (optional): place to store error (if any)
1315 : *
1316 : * Returns (transfer full): information about the @device or %NULL in case of error
1317 : *
1318 : * Tech category: %BD_CRYPTO_TECH_BITLK-%BD_CRYPTO_TECH_MODE_QUERY
1319 : */
1320 7 : BDCryptoBITLKInfo* bd_crypto_bitlk_info (const gchar *device, GError **error) {
1321 7 : return _bd_crypto_bitlk_info (device, error);
1322 : }
1323 :
1324 :
1325 0 : static BDCryptoIntegrityInfo* bd_crypto_integrity_info_stub (const gchar *device G_GNUC_UNUSED, GError **error) {
1326 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_integrity_info' called, but not implemented!");
1327 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1328 : "The function 'bd_crypto_integrity_info' called, but not implemented!");
1329 0 : return NULL;
1330 : }
1331 :
1332 : static BDCryptoIntegrityInfo* (*_bd_crypto_integrity_info) (const gchar *device, GError **error) = bd_crypto_integrity_info_stub;
1333 :
1334 : /**
1335 : * bd_crypto_integrity_info:
1336 : * @device: a device to get information about
1337 : * @error: (out) (optional): place to store error (if any)
1338 : *
1339 : * Returns: (transfer full): information about the @device or %NULL in case of error
1340 : *
1341 : * Tech category: %BD_CRYPTO_TECH_INTEGRITY-%BD_CRYPTO_TECH_MODE_QUERY
1342 : */
1343 6 : BDCryptoIntegrityInfo* bd_crypto_integrity_info (const gchar *device, GError **error) {
1344 6 : return _bd_crypto_integrity_info (device, error);
1345 : }
1346 :
1347 :
1348 0 : static BDCryptoLUKSTokenInfo** bd_crypto_luks_token_info_stub (const gchar *device G_GNUC_UNUSED, GError **error) {
1349 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_luks_token_info' called, but not implemented!");
1350 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1351 : "The function 'bd_crypto_luks_token_info' called, but not implemented!");
1352 0 : return NULL;
1353 : }
1354 :
1355 : static BDCryptoLUKSTokenInfo** (*_bd_crypto_luks_token_info) (const gchar *device, GError **error) = bd_crypto_luks_token_info_stub;
1356 :
1357 : /**
1358 : * bd_crypto_luks_token_info:
1359 : * @device: a device to get LUKS2 token information about
1360 : * @error: (out) (optional): place to store error (if any)
1361 : *
1362 : * Returns: (array zero-terminated=1) (transfer full): information about tokens on @device
1363 : *
1364 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_QUERY
1365 : */
1366 4 : BDCryptoLUKSTokenInfo** bd_crypto_luks_token_info (const gchar *device, GError **error) {
1367 4 : return _bd_crypto_luks_token_info (device, error);
1368 : }
1369 :
1370 :
1371 0 : static gboolean bd_crypto_integrity_format_stub (const gchar *device G_GNUC_UNUSED, const gchar *algorithm G_GNUC_UNUSED, gboolean wipe G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, BDCryptoIntegrityExtra *extra G_GNUC_UNUSED, GError **error) {
1372 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_integrity_format' called, but not implemented!");
1373 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1374 : "The function 'bd_crypto_integrity_format' called, but not implemented!");
1375 0 : return FALSE;
1376 : }
1377 :
1378 : static gboolean (*_bd_crypto_integrity_format) (const gchar *device, const gchar *algorithm, gboolean wipe, BDCryptoKeyslotContext *context, BDCryptoIntegrityExtra *extra, GError **error) = bd_crypto_integrity_format_stub;
1379 :
1380 : /**
1381 : * bd_crypto_integrity_format:
1382 : * @device: a device to format as integrity
1383 : * @algorithm: integrity algorithm specification (e.g. "crc32c" or "sha256")
1384 : * @wipe: whether to wipe the device after format; a device that is not initially wiped will contain invalid checksums
1385 : * @context: (nullable): key slot context (passphrase/keyfile/token...) for this device
1386 : * @extra: (nullable): extra arguments for integrity format creation
1387 : * @error: (out) (optional): place to store error (if any)
1388 : *
1389 : * Formats the given @device as integrity according to the other parameters given.
1390 : *
1391 : * Supported @context types for this function: volume key
1392 : *
1393 : * Returns: whether the given @device was successfully formatted as integrity or not
1394 : * (the @error) contains the error in such cases)
1395 : *
1396 : * Tech category: %BD_CRYPTO_TECH_INTEGRITY-%BD_CRYPTO_TECH_MODE_CREATE
1397 : */
1398 4 : gboolean bd_crypto_integrity_format (const gchar *device, const gchar *algorithm, gboolean wipe, BDCryptoKeyslotContext *context, BDCryptoIntegrityExtra *extra, GError **error) {
1399 4 : return _bd_crypto_integrity_format (device, algorithm, wipe, context, extra, error);
1400 : }
1401 :
1402 :
1403 0 : static gboolean bd_crypto_integrity_open_stub (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, const gchar *algorithm G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, BDCryptoIntegrityOpenFlags flags G_GNUC_UNUSED, BDCryptoIntegrityExtra *extra G_GNUC_UNUSED, GError **error) {
1404 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_integrity_open' called, but not implemented!");
1405 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1406 : "The function 'bd_crypto_integrity_open' called, but not implemented!");
1407 0 : return FALSE;
1408 : }
1409 :
1410 : static gboolean (*_bd_crypto_integrity_open) (const gchar *device, const gchar *name, const gchar *algorithm, BDCryptoKeyslotContext *context, BDCryptoIntegrityOpenFlags flags, BDCryptoIntegrityExtra *extra, GError **error) = bd_crypto_integrity_open_stub;
1411 :
1412 : /**
1413 : * bd_crypto_integrity_open:
1414 : * @device: integrity device to open
1415 : * @name: name for the opened @device
1416 : * @algorithm: integrity algorithm specification (e.g. "crc32c" or "sha256")
1417 : * @context: (nullable): key slot context (passphrase/keyfile/token...) for this device
1418 : * @flags: flags for the integrity device activation
1419 : * @extra: (nullable): extra arguments for integrity open
1420 : * @error: (out) (optional): place to store error (if any)
1421 : *
1422 : * Supported @context types for this function: volume key
1423 : *
1424 : * Returns: whether the @device was successfully opened or not
1425 : *
1426 : * Tech category: %BD_CRYPTO_TECH_INTEGRITY-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1427 : */
1428 5 : gboolean bd_crypto_integrity_open (const gchar *device, const gchar *name, const gchar *algorithm, BDCryptoKeyslotContext *context, BDCryptoIntegrityOpenFlags flags, BDCryptoIntegrityExtra *extra, GError **error) {
1429 5 : return _bd_crypto_integrity_open (device, name, algorithm, context, flags, extra, error);
1430 : }
1431 :
1432 :
1433 0 : static gboolean bd_crypto_integrity_close_stub (const gchar *integrity_device G_GNUC_UNUSED, GError **error) {
1434 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_integrity_close' called, but not implemented!");
1435 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1436 : "The function 'bd_crypto_integrity_close' called, but not implemented!");
1437 0 : return FALSE;
1438 : }
1439 :
1440 : static gboolean (*_bd_crypto_integrity_close) (const gchar *integrity_device, GError **error) = bd_crypto_integrity_close_stub;
1441 :
1442 : /**
1443 : * bd_crypto_integrity_close:
1444 : * @integrity_device: integrity device to close
1445 : * @error: (out) (optional): place to store error (if any)
1446 : *
1447 : * Returns: whether the given @integrity_device was successfully closed or not
1448 : *
1449 : * Tech category: %BD_CRYPTO_TECH_INTEGRITY-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1450 : */
1451 5 : gboolean bd_crypto_integrity_close (const gchar *integrity_device, GError **error) {
1452 5 : return _bd_crypto_integrity_close (integrity_device, error);
1453 : }
1454 :
1455 :
1456 0 : static gboolean bd_crypto_keyring_add_key_stub (const gchar *key_desc G_GNUC_UNUSED, const guint8 *key_data G_GNUC_UNUSED, gsize data_len G_GNUC_UNUSED, GError **error) {
1457 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_keyring_add_key' called, but not implemented!");
1458 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1459 : "The function 'bd_crypto_keyring_add_key' called, but not implemented!");
1460 0 : return FALSE;
1461 : }
1462 :
1463 : static gboolean (*_bd_crypto_keyring_add_key) (const gchar *key_desc, const guint8 *key_data, gsize data_len, GError **error) = bd_crypto_keyring_add_key_stub;
1464 :
1465 : /**
1466 : * bd_crypto_keyring_add_key:
1467 : * @key_desc: kernel keyring key description
1468 : * @key_data: (array length=data_len): a key to add to kernel keyring (may contain arbitrary binary data)
1469 : * @data_len: length of the @key_data buffer
1470 : * @error: (out) (optional): place to store error (if any)
1471 : * *
1472 : * Returns: whether the given key was successfully saved to kernel keyring or not
1473 : *
1474 : * Tech category: %BD_CRYPTO_TECH_KEYRING-%BD_CRYPTO_TECH_MODE_ADD_KEY
1475 : */
1476 3 : gboolean bd_crypto_keyring_add_key (const gchar *key_desc, const guint8 *key_data, gsize data_len, GError **error) {
1477 3 : return _bd_crypto_keyring_add_key (key_desc, key_data, data_len, error);
1478 : }
1479 :
1480 :
1481 0 : static gboolean bd_crypto_device_seems_encrypted_stub (const gchar *device G_GNUC_UNUSED, GError **error) {
1482 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_device_seems_encrypted' called, but not implemented!");
1483 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1484 : "The function 'bd_crypto_device_seems_encrypted' called, but not implemented!");
1485 0 : return FALSE;
1486 : }
1487 :
1488 : static gboolean (*_bd_crypto_device_seems_encrypted) (const gchar *device, GError **error) = bd_crypto_device_seems_encrypted_stub;
1489 :
1490 : /**
1491 : * bd_crypto_device_seems_encrypted:
1492 : * @device: the queried device
1493 : * @error: (out) (optional): place to store error (if any)
1494 : *
1495 : * Determines whether a block device seems to be encrypted.
1496 : *
1497 : * TCRYPT volumes are not easily identifiable, because they have no
1498 : * cleartext header, but are completely encrypted. This function is
1499 : * used to determine whether a block device is a candidate for being
1500 : * TCRYPT encrypted.
1501 : *
1502 : * To achieve this, we calculate the chi square value of the first
1503 : * 512 Bytes and treat devices with a chi square value between 136
1504 : * and 426 as candidates for being encrypted.
1505 : * For the reasoning, see: https://tails.boum.org/blueprint/veracrypt/
1506 : *
1507 : * Returns: %TRUE if the given @device seems to be encrypted or %FALSE if not or
1508 : * failed to determine (the @error) is populated with the error in such
1509 : * cases)
1510 : *
1511 : * Tech category: %BD_CRYPTO_TECH_TRUECRYPT-%BD_CRYPTO_TECH_MODE_QUERY
1512 : */
1513 2 : gboolean bd_crypto_device_seems_encrypted (const gchar *device, GError **error) {
1514 2 : return _bd_crypto_device_seems_encrypted (device, error);
1515 : }
1516 :
1517 :
1518 0 : static gboolean bd_crypto_tc_open_stub (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, const gchar **keyfiles G_GNUC_UNUSED, gboolean hidden G_GNUC_UNUSED, gboolean system G_GNUC_UNUSED, gboolean veracrypt G_GNUC_UNUSED, guint32 veracrypt_pim G_GNUC_UNUSED, gboolean read_only G_GNUC_UNUSED, GError **error) {
1519 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_tc_open' called, but not implemented!");
1520 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1521 : "The function 'bd_crypto_tc_open' called, but not implemented!");
1522 0 : return FALSE;
1523 : }
1524 :
1525 : static gboolean (*_bd_crypto_tc_open) (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, const gchar **keyfiles, gboolean hidden, gboolean system, gboolean veracrypt, guint32 veracrypt_pim, gboolean read_only, GError **error) = bd_crypto_tc_open_stub;
1526 :
1527 : /**
1528 : * bd_crypto_tc_open:
1529 : * @device: the device to open
1530 : * @name: name for the TrueCrypt/VeraCrypt device
1531 : * @context: (nullable): passphrase key slot context for this TrueCrypt/VeraCrypt volume
1532 : * @read_only: whether to open as read-only or not (meaning read-write)
1533 : * @keyfiles: (nullable) (array zero-terminated=1): paths to the keyfiles for the TrueCrypt/VeraCrypt volume
1534 : * @hidden: whether a hidden volume inside the volume should be opened
1535 : * @system: whether to try opening as an encrypted system (with boot loader)
1536 : * @veracrypt: whether to try VeraCrypt modes (TrueCrypt modes are tried anyway)
1537 : * @veracrypt_pim: VeraCrypt PIM value (only used if @veracrypt is %TRUE)
1538 : * @error: (out) (optional): place to store error (if any)
1539 : *
1540 : * Supported @context types for this function: passphrase
1541 : *
1542 : * Returns: whether the @device was successfully opened or not
1543 : *
1544 : * Tech category: %BD_CRYPTO_TECH_TRUECRYPT-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1545 : */
1546 7 : gboolean bd_crypto_tc_open (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, const gchar **keyfiles, gboolean hidden, gboolean system, gboolean veracrypt, guint32 veracrypt_pim, gboolean read_only, GError **error) {
1547 7 : return _bd_crypto_tc_open (device, name, context, keyfiles, hidden, system, veracrypt, veracrypt_pim, read_only, error);
1548 : }
1549 :
1550 :
1551 0 : static gboolean bd_crypto_tc_open_flags_stub (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, const gchar **keyfiles G_GNUC_UNUSED, gboolean hidden G_GNUC_UNUSED, gboolean system G_GNUC_UNUSED, gboolean veracrypt G_GNUC_UNUSED, guint32 veracrypt_pim G_GNUC_UNUSED, BDCryptoOpenFlags flags G_GNUC_UNUSED, GError **error) {
1552 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_tc_open_flags' called, but not implemented!");
1553 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1554 : "The function 'bd_crypto_tc_open_flags' called, but not implemented!");
1555 0 : return FALSE;
1556 : }
1557 :
1558 : static gboolean (*_bd_crypto_tc_open_flags) (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, const gchar **keyfiles, gboolean hidden, gboolean system, gboolean veracrypt, guint32 veracrypt_pim, BDCryptoOpenFlags flags, GError **error) = bd_crypto_tc_open_flags_stub;
1559 :
1560 : /**
1561 : * bd_crypto_tc_open_flags:
1562 : * @device: the device to open
1563 : * @name: name for the TrueCrypt/VeraCrypt device
1564 : * @context: (nullable): passphrase key slot context for this TrueCrypt/VeraCrypt volume
1565 : * @flags: activation flags for the TrueCrypt/VeraCrypt device
1566 : * @keyfiles: (nullable) (array zero-terminated=1): paths to the keyfiles for the TrueCrypt/VeraCrypt volume
1567 : * @hidden: whether a hidden volume inside the volume should be opened
1568 : * @system: whether to try opening as an encrypted system (with boot loader)
1569 : * @veracrypt: whether to try VeraCrypt modes (TrueCrypt modes are tried anyway)
1570 : * @veracrypt_pim: VeraCrypt PIM value (only used if @veracrypt is %TRUE)
1571 : * @error: (out) (optional): place to store error (if any)
1572 : *
1573 : * Supported @context types for this function: passphrase
1574 : *
1575 : * Returns: whether the @device was successfully opened or not
1576 : *
1577 : * Tech category: %BD_CRYPTO_TECH_TRUECRYPT-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1578 : */
1579 8 : gboolean bd_crypto_tc_open_flags (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, const gchar **keyfiles, gboolean hidden, gboolean system, gboolean veracrypt, guint32 veracrypt_pim, BDCryptoOpenFlags flags, GError **error) {
1580 8 : return _bd_crypto_tc_open_flags (device, name, context, keyfiles, hidden, system, veracrypt, veracrypt_pim, flags, error);
1581 : }
1582 :
1583 :
1584 0 : static gboolean bd_crypto_tc_close_stub (const gchar *tc_device G_GNUC_UNUSED, GError **error) {
1585 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_tc_close' called, but not implemented!");
1586 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1587 : "The function 'bd_crypto_tc_close' called, but not implemented!");
1588 0 : return FALSE;
1589 : }
1590 :
1591 : static gboolean (*_bd_crypto_tc_close) (const gchar *tc_device, GError **error) = bd_crypto_tc_close_stub;
1592 :
1593 : /**
1594 : * bd_crypto_tc_close:
1595 : * @tc_device: TrueCrypt/VeraCrypt device to close
1596 : * @error: (out) (optional): place to store error (if any)
1597 : *
1598 : * Returns: whether the given @tc_device was successfully closed or not
1599 : *
1600 : * Tech category: %BD_CRYPTO_TECH_TRUECRYPT-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1601 : */
1602 7 : gboolean bd_crypto_tc_close (const gchar *tc_device, GError **error) {
1603 7 : return _bd_crypto_tc_close (tc_device, error);
1604 : }
1605 :
1606 :
1607 0 : static gboolean bd_crypto_escrow_device_stub (const gchar *device G_GNUC_UNUSED, const gchar *passphrase G_GNUC_UNUSED, const gchar *cert_data G_GNUC_UNUSED, const gchar *directory G_GNUC_UNUSED, const gchar *backup_passphrase G_GNUC_UNUSED, GError **error) {
1608 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_escrow_device' called, but not implemented!");
1609 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1610 : "The function 'bd_crypto_escrow_device' called, but not implemented!");
1611 0 : return FALSE;
1612 : }
1613 :
1614 : static gboolean (*_bd_crypto_escrow_device) (const gchar *device, const gchar *passphrase, const gchar *cert_data, const gchar *directory, const gchar *backup_passphrase, GError **error) = bd_crypto_escrow_device_stub;
1615 :
1616 : /**
1617 : * bd_crypto_escrow_device:
1618 : * @device: path of the device to create escrow data for
1619 : * @passphrase: passphrase used for the device
1620 : * @cert_data: (array zero-terminated=1) (element-type gchar): certificate data to use for escrow
1621 : * @directory: directory to put escrow data into
1622 : * @backup_passphrase: (nullable): backup passphrase for the device or %NULL
1623 : * @error: (out) (optional): place to store error (if any)
1624 : *
1625 : * Returns: whether the escrow data was successfully created for @device or not
1626 : *
1627 : * Tech category: %BD_CRYPTO_TECH_ESCROW-%BD_CRYPTO_TECH_MODE_CREATE
1628 : */
1629 2 : gboolean bd_crypto_escrow_device (const gchar *device, const gchar *passphrase, const gchar *cert_data, const gchar *directory, const gchar *backup_passphrase, GError **error) {
1630 2 : return _bd_crypto_escrow_device (device, passphrase, cert_data, directory, backup_passphrase, error);
1631 : }
1632 :
1633 :
1634 0 : static gboolean bd_crypto_bitlk_open_stub (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, gboolean read_only G_GNUC_UNUSED, GError **error) {
1635 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_bitlk_open' called, but not implemented!");
1636 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1637 : "The function 'bd_crypto_bitlk_open' called, but not implemented!");
1638 0 : return FALSE;
1639 : }
1640 :
1641 : static gboolean (*_bd_crypto_bitlk_open) (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, gboolean read_only, GError **error) = bd_crypto_bitlk_open_stub;
1642 :
1643 : /**
1644 : * bd_crypto_bitlk_open:
1645 : * @device: the device to open
1646 : * @name: name for the BITLK device
1647 : * @context: key slot context (passphrase/keyfile/token...) for this BITLK device
1648 : * @read_only: whether to open as read-only or not (meaning read-write)
1649 : * @error: (out) (optional): place to store error (if any)
1650 : *
1651 : * Supported @context types for this function: passphrase, key file
1652 : *
1653 : * Returns: whether the @device was successfully opened or not
1654 : *
1655 : * Tech category: %BD_CRYPTO_TECH_BITLK-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1656 : */
1657 4 : gboolean bd_crypto_bitlk_open (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, gboolean read_only, GError **error) {
1658 4 : return _bd_crypto_bitlk_open (device, name, context, read_only, error);
1659 : }
1660 :
1661 :
1662 0 : static gboolean bd_crypto_bitlk_open_flags_stub (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, BDCryptoOpenFlags flags G_GNUC_UNUSED, GError **error) {
1663 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_bitlk_open_flags' called, but not implemented!");
1664 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1665 : "The function 'bd_crypto_bitlk_open_flags' called, but not implemented!");
1666 0 : return FALSE;
1667 : }
1668 :
1669 : static gboolean (*_bd_crypto_bitlk_open_flags) (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, BDCryptoOpenFlags flags, GError **error) = bd_crypto_bitlk_open_flags_stub;
1670 :
1671 : /**
1672 : * bd_crypto_bitlk_open_flags:
1673 : * @device: the device to open
1674 : * @name: name for the BITLK device
1675 : * @context: key slot context (passphrase/keyfile/token...) for this BITLK device
1676 : * @flags: activation flags for the BITLK device
1677 : * @error: (out) (optional): place to store error (if any)
1678 : *
1679 : * Supported @context types for this function: passphrase, key file
1680 : *
1681 : * Returns: whether the @device was successfully opened or not
1682 : *
1683 : * Tech category: %BD_CRYPTO_TECH_BITLK-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1684 : */
1685 5 : gboolean bd_crypto_bitlk_open_flags (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, BDCryptoOpenFlags flags, GError **error) {
1686 5 : return _bd_crypto_bitlk_open_flags (device, name, context, flags, error);
1687 : }
1688 :
1689 :
1690 0 : static gboolean bd_crypto_bitlk_close_stub (const gchar *bitlk_device G_GNUC_UNUSED, GError **error) {
1691 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_bitlk_close' called, but not implemented!");
1692 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1693 : "The function 'bd_crypto_bitlk_close' called, but not implemented!");
1694 0 : return FALSE;
1695 : }
1696 :
1697 : static gboolean (*_bd_crypto_bitlk_close) (const gchar *bitlk_device, GError **error) = bd_crypto_bitlk_close_stub;
1698 :
1699 : /**
1700 : * bd_crypto_bitlk_close:
1701 : * @bitlk_device: BITLK device to close
1702 : * @error: (out) (optional): place to store error (if any)
1703 : *
1704 : * Returns: whether the given @bitlk_device was successfully closed or not
1705 : *
1706 : * Tech category: %BD_CRYPTO_TECH_BITLK-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1707 : */
1708 5 : gboolean bd_crypto_bitlk_close (const gchar *bitlk_device, GError **error) {
1709 5 : return _bd_crypto_bitlk_close (bitlk_device, error);
1710 : }
1711 :
1712 :
1713 0 : static gboolean bd_crypto_fvault2_open_stub (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, gboolean read_only G_GNUC_UNUSED, GError **error) {
1714 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_fvault2_open' called, but not implemented!");
1715 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1716 : "The function 'bd_crypto_fvault2_open' called, but not implemented!");
1717 0 : return FALSE;
1718 : }
1719 :
1720 : static gboolean (*_bd_crypto_fvault2_open) (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, gboolean read_only, GError **error) = bd_crypto_fvault2_open_stub;
1721 :
1722 : /**
1723 : * bd_crypto_fvault2_open:
1724 : * @device: the device to open
1725 : * @name: name for the FVAULT2 device
1726 : * @context: key slot context (passphrase/keyfile/token...) for this FVAULT2 volume
1727 : * @read_only: whether to open as read-only or not (meaning read-write)
1728 : * @error: (out) (optional): place to store error (if any)
1729 : *
1730 : * Supported @context types for this function: passphrase, key file
1731 : *
1732 : * Returns: whether the @device was successfully opened or not
1733 : *
1734 : * Tech category: %BD_CRYPTO_TECH_FVAULT2-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1735 : */
1736 3 : gboolean bd_crypto_fvault2_open (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, gboolean read_only, GError **error) {
1737 3 : return _bd_crypto_fvault2_open (device, name, context, read_only, error);
1738 : }
1739 :
1740 :
1741 0 : static gboolean bd_crypto_fvault2_open_flags_stub (const gchar *device G_GNUC_UNUSED, const gchar *name G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, BDCryptoOpenFlags flags G_GNUC_UNUSED, GError **error) {
1742 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_fvault2_open_flags' called, but not implemented!");
1743 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1744 : "The function 'bd_crypto_fvault2_open_flags' called, but not implemented!");
1745 0 : return FALSE;
1746 : }
1747 :
1748 : static gboolean (*_bd_crypto_fvault2_open_flags) (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, BDCryptoOpenFlags flags, GError **error) = bd_crypto_fvault2_open_flags_stub;
1749 :
1750 : /**
1751 : * bd_crypto_fvault2_open_flags:
1752 : * @device: the device to open
1753 : * @name: name for the FVAULT2 device
1754 : * @context: key slot context (passphrase/keyfile/token...) for this FVAULT2 volume
1755 : * @flags: activation flags for the FVAULT2 device
1756 : * @error: (out) (optional): place to store error (if any)
1757 : *
1758 : * Supported @context types for this function: passphrase, key file
1759 : *
1760 : * Returns: whether the @device was successfully opened or not
1761 : *
1762 : * Tech category: %BD_CRYPTO_TECH_FVAULT2-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1763 : */
1764 4 : gboolean bd_crypto_fvault2_open_flags (const gchar *device, const gchar *name, BDCryptoKeyslotContext *context, BDCryptoOpenFlags flags, GError **error) {
1765 4 : return _bd_crypto_fvault2_open_flags (device, name, context, flags, error);
1766 : }
1767 :
1768 :
1769 0 : static gboolean bd_crypto_fvault2_close_stub (const gchar *fvault2_device G_GNUC_UNUSED, GError **error) {
1770 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_fvault2_close' called, but not implemented!");
1771 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1772 : "The function 'bd_crypto_fvault2_close' called, but not implemented!");
1773 0 : return FALSE;
1774 : }
1775 :
1776 : static gboolean (*_bd_crypto_fvault2_close) (const gchar *fvault2_device, GError **error) = bd_crypto_fvault2_close_stub;
1777 :
1778 : /**
1779 : * bd_crypto_fvault2_close:
1780 : * @fvault2_device: FVAULT2 device to close
1781 : * @error: (out) (optional): place to store error (if any)
1782 : *
1783 : * Returns: whether the given @fvault2_device was successfully closed or not
1784 : *
1785 : * Tech category: %BD_CRYPTO_TECH_FVAULT2-%BD_CRYPTO_TECH_MODE_OPEN_CLOSE
1786 : */
1787 3 : gboolean bd_crypto_fvault2_close (const gchar *fvault2_device, GError **error) {
1788 3 : return _bd_crypto_fvault2_close (fvault2_device, error);
1789 : }
1790 :
1791 :
1792 0 : static gboolean bd_crypto_opal_is_supported_stub (const gchar *device G_GNUC_UNUSED, GError **error) {
1793 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_opal_is_supported' called, but not implemented!");
1794 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1795 : "The function 'bd_crypto_opal_is_supported' called, but not implemented!");
1796 0 : return FALSE;
1797 : }
1798 :
1799 : static gboolean (*_bd_crypto_opal_is_supported) (const gchar *device, GError **error) = bd_crypto_opal_is_supported_stub;
1800 :
1801 : /**
1802 : * bd_crypto_opal_is_supported:
1803 : * @device: device to check for OPAL support
1804 : * @error: (out) (optional): place to store error (if any)
1805 : *
1806 : * Returns: %TRUE if the given @device supports OPAL or %FALSE if not or
1807 : * failed to determine (the @error is populated with the error in such
1808 : * cases).
1809 : *
1810 : * Tech category: %BD_CRYPTO_TECH_SED_OPAL-%BD_CRYPTO_TECH_MODE_QUERY
1811 : */
1812 3 : gboolean bd_crypto_opal_is_supported (const gchar *device, GError **error) {
1813 3 : return _bd_crypto_opal_is_supported (device, error);
1814 : }
1815 :
1816 :
1817 0 : static gboolean bd_crypto_opal_wipe_device_stub (const gchar *device G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, GError **error) {
1818 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_opal_wipe_device' called, but not implemented!");
1819 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1820 : "The function 'bd_crypto_opal_wipe_device' called, but not implemented!");
1821 0 : return FALSE;
1822 : }
1823 :
1824 : static gboolean (*_bd_crypto_opal_wipe_device) (const gchar *device, BDCryptoKeyslotContext *context, GError **error) = bd_crypto_opal_wipe_device_stub;
1825 :
1826 : /**
1827 : * bd_crypto_opal_wipe_device:
1828 : * @device: LUKS HW-OPAL device to wipe
1829 : * @context: OPAL admin passphrase context
1830 : * @error: (out) (optional): place to store error (if any)
1831 : *
1832 : * Returns: whether @device was successfully wiped or not.
1833 : *
1834 : * Supported @context types for this function: passphrase
1835 : *
1836 : * Tech category: %BD_CRYPTO_TECH_SED_OPAL-%BD_CRYPTO_TECH_MODE_MODIFY
1837 : */
1838 1 : gboolean bd_crypto_opal_wipe_device (const gchar *device, BDCryptoKeyslotContext *context, GError **error) {
1839 1 : return _bd_crypto_opal_wipe_device (device, context, error);
1840 : }
1841 :
1842 :
1843 0 : static gboolean bd_crypto_opal_format_stub (const gchar *device G_GNUC_UNUSED, const gchar *cipher G_GNUC_UNUSED, guint64 key_size G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, guint64 min_entropy G_GNUC_UNUSED, BDCryptoLUKSHWEncryptionType hw_encryption G_GNUC_UNUSED, BDCryptoKeyslotContext *opal_context G_GNUC_UNUSED, BDCryptoLUKSExtra *extra G_GNUC_UNUSED, GError **error) {
1844 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_opal_format' called, but not implemented!");
1845 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1846 : "The function 'bd_crypto_opal_format' called, but not implemented!");
1847 0 : return FALSE;
1848 : }
1849 :
1850 : static gboolean (*_bd_crypto_opal_format) (const gchar *device, const gchar *cipher, guint64 key_size, BDCryptoKeyslotContext *context, guint64 min_entropy, BDCryptoLUKSHWEncryptionType hw_encryption, BDCryptoKeyslotContext *opal_context, BDCryptoLUKSExtra *extra, GError **error) = bd_crypto_opal_format_stub;
1851 :
1852 : /**
1853 : * bd_crypto_opal_format:
1854 : * @device: a device to format as LUKS HW-OPAL
1855 : * @cipher: (nullable): cipher specification (type-mode, e.g. "aes-xts-plain64") or %NULL to use the default
1856 : * @key_size: size of the volume key in bits or 0 to use the default
1857 : * @context: key slot context (passphrase/keyfile/token...) for this LUKS device
1858 : * @min_entropy: minimum random data entropy (in bits) required to format @device as LUKS
1859 : * @hw_encryption: type of hardware encryption (SW+HW or HW only)
1860 : * @opal_context: OPAL admin passphrase
1861 : * @extra: (nullable): extra arguments for LUKS format creation
1862 : * @error: (out) (optional): place to store error (if any)
1863 : *
1864 : * Formats the given @device as LUKS HW-OPAL according to the other parameters given. If
1865 : * @min_entropy is specified (greater than 0), the function waits for enough
1866 : * entropy to be available in the random data pool (WHICH MAY POTENTIALLY TAKE
1867 : * FOREVER).
1868 : *
1869 : * Supported @context types for this function: passphrase, key file
1870 : * Supported @opal_context types for this function: passphrase
1871 : *
1872 : * Returns: whether the given @device was successfully formatted as LUKS HW-OPAL or not
1873 : * (the @error contains the error in such cases)
1874 : *
1875 : * Tech category: %BD_CRYPTO_TECH_LUKS-%BD_CRYPTO_TECH_MODE_CREATE
1876 : */
1877 1 : gboolean bd_crypto_opal_format (const gchar *device, const gchar *cipher, guint64 key_size, BDCryptoKeyslotContext *context, guint64 min_entropy, BDCryptoLUKSHWEncryptionType hw_encryption, BDCryptoKeyslotContext *opal_context, BDCryptoLUKSExtra *extra, GError **error) {
1878 1 : return _bd_crypto_opal_format (device, cipher, key_size, context, min_entropy, hw_encryption, opal_context, extra, error);
1879 : }
1880 :
1881 :
1882 0 : static gboolean bd_crypto_opal_reset_device_stub (const gchar *device G_GNUC_UNUSED, BDCryptoKeyslotContext *context G_GNUC_UNUSED, GError **error) {
1883 0 : bd_utils_log_format (BD_UTILS_LOG_CRIT, "The function 'bd_crypto_opal_reset_device' called, but not implemented!");
1884 0 : g_set_error (error, BD_INIT_ERROR, BD_INIT_ERROR_NOT_IMPLEMENTED,
1885 : "The function 'bd_crypto_opal_reset_device' called, but not implemented!");
1886 0 : return FALSE;
1887 : }
1888 :
1889 : static gboolean (*_bd_crypto_opal_reset_device) (const gchar *device, BDCryptoKeyslotContext *context, GError **error) = bd_crypto_opal_reset_device_stub;
1890 :
1891 : /**
1892 : * bd_crypto_opal_reset_device:
1893 : * @device: LUKS HW-OPAL device to run PSID reset on
1894 : * @context: PSID context
1895 : * @error: (out) (optional): place to store error (if any)
1896 : *
1897 : * Returns: whether PSI reset on @device was successful or not.
1898 : *
1899 : * Warning: PSID reset will remove all data from @device!
1900 : *
1901 : * Supported @context types for this function: passphrase, key file
1902 : *
1903 : * Tech category: %BD_CRYPTO_TECH_SED_OPAL-%BD_CRYPTO_TECH_MODE_MODIFY
1904 : */
1905 1 : gboolean bd_crypto_opal_reset_device (const gchar *device, BDCryptoKeyslotContext *context, GError **error) {
1906 1 : return _bd_crypto_opal_reset_device (device, context, error);
1907 : }
1908 :
1909 :
1910 40 : static gpointer load_crypto_from_plugin(const gchar *so_name) {
1911 40 : void *handle = NULL;
1912 40 : char *error = NULL;
1913 40 : gboolean (*init_fn) (void) = NULL;
1914 :
1915 40 : handle = dlopen(so_name, RTLD_LAZY);
1916 40 : if (!handle) {
1917 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load module crypto: %s", dlerror());
1918 0 : return NULL;
1919 : }
1920 :
1921 40 : dlerror();
1922 40 : * (void**) (&init_fn) = dlsym(handle, "bd_crypto_init");
1923 40 : if ((error = dlerror()) != NULL)
1924 0 : bd_utils_log_format (BD_UTILS_LOG_DEBUG, "failed to load the init() function for crypto: %s", error);
1925 : /* coverity[dead_error_condition] */
1926 40 : if (init_fn && !init_fn()) {
1927 0 : dlclose(handle);
1928 0 : return NULL;
1929 : }
1930 40 : init_fn = NULL;
1931 :
1932 40 : dlerror();
1933 40 : * (void**) (&_bd_crypto_is_tech_avail) = dlsym(handle, "bd_crypto_is_tech_avail");
1934 40 : if ((error = dlerror()) != NULL)
1935 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_is_tech_avail: %s", error);
1936 :
1937 40 : dlerror();
1938 40 : * (void**) (&_bd_crypto_generate_backup_passphrase) = dlsym(handle, "bd_crypto_generate_backup_passphrase");
1939 40 : if ((error = dlerror()) != NULL)
1940 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_generate_backup_passphrase: %s", error);
1941 :
1942 40 : dlerror();
1943 40 : * (void**) (&_bd_crypto_device_is_luks) = dlsym(handle, "bd_crypto_device_is_luks");
1944 40 : if ((error = dlerror()) != NULL)
1945 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_device_is_luks: %s", error);
1946 :
1947 40 : dlerror();
1948 40 : * (void**) (&_bd_crypto_luks_status) = dlsym(handle, "bd_crypto_luks_status");
1949 40 : if ((error = dlerror()) != NULL)
1950 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_status: %s", error);
1951 :
1952 40 : dlerror();
1953 40 : * (void**) (&_bd_crypto_keyslot_context_new_passphrase) = dlsym(handle, "bd_crypto_keyslot_context_new_passphrase");
1954 40 : if ((error = dlerror()) != NULL)
1955 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_keyslot_context_new_passphrase: %s", error);
1956 :
1957 40 : dlerror();
1958 40 : * (void**) (&_bd_crypto_keyslot_context_new_keyfile) = dlsym(handle, "bd_crypto_keyslot_context_new_keyfile");
1959 40 : if ((error = dlerror()) != NULL)
1960 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_keyslot_context_new_keyfile: %s", error);
1961 :
1962 40 : dlerror();
1963 40 : * (void**) (&_bd_crypto_keyslot_context_new_keyring) = dlsym(handle, "bd_crypto_keyslot_context_new_keyring");
1964 40 : if ((error = dlerror()) != NULL)
1965 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_keyslot_context_new_keyring: %s", error);
1966 :
1967 40 : dlerror();
1968 40 : * (void**) (&_bd_crypto_keyslot_context_new_volume_key) = dlsym(handle, "bd_crypto_keyslot_context_new_volume_key");
1969 40 : if ((error = dlerror()) != NULL)
1970 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_keyslot_context_new_volume_key: %s", error);
1971 :
1972 40 : dlerror();
1973 40 : * (void**) (&_bd_crypto_luks_format) = dlsym(handle, "bd_crypto_luks_format");
1974 40 : if ((error = dlerror()) != NULL)
1975 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_format: %s", error);
1976 :
1977 40 : dlerror();
1978 40 : * (void**) (&_bd_crypto_luks_open) = dlsym(handle, "bd_crypto_luks_open");
1979 40 : if ((error = dlerror()) != NULL)
1980 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_open: %s", error);
1981 :
1982 40 : dlerror();
1983 40 : * (void**) (&_bd_crypto_luks_open_flags) = dlsym(handle, "bd_crypto_luks_open_flags");
1984 40 : if ((error = dlerror()) != NULL)
1985 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_open_flags: %s", error);
1986 :
1987 40 : dlerror();
1988 40 : * (void**) (&_bd_crypto_luks_close) = dlsym(handle, "bd_crypto_luks_close");
1989 40 : if ((error = dlerror()) != NULL)
1990 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_close: %s", error);
1991 :
1992 40 : dlerror();
1993 40 : * (void**) (&_bd_crypto_luks_add_key) = dlsym(handle, "bd_crypto_luks_add_key");
1994 40 : if ((error = dlerror()) != NULL)
1995 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_add_key: %s", error);
1996 :
1997 40 : dlerror();
1998 40 : * (void**) (&_bd_crypto_luks_remove_key) = dlsym(handle, "bd_crypto_luks_remove_key");
1999 40 : if ((error = dlerror()) != NULL)
2000 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_remove_key: %s", error);
2001 :
2002 40 : dlerror();
2003 40 : * (void**) (&_bd_crypto_luks_change_key) = dlsym(handle, "bd_crypto_luks_change_key");
2004 40 : if ((error = dlerror()) != NULL)
2005 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_change_key: %s", error);
2006 :
2007 40 : dlerror();
2008 40 : * (void**) (&_bd_crypto_luks_resize) = dlsym(handle, "bd_crypto_luks_resize");
2009 40 : if ((error = dlerror()) != NULL)
2010 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_resize: %s", error);
2011 :
2012 40 : dlerror();
2013 40 : * (void**) (&_bd_crypto_luks_suspend) = dlsym(handle, "bd_crypto_luks_suspend");
2014 40 : if ((error = dlerror()) != NULL)
2015 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_suspend: %s", error);
2016 :
2017 40 : dlerror();
2018 40 : * (void**) (&_bd_crypto_luks_resume) = dlsym(handle, "bd_crypto_luks_resume");
2019 40 : if ((error = dlerror()) != NULL)
2020 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_resume: %s", error);
2021 :
2022 40 : dlerror();
2023 40 : * (void**) (&_bd_crypto_luks_kill_slot) = dlsym(handle, "bd_crypto_luks_kill_slot");
2024 40 : if ((error = dlerror()) != NULL)
2025 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_kill_slot: %s", error);
2026 :
2027 40 : dlerror();
2028 40 : * (void**) (&_bd_crypto_luks_header_backup) = dlsym(handle, "bd_crypto_luks_header_backup");
2029 40 : if ((error = dlerror()) != NULL)
2030 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_header_backup: %s", error);
2031 :
2032 40 : dlerror();
2033 40 : * (void**) (&_bd_crypto_luks_header_restore) = dlsym(handle, "bd_crypto_luks_header_restore");
2034 40 : if ((error = dlerror()) != NULL)
2035 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_header_restore: %s", error);
2036 :
2037 40 : dlerror();
2038 40 : * (void**) (&_bd_crypto_luks_set_label) = dlsym(handle, "bd_crypto_luks_set_label");
2039 40 : if ((error = dlerror()) != NULL)
2040 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_set_label: %s", error);
2041 :
2042 40 : dlerror();
2043 40 : * (void**) (&_bd_crypto_luks_check_label) = dlsym(handle, "bd_crypto_luks_check_label");
2044 40 : if ((error = dlerror()) != NULL)
2045 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_check_label: %s", error);
2046 :
2047 40 : dlerror();
2048 40 : * (void**) (&_bd_crypto_luks_set_uuid) = dlsym(handle, "bd_crypto_luks_set_uuid");
2049 40 : if ((error = dlerror()) != NULL)
2050 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_set_uuid: %s", error);
2051 :
2052 40 : dlerror();
2053 40 : * (void**) (&_bd_crypto_luks_convert) = dlsym(handle, "bd_crypto_luks_convert");
2054 40 : if ((error = dlerror()) != NULL)
2055 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_convert: %s", error);
2056 :
2057 40 : dlerror();
2058 40 : * (void**) (&_bd_crypto_luks_set_persistent_flags) = dlsym(handle, "bd_crypto_luks_set_persistent_flags");
2059 40 : if ((error = dlerror()) != NULL)
2060 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_set_persistent_flags: %s", error);
2061 :
2062 40 : dlerror();
2063 40 : * (void**) (&_bd_crypto_luks_info) = dlsym(handle, "bd_crypto_luks_info");
2064 40 : if ((error = dlerror()) != NULL)
2065 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_info: %s", error);
2066 :
2067 40 : dlerror();
2068 40 : * (void**) (&_bd_crypto_bitlk_info) = dlsym(handle, "bd_crypto_bitlk_info");
2069 40 : if ((error = dlerror()) != NULL)
2070 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_bitlk_info: %s", error);
2071 :
2072 40 : dlerror();
2073 40 : * (void**) (&_bd_crypto_integrity_info) = dlsym(handle, "bd_crypto_integrity_info");
2074 40 : if ((error = dlerror()) != NULL)
2075 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_integrity_info: %s", error);
2076 :
2077 40 : dlerror();
2078 40 : * (void**) (&_bd_crypto_luks_token_info) = dlsym(handle, "bd_crypto_luks_token_info");
2079 40 : if ((error = dlerror()) != NULL)
2080 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_luks_token_info: %s", error);
2081 :
2082 40 : dlerror();
2083 40 : * (void**) (&_bd_crypto_integrity_format) = dlsym(handle, "bd_crypto_integrity_format");
2084 40 : if ((error = dlerror()) != NULL)
2085 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_integrity_format: %s", error);
2086 :
2087 40 : dlerror();
2088 40 : * (void**) (&_bd_crypto_integrity_open) = dlsym(handle, "bd_crypto_integrity_open");
2089 40 : if ((error = dlerror()) != NULL)
2090 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_integrity_open: %s", error);
2091 :
2092 40 : dlerror();
2093 40 : * (void**) (&_bd_crypto_integrity_close) = dlsym(handle, "bd_crypto_integrity_close");
2094 40 : if ((error = dlerror()) != NULL)
2095 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_integrity_close: %s", error);
2096 :
2097 40 : dlerror();
2098 40 : * (void**) (&_bd_crypto_keyring_add_key) = dlsym(handle, "bd_crypto_keyring_add_key");
2099 40 : if ((error = dlerror()) != NULL)
2100 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_keyring_add_key: %s", error);
2101 :
2102 40 : dlerror();
2103 40 : * (void**) (&_bd_crypto_device_seems_encrypted) = dlsym(handle, "bd_crypto_device_seems_encrypted");
2104 40 : if ((error = dlerror()) != NULL)
2105 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_device_seems_encrypted: %s", error);
2106 :
2107 40 : dlerror();
2108 40 : * (void**) (&_bd_crypto_tc_open) = dlsym(handle, "bd_crypto_tc_open");
2109 40 : if ((error = dlerror()) != NULL)
2110 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_tc_open: %s", error);
2111 :
2112 40 : dlerror();
2113 40 : * (void**) (&_bd_crypto_tc_open_flags) = dlsym(handle, "bd_crypto_tc_open_flags");
2114 40 : if ((error = dlerror()) != NULL)
2115 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_tc_open_flags: %s", error);
2116 :
2117 40 : dlerror();
2118 40 : * (void**) (&_bd_crypto_tc_close) = dlsym(handle, "bd_crypto_tc_close");
2119 40 : if ((error = dlerror()) != NULL)
2120 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_tc_close: %s", error);
2121 :
2122 40 : dlerror();
2123 40 : * (void**) (&_bd_crypto_escrow_device) = dlsym(handle, "bd_crypto_escrow_device");
2124 40 : if ((error = dlerror()) != NULL)
2125 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_escrow_device: %s", error);
2126 :
2127 40 : dlerror();
2128 40 : * (void**) (&_bd_crypto_bitlk_open) = dlsym(handle, "bd_crypto_bitlk_open");
2129 40 : if ((error = dlerror()) != NULL)
2130 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_bitlk_open: %s", error);
2131 :
2132 40 : dlerror();
2133 40 : * (void**) (&_bd_crypto_bitlk_open_flags) = dlsym(handle, "bd_crypto_bitlk_open_flags");
2134 40 : if ((error = dlerror()) != NULL)
2135 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_bitlk_open_flags: %s", error);
2136 :
2137 40 : dlerror();
2138 40 : * (void**) (&_bd_crypto_bitlk_close) = dlsym(handle, "bd_crypto_bitlk_close");
2139 40 : if ((error = dlerror()) != NULL)
2140 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_bitlk_close: %s", error);
2141 :
2142 40 : dlerror();
2143 40 : * (void**) (&_bd_crypto_fvault2_open) = dlsym(handle, "bd_crypto_fvault2_open");
2144 40 : if ((error = dlerror()) != NULL)
2145 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_fvault2_open: %s", error);
2146 :
2147 40 : dlerror();
2148 40 : * (void**) (&_bd_crypto_fvault2_open_flags) = dlsym(handle, "bd_crypto_fvault2_open_flags");
2149 40 : if ((error = dlerror()) != NULL)
2150 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_fvault2_open_flags: %s", error);
2151 :
2152 40 : dlerror();
2153 40 : * (void**) (&_bd_crypto_fvault2_close) = dlsym(handle, "bd_crypto_fvault2_close");
2154 40 : if ((error = dlerror()) != NULL)
2155 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_fvault2_close: %s", error);
2156 :
2157 40 : dlerror();
2158 40 : * (void**) (&_bd_crypto_opal_is_supported) = dlsym(handle, "bd_crypto_opal_is_supported");
2159 40 : if ((error = dlerror()) != NULL)
2160 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_opal_is_supported: %s", error);
2161 :
2162 40 : dlerror();
2163 40 : * (void**) (&_bd_crypto_opal_wipe_device) = dlsym(handle, "bd_crypto_opal_wipe_device");
2164 40 : if ((error = dlerror()) != NULL)
2165 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_opal_wipe_device: %s", error);
2166 :
2167 40 : dlerror();
2168 40 : * (void**) (&_bd_crypto_opal_format) = dlsym(handle, "bd_crypto_opal_format");
2169 40 : if ((error = dlerror()) != NULL)
2170 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_opal_format: %s", error);
2171 :
2172 40 : dlerror();
2173 40 : * (void**) (&_bd_crypto_opal_reset_device) = dlsym(handle, "bd_crypto_opal_reset_device");
2174 40 : if ((error = dlerror()) != NULL)
2175 0 : bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load bd_crypto_opal_reset_device: %s", error);
2176 :
2177 40 : return handle;
2178 : }
2179 :
2180 40 : static gboolean unload_crypto (gpointer handle) {
2181 40 : char *error = NULL;
2182 40 : gboolean (*close_fn) (void) = NULL;
2183 :
2184 40 : _bd_crypto_is_tech_avail = bd_crypto_is_tech_avail_stub;
2185 40 : _bd_crypto_generate_backup_passphrase = bd_crypto_generate_backup_passphrase_stub;
2186 40 : _bd_crypto_device_is_luks = bd_crypto_device_is_luks_stub;
2187 40 : _bd_crypto_luks_status = bd_crypto_luks_status_stub;
2188 40 : _bd_crypto_keyslot_context_new_passphrase = bd_crypto_keyslot_context_new_passphrase_stub;
2189 40 : _bd_crypto_keyslot_context_new_keyfile = bd_crypto_keyslot_context_new_keyfile_stub;
2190 40 : _bd_crypto_keyslot_context_new_keyring = bd_crypto_keyslot_context_new_keyring_stub;
2191 40 : _bd_crypto_keyslot_context_new_volume_key = bd_crypto_keyslot_context_new_volume_key_stub;
2192 40 : _bd_crypto_luks_format = bd_crypto_luks_format_stub;
2193 40 : _bd_crypto_luks_open = bd_crypto_luks_open_stub;
2194 40 : _bd_crypto_luks_open_flags = bd_crypto_luks_open_flags_stub;
2195 40 : _bd_crypto_luks_close = bd_crypto_luks_close_stub;
2196 40 : _bd_crypto_luks_add_key = bd_crypto_luks_add_key_stub;
2197 40 : _bd_crypto_luks_remove_key = bd_crypto_luks_remove_key_stub;
2198 40 : _bd_crypto_luks_change_key = bd_crypto_luks_change_key_stub;
2199 40 : _bd_crypto_luks_resize = bd_crypto_luks_resize_stub;
2200 40 : _bd_crypto_luks_suspend = bd_crypto_luks_suspend_stub;
2201 40 : _bd_crypto_luks_resume = bd_crypto_luks_resume_stub;
2202 40 : _bd_crypto_luks_kill_slot = bd_crypto_luks_kill_slot_stub;
2203 40 : _bd_crypto_luks_header_backup = bd_crypto_luks_header_backup_stub;
2204 40 : _bd_crypto_luks_header_restore = bd_crypto_luks_header_restore_stub;
2205 40 : _bd_crypto_luks_set_label = bd_crypto_luks_set_label_stub;
2206 40 : _bd_crypto_luks_check_label = bd_crypto_luks_check_label_stub;
2207 40 : _bd_crypto_luks_set_uuid = bd_crypto_luks_set_uuid_stub;
2208 40 : _bd_crypto_luks_convert = bd_crypto_luks_convert_stub;
2209 40 : _bd_crypto_luks_set_persistent_flags = bd_crypto_luks_set_persistent_flags_stub;
2210 40 : _bd_crypto_luks_info = bd_crypto_luks_info_stub;
2211 40 : _bd_crypto_bitlk_info = bd_crypto_bitlk_info_stub;
2212 40 : _bd_crypto_integrity_info = bd_crypto_integrity_info_stub;
2213 40 : _bd_crypto_luks_token_info = bd_crypto_luks_token_info_stub;
2214 40 : _bd_crypto_integrity_format = bd_crypto_integrity_format_stub;
2215 40 : _bd_crypto_integrity_open = bd_crypto_integrity_open_stub;
2216 40 : _bd_crypto_integrity_close = bd_crypto_integrity_close_stub;
2217 40 : _bd_crypto_keyring_add_key = bd_crypto_keyring_add_key_stub;
2218 40 : _bd_crypto_device_seems_encrypted = bd_crypto_device_seems_encrypted_stub;
2219 40 : _bd_crypto_tc_open = bd_crypto_tc_open_stub;
2220 40 : _bd_crypto_tc_open_flags = bd_crypto_tc_open_flags_stub;
2221 40 : _bd_crypto_tc_close = bd_crypto_tc_close_stub;
2222 40 : _bd_crypto_escrow_device = bd_crypto_escrow_device_stub;
2223 40 : _bd_crypto_bitlk_open = bd_crypto_bitlk_open_stub;
2224 40 : _bd_crypto_bitlk_open_flags = bd_crypto_bitlk_open_flags_stub;
2225 40 : _bd_crypto_bitlk_close = bd_crypto_bitlk_close_stub;
2226 40 : _bd_crypto_fvault2_open = bd_crypto_fvault2_open_stub;
2227 40 : _bd_crypto_fvault2_open_flags = bd_crypto_fvault2_open_flags_stub;
2228 40 : _bd_crypto_fvault2_close = bd_crypto_fvault2_close_stub;
2229 40 : _bd_crypto_opal_is_supported = bd_crypto_opal_is_supported_stub;
2230 40 : _bd_crypto_opal_wipe_device = bd_crypto_opal_wipe_device_stub;
2231 40 : _bd_crypto_opal_format = bd_crypto_opal_format_stub;
2232 40 : _bd_crypto_opal_reset_device = bd_crypto_opal_reset_device_stub;
2233 :
2234 40 : dlerror();
2235 40 : * (void**) (&close_fn) = dlsym(handle, "bd_crypto_close");
2236 40 : if (((error = dlerror()) != NULL) || !close_fn)
2237 0 : bd_utils_log_format (BD_UTILS_LOG_DEBUG, "failed to load the close_plugin() function for crypto: %s", error);
2238 : /* coverity[dead_error_condition] */
2239 40 : if (close_fn) {
2240 40 : close_fn();
2241 : }
2242 :
2243 40 : return dlclose(handle) == 0;
2244 : }
2245 :
|