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
52afbab2
Commit
52afbab2
authored
Jun 05, 2017
by
Matteo Brichese
Browse files
cleaning up
parent
92c072c7
Changes
2
Show whitespace changes
Inline
Side-by-side
aes.h
View file @
52afbab2
...
@@ -18,6 +18,8 @@
...
@@ -18,6 +18,8 @@
#define ECB 1
#define ECB 1
#endif
#endif
#define AES128
#if defined(ECB) && ECB
#if defined(ECB) && ECB
...
...
test.c
View file @
52afbab2
...
@@ -74,7 +74,7 @@ static void test_encrypt_ecb_verbose(void)
...
@@ -74,7 +74,7 @@ static void test_encrypt_ecb_verbose(void)
printf
(
"ciphertext:
\n
"
);
printf
(
"ciphertext:
\n
"
);
for
(
i
=
0
;
i
<
4
;
++
i
)
for
(
i
=
0
;
i
<
4
;
++
i
)
{
{
AES
128
_ECB_encrypt
(
plain_text
+
(
i
*
16
),
key
,
buf
+
(
i
*
16
));
AES_ECB_encrypt
(
plain_text
+
(
i
*
16
),
key
,
buf
+
(
i
*
16
)
,
16
);
phex
(
buf
+
(
i
*
16
));
phex
(
buf
+
(
i
*
16
));
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
@@ -88,7 +88,7 @@ static void test_encrypt_ecb(void)
...
@@ -88,7 +88,7 @@ static void test_encrypt_ecb(void)
uint8_t
out
[]
=
{
0x3a
,
0xd7
,
0x7b
,
0xb4
,
0x0d
,
0x7a
,
0x36
,
0x60
,
0xa8
,
0x9e
,
0xca
,
0xf3
,
0x24
,
0x66
,
0xef
,
0x97
};
uint8_t
out
[]
=
{
0x3a
,
0xd7
,
0x7b
,
0xb4
,
0x0d
,
0x7a
,
0x36
,
0x60
,
0xa8
,
0x9e
,
0xca
,
0xf3
,
0x24
,
0x66
,
0xef
,
0x97
};
uint8_t
buffer
[
16
];
uint8_t
buffer
[
16
];
AES
128
_ECB_encrypt
(
in
,
key
,
buffer
);
AES_ECB_encrypt
(
in
,
key
,
buffer
,
16
);
printf
(
"ECB decrypt: "
);
printf
(
"ECB decrypt: "
);
...
@@ -118,10 +118,10 @@ static void test_decrypt_cbc(void)
...
@@ -118,10 +118,10 @@ static void test_decrypt_cbc(void)
0xf6
,
0x9f
,
0x24
,
0x45
,
0xdf
,
0x4f
,
0x9b
,
0x17
,
0xad
,
0x2b
,
0x41
,
0x7b
,
0xe6
,
0x6c
,
0x37
,
0x10
};
0xf6
,
0x9f
,
0x24
,
0x45
,
0xdf
,
0x4f
,
0x9b
,
0x17
,
0xad
,
0x2b
,
0x41
,
0x7b
,
0xe6
,
0x6c
,
0x37
,
0x10
};
uint8_t
buffer
[
64
];
uint8_t
buffer
[
64
];
AES
128
_CBC_decrypt_buffer
(
buffer
+
0
,
in
+
0
,
16
,
key
,
iv
);
AES_CBC_decrypt_buffer
(
buffer
+
0
,
in
+
0
,
16
,
key
,
iv
);
AES
128
_CBC_decrypt_buffer
(
buffer
+
16
,
in
+
16
,
16
,
0
,
0
);
AES_CBC_decrypt_buffer
(
buffer
+
16
,
in
+
16
,
16
,
0
,
0
);
AES
128
_CBC_decrypt_buffer
(
buffer
+
32
,
in
+
32
,
16
,
0
,
0
);
AES_CBC_decrypt_buffer
(
buffer
+
32
,
in
+
32
,
16
,
0
,
0
);
AES
128
_CBC_decrypt_buffer
(
buffer
+
48
,
in
+
48
,
16
,
0
,
0
);
AES_CBC_decrypt_buffer
(
buffer
+
48
,
in
+
48
,
16
,
0
,
0
);
printf
(
"CBC decrypt: "
);
printf
(
"CBC decrypt: "
);
...
@@ -149,7 +149,7 @@ static void test_encrypt_cbc(void)
...
@@ -149,7 +149,7 @@ static void test_encrypt_cbc(void)
0x3f
,
0xf1
,
0xca
,
0xa1
,
0x68
,
0x1f
,
0xac
,
0x09
,
0x12
,
0x0e
,
0xca
,
0x30
,
0x75
,
0x86
,
0xe1
,
0xa7
};
0x3f
,
0xf1
,
0xca
,
0xa1
,
0x68
,
0x1f
,
0xac
,
0x09
,
0x12
,
0x0e
,
0xca
,
0x30
,
0x75
,
0x86
,
0xe1
,
0xa7
};
uint8_t
buffer
[
64
];
uint8_t
buffer
[
64
];
AES
128
_CBC_encrypt_buffer
(
buffer
,
in
,
64
,
key
,
iv
);
AES_CBC_encrypt_buffer
(
buffer
,
in
,
64
,
key
,
iv
);
printf
(
"CBC encrypt: "
);
printf
(
"CBC encrypt: "
);
...
@@ -171,7 +171,7 @@ static void test_decrypt_ecb(void)
...
@@ -171,7 +171,7 @@ static void test_decrypt_ecb(void)
uint8_t
out
[]
=
{
0x6b
,
0xc1
,
0xbe
,
0xe2
,
0x2e
,
0x40
,
0x9f
,
0x96
,
0xe9
,
0x3d
,
0x7e
,
0x11
,
0x73
,
0x93
,
0x17
,
0x2a
};
uint8_t
out
[]
=
{
0x6b
,
0xc1
,
0xbe
,
0xe2
,
0x2e
,
0x40
,
0x9f
,
0x96
,
0xe9
,
0x3d
,
0x7e
,
0x11
,
0x73
,
0x93
,
0x17
,
0x2a
};
uint8_t
buffer
[
16
];
uint8_t
buffer
[
16
];
AES
128
_ECB_decrypt
(
in
,
key
,
buffer
);
AES_ECB_decrypt
(
in
,
key
,
buffer
,
16
);
printf
(
"ECB decrypt: "
);
printf
(
"ECB decrypt: "
);
...
@@ -185,4 +185,3 @@ static void test_decrypt_ecb(void)
...
@@ -185,4 +185,3 @@ static void test_decrypt_ecb(void)
}
}
}
}
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