Commit Graph

76 Commits

Author SHA1 Message Date
Milan Broz
a0d2d4c0b1 Add uint64_to_str helper. 2017-09-24 19:50:01 +02:00
Milan Broz
57825365fe Fix another signed/unsigned compilation warnings. 2017-09-23 23:30:28 +02:00
angelomariafederichini191269@protonmail.com
e2fee206c2 Allocate suitable sized buffer when reading a keyfile
If the keyfile size is explicitly given, then allocate a suitable sized
buffer right from the start instead of increasing it in 4k steps. This
speeds up reading larger keyfiles.
2017-08-15 08:49:44 +02:00
angelomariafederichini191269@protonmail.com
596e374313 Use bulk read when reading keyfile
If reading a keyfile use bulk read operations instead of reading one
character at the time. This speeds up reading larger keyfiles.

If read should stop at a EOL, then fallback to reading one character at
the time to not read anything beyond the EOL character.
2017-08-15 08:39:53 +02:00
Milan Broz
503956707c Move crypt_keyfile_read() to libcryptsetup internal file.
The utils_crypt.c file is directly linked to userpsace tools,
we should use library call and not local implementation.
2017-08-15 08:35:10 +02:00
Milan Broz
0abf57be5d Change PBKDF interface API.
Prepare API for PBKDF that can set three costs
  - time (similar to iterations in PBKDF2)
  - memory (required memory for memory-hard function)
  - threads (required number of threads/CPUs).

This patch also removes wrongly designed API call
crypt_benchmark_kdf and replaces it with the new call
crypt_benchmark_pbkdf.

Two functions for PBKDF per context setting
are introduced: crypt_set_pbkdf_type and crypt_get_pbkdf_type.

The patch should be backward compatible when using
crypt_set_iteration_time function (works only for PBKDF2).

Signed-off-by: Milan Broz <gmazyland@gmail.com>
2017-08-06 21:24:05 +02:00
Milan Broz
e853aa2e7c Fix blockwise access functions for systems with big page size.
Initially cryptsetup expected underlying device that was, by definition,
always aligned to a sector size (and length was always multiple of sectors).

For the images in file, we can now access the image directly.
Expecting that the image is always aligned to the whole block is now false
(the last block in file image can be incomplete).

Moreover, we cannot easily detect underlying block device sector (block) size
(the storage stack can be complex with various RAID and loop block sizes),
so code uses systyem PAGE_SIZE in this situation (should be the safest way).

Unfortunately, PAGE_SIZE can be bigger (1MB) than device sector (4k) and
the blockwise functions then fails because the image in file is not
aligned to PAGE_SIZE multiple..

Fix it by checking that read/write for the last part of an image is
the exact requested size and not a full block.

(The problem is for example for an unaligned hidden Truecrypt header
on PPC64LE systems, where page size is 64k.)
2017-07-24 14:17:21 +02:00
Milan Broz
73030aa5fb Make block size size_t type.
And fix all related comparisons and functions.
2017-06-08 14:39:54 +02:00
Milan Broz
34bf809e51 Use device alignment wrapper.
And cache the value to not call ioctl on every block read/write.
2017-06-08 09:30:53 +02:00
Milan Broz
3f9346836e Get rid of old alignment code and use posix_memalign.
We require posix_memalign already for some time so it makes
no sense to keep old workarounds.
2017-04-30 13:13:46 +02:00
Milan Broz
eb59311136 Fix access to unaligned hidden TrueCrypt header.
On native 4k-sector device the old hidden header is not aligned
with hw sector size and derect-io access with SEEK_END fails.

Let's extend blockwise functions to support a negative offset
and use the same logic as normal unaligned writes.

Fixes problem mentioned in
https://gitlab.com/cryptsetup/cryptsetup/merge_requests/18
2017-03-27 12:04:31 +02:00
Milan Broz
98368c4770 Update copyright years. 2017-03-12 13:17:15 +01:00
Eduardo Villanueva Che
2c833c2342 Fixed veritysetup bug with hash offsets bigger than 2gb.
The lseek in function write_blockwise() could return value
that is greater than integer for result so it can overflow
and fail the whole write.
[comment added by mbroz]
2016-10-22 09:24:09 +02:00
Milan Broz
229497871d Fix write_lseek prototype and avoid using void in arithmetic warning. 2016-01-03 16:05:17 +01:00
Ondrej Kozina
8e160562ee read_lseek_blockwise: use void pointer 2015-12-12 17:02:27 +01:00
Ondrej Kozina
091dfa0c26 Slight code style improvements for blockwise functions. 2015-12-01 10:57:04 +01:00
Ondrej Kozina
7fc006b63b Add interrupt safe read_lseek_blockwise function. 2015-12-01 10:52:42 +01:00
Ondrej Kozina
64f3df44ee Use read/write buffer functions where appropriate. 2015-12-01 10:51:56 +01:00
Ondrej Kozina
42ccddeff3 Add read_buffer and write_buffer functions.
Introduce functions for proper I/O handling. These functions
are able to deal with interrupts and partial I/O.
2015-12-01 10:44:02 +01:00
Ondrej Kozina
0435fbf2e5 Avoid write with zero size.
This can happen if write buffer size is smaller than underlying
block size and initial buffer is misaligned.

Also use size_t for buffer length variables.
2015-12-01 10:42:08 +01:00
Milan Broz
bb8dbfdf5b Update author name. 2014-06-23 21:40:12 +02:00
Milan Broz
29f21208a0 Change License from GPLv2 only to GPLv2+ ("or any later").
Agreed by all copyright authors.
2012-12-29 11:33:54 +01:00
Milan Broz
83f02e6682 Add copyright line for files I have written or modified. 2012-12-21 16:40:33 +01:00
Milan Broz
9ae7b7d1be Fix regression in header backup (1.5.1).
Access to backup file must handle write to regular files too.
2012-12-19 13:19:05 +01:00
Milan Broz
50d5cfa8bc Get page size should never fail (in the works case it fails later with wrong alignment). 2012-12-10 17:47:06 +01:00
Milan Broz
98db3bc0bf Fix blockwise read/write for end writes near end of device.
Ignore setpriority failure (will be remoced later anyway).
2012-11-25 22:57:32 +01:00
Milan Broz
1d5788f779 Set context for DM log for all DM backend entries.
Try to handle error if run as non-root user better.
2012-08-14 19:17:13 +02:00
Milan Broz
65f975655c New device access backend.
Allocate loop device late (only when real block device needed).
Rework underlying device/file access functions.
Move all device (and ioctl) access to utils_device.c.

Allows using file where appropriate without allocation loop device.
2012-08-12 22:00:17 +02:00
Milan Broz
4b8f91d0d9 Remove some compilation warnings. 2012-06-10 18:56:04 +02:00
Milan Broz
cd8826618d Warn if block exceeds page size. 2012-06-07 15:09:58 +02:00
Milan Broz
f720affe8c Relax --shared test, allow mapping even for overlapping segments.
Support shared flag for LUKS devices (dangerous).
2012-05-02 00:58:54 +02:00
Milan Broz
ee8425b836 Version 1.4.2.
Add header and copyright for header files.
2012-04-02 22:03:05 +02:00
Milan Broz
7835b365a7 Fix FSF address in license text according to
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@671 36d66b0a-2a48-0410-832c-cd162a569da5
2011-11-02 22:35:21 +00:00
Milan Broz
d7960b9307 Simplify global error call.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@622 36d66b0a-2a48-0410-832c-cd162a569da5
2011-10-09 13:45:38 +00:00
Milan Broz
d2fbc963ca If device is not rotational, do not use Gutmann wipe method.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@615 36d66b0a-2a48-0410-832c-cd162a569da5
2011-10-08 16:17:08 +00:00
Milan Broz
7665f8e805 Improve check for invalid offset and size values. (thx to okozina)
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@588 36d66b0a-2a48-0410-832c-cd162a569da5
2011-08-01 12:27:34 +00:00
Milan Broz
f80b506b65 * Allow different data offset setting for detached header.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@576 36d66b0a-2a48-0410-832c-cd162a569da5
2011-07-20 17:39:38 +00:00
Milan Broz
913ef7c07e Rewrite dm query/create function backend.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@570 36d66b0a-2a48-0410-832c-cd162a569da5
2011-07-17 22:35:17 +00:00
Milan Broz
790ef04304 Fix error message.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@560 36d66b0a-2a48-0410-832c-cd162a569da5
2011-07-01 16:41:59 +00:00
Milan Broz
d44d07c9eb * Add --shared option for creating non-overlapping crypt segments.
* Add shared flag to libcryptsetup api.
* Fix plain crypt format parameters to include size option (API change).

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@559 36d66b0a-2a48-0410-832c-cd162a569da5
2011-07-01 16:38:58 +00:00
Milan Broz
2755f37266 Move devpath scan to separate file.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@529 36d66b0a-2a48-0410-832c-cd162a569da5
2011-05-24 11:19:00 +00:00
Milan Broz
1b58fab430 Remove old ifdef, all recent systems have this defined.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@513 36d66b0a-2a48-0410-832c-cd162a569da5
2011-04-18 10:52:28 +00:00
Milan Broz
231a2e932d Fix possible leaks in blockwise read/write code.
Fix lseek_write blockwise function (not used in that mode anyway).

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@511 36d66b0a-2a48-0410-832c-cd162a569da5
2011-04-18 10:52:15 +00:00
Milan Broz
5d2205a2f8 Fix verbose mode compiler warnings.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@510 36d66b0a-2a48-0410-832c-cd162a569da5
2011-04-18 10:52:02 +00:00
Milan Broz
ddcdd76cc2 Specify copyright holders in source files.
Add README notes.

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@461 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-14 14:17:38 +00:00
Milan Broz
d9ba34693f Add support for automatic loop device use (image infile etc).
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@443 36d66b0a-2a48-0410-832c-cd162a569da5
2011-03-11 19:04:37 +00:00
Milan Broz
0a905364fa Fix mapping removal if device disappeared but node still exists.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@420 36d66b0a-2a48-0410-832c-cd162a569da5
2011-01-29 15:55:27 +00:00
Milan Broz
66bea4b3be Add dm flags for query for features.
Move adjust device helper to utils.
Fix locking memory message.

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@416 36d66b0a-2a48-0410-832c-cd162a569da5
2011-01-25 18:48:41 +00:00
Milan Broz
a70b27762d Fix some warnings if compiled with clang.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@371 36d66b0a-2a48-0410-832c-cd162a569da5
2010-11-15 16:19:19 +00:00
Milan Broz
b7caa72acd * Disallow mapping of device which is already in use (mapped or mounted).
* Disallow luksFormat on device in use.

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@361 36d66b0a-2a48-0410-832c-cd162a569da5
2010-11-05 17:53:33 +00:00