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 #include <stdint.h>
409 #include <stdbool.h>
410 
411 #include <ti/drivers/Power.h>
412 
413 #include <ti/devices/DeviceFamily.h>
414 #include DeviceFamily_constructPath(driverlib/crypto.h)
415 
416 #include <ti/drivers/dpl/HwiP.h>
417 #include <ti/drivers/dpl/SemaphoreP.h>
418 
419 #ifdef __cplusplus
420 extern "C" {
421 #endif
422 
423 #if DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2
424  #warning "This driver is deprecated for the CC26x2 and CC13x2 families.\
425  It is superceded by AESECB and AESCCM."
426 #endif
427 
438 /* Add CryptoCC26XX_STATUS_* macros here */
439 
452 /* Add CryptoCC26XX_CMD_* macros here */
453 
456 #define CRYPTOCC26XX_TIMEOUT 20
458 #define CRYPTOCC26XX_STATUS_SUCCESS 0
459 #define CRYPTOCC26XX_STATUS_ERROR -1
460 #define CRYPTOCC26XX_STATUS_UNDEFINEDCMD -2
462 #define CRYPTOCC26XX_OP_AES_CCM_ENCRYPT 0
463 #define CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY 1
464 #define CRYPTOCC26XX_OP_AES_CCM_DECRYPT 2
465 #define CRYPTOCC26XX_OP_AES_CCM_DECRYPT_AAD_ONLY 3
466 #define CRYPTOCC26XX_OP_AES_ECB_ENCRYPT 4
467 #define CRYPTOCC26XX_OP_AES_ECB_DECRYPT 5
468 #define CRYPTOCC26XX_OP_AES_CBC_ENCRYPT 6
469 #define CRYPTOCC26XX_OP_AES_CBC_DECRYPT 7
471 /* Deprecated operation mode names */
472 #define CRYPTOCC26XX_OP_AES_CCM CRYPTOCC26XX_OP_AES_CCM_ENCRYPT
473 #define CRYPTOCC26XX_OP_AES_CCM_NOCRYPT CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY
474 #define CRYPTOCC26XX_OP_AES_CCMINV CRYPTOCC26XX_OP_AES_CCM_DECRYPT
475 #define CRYPTOCC26XX_OP_AES_CCMINV_NOCRYPT CRYPTOCC26XX_OP_AES_CCM_DECRYPT_AAD_ONLY
476 #define CRYPTOCC26XX_OP_AES_ECB CRYPTOCC26XX_OP_AES_ECB_ENCRYPT
477 #define CRYPTOCC26XX_OP_AES_ECB_NOCRYPT CRYPTOCC26XX_OP_AES_ECB_DECRYPT
478 
480 typedef struct {
482  void *object;
483 
485  void const *hwAttrs;
487 
492 
499 typedef enum {
505 
512 
527 typedef uint8_t CryptoCC26XX_Operation;
528 
535 typedef enum {
543  CRYPTOCC26XX_KEY_ANY = 9, /* Do not change this enum assignment.
544  * There is ROM code that references it and
545  * requires its value be 9.
546  */
548 
552 typedef struct {
553  uint32_t timeout;
555 
561 typedef uint8_t CryptoCC26XX_KeyStore;
562 
572 typedef struct {
573  CryptoCC26XX_Operation opType;
574  CryptoCC26XX_Mode mode;
575  uint8_t data[];
577 
628 typedef struct {
629  CryptoCC26XX_Operation opType;
630  CryptoCC26XX_Mode mode;
631  uint8_t keyIndex;
632  uint8_t authLength;
634  char *nonce;
651  char *msgIn;
657  char *header;
658  void *msgOut;
664  uint8_t fieldLength;
675  uint16_t msgInLength;
677  uint16_t headerLength;
679 
686 typedef struct {
687  CryptoCC26XX_Operation opType;
688  CryptoCC26XX_Mode mode;
689  uint8_t keyIndex;
690  void *nonce;
691  void *msgIn;
692  void *msgOut;
693  uint16_t msgInLength;
695 
702 typedef struct {
703  CryptoCC26XX_Operation opType;
704  CryptoCC26XX_Mode mode;
705  uint8_t keyIndex;
706  void *msgIn;
707  void *msgOut;
709 
739 typedef struct {
741  uint32_t baseAddr;
745  int intNum;
758  uint8_t intPriority;
760 
766 typedef struct {
767  /* CryptoCC26XX control variables */
768  int openCnt;
769  uint32_t timeout;
770  CryptoCC26XX_KeyStore keyStore;
772  /* CryptoCC26XX SYS/BIOS objects */
773  HwiP_Struct hwi;
775 
790 int CryptoCC26XX_close(CryptoCC26XX_Handle handle);
791 
801 void CryptoCC26XX_init(void);
802 
827 CryptoCC26XX_Handle CryptoCC26XX_open(unsigned int index, bool exclusiveAccess, CryptoCC26XX_Params *params);
828 
840 
851 void CryptoCC26XX_Transac_init(CryptoCC26XX_Transaction *trans, CryptoCC26XX_Operation opType);
852 
892 int CryptoCC26XX_allocateKey(CryptoCC26XX_Handle handle, CryptoCC26XX_KeyLocation keyLocation, const uint32_t *keySrc);
893 
894 
918 int CryptoCC26XX_loadKey(CryptoCC26XX_Handle handle, int keyIndex, const uint32_t *keySrc);
919 
937 int CryptoCC26XX_releaseKey(CryptoCC26XX_Handle handle, int *keyIndex);
938 
959 int CryptoCC26XX_transact(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
960 
980 int CryptoCC26XX_transactPolling(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
981 
1005 int CryptoCC26XX_transactCallback(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
1006 
1007 #ifdef __cplusplus
1008 }
1009 #endif
1010 
1011 #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:572
CryptoCC26XX Global Configuration.
Definition: CryptoCC26XX.h:480
CryptoCC26XX_Transaction * currentTransact
Definition: CryptoCC26XX.h:771
void CryptoCC26XX_Params_init(CryptoCC26XX_Params *params)
Function to initialize the CryptoCC26XX_Params struct to its defaults.
CryptoCC26XX_Config * CryptoCC26XX_Handle
A handle that is returned from a CryptoCC26XX_open() call.
Definition: CryptoCC26XX.h:491
CryptoCC26XX AES-CCM Transaction.
Definition: CryptoCC26XX.h:628
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:703
int CryptoCC26XX_close(CryptoCC26XX_Handle handle)
Function to closes a given CryptoCC26XX peripheral specified by the CryptoCC26XX handle.
void * msgOut
Definition: CryptoCC26XX.h:658
CryptoCC26XX Parameters.
Definition: CryptoCC26XX.h:552
uint8_t keyIndex
Definition: CryptoCC26XX.h:705
void * msgIn
Definition: CryptoCC26XX.h:691
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:629
Definition: CryptoCC26XX.h:537
Power Manager.
HwiP_Struct hwi
Definition: CryptoCC26XX.h:773
uint8_t CryptoCC26XX_Operation
CryptoCC26XX Operation Type.
Definition: CryptoCC26XX.h:527
uint8_t fieldLength
Definition: CryptoCC26XX.h:664
Definition: CryptoCC26XX.h:540
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:573
Definition: CryptoCC26XX.h:504
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:687
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:707
uint8_t keyIndex
Definition: CryptoCC26XX.h:631
char * nonce
Definition: CryptoCC26XX.h:634
void * msgOut
Definition: CryptoCC26XX.h:692
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:657
CryptoCC26XX Hardware Attributes.
Definition: CryptoCC26XX.h:739
int openCnt
Definition: CryptoCC26XX.h:768
void const * hwAttrs
Definition: CryptoCC26XX.h:485
uint16_t headerLength
Definition: CryptoCC26XX.h:677
Definition: CryptoCC26XX.h:510
uint16_t msgInLength
Definition: CryptoCC26XX.h:675
void * msgIn
Definition: CryptoCC26XX.h:706
uint32_t timeout
Definition: CryptoCC26XX.h:769
Definition: CryptoCC26XX.h:542
CryptoCC26XX_Mode
CryptoCC26XX Mode Settings.
Definition: CryptoCC26XX.h:499
CryptoCC26XX AES-ECB Transaction.
Definition: CryptoCC26XX.h:702
char * msgIn
Definition: CryptoCC26XX.h:651
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:758
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:688
CryptoCC26XX_KeyStore keyStore
Definition: CryptoCC26XX.h:770
uint8_t keyIndex
Definition: CryptoCC26XX.h:689
uint16_t msgInLength
Definition: CryptoCC26XX.h:693
int powerMngrId
Definition: CryptoCC26XX.h:743
void * object
Definition: CryptoCC26XX.h:482
Definition: CryptoCC26XX.h:543
Definition: CryptoCC26XX.h:539
uint8_t CryptoCC26XX_KeyStore
CryptoCC26XX Key.
Definition: CryptoCC26XX.h:561
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:704
void * nonce
Definition: CryptoCC26XX.h:690
CryptoCC26XX_KeyLocation
CryptoCC26XX Key Store Location.
Definition: CryptoCC26XX.h:535
int intNum
Definition: CryptoCC26XX.h:745
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:574
Definition: CryptoCC26XX.h:541
uint32_t timeout
Definition: CryptoCC26XX.h:553
CryptoCC26XX Object.
Definition: CryptoCC26XX.h:766
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:630
uint32_t baseAddr
Definition: CryptoCC26XX.h:741
Definition: CryptoCC26XX.h:538
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:632
CryptoCC26XX AES-CBC Transaction.
Definition: CryptoCC26XX.h:686
Definition: CryptoCC26XX.h:536
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale