Run util/openssl-format-source on the Curve448 code
[openssl.git] / crypto / ec / curve448 / f_arithmetic.c
1 /*
2  * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
3  * Copyright 2014 Cryptography Research, Inc.
4  *
5  * Licensed under the OpenSSL license (the "License").  You may not use
6  * this file except in compliance with the License.  You can obtain a copy
7  * in the file LICENSE in the source distribution or at
8  * https://www.openssl.org/source/license.html
9  *
10  * Originally written by Mike Hamburg
11  */
12
13 #include "field.h"
14
15 mask_t gf_isr(gf a, const gf x)
16 {
17     gf L0, L1, L2;
18     gf_sqr(L1, x);
19     gf_mul(L2, x, L1);
20     gf_sqr(L1, L2);
21     gf_mul(L2, x, L1);
22     gf_sqrn(L1, L2, 3);
23     gf_mul(L0, L2, L1);
24     gf_sqrn(L1, L0, 3);
25     gf_mul(L0, L2, L1);
26     gf_sqrn(L2, L0, 9);
27     gf_mul(L1, L0, L2);
28     gf_sqr(L0, L1);
29     gf_mul(L2, x, L0);
30     gf_sqrn(L0, L2, 18);
31     gf_mul(L2, L1, L0);
32     gf_sqrn(L0, L2, 37);
33     gf_mul(L1, L2, L0);
34     gf_sqrn(L0, L1, 37);
35     gf_mul(L1, L2, L0);
36     gf_sqrn(L0, L1, 111);
37     gf_mul(L2, L1, L0);
38     gf_sqr(L0, L2);
39     gf_mul(L1, x, L0);
40     gf_sqrn(L0, L1, 223);
41     gf_mul(L1, L2, L0);
42     gf_sqr(L2, L1);
43     gf_mul(L0, L2, x);
44     gf_copy(a, L1);
45     return gf_eq(L0, ONE);
46 }