Skip to content

Commit

Permalink
Indent
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Mar 4, 2024
1 parent 75c1f66 commit 79fa39a
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 31 deletions.
22 changes: 17 additions & 5 deletions impl/gimli-core/sse2.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <emmintrin.h>
#ifdef __SSSE3__
# include <tmmintrin.h>
# include <tmmintrin.h>
#endif

#define S 9
Expand Down Expand Up @@ -31,10 +31,22 @@ rotate24(__m128i x)

_mm_storeu_si128((__m128i *) (void *) x8, x);

y8[ 0] = x8[ 1]; y8[ 1] = x8[ 2]; y8[ 2] = x8[ 3]; y8[ 3] = x8[ 0];
y8[ 4] = x8[ 5]; y8[ 5] = x8[ 6]; y8[ 6] = x8[ 7]; y8[ 7] = x8[ 4];
y8[ 8] = x8[ 9]; y8[ 9] = x8[10]; y8[10] = x8[11]; y8[11] = x8[ 8];
y8[12] = x8[13]; y8[13] = x8[14]; y8[14] = x8[15]; y8[15] = x8[12];
y8[0] = x8[1];
y8[1] = x8[2];
y8[2] = x8[3];
y8[3] = x8[0];
y8[4] = x8[5];
y8[5] = x8[6];
y8[6] = x8[7];
y8[7] = x8[4];
y8[8] = x8[9];
y8[9] = x8[10];
y8[10] = x8[11];
y8[11] = x8[8];
y8[12] = x8[13];
y8[13] = x8[14];
y8[14] = x8[15];
y8[15] = x8[12];

return _mm_loadu_si128((const __m128i *) (const void *) y8);
}
Expand Down
4 changes: 3 additions & 1 deletion impl/random/avr.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ hydro_random_init(void)
return 0;
}

ISR(WDT_vect) { }
ISR(WDT_vect)
{
}
7 changes: 4 additions & 3 deletions impl/random/ch32.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if defined(CH32V30x_D8) || defined(CH32V30x_D8C)
# include <ch32v30x_rng.h>
# include <ch32v30x_rng.h>
#else
# error CH32 implementation missing!
# error CH32 implementation missing!
#endif

static int
Expand All @@ -20,7 +20,8 @@ hydro_random_init(void)
hydro_hash_init(&st, ctx, NULL);

while (ebits < 256) {
while (RNG_GetFlagStatus(RNG_FLAG_DRDY) == RESET);
while (RNG_GetFlagStatus(RNG_FLAG_DRDY) == RESET)
;
uint32_t r = RNG_GetRandomNumber();

hydro_hash_update(&st, (const uint32_t *) &r, sizeof r);
Expand Down
3 changes: 1 addition & 2 deletions impl/random/chibios.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ hydro_random_init(void)
{
trngStart(&TRNGD1, NULL);

if (trngGenerate(&TRNGD1, sizeof hydro_random_context.state,
hydro_random_context.state)) {
if (trngGenerate(&TRNGD1, sizeof hydro_random_context.state, hydro_random_context.state)) {
return -1;
}
hydro_random_context.counter = ~LOAD64_LE(hydro_random_context.state);
Expand Down
4 changes: 2 additions & 2 deletions impl/random/esp32.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Important: RF *must* be activated on ESP board
// https://techtutorialsx.com/2017/12/22/esp32-arduino-random-number-generation/
#ifdef ESP32
#include <esp_system.h>
# include <esp_system.h>
#endif

#ifdef ARDUINO
#include <Arduino.h>
# include <Arduino.h>
#endif

static int
Expand Down
3 changes: 1 addition & 2 deletions impl/random/linux_kernel.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
static int
hydro_random_init(void)
{
get_random_bytes(&hydro_random_context.state,
sizeof hydro_random_context.state);
get_random_bytes(&hydro_random_context.state, sizeof hydro_random_context.state);
hydro_random_context.counter = ~LOAD64_LE(hydro_random_context.state);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion impl/random/mbed.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ hydro_random_init(void)
return 0;
}
#else
#error Need an entropy source
# error Need an entropy source
#endif
5 changes: 3 additions & 2 deletions impl/random/rtthread.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include <rtthread.h>
#include <hw_rng.h>
#include <rtthread.h>

#define DBG_TAG "libhydrogen"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

static int
hydrogen_init(void) {
hydrogen_init(void)
{
if (hydro_init() != 0) {
abort();
}
Expand Down
24 changes: 12 additions & 12 deletions impl/random/stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// Working with HAL, LL Driver (untested)
#if defined(STM32F4) || defined(STM32L4)

# if defined(STM32F4)
# include "stm32f4xx.h"
# elif defined(STM32L4)
# include "stm32l4xx_hal_rng.h"
# if defined(STM32F4)
# include "stm32f4xx.h"
# elif defined(STM32L4)
# include "stm32l4xx_hal_rng.h"

static RNG_HandleTypeDef RngHandle;
# endif
# endif

static int
hydro_random_init(void)
Expand All @@ -20,7 +20,7 @@ hydro_random_init(void)

__IO uint32_t tmpreg;

# if defined(STM32F4)
# if defined(STM32F4)
// Enable RNG clock source
SET_BIT(RCC->AHB2ENR, RCC_AHB2ENR_RNGEN);

Expand All @@ -30,25 +30,25 @@ hydro_random_init(void)

// RNG Peripheral enable
SET_BIT(RNG->CR, RNG_CR_RNGEN);
# elif defined(STM32L4)
# elif defined(STM32L4)
RngHandle.Instance = RNG;
HAL_RNG_Init(&RngHandle);
# endif
# endif

hydro_hash_init(&st, ctx, NULL);

while (ebits < 256) {
uint32_t r = 0;
# if defined(STM32F4)
# if defined(STM32F4)
while (!(READ_BIT(RNG->SR, RNG_SR_DRDY))) {
}

r = RNG->DR;
# elif defined(STM32L4)
# elif defined(STM32L4)
if (HAL_RNG_GenerateRandomNumber(&RngHandle, &r) != HAL_OK) {
continue;
}
# endif
# endif
hydro_hash_update(&st, (const uint32_t *) &r, sizeof r);
ebits += 32;
}
Expand All @@ -59,5 +59,5 @@ hydro_random_init(void)
return 0;
}
#else
# error SMT32 implementation missing!
# error SMT32 implementation missing!
#endif
2 changes: 1 addition & 1 deletion impl/random/unix.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <errno.h>
#include <fcntl.h>
#ifdef __linux__
#include <poll.h>
# include <poll.h>
#endif
#include <sys/types.h>
#include <unistd.h>
Expand Down

0 comments on commit 79fa39a

Please sign in to comment.