Commit 3eb603d0 authored by Niels Möller's avatar Niels Möller
Browse files

Use size_t rather than unsigned for all cipher-related functions.

parent 2b49c179
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.
......
......@@ -35,7 +35,7 @@
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)
......
......@@ -338,7 +338,7 @@ _aes_decrypt_table =
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) );
......
......@@ -35,7 +35,7 @@
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)
......
......@@ -36,7 +36,7 @@
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) );
......
......@@ -53,13 +53,13 @@ struct aes_table
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 */
......
......@@ -161,7 +161,7 @@ aes_invert_key(struct aes_ctx *dst,
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. */
......
......@@ -36,7 +36,7 @@
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,
......
......@@ -59,11 +59,11 @@ struct aes_ctx
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,
......@@ -71,11 +71,11 @@ 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
......
......@@ -33,7 +33,7 @@
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;
......
......@@ -35,7 +35,7 @@
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;
......
......@@ -51,11 +51,11 @@ struct arcfour_ctx
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
......
......@@ -85,7 +85,7 @@ static const uint8_t arctwo_sbox[] = {
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)
{
......@@ -130,7 +130,7 @@ arctwo_encrypt (struct arctwo_ctx *ctx,
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)
{
......@@ -176,9 +176,9 @@ arctwo_decrypt (struct arctwo_ctx *ctx,
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;
......@@ -217,14 +217,14 @@ arctwo_set_key_ekb (struct arctwo_ctx *ctx,
}
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);
}
......@@ -57,23 +57,23 @@ struct arctwo_ctx
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
}
......
......@@ -321,7 +321,7 @@ decrypt (const struct blowfish_ctx *ctx, uint32_t * ret_xl, uint32_t * ret_xr)
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)
{
......@@ -343,7 +343,7 @@ blowfish_encrypt (const struct blowfish_ctx *ctx,
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)
{
......@@ -365,7 +365,7 @@ blowfish_decrypt (const struct blowfish_ctx *ctx,
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;
......
......@@ -58,15 +58,15 @@ struct blowfish_ctx
* 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
......
......@@ -125,7 +125,7 @@
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)
......
......@@ -36,7 +36,7 @@
For PIC code, the details can be complex and system dependent. */
void
camellia_crypt(const struct camellia_ctx *ctx,
unsigned length, uint8_t *dst,
size_t length, uint8_t *dst,
const uint8_t *src)
{
assert(!(length % CAMELLIA_BLOCK_SIZE) );
......
......@@ -63,7 +63,7 @@ struct 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;
......
......@@ -54,7 +54,7 @@ camellia_invert_key(struct camellia_ctx *dst,
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment