2016-06-12 01:14:56 +02:00
|
|
|
/* This file is part of libbrandt.
|
|
|
|
* Copyright (C) 2016 GNUnet e.V.
|
|
|
|
*
|
|
|
|
* libbrandt is free software: you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* libbrandt 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* libbrandt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file crypto.h
|
|
|
|
* @brief Interface of the crypto primitives.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BRANDT_CRYPTO_H
|
|
|
|
#define _BRANDT_CRYPTO_H
|
|
|
|
|
|
|
|
#include <gcrypt.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2016-06-12 20:52:22 +02:00
|
|
|
extern gcry_mpi_point_t ec_gen;
|
|
|
|
extern gcry_ctx_t ec_ctx;
|
2016-06-12 01:14:56 +02:00
|
|
|
|
|
|
|
|
2016-06-12 20:52:22 +02:00
|
|
|
void brandt_crypto_init ();
|
|
|
|
|
2016-06-12 01:14:56 +02:00
|
|
|
|
2016-06-12 20:52:22 +02:00
|
|
|
/* --- RANDOM --- */
|
|
|
|
|
|
|
|
void brandt_rand_poll ();
|
2016-06-12 01:14:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* --- HASHING --- */
|
|
|
|
|
|
|
|
struct brandt_hash_code {
|
|
|
|
uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */
|
|
|
|
};
|
|
|
|
|
|
|
|
void brandt_hash (const void *block, size_t size, struct brandt_hash_code *ret);
|
|
|
|
|
|
|
|
|
|
|
|
/* --- MPI --- */
|
|
|
|
|
|
|
|
void brandt_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val);
|
2016-06-12 20:52:22 +02:00
|
|
|
void brandt_mpi_scan_unsigned (gcry_mpi_t *result, const void *data, size_t size);
|
2016-06-12 01:14:56 +02:00
|
|
|
|
|
|
|
|
2016-06-12 20:52:22 +02:00
|
|
|
/* --- EC --- */
|
2016-06-12 01:14:56 +02:00
|
|
|
|
2016-06-12 20:52:22 +02:00
|
|
|
void brandt_ec_skey_create (gcry_mpi_t* skey);
|
|
|
|
void brandt_ec_pkey_compute (gcry_mpi_point_t* pkey, const gcry_mpi_t skey);
|
|
|
|
void brandt_ec_keypair_create (gcry_mpi_point_t* pkey, gcry_mpi_t* skey);
|
2016-06-12 01:14:56 +02:00
|
|
|
|
|
|
|
#endif /* ifndef _BRANDT_CRYPTO_H */
|