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).
Loading...
Searching...
No Matches
randomKey.h File Reference
#include <stdint.h>
#include <stdio.h>
Include dependency graph for randomKey.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void generateStringKey (char *keyString, int length)
 Generates a full string of random characters.
 
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.
 
int testRandomKey ()
 

Function Documentation

◆ base32_decode2()

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.

Parameters
inputA null-terminated string containing the Base32-encoded data.
output_lenA pointer to a size_t variable where the function will store the length of the decoded binary data.
Returns
A pointer to the decoded binary data as a dynamically allocated array. The caller is responsible for freeing the memory. Returns NULL if memory allocation fails or if invalid input is detected.

Definition at line 128 of file randomKey.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cloneArray()

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.

Parameters
originalA pointer to the original array to be cloned.
lengthThe number of elements (bytes) in the original array.
Returns
A pointer to the newly allocated array containing the copied data. Returns NULL if memory allocation fails.

Definition at line 176 of file randomKey.c.

◆ generateStringKey()

void generateStringKey ( char * keyString,
int length )

Generates a full string of random characters.

Parameters
keyStringPointer for the string to hold the key
lengthLength 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.

Here is the caller graph for this function:

◆ testRandomKey()

int testRandomKey ( )

Definition at line 209 of file randomKey.c.

Here is the call graph for this function:
Here is the caller graph for this function: