Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix potential write to read only memory #21

Merged
merged 3 commits into from Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion tgcrypto/aes256.h
Expand Up @@ -32,7 +32,7 @@
#define LROTR(x) (((x) >> 8) | ((x) << 24))
#define SWAP(x) ((LROTL((x)) & 0x00ff00ff) | (LROTR((x)) & 0xff00ff00))
#define GET(p) SWAP(*((uint32_t *)(p)))
#define PUT(ct, st) {*((uint32_t *)(ct)) = SWAP((st));}
#define PUT(ct, st) {*((uint32_t *)(ct)) = SWAP((st));} (void)0
Wirtos marked this conversation as resolved.
Show resolved Hide resolved

void aes256_set_encryption_key(const uint8_t key[32], uint32_t expandedKey[60]);

Expand Down
2 changes: 1 addition & 1 deletion tgcrypto/cbc256.h
Expand Up @@ -21,6 +21,6 @@
#ifndef CBC256_H
#define CBC256_H

uint8_t *cbc256(const uint8_t in[], uint32_t length, const uint8_t key[32], const uint8_t iv[16], uint8_t encrypt);
uint8_t *cbc256(const uint8_t in[], uint32_t length, const uint8_t key[32], uint8_t iv[16], uint8_t encrypt);

#endif // CBC256_H
3 changes: 2 additions & 1 deletion tgcrypto/ctr256.c
Expand Up @@ -41,7 +41,8 @@ uint8_t *ctr256(const uint8_t in[], uint32_t length, const uint8_t key[32], uint
*state = 0;

if (*state == 0) {
for (k = AES_BLOCK_SIZE - 1; k >= 0; --k)
k = AES_BLOCK_SIZE;
while(k--)
Wirtos marked this conversation as resolved.
Show resolved Hide resolved
if (++iv[k])
break;

Expand Down
2 changes: 1 addition & 1 deletion tgcrypto/ctr256.h
Expand Up @@ -21,6 +21,6 @@
#ifndef CTR256_H
#define CTR256_H

uint8_t *ctr256(const uint8_t in[], uint32_t length, const uint8_t key[32], const uint8_t iv[16], uint8_t *state);
uint8_t *ctr256(const uint8_t in[], uint32_t length, const uint8_t key[32], uint8_t iv[16], uint8_t *state);

#endif // CTR256_H