/*
 * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
 * Copyright 2016 Cryptography Research, Inc.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 *
 * Originally written by Mike Hamburg
 */

#ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
# define OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H

# include "internal/constant_time.h"

# define ARCH_WORD_BITS 64

# define word_is_zero(a)     constant_time_is_zero_64(a)

static ossl_inline uint128_t widemul(uint64_t a, uint64_t b)
{
    return ((uint128_t) a) * b;
}

#endif                          /* OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H */

/*
 * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
 * Copyright 2016 Cryptography Research, Inc.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 *
 * Originally written by Mike Hamburg
 */

#ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
# define OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H

# define ARCH_WORD_BITS 64

static ossl_inline uint64_t word_is_zero(uint64_t a)
{
    /* let's hope the compiler isn't clever enough to optimize this. */
    return (((__uint128_t) a) - 1) >> 64;
}

static ossl_inline uint128_t widemul(uint64_t a, uint64_t b)
{
    return ((uint128_t) a) * b;
}

#endif                          /* OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H */

--- 
+++ 
@@ -13,13 +13,11 @@
 #ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
 # define OSSL_CRYPTO_EC_CURVE448_ARCH_64_INTRINSICS_H
 
+# include "internal/constant_time.h"
+
 # define ARCH_WORD_BITS 64
 
-static ossl_inline uint64_t word_is_zero(uint64_t a)
-{
-    /* let's hope the compiler isn't clever enough to optimize this. */
-    return (((__uint128_t) a) - 1) >> 64;
-}
+# define word_is_zero(a)     constant_time_is_zero_64(a)
 
 static ossl_inline uint128_t widemul(uint64_t a, uint64_t b)
 {
curve448: Use constant time zero check function

Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>

Reviewed-by: Tomas Mraz <2bc6038c3dfca09b2da23c8b6da8ba884dc2dcc2@openssl.org>
Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14784)
