Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nettle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Wim Lewis
nettle
Commits
58785537
Commit
58785537
authored
Jan 29, 2014
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dropped length argument from nettle_set_key_func.
parent
f508b1fe
Changes
38
Show whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
763 additions
and
466 deletions
+763
-466
ChangeLog
ChangeLog
+89
-0
aes128-meta.c
aes128-meta.c
+3
-20
aes192-meta.c
aes192-meta.c
+3
-20
aes256-meta.c
aes256-meta.c
+3
-20
arcfour-meta.c
arcfour-meta.c
+3
-3
arcfour.c
arcfour.c
+6
-1
arcfour.h
arcfour.h
+6
-1
arctwo-meta.c
arctwo-meta.c
+23
-15
arctwo.c
arctwo.c
+24
-1
arctwo.h
arctwo.h
+15
-2
camellia128-meta.c
camellia128-meta.c
+3
-17
camellia192-meta.c
camellia192-meta.c
+3
-17
camellia256-meta.c
camellia256-meta.c
+3
-17
cast128.c
cast128.c
+11
-5
cast128.h
cast128.h
+10
-5
eax.h
eax.h
+2
-2
examples/nettle-benchmark.c
examples/nettle-benchmark.c
+7
-7
examples/nettle-openssl.c
examples/nettle-openssl.c
+47
-23
gcm-aes128.c
gcm-aes128.c
+1
-2
gcm-aes192.c
gcm-aes192.c
+1
-2
gcm-aes256.c
gcm-aes256.c
+1
-2
gcm.h
gcm.h
+3
-6
nettle-internal.c
nettle-internal.c
+17
-46
nettle-internal.h
nettle-internal.h
+5
-6
nettle-types.h
nettle-types.h
+2
-4
serpent-meta.c
serpent-meta.c
+15
-6
serpent-set-key.c
serpent-set-key.c
+20
-2
serpent.h
serpent.h
+13
-0
testsuite/aes-test.c
testsuite/aes-test.c
+55
-0
testsuite/arcfour-test.c
testsuite/arcfour-test.c
+142
-78
testsuite/blowfish-test.c
testsuite/blowfish-test.c
+46
-78
testsuite/cast128-test.c
testsuite/cast128-test.c
+49
-8
testsuite/gcm-test.c
testsuite/gcm-test.c
+5
-6
testsuite/serpent-test.c
testsuite/serpent-test.c
+70
-30
testsuite/testutils.c
testsuite/testutils.c
+12
-6
twofish-meta.c
twofish-meta.c
+15
-6
twofish.c
twofish.c
+17
-1
twofish.h
twofish.h
+13
-1
No files found.
ChangeLog
View file @
58785537
2014-01-29 Niels Möller <nisse@lysator.liu.se>
* nettle-types.h (typedef nettle_set_key_func): Deleted length
argument.
* arctwo.c (arctwo40_set_key, arctwo64_set_key)
(arctwo128_set_key, arctwo128_set_key_gutmann): New functions.
* arctwo.h: Declare them.
* arctwo-meta.c (ARCTWO): New macro.
(nettle_arctwo40, nettle_arctwo64, nettle_arctwo128)
(nettle_arctwo_gutmann128): Use new _set_key functions.
* arcfour.h (ARCFOUR128_KEY_SIZE): New constant.
* arcfour.c (arcfour128_set_key): New function.
* arcfour-meta.c (nettle_arcfour128): Use arcfour128_set_key and
ARCFOUR128_KEY_SIZE.
* cast128.c (cast5_set_key): Renamed, was cast128_set_key.
(cast128_set_key): New definition, with fixed key size.
* cast128.h (CAST128_MIN_KEY_SIZE, CAST128_MAX_KEY_SIZE): Renamed
constants, to...
(CAST5_MIN_KEY_SIZE, CAST5_MAX_KEY_SIZE): ... new names.
* eax.h (EAX_SET_KEY): Deleted length argument.
* aes128-meta.c: Deleted _set_key wrappers.
* aes192-meta.c: Likewise.
* aes256-meta.c: Likewise.
* camellia128-meta.c: Likewise.
* camellia192-meta.c: Likewise.
* camellia256-meta.c: Likewise.
* gcm-aes128.c (gcm_aes128_set_key): Deleted length argument.
* gcm-aes192.c (gcm_aes192_set_key): Likewise.
* gcm-aes256.c (gcm_aes256_set_key): Likewise.
* gcm.h: Updated prototypes.
* serpent-set-key.c (serpent128_set_key, serpent192_set_key)
(serpent256_set_key): New functions.
* serpent.h: Declare new functions.
(SERPENT128_KEY_SIZE, SERPENT192_KEY_SIZE)
(SERPENT256_KEY_SIZE): New constants.
* serpent-meta.c (SERPENT): New macro.
(nettle_serpent128, nettle_serpent192, nettle_serpent256): Use new
_set_key functions.
* twofish-set-key.c (twofish128_set_key, twofish192_set_key)
(twofish256_set_key): New functions.
* twofish.h: Declare new functions.
(TWOFISH128_KEY_SIZE, TWOFISH192_KEY_SIZE)
(TWOFISH256_KEY_SIZE): New constants.
* twofish-meta.c (TWOFISH): New macro.
(nettle_twofish128, nettle_twofish192, nettle_twofish256): Use new
_set_key functions.
* nettle-internal.h (struct nettle_aead): Use
nettle_hash_update_func for the set_iv function pointer.
* nettle-internal.c (des_set_key_hack, des3_set_key_hack): Deleted
wrapper functions.
(chacha_set_key_hack): Deleted length argument. Use
chacha256_set_key.
(salsa20_set_key_hack): Deleted length argument. Use
salsa20_256_set_key.
(nettle_unified_aes128, nettle_unified_aes192)
(nettle_unified_aes256): Deleted, moved to test program.
(eax_aes128_set_key): Deleted length argument. Use EAX_SET_KEY.
* examples/nettle-benchmark.c: Updated for _set_key changes.
* examples/nettle-openssl.c: Likewise.
* testsuite/testutils.c: Likewise.
* testsuite/gcm-test.c: Likewise.
* testsuite/aes-test.c (UNIFIED_AES): New macro. Moved glue for
testing the old aes interface (struct aes_ctx) here.
* testsuite/arcfour-test.c (test_arcfour): New function, for key
sizes != 128 bits.
(test_main): Use it.
* testsuite/blowfish-test.c (test_blowfish): New function.
(test_main): Use it. Also deleted old #if:ed out code.
* testsuite/cast128-test.c (test_cast5): New function.
(test_main): Use it, for 40-bit and 80-bit tests.
* testsuite/serpent-test.c (test_serpent): New function.
(test_main): Use it.
2014-01-27 Niels Möller <nisse@lysator.liu.se>
* eax.h (struct eax_key, struct eax_ctx): Use union
...
...
aes128-meta.c
View file @
58785537
...
...
@@ -2,7 +2,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2013 Niels Möller
* Copyright (C) 2013
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -30,28 +30,11 @@
#include "aes.h"
static
nettle_set_key_func
aes128_set_encrypt_key_wrapper
;
static
nettle_set_key_func
aes128_set_decrypt_key_wrapper
;
static
void
aes128_set_encrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
AES128_KEY_SIZE
);
aes128_set_encrypt_key
(
ctx
,
key
);
}
static
void
aes128_set_decrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
AES128_KEY_SIZE
);
aes128_set_decrypt_key
(
ctx
,
key
);
}
const
struct
nettle_cipher
nettle_aes128
=
{
"aes128"
,
sizeof
(
struct
aes128_ctx
),
AES_BLOCK_SIZE
,
AES128_KEY_SIZE
,
aes128_set_encrypt_key_wrapper
,
aes128_set_decrypt_key_wrapper
,
(
nettle_set_key_func
*
)
aes128_set_encrypt_key
,
(
nettle_set_key_func
*
)
aes128_set_decrypt_key
,
(
nettle_crypt_func
*
)
aes128_encrypt
,
(
nettle_crypt_func
*
)
aes128_decrypt
};
aes192-meta.c
View file @
58785537
...
...
@@ -2,7 +2,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2013 Niels Möller
* Copyright (C) 2013
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -30,28 +30,11 @@
#include "aes.h"
static
nettle_set_key_func
aes192_set_encrypt_key_wrapper
;
static
nettle_set_key_func
aes192_set_decrypt_key_wrapper
;
static
void
aes192_set_encrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
AES192_KEY_SIZE
);
aes192_set_encrypt_key
(
ctx
,
key
);
}
static
void
aes192_set_decrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
AES192_KEY_SIZE
);
aes192_set_decrypt_key
(
ctx
,
key
);
}
const
struct
nettle_cipher
nettle_aes192
=
{
"aes192"
,
sizeof
(
struct
aes192_ctx
),
AES_BLOCK_SIZE
,
AES192_KEY_SIZE
,
aes192_set_encrypt_key_wrapper
,
aes192_set_decrypt_key_wrapper
,
(
nettle_set_key_func
*
)
aes192_set_encrypt_key
,
(
nettle_set_key_func
*
)
aes192_set_decrypt_key
,
(
nettle_crypt_func
*
)
aes192_encrypt
,
(
nettle_crypt_func
*
)
aes192_decrypt
};
aes256-meta.c
View file @
58785537
...
...
@@ -2,7 +2,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2013 Niels Möller
* Copyright (C) 2013
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -30,28 +30,11 @@
#include "aes.h"
static
nettle_set_key_func
aes256_set_encrypt_key_wrapper
;
static
nettle_set_key_func
aes256_set_decrypt_key_wrapper
;
static
void
aes256_set_encrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
AES256_KEY_SIZE
);
aes256_set_encrypt_key
(
ctx
,
key
);
}
static
void
aes256_set_decrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
AES256_KEY_SIZE
);
aes256_set_decrypt_key
(
ctx
,
key
);
}
const
struct
nettle_cipher
nettle_aes256
=
{
"aes256"
,
sizeof
(
struct
aes256_ctx
),
AES_BLOCK_SIZE
,
AES256_KEY_SIZE
,
aes256_set_encrypt_key_wrapper
,
aes256_set_decrypt_key_wrapper
,
(
nettle_set_key_func
*
)
aes256_set_encrypt_key
,
(
nettle_set_key_func
*
)
aes256_set_decrypt_key
,
(
nettle_crypt_func
*
)
aes256_encrypt
,
(
nettle_crypt_func
*
)
aes256_decrypt
};
arcfour-meta.c
View file @
58785537
...
...
@@ -30,9 +30,9 @@
const
struct
nettle_cipher
nettle_arcfour128
=
{
"arcfour128"
,
sizeof
(
struct
arcfour_ctx
),
0
,
16
,
(
nettle_set_key_func
*
)
arcfour_set_key
,
(
nettle_set_key_func
*
)
arcfour_set_key
,
0
,
ARCFOUR128_KEY_SIZE
,
(
nettle_set_key_func
*
)
arcfour
128
_set_key
,
(
nettle_set_key_func
*
)
arcfour
128
_set_key
,
(
nettle_crypt_func
*
)
arcfour_crypt
,
(
nettle_crypt_func
*
)
arcfour_crypt
};
arcfour.c
View file @
58785537
...
...
@@ -5,7 +5,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Möller
* Copyright (C) 2001
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -56,3 +56,8 @@ arcfour_set_key(struct arcfour_ctx *ctx,
ctx
->
i
=
ctx
->
j
=
0
;
}
void
arcfour128_set_key
(
struct
arcfour_ctx
*
ctx
,
const
uint8_t
*
key
)
{
arcfour_set_key
(
ctx
,
ARCFOUR128_KEY_SIZE
,
key
);
}
arcfour.h
View file @
58785537
...
...
@@ -5,7 +5,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Möller
* Copyright (C) 2001
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -33,6 +33,7 @@ extern "C" {
#endif
/* Name mangling */
#define arcfour128_set_key nettle_arcfour128_set_key
#define arcfour_set_key nettle_arcfour_set_key
#define arcfour_crypt nettle_arcfour_crypt
...
...
@@ -41,6 +42,7 @@ extern "C" {
#define ARCFOUR_MIN_KEY_SIZE 1
#define ARCFOUR_MAX_KEY_SIZE 256
#define ARCFOUR_KEY_SIZE 16
#define ARCFOUR128_KEY_SIZE 16
struct
arcfour_ctx
{
...
...
@@ -53,6 +55,9 @@ void
arcfour_set_key
(
struct
arcfour_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
key
);
void
arcfour128_set_key
(
struct
arcfour_ctx
*
ctx
,
const
uint8_t
*
key
);
void
arcfour_crypt
(
struct
arcfour_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
...
...
arctwo-meta.c
View file @
58785537
...
...
@@ -3,6 +3,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2004 Simon Josefsson
* Copyright (C) 2014 Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -28,21 +29,28 @@
#include "arctwo.h"
#define ARCTWO(bits) { \
"arctwo" #bits, sizeof (struct arctwo_ctx), \
ARCTWO_BLOCK_SIZE, bits/8, \
(nettle_set_key_func *) arctwo ## bits ## _set_key, \
(nettle_set_key_func *) arctwo ## bits ## _set_key, \
(nettle_crypt_func *) arctwo_encrypt, \
(nettle_crypt_func *) arctwo_decrypt, \
}
const
struct
nettle_cipher
nettle_arctwo40
=
_NETTLE_CIPHER
(
arctwo
,
ARCTWO
,
40
);
=
ARCTWO
(
40
);
const
struct
nettle_cipher
nettle_arctwo64
=
_NETTLE_CIPHER
(
arctwo
,
ARCTWO
,
64
);
=
ARCTWO
(
64
);
const
struct
nettle_cipher
nettle_arctwo128
=
_NETTLE_CIPHER
(
arctwo
,
ARCTWO
,
128
);
/* Map Gutmann variant. */
#define arctwo_gutmann_ctx arctwo_ctx
#define arctwo_gutmann_encrypt arctwo_encrypt
#define arctwo_gutmann_decrypt arctwo_decrypt
#define arctwo_gutmann_ctx arctwo_ctx
#define arctwo_gutmann_set_key arctwo_set_key_gutmann
const
struct
nettle_cipher
nettle_arctwo_gutmann128
=
_NETTLE_CIPHER
(
arctwo_gutmann
,
ARCTWO
,
128
);
=
ARCTWO
(
128
);
/* Gutmann variant. */
const
struct
nettle_cipher
nettle_arctwo_gutmann128
=
{
"arctwo_gutmann128"
,
sizeof
(
struct
arctwo_ctx
),
ARCTWO_BLOCK_SIZE
,
16
,
(
nettle_set_key_func
*
)
arctwo128_set_key_gutmann
,
(
nettle_set_key_func
*
)
arctwo128_set_key_gutmann
,
(
nettle_crypt_func
*
)
arctwo_encrypt
,
(
nettle_crypt_func
*
)
arctwo_decrypt
,
};
arctwo.c
View file @
58785537
...
...
@@ -8,7 +8,7 @@
* Copyright (C) 2004 Simon Josefsson
* Copyright (C) 2003 Nikos Mavroyanopoulos
* Copyright (C) 2004 Free Software Foundation, Inc.
* Copyright (C) 2004 Niels Möller
* Copyright (C) 2004
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -228,3 +228,26 @@ arctwo_set_key_gutmann (struct arctwo_ctx *ctx,
{
arctwo_set_key_ekb
(
ctx
,
length
,
key
,
0
);
}
void
arctwo40_set_key
(
struct
arctwo_ctx
*
ctx
,
const
uint8_t
*
key
)
{
arctwo_set_key_ekb
(
ctx
,
5
,
key
,
40
);
}
void
arctwo64_set_key
(
struct
arctwo_ctx
*
ctx
,
const
uint8_t
*
key
)
{
arctwo_set_key_ekb
(
ctx
,
8
,
key
,
64
);
}
void
arctwo128_set_key
(
struct
arctwo_ctx
*
ctx
,
const
uint8_t
*
key
)
{
arctwo_set_key_ekb
(
ctx
,
16
,
key
,
128
);
}
void
arctwo128_set_key_gutmann
(
struct
arctwo_ctx
*
ctx
,
const
uint8_t
*
key
)
{
arctwo_set_key_ekb
(
ctx
,
16
,
key
,
1024
);
}
arctwo.h
View file @
58785537
...
...
@@ -6,7 +6,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2004 Simon Josefsson
* Copyright (C) 2002, 2004 Niels Möller
* Copyright (C) 2002, 2004
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -36,9 +36,13 @@ extern "C" {
/* Name mangling */
#define arctwo_set_key nettle_arctwo_set_key
#define arctwo_set_key_ekb nettle_arctwo_set_key_ekb
#define arctwo_set_key_gutmann nettle_arctwo_set_key_gutmann
#define arctwo40_set_key nettle_arctwo40_set_key
#define arctwo64_set_key nettle_arctwo64_set_key
#define arctwo128_set_key nettle_arctwo128_set_key
#define arctwo128_set_key_gutmann nettle_arctwo128_set_key_gutmann
#define arctwo_encrypt nettle_arctwo_encrypt
#define arctwo_decrypt nettle_arctwo_decrypt
#define arctwo_set_key_gutmann nettle_arctwo_set_key_gutmann
#define ARCTWO_BLOCK_SIZE 8
...
...
@@ -62,11 +66,20 @@ arctwo_set_key_ekb (struct arctwo_ctx *ctx,
/* Equvivalent to arctwo_set_key_ekb, with ekb = 8 * length */
void
arctwo_set_key
(
struct
arctwo_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
key
);
void
arctwo40_set_key
(
struct
arctwo_ctx
*
ctx
,
const
uint8_t
*
key
);
void
arctwo64_set_key
(
struct
arctwo_ctx
*
ctx
,
const
uint8_t
*
key
);
void
arctwo128_set_key
(
struct
arctwo_ctx
*
ctx
,
const
uint8_t
*
key
);
/* Equvivalent to arctwo_set_key_ekb, with ekb = 1024 */
void
arctwo_set_key_gutmann
(
struct
arctwo_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
key
);
void
arctwo128_set_key_gutmann
(
struct
arctwo_ctx
*
ctx
,
const
uint8_t
*
key
);
void
arctwo_encrypt
(
struct
arctwo_ctx
*
ctx
,
...
...
camellia128-meta.c
View file @
58785537
...
...
@@ -2,7 +2,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2010, 2013 Niels Möller
* Copyright (C) 2010, 2013
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -30,25 +30,11 @@
#include "camellia.h"
static
void
camellia128_set_encrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
CAMELLIA128_KEY_SIZE
);
camellia128_set_encrypt_key
(
ctx
,
key
);
}
static
void
camellia128_set_decrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
CAMELLIA128_KEY_SIZE
);
camellia128_set_decrypt_key
(
ctx
,
key
);
}
const
struct
nettle_cipher
nettle_camellia128
=
{
"camellia128"
,
sizeof
(
struct
camellia128_ctx
),
CAMELLIA_BLOCK_SIZE
,
CAMELLIA128_KEY_SIZE
,
camellia128_set_encrypt_key_wrapper
,
camellia128_set_decrypt_key_wrapper
,
(
nettle_set_key_func
*
)
camellia128_set_encrypt_key
,
(
nettle_set_key_func
*
)
camellia128_set_decrypt_key
,
(
nettle_crypt_func
*
)
camellia128_crypt
,
(
nettle_crypt_func
*
)
camellia128_crypt
};
camellia192-meta.c
View file @
58785537
...
...
@@ -2,7 +2,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2010, 2013 Niels Möller
* Copyright (C) 2010, 2013
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -30,25 +30,11 @@
#include "camellia.h"
static
void
camellia192_set_encrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
CAMELLIA192_KEY_SIZE
);
camellia192_set_encrypt_key
(
ctx
,
key
);
}
static
void
camellia192_set_decrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
CAMELLIA192_KEY_SIZE
);
camellia192_set_decrypt_key
(
ctx
,
key
);
}
const
struct
nettle_cipher
nettle_camellia192
=
{
"camellia192"
,
sizeof
(
struct
camellia256_ctx
),
CAMELLIA_BLOCK_SIZE
,
CAMELLIA192_KEY_SIZE
,
camellia192_set_encrypt_key_wrapper
,
camellia192_set_decrypt_key_wrapper
,
(
nettle_set_key_func
*
)
camellia192_set_encrypt_key
,
(
nettle_set_key_func
*
)
camellia192_set_decrypt_key
,
(
nettle_crypt_func
*
)
camellia256_crypt
,
(
nettle_crypt_func
*
)
camellia256_crypt
};
camellia256-meta.c
View file @
58785537
...
...
@@ -2,7 +2,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2010, 2013 Niels Möller
* Copyright (C) 2010, 2013
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -30,25 +30,11 @@
#include "camellia.h"
static
void
camellia256_set_encrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
CAMELLIA256_KEY_SIZE
);
camellia256_set_encrypt_key
(
ctx
,
key
);
}
static
void
camellia256_set_decrypt_key_wrapper
(
void
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
assert
(
length
==
CAMELLIA256_KEY_SIZE
);
camellia256_set_decrypt_key
(
ctx
,
key
);
}
const
struct
nettle_cipher
nettle_camellia256
=
{
"camellia256"
,
sizeof
(
struct
camellia256_ctx
),
CAMELLIA_BLOCK_SIZE
,
CAMELLIA256_KEY_SIZE
,
camellia256_set_encrypt_key_wrapper
,
camellia256_set_decrypt_key_wrapper
,
(
nettle_set_key_func
*
)
camellia256_set_encrypt_key
,
(
nettle_set_key_func
*
)
camellia256_set_decrypt_key
,
(
nettle_crypt_func
*
)
camellia256_crypt
,
(
nettle_crypt_func
*
)
camellia256_crypt
};
cast128.c
View file @
58785537
...
...
@@ -11,7 +11,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Möller
* Copyright (C) 2001
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -213,15 +213,15 @@ cast128_decrypt(const struct cast128_ctx *ctx,
} while (0)
void
cast
128
_set_key
(
struct
cast128_ctx
*
ctx
,
cast
5
_set_key
(
struct
cast128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
key
)
{
uint32_t
x0
,
x1
,
x2
,
x3
,
z0
,
z1
,
z2
,
z3
;
uint32_t
w
;
int
full
;
assert
(
length
>=
CAST
128
_MIN_KEY_SIZE
);
assert
(
length
<=
CAST
128
_MAX_KEY_SIZE
);
assert
(
length
>=
CAST
5
_MIN_KEY_SIZE
);
assert
(
length
<=
CAST
5
_MAX_KEY_SIZE
);
full
=
(
length
>
CAST_SMALL_KEY
);
...
...
@@ -269,3 +269,9 @@ cast128_set_key(struct cast128_ctx *ctx,
ctx
->
rounds
=
full
?
16
:
12
;
}
void
cast128_set_key
(
struct
cast128_ctx
*
ctx
,
const
uint8_t
*
key
)
{
cast5_set_key
(
ctx
,
CAST128_KEY_SIZE
,
key
);
}
cast128.h
View file @
58785537
...
...
@@ -11,7 +11,7 @@
/* nettle, low-level cryptographics library
*
* Copyright (C) 2001 Niels Möller
* Copyright (C) 2001
, 2014
Niels Möller
*
* The nettle library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -39,6 +39,7 @@ extern "C" {
#endif
/* Name mangling */
#define cast5_set_key nettle_cast5_set_key
#define cast128_set_key nettle_cast128_set_key
#define cast128_encrypt nettle_cast128_encrypt
#define cast128_decrypt nettle_cast128_decrypt
...
...
@@ -46,8 +47,8 @@ extern "C" {
#define CAST128_BLOCK_SIZE 8
/* Variable key size between 40 and 128. */
#define CAST
128
_MIN_KEY_SIZE 5
#define CAST
128
_MAX_KEY_SIZE 16
#define CAST
5
_MIN_KEY_SIZE 5
#define CAST
5
_MAX_KEY_SIZE 16
#define CAST128_KEY_SIZE 16
...
...
@@ -59,10 +60,14 @@ struct cast128_ctx
uint32_t
Km
[
16
];
};
/* Using variable key size. */
void
cast
128
_set_key
(
struct
cast128_ctx
*
ctx
,
cast
5
_set_key
(
struct
cast128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
key
);
void
cast128_set_key
(
struct
cast128_ctx
*
ctx
,
const
uint8_t
*
key
);
void
cast128_encrypt
(
const
struct
cast128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
...
...
eax.h
View file @
58785537
...
...
@@ -102,9 +102,9 @@ eax_digest (struct eax_ctx *eax, const struct eax_key *key,
#define EAX_CTX(type) \
{ struct eax_key key; struct eax_ctx eax; type cipher; }
#define EAX_SET_KEY(ctx, set_key, encrypt,
length, data)
\
#define EAX_SET_KEY(ctx, set_key, encrypt,
data)
\
do { \
(set_key)(&(ctx)->cipher, (
length), (data));
\
(set_key)(&(ctx)->cipher, (
data));
\
if (0) (encrypt) (&(ctx)->cipher, 0, (void *) 0, (void *) 0); \
eax_set_key (&(ctx)->key, &(ctx)->cipher, (nettle_crypt_func *) encrypt); \
} while (0)
...
...
examples/nettle-benchmark.c
View file @
58785537
...
...
@@ -427,7 +427,7 @@ time_gcm(void)
uint8_t
key
[
AES128_KEY_SIZE
];
uint8_t
iv
[
GCM_IV_SIZE
];
gcm_aes128_set_key
(
&
ctx
,
sizeof
(
key
),
key
);
gcm_aes128_set_key
(
&
ctx
,
key
);
gcm_aes128_set_iv
(
&
ctx
,
sizeof
(
iv
),
iv
);
hinfo
.
ctx
=
&
ctx
;
...
...
@@ -461,7 +461,7 @@ time_eax(void)
uint8_t
key
[
AES128_KEY_SIZE
];
uint8_t
iv
[
EAX_BLOCK_SIZE
];
eax_aes128_set_key
(
&
ctx
,
sizeof
(
key
),
key
);
eax_aes128_set_key
(
&
ctx
,
key
);
eax_aes128_set_nonce
(
&
ctx
,
sizeof
(
iv
),
iv
);
hinfo
.
ctx
=
&
ctx
;
...
...
@@ -521,7 +521,7 @@ time_cipher(const struct nettle_cipher *cipher)
info
.
data
=
data
;
init_key
(
cipher
->
key_size
,
key
);
cipher
->
set_encrypt_key
(
ctx
,
cipher
->
key_size
,
key
);
cipher
->
set_encrypt_key
(
ctx
,
key
);
display
(
cipher
->
name
,
"ECB encrypt"
,
cipher
->
block_size
,