SimpleLink MCU SDK Driver APIs  tidrivers_cc13xx_cc26xx_3_01_01_03
CryptoCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
366 #ifndef ti_drivers_crypto_CryptoCC26XX__include
367 #define ti_drivers_crypto_CryptoCC26XX__include
368 
369 #ifdef __cplusplus
370 extern "C" {
371 #endif
372 
373 #include <stdint.h>
374 #include <stdbool.h>
375 #include <ti/drivers/Power.h>
376 
377 #ifdef DEVICE_FAMILY
378  #undef DEVICE_FAMILY_PATH
379  #define DEVICE_FAMILY_PATH(x) <ti/devices/DEVICE_FAMILY/x>
380 #else
381  #error "You must define DEVICE_FAMILY at the project level as one of cc26x0, cc26x0r2, cc13x0, etc."
382 #endif
383 
384 #include DEVICE_FAMILY_PATH(driverlib/crypto.h)
385 
396 /* Add CryptoCC26XX_STATUS_* macros here */
397 
410 /* Add CryptoCC26XX_CMD_* macros here */
411 
414 #define CRYPTOCC26XX_TIMEOUT 20
416 #define CRYPTOCC26XX_STATUS_SUCCESS 0
417 #define CRYPTOCC26XX_STATUS_ERROR -1
418 #define CRYPTOCC26XX_STATUS_UNDEFINEDCMD -2
420 #define CRYPTOCC26XX_OP_AES_CCM_ENCRYPT 0
421 #define CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY 1
422 #define CRYPTOCC26XX_OP_AES_CCM_DECRYPT 2
423 #define CRYPTOCC26XX_OP_AES_CCM_DECRYPT_AAD_ONLY 3
424 #define CRYPTOCC26XX_OP_AES_ECB_ENCRYPT 4
425 #define CRYPTOCC26XX_OP_AES_ECB_DECRYPT 5
426 #define CRYPTOCC26XX_OP_AES_CBC_ENCRYPT 6
427 #define CRYPTOCC26XX_OP_AES_CBC_DECRYPT 7
429 /* Deprecated operation mode names */
430 #define CRYPTOCC26XX_OP_AES_CCM CRYPTOCC26XX_OP_AES_CCM_ENCRYPT
431 #define CRYPTOCC26XX_OP_AES_CCM_NOCRYPT CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY
432 #define CRYPTOCC26XX_OP_AES_CCMINV CRYPTOCC26XX_OP_AES_CCM_DECRYPT
433 #define CRYPTOCC26XX_OP_AES_CCMINV_NOCRYPT CRYPTOCC26XX_OP_AES_CCM_DECRYPT_AAD_ONLY
434 #define CRYPTOCC26XX_OP_AES_ECB CRYPTOCC26XX_OP_AES_ECB_ENCRYPT
435 #define CRYPTOCC26XX_OP_AES_ECB_NOCRYPT CRYPTOCC26XX_OP_AES_ECB_DECRYPT
436 
437 
438 /*
439  * The following allows this header file to be included in an application file
440  * which also includes ti/sysbios/hal/Hwi.h.
441  */
442 #define ti_sysbios_family_arm_m3_Hwi__nolocalnames
443 #include <ti/sysbios/family/arm/m3/Hwi.h>
444 #include <ti/sysbios/knl/Semaphore.h>
445 
450 
457 typedef enum CryptoCC26XX_Mode {
463 
470 
485 typedef uint8_t CryptoCC26XX_Operation;
486 
505 
509 typedef struct CryptoCC26XX_Params {
510  uint32_t timeout;
512 
518 typedef uint8_t CryptoCC26XX_KeyStore;
519 
529 typedef struct CryptoCC26XX_Transaction {
530  CryptoCC26XX_Operation opType;
532  uint8_t data[];
534 
586  CryptoCC26XX_Operation opType;
588  uint8_t keyIndex;
589  uint8_t authLength;
591  char *nonce;
592  char *msgIn;
598  char *header;
599  void *msgOut;
600  uint8_t fieldLength;
606  uint16_t msgInLength;
608  uint16_t headerLength;
610 
618  CryptoCC26XX_Operation opType;
620  uint8_t keyIndex;
621  void *nonce;
622  void *msgIn;
623  void *msgOut;
624  uint16_t msgInLength;
626 
634  CryptoCC26XX_Operation opType;
636  uint8_t keyIndex;
637  void *msgIn;
638  void *msgOut;
640 
672 typedef struct CryptoCC26XX_HWAttrs {
674  uint32_t baseAddr;
678  int intNum;
691  uint8_t intPriority;
693 
699 typedef struct CryptoCC26XX_Object {
700  /* CryptoCC26XX control variables */
701  int openCnt;
702  uint32_t timeout;
703  CryptoCC26XX_KeyStore keyStore;
706  /* Crypto transaction pointers for CryptoCC26XX_MODE_CALLBACK */
712 
713  /* CryptoCC26XX SYS/BIOS objects */
714  ti_sysbios_family_arm_m3_Hwi_Struct hwi;
715  Semaphore_Struct transSem;
716  Semaphore_Struct waitSem;
718 
720 typedef struct CryptoCC26XX_Config {
722  void *object;
723 
725  void const *hwAttrs;
727 
742 int CryptoCC26XX_close(CryptoCC26XX_Handle handle);
743 
751 void CryptoCC26XX_init(void);
752 
776 CryptoCC26XX_Handle CryptoCC26XX_open(unsigned int index, bool exclusiveAccess, CryptoCC26XX_Params *params);
777 
789 
800 void CryptoCC26XX_Transac_init(CryptoCC26XX_Transaction *trans, CryptoCC26XX_Operation opType);
801 
830 int CryptoCC26XX_allocateKey(CryptoCC26XX_Handle handle, CryptoCC26XX_KeyLocation keyLocation, const uint32_t *keySrc);
831 
832 
854 int CryptoCC26XX_loadKey(CryptoCC26XX_Handle handle, int keyIndex, const uint32_t *keySrc);
855 
873 int CryptoCC26XX_releaseKey(CryptoCC26XX_Handle handle, int *keyIndex);
874 
895 int CryptoCC26XX_transact(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
896 
916 int CryptoCC26XX_transactPolling(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
917 
941 int CryptoCC26XX_transactCallback(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
942 
943 
944 /* Do not interfere with the app if they include the family Hwi module */
945 #undef ti_sysbios_family_arm_m3_Hwi__nolocalnames
946 
947 #ifdef __cplusplus
948 }
949 #endif
950 
951 #endif /* ti_drivers_crypto_CryptoCC26XX__include */
int CryptoCC26XX_allocateKey(CryptoCC26XX_Handle handle, CryptoCC26XX_KeyLocation keyLocation, const uint32_t *keySrc)
Function that allocates key, writes key into key store RAM and returns a handle to CryptoCC26XX Key...
CryptoCC26XX Transaction.
Definition: CryptoCC26XX.h:529
Semaphore_Struct waitSem
Definition: CryptoCC26XX.h:716
CryptoCC26XX Global Configuration.
Definition: CryptoCC26XX.h:720
CryptoCC26XX_Transaction * currentTransact
Definition: CryptoCC26XX.h:704
void CryptoCC26XX_Params_init(CryptoCC26XX_Params *params)
Function to initialize the CryptoCC26XX_Params struct to its defaults.
CryptoCC26XX AES-CCM Transaction.
Definition: CryptoCC26XX.h:585
struct CryptoCC26XX_Object CryptoCC26XX_Object
CryptoCC26XX Object.
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:634
int CryptoCC26XX_close(CryptoCC26XX_Handle handle)
Function to closes a given CryptoCC26XX peripheral specified by the CryptoCC26XX handle.
void * msgOut
Definition: CryptoCC26XX.h:599
struct CryptoCC26XX_AESCCM_Transaction CryptoCC26XX_AESCCM_Transaction
CryptoCC26XX AES-CCM Transaction.
CryptoCC26XX_Transaction * tailPtr
Definition: CryptoCC26XX.h:708
CryptoCC26XX Parameters.
Definition: CryptoCC26XX.h:509
uint8_t keyIndex
Definition: CryptoCC26XX.h:636
void * msgIn
Definition: CryptoCC26XX.h:622
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:586
Definition: CryptoCC26XX.h:495
Power manager interface.
uint8_t CryptoCC26XX_Operation
CryptoCC26XX Operation Type.
Definition: CryptoCC26XX.h:485
uint8_t fieldLength
Definition: CryptoCC26XX.h:600
Power notify object structure.
Definition: Power.h:113
Definition: CryptoCC26XX.h:498
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:530
uint8_t data[]
Definition: CryptoCC26XX.h:532
Definition: CryptoCC26XX.h:462
CryptoCC26XX_Transaction * headPtr
Definition: CryptoCC26XX.h:707
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:618
int CryptoCC26XX_loadKey(CryptoCC26XX_Handle handle, int keyIndex, const uint32_t *keySrc)
Function that writes a given key into a key store.
void * msgOut
Definition: CryptoCC26XX.h:638
uint8_t keyIndex
Definition: CryptoCC26XX.h:588
char * nonce
Definition: CryptoCC26XX.h:591
void * msgOut
Definition: CryptoCC26XX.h:623
struct CryptoCC26XX_Config CryptoCC26XX_Config
CryptoCC26XX Global Configuration.
void CryptoCC26XX_Transac_init(CryptoCC26XX_Transaction *trans, CryptoCC26XX_Operation opType)
Function to initialize the CryptoCC26XX_Transaction struct to its defaults.
int CryptoCC26XX_releaseKey(CryptoCC26XX_Handle handle, int *keyIndex)
Function that releases the specified CryptoCC26XX Key.
Definition: CryptoCC26XX.h:501
char * header
Definition: CryptoCC26XX.h:598
CryptoCC26XX Hardware Attributes.
Definition: CryptoCC26XX.h:672
Power_NotifyObj cryptoNotiObj
Definition: CryptoCC26XX.h:711
int openCnt
Definition: CryptoCC26XX.h:701
ti_sysbios_family_arm_m3_Hwi_Struct hwi
Definition: CryptoCC26XX.h:714
Definition: CryptoCC26XX.h:500
void const * hwAttrs
Definition: CryptoCC26XX.h:725
uint16_t headerLength
Definition: CryptoCC26XX.h:608
Definition: CryptoCC26XX.h:468
uint16_t msgInLength
Definition: CryptoCC26XX.h:606
struct CryptoCC26XX_Params CryptoCC26XX_Params
CryptoCC26XX Parameters.
struct CryptoCC26XX_Config * CryptoCC26XX_Handle
A handle that is returned from a CryptoCC26XX_open() call.
Definition: CryptoCC26XX.h:449
void * msgIn
Definition: CryptoCC26XX.h:637
uint32_t timeout
Definition: CryptoCC26XX.h:702
Definition: CryptoCC26XX.h:502
CryptoCC26XX_Mode
CryptoCC26XX Mode Settings.
Definition: CryptoCC26XX.h:457
CryptoCC26XX AES-ECB Transaction.
Definition: CryptoCC26XX.h:633
char * msgIn
Definition: CryptoCC26XX.h:592
void CryptoCC26XX_init(void)
Function to initializes bios modules needed by CryptoCC26XX module.
uint8_t intPriority
Crypto Peripheral's interrupt priority.
Definition: CryptoCC26XX.h:691
int CryptoCC26XX_transact(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction)
Function to do a Crypto operation (encryption or decryption) in blocking mode.
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:619
CryptoCC26XX_KeyStore keyStore
Definition: CryptoCC26XX.h:703
uint8_t keyIndex
Definition: CryptoCC26XX.h:620
uint16_t msgInLength
Definition: CryptoCC26XX.h:624
int powerMngrId
Definition: CryptoCC26XX.h:676
void * object
Definition: CryptoCC26XX.h:722
Semaphore_Struct transSem
Definition: CryptoCC26XX.h:715
Definition: CryptoCC26XX.h:503
Definition: CryptoCC26XX.h:497
uint8_t CryptoCC26XX_KeyStore
CryptoCC26XX Key.
Definition: CryptoCC26XX.h:518
CryptoCC26XX_Handle CryptoCC26XX_open(unsigned int index, bool exclusiveAccess, CryptoCC26XX_Params *params)
Function to initialize a given CryptoCC26XX peripheral specified by the particular index value...
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:635
void * nonce
Definition: CryptoCC26XX.h:621
CryptoCC26XX_KeyLocation
CryptoCC26XX Key Store Location.
Definition: CryptoCC26XX.h:493
int intNum
Definition: CryptoCC26XX.h:678
struct CryptoCC26XX_HWAttrs CryptoCC26XX_HWAttrs
CryptoCC26XX Hardware Attributes.
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:531
Definition: CryptoCC26XX.h:499
struct CryptoCC26XX_Transaction CryptoCC26XX_Transaction
CryptoCC26XX Transaction.
uint32_t timeout
Definition: CryptoCC26XX.h:510
CryptoCC26XX Object.
Definition: CryptoCC26XX.h:699
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:587
uint32_t baseAddr
Definition: CryptoCC26XX.h:674
struct CryptoCC26XX_AESECB_Transaction CryptoCC26XX_AESECB_Transaction
CryptoCC26XX AES-ECB Transaction.
struct CryptoCC26XX_AESCBC_Transaction CryptoCC26XX_AESCBC_Transaction
CryptoCC26XX AES-CBC Transaction.
Definition: CryptoCC26XX.h:496
int CryptoCC26XX_transactPolling(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction)
Function to do a Crypto transaction operation (encryption or decryption) in polling mode...
int CryptoCC26XX_transactCallback(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction)
Function to do a Crypto transaction operation (encryption or decryption) in callback mode...
uint8_t authLength
Definition: CryptoCC26XX.h:589
CryptoCC26XX AES-CBC Transaction.
Definition: CryptoCC26XX.h:617
Definition: CryptoCC26XX.h:494
Copyright 2016, Texas Instruments Incorporated