~xnox/debian/sid/cryptsetup/ubuntu

« back to all changes in this revision

Viewing changes to lib/crypto_backend/crypto_gcrypt.c

  • 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:
2
2
 * GCRYPT crypto backend implementation
3
3
 *
4
4
 * Copyright (C) 2010-2012, Red Hat, Inc. All rights reserved.
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the GNU General Public License
8
 
 * version 2 as published by the Free Software Foundation.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
 
5
 * Copyright (C) 2010-2012, Milan Broz
 
6
 *
 
7
 * This file is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2.1 of the License, or (at your option) any later version.
 
11
 *
 
12
 * This file is distributed in the hope that it will be useful,
11
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Lesser General Public License for more details.
14
16
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this file; if not, write to the Free Software
17
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
20
 */
19
21
 
251
253
        }
252
254
        return 0;
253
255
}
 
256
 
 
257
/* PBKDF */
 
258
int crypt_pbkdf(const char *kdf, const char *hash,
 
259
                const char *password, size_t password_length,
 
260
                const char *salt, size_t salt_length,
 
261
                char *key, size_t key_length,
 
262
                unsigned int iterations)
 
263
{
 
264
#if USE_INTERNAL_PBKDF2
 
265
        if (!kdf || strncmp(kdf, "pbkdf2", 6))
 
266
                return -EINVAL;
 
267
 
 
268
        return pkcs5_pbkdf2(hash, password, password_length, salt, salt_length,
 
269
                            iterations, key_length, key);
 
270
 
 
271
#else /* USE_INTERNAL_PBKDF2 */
 
272
        int hash_id = gcry_md_map_name(hash);
 
273
        int kdf_id;
 
274
 
 
275
        if (!hash_id)
 
276
                return -EINVAL;
 
277
 
 
278
        if (kdf && !strncmp(kdf, "pbkdf2", 6))
 
279
                kdf_id = GCRY_KDF_PBKDF2;
 
280
        else
 
281
                return -EINVAL;
 
282
 
 
283
        if (gcry_kdf_derive(password, password_length, kdf_id, hash_id,
 
284
            salt, salt_length, iterations, key_length, key))
 
285
                return -EINVAL;
 
286
 
 
287
        return 0;
 
288
#endif /* USE_INTERNAL_PBKDF2 */
 
289
}