CryptoCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2019, 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  */
405 #ifndef ti_drivers_crypto_CryptoCC26XX__include
406 #define ti_drivers_crypto_CryptoCC26XX__include
407 
408 #ifdef __cplusplus
409 extern "C" {
410 #endif
411 
412 #include <stdint.h>
413 #include <stdbool.h>
414 
415 #include <ti/drivers/Power.h>
416 
417 #include <ti/devices/DeviceFamily.h>
418 #include DeviceFamily_constructPath(driverlib/crypto.h)
419 
420 #if DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2
421  #warning "This driver is deprecated for the CC26x2 and CC13x2 families.\
422  It is superceded by AESECB and AESCCM."
423 #endif
424 
435 /* Add CryptoCC26XX_STATUS_* macros here */
436 
449 /* Add CryptoCC26XX_CMD_* macros here */
450 
453 #define CRYPTOCC26XX_TIMEOUT 20
455 #define CRYPTOCC26XX_STATUS_SUCCESS 0
456 #define CRYPTOCC26XX_STATUS_ERROR -1
457 #define CRYPTOCC26XX_STATUS_UNDEFINEDCMD -2
459 #define CRYPTOCC26XX_OP_AES_CCM_ENCRYPT 0
460 #define CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY 1
461 #define CRYPTOCC26XX_OP_AES_CCM_DECRYPT 2
462 #define CRYPTOCC26XX_OP_AES_CCM_DECRYPT_AAD_ONLY 3
463 #define CRYPTOCC26XX_OP_AES_ECB_ENCRYPT 4
464 #define CRYPTOCC26XX_OP_AES_ECB_DECRYPT 5
465 #define CRYPTOCC26XX_OP_AES_CBC_ENCRYPT 6
466 #define CRYPTOCC26XX_OP_AES_CBC_DECRYPT 7
468 /* Deprecated operation mode names */
469 #define CRYPTOCC26XX_OP_AES_CCM CRYPTOCC26XX_OP_AES_CCM_ENCRYPT
470 #define CRYPTOCC26XX_OP_AES_CCM_NOCRYPT CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY
471 #define CRYPTOCC26XX_OP_AES_CCMINV CRYPTOCC26XX_OP_AES_CCM_DECRYPT
472 #define CRYPTOCC26XX_OP_AES_CCMINV_NOCRYPT CRYPTOCC26XX_OP_AES_CCM_DECRYPT_AAD_ONLY
473 #define CRYPTOCC26XX_OP_AES_ECB CRYPTOCC26XX_OP_AES_ECB_ENCRYPT
474 #define CRYPTOCC26XX_OP_AES_ECB_NOCRYPT CRYPTOCC26XX_OP_AES_ECB_DECRYPT
475 
476 
477 #include <ti/drivers/dpl/HwiP.h>
478 #include <ti/drivers/dpl/SemaphoreP.h>
479 
484 
491 typedef enum CryptoCC26XX_Mode {
497 
504 
519 typedef uint8_t CryptoCC26XX_Operation;
520 
537 
541 typedef struct CryptoCC26XX_Params {
542  uint32_t timeout;
544 
550 typedef uint8_t CryptoCC26XX_KeyStore;
551 
561 typedef struct CryptoCC26XX_Transaction {
562  CryptoCC26XX_Operation opType;
563  CryptoCC26XX_Mode mode;
564  uint8_t data[];
566 
618  CryptoCC26XX_Operation opType;
619  CryptoCC26XX_Mode mode;
620  uint8_t keyIndex;
621  uint8_t authLength;
623  char *nonce;
640  char *msgIn;
646  char *header;
647  void *msgOut;
653  uint8_t fieldLength;
664  uint16_t msgInLength;
666  uint16_t headerLength;
668 
676  CryptoCC26XX_Operation opType;
677  CryptoCC26XX_Mode mode;
678  uint8_t keyIndex;
679  void *nonce;
680  void *msgIn;
681  void *msgOut;
682  uint16_t msgInLength;
684 
692  CryptoCC26XX_Operation opType;
693  CryptoCC26XX_Mode mode;
694  uint8_t keyIndex;
695  void *msgIn;
696  void *msgOut;
698 
728 typedef struct CryptoCC26XX_HWAttrs {
730  uint32_t baseAddr;
734  int intNum;
747  uint8_t intPriority;
749 
755 typedef struct CryptoCC26XX_Object {
756  /* CryptoCC26XX control variables */
757  int openCnt;
758  uint32_t timeout;
759  CryptoCC26XX_KeyStore keyStore;
764 
765  /* CryptoCC26XX SYS/BIOS objects */
766  HwiP_Struct hwi;
768 
770 typedef struct CryptoCC26XX_Config {
772  void *object;
773 
775  void const *hwAttrs;
777 
792 int CryptoCC26XX_close(CryptoCC26XX_Handle handle);
793 
803 void CryptoCC26XX_init(void);
804 
829 CryptoCC26XX_Handle CryptoCC26XX_open(unsigned int index, bool exclusiveAccess, CryptoCC26XX_Params *params);
830 
842 
853 void CryptoCC26XX_Transac_init(CryptoCC26XX_Transaction *trans, CryptoCC26XX_Operation opType);
854 
883 int CryptoCC26XX_allocateKey(CryptoCC26XX_Handle handle, CryptoCC26XX_KeyLocation keyLocation, const uint32_t *keySrc);
884 
885 
909 int CryptoCC26XX_loadKey(CryptoCC26XX_Handle handle, int keyIndex, const uint32_t *keySrc);
910 
928 int CryptoCC26XX_releaseKey(CryptoCC26XX_Handle handle, int *keyIndex);
929 
950 int CryptoCC26XX_transact(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
951 
971 int CryptoCC26XX_transactPolling(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
972 
996 int CryptoCC26XX_transactCallback(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
997 
998 #ifdef __cplusplus
999 }
1000 #endif
1001 
1002 #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:561
CryptoCC26XX Global Configuration.
Definition: CryptoCC26XX.h:770
CryptoCC26XX_Transaction * currentTransact
Definition: CryptoCC26XX.h:760
void CryptoCC26XX_Params_init(CryptoCC26XX_Params *params)
Function to initialize the CryptoCC26XX_Params struct to its defaults.
CryptoCC26XX AES-CCM Transaction.
Definition: CryptoCC26XX.h:617
struct CryptoCC26XX_Object CryptoCC26XX_Object
CryptoCC26XX Object.
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:692
int CryptoCC26XX_close(CryptoCC26XX_Handle handle)
Function to closes a given CryptoCC26XX peripheral specified by the CryptoCC26XX handle.
void * msgOut
Definition: CryptoCC26XX.h:647
struct CryptoCC26XX_AESCCM_Transaction CryptoCC26XX_AESCCM_Transaction
CryptoCC26XX AES-CCM Transaction.
CryptoCC26XX Parameters.
Definition: CryptoCC26XX.h:541
uint8_t keyIndex
Definition: CryptoCC26XX.h:694
void * msgIn
Definition: CryptoCC26XX.h:680
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:618
Definition: CryptoCC26XX.h:529
Power Manager.
HwiP_Struct hwi
Definition: CryptoCC26XX.h:766
uint8_t CryptoCC26XX_Operation
CryptoCC26XX Operation Type.
Definition: CryptoCC26XX.h:519
uint8_t fieldLength
Definition: CryptoCC26XX.h:653
Definition: CryptoCC26XX.h:532
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:562
Definition: CryptoCC26XX.h:496
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:676
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:696
uint8_t keyIndex
Definition: CryptoCC26XX.h:620
char * nonce
Definition: CryptoCC26XX.h:623
void * msgOut
Definition: CryptoCC26XX.h:681
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.
char * header
Definition: CryptoCC26XX.h:646
CryptoCC26XX Hardware Attributes.
Definition: CryptoCC26XX.h:728
Power_NotifyObj cryptoNotiObj
Definition: CryptoCC26XX.h:763
int openCnt
Definition: CryptoCC26XX.h:757
void const * hwAttrs
Definition: CryptoCC26XX.h:775
uint16_t headerLength
Definition: CryptoCC26XX.h:666
Definition: CryptoCC26XX.h:502
uint16_t msgInLength
Definition: CryptoCC26XX.h:664
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:483
void * msgIn
Definition: CryptoCC26XX.h:695
Power notify object structure.
Definition: Power.h:443
uint32_t timeout
Definition: CryptoCC26XX.h:758
Definition: CryptoCC26XX.h:534
CryptoCC26XX_Mode
CryptoCC26XX Mode Settings.
Definition: CryptoCC26XX.h:491
CryptoCC26XX AES-ECB Transaction.
Definition: CryptoCC26XX.h:691
char * msgIn
Definition: CryptoCC26XX.h:640
void CryptoCC26XX_init(void)
Function to initialize CryptoCC26XX driver. Users of this module must call init(). Multiple users/libraries may call init(), though subsequent calls may be benign.
uint8_t intPriority
Crypto Peripheral&#39;s interrupt priority.
Definition: CryptoCC26XX.h:747
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:677
CryptoCC26XX_KeyStore keyStore
Definition: CryptoCC26XX.h:759
uint8_t keyIndex
Definition: CryptoCC26XX.h:678
uint16_t msgInLength
Definition: CryptoCC26XX.h:682
int powerMngrId
Definition: CryptoCC26XX.h:732
void * object
Definition: CryptoCC26XX.h:772
Definition: CryptoCC26XX.h:535
Definition: CryptoCC26XX.h:531
uint8_t CryptoCC26XX_KeyStore
CryptoCC26XX Key.
Definition: CryptoCC26XX.h:550
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:693
void * nonce
Definition: CryptoCC26XX.h:679
CryptoCC26XX_KeyLocation
CryptoCC26XX Key Store Location.
Definition: CryptoCC26XX.h:527
int intNum
Definition: CryptoCC26XX.h:734
struct CryptoCC26XX_HWAttrs CryptoCC26XX_HWAttrs
CryptoCC26XX Hardware Attributes.
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:563
Definition: CryptoCC26XX.h:533
struct CryptoCC26XX_Transaction CryptoCC26XX_Transaction
CryptoCC26XX Transaction.
uint32_t timeout
Definition: CryptoCC26XX.h:542
CryptoCC26XX Object.
Definition: CryptoCC26XX.h:755
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:619
uint32_t baseAddr
Definition: CryptoCC26XX.h:730
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:530
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:621
CryptoCC26XX AES-CBC Transaction.
Definition: CryptoCC26XX.h:675
Definition: CryptoCC26XX.h:528
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale