Skip to content

aes.h #6

@SleepTheGod

Description

@SleepTheGod

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 */

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions