Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Tiny AES C
Commits
ba3271ea
Commit
ba3271ea
authored
Jul 12, 2014
by
kokke
Browse files
Update test.c
parent
ce6f709a
Changes
1
Hide whitespace changes
Inline
Side-by-side
test.c
View file @
ba3271ea
...
@@ -5,11 +5,13 @@
...
@@ -5,11 +5,13 @@
static
void
phex
(
uint8_t
*
str
);
static
void
phex
(
uint8_t
*
str
);
static
void
test_ECB
(
void
);
static
void
test_ECB
(
void
);
static
void
test_decrypt
(
void
);
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
test_ECB
();
test_ECB
();
test_decrypt
();
return
0
;
return
0
;
}
}
...
@@ -54,7 +56,7 @@ static void test_ECB(void)
...
@@ -54,7 +56,7 @@ static void test_ECB(void)
}
}
// prints string as hex
// prints string as hex
void
phex
(
uint8_t
*
str
)
static
void
phex
(
uint8_t
*
str
)
{
{
unsigned
char
i
;
unsigned
char
i
;
for
(
i
=
0
;
i
<
16
;
++
i
)
for
(
i
=
0
;
i
<
16
;
++
i
)
...
@@ -63,3 +65,24 @@ void phex(uint8_t* str)
...
@@ -63,3 +65,24 @@ void phex(uint8_t* str)
}
}
static
void
test_decrypt
(
void
)
{
uint8_t
key
[]
=
{
0x2b
,
0x7e
,
0x15
,
0x16
,
0x28
,
0xae
,
0xd2
,
0xa6
,
0xab
,
0xf7
,
0x15
,
0x88
,
0x09
,
0xcf
,
0x4f
,
0x3c
};
uint8_t
in
[]
=
{
0x3a
,
0xd7
,
0x7b
,
0xb4
,
0x0d
,
0x7a
,
0x36
,
0x60
,
0xa8
,
0x9e
,
0xca
,
0xf3
,
0x24
,
0x66
,
0xef
,
0x97
};
uint8_t
out
[]
=
{
0x6b
,
0xc1
,
0xbe
,
0xe2
,
0x2e
,
0x40
,
0x9f
,
0x96
,
0xe9
,
0x3d
,
0x7e
,
0x11
,
0x73
,
0x93
,
0x17
,
0x2a
};
uint8_t
buffer
[
16
];
AES128_ECB_decrypt
(
in
,
key
,
buffer
);
printf
(
"decrypt: "
);
if
(
0
==
strncmp
(
out
,
buffer
,
16
))
{
printf
(
"SUCCESS!
\n
"
);
}
else
{
printf
(
"FAILURE!
\n
"
);
}
}
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