Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dmitry Baryshkov
nettle
Commits
c6ce389e
Commit
c6ce389e
authored
Feb 13, 2014
by
Niels Möller
Browse files
Make eax_aes128 interface public.
parent
63108e98
Changes
9
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
c6ce389e
2014-02-13 Niels Möller <nisse@lysator.liu.se>
* Makefile.in (nettle_SOURCES): Added eax-aes128.c
eax-aes128-meta.c.
* examples/nettle-benchmark.c: Include eax.h.
* nettle-meta.h (nettle_eax_aes128): Declare, moved from
nettle-internal.h.
* eax.h: Declare eax_aes128_ctx and related functions. Moved from
nettle-internal.h
(EAX_IV_SIZE): New constant.
* eax-aes128-meta.c (nettle_eax_aes128): Moved definition to new
file.
* eax-aes128.c (eax_aes128_set_key, eax_aes128_set_nonce)
(eax_aes128_update, eax_aes128_encrypt, eax_aes128_decrypt)
(eax_aes128_digest): Moved functions to a new file.
* nettle-internal.c: ... from old location.
* nettle-internal.h: Moved eax declarations elsewhere.
* tools/nettle-pbkdf2.c (main): Added missing deallocation.
2014-02-12 Niels Möller <nisse@lysator.liu.se>
...
...
Makefile.in
View file @
c6ce389e
...
...
@@ -91,7 +91,8 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
chacha-poly1305.c chacha-poly1305-meta.c
\
chacha-set-key.c chacha-set-nonce.c
\
chacha128-set-key.c chacha256-set-key.c
\
ctr.c des.c des3.c des-compat.c eax.c
\
ctr.c des.c des3.c des-compat.c
\
eax.c eax-aes128.c eax-aes128-meta.c
\
gcm.c gcm-aes.c
\
gcm-aes128.c gcm-aes128-meta.c
\
gcm-aes192.c gcm-aes192-meta.c
\
...
...
eax-aes128-meta.c
0 → 100644
View file @
c6ce389e
/* eax-aes128-meta.c
*/
/* nettle, low-level cryptographics library
*
* 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
* 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 "eax.h"
#include "nettle-meta.h"
static
nettle_set_key_func
eax_aes128_set_nonce_wrapper
;
static
void
eax_aes128_set_nonce_wrapper
(
void
*
ctx
,
const
uint8_t
*
nonce
)
{
eax_aes128_set_nonce
(
ctx
,
EAX_IV_SIZE
,
nonce
);
}
const
struct
nettle_aead
nettle_eax_aes128
=
{
"eax_aes128"
,
sizeof
(
struct
eax_aes128_ctx
),
EAX_BLOCK_SIZE
,
AES128_KEY_SIZE
,
EAX_IV_SIZE
,
EAX_DIGEST_SIZE
,
(
nettle_set_key_func
*
)
eax_aes128_set_key
,
(
nettle_set_key_func
*
)
eax_aes128_set_key
,
eax_aes128_set_nonce_wrapper
,
(
nettle_hash_update_func
*
)
eax_aes128_update
,
(
nettle_crypt_func
*
)
eax_aes128_encrypt
,
(
nettle_crypt_func
*
)
eax_aes128_decrypt
,
(
nettle_hash_digest_func
*
)
eax_aes128_digest
};
eax-aes128.c
0 → 100644
View file @
c6ce389e
/* eax-aes128.c
*/
/* nettle, low-level cryptographics library
*
* 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
* 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 "eax.h"
void
eax_aes128_set_key
(
struct
eax_aes128_ctx
*
ctx
,
const
uint8_t
*
key
)
{
EAX_SET_KEY
(
ctx
,
aes128_set_encrypt_key
,
aes128_encrypt
,
key
);
}
void
eax_aes128_set_nonce
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
iv
)
{
EAX_SET_NONCE
(
ctx
,
aes128_encrypt
,
length
,
iv
);
}
void
eax_aes128_update
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
data
)
{
EAX_UPDATE
(
ctx
,
aes128_encrypt
,
length
,
data
);
}
void
eax_aes128_encrypt
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
)
{
EAX_ENCRYPT
(
ctx
,
aes128_encrypt
,
length
,
dst
,
src
);
}
void
eax_aes128_decrypt
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
)
{
EAX_DECRYPT
(
ctx
,
aes128_encrypt
,
length
,
dst
,
src
);
}
void
eax_aes128_digest
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
digest
)
{
EAX_DIGEST
(
ctx
,
aes128_encrypt
,
length
,
digest
);
}
eax.h
View file @
c6ce389e
...
...
@@ -40,18 +40,20 @@ extern "C" {
#define eax_decrypt nettle_eax_decrypt
#define eax_digest nettle_eax_digest
#define eax_aes_set_key nettle_eax_aes_set_key
#define eax_aes_set_nonce nettle_eax_aes_set_nonce
#define eax_aes_update nettle_eax_aes_update
#define eax_aes_encrypt nettle_eax_aes_encrypt
#define eax_aes_decrypt nettle_eax_aes_decrypt
#define eax_aes_digest nettle_eax_aes_digest
#define eax_aes
128
_set_key nettle_eax_aes
128
_set_key
#define eax_aes
128
_set_nonce nettle_eax_aes
128
_set_nonce
#define eax_aes
128
_update nettle_eax_aes
128
_update
#define eax_aes
128
_encrypt nettle_eax_aes
128
_encrypt
#define eax_aes
128
_decrypt nettle_eax_aes
128
_decrypt
#define eax_aes
128
_digest nettle_eax_aes
128
_digest
/* Restricted to block ciphers with 128 bit block size. FIXME: Reflect
this in naming? */
#define EAX_BLOCK_SIZE 16
#define EAX_DIGEST_SIZE 16
/* FIXME: Reasonable default? */
#define EAX_IV_SIZE 16
/* Values independent of message and nonce */
struct
eax_key
...
...
@@ -138,6 +140,30 @@ eax_digest (struct eax_ctx *eax, const struct eax_key *key,
&(ctx)->cipher, (nettle_crypt_func *) (encrypt), \
(length), (digest)))
struct
eax_aes128_ctx
EAX_CTX
(
struct
aes128_ctx
);
void
eax_aes128_set_key
(
struct
eax_aes128_ctx
*
ctx
,
const
uint8_t
*
key
);
void
eax_aes128_set_nonce
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
iv
);
void
eax_aes128_update
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
data
);
void
eax_aes128_encrypt
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
void
eax_aes128_decrypt
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
void
eax_aes128_digest
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
digest
);
#ifdef __cplusplus
}
#endif
...
...
examples/nettle-benchmark.c
View file @
c6ce389e
...
...
@@ -47,6 +47,7 @@
#include "cbc.h"
#include "ctr.h"
#include "des.h"
#include "eax.h"
#include "gcm.h"
#include "memxor.h"
#include "salsa20.h"
...
...
nettle-internal.c
View file @
c6ce389e
...
...
@@ -34,8 +34,6 @@
#include "nettle-internal.h"
#include "blowfish.h"
#include "des.h"
#include "eax.h"
#include "gcm.h"
#include "chacha.h"
#include "salsa20.h"
...
...
@@ -120,70 +118,3 @@ nettle_salsa20r12 = {
(
nettle_crypt_func
*
)
salsa20r12_crypt
};
/* eax-aes128 */
void
eax_aes128_set_key
(
struct
eax_aes128_ctx
*
ctx
,
const
uint8_t
*
key
)
{
EAX_SET_KEY
(
ctx
,
aes128_set_encrypt_key
,
aes128_encrypt
,
key
);
}
void
eax_aes128_set_nonce
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
iv
)
{
EAX_SET_NONCE
(
ctx
,
aes128_encrypt
,
length
,
iv
);
}
void
eax_aes128_update
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
data
)
{
EAX_UPDATE
(
ctx
,
aes128_encrypt
,
length
,
data
);
}
void
eax_aes128_encrypt
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
)
{
EAX_ENCRYPT
(
ctx
,
aes128_encrypt
,
length
,
dst
,
src
);
}
void
eax_aes128_decrypt
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
)
{
EAX_DECRYPT
(
ctx
,
aes128_encrypt
,
length
,
dst
,
src
);
}
void
eax_aes128_digest
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
digest
)
{
EAX_DIGEST
(
ctx
,
aes128_encrypt
,
length
,
digest
);
}
/* FIXME: Reasonable default? */
#define EAX_IV_SIZE 16
static
nettle_set_key_func
eax_aes128_set_nonce_wrapper
;
static
void
eax_aes128_set_nonce_wrapper
(
void
*
ctx
,
const
uint8_t
*
nonce
)
{
eax_aes128_set_nonce
(
ctx
,
EAX_IV_SIZE
,
nonce
);
}
const
struct
nettle_aead
nettle_eax_aes128
=
{
"eax_aes128"
,
sizeof
(
struct
eax_aes128_ctx
),
EAX_BLOCK_SIZE
,
AES128_KEY_SIZE
,
EAX_IV_SIZE
,
EAX_DIGEST_SIZE
,
(
nettle_set_key_func
*
)
eax_aes128_set_key
,
(
nettle_set_key_func
*
)
eax_aes128_set_key
,
eax_aes128_set_nonce_wrapper
,
(
nettle_hash_update_func
*
)
eax_aes128_update
,
(
nettle_crypt_func
*
)
eax_aes128_encrypt
,
(
nettle_crypt_func
*
)
eax_aes128_decrypt
,
(
nettle_hash_digest_func
*
)
eax_aes128_digest
};
nettle-internal.h
View file @
c6ce389e
...
...
@@ -29,8 +29,6 @@
#include "nettle-meta.h"
#include "eax.h"
/* Temporary allocation, for systems that don't support alloca. Note
* that the allocation requests should always be reasonably small, so
* that they can fit on the stack. For non-alloca systems, we use a
...
...
@@ -82,32 +80,4 @@ extern const struct nettle_cipher nettle_openssl_cast128;
extern
const
struct
nettle_hash
nettle_openssl_md5
;
extern
const
struct
nettle_hash
nettle_openssl_sha1
;
/* Tentative interface. */
struct
eax_aes128_ctx
EAX_CTX
(
struct
aes128_ctx
);
void
eax_aes128_set_key
(
struct
eax_aes128_ctx
*
ctx
,
const
uint8_t
*
key
);
void
eax_aes128_set_nonce
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
iv
);
void
eax_aes128_update
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
const
uint8_t
*
data
);
void
eax_aes128_encrypt
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
void
eax_aes128_decrypt
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
dst
,
const
uint8_t
*
src
);
void
eax_aes128_digest
(
struct
eax_aes128_ctx
*
ctx
,
size_t
length
,
uint8_t
*
digest
);
extern
const
struct
nettle_aead
nettle_eax_aes128
;
#endif
/* NETTLE_INTERNAL_H_INCLUDED */
nettle-meta.h
View file @
c6ce389e
...
...
@@ -151,6 +151,7 @@ extern const struct nettle_aead nettle_gcm_aes128;
extern
const
struct
nettle_aead
nettle_gcm_aes192
;
extern
const
struct
nettle_aead
nettle_gcm_aes256
;
extern
const
struct
nettle_aead
nettle_chacha_poly1305
;
extern
const
struct
nettle_aead
nettle_eax_aes128
;
struct
nettle_armor
{
...
...
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