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
c3b7532b
Unverified
Commit
c3b7532b
authored
Jan 06, 2021
by
kokke
Committed by
GitHub
Jan 06, 2021
Browse files
Merge pull request #173 from Youw/master
use size_t for buffer size and its indexes
parents
7279b02a
2ca3e81f
Changes
2
Hide whitespace changes
Inline
Side-by-side
aes.c
View file @
c3b7532b
...
...
@@ -498,9 +498,9 @@ static void XorWithIv(uint8_t* buf, const uint8_t* Iv)
}
}
void
AES_CBC_encrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
uint32
_t
length
)
void
AES_CBC_encrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
size
_t
length
)
{
uintptr
_t
i
;
size
_t
i
;
uint8_t
*
Iv
=
ctx
->
Iv
;
for
(
i
=
0
;
i
<
length
;
i
+=
AES_BLOCKLEN
)
{
...
...
@@ -513,9 +513,9 @@ void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t* buf, uint32_t length)
memcpy
(
ctx
->
Iv
,
Iv
,
AES_BLOCKLEN
);
}
void
AES_CBC_decrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
uint32
_t
length
)
void
AES_CBC_decrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
size
_t
length
)
{
uintptr
_t
i
;
size
_t
i
;
uint8_t
storeNextIv
[
AES_BLOCKLEN
];
for
(
i
=
0
;
i
<
length
;
i
+=
AES_BLOCKLEN
)
{
...
...
@@ -535,11 +535,11 @@ void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length)
#if defined(CTR) && (CTR == 1)
/* Symmetrical operation: same function for encrypting as for decrypting. Note any IV/nonce should never be reused with the same key */
void
AES_CTR_xcrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
uint32
_t
length
)
void
AES_CTR_xcrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
size
_t
length
)
{
uint8_t
buffer
[
AES_BLOCKLEN
];
unsigned
i
;
size_t
i
;
int
bi
;
for
(
i
=
0
,
bi
=
AES_BLOCKLEN
;
i
<
length
;
++
i
,
++
bi
)
{
...
...
aes.h
View file @
c3b7532b
...
...
@@ -69,8 +69,8 @@ void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
// Suggest https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme
// NOTES: you need to set IV in ctx via AES_init_ctx_iv() or AES_ctx_set_iv()
// no IV should ever be reused with the same key
void
AES_CBC_encrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
uint32
_t
length
);
void
AES_CBC_decrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
uint32
_t
length
);
void
AES_CBC_encrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
size
_t
length
);
void
AES_CBC_decrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
size
_t
length
);
#endif // #if defined(CBC) && (CBC == 1)
...
...
@@ -82,7 +82,7 @@ void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length);
// Suggesting https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme
// NOTES: you need to set IV in ctx with AES_init_ctx_iv() or AES_ctx_set_iv()
// no IV should ever be reused with the same key
void
AES_CTR_xcrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
uint32
_t
length
);
void
AES_CTR_xcrypt_buffer
(
struct
AES_ctx
*
ctx
,
uint8_t
*
buf
,
size
_t
length
);
#endif // #if defined(CTR) && (CTR == 1)
...
...
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