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
764a4813
Commit
764a4813
authored
Feb 10, 2014
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed chacha_set_iv to chacha_set_nonce.
parent
db9a1b61
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
15 deletions
+21
-15
ChangeLog
ChangeLog
+6
-0
Makefile.in
Makefile.in
+1
-1
chacha-set-nonce.c
chacha-set-nonce.c
+5
-5
chacha.h
chacha.h
+3
-3
nettle-internal.c
nettle-internal.c
+2
-2
testsuite/chacha-test.c
testsuite/chacha-test.c
+4
-4
No files found.
ChangeLog
View file @
764a4813
2014-02-10 Niels Möller <nisse@lysator.liu.se>
* chacha-set-nonce.c (chacha_set_nonce): Renamed file and
function, updated callers and Makefile.in.
* chacha-set-iv.c (chacha_set_iv): ... from old names.
2014-02-08 Niels Möller <nisse@lysator.liu.se>
* testsuite/chacha-test.c (test_chacha): For 20 rounds, use
...
...
Makefile.in
View file @
764a4813
...
...
@@ -88,7 +88,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
camellia256-meta.c
\
cast128.c cast128-meta.c cbc.c
\
chacha-crypt.c chacha-core-internal.c
\
chacha-set-
iv.c chacha-set-key
.c
\
chacha-set-
key.c chacha-set-nonce
.c
\
chacha128-set-key.c chacha256-set-key.c
\
ctr.c gcm.c
\
des.c des3.c des-compat.c eax.c
\
...
...
chacha-set-
iv
.c
→
chacha-set-
nonce
.c
View file @
764a4813
/* chacha-set-
iv
.c
/* chacha-set-
nonce
.c
*
* Setting the
IV
the ChaCha stream cipher.
* Setting the
nonce
the ChaCha stream cipher.
* Based on the Salsa20 implementation in Nettle.
*/
...
...
@@ -44,10 +44,10 @@
#include "macros.h"
void
chacha_set_
iv
(
struct
chacha_ctx
*
ctx
,
const
uint8_t
*
iv
)
chacha_set_
nonce
(
struct
chacha_ctx
*
ctx
,
const
uint8_t
*
nonce
)
{
ctx
->
state
[
12
]
=
0
;
ctx
->
state
[
13
]
=
0
;
ctx
->
state
[
14
]
=
LE_READ_UINT32
(
iv
+
0
);
ctx
->
state
[
15
]
=
LE_READ_UINT32
(
iv
+
4
);
ctx
->
state
[
14
]
=
LE_READ_UINT32
(
nonce
+
0
);
ctx
->
state
[
15
]
=
LE_READ_UINT32
(
nonce
+
4
);
}
chacha.h
View file @
764a4813
...
...
@@ -39,7 +39,7 @@ extern "C" {
#define chacha_set_key nettle_chacha_set_key
#define chacha128_set_key nettle_chacha128_set_key
#define chacha256_set_key nettle_chacha256_set_key
#define chacha_set_
iv nettle_chacha_set_iv
#define chacha_set_
nonce nettle_chacha_set_nonce
#define chacha_crypt nettle_chacha_crypt
#define _chacha_core _nettle_chacha_core
...
...
@@ -50,7 +50,7 @@ extern "C" {
#define CHACHA_BLOCK_SIZE 64
#define CHACHA_
IV
_SIZE 8
#define CHACHA_
NONCE
_SIZE 8
#define _CHACHA_STATE_LENGTH 16
...
...
@@ -81,7 +81,7 @@ chacha_set_key(struct chacha_ctx *ctx,
size_t
length
,
const
uint8_t
*
key
);
void
chacha_set_
iv
(
struct
chacha_ctx
*
ctx
,
const
uint8_t
*
iv
);
chacha_set_
nonce
(
struct
chacha_ctx
*
ctx
,
const
uint8_t
*
nonce
);
void
chacha_crypt
(
struct
chacha_ctx
*
ctx
,
size_t
length
,
...
...
nettle-internal.c
View file @
764a4813
...
...
@@ -77,9 +77,9 @@ nettle_blowfish128 =
static
void
chacha_set_key_hack
(
void
*
ctx
,
const
uint8_t
*
key
)
{
static
const
uint8_t
iv
[
CHACHA_IV
_SIZE
];
static
const
uint8_t
nonce
[
CHACHA_NONCE
_SIZE
];
chacha256_set_key
(
ctx
,
key
);
chacha_set_
iv
(
ctx
,
iv
);
chacha_set_
nonce
(
ctx
,
nonce
);
}
/* Claim zero block size, to classify as a stream cipher. */
...
...
testsuite/chacha-test.c
View file @
764a4813
...
...
@@ -29,13 +29,13 @@
#include "chacha.h"
static
void
test_chacha
(
const
struct
tstring
*
key
,
const
struct
tstring
*
iv
,
test_chacha
(
const
struct
tstring
*
key
,
const
struct
tstring
*
nonce
,
const
struct
tstring
*
expected
,
unsigned
rounds
)
{
struct
chacha_ctx
ctx
;
chacha_set_key
(
&
ctx
,
key
->
length
,
key
->
data
);
ASSERT
(
iv
->
length
==
CHACHA_IV
_SIZE
);
ASSERT
(
nonce
->
length
==
CHACHA_NONCE
_SIZE
);
if
(
rounds
==
20
)
{
...
...
@@ -48,7 +48,7 @@ test_chacha(const struct tstring *key, const struct tstring *iv,
data
[
-
1
]
=
17
;
memset
(
data
,
0
,
length
);
data
[
length
]
=
17
;
chacha_set_
iv
(
&
ctx
,
iv
->
data
);
chacha_set_
nonce
(
&
ctx
,
nonce
->
data
);
chacha_crypt
(
&
ctx
,
length
,
data
,
data
);
ASSERT
(
data
[
-
1
]
==
17
);
...
...
@@ -76,7 +76,7 @@ test_chacha(const struct tstring *key, const struct tstring *iv,
uint32_t
out
[
_CHACHA_STATE_LENGTH
];
ASSERT
(
expected
->
length
==
CHACHA_BLOCK_SIZE
);
chacha_set_
iv
(
&
ctx
,
iv
->
data
);
chacha_set_
nonce
(
&
ctx
,
nonce
->
data
);
_chacha_core
(
out
,
ctx
.
state
,
rounds
);
if
(
!
MEMEQ
(
CHACHA_BLOCK_SIZE
,
out
,
expected
->
data
))
...
...
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