Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dh.h Source File

dh.h

Go to the documentation of this file.
00001 /**
00002  * @file dh.h
00003  * @brief Diffie-Hellman key exchange
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneCrypto Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _DH_H
00030 #define _DH_H
00031 
00032 //Dependencies
00033 #include "crypto.h"
00034 #include "mpi.h"
00035 
00036 
00037 /**
00038  * @brief Diffie-Hellman parameters
00039  **/
00040 
00041 typedef struct
00042 {
00043    Mpi p; ///<Prime modulus
00044    Mpi g; ///<Generator
00045 } DhParameters;
00046 
00047 
00048 /**
00049  * @brief Diffie-Hellman context
00050  **/
00051 
00052 typedef struct
00053 {
00054    DhParameters params; //Diffie-Hellman parameters
00055    Mpi xa;              ///<One's own private value
00056    Mpi ya;              ///<One's own public value
00057    Mpi yb;              ///<Peer's public value
00058 } DhContext;
00059 
00060 
00061 //Diffie-Hellman related functions
00062 void dhInit(DhContext *context);
00063 void dhFree(DhContext *context);
00064 
00065 error_t dhGenerateKeyPair(DhContext *context,
00066    const PrngAlgo *prngAlgo, void *prngContext);
00067 
00068 error_t dhCheckPublicKey(DhParameters *params, const Mpi *publicKey);
00069 
00070 error_t dhComputeSharedSecret(DhContext *context,
00071    uint8_t *output, size_t outputSize, size_t *outputLength);
00072 
00073 #endif
00074