Skip to content

Commit 39844bf

Browse files
committed
add ecc SVDP_DH
1 parent f5e1e7f commit 39844bf

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/ecc/nRFCrypto_ECC.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424

2525
#include "nrf_cc310/include/crys_ecpki_kg.h"
26+
#include "nrf_cc310/include/crys_ecpki_dh.h"
2627

2728
#include "Adafruit_nRFCrypto.h"
2829

@@ -55,6 +56,23 @@ bool nRFCrypto_ECC::genKeyPair(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_
5556
return true;
5657
}
5758

59+
uint32_t nRFCrypto_ECC::SVDP_DH(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& peer_pubkey, uint8_t* shared_secret, uint32_t bufsize)
60+
{
61+
CRYS_ECDH_TempData_t* tempbuf = (CRYS_ECDH_TempData_t *) rtos_malloc(sizeof(CRYS_ECDH_TempData_t));
62+
VERIFY(tempbuf);
63+
64+
nRFCrypto.enable();
65+
66+
uint32_t err = CRYS_ECDH_SVDP_DH(&peer_pubkey._key, &private_key._key, shared_secret, &bufsize, tempbuf);
67+
68+
nRFCrypto.disable();
69+
70+
rtos_free(tempbuf);
71+
72+
VERIFY_CRYS(err, 0);
73+
return bufsize;
74+
}
75+
5876
nRFCrypto_ECC::nRFCrypto_ECC(void)
5977
{
6078

src/ecc/nRFCrypto_ECC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class nRFCrypto_ECC
3737
public:
3838
//------------- Static Members -------------//
3939
static bool genKeyPair(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& public_key);
40+
static uint32_t SVDP_DH(nRFCrypto_ECC_PrivateKey& private_key, nRFCrypto_ECC_PublicKey& peer_pubkey, uint8_t* shared_secret, uint32_t bufsize);
4041

4142
public:
4243
nRFCrypto_ECC(void);

0 commit comments

Comments
 (0)