Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brian Smith
nettle
Commits
f0053e65
Commit
f0053e65
authored
23 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
(test_cbc_bulk): New function, testing CBC
with larger blocks. Rev: src/nettle/testsuite/cbc-test.c:1.3
parent
b44f9704
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testsuite/cbc-test.c
+71
-2
71 additions, 2 deletions
testsuite/cbc-test.c
with
71 additions
and
2 deletions
testsuite/cbc-test.c
+
71
−
2
View file @
f0053e65
#include
"testutils.h"
#include
"aes.h"
#include
"cbc.h"
#include
"knuth-lfib.h"
/* Test with more data and inplace decryption, to check that the
* cbc_decrypt buffering works. */
#define CBC_BULK_DATA 0x2710
/* 10000 */
static
void
test_cbc_bulk
(
void
)
{
struct
knuth_lfib_ctx
random
;
uint8_t
clear
[
CBC_BULK_DATA
];
uint8_t
cipher
[
CBC_BULK_DATA
+
1
];
const
uint8_t
*
key
=
H
(
"966c7bf00bebe6dc 8abd37912384958a"
"743008105a08657d dcaad4128eee38b3"
);
const
uint8_t
*
start_iv
=
H
(
"11adbff119749103 207619cfa0e8d13a"
);
const
uint8_t
*
end_iv
=
H
(
"c7a42a569b421224 d0c23e52f46f97f5"
);
struct
CBC_CTX
(
struct
aes_ctx
,
AES_BLOCK_SIZE
)
aes
;
knuth_lfib_init
(
&
random
,
CBC_BULK_DATA
);
knuth_lfib_random
(
&
random
,
CBC_BULK_DATA
,
clear
);
/* Byte that should not be overwritten */
cipher
[
CBC_BULK_DATA
]
=
17
;
aes_set_key
(
&
aes
.
ctx
,
32
,
key
);
CBC_SET_IV
(
&
aes
,
start_iv
);
CBC_ENCRYPT
(
&
aes
,
aes_encrypt
,
CBC_BULK_DATA
,
cipher
,
clear
);
if
(
cipher
[
CBC_BULK_DATA
]
!=
17
)
FAIL
();
if
(
verbose
)
{
printf
(
"IV after bulk encryption: "
);
print_hex
(
AES_BLOCK_SIZE
,
aes
.
iv
);
printf
(
"
\n
"
);
}
if
(
!
MEMEQ
(
AES_BLOCK_SIZE
,
aes
.
iv
,
end_iv
))
FAIL
();
/* Decrypt, in place */
CBC_SET_IV
(
&
aes
,
start_iv
);
CBC_DECRYPT
(
&
aes
,
aes_decrypt
,
CBC_BULK_DATA
,
cipher
,
cipher
);
if
(
cipher
[
CBC_BULK_DATA
]
!=
17
)
FAIL
();
if
(
verbose
)
{
printf
(
"IV after bulk decryption: "
);
print_hex
(
AES_BLOCK_SIZE
,
aes
.
iv
);
printf
(
"
\n
"
);
}
if
(
!
MEMEQ
(
AES_BLOCK_SIZE
,
aes
.
iv
,
end_iv
))
FAIL
();
if
(
!
MEMEQ
(
CBC_BULK_DATA
,
clear
,
cipher
))
FAIL
();
}
int
test_main
(
void
)
{
uint8_t
msg
[
2
*
AES_BLOCK_SIZE
]
=
"Listen, I'll say this only once!"
;
/* Intermediate values:
* iv XOR first message block:
* "a5 ce 55 d4 21 15 a1 c6 4a a4 0c b2 ca a6 d1 37"
...
...
@@ -36,7 +103,7 @@ test_main(void)
* F.2.1 CBC-AES128.Encrypt
*/
/* Intermediate values, bl
c
oks input to AES:
/* Intermediate values, blo
c
ks input to AES:
*
* 6bc0bce12a459991e134741a7f9e1925
* d86421fb9f1a1eda505ee1375746972c
...
...
@@ -101,6 +168,8 @@ test_main(void)
"b2eb05e2c39be9fcda6c19078c6a9d1b"
),
H
(
"000102030405060708090a0b0c0d0e0f"
));
test_cbc_bulk
();
SUCCESS
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment