1 /* $OpenBSD: curve25519.h,v 1.3 2019/05/11 15:55:52 tb Exp $ */ 2 /* 3 * Copyright (c) 2015, Google Inc. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 12 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 14 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 15 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 /** 18 * Curve25519. 19 * 20 * Curve25519 is an elliptic curve. 21 * 22 * See_Also: 23 * https://tools.ietf.org/html/rfc7748 24 */ 25 module libressl_d.openssl.curve25519; 26 27 28 private static import core.stdc.stdint; 29 public import libressl_d.openssl.opensslconf; 30 31 extern (C): 32 nothrow @nogc: 33 34 /** 35 * X25519. 36 * 37 * X25519 is the Diffie-Hellman primitive built from curve25519. It is 38 * sometimes referred to as curve25519, but X25519 is a more precise name. 39 * 40 * See_Also: 41 * http://cr.yp.to/ecdh.html 42 * https://tools.ietf.org/html/rfc7748 43 */ 44 enum X25519_KEY_LENGTH = 32; 45 46 /** 47 * X25519_keypair sets |out_public_value| and |out_private_key| to a freshly 48 * generated, public/private key pair. 49 */ 50 void X25519_keypair(core.stdc.stdint.uint8_t* out_public_value, core.stdc.stdint.uint8_t* out_private_key); 51 52 /** 53 * X25519 writes a shared key to |out_shared_key| that is calculated from the 54 * given private key and the peer's public value. It returns one on success and 55 * zero on error. 56 * 57 * Don't use the shared key directly, rather use a KDF and also include the two 58 * public values as inputs. 59 */ 60 int X25519(core.stdc.stdint.uint8_t* out_shared_key, const (core.stdc.stdint.uint8_t)* private_key, const (core.stdc.stdint.uint8_t)* peers_public_value);