+2013-04-26 Niels Möller <nisse@lysator.liu.se>
+
+ * Many files: Use size_t rather than unsigned for data sizes.
+ * x86_64/aes-encrypt-internal.asm: Accept 64-bit length.
+ * x86_64/aes-decrypt-internal.asm: Likewise.
+
2013-04-25 Niels Möller <nisse@lysator.liu.se>
* configure.ac: Changed version number, to 2.8.
void
_nettle_aes_decrypt(const struct aes_ctx *ctx,
const struct aes_table *T,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
FOR_BLOCKS(length, dst, src, AES_BLOCK_SIZE)
void
aes_decrypt(const struct aes_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
assert(!(length % AES_BLOCK_SIZE) );
void
_nettle_aes_encrypt(const struct aes_ctx *ctx,
const struct aes_table *T,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
FOR_BLOCKS(length, dst, src, AES_BLOCK_SIZE)
For PIC code, the details can be complex and system dependent. */
void
aes_encrypt(const struct aes_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
assert(!(length % AES_BLOCK_SIZE) );
void
_aes_encrypt(const struct aes_ctx *ctx,
const struct aes_table *T,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
_aes_decrypt(const struct aes_ctx *ctx,
const struct aes_table *T,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
/* Macros */
void
aes_set_decrypt_key(struct aes_ctx *ctx,
- unsigned keysize, const uint8_t *key)
+ size_t keysize, const uint8_t *key)
{
/* We first create subkeys for encryption,
* then modify the subkeys for decryption. */
void
aes_set_encrypt_key(struct aes_ctx *ctx,
- unsigned keysize, const uint8_t *key)
+ size_t keysize, const uint8_t *key)
{
static const uint8_t rcon[10] = {
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x1b,0x36,
void
aes_set_encrypt_key(struct aes_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
aes_set_decrypt_key(struct aes_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
aes_invert_key(struct aes_ctx *dst,
void
aes_encrypt(const struct aes_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
aes_decrypt(const struct aes_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#ifdef __cplusplus
void
arcfour_crypt(struct arcfour_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
register uint8_t i, j;
void
arcfour_set_key(struct arcfour_ctx *ctx,
- unsigned length, const uint8_t *key)
+ size_t length, const uint8_t *key)
{
unsigned i, j, k;
void
arcfour_set_key(struct arcfour_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
arcfour_crypt(struct arcfour_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#ifdef __cplusplus
void
arctwo_encrypt (struct arctwo_ctx *ctx,
- unsigned length, uint8_t *dst, const uint8_t *src)
+ size_t length, uint8_t *dst, const uint8_t *src)
{
FOR_BLOCKS (length, dst, src, ARCTWO_BLOCK_SIZE)
{
void
arctwo_decrypt (struct arctwo_ctx *ctx,
- unsigned length, uint8_t *dst, const uint8_t *src)
+ size_t length, uint8_t *dst, const uint8_t *src)
{
FOR_BLOCKS (length, dst, src, ARCTWO_BLOCK_SIZE)
{
void
arctwo_set_key_ekb (struct arctwo_ctx *ctx,
- unsigned length, const uint8_t *key, unsigned ekb)
+ size_t length, const uint8_t *key, unsigned ekb)
{
- unsigned i;
+ size_t i;
/* Expanded key, treated as octets */
uint8_t S[128];
uint8_t x;
}
void
-arctwo_set_key (struct arctwo_ctx *ctx, unsigned length, const uint8_t *key)
+arctwo_set_key (struct arctwo_ctx *ctx, size_t length, const uint8_t *key)
{
arctwo_set_key_ekb (ctx, length, key, 8 * length);
}
void
arctwo_set_key_gutmann (struct arctwo_ctx *ctx,
- unsigned length, const uint8_t *key)
+ size_t length, const uint8_t *key)
{
arctwo_set_key_ekb (ctx, length, key, 0);
}
as an explicit argument. 0 means maximum key bits. */
void
arctwo_set_key_ekb (struct arctwo_ctx *ctx,
- unsigned length, const uint8_t * key, unsigned ekb);
+ size_t length, const uint8_t * key, unsigned ekb);
/* Equvivalent to arctwo_set_key_ekb, with ekb = 8 * length */
void
-arctwo_set_key (struct arctwo_ctx *ctx, unsigned length, const uint8_t *key);
+arctwo_set_key (struct arctwo_ctx *ctx, size_t length, const uint8_t *key);
/* Equvivalent to arctwo_set_key_ekb, with ekb = 1024 */
void
arctwo_set_key_gutmann (struct arctwo_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
arctwo_encrypt (struct arctwo_ctx *ctx,
- unsigned length, uint8_t *dst, const uint8_t *src);
+ size_t length, uint8_t *dst, const uint8_t *src);
void
arctwo_decrypt (struct arctwo_ctx *ctx,
- unsigned length, uint8_t *dst, const uint8_t *src);
+ size_t length, uint8_t *dst, const uint8_t *src);
#ifdef __cplusplus
}
void
blowfish_encrypt (const struct blowfish_ctx *ctx,
- unsigned length, uint8_t * dst, const uint8_t * src)
+ size_t length, uint8_t * dst, const uint8_t * src)
{
FOR_BLOCKS (length, dst, src, BLOWFISH_BLOCK_SIZE)
{
void
blowfish_decrypt (const struct blowfish_ctx *ctx,
- unsigned length, uint8_t * dst, const uint8_t * src)
+ size_t length, uint8_t * dst, const uint8_t * src)
{
FOR_BLOCKS (length, dst, src, BLOWFISH_BLOCK_SIZE)
{
int
blowfish_set_key (struct blowfish_ctx *ctx,
- unsigned length, const uint8_t * key)
+ size_t length, const uint8_t * key)
{
int i, j;
uint32_t data, datal, datar;
* On error, returns 0 and sets ctx->status to BLOWFISH_WEAK_KEY. */
int
blowfish_set_key(struct blowfish_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
blowfish_encrypt(const struct blowfish_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
blowfish_decrypt(const struct blowfish_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#ifdef __cplusplus
void
_camellia_crypt(const struct camellia_ctx *ctx,
const struct camellia_table *T,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
FOR_BLOCKS(length, dst, src, CAMELLIA_BLOCK_SIZE)
For PIC code, the details can be complex and system dependent. */
void
camellia_crypt(const struct camellia_ctx *ctx,
- unsigned length, uint8_t *dst,
- const uint8_t *src)
+ size_t length, uint8_t *dst,
+ const uint8_t *src)
{
assert(!(length % CAMELLIA_BLOCK_SIZE) );
_camellia_crypt(ctx, &_camellia_table,
void
_camellia_crypt(const struct camellia_ctx *ctx,
const struct camellia_table *T,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
extern const struct camellia_table _camellia_table;
void
camellia_set_decrypt_key(struct camellia_ctx *ctx,
- unsigned length, const uint8_t *key)
+ size_t length, const uint8_t *key)
{
camellia_set_encrypt_key(ctx, length, key);
camellia_invert_key(ctx, ctx);
void
camellia_set_encrypt_key(struct camellia_ctx *ctx,
- unsigned length, const uint8_t *key)
+ size_t length, const uint8_t *key)
{
uint64_t k0, k1;
void
camellia_set_encrypt_key(struct camellia_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
camellia_set_decrypt_key(struct camellia_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
camellia_invert_key(struct camellia_ctx *dst,
void
camellia_crypt(const struct camellia_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#ifdef __cplusplus
}
void
cast128_encrypt(const struct cast128_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
FOR_BLOCKS(length, dst, src, CAST128_BLOCK_SIZE)
void
cast128_decrypt(const struct cast128_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
FOR_BLOCKS(length, dst, src, CAST128_BLOCK_SIZE)
void
cast128_set_key(struct cast128_ctx *ctx,
- unsigned keybytes, const uint8_t *rawkey)
+ size_t keybytes, const uint8_t *rawkey)
{
uint32_t t[4], z[4], x[4];
unsigned i;
void
cast128_set_key(struct cast128_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
cast128_encrypt(const struct cast128_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
cast128_decrypt(const struct cast128_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#ifdef __cplusplus
void
cbc_encrypt(void *ctx, nettle_crypt_func *f,
- unsigned block_size, uint8_t *iv,
- unsigned length, uint8_t *dst,
+ size_t block_size, uint8_t *iv,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
assert(!(length % block_size));
void
cbc_decrypt(void *ctx, nettle_crypt_func *f,
- unsigned block_size, uint8_t *iv,
- unsigned length, uint8_t *dst,
+ size_t block_size, uint8_t *iv,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
assert(!(length % block_size));
TMP_DECL(buffer, uint8_t, CBC_BUFFER_LIMIT);
TMP_DECL(initial_iv, uint8_t, NETTLE_MAX_CIPHER_BLOCK_SIZE);
- unsigned buffer_size;
+ size_t buffer_size;
if (length <= CBC_BUFFER_LIMIT)
buffer_size = length;
void
cbc_encrypt(void *ctx, nettle_crypt_func *f,
- unsigned block_size, uint8_t *iv,
- unsigned length, uint8_t *dst,
+ size_t block_size, uint8_t *iv,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
cbc_decrypt(void *ctx, nettle_crypt_func *f,
- unsigned block_size, uint8_t *iv,
- unsigned length, uint8_t *dst,
+ size_t block_size, uint8_t *iv,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#define CBC_CTX(type, size) \
void
ctr_crypt(void *ctx, nettle_crypt_func *f,
- unsigned block_size, uint8_t *ctr,
- unsigned length, uint8_t *dst,
+ size_t block_size, uint8_t *ctr,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
if (src != dst)
}
else
{
- unsigned left;
+ size_t left;
uint8_t *p;
for (p = dst, left = length;
if (length > block_size)
{
TMP_DECL(buffer, uint8_t, NBLOCKS * NETTLE_MAX_CIPHER_BLOCK_SIZE);
- unsigned chunk = NBLOCKS * block_size;
+ size_t chunk = NBLOCKS * block_size;
TMP_ALLOC(buffer, chunk);
void
ctr_crypt(void *ctx, nettle_crypt_func *f,
- unsigned block_size, uint8_t *ctr,
- unsigned length, uint8_t *dst,
+ size_t block_size, uint8_t *ctr,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#define CTR_CTX(type, size) \
#define PARITY(x) (parity_16[(x)&0xf] ^ parity_16[((x)>>4) & 0xf])
int
-des_check_parity(unsigned length, const uint8_t *key)
+des_check_parity(size_t length, const uint8_t *key)
{
- unsigned i;
+ size_t i;
for (i = 0; i<length; i++)
if (!PARITY(key[i]))
return 0;
}
void
-des_fix_parity(unsigned length, uint8_t *dst,
+des_fix_parity(size_t length, uint8_t *dst,
const uint8_t *src)
{
- unsigned i;
+ size_t i;
for (i = 0; i<length; i++)
dst[i] = src[i] ^ PARITY(src[i]) ^ 1;
}
void
des_encrypt(const struct des_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
assert(!(length % DES_BLOCK_SIZE));
void
des_decrypt(const struct des_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
assert(!(length % DES_BLOCK_SIZE));
void
des_encrypt(const struct des_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
des_decrypt(const struct des_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
int
-des_check_parity(unsigned length, const uint8_t *key);
+des_check_parity(size_t length, const uint8_t *key);
void
-des_fix_parity(unsigned length, uint8_t *dst,
+des_fix_parity(size_t length, uint8_t *dst,
const uint8_t *src);
#define DES3_KEY_SIZE 24
void
des3_encrypt(const struct des3_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
des3_decrypt(const struct des3_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#ifdef __cplusplus
void
des3_encrypt(const struct des3_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
des_encrypt(&ctx->des[0],
void
des3_decrypt(const struct des3_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src)
{
des_decrypt(&ctx->des[2],
/* AES */
static nettle_set_key_func openssl_aes_set_encrypt_key;
static void
-openssl_aes_set_encrypt_key(void *ctx, unsigned length, const uint8_t *key)
+openssl_aes_set_encrypt_key(void *ctx, size_t length, const uint8_t *key)
{
AES_set_encrypt_key(key, length * 8, ctx);
}
static nettle_set_key_func openssl_aes_set_decrypt_key;
static void
-openssl_aes_set_decrypt_key(void *ctx, unsigned length, const uint8_t *key)
+openssl_aes_set_decrypt_key(void *ctx, size_t length, const uint8_t *key)
{
AES_set_decrypt_key(key, length * 8, ctx);
}
static nettle_crypt_func openssl_aes_encrypt;
static void
-openssl_aes_encrypt(void *ctx, unsigned length,
+openssl_aes_encrypt(void *ctx, size_t length,
uint8_t *dst, const uint8_t *src)
{
assert (!(length % AES_BLOCK_SIZE));
static nettle_crypt_func openssl_aes_decrypt;
static void
-openssl_aes_decrypt(void *ctx, unsigned length,
+openssl_aes_decrypt(void *ctx, size_t length,
uint8_t *dst, const uint8_t *src)
{
assert (!(length % AES_BLOCK_SIZE));
/* Arcfour */
static nettle_set_key_func openssl_arcfour_set_key;
static void
-openssl_arcfour_set_key(void *ctx, unsigned length, const uint8_t *key)
+openssl_arcfour_set_key(void *ctx, size_t length, const uint8_t *key)
{
RC4_set_key(ctx, length, key);
}
static nettle_crypt_func openssl_arcfour_crypt;
static void
-openssl_arcfour_crypt(void *ctx, unsigned length,
+openssl_arcfour_crypt(void *ctx, size_t length,
uint8_t *dst, const uint8_t *src)
{
RC4(ctx, length, src, dst);
/* Blowfish */
static nettle_set_key_func openssl_bf_set_key;
static void
-openssl_bf_set_key(void *ctx, unsigned length, const uint8_t *key)
+openssl_bf_set_key(void *ctx, size_t length, const uint8_t *key)
{
BF_set_key(ctx, length, key);
}
static nettle_crypt_func openssl_bf_encrypt;
static void
-openssl_bf_encrypt(void *ctx, unsigned length,
+openssl_bf_encrypt(void *ctx, size_t length,
uint8_t *dst, const uint8_t *src)
{
assert (!(length % BF_BLOCK));
static nettle_crypt_func openssl_bf_decrypt;
static void
-openssl_bf_decrypt(void *ctx, unsigned length,
+openssl_bf_decrypt(void *ctx, size_t length,
uint8_t *dst, const uint8_t *src)
{
assert (!(length % BF_BLOCK));
/* DES */
static nettle_set_key_func openssl_des_set_key;
static void
-openssl_des_set_key(void *ctx, unsigned length, const uint8_t *key)
+openssl_des_set_key(void *ctx, size_t length, const uint8_t *key)
{
assert(length == 8);
/* Not sure what "unchecked" means. We want to ignore parity bits,
static nettle_crypt_func openssl_des_encrypt;
static void
-openssl_des_encrypt(void *ctx, unsigned length,
+openssl_des_encrypt(void *ctx, size_t length,
uint8_t *dst, const uint8_t *src)
{
assert (!(length % DES_BLOCK_SIZE));
static nettle_crypt_func openssl_des_decrypt;
static void
-openssl_des_decrypt(void *ctx, unsigned length,
+openssl_des_decrypt(void *ctx, size_t length,
uint8_t *dst, const uint8_t *src)
{
assert (!(length % DES_BLOCK_SIZE));
/* Cast128 */
static nettle_set_key_func openssl_cast_set_key;
static void
-openssl_cast_set_key(void *ctx, unsigned length, const uint8_t *key)
+openssl_cast_set_key(void *ctx, size_t length, const uint8_t *key)
{
CAST_set_key(ctx, length, key);
}
static nettle_crypt_func openssl_cast_encrypt;
static void
-openssl_cast_encrypt(void *ctx, unsigned length,
+openssl_cast_encrypt(void *ctx, size_t length,
uint8_t *dst, const uint8_t *src)
{
assert (!(length % CAST_BLOCK));
static nettle_crypt_func openssl_cast_decrypt;
static void
-openssl_cast_decrypt(void *ctx, unsigned length,
+openssl_cast_decrypt(void *ctx, size_t length,
uint8_t *dst, const uint8_t *src)
{
assert (!(length % CAST_BLOCK));
#include "gcm.h"
void
-gcm_aes_set_key(struct gcm_aes_ctx *ctx, unsigned length, const uint8_t *key)
+gcm_aes_set_key(struct gcm_aes_ctx *ctx, size_t length, const uint8_t *key)
{
GCM_SET_KEY(ctx, aes_set_encrypt_key, aes_encrypt, length, key);
}
void
gcm_aes_set_iv(struct gcm_aes_ctx *ctx,
- unsigned length, const uint8_t *iv)
+ size_t length, const uint8_t *iv)
{
GCM_SET_IV(ctx, length, iv);
}
void
gcm_aes_encrypt(struct gcm_aes_ctx *ctx,
- unsigned length, uint8_t *dst, const uint8_t *src)
+ size_t length, uint8_t *dst, const uint8_t *src)
{
GCM_ENCRYPT(ctx, aes_encrypt, length, dst, src);
}
void
gcm_aes_decrypt(struct gcm_aes_ctx *ctx,
- unsigned length, uint8_t *dst, const uint8_t *src)
+ size_t length, uint8_t *dst, const uint8_t *src)
{
GCM_DECRYPT(ctx, aes_encrypt, length, dst, src);
}
*/
void
gcm_set_iv(struct gcm_ctx *ctx, const struct gcm_key *key,
- unsigned length, const uint8_t *iv)
+ size_t length, const uint8_t *iv)
{
if (length == GCM_IV_SIZE)
{
static void
gcm_crypt(struct gcm_ctx *ctx, void *cipher, nettle_crypt_func *f,
- unsigned length, uint8_t *dst, const uint8_t *src)
+ size_t length, uint8_t *dst, const uint8_t *src)
{
uint8_t buffer[GCM_BLOCK_SIZE];
void
gcm_encrypt (struct gcm_ctx *ctx, const struct gcm_key *key,
void *cipher, nettle_crypt_func *f,
- unsigned length, uint8_t *dst, const uint8_t *src)
+ size_t length, uint8_t *dst, const uint8_t *src)
{
assert(ctx->data_size % GCM_BLOCK_SIZE == 0);
void
gcm_decrypt(struct gcm_ctx *ctx, const struct gcm_key *key,
void *cipher, nettle_crypt_func *f,
- unsigned length, uint8_t *dst, const uint8_t *src)
+ size_t length, uint8_t *dst, const uint8_t *src)
{
assert(ctx->data_size % GCM_BLOCK_SIZE == 0);
void
gcm_set_iv(struct gcm_ctx *ctx, const struct gcm_key *key,
- unsigned length, const uint8_t *iv);
+ size_t length, const uint8_t *iv);
void
gcm_update(struct gcm_ctx *ctx, const struct gcm_key *key,
void
gcm_encrypt(struct gcm_ctx *ctx, const struct gcm_key *key,
void *cipher, nettle_crypt_func *f,
- unsigned length, uint8_t *dst, const uint8_t *src);
+ size_t length, uint8_t *dst, const uint8_t *src);
void
gcm_decrypt(struct gcm_ctx *ctx, const struct gcm_key *key,
void *cipher, nettle_crypt_func *f,
- unsigned length, uint8_t *dst, const uint8_t *src);
+ size_t length, uint8_t *dst, const uint8_t *src);
void
gcm_digest(struct gcm_ctx *ctx, const struct gcm_key *key,
void
gcm_aes_set_key(struct gcm_aes_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
gcm_aes_set_iv(struct gcm_aes_ctx *ctx,
- unsigned length, const uint8_t *iv);
+ size_t length, const uint8_t *iv);
void
gcm_aes_update(struct gcm_aes_ctx *ctx,
void
gcm_aes_encrypt(struct gcm_aes_ctx *ctx,
- unsigned length, uint8_t *dst, const uint8_t *src);
+ size_t length, uint8_t *dst, const uint8_t *src);
void
gcm_aes_decrypt(struct gcm_aes_ctx *ctx,
- unsigned length, uint8_t *dst, const uint8_t *src);
+ size_t length, uint8_t *dst, const uint8_t *src);
void
gcm_aes_digest(struct gcm_aes_ctx *ctx, unsigned length, uint8_t *digest);
/* DES uses a different signature for the key set function. We ignore
the return value indicating weak keys. */
static void
-des_set_key_hack(void *ctx, unsigned length, const uint8_t *key)
+des_set_key_hack(void *ctx, size_t length, const uint8_t *key)
{
assert(length == DES_KEY_SIZE);
des_set_key(ctx, key);
}
static void
-des3_set_key_hack(void *ctx, unsigned length, const uint8_t *key)
+des3_set_key_hack(void *ctx, size_t length, const uint8_t *key)
{
assert(length == DES3_KEY_SIZE);
des3_set_key(ctx, key);
/* Sets a fix zero iv. For benchmarking only. */
static void
-salsa20_set_key_hack(void *ctx, unsigned length, const uint8_t *key)
+salsa20_set_key_hack(void *ctx, size_t length, const uint8_t *key)
{
static const uint8_t iv[SALSA20_IV_SIZE];
salsa20_set_key (ctx, length, key);
{
const char *name;
- unsigned context_size;
+ size_t context_size;
/* Zero for stream ciphers */
- unsigned block_size;
+ size_t block_size;
/* Suggested key size; other sizes are sometimes possible. */
- unsigned key_size;
+ size_t key_size;
nettle_set_key_func *set_encrypt_key;
nettle_set_key_func *set_decrypt_key;
/* Ciphers */
typedef void nettle_set_key_func(void *ctx,
- unsigned length,
+ size_t length,
const uint8_t *key);
/* Uses a void * for cipher contexts.
internal state changes during the encryption. */
typedef void nettle_crypt_func(void *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
/* Hash algorithms */
void
salsa20_crypt(struct salsa20_ctx *ctx,
- unsigned length,
+ size_t length,
uint8_t *c,
const uint8_t *m)
{
void
salsa20_set_key(struct salsa20_ctx *ctx,
- unsigned length, const uint8_t *key)
+ size_t length, const uint8_t *key)
{
static const uint32_t sigma[4] = {
/* "expand 32-byte k" */
void
salsa20_set_key(struct salsa20_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
salsa20_set_iv(struct salsa20_ctx *ctx, const uint8_t *iv);
void
salsa20_crypt(struct salsa20_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
salsa20r12_crypt(struct salsa20_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
void
salsa20r12_crypt(struct salsa20_ctx *ctx,
- unsigned length,
- uint8_t *c,
- const uint8_t *m)
+ size_t length,
+ uint8_t *c,
+ const uint8_t *m)
{
uint32_t x[_SALSA20_INPUT_LENGTH];
void
serpent_decrypt (const struct serpent_ctx *ctx,
- unsigned length, uint8_t * dst, const uint8_t * src)
+ size_t length, uint8_t * dst, const uint8_t * src)
{
assert( !(length % SERPENT_BLOCK_SIZE));
void
serpent_encrypt (const struct serpent_ctx *ctx,
- unsigned length, uint8_t * dst, const uint8_t * src)
+ size_t length, uint8_t * dst, const uint8_t * src)
{
assert( !(length % SERPENT_BLOCK_SIZE));
/* Initialize CONTEXT with the key KEY of KEY_LENGTH bits. */
void
serpent_set_key (struct serpent_ctx *ctx,
- unsigned length, const uint8_t * key)
+ size_t length, const uint8_t * key)
{
uint32_t w[8];
uint32_t (*keys)[4];
void
serpent_set_key(struct serpent_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
serpent_encrypt(const struct serpent_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
serpent_decrypt(const struct serpent_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#ifdef __cplusplus
void
twofish_set_key(struct twofish_ctx *context,
- unsigned keysize, const uint8_t *key)
+ size_t keysize, const uint8_t *key)
{
uint8_t key_copy[32];
uint32_t m[8], s[4], t;
void
twofish_encrypt(const struct twofish_ctx *context,
- unsigned length,
+ size_t length,
uint8_t *ciphertext,
const uint8_t *plaintext)
{
void
twofish_decrypt(const struct twofish_ctx *context,
- unsigned length,
+ size_t length,
uint8_t *plaintext,
const uint8_t *ciphertext)
void
twofish_set_key(struct twofish_ctx *ctx,
- unsigned length, const uint8_t *key);
+ size_t length, const uint8_t *key);
void
twofish_encrypt(const struct twofish_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
void
twofish_decrypt(const struct twofish_ctx *ctx,
- unsigned length, uint8_t *dst,
+ size_t length, uint8_t *dst,
const uint8_t *src);
#ifdef __cplusplus
define(<CTX>, <%rdi>)
define(<TABLE>, <%rsi>)
-define(<PARAM_LENGTH>,<%edx>) C Length is only 32 bits
+define(<PARAM_LENGTH>,<%rdx>)
define(<PARAM_DST>, <%rcx>)
define(<SRC>, <%r8>)
define(<DST>, <%r9>)
define(<KEY>,<%r14>)
define(<COUNT>, <%r15d>)
-define(<BLOCK_COUNT>, <%r13d>)
+define(<BLOCK_COUNT>, <%r13>)
C Must correspond to an old-style register, for movzb from %ah--%dh to
C work.
C _aes_decrypt(struct aes_context *ctx,
C const struct aes_table *T,
- C unsigned length, uint8_t *dst,
+ C size_t length, uint8_t *dst,
C uint8_t *src)
.text
ALIGN(16)
push %r15
mov PARAM_DST, DST
- movl PARAM_LENGTH, BLOCK_COUNT
- shrl $4, BLOCK_COUNT
+ mov PARAM_LENGTH, BLOCK_COUNT
+ shr $4, BLOCK_COUNT
.Lblock_loop:
mov CTX,KEY
AES_STORE(TA,TB,TC,SD, KEY, DST)
add $16, DST
- decl BLOCK_COUNT
+ dec BLOCK_COUNT
jnz .Lblock_loop
define(<CTX>, <%rdi>)
define(<TABLE>, <%rsi>)
-define(<PARAM_LENGTH>,<%edx>) C Length is only 32 bits
+define(<PARAM_LENGTH>,<%rdx>)
define(<PARAM_DST>, <%rcx>)
define(<SRC>, <%r8>)
define(<DST>, <%r9>)
define(<KEY>,<%r14>)
define(<COUNT>, <%r15d>)
-define(<BLOCK_COUNT>, <%r13d>)
+define(<BLOCK_COUNT>, <%r13>)
C Must correspond to an old-style register, for movzb from %ah--%dh to
C work.
C _aes_encrypt(struct aes_context *ctx,
C const struct aes_table *T,
- C unsigned length, uint8_t *dst,
+ C size_t length, uint8_t *dst,
C uint8_t *src)
.text
ALIGN(16)
push %r15
mov PARAM_DST, DST
- movl PARAM_LENGTH, BLOCK_COUNT
- shrl $4, BLOCK_COUNT
+ mov PARAM_LENGTH, BLOCK_COUNT
+ shr $4, BLOCK_COUNT
.Lblock_loop:
mov CTX,KEY
AES_STORE(TA,TB,TC,SD, KEY, DST)
add $16, DST
- decl BLOCK_COUNT
+ dec BLOCK_COUNT
jnz .Lblock_loop