Mercurial > dropbear
comparison libtomcrypt/src/modes/xts/xts_init.c @ 1435:f849a5ca2efc
update to libtomcrypt 1.17 (with Dropbear changes)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 24 Jun 2017 17:50:50 +0800 |
parents | |
children | 6dba84798cd5 |
comparison
equal
deleted
inserted
replaced
1434:27b9ddb06b09 | 1435:f849a5ca2efc |
---|---|
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis | |
2 * | |
3 * LibTomCrypt is a library that provides various cryptographic | |
4 * algorithms in a highly modular and flexible manner. | |
5 * | |
6 * The library is free for all purposes without any express | |
7 * guarantee it works. | |
8 * | |
9 * Tom St Denis, [email protected], http://libtom.org | |
10 */ | |
11 #include "tomcrypt.h" | |
12 | |
13 /** | |
14 Source donated by Elliptic Semiconductor Inc (www.ellipticsemi.com) to the LibTom Projects | |
15 */ | |
16 | |
17 #ifdef LTC_XTS_MODE | |
18 | |
19 | |
20 /** Start XTS mode | |
21 @param cipher The index of the cipher to use | |
22 @param key1 The encrypt key | |
23 @param key2 The tweak encrypt key | |
24 @param keylen The length of the keys (each) in octets | |
25 @param num_rounds The number of rounds for the cipher (0 == default) | |
26 @param xts [out] XTS structure | |
27 Returns CRYPT_OK upon success. | |
28 */ | |
29 int xts_start( int cipher, | |
30 const unsigned char *key1, | |
31 const unsigned char *key2, | |
32 unsigned long keylen, | |
33 int num_rounds, | |
34 symmetric_xts *xts) | |
35 { | |
36 int err; | |
37 | |
38 /* check inputs */ | |
39 LTC_ARGCHK(key1 != NULL); | |
40 LTC_ARGCHK(key2 != NULL); | |
41 LTC_ARGCHK(xts != NULL); | |
42 | |
43 /* check if valid */ | |
44 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) { | |
45 return err; | |
46 } | |
47 | |
48 if (cipher_descriptor[cipher].block_length != 16) { | |
49 return CRYPT_INVALID_ARG; | |
50 } | |
51 | |
52 /* schedule the two ciphers */ | |
53 if ((err = cipher_descriptor[cipher].setup(key1, keylen, num_rounds, &xts->key1)) != CRYPT_OK) { | |
54 return err; | |
55 } | |
56 if ((err = cipher_descriptor[cipher].setup(key2, keylen, num_rounds, &xts->key2)) != CRYPT_OK) { | |
57 return err; | |
58 } | |
59 xts->cipher = cipher; | |
60 | |
61 return err; | |
62 } | |
63 | |
64 #endif | |
65 | |
66 /* $Source$ */ | |
67 /* $Revision$ */ | |
68 /* $Date$ */ | |
69 |