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
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Nettle
nettle
Commits
47fd6eb8
Commit
47fd6eb8
authored
Jun 25, 2013
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New interface for AES-256. Also deleted old aes-meta.c.
parent
dc2227ac
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
199 additions
and
36 deletions
+199
-36
ChangeLog
ChangeLog
+4
-2
Makefile.in
Makefile.in
+3
-1
aes-decrypt.c
aes-decrypt.c
+10
-0
aes-encrypt.c
aes-encrypt.c
+10
-0
aes.h
aes.h
+26
-0
aes256-meta.c
aes256-meta.c
+57
-0
aes256-set-decrypt-key.c
aes256-set-decrypt-key.c
+46
-0
aes256-set-encrypt-key.c
aes256-set-encrypt-key.c
+12
-6
nettle-internal.c
nettle-internal.c
+3
-0
nettle-internal.h
nettle-internal.h
+1
-0
testsuite/aes-test.c
testsuite/aes-test.c
+27
-27
No files found.
ChangeLog
View file @
47fd6eb8
2013-06-25 Niels Möller <nisse@lysator.liu.se>
* aes-meta.c: Deleted file.
Analogous changes for new aes192 and aes256 interface.
* aes.h (struct aes128_ctx): New aes128 declarations.
* aes-decrypt.c (aes128_decrypt): New function.
* aes-encrypt.c (aes128_encrypt): New function.
...
...
@@ -16,8 +20,6 @@
* testsuite/aes-test.c (test_cipher2): New function.
(test_main): Test both nettle_aes128 and nettle_unified_aes128.
Analogous changes för aes192.
2013-05-22 Niels Möller <nisse@lysator.liu.se>
* Makefile.in (nettle_SOURCES): Added aes-invert-internal.c and
...
...
Makefile.in
View file @
47fd6eb8
...
...
@@ -64,11 +64,13 @@ all-here: $(TARGETS) $(DOCTARGETS)
nettle_SOURCES
=
aes-decrypt-internal.c aes-decrypt.c
\
aes-encrypt-internal.c aes-encrypt.c aes-encrypt-table.c
\
aes-invert-internal.c aes-set-key-internal.c
\
aes-set-encrypt-key.c aes-set-decrypt-key.c
aes-meta.c
\
aes-set-encrypt-key.c aes-set-decrypt-key.c
\
aes128-set-encrypt-key.c aes128-set-decrypt-key.c
\
aes128-meta.c
\
aes192-set-encrypt-key.c aes192-set-decrypt-key.c
\
aes192-meta.c
\
aes256-set-encrypt-key.c aes256-set-decrypt-key.c
\
aes256-meta.c
\
arcfour.c arcfour-crypt.c arcfour-meta.c
\
arctwo.c arctwo-meta.c gosthash94-meta.c
\
base16-encode.c base16-decode.c base16-meta.c
\
...
...
aes-decrypt.c
View file @
47fd6eb8
...
...
@@ -365,3 +365,13 @@ aes192_decrypt(const struct aes192_ctx *ctx,
_aes_decrypt
(
_AES192_ROUNDS
,
ctx
->
keys
,
&
_aes_decrypt_table
,
length
,
dst
,
src
);
}
void
aes256_decrypt
(
const
struct
aes256_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
)
{
assert
(
!
(
length
%
AES_BLOCK_SIZE
)
);
_aes_decrypt
(
_AES256_ROUNDS
,
ctx
->
keys
,
&
_aes_decrypt_table
,
length
,
dst
,
src
);
}
aes-encrypt.c
View file @
47fd6eb8
...
...
@@ -63,3 +63,13 @@ aes192_encrypt(const struct aes192_ctx *ctx,
_aes_encrypt
(
_AES192_ROUNDS
,
ctx
->
keys
,
&
_aes_encrypt_table
,
length
,
dst
,
src
);
}
void
aes256_encrypt
(
const
struct
aes256_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
)
{
assert
(
!
(
length
%
AES_BLOCK_SIZE
)
);
_aes_encrypt
(
_AES256_ROUNDS
,
ctx
->
keys
,
&
_aes_encrypt_table
,
length
,
dst
,
src
);
}
aes.h
View file @
47fd6eb8
...
...
@@ -48,6 +48,11 @@ extern "C" {
#define aes192_invert_key nettle_aes192invert_key
#define aes192_encrypt nettle_aes192encrypt
#define aes192_decrypt nettle_aes192decrypt
#define aes256_set_encrypt_key nettle_aes256_set_encrypt_key
#define aes256_set_decrypt_key nettle_aes256_set_decrypt_key
#define aes256_invert_key nettle_aes256_invert_key
#define aes256_encrypt nettle_aes256_encrypt
#define aes256_decrypt nettle_aes256_decrypt
#define AES_BLOCK_SIZE 16
...
...
@@ -136,6 +141,27 @@ aes192_decrypt(const struct aes192_ctx *ctx,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
struct
aes256_ctx
{
uint32_t
keys
[
4
*
(
_AES256_ROUNDS
+
1
)];
};
void
aes256_set_encrypt_key
(
struct
aes256_ctx
*
ctx
,
const
uint8_t
*
key
);
void
aes256_set_decrypt_key
(
struct
aes256_ctx
*
ctx
,
const
uint8_t
*
key
);
void
aes256_invert_key
(
struct
aes256_ctx
*
dst
,
const
struct
aes256_ctx
*
src
);
void
aes256_encrypt
(
const
struct
aes256_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
void
aes256_decrypt
(
const
struct
aes256_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
#ifdef __cplusplus
}
#endif
...
...
aes256-meta.c
0 → 100644
View file @
47fd6eb8
/* aes256-meta.c */
/* nettle, low-level cryptographics library
*
* Copyright (C) 2013 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
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02111-1301, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include "nettle-meta.h"
#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_crypt_func
*
)
aes256_encrypt
,
(
nettle_crypt_func
*
)
aes256_decrypt
};
aes256-set-decrypt-key.c
0 → 100644
View file @
47fd6eb8
/* aes256-set-decrypt-key.c
*
* Key setup for the aes/rijndael block cipher.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 2013, 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
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The nettle library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the nettle library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02111-1301, USA.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include "aes-internal.h"
#include "macros.h"
void
aes256_invert_key
(
struct
aes256_ctx
*
dst
,
const
struct
aes256_ctx
*
src
)
{
_aes_invert
(
_AES256_ROUNDS
,
dst
->
keys
,
src
->
keys
);
}
void
aes256_set_decrypt_key
(
struct
aes256_ctx
*
ctx
,
const
uint8_t
*
key
)
{
aes256_set_encrypt_key
(
ctx
,
key
);
aes256_invert_key
(
ctx
,
ctx
);
}
aes
-meta
.c
→
aes
256-set-encrypt-key
.c
View file @
47fd6eb8
/* aes-meta.c */
/* aes256-set-encrypt-key.c
*
* Key setup for the aes/rijndael block cipher.
*/
/* nettle, low-level cryptographics library
*
* Copyright (C) 20
02
Niels Möller
* Copyright (C) 20
13,
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
...
...
@@ -24,9 +27,12 @@
# include "config.h"
#endif
#include
"nettle-meta.h"
#include
<assert.h>
#include "aes.h"
#include "aes
-internal
.h"
const
struct
nettle_cipher
nettle_aes256
=
_NETTLE_CIPHER_SEP
(
aes
,
AES
,
256
);
void
aes256_set_encrypt_key
(
struct
aes256_ctx
*
ctx
,
const
uint8_t
*
key
)
{
_aes_set_key
(
_AES256_ROUNDS
,
AES256_KEY_SIZE
/
4
,
ctx
->
keys
,
key
);
}
nettle-internal.c
View file @
47fd6eb8
...
...
@@ -119,3 +119,6 @@ const struct nettle_cipher nettle_unified_aes128
const
struct
nettle_cipher
nettle_unified_aes192
=
_NETTLE_CIPHER_SEP
(
aes
,
AES
,
192
);
const
struct
nettle_cipher
nettle_unified_aes256
=
_NETTLE_CIPHER_SEP
(
aes
,
AES
,
256
);
nettle-internal.h
View file @
47fd6eb8
...
...
@@ -66,6 +66,7 @@ extern const struct nettle_cipher nettle_salsa20r12;
extern
const
struct
nettle_cipher
nettle_unified_aes128
;
extern
const
struct
nettle_cipher
nettle_unified_aes192
;
extern
const
struct
nettle_cipher
nettle_unified_aes256
;
/* Glue to openssl, for comparative benchmarking. Code in
* examples/nettle-openssl.c. */
...
...
testsuite/aes-test.c
View file @
47fd6eb8
...
...
@@ -90,25 +90,25 @@ test_main(void)
SHEX
(
"2D33EEF2C0430A8A 9EBF45E809C40BB6"
),
SHEX
(
"DFF4945E0336DF4C 1C56BC700EFF837F"
));
/* 256 bit keys */
test_cipher
(
&
nettle
_aes256
,
SHEX
(
"0001020305060708 0A0B0C0D0F101112"
"14151617191A1B1C 1E1F202123242526"
),
SHEX
(
"834EADFCCAC7E1B30664B1ABA44815AB"
),
SHEX
(
"1946DABF6A03A2A2 C3D0B05080AED6FC"
));
/* 256 bit keys */
test_cipher
2
(
&
nettle_aes256
,
&
nettle_unified
_aes256
,
SHEX
(
"0001020305060708 0A0B0C0D0F101112"
"14151617191A1B1C 1E1F202123242526"
),
SHEX
(
"834EADFCCAC7E1B30664B1ABA44815AB"
),
SHEX
(
"1946DABF6A03A2A2 C3D0B05080AED6FC"
));
/* This test case has been problematic with the CBC test case */
test_cipher
(
&
nettle
_aes256
,
SHEX
(
"8d ae 93 ff fc 78 c9 44"
"2a bd 0c 1e 68 bc a6 c7"
"05 c7 84 e3 5a a9 11 8b"
"d3 16 aa 54 9b 44 08 9e"
),
SHEX
(
"a5 ce 55 d4 21 15 a1 c6 4a a4 0c b2 ca a6 d1 37"
),
/* In the cbc test, I once got the bad value
* "b2 a0 6c d2 2f df 7d 2c 26 d2 42 88 8f 20 74 a2" */
SHEX
(
"1f 94 fc 85 f2 36 21 06"
"4a ea e3 c9 cc 38 01 0e"
));
test_cipher
2
(
&
nettle_aes256
,
&
nettle_unified
_aes256
,
SHEX
(
"8d ae 93 ff fc 78 c9 44"
"2a bd 0c 1e 68 bc a6 c7"
"05 c7 84 e3 5a a9 11 8b"
"d3 16 aa 54 9b 44 08 9e"
),
SHEX
(
"a5 ce 55 d4 21 15 a1 c6 4a a4 0c b2 ca a6 d1 37"
),
/* In the cbc test, I once got the bad value
* "b2 a0 6c d2 2f df 7d 2c 26 d2 42 88 8f 20 74 a2" */
SHEX
(
"1f 94 fc 85 f2 36 21 06"
"4a ea e3 c9 cc 38 01 0e"
));
/* From draft NIST spec on AES modes.
*
...
...
@@ -141,17 +141,17 @@ test_main(void)
"9a4b41ba738d6c72fb16691603c18e0e"
));
/* F.1.5 ECB-AES256-Encrypt */
test_cipher
(
&
nettle
_aes256
,
SHEX
(
"603deb1015ca71be2b73aef0857d7781"
"1f352c073b6108d72d9810a30914dff4"
),
SHEX
(
"6bc1bee22e409f96e93d7e117393172a"
"ae2d8a571e03ac9c9eb76fac45af8e51"
"30c81c46a35ce411e5fbc1191a0a52ef"
"f69f2445df4f9b17ad2b417be66c3710"
),
SHEX
(
"f3eed1bdb5d2a03c064b5a7e3db181f8"
"591ccb10d410ed26dc5ba74a31362870"
"b6ed21b99ca6f4f9f153e7b1beafed1d"
"23304b7a39f9f3ff067d8d8f9e24ecc7"
));
test_cipher
2
(
&
nettle_aes256
,
&
nettle_unified
_aes256
,
SHEX
(
"603deb1015ca71be2b73aef0857d7781"
"1f352c073b6108d72d9810a30914dff4"
),
SHEX
(
"6bc1bee22e409f96e93d7e117393172a"
"ae2d8a571e03ac9c9eb76fac45af8e51"
"30c81c46a35ce411e5fbc1191a0a52ef"
"f69f2445df4f9b17ad2b417be66c3710"
),
SHEX
(
"f3eed1bdb5d2a03c064b5a7e3db181f8"
"591ccb10d410ed26dc5ba74a31362870"
"b6ed21b99ca6f4f9f153e7b1beafed1d"
"23304b7a39f9f3ff067d8d8f9e24ecc7"
));
/* Test aes_invert_key with src != dst */
test_invert
(
SHEX
(
"0001020305060708 0A0B0C0D0F101112"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment