Commit c8f4cc35 authored by Niels Möller's avatar Niels Möller

* aes.h (aes_encrypt, aes_decrypt): Declare ctx argument as const.

Also updated implementation.
* blowfish.h (blowfish_encrypt, blowfish_decrypt): Likewise.
* cast128.h (cast128_encrypt, cast128_decrypt): Likewise.
* serpent.h (serpent_encrypt, serpent_decrypt): Likewise.
* twofish.h (twofish_encrypt, twofish_decrypt): Likewise.

Rev: nettle/ChangeLog:1.91
Rev: nettle/aes-decrypt.c:1.2
Rev: nettle/aes-encrypt.c:1.2
Rev: nettle/aes.h:1.2
Rev: nettle/blowfish.c:1.3
Rev: nettle/blowfish.h:1.3
Rev: nettle/cast128.c:1.2
Rev: nettle/cast128.h:1.2
Rev: nettle/serpent.c:1.2
Rev: nettle/serpent.h:1.2
Rev: nettle/twofish.c:1.2
Rev: nettle/twofish.h:1.2
parent 99db0536
2010-07-07 Niels Mller <nisse@lysator.liu.se> 2010-07-07 Niels Mller <nisse@lysator.liu.se>
* aes.h (aes_encrypt, aes_decrypt): Declare ctx argument as const.
Also updated implementation.
* blowfish.h (blowfish_encrypt, blowfish_decrypt): Likewise.
* cast128.h (cast128_encrypt, cast128_decrypt): Likewise.
* serpent.h (serpent_encrypt, serpent_decrypt): Likewise.
* twofish.h (twofish_encrypt, twofish_decrypt): Likewise.
* testsuite/Makefile.in (TS_NETTLE_SOURCES): Added * testsuite/Makefile.in (TS_NETTLE_SOURCES): Added
camellia-test.c. camellia-test.c.
......
...@@ -337,7 +337,7 @@ _aes_decrypt_table = ...@@ -337,7 +337,7 @@ _aes_decrypt_table =
}; };
void void
aes_decrypt(struct aes_ctx *ctx, aes_decrypt(const struct aes_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src) const uint8_t *src)
{ {
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
implementations of _nettle_aes_encrypt to get the table pointer. implementations of _nettle_aes_encrypt to get the table pointer.
For PIC code, the details can be complex and system dependent. */ For PIC code, the details can be complex and system dependent. */
void void
aes_encrypt(struct aes_ctx *ctx, aes_encrypt(const struct aes_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src) const uint8_t *src)
{ {
......
...@@ -61,11 +61,11 @@ aes_set_decrypt_key(struct aes_ctx *ctx, ...@@ -61,11 +61,11 @@ aes_set_decrypt_key(struct aes_ctx *ctx,
unsigned length, const uint8_t *key); unsigned length, const uint8_t *key);
void void
aes_encrypt(struct aes_ctx *ctx, aes_encrypt(const struct aes_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
void void
aes_decrypt(struct aes_ctx *ctx, aes_decrypt(const struct aes_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
......
...@@ -245,7 +245,7 @@ initial_ctx = ...@@ -245,7 +245,7 @@ initial_ctx =
#define R(c, l, r, i) do { l ^= c->p[i]; r ^= F(c, l); } while(0) #define R(c, l, r, i) do { l ^= c->p[i]; r ^= F(c, l); } while(0)
static void static void
encrypt(struct blowfish_ctx *bc, uint32_t *ret_xl, uint32_t *ret_xr) encrypt(const struct blowfish_ctx *bc, uint32_t *ret_xl, uint32_t *ret_xr)
{ {
uint32_t xl, xr; uint32_t xl, xr;
...@@ -276,7 +276,7 @@ encrypt(struct blowfish_ctx *bc, uint32_t *ret_xl, uint32_t *ret_xr) ...@@ -276,7 +276,7 @@ encrypt(struct blowfish_ctx *bc, uint32_t *ret_xl, uint32_t *ret_xr)
} }
static void static void
decrypt(struct blowfish_ctx *bc, uint32_t *ret_xl, uint32_t *ret_xr ) decrypt(const struct blowfish_ctx *bc, uint32_t *ret_xl, uint32_t *ret_xr )
{ {
uint32_t xl, xr; uint32_t xl, xr;
...@@ -311,7 +311,7 @@ decrypt(struct blowfish_ctx *bc, uint32_t *ret_xl, uint32_t *ret_xr ) ...@@ -311,7 +311,7 @@ decrypt(struct blowfish_ctx *bc, uint32_t *ret_xl, uint32_t *ret_xr )
#undef R #undef R
void void
blowfish_encrypt(struct blowfish_ctx *bc, unsigned length, blowfish_encrypt(const struct blowfish_ctx *bc, unsigned length,
uint8_t *outbuf, const uint8_t *inbuf) uint8_t *outbuf, const uint8_t *inbuf)
{ {
uint32_t d1, d2; uint32_t d1, d2;
...@@ -330,7 +330,7 @@ blowfish_encrypt(struct blowfish_ctx *bc, unsigned length, ...@@ -330,7 +330,7 @@ blowfish_encrypt(struct blowfish_ctx *bc, unsigned length,
void void
blowfish_decrypt(struct blowfish_ctx *bc, unsigned length, blowfish_decrypt(const struct blowfish_ctx *bc, unsigned length,
uint8_t *outbuf, const uint8_t *inbuf ) uint8_t *outbuf, const uint8_t *inbuf )
{ {
uint32_t d1, d2; uint32_t d1, d2;
......
...@@ -61,11 +61,11 @@ blowfish_set_key(struct blowfish_ctx *ctx, ...@@ -61,11 +61,11 @@ blowfish_set_key(struct blowfish_ctx *ctx,
unsigned length, const uint8_t *key); unsigned length, const uint8_t *key);
void void
blowfish_encrypt(struct blowfish_ctx *ctx, blowfish_encrypt(const struct blowfish_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
void void
blowfish_decrypt(struct blowfish_ctx *ctx, blowfish_decrypt(const struct blowfish_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
/***** Encryption Function *****/ /***** Encryption Function *****/
void void
cast128_encrypt(struct cast128_ctx *ctx, cast128_encrypt(const struct cast128_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src) const uint8_t *src)
{ {
...@@ -115,7 +115,7 @@ cast128_encrypt(struct cast128_ctx *ctx, ...@@ -115,7 +115,7 @@ cast128_encrypt(struct cast128_ctx *ctx,
/***** Decryption Function *****/ /***** Decryption Function *****/
void void
cast128_decrypt(struct cast128_ctx *ctx, cast128_decrypt(const struct cast128_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src) const uint8_t *src)
{ {
......
...@@ -62,11 +62,11 @@ cast128_set_key(struct cast128_ctx *ctx, ...@@ -62,11 +62,11 @@ cast128_set_key(struct cast128_ctx *ctx,
unsigned length, const uint8_t *key); unsigned length, const uint8_t *key);
void void
cast128_encrypt(struct cast128_ctx *ctx, cast128_encrypt(const struct cast128_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
void void
cast128_decrypt(struct cast128_ctx *ctx, cast128_decrypt(const struct cast128_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
......
...@@ -124,7 +124,7 @@ serpent_set_key(struct serpent_ctx *ctx, ...@@ -124,7 +124,7 @@ serpent_set_key(struct serpent_ctx *ctx,
} }
void void
serpent_encrypt(struct serpent_ctx *ctx, serpent_encrypt(const struct serpent_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *plain) const uint8_t *plain)
{ {
...@@ -249,7 +249,7 @@ serpent_encrypt(struct serpent_ctx *ctx, ...@@ -249,7 +249,7 @@ serpent_encrypt(struct serpent_ctx *ctx,
} }
void void
serpent_decrypt(struct serpent_ctx *ctx, serpent_decrypt(const struct serpent_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *cipher) const uint8_t *cipher)
{ {
......
...@@ -66,11 +66,11 @@ serpent_set_key(struct serpent_ctx *ctx, ...@@ -66,11 +66,11 @@ serpent_set_key(struct serpent_ctx *ctx,
unsigned length, const uint8_t *key); unsigned length, const uint8_t *key);
void void
serpent_encrypt(struct serpent_ctx *ctx, serpent_encrypt(const struct serpent_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
void void
serpent_decrypt(struct serpent_ctx *ctx, serpent_decrypt(const struct serpent_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
......
...@@ -333,13 +333,13 @@ twofish_set_key(struct twofish_ctx *context, ...@@ -333,13 +333,13 @@ twofish_set_key(struct twofish_ctx *context,
*/ */
void void
twofish_encrypt(struct twofish_ctx *context, twofish_encrypt(const struct twofish_ctx *context,
unsigned length, unsigned length,
uint8_t *ciphertext, uint8_t *ciphertext,
const uint8_t *plaintext) const uint8_t *plaintext)
{ {
uint32_t * keys = context->keys; const uint32_t * keys = context->keys;
uint32_t (*s_box)[256] = context->s_box; const uint32_t (*s_box)[256] = context->s_box;
assert( !(length % TWOFISH_BLOCK_SIZE) ); assert( !(length % TWOFISH_BLOCK_SIZE) );
for ( ; length; length -= TWOFISH_BLOCK_SIZE) for ( ; length; length -= TWOFISH_BLOCK_SIZE)
...@@ -403,14 +403,14 @@ twofish_encrypt(struct twofish_ctx *context, ...@@ -403,14 +403,14 @@ twofish_encrypt(struct twofish_ctx *context,
*/ */
void void
twofish_decrypt(struct twofish_ctx *context, twofish_decrypt(const struct twofish_ctx *context,
unsigned length, unsigned length,
uint8_t *plaintext, uint8_t *plaintext,
const uint8_t *ciphertext) const uint8_t *ciphertext)
{ {
uint32_t *keys = context->keys; const uint32_t *keys = context->keys;
uint32_t (*s_box)[256] = context->s_box; const uint32_t (*s_box)[256] = context->s_box;
assert( !(length % TWOFISH_BLOCK_SIZE) ); assert( !(length % TWOFISH_BLOCK_SIZE) );
for ( ; length; length -= TWOFISH_BLOCK_SIZE) for ( ; length; length -= TWOFISH_BLOCK_SIZE)
......
...@@ -63,11 +63,11 @@ twofish_set_key(struct twofish_ctx *ctx, ...@@ -63,11 +63,11 @@ twofish_set_key(struct twofish_ctx *ctx,
unsigned length, const uint8_t *key); unsigned length, const uint8_t *key);
void void
twofish_encrypt(struct twofish_ctx *ctx, twofish_encrypt(const struct twofish_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
void void
twofish_decrypt(struct twofish_ctx *ctx, twofish_decrypt(const struct twofish_ctx *ctx,
unsigned length, uint8_t *dst, unsigned length, uint8_t *dst,
const uint8_t *src); const uint8_t *src);
......
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