diff options
author | kokke <spam@rowdy.dk> | 2019-02-22 09:23:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-22 09:23:16 +0100 |
commit | 4b4b04b8fa87ca35fdf681fca20777ee8a16e93f (patch) | |
tree | 2a0e4188f2235c1a38f52f36eea02f9ef75247e4 /aes.c | |
parent | Merge pull request #124 from torfinnberset/master (diff) | |
parent | Update README (diff) | |
download | tiny-AES-c-4b4b04b8fa87ca35fdf681fca20777ee8a16e93f.tar tiny-AES-c-4b4b04b8fa87ca35fdf681fca20777ee8a16e93f.tar.gz tiny-AES-c-4b4b04b8fa87ca35fdf681fca20777ee8a16e93f.tar.bz2 tiny-AES-c-4b4b04b8fa87ca35fdf681fca20777ee8a16e93f.tar.lz tiny-AES-c-4b4b04b8fa87ca35fdf681fca20777ee8a16e93f.tar.xz tiny-AES-c-4b4b04b8fa87ca35fdf681fca20777ee8a16e93f.tar.zst tiny-AES-c-4b4b04b8fa87ca35fdf681fca20777ee8a16e93f.zip |
Diffstat (limited to '')
-rw-r--r-- | aes.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -240,7 +240,7 @@ void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv) // This function adds the round key to state. // The round key is added to the state by an XOR function. -static void AddRoundKey(uint8_t round,state_t* state,uint8_t* RoundKey) +static void AddRoundKey(uint8_t round, state_t* state, const uint8_t* RoundKey) { uint8_t i,j; for (i = 0; i < 4; ++i) @@ -408,7 +408,7 @@ static void InvShiftRows(state_t* state) #endif // #if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1) // Cipher is the main function that encrypts the PlainText. -static void Cipher(state_t* state, uint8_t* RoundKey) +static void Cipher(state_t* state, const uint8_t* RoundKey) { uint8_t round = 0; @@ -434,7 +434,7 @@ static void Cipher(state_t* state, uint8_t* RoundKey) } #if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1) -static void InvCipher(state_t* state,uint8_t* RoundKey) +static void InvCipher(state_t* state, const uint8_t* RoundKey) { uint8_t round = 0; @@ -466,13 +466,13 @@ static void InvCipher(state_t* state,uint8_t* RoundKey) #if defined(ECB) && (ECB == 1) -void AES_ECB_encrypt(struct AES_ctx *ctx, uint8_t* buf) +void AES_ECB_encrypt(const struct AES_ctx *ctx, uint8_t* buf) { // The next function call encrypts the PlainText with the Key using AES algorithm. Cipher((state_t*)buf, ctx->RoundKey); } -void AES_ECB_decrypt(struct AES_ctx* ctx, uint8_t* buf) +void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf) { // The next function call decrypts the PlainText with the Key using AES algorithm. InvCipher((state_t*)buf, ctx->RoundKey); @@ -488,7 +488,7 @@ void AES_ECB_decrypt(struct AES_ctx* ctx, uint8_t* buf) #if defined(CBC) && (CBC == 1) -static void XorWithIv(uint8_t* buf, uint8_t* Iv) +static void XorWithIv(uint8_t* buf, const uint8_t* Iv) { uint8_t i; for (i = 0; i < AES_BLOCKLEN; ++i) // The block in AES is always 128bit no matter the key size @@ -497,7 +497,7 @@ static void XorWithIv(uint8_t* buf, 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, uint32_t length) { uintptr_t i; uint8_t *Iv = ctx->Iv; @@ -552,9 +552,9 @@ void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length) /* Increment Iv and handle overflow */ for (bi = (AES_BLOCKLEN - 1); bi >= 0; --bi) { - /* inc will owerflow */ + /* inc will overflow */ if (ctx->Iv[bi] == 255) - { + { ctx->Iv[bi] = 0; continue; } |