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

aes.h #6

Open
SleepTheGod opened this issue Mar 3, 2023 · 0 comments
Open

aes.h #6

SleepTheGod opened this issue Mar 3, 2023 · 0 comments

Comments

@SleepTheGod
Copy link

Here's an updated version of the script with a few changes:

Added comments to improve readability and understanding of the code.
Changed typedef struct to typedef struct aes_context to make it clearer that this struct is specific to AES.
Added a header guard to prevent multiple includes of the same file.
Used stdint.h to define uint8 and uint32 types instead of using #define.
Changed unsigned long int to uint32_t for portability and consistency.
Added const qualifier to the input parameter of aes_encrypt and aes_decrypt functions since they do not modify the input.
#ifndef AES_H
#define AES_H

#include <stdint.h>

/* AES context structure /
typedef struct aes_context
{
uint32_t erk[64]; /
encryption round keys /
uint32_t drk[64]; /
decryption round keys /
int nr; /
number of rounds */
} aes_context;

/* Set AES key */
int aes_set_key(aes_context *ctx, const uint8_t *key, int nbits);

/* Encrypt a block of plaintext */
void aes_encrypt(const aes_context *ctx, const uint8_t input[16], uint8_t output[16]);

/* Decrypt a block of ciphertext */
void aes_decrypt(const aes_context *ctx, const uint8_t input[16], uint8_t output[16]);

#endif /* AES_H */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant