repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
teddycloud | github_2023 | toniebox-reverse-engineering | c | osCreateTask | OsTaskId osCreateTask(const char_t *name, OsTaskCode taskCode,
void *param, size_t stackSize, int_t priority)
{
void *handle;
//Create a new thread
handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) taskCode,
param, 0, NULL);
WCHAR wname[128];
MultiByteToWideChar(CP_ACP, 0, name, -1, wnam... | /**
* @brief Create a task
* @param[in] name A name identifying the task
* @param[in] taskCode Pointer to the task entry function
* @param[in] param A pointer to a variable to be passed to the task
* @param[in] stackSize The initial size of the stack, in words
* @param[in] priority The priority at which the task ... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L79-L94 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osDeleteTask | void osDeleteTask(OsTaskId taskId)
{
//Delete the calling thread?
if(taskId == OS_SELF_TASK_ID)
{
//Kill ourselves
ExitThread(0);
}
else
{
//Delete the specified thread
TerminateThread((HANDLE) taskId, 0);
}
} | /**
* @brief Delete a task
* @param[in] taskId Task identifier referencing the task to be deleted
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L102-L115 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osDelayTask | void osDelayTask(systime_t delay)
{
//Delay the task for the specified duration
Sleep(delay);
} | /**
* @brief Delay routine
* @param[in] delay Amount of time for which the calling task should block
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L123-L127 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osSwitchTask | void osSwitchTask(void)
{
//Not implemented
} | /**
* @brief Yield control to the next task
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L134-L137 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osSuspendAllTasks | void osSuspendAllTasks(void)
{
if (!isCritSecInitialized)
{
InitializeCriticalSection(&critSec);
isCritSecInitialized = true;
}
EnterCriticalSection(&critSec);
} | /**
* @brief Suspend scheduler activity
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L147-L156 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osResumeAllTasks | void osResumeAllTasks(void)
{
if (!isCritSecInitialized)
{
InitializeCriticalSection(&critSec);
isCritSecInitialized = true;
return;
}
LeaveCriticalSection(&critSec);
} | /**
* @brief Resume scheduler activity
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L163-L173 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osCreateEvent | bool_t osCreateEvent(OsEvent *event)
{
//Create an event object
event->handle = CreateEvent(NULL, FALSE, FALSE, NULL);
//Check whether the returned handle is valid
if(event->handle != NULL)
{
return TRUE;
}
else
{
return FALSE;
}
} | /**
* @brief Create an event object
* @param[in] event Pointer to the event object
* @return The function returns TRUE if the event object was successfully
* created. Otherwise, FALSE is returned
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L183-L197 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osDeleteEvent | void osDeleteEvent(OsEvent *event)
{
//Make sure the handle is valid
if(event->handle != NULL)
{
//Properly dispose the event object
CloseHandle(event->handle);
}
} | /**
* @brief Delete an event object
* @param[in] event Pointer to the event object
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L205-L213 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osSetEvent | void osSetEvent(OsEvent *event)
{
//Set the specified event to the signaled state
SetEvent(event->handle);
} | /**
* @brief Set the specified event object to the signaled state
* @param[in] event Pointer to the event object
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L221-L225 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osResetEvent | void osResetEvent(OsEvent *event)
{
//Force the specified event to the nonsignaled state
ResetEvent(event->handle);
} | /**
* @brief Set the specified event object to the nonsignaled state
* @param[in] event Pointer to the event object
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L233-L237 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osWaitForEvent | bool_t osWaitForEvent(OsEvent *event, systime_t timeout)
{
//Wait until the specified event is in the signaled state or the timeout
//interval elapses
if(WaitForSingleObject(event->handle, timeout) == WAIT_OBJECT_0)
{
return TRUE;
}
else
{
return FALSE;
}
} | /**
* @brief Wait until the specified event is in the signaled state
* @param[in] event Pointer to the event object
* @param[in] timeout Timeout interval
* @return The function returns TRUE if the state of the specified object is
* signaled. FALSE is returned if the timeout interval elapsed
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L248-L260 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osSetEventFromIsr | bool_t osSetEventFromIsr(OsEvent *event)
{
//Not implemented
return FALSE;
} | /**
* @brief Set an event object to the signaled state from an interrupt service routine
* @param[in] event Pointer to the event object
* @return TRUE if setting the event to signaled state caused a task to unblock
* and the unblocked task has a priority higher than the currently running task
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L270-L274 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osCreateSemaphore | bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
{
//Create a semaphore object
semaphore->handle = CreateSemaphore(NULL, count, count, NULL);
//Check whether the returned handle is valid
if(semaphore->handle != NULL)
{
return TRUE;
}
else
{
return FALSE;
}
} | /**
* @brief Create a semaphore object
* @param[in] semaphore Pointer to the semaphore object
* @param[in] count The maximum count for the semaphore object. This value
* must be greater than zero
* @return The function returns TRUE if the semaphore was successfully
* created. Otherwise, FALSE is returned
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L286-L300 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osDeleteSemaphore | void osDeleteSemaphore(OsSemaphore *semaphore)
{
//Make sure the handle is valid
if(semaphore->handle != NULL)
{
//Properly dispose the semaphore object
CloseHandle(semaphore->handle);
}
} | /**
* @brief Delete a semaphore object
* @param[in] semaphore Pointer to the semaphore object
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L308-L316 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osWaitForSemaphore | bool_t osWaitForSemaphore(OsSemaphore *semaphore, systime_t timeout)
{
//Wait until the specified semaphore becomes available
if(WaitForSingleObject(semaphore->handle, timeout) == WAIT_OBJECT_0)
{
return TRUE;
}
else
{
return FALSE;
}
} | /**
* @brief Wait for the specified semaphore to be available
* @param[in] semaphore Pointer to the semaphore object
* @param[in] timeout Timeout interval
* @return The function returns TRUE if the semaphore is available. FALSE is
* returned if the timeout interval elapsed
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L327-L338 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osReleaseSemaphore | void osReleaseSemaphore(OsSemaphore *semaphore)
{
//Release the semaphore
ReleaseSemaphore(semaphore->handle, 1, NULL);
} | /**
* @brief Release the specified semaphore object
* @param[in] semaphore Pointer to the semaphore object
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L346-L350 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osCreateMutex | bool_t osCreateMutex(OsMutex *mutex)
{
//Create a mutex object
mutex->handle = CreateMutex(NULL, FALSE, NULL);
//Check whether the returned handle is valid
if(mutex->handle != NULL)
{
return TRUE;
}
else
{
return FALSE;
}
} | /**
* @brief Create a mutex object
* @param[in] mutex Pointer to the mutex object
* @return The function returns TRUE if the mutex was successfully
* created. Otherwise, FALSE is returned
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L360-L374 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osDeleteMutex | void osDeleteMutex(OsMutex *mutex)
{
//Make sure the handle is valid
if(mutex->handle != NULL)
{
//Properly dispose the mutex object
CloseHandle(mutex->handle);
}
} | /**
* @brief Delete a mutex object
* @param[in] mutex Pointer to the mutex object
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L382-L390 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osAcquireMutex | void osAcquireMutex(OsMutex *mutex)
{
//Obtain ownership of the mutex object
WaitForSingleObject(mutex->handle, INFINITE);
} | /**
* @brief Acquire ownership of the specified mutex object
* @param[in] mutex Pointer to the mutex object
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L398-L402 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osReleaseMutex | void osReleaseMutex(OsMutex *mutex)
{
//Release ownership of the mutex object
ReleaseMutex(mutex->handle);
} | /**
* @brief Release ownership of the specified mutex object
* @param[in] mutex Pointer to the mutex object
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L410-L414 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osGetSystemTime | systime_t osGetSystemTime(void)
{
//Get current tick count
return GetTickCount();
} | /**
* @brief Retrieve system time
* @return Number of milliseconds elapsed since the system was last started
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L422-L426 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | osFreeMem | __weak_func void osFreeMem(void *p)
{
//Free memory block
free(p);
} | /**
* @brief Release a previously allocated memory block
* @param[in] p Previously allocated memory block to be freed
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/common/os_port_windows.c#L448-L452 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiInit | void mpiInit(Mpi *r)
{
// Initialize structure
r->sign = 1;
r->size = 0;
r->data = NULL;
} | /**
* @brief Initialize a multiple precision integer
* @param[in,out] r Pointer to the multiple precision integer to be initialized
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L51-L57 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiFree | void mpiFree(Mpi *r)
{
// Any memory previously allocated?
if (r->data != NULL)
{
// Erase contents before releasing memory
osMemset(r->data, 0, r->size * MPI_INT_SIZE);
cryptoFreeMem(r->data);
}
// Set size to zero
r->size = 0;
r->data = NULL;
} | /**
* @brief Release a multiple precision integer
* @param[in,out] r Pointer to the multiple precision integer to be freed
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L64-L77 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiGrow | error_t mpiGrow(Mpi *r, uint_t size)
{
uint_t *data;
// Ensure the parameter is valid
size = MAX(size, 1);
// Check the current size
if (r->size >= size)
return NO_ERROR;
// Allocate a memory buffer
data = cryptoAllocMem(size * MPI_INT_SIZE);
// Failed to allocate memory?
if (data ==... | /**
* @brief Adjust the size of multiple precision integer
* @param[in,out] r A multiple precision integer whose size is to be increased
* @param[in] size Desired size in words
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L86-L121 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiGetLength | uint_t mpiGetLength(const Mpi *a)
{
int_t i;
// Check whether the specified multiple precision integer is empty
if (a->size == 0)
return 0;
// Start from the most significant word
for (i = a->size - 1; i >= 0; i--)
{
// Loop as long as the current word is zero
if (a->data[i] != 0)
... | /**
* @brief Get the actual length in words
* @param[in] a Pointer to a multiple precision integer
* @return The actual length in words
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L129-L147 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiGetByteLength | uint_t mpiGetByteLength(const Mpi *a)
{
uint_t n;
uint32_t m;
// Check whether the specified multiple precision integer is empty
if (a->size == 0)
return 0;
// Start from the most significant word
for (n = a->size - 1; n > 0; n--)
{
// Loop as long as the current word is zero
if... | /**
* @brief Get the actual length in bytes
* @param[in] a Pointer to a multiple precision integer
* @return The actual byte count
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L155-L185 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiGetBitLength | uint_t mpiGetBitLength(const Mpi *a)
{
uint_t n;
uint32_t m;
// Check whether the specified multiple precision integer is empty
if (a->size == 0)
return 0;
// Start from the most significant word
for (n = a->size - 1; n > 0; n--)
{
// Loop as long as the current word is zero
if ... | /**
* @brief Get the actual length in bits
* @param[in] a Pointer to a multiple precision integer
* @return The actual bit count
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L193-L223 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiSetBitValue | error_t mpiSetBitValue(Mpi *r, uint_t index, uint_t value)
{
error_t error;
uint_t n1;
uint_t n2;
// Retrieve the position of the bit to be written
n1 = index / (MPI_INT_SIZE * 8);
n2 = index % (MPI_INT_SIZE * 8);
// Ajust the size of the multiple precision integer if necessary
error = mpiGrow... | /**
* @brief Set the bit value at the specified index
* @param[in] r Pointer to a multiple precision integer
* @param[in] index Position of the bit to be written
* @param[in] value Bit value
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L233-L257 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiGetBitValue | uint_t mpiGetBitValue(const Mpi *a, uint_t index)
{
uint_t n1;
uint_t n2;
// Retrieve the position of the bit to be read
n1 = index / (MPI_INT_SIZE * 8);
n2 = index % (MPI_INT_SIZE * 8);
// Index out of range?
if (n1 >= a->size)
return 0;
// Return the actual bit value
return (a->dat... | /**
* @brief Get the bit value at the specified index
* @param[in] a Pointer to a multiple precision integer
* @param[in] index Position where to read the bit
* @return The actual bit value
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L266-L281 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiComp | int_t mpiComp(const Mpi *a, const Mpi *b)
{
uint_t m;
uint_t n;
// Determine the actual length of A and B
m = mpiGetLength(a);
n = mpiGetLength(b);
// Compare lengths
if (!m && !n)
return 0;
else if (m > n)
return a->sign;
else if (m < n)
return -b->sign;
// Compare si... | /**
* @brief Compare two multiple precision integers
* @param[in] a The first multiple precision integer to be compared
* @param[in] b The second multiple precision integer to be compared
* @return Comparison result
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L290-L324 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiCompInt | int_t mpiCompInt(const Mpi *a, int_t b)
{
uint_t value;
Mpi t;
// Initialize a temporary multiple precision integer
value = (b >= 0) ? b : -b;
t.sign = (b >= 0) ? 1 : -1;
t.size = 1;
t.data = &value;
// Return comparison result
return mpiComp(a, &t);
} | /**
* @brief Compare a multiple precision integer with an integer
* @param[in] a Multiple precision integer to be compared
* @param[in] b Integer to be compared
* @return Comparison result
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L333-L346 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiCompAbs | int_t mpiCompAbs(const Mpi *a, const Mpi *b)
{
uint_t m;
uint_t n;
// Determine the actual length of A and B
m = mpiGetLength(a);
n = mpiGetLength(b);
// Compare lengths
if (!m && !n)
return 0;
else if (m > n)
return 1;
else if (m < n)
return -1;
// Then compare values... | /**
* @brief Compare the absolute value of two multiple precision integers
* @param[in] a The first multiple precision integer to be compared
* @param[in] b The second multiple precision integer to be compared
* @return Comparison result
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L355-L383 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiCopy | error_t mpiCopy(Mpi *r, const Mpi *a)
{
error_t error;
uint_t n;
// R and A are the same instance?
if (r == a)
return NO_ERROR;
// Determine the actual length of A
n = mpiGetLength(a);
// Ajust the size of the destination operand
error = mpiGrow(r, n);
// Any error to report?
if (... | /**
* @brief Copy a multiple precision integer
* @param[out] r Pointer to a multiple precision integer (destination)
* @param[in] a Pointer to a multiple precision integer (source)
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L392-L419 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiSetValue | error_t mpiSetValue(Mpi *r, int_t a)
{
error_t error;
// Ajust the size of the destination operand
error = mpiGrow(r, 1);
// Failed to adjust the size?
if (error)
return error;
// Clear the contents of the multiple precision integer
osMemset(r->data, 0, r->size * MPI_INT_SIZE);
// Set th... | /**
* @brief Set the value of a multiple precision integer
* @param[out] r Pointer to a multiple precision integer
* @param[in] a Value to be assigned to the multiple precision integer
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L428-L447 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiRand | error_t mpiRand(Mpi *r, uint_t length, const PrngAlgo *prngAlgo,
void *prngContext)
{
error_t error;
uint_t m;
uint_t n;
// Compute the required length, in words
n = (length + (MPI_INT_SIZE * 8) - 1) / (MPI_INT_SIZE * 8);
// Number of bits in the most significant word
m = length % ... | /**
* @brief Generate a random value
* @param[out] r Pointer to a multiple precision integer
* @param[in] length Desired length in bits
* @param[in] prngAlgo PRNG algorithm
* @param[in] prngContext Pointer to the PRNG context
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L458-L495 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiRandRange | error_t mpiRandRange(Mpi *r, const Mpi *p, const PrngAlgo *prngAlgo,
void *prngContext)
{
error_t error;
uint_t n;
Mpi a;
// Make sure p is greater than 1
if (mpiCompInt(p, 1) <= 0)
return ERROR_INVALID_PARAMETER;
// Initialize multiple precision integer
mpiInit(&a);
... | /**
* @brief Generate a random value in the range 1 to p-1
* @param[out] r Pointer to a multiple precision integer
* @param[in] p The upper bound of the range
* @param[in] prngAlgo PRNG algorithm
* @param[in] prngContext Pointer to the PRNG context
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L506-L538 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiCheckProbablePrimeWorker | bool mpiCheckProbablePrimeWorker(const Mpi *n, int k, const PrngAlgo *prngAlgo, void *prngContext)
{
bool ret = false;
/* keep Mpi numbers initialized outside loop */
Mpi randRange;
Mpi num1;
Mpi num2;
Mpi x2;
Mpi a;
Mpi rnd;
Mpi x;
Mpi m;
Mpi n1;
Mpi sShifted;
Mpi d;
mpiInit... | /* https://github.com/cslarsen/miller-rabin */ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L541-L642 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiCheckProbablePrime | __weak_func error_t mpiCheckProbablePrime(const Mpi *a)
{
uint_t k;
size_t n;
// Retrieve the length of the input integer, in bits
n = mpiGetBitLength(a);
// Prime numbers of a size lower than 96 bits cannot be tested by this
// service
if (n < 96)
return ERROR_INVALID_LENGTH;
// The nu... | /**
* @brief Test whether a number is probable prime
* @param[in] a Pointer to a multiple precision integer
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L650-L720 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiImport | error_t mpiImport(Mpi *r, const uint8_t *data, uint_t length, MpiFormat format)
{
error_t error;
uint_t i;
// Check input format
if (format == MPI_FORMAT_LITTLE_ENDIAN)
{
// Skip trailing zeroes
while (length > 0 && data[length - 1] == 0)
{
length--;
}
// Ajust th... | /**
* @brief Octet string to integer conversion
*
* Converts an octet string to a non-negative integer
*
* @param[out] r Non-negative integer resulting from the conversion
* @param[in] data Octet string to be converted
* @param[in] length Length of the octet string
* @param[in] format Input format
* @return Er... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L734-L804 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiExport | error_t mpiExport(const Mpi *a, uint8_t *data, uint_t length, MpiFormat format)
{
uint_t i;
uint_t n;
error_t error;
// Initialize status code
error = NO_ERROR;
// Check input format
if (format == MPI_FORMAT_LITTLE_ENDIAN)
{
// Get the actual length in bytes
n = mpiGetByteLength(a)... | /**
* @brief Integer to octet string conversion
*
* Converts an integer to an octet string of a specified length
*
* @param[in] a Non-negative integer to be converted
* @param[out] data Octet string resulting from the conversion
* @param[in] length Intended length of the resulting octet string
* @param[in] form... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L818-L885 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiAdd | error_t mpiAdd(Mpi *r, const Mpi *a, const Mpi *b)
{
error_t error;
int_t sign;
// Retrieve the sign of A
sign = a->sign;
// Both operands have the same sign?
if (a->sign == b->sign)
{
// Perform addition
error = mpiAddAbs(r, a, b);
// Set the sign of the resulting number
... | /**
* @brief Multiple precision addition
* @param[out] r Resulting integer R = A + B
* @param[in] a First operand A
* @param[in] b Second operand B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L895-L933 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiAddInt | error_t mpiAddInt(Mpi *r, const Mpi *a, int_t b)
{
uint_t value;
Mpi t;
// Convert the second operand to a multiple precision integer
value = (b >= 0) ? b : -b;
t.sign = (b >= 0) ? 1 : -1;
t.size = 1;
t.data = &value;
// Perform addition
return mpiAdd(r, a, &t);
} | /**
* @brief Add an integer to a multiple precision integer
* @param[out] r Resulting integer R = A + B
* @param[in] a First operand A
* @param[in] b Second operand B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L943-L956 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiSub | error_t mpiSub(Mpi *r, const Mpi *a, const Mpi *b)
{
error_t error;
int_t sign;
// Retrieve the sign of A
sign = a->sign;
// Both operands have the same sign?
if (a->sign == b->sign)
{
// Compare the absolute value of A and B
if (mpiCompAbs(a, b) >= 0)
{
// Perform subt... | /**
* @brief Multiple precision subtraction
* @param[out] r Resulting integer R = A - B
* @param[in] a First operand A
* @param[in] b Second operand B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L966-L1004 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiSubInt | error_t mpiSubInt(Mpi *r, const Mpi *a, int_t b)
{
uint_t value;
Mpi t;
// Convert the second operand to a multiple precision integer
value = (b >= 0) ? b : -b;
t.sign = (b >= 0) ? 1 : -1;
t.size = 1;
t.data = &value;
// Perform subtraction
return mpiSub(r, a, &t);
} | /**
* @brief Subtract an integer from a multiple precision integer
* @param[out] r Resulting integer R = A - B
* @param[in] a First operand A
* @param[in] b Second operand B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1014-L1027 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiAddAbs | error_t mpiAddAbs(Mpi *r, const Mpi *a, const Mpi *b)
{
error_t error;
uint_t i;
uint_t n;
uint_t c;
uint_t d;
// R and B are the same instance?
if (r == b)
{
// Swap A and B
const Mpi *t = a;
a = b;
b = t;
}
// R is neither A nor B?
else if (r != a)
{
... | /**
* @brief Helper routine for multiple precision addition
* @param[out] r Resulting integer R = |A + B|
* @param[in] a First operand A
* @param[in] b Second operand B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1037-L1109 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiSubAbs | error_t mpiSubAbs(Mpi *r, const Mpi *a, const Mpi *b)
{
error_t error;
uint_t c;
uint_t d;
uint_t i;
uint_t m;
uint_t n;
// Check input parameters
if (mpiCompAbs(a, b) < 0)
{
// Swap A and B if necessary
const Mpi *t = b;
a = b;
b = t;
}
// Determine the actual... | /**
* @brief Helper routine for multiple precision subtraction
* @param[out] r Resulting integer R = |A - B|
* @param[in] a First operand A
* @param[in] b Second operand B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1119-L1202 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiShiftLeft | error_t mpiShiftLeft(Mpi *r, uint_t n)
{
error_t error;
uint_t i;
// Number of 32-bit words to shift
uint_t n1 = n / (MPI_INT_SIZE * 8);
// Number of bits to shift
uint_t n2 = n % (MPI_INT_SIZE * 8);
// Check parameters
if (!r->size || !n)
return NO_ERROR;
// Increase the size of the... | /**
* @brief Left shift operation
* @param[in,out] r The multiple precision integer to be shifted to the left
* @param[in] n The number of bits to shift
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1211-L1262 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiShiftRight | error_t mpiShiftRight(Mpi *r, uint_t n)
{
uint_t i;
uint_t m;
// Number of 32-bit words to shift
uint_t n1 = n / (MPI_INT_SIZE * 8);
// Number of bits to shift
uint_t n2 = n % (MPI_INT_SIZE * 8);
// Check parameters
if (n1 >= r->size)
{
osMemset(r->data, 0, r->size * MPI_INT_SIZE);
... | /**
* @brief Right shift operation
* @param[in,out] r The multiple precision integer to be shifted to the right
* @param[in] n The number of bits to shift
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1271-L1319 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiMul | __weak_func error_t mpiMul(Mpi *r, const Mpi *a, const Mpi *b)
{
error_t error;
int_t i;
int_t m;
int_t n;
Mpi ta;
Mpi tb;
// Initialize multiple precision integers
mpiInit(&ta);
mpiInit(&tb);
// R and A are the same instance?
if (r == a)
{
// Copy A to TA
MPI_CHECK(mpi... | /**
* @brief Multiple precision multiplication
* @param[out] r Resulting integer R = A * B
* @param[in] a First operand A
* @param[in] b Second operand B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1329-L1395 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiMulInt | error_t mpiMulInt(Mpi *r, const Mpi *a, int_t b)
{
uint_t value;
Mpi t;
// Convert the second operand to a multiple precision integer
value = (b >= 0) ? b : -b;
t.sign = (b >= 0) ? 1 : -1;
t.size = 1;
t.data = &value;
// Perform multiplication
return mpiMul(r, a, &t);
} | /**
* @brief Multiply a multiple precision integer by an integer
* @param[out] r Resulting integer R = A * B
* @param[in] a First operand A
* @param[in] b Second operand B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1405-L1418 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiDiv | error_t mpiDiv(Mpi *q, Mpi *r, const Mpi *a, const Mpi *b)
{
error_t error;
uint_t m;
uint_t n;
Mpi c;
Mpi d;
Mpi e;
// Check whether the divisor is equal to zero
if (!mpiCompInt(b, 0))
return ERROR_INVALID_PARAMETER;
// Initialize multiple precision integers
mpiInit(&c);
mpiIni... | /**
* @brief Multiple precision division
* @param[out] q The quotient Q = A / B
* @param[out] r The remainder R = A mod B
* @param[in] a The dividend A
* @param[in] b The divisor B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1429-L1484 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiDivInt | error_t mpiDivInt(Mpi *q, Mpi *r, const Mpi *a, int_t b)
{
uint_t value;
Mpi t;
// Convert the divisor to a multiple precision integer
value = (b >= 0) ? b : -b;
t.sign = (b >= 0) ? 1 : -1;
t.size = 1;
t.data = &value;
// Perform division
return mpiDiv(q, r, a, &t);
} | /**
* @brief Divide a multiple precision integer by an integer
* @param[out] q The quotient Q = A / B
* @param[out] r The remainder R = A mod B
* @param[in] a The dividend A
* @param[in] b The divisor B
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1495-L1508 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiMod | error_t mpiMod(Mpi *r, const Mpi *a, const Mpi *p)
{
error_t error;
int_t sign;
uint_t m;
uint_t n;
Mpi c;
// Make sure the modulus is positive
if (mpiCompInt(p, 0) <= 0)
return ERROR_INVALID_PARAMETER;
// Initialize multiple precision integer
mpiInit(&c);
// Save the sign of A
... | /**
* @brief Modulo operation
* @param[out] r Resulting integer R = A mod P
* @param[in] a The multiple precision integer to be reduced
* @param[in] p The modulus P
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1518-L1570 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiAddMod | error_t mpiAddMod(Mpi *r, const Mpi *a, const Mpi *b, const Mpi *p)
{
error_t error;
// Perform modular addition
MPI_CHECK(mpiAdd(r, a, b));
MPI_CHECK(mpiMod(r, r, p));
end:
// Return status code
return error;
} | /**
* @brief Modular addition
* @param[out] r Resulting integer R = A + B mod P
* @param[in] a The first operand A
* @param[in] b The second operand B
* @param[in] p The modulus P
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1581-L1592 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiSubMod | error_t mpiSubMod(Mpi *r, const Mpi *a, const Mpi *b, const Mpi *p)
{
error_t error;
// Perform modular subtraction
MPI_CHECK(mpiSub(r, a, b));
MPI_CHECK(mpiMod(r, r, p));
end:
// Return status code
return error;
} | /**
* @brief Modular subtraction
* @param[out] r Resulting integer R = A - B mod P
* @param[in] a The first operand A
* @param[in] b The second operand B
* @param[in] p The modulus P
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1603-L1614 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiMulMod | __weak_func error_t mpiMulMod(Mpi *r, const Mpi *a, const Mpi *b, const Mpi *p)
{
error_t error;
// Perform modular multiplication
MPI_CHECK(mpiMul(r, a, b));
MPI_CHECK(mpiMod(r, r, p));
end:
// Return status code
return error;
} | /**
* @brief Modular multiplication
* @param[out] r Resulting integer R = A * B mod P
* @param[in] a The first operand A
* @param[in] b The second operand B
* @param[in] p The modulus P
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1625-L1636 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiInvMod | __weak_func error_t mpiInvMod(Mpi *r, const Mpi *a, const Mpi *p)
{
error_t error;
Mpi b;
Mpi c;
Mpi q0;
Mpi r0;
Mpi t;
Mpi u;
Mpi v;
// Initialize multiple precision integers
mpiInit(&b);
mpiInit(&c);
mpiInit(&q0);
mpiInit(&r0);
mpiInit(&t);
mpiInit(&u);
mpiInit(&v);
... | /**
* @brief Modular inverse
* @param[out] r Resulting integer R = A^-1 mod P
* @param[in] a The multiple precision integer A
* @param[in] p The modulus P
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1646-L1710 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiExpMod | __weak_func error_t mpiExpMod(Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p)
{
error_t error;
int_t i;
int_t j;
int_t n;
uint_t d;
uint_t k;
uint_t u;
Mpi b;
Mpi c2;
Mpi t;
Mpi s[8];
// Initialize multiple precision integers
mpiInit(&b);
mpiInit(&c2);
mpiInit(&t);
//... | /**
* @brief Modular exponentiation
* @param[out] r Resulting integer R = A ^ E mod P
* @param[in] a Pointer to a multiple precision integer
* @param[in] e Exponent
* @param[in] p Modulus
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1721-L1901 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiExpModFast | __weak_func error_t mpiExpModFast(Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p)
{
// Perform modular exponentiation
return mpiExpMod(r, a, e, p);
} | /**
* @brief Modular exponentiation (fast calculation)
* @param[out] r Resulting integer R = A ^ E mod P
* @param[in] a Pointer to a multiple precision integer
* @param[in] e Exponent
* @param[in] p Modulus
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1912-L1916 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiExpModRegular | __weak_func error_t mpiExpModRegular(Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p)
{
// Perform modular exponentiation
return mpiExpMod(r, a, e, p);
} | /**
* @brief Modular exponentiation (regular calculation)
* @param[out] r Resulting integer R = A ^ E mod P
* @param[in] a Pointer to a multiple precision integer
* @param[in] e Exponent
* @param[in] p Modulus
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1927-L1931 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiMontgomeryMul | error_t mpiMontgomeryMul(Mpi *r, const Mpi *a, const Mpi *b, uint_t k,
const Mpi *p, Mpi *t)
{
error_t error;
uint_t i;
uint_t m;
uint_t n;
uint_t q;
// Use Newton's method to compute the inverse of P[0] mod 2^32
for (m = 2 - p->data[0], i = 0; i < 4; i++)
{
m = m... | /**
* @brief Montgomery multiplication
* @param[out] r Resulting integer R = A * B / 2^k mod P
* @param[in] a An integer A such as 0 <= A < 2^k
* @param[in] b An integer B such as 0 <= B < 2^k
* @param[in] k An integer k such as P < 2^k
* @param[in] p Modulus P
* @param[in] t An preallocated integer T (for inter... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L1944-L2004 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiMontgomeryRed | error_t mpiMontgomeryRed(Mpi *r, const Mpi *a, uint_t k, const Mpi *p, Mpi *t)
{
uint_t value;
Mpi b;
// Let B = 1
value = 1;
b.sign = 1;
b.size = 1;
b.data = &value;
// Compute R = A / 2^k mod P
return mpiMontgomeryMul(r, a, &b, k, p, t);
} | /**
* @brief Montgomery reduction
* @param[out] r Resulting integer R = A / 2^k mod P
* @param[in] a An integer A such as 0 <= A < 2^k
* @param[in] k An integer k such as P < 2^k
* @param[in] p Modulus P
* @param[in] t An preallocated integer T (for internal operation)
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L2016-L2029 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiMulAccCore | void mpiMulAccCore(uint_t *r, const uint_t *a, int_t m, const uint_t b)
{
int_t i;
uint32_t c;
uint32_t u;
uint32_t v;
uint64_t p;
// Clear variables
c = 0;
u = 0;
v = 0;
// Perform multiplication
for (i = 0; i < m; i++)
{
p = (uint64_t)a[i] * b;
u = (uint32_t)p;
... | /**
* @brief Multiply-accumulate operation
* @param[out] r Resulting integer
* @param[in] a First operand A
* @param[in] m Size of A in words
* @param[in] b Second operand B
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L2041-L2079 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | mpiDump | void mpiDump(FILE *stream, const char_t *prepend, const Mpi *a)
{
uint_t i;
// Process each word
for (i = 0; i < a->size; i++)
{
// Beginning of a new line?
if (i == 0 || ((a->size - i - 1) % 8) == 7)
fprintf(stream, "%s", prepend);
// Display current data
fprintf(stream, ... | /**
* @brief Display the contents of a multiple precision integer
* @param[in] stream Pointer to a FILE object that identifies an output stream
* @param[in] prepend String to prepend to the left of each line
* @param[in] a Pointer to a multiple precision integer
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/mpi.c#L2090-L2108 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | aesInit | __weak_func error_t aesInit(AesContext *context, const uint8_t *key,
size_t keyLen)
{
uint_t i;
uint32_t temp;
size_t keyScheduleSize;
//Check parameters
if(context == NULL || key == NULL)
return ERROR_INVALID_PARAMETER;
//Check the length of the key
if(keyLen == 16)
{
//10 roun... | /**
* @brief Key expansion
* @param[in] context Pointer to the AES context to initialize
* @param[in] key Pointer to the key
* @param[in] keyLen Length of the key
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/cipher/aes.c#L203-L302 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | aesEncryptBlock | __weak_func void aesEncryptBlock(AesContext *context, const uint8_t *input,
uint8_t *output)
{
uint_t i;
uint32_t s0;
uint32_t s1;
uint32_t s2;
uint32_t s3;
uint32_t t0;
uint32_t t1;
uint32_t t2;
uint32_t t3;
uint32_t temp;
//Copy the plaintext to the state array
s0 = LOAD32LE(in... | /**
* @brief Encrypt a 16-byte block using AES algorithm
* @param[in] context Pointer to the AES context
* @param[in] input Plaintext block to encrypt
* @param[out] output Ciphertext block resulting from encryption
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/cipher/aes.c#L312-L413 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | aesDecryptBlock | __weak_func void aesDecryptBlock(AesContext *context, const uint8_t *input,
uint8_t *output)
{
uint_t i;
uint32_t s0;
uint32_t s1;
uint32_t s2;
uint32_t s3;
uint32_t t0;
uint32_t t1;
uint32_t t2;
uint32_t t3;
uint32_t temp;
//Copy the ciphertext to the state array
s0 = LOAD32LE(i... | /**
* @brief Decrypt a 16-byte block using AES algorithm
* @param[in] context Pointer to the AES context
* @param[in] input Ciphertext block to decrypt
* @param[out] output Plaintext block resulting from decryption
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/cipher/aes.c#L423-L524 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | aesDeinit | __weak_func void aesDeinit(AesContext *context)
{
//Clear AES context
osMemset(context, 0, sizeof(AesContext));
} | /**
* @brief Release AES context
* @param[in] context Pointer to the AES context
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_crypto/cipher/aes.c#L532-L536 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsFormatCertificateList | error_t tlsFormatCertificateList(TlsContext *context, uint8_t *p,
size_t *written)
{
error_t error;
size_t m;
size_t n;
size_t certChainLen;
const char_t *certChain;
//Initialize status code
error = NO_ERROR;
//Length of the certificate list in bytes
*written = 0;
//Check whether a c... | /**
* @brief Format certificate chain
* @param[in] context Pointer to the TLS context
* @param[in] p Output stream where to write the certificate chain
* @param[out] written Total number of bytes that have been written
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L58-L147 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsFormatRawPublicKey | error_t tlsFormatRawPublicKey(TlsContext *context, uint8_t *p,
size_t *written)
{
error_t error;
//Initialize status code
error = NO_ERROR;
//Length of the certificate list in bytes
*written = 0;
#if (TLS_RAW_PUBLIC_KEY_SUPPORT == ENABLED)
//Check whether a certificate is available
if(context... | /**
* @brief Format raw public key
* @param[in] context Pointer to the TLS context
* @param[in] p Output stream where to write the raw public key
* @param[out] written Total number of bytes that have been written
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L158-L274 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsParseCertificateList_override | __weak_func error_t tlsParseCertificateList_override(TlsContext *context,
const uint8_t *p, size_t length)
{
error_t error;
error_t certValidResult;
uint_t i;
size_t n;
const char_t *subjectName;
X509CertInfo *certInfo;
X509CertInfo *issuerCertInfo;
//Initialize X.509 certificates
certInf... | /**
* @brief Parse certificate chain
* @param[in] context Pointer to the TLS context
* @param[in] p Input stream where to read the certificate chain
* @param[in] length Number of bytes available in the input stream
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L285-L585 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsParseRawPublicKey | error_t tlsParseRawPublicKey(TlsContext *context, const uint8_t *p,
size_t length)
{
error_t error;
#if (TLS_RAW_PUBLIC_KEY_SUPPORT == ENABLED)
//Any registered callback?
if(context->rpkVerifyCallback != NULL)
{
size_t n;
size_t rawPublicKeyLen;
const uint8_t *rawPublicKey;
X509S... | /**
* @brief Parse raw public key
* @param[in] context Pointer to the TLS context
* @param[in] p Input stream where to read the raw public key
* @param[in] length Number of bytes available in the input stream
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L596-L696 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsIsCertificateAcceptable | bool_t tlsIsCertificateAcceptable(TlsContext *context, const TlsCertDesc *cert,
const uint8_t *certTypes, size_t numCertTypes, const TlsSignHashAlgos *signHashAlgos,
const TlsSignHashAlgos *certSignHashAlgos, const TlsSupportedGroupList *curveList,
const TlsCertAuthorities *certAuthorities)
{
size_t i;
s... | /**
* @brief Check whether a certificate is acceptable
* @param[in] context Pointer to the TLS context
* @param[in] cert End entity certificate
* @param[in] certTypes List of supported certificate types
* @param[in] numCertTypes Size of the list that contains the supported
* certificate types
* @param[in] sign... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L716-L1253 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsValidateCertificate | error_t tlsValidateCertificate(TlsContext *context,
const X509CertInfo *certInfo, uint_t pathLen,
const char_t *subjectName)
{
error_t error;
size_t pemCertLen;
const char_t *trustedCaList;
size_t trustedCaListLen;
uint8_t *derCert;
size_t derCertLen;
X509CertInfo *caCertInfo;
//Initializ... | /**
* @brief Verify certificate against root CAs
* @param[in] context Pointer to the TLS context
* @param[in] certInfo X.509 certificate to be verified
* @param[in] pathLen Certificate path length
* @param[in] subjectName Subject name (optional parameter)
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L1265-L1418 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsGetCertificateType | error_t tlsGetCertificateType(const X509CertInfo *certInfo,
TlsCertificateType *certType, TlsNamedGroup *namedCurve)
{
size_t oidLen;
const uint8_t *oid;
//Check parameters
if(certInfo == NULL || certType == NULL || namedCurve == NULL)
return ERROR_INVALID_PARAMETER;
//Point to the public key ... | /**
* @brief Retrieve the certificate type
* @param[in] certInfo X.509 certificate
* @param[out] certType Certificate type
* @param[out] namedCurve Elliptic curve (only for ECDSA certificates)
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L1429-L1523 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsGetCertificateSignAlgo | error_t tlsGetCertificateSignAlgo(const X509CertInfo *certInfo,
TlsSignatureAlgo *signAlgo, TlsHashAlgo *hashAlgo)
{
size_t oidLen;
const uint8_t *oid;
//Check parameters
if(certInfo == NULL || signAlgo == NULL || hashAlgo == NULL)
return ERROR_INVALID_PARAMETER;
//Point to the signature algor... | /**
* @brief Retrieve the signature algorithm used to sign the certificate
* @param[in] certInfo X.509 certificate
* @param[out] signAlgo Signature algorithm
* @param[out] hashAlgo Hash algorithm
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L1534-L1725 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsReadSubjectPublicKey | error_t tlsReadSubjectPublicKey(TlsContext *context,
const X509SubjectPublicKeyInfo *subjectPublicKeyInfo)
{
error_t error;
size_t oidLen;
const uint8_t *oid;
//Retrieve public key identifier
oid = subjectPublicKeyInfo->oid.value;
oidLen = subjectPublicKeyInfo->oid.length;
#if (TLS_RSA_SIGN_SUPPO... | /**
* @brief Extract the subject public key from the received certificate
* @param[in] context Pointer to the TLS context
* @param[in] subjectPublicKeyInfo Pointer to the subject's public key
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L1735-L1993 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | tlsCheckKeyUsage | error_t tlsCheckKeyUsage(const X509CertInfo *certInfo,
TlsConnectionEnd entity, TlsKeyExchMethod keyExchMethod)
{
#if (TLS_CERT_KEY_USAGE_SUPPORT == ENABLED)
error_t error;
const X509KeyUsage *keyUsage;
const X509ExtendedKeyUsage *extKeyUsage;
//Initialize status code
error = NO_ERROR;
//Point to... | /**
* @brief Check certificate key usage
* @param[in] certInfo Pointer to the X.509 certificate
* @param[in] entity Specifies whether this entity is considered a client or a server
* @param[in] keyExchMethod TLS key exchange method
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_ssl/tls_certificate.c#L2004-L2098 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpClientOpenConnection | error_t httpClientOpenConnection(HttpClientContext *context)
{
error_t error;
//Open a TCP socket
context->socket = socketOpen(SOCKET_TYPE_STREAM, SOCKET_IP_PROTO_TCP);
//Failed to open socket?
if(context->socket == NULL)
return ERROR_OPEN_FAILED;
//Associate the socket with the relevant inter... | /**
* @brief Open network connection
* @param[in] context Pointer to the HTTP client context
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_client_transport.c#L51-L118 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpClientEstablishConnection | error_t httpClientEstablishConnection(HttpClientContext *context,
const IpAddr *serverIpAddr, uint16_t serverPort)
{
error_t error;
//Establish TCP connection
error = socketConnect(context->socket, serverIpAddr, serverPort);
//Any error to report?
if(error)
return error;
#if (HTTP_CLIENT_TLS_S... | /**
* @brief Establish network connection
* @param[in] context Pointer to the HTTP client context
* @param[in] serverIpAddr IP address of the HTTP server to connect to
* @param[in] serverPort TCP port number that will be used to establish the
* connection
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_client_transport.c#L130-L155 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpClientShutdownConnection | error_t httpClientShutdownConnection(HttpClientContext *context)
{
error_t error;
//Initialize status code
error = NO_ERROR;
pcaplog_ctx_t ctx;
ctx.local_endpoint.ipv4 = 0;
ctx.local_endpoint.port = context->socket->localPort;
ctx.remote_endpoint.ipv4 = context->socket->remoteIpAddr.ipv4Addr;
... | /**
* @brief Shutdown network connection
* @param[in] context Pointer to the HTTP client context
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_client_transport.c#L164-L202 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpClientCloseConnection | void httpClientCloseConnection(HttpClientContext *context)
{
#if (HTTP_CLIENT_TLS_SUPPORT == ENABLED)
//Release TLS context
if(context->tlsContext != NULL)
{
tlsFree(context->tlsContext);
context->tlsContext = NULL;
}
#endif
//Close TCP connection
if(context->socket != NULL)
{
so... | /**
* @brief Close network connection
* @param[in] context Pointer to the HTTP client context
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_client_transport.c#L210-L227 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpClientSendData | error_t httpClientSendData(HttpClientContext *context, const void *data,
size_t length, size_t *written, uint_t flags)
{
error_t error;
#if (HTTP_CLIENT_TLS_SUPPORT == ENABLED)
//TLS-secured connection?
if(context->tlsContext != NULL)
{
//Send TLS-encrypted data
error = tlsWrite(context->tls... | /**
* @brief Send data using the relevant transport protocol
* @param[in] context Pointer to the HTTP client context
* @param[in] data Pointer to a buffer containing the data to be transmitted
* @param[in] length Number of bytes to be transmitted
* @param[out] written Actual number of bytes written (optional param... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_client_transport.c#L240-L269 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpClientReceiveData | error_t httpClientReceiveData(HttpClientContext *context, void *data,
size_t size, size_t *received, uint_t flags)
{
error_t error;
#if (HTTP_CLIENT_TLS_SUPPORT == ENABLED)
//TLS-secured connection?
if(context->tlsContext != NULL)
{
//Receive TLS-encrypted data
error = tlsRead(context->tlsCo... | /**
* @brief Receive data using the relevant transport protocol
* @param[in] context Pointer to the HTTP client context
* @param[out] data Buffer into which received data will be placed
* @param[in] size Maximum number of bytes that can be received
* @param[out] received Number of bytes that have been received
* ... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_client_transport.c#L282-L311 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpClientSaveSession | error_t httpClientSaveSession(HttpClientContext *context)
{
error_t error;
//Initialize status code
error = NO_ERROR;
#if (HTTP_CLIENT_TLS_SUPPORT == ENABLED)
//TLS-secured connection?
if(context->tlsContext != NULL)
{
//Save TLS session
error = tlsSaveSessionState(context->tlsContext, &... | /**
* @brief Save TLS session
* @param[in] context Pointer to the HTTP client context
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_client_transport.c#L320-L338 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpServerGetDefaultSettings | void httpServerGetDefaultSettings(HttpServerSettings *settings)
{
// The HTTP server is not bound to any interface
settings->interface = NULL;
// Listen to port 80
settings->port = HTTP_PORT;
// HTTP server IP address
settings->ipAddr = IP_ADDR_ANY;
// Maximum length of the pending connection queu... | /**
* @brief Initialize settings with default values
* @param[out] settings Structure that contains HTTP server settings
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L63-L102 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpServerInit | error_t httpServerInit(HttpServerContext *context, const HttpServerSettings *settings)
{
error_t error;
uint_t i;
HttpConnection *connection;
// Debug message
TRACE_INFO("Initializing HTTP server...\r\n");
// Ensure the parameters are valid
if (context == NULL || settings == NULL)
return ER... | /**
* @brief HTTP server initialization
* @param[in] context Pointer to the HTTP server context
* @param[in] settings HTTP server specific settings
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L111-L200 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpServerStart | error_t httpServerStart(HttpServerContext *context)
{
uint_t i;
HttpConnection *connection;
// Make sure the HTTP server context is valid
if (context == NULL)
return ERROR_INVALID_PARAMETER;
// Debug message
TRACE_INFO("Starting HTTP server...\r\n");
// Loop through client connections
f... | /**
* @brief Start HTTP server
* @param[in] context Pointer to the HTTP server context
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L208-L259 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpListenerTask | void httpListenerTask(void *param)
{
uint_t i;
uint_t counter;
uint16_t clientPort;
IpAddr clientIpAddr;
HttpServerContext *context;
HttpConnection *connection;
Socket *socket;
// Task prologue
osEnterTask();
// Retrieve the HTTP server context
context = (HttpServerContext *)param;
... | /**
* @brief HTTP server listener task
* @param[in] param Pointer to the HTTP server context
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L266-L338 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpConnectionTask | void httpConnectionTask(void *param)
{
error_t error;
uint_t counter;
HttpConnection *connection;
// Task prologue
osEnterTask();
// Point to the structure representing the HTTP connection
connection = (HttpConnection *)param;
// Endless loop
while (1)
{
// Wait for an incoming co... | /**
* @brief Task that services requests from an active connection
* @param[in] param Structure representing an HTTP connection with a client
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L345-L666 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpWriteHeader | error_t httpWriteHeader(HttpConnection *connection)
{
error_t error;
#if (NET_RTOS_SUPPORT == DISABLED)
// Flush buffer
connection->bufferPos = 0;
connection->bufferLen = 0;
#endif
// Format HTTP response header
error = httpFormatResponseHeader(connection, connection->buffer);
// Check status co... | /**
* @brief Send HTTP response header
* @param[in] connection Structure representing an HTTP connection
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L674-L700 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpReadStream | error_t httpReadStream(HttpConnection *connection,
void *data, size_t size, size_t *received, uint_t flags)
{
error_t error;
size_t n;
// No data has been read yet
*received = 0;
// Chunked encoding transfer is used?
if (connection->request.chunkedEncoding)
{
// Point... | /**
* @brief Read data from client request
* @param[in] connection Structure representing an HTTP connection
* @param[out] data Buffer where to store the incoming data
* @param[in] size Maximum number of bytes that can be received
* @param[out] received Number of bytes that have been received
* @param[in] flags S... | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L712-L807 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpWriteStream | error_t httpWriteStream(HttpConnection *connection,
const void *data, size_t length)
{
error_t error;
uint_t n;
// Use chunked encoding transfer?
if (connection->response.chunkedEncoding)
{
// Any data to send?
if (length > 0)
{
char_t s[20];
... | /**
* @brief Write data to the client
* @param[in] connection Structure representing an HTTP connection
* @param[in] data Buffer containing the data to be transmitted
* @param[in] length Number of bytes to be transmitted
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L817-L873 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpCloseStream | error_t httpCloseStream(HttpConnection *connection)
{
error_t error;
// Use chunked encoding transfer?
if (connection->response.chunkedEncoding)
{
// The chunked encoding is ended by any chunk whose size is zero
error = httpSend(connection, "0\r\n\r\n", 5, HTTP_FLAG_NO_DELAY);
}
else
{... | /**
* @brief Close output stream
* @param[in] connection Structure representing an HTTP connection
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L881-L899 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpSendResponse | error_t httpSendResponse(HttpConnection *connection, const char_t *uri)
{
return httpSendResponseStream(connection, uri, false);
} | /**
* @brief Send HTTP response
* @param[in] connection Structure representing an HTTP connection
* @param[in] uri NULL-terminated string containing the file to be sent in response
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L908-L911 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpSendErrorResponse | error_t httpSendErrorResponse(HttpConnection *connection,
uint_t statusCode, const char_t *message)
{
error_t error;
size_t length;
// HTML response template
static const char_t template[] =
"<!doctype html>\r\n"
"<html>\r\n"
"<head><title>Error %03d</titl... | /**
* @brief Send error response to the client
* @param[in] connection Structure representing an HTTP connection
* @param[in] statusCode HTTP status code
* @param[in] message User message
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L1194-L1249 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpSendRedirectResponse | error_t httpSendRedirectResponse(HttpConnection *connection,
uint_t statusCode, const char_t *uri)
{
error_t error;
size_t length;
// HTML response template
static const char_t template[] =
"<!doctype html>\r\n"
"<html>\r\n"
"<head><title>Moved</title><... | /**
* @brief Send redirect response to the client
* @param[in] connection Structure representing an HTTP connection
* @param[in] statusCode HTTP status code (301 for permanent redirects)
* @param[in] uri NULL-terminated string containing the redirect URI
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L1259-L1315 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpCheckWebSocketHandshake | bool_t httpCheckWebSocketHandshake(HttpConnection *connection)
{
#if (HTTP_SERVER_WEB_SOCKET_SUPPORT == ENABLED)
error_t error;
size_t n;
// The request must contain an Upgrade header field whose value
// must include the "websocket" keyword
if (!connection->request.upgradeWebSocket)
return FALSE;... | /**
* @brief Check whether the client's handshake is valid
* @param[in] connection Structure representing an HTTP connection
* @return TRUE if the WebSocket handshake is valid, else FALSE
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server.c#L1323-L1363 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
teddycloud | github_2023 | toniebox-reverse-engineering | c | httpParseRequestLine | error_t httpParseRequestLine(HttpConnection *connection, char_t *requestLine)
{
error_t error;
char_t *token;
char_t *p;
char_t *s;
//The Request-Line begins with a method token
token = osStrtok_r(requestLine, " \r\n", &p);
//Unable to retrieve the method?
if(token == NULL)
return ERROR_I... | /**
* @brief Parse Request-Line
* @param[in] connection Structure representing an HTTP connection
* @param[in] requestLine Pointer to the string that holds the Request-Line
* @return Error code
**/ | https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/src/cyclone/cyclone_tcp/http/http_server_misc.c#L188-L293 | 83d3b29cbfc74e8f76f48f8782646c8e464055b2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.