From 3525f032df086db268318d8ea686f6ed3f27193d Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 28 Jul 2017 18:51:04 +0200 Subject: [PATCH] Inline --- .../crypto_pwhash/argon2/argon2-core.c | 22 ------------------ .../crypto_pwhash/argon2/argon2-core.h | 23 ++++++++++++++++--- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-core.c b/src/libsodium/crypto_pwhash/argon2/argon2-core.c index b35f9d2a..16f88061 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-core.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2-core.c @@ -36,28 +36,6 @@ static fill_segment_fn fill_segment = fill_segment_ref; -/***************Instance and Position constructors**********/ -void -init_block_value(block *b, uint8_t in) -{ - memset(b->v, in, sizeof(b->v)); -} - -void -copy_block(block *dst, const block *src) -{ - memcpy(dst->v, src->v, sizeof(uint64_t) * ARGON2_QWORDS_IN_BLOCK); -} - -void -xor_block(block *dst, const block *src) -{ - int i; - for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; ++i) { - dst->v[i] ^= src->v[i]; - } -} - static void load_block(block *dst, const void *input) { diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-core.h b/src/libsodium/crypto_pwhash/argon2/argon2-core.h index c14d8465..776dd871 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-core.h +++ b/src/libsodium/crypto_pwhash/argon2/argon2-core.h @@ -14,6 +14,8 @@ #ifndef argon2_core_H #define argon2_core_H +#include + #include "argon2.h" /*************************Argon2 internal @@ -60,13 +62,28 @@ typedef struct block_region_ { /*****************Functions that work with the block******************/ /* Initialize each byte of the block with @in */ -void init_block_value(block *b, uint8_t in); +static inline void +init_block_value(block *b, uint8_t in) +{ + memset(b->v, in, sizeof(b->v)); +} /* Copy block @src to block @dst */ -void copy_block(block *dst, const block *src); +static inline void +copy_block(block *dst, const block *src) +{ + memcpy(dst->v, src->v, sizeof(uint64_t) * ARGON2_QWORDS_IN_BLOCK); +} /* XOR @src onto @dst bytewise */ -void xor_block(block *dst, const block *src); +static inline void +xor_block(block *dst, const block *src) +{ + int i; + for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; ++i) { + dst->v[i] ^= src->v[i]; + } +} /* * Argon2 instance: memory pointer, number of passes, amount of memory, type,