dh.h File Reference

Diffie-Hellman key exchange. More...

#include "core/crypto.h"
#include "mpi/mpi.h"

Go to the source code of this file.

Data Structures

struct  DhParameters
 Diffie-Hellman parameters. More...
 
struct  DhContext
 Diffie-Hellman context. More...
 

Functions

void dhInit (DhContext *context)
 Initialize Diffie-Hellman context. More...
 
void dhFree (DhContext *context)
 Release Diffie-Hellman context. More...
 
void dhInitParameters (DhParameters *params)
 Initialize Diffie-Hellman parameters. More...
 
void dhFreeParameters (DhParameters *params)
 Release Diffie-Hellman parameters. More...
 
error_t dhGenerateKeyPair (DhContext *context, const PrngAlgo *prngAlgo, void *prngContext)
 Diffie-Hellman key pair generation. More...
 
error_t dhCheckPublicKey (DhParameters *params, const Mpi *publicKey)
 Check Diffie-Hellman public value. More...
 
error_t dhComputeSharedSecret (DhContext *context, uint8_t *output, size_t outputSize, size_t *outputLen)
 Compute Diffie-Hellman shared secret. More...
 

Detailed Description

Diffie-Hellman key exchange.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneCRYPTO Open.

This program 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 2 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 General Public License for more details.

You should have received a copy of the GNU 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
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file dh.h.

Function Documentation

◆ dhCheckPublicKey()

error_t dhCheckPublicKey ( DhParameters params,
const Mpi publicKey 
)

Check Diffie-Hellman public value.

Parameters
[in]paramsPointer to the Diffie-Hellman parameters
[in]publicKeyPublic value to be checked
Returns
Error code

Definition at line 183 of file dh.c.

◆ dhComputeSharedSecret()

error_t dhComputeSharedSecret ( DhContext context,
uint8_t *  output,
size_t  outputSize,
size_t *  outputLen 
)

Compute Diffie-Hellman shared secret.

Parameters
[in]contextPointer to the Diffie-Hellman context
[out]outputBuffer where to store the shared secret
[in]outputSizeSize of the buffer in bytes
[out]outputLenLength of the resulting shared secret
Returns
Error code

Definition at line 223 of file dh.c.

◆ dhFree()

void dhFree ( DhContext context)

Release Diffie-Hellman context.

Parameters
[in]contextPointer to the Diffie-Hellman context

Definition at line 71 of file dh.c.

◆ dhFreeParameters()

void dhFreeParameters ( DhParameters params)

Release Diffie-Hellman parameters.

Parameters
[in]paramsPointer to the Diffie-Hellman parameters

Definition at line 102 of file dh.c.

◆ dhGenerateKeyPair()

error_t dhGenerateKeyPair ( DhContext context,
const PrngAlgo prngAlgo,
void *  prngContext 
)

Diffie-Hellman key pair generation.

Parameters
[in]contextPointer to the Diffie-Hellman context
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
Returns
Error code

Definition at line 119 of file dh.c.

◆ dhInit()

void dhInit ( DhContext context)

Initialize Diffie-Hellman context.

Parameters
[in]contextPointer to the Diffie-Hellman context

Definition at line 54 of file dh.c.

◆ dhInitParameters()

void dhInitParameters ( DhParameters params)

Initialize Diffie-Hellman parameters.

Parameters
[in]paramsPointer to the Diffie-Hellman parameters

Definition at line 88 of file dh.c.