From d1a9a6eb1d3014b7708b0f0ddf6e85b783d21639 Mon Sep 17 00:00:00 2001 From: rasky Date: Wed, 29 Sep 2010 15:30:11 +0000 Subject: [PATCH] SEC: update ISAAC to coding standard naming. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4354 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/sec/prng/isaac.c | 26 +++++++++++++------------- bertos/sec/prng/isaac.h | 16 ++++++++-------- bertos/sec/random_p.h | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bertos/sec/prng/isaac.c b/bertos/sec/prng/isaac.c index d4246f71..72d4a320 100644 --- a/bertos/sec/prng/isaac.c +++ b/bertos/sec/prng/isaac.c @@ -32,7 +32,7 @@ * * \brief ISAAC implementation * \author Giovanni Bajo - * + * */ /* @@ -65,7 +65,7 @@ typedef uint8_t ub1; *(r++) = b = ind(mm,y>>CONFIG_ISAAC_RANDSIZL) + x; \ } -static void isaac(ISAAC_Context *ctx) +static void isaac(IsaacContext *ctx) { register ub4 a,b,x,y,*m,*mm,*m2,*r,*mend; mm=ctx->randmem; r=ctx->randrsl; @@ -100,9 +100,9 @@ static void isaac(ISAAC_Context *ctx) h^=a>>9; c+=h; a+=b; \ } -static void ISAAC_reseed(PRNG *ctx_, const uint8_t *seed) +static void isaac_reseed(PRNG *ctx_, const uint8_t *seed) { - ISAAC_Context *ctx = (ISAAC_Context *)ctx_; + IsaacContext *ctx = (IsaacContext *)ctx_; int i; ub4 a,b,c,d,e,f,g,h; ub4 *m,*r; @@ -141,23 +141,23 @@ static void ISAAC_reseed(PRNG *ctx_, const uint8_t *seed) } } -static void ISAAC_generate(PRNG *ctx_, uint8_t *data, size_t len) +static void isaac_generate(PRNG *ctx_, uint8_t *data, size_t len) { - ISAAC_Context *ctx = (ISAAC_Context *)ctx_; + IsaacContext *ctx = (IsaacContext *)ctx_; STATIC_ASSERT(sizeof(ctx->randrsl) == CONFIG_ISAAC_RANDSIZ*4); while (len) { ASSERT(ctx->randcnt <= CONFIG_ISAAC_RANDSIZ*4); - + if (ctx->randcnt == CONFIG_ISAAC_RANDSIZ*4) { isaac(ctx); - ctx->randcnt = 0; + ctx->randcnt = 0; } - - size_t L = MIN(len, CONFIG_ISAAC_RANDSIZ*4 - (size_t)ctx->randcnt); + + size_t L = MIN(len, CONFIG_ISAAC_RANDSIZ*4 - (size_t)ctx->randcnt); memcpy(data, (uint8_t*)ctx->randrsl + ctx->randcnt, L); data += L; ctx->randcnt += L; @@ -168,10 +168,10 @@ static void ISAAC_generate(PRNG *ctx_, uint8_t *data, size_t len) /**********************************************************************/ -void ISAAC_init(ISAAC_Context *ctx) +void isaac_init(IsaacContext *ctx) { - ctx->prng.reseed = ISAAC_reseed; - ctx->prng.generate = ISAAC_generate; + ctx->prng.reseed = isaac_reseed; + ctx->prng.generate = isaac_generate; ctx->prng.seed_len = sizeof(ctx->randrsl) / 2; ctx->randcnt = CONFIG_ISAAC_RANDSIZ*4; diff --git a/bertos/sec/prng/isaac.h b/bertos/sec/prng/isaac.h index c9f9663e..8be03c11 100644 --- a/bertos/sec/prng/isaac.h +++ b/bertos/sec/prng/isaac.h @@ -32,7 +32,7 @@ * * \brief ISAAC implementation * \author Giovanni Bajo - * + * */ #ifndef SEC_PRNG_ISAAC_H @@ -42,7 +42,7 @@ /** * Size of the internal ISAAC state (in 32-bit words). - * + * * ISAAC is known to generate unbiased data as follows: * * 3 words: 2^37 unbiased values * * 4 words: 2^45 unbiased values @@ -50,14 +50,14 @@ * * 6 words: 2^61 unbiased values * * 7 words: 2^69 unbiased values * * 8 words: 2^77 unbiased values - * + * * The period of the generator is usually much longer, but it is * obviously uninteresting for a CSPRNG. */ #define CONFIG_ISAAC_RANDSIZL (3) #define CONFIG_ISAAC_RANDSIZ (1<<(CONFIG_ISAAC_RANDSIZL)) -typedef struct +typedef struct IsaacContext { PRNG prng; uint32_t randcnt; @@ -66,12 +66,12 @@ typedef struct uint32_t randa; uint32_t randb; uint32_t randc; -} ISAAC_Context; +} IsaacContext; -void ISAAC_init(ISAAC_Context *ctx); +void isaac_init(IsaacContext *ctx); -#define ISAAC_stackinit(...) \ - ({ ISAAC_Context *ctx = alloca(sizeof(ISAAC_Context)); ISAAC_init(ctx , ##__VA_ARGS__); &ctx->prng; }) +#define isaac_stackinit(...) \ + ({ IsaacContext *ctx = alloca(sizeof(IsaacContext)); isaac_init(ctx , ##__VA_ARGS__); &ctx->prng; }) #endif /* SEC_PRNG_ISAAC_H */ diff --git a/bertos/sec/random_p.h b/bertos/sec/random_p.h index 324f4bde..97d51dad 100644 --- a/bertos/sec/random_p.h +++ b/bertos/sec/random_p.h @@ -52,7 +52,7 @@ #define PRNG_ISAAC 1 #define PRNG_X917 2 #define PRNG_YARROW 3 -#define PRNG_NAMEU1 ISAAC +#define PRNG_NAMEU1 Isaac #define PRNG_NAMEL1 isaac #define PRNG_NAMEU2 X917 #define PRNG_NAMEL2 x917 -- 2.25.1