Update the imported curve448 code to use OpenSSL copyright headers
[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 (
16     gf a,
17     const gf x
18 ) {
19     gf L0, L1, L2;
20     gf_sqr  (L1,     x );
21     gf_mul  (L2,     x,   L1 );
22     gf_sqr  (L1,   L2 );
23     gf_mul  (L2,     x,   L1 );
24     gf_sqrn (L1,   L2,     3 );
25     gf_mul  (L0,   L2,   L1 );
26     gf_sqrn (L1,   L0,     3 );
27     gf_mul  (L0,   L2,   L1 );
28     gf_sqrn (L2,   L0,     9 );
29     gf_mul  (L1,   L0,   L2 );
30     gf_sqr  (L0,   L1 );
31     gf_mul  (L2,     x,   L0 );
32     gf_sqrn (L0,   L2,    18 );
33     gf_mul  (L2,   L1,   L0 );
34     gf_sqrn (L0,   L2,    37 );
35     gf_mul  (L1,   L2,   L0 );
36     gf_sqrn (L0,   L1,    37 );
37     gf_mul  (L1,   L2,   L0 );
38     gf_sqrn (L0,   L1,   111 );
39     gf_mul  (L2,   L1,   L0 );
40     gf_sqr  (L0,   L2 );
41     gf_mul  (L1,     x,   L0 );
42     gf_sqrn (L0,   L1,   223 );
43     gf_mul  (L1,   L2,   L0 );
44     gf_sqr  (L2, L1);
45     gf_mul  (L0, L2, x);
46     gf_copy(a,L1);
47     return gf_eq(L0,ONE);
48 }