X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fsec%2Futil.h;h=189e4ed715858734fcac66a270cbd69bfd3713fb;hb=94f23fc17d4a4a56e66d76e76f23ca35c176f3a6;hp=36ce22f883a26d5917ce23e573898fe6331a2e2d;hpb=f3a74d05913e05818c39b796968fda9277e213f9;p=bertos.git diff --git a/bertos/sec/util.h b/bertos/sec/util.h index 36ce22f8..189e4ed7 100644 --- a/bertos/sec/util.h +++ b/bertos/sec/util.h @@ -7,7 +7,7 @@ /** * Purge local variables, by zeroing them. - * + * * This can be used to clear stack from intermediate results in crypto * calculations that might somehow be leaked. */ @@ -17,21 +17,21 @@ /** * Convert a generic "password" (low-diffused) to a generic "key" * (high-diffused). - * + * * In common terminology, a "password" is a key with weak cryptographic - * characteristics, such as commonly used password input by an user, + * characteristics, such as commonly used password input by an user, * which are usually short and use only a few different characters from * the 0-255 byte range. - * + * * This function derives a strong key from the password using a one-way * process. - * + * * \note Uses PBKDF2 as key-derivation function, with a fixed salt that * changes for each Bertos project. */ void password2key(const char *pwd, size_t pwd_len, uint8_t *key, size_t key_len); - + /** * Perform a bitwise xor between \a in and \a inout, and store * the result into \a inout. @@ -59,7 +59,7 @@ INLINE void xor_block(uint8_t *out, const uint8_t *in1, const uint8_t* in2, size const uint32_t *ibuf2 = (const uint32_t *)in2; uint32_t *obuf = (uint32_t *)out; size_t rem = (len & 3); - + len /= 4; while (len--) *obuf++ = *ibuf1++ ^ *ibuf2++; @@ -67,7 +67,7 @@ INLINE void xor_block(uint8_t *out, const uint8_t *in1, const uint8_t* in2, size in1 = (const uint8_t*)ibuf1; in2 = (const uint8_t*)ibuf2; out = (uint8_t*)obuf; - while (rem--) + while (rem--) *out++ = *in1++ ^ *in2++; } @@ -80,14 +80,14 @@ INLINE void xor_block_const(uint8_t *out, const uint8_t *in, uint8_t k, size_t l const uint32_t *ibuf = (const uint32_t *)in; uint32_t *obuf = (uint32_t *)out; size_t rem = (len & 3); - + len /= 4; while (len--) *obuf++ = *ibuf++ ^ k32; in = (const uint8_t*)ibuf; out = (uint8_t*)obuf; - while (rem--) + while (rem--) *out++ = *in++ ^ k; }