Data Structures | Macros | Enumerations
ECDHCC26X2.h File Reference

Detailed Description

ECDH driver implementation for the CC26X2 family.

============================================================================

Warning
This is a beta API. It may change in future releases.

This file should only be included in the board file to fill the ECDH_config struct.

Hardware and Implementation Details

The CC26X2 family has a dedicated public key accelerator. It is capable of multiple mathematical operations including dedicated ECC point addition, doubling, and scalar multiplication. Only one operation can be carried out on the accelerator at a time. Mutual exclusion is implemented at the driver level and coordinated between all drivers relying on the accelerator. It is transparent to the application and only noted ensure sensible access timeouts are set.

The large number maths engine (LNME) uses a dedicated 2kB block of RAM (PKA RAM) for its operations. The operands of the maths operations must be copied into and results out of the PKA ram. This necessitates a significant number of reads and writes for each operation. The bus interface to the RAM only allows for word-aligned reads and writes. The CPU splits the reads and writes from and to general SRAM from unaligned addresses into multiple bus operations while accumulating the data in a register until it is full. The result of this hardware process is that providing buffers such as plaintext CryptoKey keying material to ECC APIs that are word-aligned will significantly speed up the operation and reduce power consumption.

The driver implementation does not perform runtime checks for most input parameters. Only values that are likely to have a stochastic element to them are checked (such as whether a driver is already open). Higher input parameter validation coverage is achieved by turning on assertions when compiling the driver.

Supported Curve Types

The driver implementation supports the following curve types for ECDH:

Curve Type Supported
Short Weierstrass Yes
Montgomery Yes
Edwards No

Curve25519 Private Keys

When using Montgomery Curve25519, the private key must be formatted according to cr.yp.to/ecdh.html by the application before passing it to the driver. The driver cannot do so itself as the memory location of the keying material may be in flash.

For keying material uint8_t myPrivateKey[32], you must do the following:

myPrivateKey[0] &= 0xF8;
myPrivateKey[31] &= 0x7F;
myPrivateKey[31] |= 0x40;

Alternatively, you can call ECCParams_FormatCurve25519PrivateKey() in ti/drivers/cryptoutils/ecc/ECCParams.h

Public Key Validation

When performing shared secret generation, the foreign public key will always be validated when using short Weierstrass curves. The only explicitly supported Montgomery curve is Curve25519 which does not require public key validation. The implementation assumes that the cofactor, h, of the curve is 1. This lets us skip the computationally expensive step of multiplying the foreign key by the order and checking if it yields the point at infinity. When the cofactor is 1, this property is implied by validating that the point is not already the point at infinity and that it validates against the curve equation. All curves supplied by default, the NIST and Brainpool curves, have cofactor = 1. While the implementation can use arbitrary curves, you should verify that any other curve used has a cofactor of 1.

#include <stdint.h>
#include <stdbool.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/ECDH.h>
#include <ti/drivers/cryptoutils/ecc/ECCParams.h>
#include <ti/drivers/cryptoutils/cryptokey/CryptoKey.h>
#include <ti/devices/DeviceFamily.h>
#include <DeviceFamily_constructPath(driverlib/pka.h)>
#include <ti/drivers/dpl/HwiP.h>
#include <ti/drivers/dpl/SwiP.h>
#include <ti/drivers/dpl/SemaphoreP.h>
Include dependency graph for ECDHCC26X2.h:

Go to the source code of this file.

Data Structures

struct  ECDHCC26X2_HWAttrs
 ECDHCC26X2 Hardware Attributes. More...
 
struct  ECDHCC26X2_Object
 ECDHCC26X2 Object. More...
 

Macros

#define ECDHCC26X2_STATUS_FSM_RUN_PKA_OP   ECDH_STATUS_RESERVED - 0
 
#define ECDHCC26X2_STATUS_FSM_RUN_FSM   ECDH_STATUS_RESERVED - 1
 

Enumerations

enum  ECDHCC26X2_FsmState {
  ECDHCC26X2_FSM_ERROR = 0, ECDHCC26X2_FSM_GEN_PUB_KEY_MULT_PRIVATE_KEY_BY_GENERATOR, ECDHCC26X2_FSM_GEN_PUB_KEY_MULT_PRIVATE_KEY_BY_GENERATOR_RESULT, ECDHCC26X2_FSM_GEN_PUB_KEY_RETURN,
  ECDHCC26X2_FSM_GEN_PUB_KEY_MULT_PRIVATE_KEY_BY_GENERATOR_MONTGOMERY, ECDHCC26X2_FSM_GEN_PUB_KEY_MULT_PRIVATE_KEY_BY_GENERATOR_RESULT_MONTGOMERY, ECDHCC26X2_FSM_GEN_PUB_KEY_RETURN_MONTGOMERY, ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_MULT_PRIVATE_KEY_BY_PUB_KEY,
  ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_MULT_PRIVATE_KEY_BY_PUB_KEY_RESULT, ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_RETURN, ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_MULT_PRIVATE_KEY_BY_PUB_KEY_MONTGOMERY, ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_MULT_PRIVATE_KEY_BY_PUB_KEY_RESULT_MONTGOMERY,
  ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_RETURN_MONTGOMERY
}
 ECDHCC26X2 states. More...
 

Macro Definition Documentation

§ ECDHCC26X2_STATUS_FSM_RUN_PKA_OP

#define ECDHCC26X2_STATUS_FSM_RUN_PKA_OP   ECDH_STATUS_RESERVED - 0

§ ECDHCC26X2_STATUS_FSM_RUN_FSM

#define ECDHCC26X2_STATUS_FSM_RUN_FSM   ECDH_STATUS_RESERVED - 1

Enumeration Type Documentation

§ ECDHCC26X2_FsmState

ECDHCC26X2 states.

The ECDH operations are implemented using multiple invidividual PKA operations. Since state transitions for these operations are almost always predictable, the state transitions are encoded linearly in this enum. The FSM controller will increment the state counter and iterate through states until it is told to stop or restart.

Enumerator
ECDHCC26X2_FSM_ERROR 
ECDHCC26X2_FSM_GEN_PUB_KEY_MULT_PRIVATE_KEY_BY_GENERATOR 
ECDHCC26X2_FSM_GEN_PUB_KEY_MULT_PRIVATE_KEY_BY_GENERATOR_RESULT 
ECDHCC26X2_FSM_GEN_PUB_KEY_RETURN 
ECDHCC26X2_FSM_GEN_PUB_KEY_MULT_PRIVATE_KEY_BY_GENERATOR_MONTGOMERY 
ECDHCC26X2_FSM_GEN_PUB_KEY_MULT_PRIVATE_KEY_BY_GENERATOR_RESULT_MONTGOMERY 
ECDHCC26X2_FSM_GEN_PUB_KEY_RETURN_MONTGOMERY 
ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_MULT_PRIVATE_KEY_BY_PUB_KEY 
ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_MULT_PRIVATE_KEY_BY_PUB_KEY_RESULT 
ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_RETURN 
ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_MULT_PRIVATE_KEY_BY_PUB_KEY_MONTGOMERY 
ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_MULT_PRIVATE_KEY_BY_PUB_KEY_RESULT_MONTGOMERY 
ECDHCC26X2_FSM_COMPUTE_SHARED_SECRET_RETURN_MONTGOMERY 
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale