Commit | Line | Data |
---|---|---|
643eb1bb MW |
1 | /* -*-c-*- |
2 | * | |
3 | * The X448 key-agreement algorithm | |
4 | * | |
5 | * (c) 2017 Straylight/Edgeware | |
6 | */ | |
7 | ||
8 | /*----- Licensing notice --------------------------------------------------* | |
9 | * | |
10 | * This file is part of Catacomb. | |
11 | * | |
12 | * Catacomb is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU Library General Public License as | |
14 | * published by the Free Software Foundation; either version 2 of the | |
15 | * License, or (at your option) any later version. | |
16 | * | |
17 | * Catacomb is distributed in the hope that it will be useful, | |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | * GNU Library General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Library General Public | |
23 | * License along with Catacomb; if not, write to the Free | |
24 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, | |
25 | * MA 02111-1307, USA. | |
26 | */ | |
27 | ||
28 | #ifndef CATACOMB_X448_H | |
29 | #define CATACOMB_X448_H | |
30 | ||
31 | #ifdef __cplusplus | |
32 | extern "C" { | |
33 | #endif | |
34 | ||
35 | /*----- Notes on the X448 key-agreement algorithm -------------------------* | |
36 | * | |
37 | * This is X448, as described in RFC7748, based on the elliptic curve defined | |
38 | * in Mike Hamburg, `Ed448-Goldilocks, a new elliptic curve', EUROCRYPT 2016, | |
c578d5d8 MW |
39 | * https://eprint.iacr.org/2015/625/. (The curve here is 4-isogenous to |
40 | * Hamburg's curve.) | |
643eb1bb MW |
41 | * |
42 | * The RFC-specified operation is simpler than the Diffie--Hellman function | |
43 | * described in Hamburg's paper, since it doesn't involve the `Decaf' | |
44 | * cofactor elimination procedure. Indeed, it looks very much like X25519 | |
45 | * with Hamburg's curve slotted in in place of Bernstein's. | |
6dbc50ef MW |
46 | * |
47 | * The @x448@ function essentially performs incompatible cofactor | |
48 | * multiplication on the elliptic curve %$E(k)$% containing points %$(x, y)$% | |
49 | * in %$\proj^2(k)$% satisfying the Montgomery-form equation | |
50 | * | |
51 | * %$y^3 = x^3 + 156326 x^2 + x$% , | |
52 | * | |
53 | * where $k = \gf{p}$, with $p = \phi^2 - \phi - 1$%, where | |
54 | * %$\phi = 2^{224}$%. The curve has %$n = (p + 1) + {}$% | |
55 | * %$28312320572429821613362531907042076847709625476988141958474579766324$% | |
56 | * points; this is four times a prime %$\ell$%. The points with | |
57 | * %$x$%-coordinate 5 have order %$\ell$%. | |
643eb1bb MW |
58 | */ |
59 | ||
60 | /*----- Header files ------------------------------------------------------*/ | |
61 | ||
62 | #include <mLib/bits.h> | |
63 | ||
64 | #ifndef CATACOMB_KEY_H | |
65 | # include "key.h" | |
66 | #endif | |
67 | ||
68 | /*----- Key fetching ------------------------------------------------------*/ | |
69 | ||
70 | typedef struct x448_priv { key_bin priv, pub; } x448_priv; | |
71 | typedef struct x448_pub { key_bin pub; } x448_pub; | |
72 | ||
73 | extern const key_fetchdef x448_pubfetch[], x448_privfetch[]; | |
74 | #define X448_PUBFETCHSZ 3 | |
75 | #define X448_PRIVFETCHSZ 6 | |
76 | ||
77 | /*----- Important constants -----------------------------------------------*/ | |
78 | ||
79 | #define X448_KEYSZ 56 | |
80 | #define X448_PUBSZ 56 | |
81 | #define X448_OUTSZ 56 | |
82 | ||
83 | extern const octet x448_base[56]; | |
84 | ||
85 | /*----- Functions provided ------------------------------------------------*/ | |
86 | ||
87 | /* --- @x448@ --- * | |
88 | * | |
89 | * Arguments: @octet zz[X448_OUTSZ]@ = where to put the result | |
90 | * @const octet k[X448_KEYSZ]@ = pointer to private key | |
91 | * @const octet qx[X448_PUBSZ]@ = pointer to public value | |
92 | * | |
93 | * Returns: --- | |
94 | * | |
95 | * Use: Calculates X448 of @k@ and @qx@. | |
96 | */ | |
97 | ||
98 | extern void x448(octet /*zz*/[X448_OUTSZ], | |
99 | const octet /*k*/[X448_KEYSZ], | |
100 | const octet /*qx*/[X448_PUBSZ]); | |
101 | ||
102 | /*----- That's all, folks -------------------------------------------------*/ | |
103 | ||
104 | #ifdef __cplusplus | |
105 | } | |
106 | #endif | |
107 | ||
108 | #endif |