Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wim Lewis
nettle
Commits
29c06e98
Commit
29c06e98
authored
Jul 02, 2005
by
Niels Möller
Browse files
(test_cipher_ctr): New function.
Rev: src/nettle/testsuite/testutils.c:1.27 Rev: src/nettle/testsuite/testutils.h:1.22
parent
100223be
Changes
2
Hide whitespace changes
Inline
Side-by-side
testsuite/testutils.c
View file @
29c06e98
...
...
@@ -3,6 +3,7 @@
#include
"testutils.h"
#include
"cbc.h"
#include
"ctr.h"
#include
"knuth-lfib.h"
#include
<ctype.h>
...
...
@@ -224,6 +225,43 @@ test_cipher_cbc(const struct nettle_cipher *cipher,
free
(
iv
);
}
void
test_cipher_ctr
(
const
struct
nettle_cipher
*
cipher
,
unsigned
key_length
,
const
uint8_t
*
key
,
unsigned
length
,
const
uint8_t
*
cleartext
,
const
uint8_t
*
ciphertext
,
const
uint8_t
*
ictr
)
{
void
*
ctx
=
xalloc
(
cipher
->
context_size
);
uint8_t
*
data
=
xalloc
(
length
);
uint8_t
*
ctr
=
xalloc
(
cipher
->
block_size
);
cipher
->
set_encrypt_key
(
ctx
,
key_length
,
key
);
memcpy
(
ctr
,
ictr
,
cipher
->
block_size
);
ctr_crypt
(
ctx
,
cipher
->
encrypt
,
cipher
->
block_size
,
ctr
,
length
,
data
,
cleartext
);
if
(
!
MEMEQ
(
length
,
data
,
ciphertext
))
FAIL
();
memcpy
(
ctr
,
ictr
,
cipher
->
block_size
);
ctr_crypt
(
ctx
,
cipher
->
encrypt
,
cipher
->
block_size
,
ctr
,
length
,
data
,
data
);
if
(
!
MEMEQ
(
length
,
data
,
cleartext
))
FAIL
();
free
(
ctx
);
free
(
data
);
free
(
ctr
);
}
void
test_cipher_stream
(
const
struct
nettle_cipher
*
cipher
,
unsigned
key_length
,
...
...
testsuite/testutils.h
View file @
29c06e98
...
...
@@ -63,6 +63,15 @@ test_cipher_cbc(const struct nettle_cipher *cipher,
const
uint8_t
*
ciphertext
,
const
uint8_t
*
iv
);
void
test_cipher_ctr
(
const
struct
nettle_cipher
*
cipher
,
unsigned
key_length
,
const
uint8_t
*
key
,
unsigned
length
,
const
uint8_t
*
cleartext
,
const
uint8_t
*
ciphertext
,
const
uint8_t
*
iv
);
void
test_cipher_stream
(
const
struct
nettle_cipher
*
cipher
,
unsigned
key_length
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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