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 
535  CRYPTOCC26XX_KEY_ANY = 9, /* Do not change this enum assignment.
536  * There is ROM code that references it and
537  * requires its value be 9.
538  */
540 
544 typedef struct CryptoCC26XX_Params {
545  uint32_t timeout;
547 
553 typedef uint8_t CryptoCC26XX_KeyStore;
554 
564 typedef struct CryptoCC26XX_Transaction {
565  CryptoCC26XX_Operation opType;
566  CryptoCC26XX_Mode mode;
567  uint8_t data[];
569 
621  CryptoCC26XX_Operation opType;
622  CryptoCC26XX_Mode mode;
623  uint8_t keyIndex;
624  uint8_t authLength;
626  char *nonce;
643  char *msgIn;
649  char *header;
650  void *msgOut;
656  uint8_t fieldLength;
667  uint16_t msgInLength;
669  uint16_t headerLength;
671 
679  CryptoCC26XX_Operation opType;
680  CryptoCC26XX_Mode mode;
681  uint8_t keyIndex;
682  void *nonce;
683  void *msgIn;
684  void *msgOut;
685  uint16_t msgInLength;
687 
695  CryptoCC26XX_Operation opType;
696  CryptoCC26XX_Mode mode;
697  uint8_t keyIndex;
698  void *msgIn;
699  void *msgOut;
701 
731 typedef struct CryptoCC26XX_HWAttrs {
733  uint32_t baseAddr;
737  int intNum;
750  uint8_t intPriority;
752 
758 typedef struct CryptoCC26XX_Object {
759  /* CryptoCC26XX control variables */
760  int openCnt;
761  uint32_t timeout;
762  CryptoCC26XX_KeyStore keyStore;
764  /* CryptoCC26XX SYS/BIOS objects */
765  HwiP_Struct hwi;
767 
769 typedef struct CryptoCC26XX_Config {
771  void *object;
772 
774  void const *hwAttrs;
776 
791 int CryptoCC26XX_close(CryptoCC26XX_Handle handle);
792 
802 void CryptoCC26XX_init(void);
803 
828 CryptoCC26XX_Handle CryptoCC26XX_open(unsigned int index, bool exclusiveAccess, CryptoCC26XX_Params *params);
829 
841 
852 void CryptoCC26XX_Transac_init(CryptoCC26XX_Transaction *trans, CryptoCC26XX_Operation opType);
853 
893 int CryptoCC26XX_allocateKey(CryptoCC26XX_Handle handle, CryptoCC26XX_KeyLocation keyLocation, const uint32_t *keySrc);
894 
895 
919 int CryptoCC26XX_loadKey(CryptoCC26XX_Handle handle, int keyIndex, const uint32_t *keySrc);
920 
938 int CryptoCC26XX_releaseKey(CryptoCC26XX_Handle handle, int *keyIndex);
939 
960 int CryptoCC26XX_transact(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
961 
981 int CryptoCC26XX_transactPolling(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
982 
1006 int CryptoCC26XX_transactCallback(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
1007 
1008 #ifdef __cplusplus
1009 }
1010 #endif
1011 
1012 #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:564
CryptoCC26XX Global Configuration.
Definition: CryptoCC26XX.h:769
CryptoCC26XX_Transaction * currentTransact
Definition: CryptoCC26XX.h:763
void CryptoCC26XX_Params_init(CryptoCC26XX_Params *params)
Function to initialize the CryptoCC26XX_Params struct to its defaults.
CryptoCC26XX AES-CCM Transaction.
Definition: CryptoCC26XX.h:620
struct CryptoCC26XX_Object CryptoCC26XX_Object
CryptoCC26XX Object.
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:695
int CryptoCC26XX_close(CryptoCC26XX_Handle handle)
Function to closes a given CryptoCC26XX peripheral specified by the CryptoCC26XX handle.
void * msgOut
Definition: CryptoCC26XX.h:650
struct CryptoCC26XX_AESCCM_Transaction CryptoCC26XX_AESCCM_Transaction
CryptoCC26XX AES-CCM Transaction.
CryptoCC26XX Parameters.
Definition: CryptoCC26XX.h:544
uint8_t keyIndex
Definition: CryptoCC26XX.h:697
void * msgIn
Definition: CryptoCC26XX.h:683
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:621
Definition: CryptoCC26XX.h:529
Power Manager.
HwiP_Struct hwi
Definition: CryptoCC26XX.h:765
uint8_t CryptoCC26XX_Operation
CryptoCC26XX Operation Type.
Definition: CryptoCC26XX.h:519
uint8_t fieldLength
Definition: CryptoCC26XX.h:656
Definition: CryptoCC26XX.h:532
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:565
Definition: CryptoCC26XX.h:496
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:679
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:699
uint8_t keyIndex
Definition: CryptoCC26XX.h:623
char * nonce
Definition: CryptoCC26XX.h:626
void * msgOut
Definition: CryptoCC26XX.h:684
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:649
CryptoCC26XX Hardware Attributes.
Definition: CryptoCC26XX.h:731
int openCnt
Definition: CryptoCC26XX.h:760
void const * hwAttrs
Definition: CryptoCC26XX.h:774
uint16_t headerLength
Definition: CryptoCC26XX.h:669
Definition: CryptoCC26XX.h:502
uint16_t msgInLength
Definition: CryptoCC26XX.h:667
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:698
uint32_t timeout
Definition: CryptoCC26XX.h:761
Definition: CryptoCC26XX.h:534
CryptoCC26XX_Mode
CryptoCC26XX Mode Settings.
Definition: CryptoCC26XX.h:491
CryptoCC26XX AES-ECB Transaction.
Definition: CryptoCC26XX.h:694
char * msgIn
Definition: CryptoCC26XX.h:643
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:750
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:680
CryptoCC26XX_KeyStore keyStore
Definition: CryptoCC26XX.h:762
uint8_t keyIndex
Definition: CryptoCC26XX.h:681
uint16_t msgInLength
Definition: CryptoCC26XX.h:685
int powerMngrId
Definition: CryptoCC26XX.h:735
void * object
Definition: CryptoCC26XX.h:771
Definition: CryptoCC26XX.h:535
Definition: CryptoCC26XX.h:531
uint8_t CryptoCC26XX_KeyStore
CryptoCC26XX Key.
Definition: CryptoCC26XX.h:553
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:696
void * nonce
Definition: CryptoCC26XX.h:682
CryptoCC26XX_KeyLocation
CryptoCC26XX Key Store Location.
Definition: CryptoCC26XX.h:527
int intNum
Definition: CryptoCC26XX.h:737
struct CryptoCC26XX_HWAttrs CryptoCC26XX_HWAttrs
CryptoCC26XX Hardware Attributes.
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:566
Definition: CryptoCC26XX.h:533
struct CryptoCC26XX_Transaction CryptoCC26XX_Transaction
CryptoCC26XX Transaction.
uint32_t timeout
Definition: CryptoCC26XX.h:545
CryptoCC26XX Object.
Definition: CryptoCC26XX.h:758
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:622
uint32_t baseAddr
Definition: CryptoCC26XX.h:733
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:624
CryptoCC26XX AES-CBC Transaction.
Definition: CryptoCC26XX.h:678
Definition: CryptoCC26XX.h:528
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale