CC26xx Driver Library
Rom_crypto_api

Functions

void ECC_initialize (uint32_t *pWorkzone)
 Initialize elliptic curve parameters to default values and specify workzone. More...
 
void ECC_init (uint32_t *workzone, uint8_t windowSize, const uint32_t *prime, const uint32_t *order, const uint32_t *a, const uint32_t *b, const uint32_t *generatorX, const uint32_t *generatorY)
 Initialize elliptic curve parameters to specified values and specify workzone. More...
 
uint8_t ECC_generateKey (uint32_t *randString, uint32_t *privateKey, uint32_t *publicKey_x, uint32_t *publicKey_y)
 Generate a key. More...
 
uint8_t ECC_ECDSA_sign (uint32_t *secretKey, uint32_t *text, uint32_t *randString, uint32_t *sign1, uint32_t *sign2)
 Sign data. More...
 
uint8_t ECC_ECDSA_verify (uint32_t *publicKey_x, uint32_t *publicKey_y, uint32_t *text, uint32_t *sign1, uint32_t *sign2)
 Verify signature. More...
 
uint8_t ECC_ECDH_computeSharedSecret (uint32_t *privateKey, uint32_t *publicKey_x, uint32_t *publicKey_y, uint32_t *sharedSecret_x, uint32_t *sharedSecret_y)
 Compute the shared secret. More...
 

Detailed Description

Function Documentation

§ ECC_ECDH_computeSharedSecret()

uint8_t ECC_ECDH_computeSharedSecret ( uint32_t *  privateKey,
uint32_t *  publicKey_x,
uint32_t *  publicKey_y,
uint32_t *  sharedSecret_x,
uint32_t *  sharedSecret_y 
)

Compute the shared secret.

Parameters
privateKeyPointer to private key, input.
publicKey_xPointer to public key X-coordinate, input.
publicKey_yPointer to public key Y-coordinate, input.
sharedSecret_xPointer to shared secret X-coordinate, output.
sharedSecret_yPointer to shared secret Y-coordinate, output.
Returns
Status
172 {
173  return (uint8_t)ecdh_computeSharedSecret((uint32_t*)privateKey, (uint32_t*)publicKey_x,
174  (uint32_t*)publicKey_y, (uint32_t*)sharedSecret_x,
175  (uint32_t*)sharedSecret_y);
176 }
ecdh_computeSharedSecret_t ecdh_computeSharedSecret
Definition: rom_crypto.c:129

§ ECC_ECDSA_sign()

uint8_t ECC_ECDSA_sign ( uint32_t *  secretKey,
uint32_t *  text,
uint32_t *  randString,
uint32_t *  sign1,
uint32_t *  sign2 
)

Sign data.

Parameters
secretKeyPointer to the secret key, input.
textPointer to the message, input.
randStringPointer to random string, input.
sign1Pointer to signature part 1, output.
sign2Pointer to signature part 2, output.
Returns
Status
149 {
150  return (uint8_t)ecc_ecdsa_sign((uint32_t*)secretKey, (uint32_t*)text, (uint32_t*)randString,
151  (uint32_t*)sign1, (uint32_t*)sign2);
152 }
ecdsa_sign_t ecc_ecdsa_sign
Definition: rom_crypto.c:123

§ ECC_ECDSA_verify()

uint8_t ECC_ECDSA_verify ( uint32_t *  publicKey_x,
uint32_t *  publicKey_y,
uint32_t *  text,
uint32_t *  sign1,
uint32_t *  sign2 
)

Verify signature.

Parameters
publicKey_xPointer to public key X-coordinate, input.
publicKey_yPointer to public key Y-coordinate, input.
textPointer to message data, input.
sign1Pointer to signature part 1, input.
sign2Pointer to signature part 2, input.
Returns
Status
160 {
161  return (uint8_t)ecc_ecdsa_verify((uint32_t*)publicKey_x, (uint32_t*)publicKey_y, (uint32_t*)text,
162  (uint32_t*)sign1, (uint32_t*)sign2);
163 }
ecdsa_verify_t ecc_ecdsa_verify
Definition: rom_crypto.c:126

§ ECC_generateKey()

uint8_t ECC_generateKey ( uint32_t *  randString,
uint32_t *  privateKey,
uint32_t *  publicKey_x,
uint32_t *  publicKey_y 
)

Generate a key.

This is used for both ECDH and ECDSA.

Parameters
randStringPointer to random string, input.
privateKeyPointer to the private key, output.
publicKey_xPointer to public key X-coordinate, output.
publicKey_yPointer to public key Y-coordinate, output.
Returns
Status
137 {
138  return (uint8_t)ecc_generatekey((uint32_t*)randString, (uint32_t*)privateKey,
139  (uint32_t*)publicKey_x, (uint32_t*)publicKey_y);
140 
141 }
ecc_keygen_t ecc_generatekey
Definition: rom_crypto.c:120

§ ECC_init()

void ECC_init ( uint32_t *  workzone,
uint8_t  windowSize,
const uint32_t *  prime,
const uint32_t *  order,
const uint32_t *  a,
const uint32_t *  b,
const uint32_t *  generatorX,
const uint32_t *  generatorY 
)

Initialize elliptic curve parameters to specified values and specify workzone.

This function may be used to explicitly specify the curve parameters used by the ECC in ROM implementation.

All curve parameters must be prepended with a length word specifying the length of the parameter in 32-bit words excluding the length word itself. For NIST-P256, the length word is 8.

Parameters
workzonePointer to memory allocated for computations, input. See description at beginning of ECC section for memory requirements.
windowSizeWindow size of workzone. Default value is 3.
primeCurve prime
orderCurve order
aCurve a value
bCurve b value
generatorXX coordinate of generator point
generatorYY coordinate of generator point
90 {
91  // Initialize curve parameters
92  //data_p = (uint32_t *)PARAM_P;
93  *((const uint32_t **)0x20000138) = prime;
94 
95  //data_r = (uint32_t *)PARAM_R;
96  *((const uint32_t **)0x2000013c) = order;
97 
98  //data_a = (uint32_t *)PARAM_A;
99  *((const uint32_t **)0x20000140) = a;
100 
101  //data_b = (uint32_t *)PARAM_B;
102  *((const uint32_t **)0x20000144) = b;
103 
104  //data_Gx = (uint32_t *)PARAM_GX;
105  *((const uint32_t **)0x2000012c) = generatorX;
106 
107  //data_Gy = (uint32_t *)PARAM_GY;
108  *((const uint32_t **)0x20000130) = generatorY;
109 
110  // Initialize window size
111  //win = (uint8_t) windowSize;
112  *((uint8_t *)0x20000148) = windowSize;
113 
114  // Initialize work zone
115  //workzone = (uint32_t *) pWorkzone;
116  *((uint32_t **)0x20000134) = workzone;
117 }

§ ECC_initialize()

void ECC_initialize ( uint32_t *  pWorkzone)

Initialize elliptic curve parameters to default values and specify workzone.

This function initializes the elliptic curve parameters to default values. The default elliptic curve used is NIST-P256.

The workzone defaults to an expected window size of 3.

This function can be called again to point the ECC workzone at a different memory buffer.

Parameters
pWorkzonePointer to memory allocated for computations, input. See description at beginning of ECC section for memory requirements.
Returns
None
49 {
50  // Initialize curve parameters
51  //data_p = ECC_NISTP256_prime;
52  *((const uint32_t **)0x20000138) = ECC_NISTP256_prime;
53 
54  //data_r = ECC_NISTP256_order;
55  *((const uint32_t **)0x2000013c) = ECC_NISTP256_order;
56 
57  //data_a = ECC_NISTP256_a;
58  *((const uint32_t **)0x20000140) = ECC_NISTP256_a;
59 
60  //data_b = ECC_NISTP256_b;
61  *((const uint32_t **)0x20000144) = ECC_NISTP256_b;
62 
63  //data_Gx = ECC_NISTP256_generatorX;
64  *((const uint32_t **)0x2000012c) = ECC_NISTP256_generatorX;
65 
66  //data_Gy = ECC_NISTP256_generatorY;
67  *((const uint32_t **)0x20000130) = ECC_NISTP256_generatorY;
68 
69  // Initialize window size
70  //win = (uint8_t) ECC_WINDOW_SIZE;
71  *((uint8_t *)0x20000148) = (uint8_t) ECC_WINDOW_SIZE;
72 
73  // Initialize work zone
74  //workzone = (uint32_t *) pWorkzone;
75  *((uint32_t **)0x20000134) = (uint32_t *) pWorkzone;
76 }
#define ECC_NISTP256_generatorX
Definition: rom_crypto.h:68
#define ECC_NISTP256_b
Definition: rom_crypto.h:67
#define ECC_NISTP256_generatorY
Definition: rom_crypto.h:69
#define ECC_NISTP256_order
Definition: rom_crypto.h:65
#define ECC_NISTP256_a
Definition: rom_crypto.h:66
#define ECC_WINDOW_SIZE
Definition: rom_crypto.h:93
#define ECC_NISTP256_prime
Definition: rom_crypto.h:64

Macro Definition Documentation

§ ECC_A_COEF_LENGTH_ZERO

#define ECC_A_COEF_LENGTH_ZERO   0xC5

§ ECC_A_COEF_TOO_LONG

#define ECC_A_COEF_TOO_LONG   0x5C

§ ECC_BAD_WINDOW_SIZE

#define ECC_BAD_WINDOW_SIZE   0x66

§ ECC_DIGEST_LENGTH_ZERO

#define ECC_DIGEST_LENGTH_ZERO   0x72

§ ECC_DIGEST_TOO_LONG

#define ECC_DIGEST_TOO_LONG   0x27

§ ECC_ECC_KEY_LENGTH_ZERO

#define ECC_ECC_KEY_LENGTH_ZERO   0x52

§ ECC_ECC_KEY_TOO_LONG

#define ECC_ECC_KEY_TOO_LONG   0x25

§ ECC_ECDH_COMMON_KEY_OK

#define ECC_ECDH_COMMON_KEY_OK   ECC_SCALAR_MUL_OK

§ ECC_ECDH_KEYGEN_OK

#define ECC_ECDH_KEYGEN_OK   ECC_SCALAR_MUL_OK

§ ECC_ECDSA_INVALID_SIGNATURE

#define ECC_ECDSA_INVALID_SIGNATURE   0x5A

§ ECC_ECDSA_KEYGEN_OK

#define ECC_ECDSA_KEYGEN_OK   ECC_SCALAR_MUL_OK

§ ECC_ECDSA_SIGN_OK

#define ECC_ECDSA_SIGN_OK   0x32

§ ECC_ECDSA_VALID_SIGNATURE

#define ECC_ECDSA_VALID_SIGNATURE   0xA5

§ ECC_LENGTH_OFFSET_BYTES

#define ECC_LENGTH_OFFSET_BYTES   4

§ ECC_MODULUS_EVEN

#define ECC_MODULUS_EVEN   0xDC

§ ECC_MODULUS_LARGER_THAN_255_WORDS

#define ECC_MODULUS_LARGER_THAN_255_WORDS   0xD2

§ ECC_MODULUS_LENGTH_ZERO

#define ECC_MODULUS_LENGTH_ZERO   0x08

§ ECC_MODULUS_MSW_IS_ZERO

#define ECC_MODULUS_MSW_IS_ZERO   0x30

§ ECC_NISTP256_a

#define ECC_NISTP256_a   ((const uint32_t *) 0x1002581c)

Referenced by ECC_initialize().

§ ECC_NISTP256_b

#define ECC_NISTP256_b   ((const uint32_t *) 0x10025840)

Referenced by ECC_initialize().

§ ECC_NISTP256_generatorX

#define ECC_NISTP256_generatorX   ((const uint32_t *) 0x10025864)

Referenced by ECC_initialize().

§ ECC_NISTP256_generatorY

#define ECC_NISTP256_generatorY   ((const uint32_t *) 0x10025888)

Referenced by ECC_initialize().

§ ECC_NISTP256_order

#define ECC_NISTP256_order   ((const uint32_t *) 0x100257f8)

Referenced by ECC_initialize().

§ ECC_NISTP256_PARAM_LENGTH_BYTES

#define ECC_NISTP256_PARAM_LENGTH_BYTES   32

§ ECC_NISTP256_PARAM_LENGTH_WORDS

#define ECC_NISTP256_PARAM_LENGTH_WORDS   (ECC_NISTP256_PARAM_LENGTH_BYTES / sizeof(uint32_t))

§ ECC_NISTP256_prime

#define ECC_NISTP256_prime   ((const uint32_t *) 0x100257d4)

Referenced by ECC_initialize().

§ ECC_ORDER_EVEN

#define ECC_ORDER_EVEN   0x82

§ ECC_ORDER_LARGER_THAN_255_WORDS

#define ECC_ORDER_LARGER_THAN_255_WORDS   0x28

§ ECC_ORDER_LENGTH_ZERO

#define ECC_ORDER_LENGTH_ZERO   0x6C

§ ECC_ORDER_MSW_IS_ZERO

#define ECC_ORDER_MSW_IS_ZERO   0x23

§ ECC_ORDER_TOO_LONG

#define ECC_ORDER_TOO_LONG   0xC6

§ ECC_PRIME_NIST256_CURVE

#define ECC_PRIME_NIST256_CURVE

§ ECC_SCALAR_LENGTH_ZERO

#define ECC_SCALAR_LENGTH_ZERO   0x53

§ ECC_SCALAR_MUL_OK

#define ECC_SCALAR_MUL_OK   0x99

§ ECC_SCALAR_TOO_LONG

#define ECC_SCALAR_TOO_LONG   0x35

§ ECC_SIG_P1_LENGTH_ZERO

#define ECC_SIG_P1_LENGTH_ZERO   0x12

§ ECC_SIG_P1_TOO_LONG

#define ECC_SIG_P1_TOO_LONG   0x11

§ ECC_SIG_P2_LENGTH_ZERO

#define ECC_SIG_P2_LENGTH_ZERO   0x21

§ ECC_SIG_P2_TOO_LONG

#define ECC_SIG_P2_TOO_LONG   0x22

§ ECC_WINDOW_SIZE

#define ECC_WINDOW_SIZE   3

Referenced by ECC_initialize().

§ ECC_X_COORD_LENGTH_ZERO

#define ECC_X_COORD_LENGTH_ZERO   0xC3

§ ECC_X_COORD_TOO_LONG

#define ECC_X_COORD_TOO_LONG   0x3C

§ ECC_Y_COORD_LENGTH_ZERO

#define ECC_Y_COORD_LENGTH_ZERO   0x56

§ ECC_Y_COORD_TOO_LONG

#define ECC_Y_COORD_TOO_LONG   0x65