Hi David,
On 13-10-16 21:59, David Sommerseth wrote:
> This function is quite useful other places, so make it generally
> accessible.
>
> Signed-off-by: David Sommerseth <[email protected]>
> ---
> src/openvpn/crypto.c | 18 ------------------
> src/openvpn/crypto.h | 18 ++++++++++++++++++
> 2 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c
> index 3dd4a9e..026d9ae 100644
> --- a/src/openvpn/crypto.c
> +++ b/src/openvpn/crypto.c
> @@ -66,24 +66,6 @@
> #define CRYPT_ERROR(format) \
> do { msg (D_CRYPT_ERRORS, "%s: " format, error_prefix); goto error_exit; }
> while (false)
>
> -/**
> - * As memcmp(), but constant-time.
> - * Returns 0 when data is equal, non-zero otherwise.
> - */
> -static int
> -memcmp_constant_time (const void *a, const void *b, size_t size) {
> - const uint8_t * a1 = a;
> - const uint8_t * b1 = b;
> - int ret = 0;
> - size_t i;
> -
> - for (i = 0; i < size; i++) {
> - ret |= *a1++ ^ *b1++;
> - }
> -
> - return ret;
> -}
> -
> static void
> openvpn_encrypt_aead (struct buffer *buf, struct buffer work,
> struct crypto_options *opt) {
> diff --git a/src/openvpn/crypto.h b/src/openvpn/crypto.h
> index 3b6bb98..9ae0610 100644
> --- a/src/openvpn/crypto.h
> +++ b/src/openvpn/crypto.h
> @@ -476,6 +476,24 @@ void get_tls_handshake_key (const struct key_type
> *key_type,
> * Inline functions
> */
>
> +/**
> + * As memcmp(), but constant-time.
> + * Returns 0 when data is equal, non-zero otherwise.
> + */
> +static int
I think this should carry an 'inline', now that it's in the header.
> +memcmp_constant_time (const void *a, const void *b, size_t size) {
> + const uint8_t * a1 = a;
> + const uint8_t * b1 = b;
> + int ret = 0;
> + size_t i;
> +
> + for (i = 0; i < size; i++) {
Since we're allowed to write C99 now, can we take this opportunity to
save ourselves a line and write for (size_t i = 0, ...) ? (Feel free to
ignore if you disagree.)
If you fix the first comment: ACK.
-Steffan
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel