|
SWE-350 TOTP Generator Milestone 5
The DE-10 board has six 7-segment displays, this can be used to display and generate a time based one-time pin (TOTP).
|
#include "randomKey.h"#include <ctype.h>#include <stdint.h>#include <stdio.h>#include <string.h>#include <time.h>#include <assert.h>
Go to the source code of this file.
Functions | |
| int | get_base32_value (char letter) |
| Returns the int value (1-32) of a character. | |
| void | generateStringKey (char *keyString, int length) |
| Generates a full string of random characters. | |
| int | get_base32_value2 (char c) |
| uint8_t * | base32_decode2 (const char *input, size_t *output_len) |
| Decodes a Base32-encoded string into a binary byte array. | |
| uint8_t * | cloneArray (const uint8_t *original, size_t length) |
| Function to clone a uint8_t array. | |
| void | test_get_base32_value () |
| int | testRandomKey () |
| uint8_t * base32_decode2 | ( | const char * | input, |
| size_t * | output_len ) |
Decodes a Base32-encoded string into a binary byte array.
The following was written by Chat-GPT 4o, Nov 30, 2024 This function converts a Base32-encoded string into its binary representation. It expects the input to be valid Base32 characters. If the input contains invalid characters, it prints an error message and returns NULL.
| input | A null-terminated string containing the Base32-encoded data. |
| output_len | A pointer to a size_t variable where the function will store the length of the decoded binary data. |
NULL if memory allocation fails or if invalid input is detected. Definition at line 128 of file randomKey.c.


| uint8_t * cloneArray | ( | const uint8_t * | original, |
| size_t | length ) |
Function to clone a uint8_t array.
The following was written by Chat-GPT 4o, Nov 30, 2024 This function allocates memory for a new array and copies the contents of the original array into it. The size of the array to be cloned is specified by the length parameter.
| original | A pointer to the original array to be cloned. |
| length | The number of elements (bytes) in the original array. |
NULL if memory allocation fails. Definition at line 176 of file randomKey.c.
| void generateStringKey | ( | char * | keyString, |
| int | length ) |
Generates a full string of random characters.
| keyString | Pointer for the string to hold the key |
| length | Length of the key, 32 when used here. |
Generates a random key of a certain length and outputs it to a string pointer.
Definition at line 82 of file randomKey.c.

| int get_base32_value | ( | char | letter | ) |
Returns the int value (1-32) of a character.
| letter | A single character |
Internal only
Definition at line 57 of file randomKey.c.

| int get_base32_value2 | ( | char | c | ) |
| void test_get_base32_value | ( | ) |
Definition at line 193 of file randomKey.c.


| int testRandomKey | ( | ) |
Definition at line 209 of file randomKey.c.

