~xnox/debian/sid/cryptsetup/ubuntu

« back to all changes in this revision

Viewing changes to lib/internal.h

  • Committer: Package Import Robot
  • Author(s): Jonas Meurer, Milan Broz, Steve Langasek, Jonas Meurer
  • Date: 2013-06-28 12:10:41 UTC
  • mfrom: (0.2.11)
  • Revision ID: package-import@ubuntu.com-20130628121041-ek9rtel19yehj31t
Tags: 2:1.6.1-1
[ Milan Broz ]
* new upstream version. (closes: #704827, 707997)
  - default LUKS encryption mode is XTS (aes-xts-plain64) (closes: #714331)
  - adds native support for Truecrypt and compatible on-disk format
  - adds benchmark command
  - adds cryptsetup-reencrypt, a tool to offline reencrypt LUKS device
  - adds veritysetup, a tool for dm-verity block device verification module
* install docs/examples into docs at cryptsetup-dev package.
* fix compilation warnings in askpass.c.

[ Steve Langasek ]
* fix upstart jobs to not cause boot hangs when actually used in
  conjunction with startpar.  (closes: #694499, #677712).
* in connection with the above, make the cryptdisks-early job explicitly
  wait for 'umountfs' on shutdown just like cryptdisks does; otherwise,
  the teardown of the cryptdisks upstart job may cause the cryptdisks-early
  init script run before we're done unmounting filesystems.

[ Jonas Meurer ]
* minor wording fixes to README.initramfs, suggested by intrigeri and Adam
  D. Barrett.
* add bash-completion script for cryptdisks_{start,stop}. Thanks to Claudius
  Hubig for providing a patch. (closes: #700777)
* support specifying key-slot in crypttab. Thanks to Kevin Locke for the
  patch. (closes: #704470)
* remove evms support code from cryptroot initramfs script. (closes: #713918)
* fix location of keyscripts in initramfs documentation. (closes: #697446)
* fix a typo in decrypt_ssl script that prevented stdout from beeing
  redirected to /dev/null. (closes: #700285)
* give full path to blkid in crytproot initramfs script. (closes: #697155)
* export number of previous tries from cryptroot and cryptdisks to
  keyscript. Thanks to Laurens Blankers for the idea. Opens the possibility
  to fallback after a given number of tries for keyscripts. (closes: #438481,
  #471729, #697455)
* improve check for cpu hardware encryption support in initramfs cryptroot
  hook. (closes: #714326)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Copyright (C) 2004, Christophe Saout <christophe@saout.de>
5
5
 * Copyright (C) 2004-2007, Clemens Fruhwirth <clemens@endorphin.org>
6
6
 * Copyright (C) 2009-2012, Red Hat, Inc. All rights reserved.
 
7
 * Copyright (C) 2009-2012, Milan Broz
7
8
 *
8
9
 * This program is free software; you can redistribute it and/or
9
10
 * modify it under the terms of the GNU General Public License
10
 
 * version 2 as published by the Free Software Foundation.
 
11
 * as published by the Free Software Foundation; either version 2
 
12
 * of the License, or (at your option) any later version.
11
13
 *
12
14
 * This program is distributed in the hope that it will be useful,
13
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
34
#include <inttypes.h>
33
35
 
34
36
#include "nls.h"
 
37
#include "bitops.h"
35
38
#include "utils_crypt.h"
36
39
#include "utils_loop.h"
37
40
#include "utils_dm.h"
38
41
#include "utils_fips.h"
39
42
#include "crypto_backend.h"
40
43
 
 
44
#include "libcryptsetup.h"
 
45
 
41
46
/* to silent gcc -Wcast-qual for const cast */
42
47
#define CONST_CAST(x) (x)(uintptr_t)
43
48
 
60
65
struct volume_key *crypt_generate_volume_key(struct crypt_device *cd, unsigned keylength);
61
66
void crypt_free_volume_key(struct volume_key *vk);
62
67
 
 
68
/* Device backend */
 
69
struct device;
 
70
int device_alloc(struct device **device, const char *path);
 
71
void device_free(struct device *device);
 
72
const char *device_path(const struct device *device);
 
73
const char *device_block_path(const struct device *device);
 
74
void device_topology_alignment(struct device *device,
 
75
                            unsigned long *required_alignment, /* bytes */
 
76
                            unsigned long *alignment_offset,   /* bytes */
 
77
                            unsigned long default_alignment);
 
78
int device_block_size(struct device *device);
 
79
int device_read_ahead(struct device *device, uint32_t *read_ahead);
 
80
int device_size(struct device *device, uint64_t *size);
 
81
int device_open(struct device *device, int flags);
 
82
 
 
83
enum devcheck { DEV_OK = 0, DEV_EXCL = 1, DEV_SHARED = 2 };
 
84
int device_block_adjust(struct crypt_device *cd,
 
85
                        struct device *device,
 
86
                        enum devcheck device_check,
 
87
                        uint64_t device_offset,
 
88
                        uint64_t *size,
 
89
                        uint32_t *flags);
 
90
size_t size_round_up(size_t size, unsigned int block);
 
91
 
 
92
/* Receive backend devices from context helpers */
 
93
struct device *crypt_metadata_device(struct crypt_device *cd);
 
94
struct device *crypt_data_device(struct crypt_device *cd);
 
95
 
63
96
int crypt_confirm(struct crypt_device *cd, const char *msg);
64
97
 
65
98
char *crypt_lookup_dev(const char *dev_id);
66
 
int crypt_sysfs_check_crypt_segment(const char *device, uint64_t offset, uint64_t size);
67
99
int crypt_sysfs_get_rotational(int major, int minor, int *rotational);
68
100
 
69
 
int sector_size_for_device(const char *device);
70
 
int device_read_ahead(const char *dev, uint32_t *read_ahead);
71
 
ssize_t write_blockwise(int fd, void *buf, size_t count);
72
 
ssize_t read_blockwise(int fd, void *_buf, size_t count);
73
 
ssize_t write_lseek_blockwise(int fd, char *buf, size_t count, off_t offset);
74
 
int device_ready(struct crypt_device *cd, const char *device, int mode);
75
 
int device_size(const char *device, uint64_t *size);
 
101
ssize_t write_blockwise(int fd, int bsize, void *buf, size_t count);
 
102
ssize_t read_blockwise(int fd, int bsize, void *_buf, size_t count);
 
103
ssize_t write_lseek_blockwise(int fd, int bsize, char *buf, size_t count, off_t offset);
76
104
 
77
 
enum devcheck { DEV_OK = 0, DEV_EXCL = 1, DEV_SHARED = 2 };
78
 
int device_check_and_adjust(struct crypt_device *cd,
79
 
                            const char *device,
80
 
                            enum devcheck device_check,
81
 
                            uint64_t *size,
82
 
                            uint64_t *offset,
83
 
                            uint32_t *flags);
 
105
unsigned crypt_getpagesize(void);
 
106
int init_crypto(struct crypt_device *ctx);
84
107
 
85
108
void logger(struct crypt_device *cd, int class, const char *file, int line, const char *format, ...);
86
109
#define log_dbg(x...) logger(NULL, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x)
89
112
#define log_err(c, x...) logger(c, CRYPT_LOG_ERROR, __FILE__, __LINE__, x)
90
113
 
91
114
int crypt_get_debug_level(void);
92
 
void debug_processes_using_device(const char *name);
93
115
 
94
116
int crypt_memlock_inc(struct crypt_device *ctx);
95
117
int crypt_memlock_dec(struct crypt_device *ctx);
96
118
 
97
 
void get_topology_alignment(const char *device,
98
 
                            unsigned long *required_alignment, /* bytes */
99
 
                            unsigned long *alignment_offset,   /* bytes */
100
 
                            unsigned long default_alignment);
101
 
 
102
119
int crypt_random_init(struct crypt_device *ctx);
103
120
int crypt_random_get(struct crypt_device *ctx, char *buf, size_t len, int quality);
104
121
void crypt_random_exit(void);
127
144
                            * random algorithm */
128
145
} crypt_wipe_type;
129
146
 
130
 
int crypt_wipe(const char *device,
 
147
int crypt_wipe(struct device *device,
131
148
               uint64_t offset,
132
149
               uint64_t sectors,
133
150
               crypt_wipe_type type,