Skip to content

Commit

Permalink
add ecc SVDP_DH
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Feb 13, 2020
1 parent f5e1e7f commit 39844bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ecc/nRFCrypto_ECC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

#include "nrf_cc310/include/crys_ecpki_kg.h"
#include "nrf_cc310/include/crys_ecpki_dh.h"

#include "Adafruit_nRFCrypto.h"

Expand Down Expand Up @@ -55,6 +56,23 @@ bool nRFCrypto_ECC::genKeyPair(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_
return true;
}

uint32_t nRFCrypto_ECC::SVDP_DH(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& peer_pubkey, uint8_t* shared_secret, uint32_t bufsize)
{
CRYS_ECDH_TempData_t* tempbuf = (CRYS_ECDH_TempData_t *) rtos_malloc(sizeof(CRYS_ECDH_TempData_t));
VERIFY(tempbuf);

nRFCrypto.enable();

uint32_t err = CRYS_ECDH_SVDP_DH(&peer_pubkey._key, &private_key._key, shared_secret, &bufsize, tempbuf);

nRFCrypto.disable();

rtos_free(tempbuf);

VERIFY_CRYS(err, 0);
return bufsize;
}

nRFCrypto_ECC::nRFCrypto_ECC(void)
{

Expand Down
1 change: 1 addition & 0 deletions src/ecc/nRFCrypto_ECC.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class nRFCrypto_ECC
public:
//------------- Static Members -------------//
static bool genKeyPair(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& public_key);
static uint32_t SVDP_DH(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& peer_pubkey, uint8_t* shared_secret, uint32_t bufsize);

public:
nRFCrypto_ECC(void);
Expand Down

0 comments on commit 39844bf

Please sign in to comment.