libsecret/egg/egg-dh.h
Daiki Ueno 47f524e2df egg-dh: Hide gcry_mpi_t from the internal API
This wraps gcry_mpi_t usage in the API with opaque strucs, so it would
be easier to port egg-dh to other crypto libraries.

Signed-off-by: Daiki Ueno <dueno@src.gnome.org>
2023-11-28 14:51:23 +09:00

59 lines
2.3 KiB
C

/*
* gnome-keyring
*
* Copyright (C) 2009 Stefan Walter
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*
* Author: Stef Walter <stefw@thewalter.net>
*/
#ifndef EGG_DH_H_
#define EGG_DH_H_
#include <glib.h>
typedef struct egg_dh_params egg_dh_params;
typedef struct egg_dh_pubkey egg_dh_pubkey;
typedef struct egg_dh_privkey egg_dh_privkey;
egg_dh_params *egg_dh_default_params (const gchar *name);
gboolean egg_dh_default_params_raw (const gchar *name,
gconstpointer *prime,
gsize *n_prime,
gconstpointer *base,
gsize *n_base);
gboolean egg_dh_gen_pair (egg_dh_params *params,
guint bits,
egg_dh_pubkey **pub,
egg_dh_privkey **priv);
GBytes *egg_dh_gen_secret (egg_dh_pubkey *peer,
egg_dh_privkey *priv,
egg_dh_params *prime);
void egg_dh_params_free (egg_dh_params *params);
void egg_dh_pubkey_free (egg_dh_pubkey *pubkey);
void egg_dh_privkey_free (egg_dh_privkey *privkey);
GBytes *egg_dh_pubkey_export (const egg_dh_pubkey *pubkey);
egg_dh_pubkey *egg_dh_pubkey_new_from_bytes (const egg_dh_params *params,
GBytes *bytes);
#endif /* EGG_DH_H_ */