CryptoCC26XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2017, 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  */
367 #ifndef ti_drivers_crypto_CryptoCC26XX__include
368 #define ti_drivers_crypto_CryptoCC26XX__include
369 
370 #ifdef __cplusplus
371 extern "C" {
372 #endif
373 
374 #include <stdint.h>
375 #include <stdbool.h>
376 
377 #include <ti/drivers/Power.h>
378 
379 #include <ti/devices/DeviceFamily.h>
380 #include DeviceFamily_constructPath(driverlib/crypto.h)
381 
392 /* Add CryptoCC26XX_STATUS_* macros here */
393 
406 /* Add CryptoCC26XX_CMD_* macros here */
407 
410 #define CRYPTOCC26XX_TIMEOUT 20
412 #define CRYPTOCC26XX_STATUS_SUCCESS 0
413 #define CRYPTOCC26XX_STATUS_ERROR -1
414 #define CRYPTOCC26XX_STATUS_UNDEFINEDCMD -2
416 #define CRYPTOCC26XX_OP_AES_CCM_ENCRYPT 0
417 #define CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY 1
418 #define CRYPTOCC26XX_OP_AES_CCM_DECRYPT 2
419 #define CRYPTOCC26XX_OP_AES_CCM_DECRYPT_AAD_ONLY 3
420 #define CRYPTOCC26XX_OP_AES_ECB_ENCRYPT 4
421 #define CRYPTOCC26XX_OP_AES_ECB_DECRYPT 5
422 #define CRYPTOCC26XX_OP_AES_CBC_ENCRYPT 6
423 #define CRYPTOCC26XX_OP_AES_CBC_DECRYPT 7
425 /* Deprecated operation mode names */
426 #define CRYPTOCC26XX_OP_AES_CCM CRYPTOCC26XX_OP_AES_CCM_ENCRYPT
427 #define CRYPTOCC26XX_OP_AES_CCM_NOCRYPT CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY
428 #define CRYPTOCC26XX_OP_AES_CCMINV CRYPTOCC26XX_OP_AES_CCM_DECRYPT
429 #define CRYPTOCC26XX_OP_AES_CCMINV_NOCRYPT CRYPTOCC26XX_OP_AES_CCM_DECRYPT_AAD_ONLY
430 #define CRYPTOCC26XX_OP_AES_ECB CRYPTOCC26XX_OP_AES_ECB_ENCRYPT
431 #define CRYPTOCC26XX_OP_AES_ECB_NOCRYPT CRYPTOCC26XX_OP_AES_ECB_DECRYPT
432 
433 
434 #include <ti/drivers/dpl/HwiP.h>
435 #include <ti/drivers/dpl/SemaphoreP.h>
436 
441 
448 typedef enum CryptoCC26XX_Mode {
454 
461 
476 typedef uint8_t CryptoCC26XX_Operation;
477 
496 
500 typedef struct CryptoCC26XX_Params {
501  uint32_t timeout;
503 
509 typedef uint8_t CryptoCC26XX_KeyStore;
510 
520 typedef struct CryptoCC26XX_Transaction {
521  CryptoCC26XX_Operation opType;
522  CryptoCC26XX_Mode mode;
523  uint8_t data[];
525 
577  CryptoCC26XX_Operation opType;
578  CryptoCC26XX_Mode mode;
579  uint8_t keyIndex;
580  uint8_t authLength;
582  char *nonce;
599  char *msgIn;
605  char *header;
606  void *msgOut;
612  uint8_t fieldLength;
623  uint16_t msgInLength;
625  uint16_t headerLength;
627 
635  CryptoCC26XX_Operation opType;
636  CryptoCC26XX_Mode mode;
637  uint8_t keyIndex;
638  void *nonce;
639  void *msgIn;
640  void *msgOut;
641  uint16_t msgInLength;
643 
651  CryptoCC26XX_Operation opType;
652  CryptoCC26XX_Mode mode;
653  uint8_t keyIndex;
654  void *msgIn;
655  void *msgOut;
657 
687 typedef struct CryptoCC26XX_HWAttrs {
689  uint32_t baseAddr;
693  int intNum;
706  uint8_t intPriority;
708 
714 typedef struct CryptoCC26XX_Object {
715  /* CryptoCC26XX control variables */
716  int openCnt;
717  uint32_t timeout;
718  CryptoCC26XX_KeyStore keyStore;
721  /* Crypto transaction pointers for CryptoCC26XX_MODE_CALLBACK */
727 
728  /* CryptoCC26XX SYS/BIOS objects */
729  HwiP_Struct hwi;
730  SemaphoreP_Struct transSem;
731  SemaphoreP_Struct waitSem;
733 
735 typedef struct CryptoCC26XX_Config {
737  void *object;
738 
740  void const *hwAttrs;
742 
757 int CryptoCC26XX_close(CryptoCC26XX_Handle handle);
758 
766 void CryptoCC26XX_init(void);
767 
792 CryptoCC26XX_Handle CryptoCC26XX_open(unsigned int index, bool exclusiveAccess, CryptoCC26XX_Params *params);
793 
805 
816 void CryptoCC26XX_Transac_init(CryptoCC26XX_Transaction *trans, CryptoCC26XX_Operation opType);
817 
846 int CryptoCC26XX_allocateKey(CryptoCC26XX_Handle handle, CryptoCC26XX_KeyLocation keyLocation, const uint32_t *keySrc);
847 
848 
870 int CryptoCC26XX_loadKey(CryptoCC26XX_Handle handle, int keyIndex, const uint32_t *keySrc);
871 
889 int CryptoCC26XX_releaseKey(CryptoCC26XX_Handle handle, int *keyIndex);
890 
911 int CryptoCC26XX_transact(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
912 
932 int CryptoCC26XX_transactPolling(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
933 
957 int CryptoCC26XX_transactCallback(CryptoCC26XX_Handle handle, CryptoCC26XX_Transaction *transaction);
958 
959 #ifdef __cplusplus
960 }
961 #endif
962 
963 #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:520
CryptoCC26XX Global Configuration.
Definition: CryptoCC26XX.h:735
CryptoCC26XX_Transaction * currentTransact
Definition: CryptoCC26XX.h:719
void CryptoCC26XX_Params_init(CryptoCC26XX_Params *params)
Function to initialize the CryptoCC26XX_Params struct to its defaults.
CryptoCC26XX AES-CCM Transaction.
Definition: CryptoCC26XX.h:576
struct CryptoCC26XX_Object CryptoCC26XX_Object
CryptoCC26XX Object.
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:651
int CryptoCC26XX_close(CryptoCC26XX_Handle handle)
Function to closes a given CryptoCC26XX peripheral specified by the CryptoCC26XX handle.
void * msgOut
Definition: CryptoCC26XX.h:606
struct CryptoCC26XX_AESCCM_Transaction CryptoCC26XX_AESCCM_Transaction
CryptoCC26XX AES-CCM Transaction.
CryptoCC26XX_Transaction * tailPtr
Definition: CryptoCC26XX.h:723
CryptoCC26XX Parameters.
Definition: CryptoCC26XX.h:500
uint8_t keyIndex
Definition: CryptoCC26XX.h:653
void * msgIn
Definition: CryptoCC26XX.h:639
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:577
Definition: CryptoCC26XX.h:486
Power manager interface.
SemaphoreP_Struct waitSem
Definition: CryptoCC26XX.h:731
HwiP_Struct hwi
Definition: CryptoCC26XX.h:729
SemaphoreP_Struct transSem
Definition: CryptoCC26XX.h:730
uint8_t CryptoCC26XX_Operation
CryptoCC26XX Operation Type.
Definition: CryptoCC26XX.h:476
uint8_t fieldLength
Definition: CryptoCC26XX.h:612
Power notify object structure.
Definition: Power.h:115
Definition: CryptoCC26XX.h:489
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:521
Definition: CryptoCC26XX.h:453
CryptoCC26XX_Transaction * headPtr
Definition: CryptoCC26XX.h:722
CryptoCC26XX_Operation opType
Definition: CryptoCC26XX.h:635
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:655
uint8_t keyIndex
Definition: CryptoCC26XX.h:579
char * nonce
Definition: CryptoCC26XX.h:582
void * msgOut
Definition: CryptoCC26XX.h:640
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:492
char * header
Definition: CryptoCC26XX.h:605
CryptoCC26XX Hardware Attributes.
Definition: CryptoCC26XX.h:687
Power_NotifyObj cryptoNotiObj
Definition: CryptoCC26XX.h:726
int openCnt
Definition: CryptoCC26XX.h:716
Definition: CryptoCC26XX.h:491
void const * hwAttrs
Definition: CryptoCC26XX.h:740
uint16_t headerLength
Definition: CryptoCC26XX.h:625
Definition: CryptoCC26XX.h:459
uint16_t msgInLength
Definition: CryptoCC26XX.h:623
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:440
void * msgIn
Definition: CryptoCC26XX.h:654
uint32_t timeout
Definition: CryptoCC26XX.h:717
Definition: CryptoCC26XX.h:493
CryptoCC26XX_Mode
CryptoCC26XX Mode Settings.
Definition: CryptoCC26XX.h:448
CryptoCC26XX AES-ECB Transaction.
Definition: CryptoCC26XX.h:650
char * msgIn
Definition: CryptoCC26XX.h:599
void CryptoCC26XX_init(void)
Function to initializes bios modules needed by CryptoCC26XX module.
uint8_t intPriority
Crypto Peripheral&#39;s interrupt priority.
Definition: CryptoCC26XX.h:706
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:636
CryptoCC26XX_KeyStore keyStore
Definition: CryptoCC26XX.h:718
uint8_t keyIndex
Definition: CryptoCC26XX.h:637
uint16_t msgInLength
Definition: CryptoCC26XX.h:641
int powerMngrId
Definition: CryptoCC26XX.h:691
void * object
Definition: CryptoCC26XX.h:737
Definition: CryptoCC26XX.h:494
Definition: CryptoCC26XX.h:488
uint8_t CryptoCC26XX_KeyStore
CryptoCC26XX Key.
Definition: CryptoCC26XX.h:509
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:652
void * nonce
Definition: CryptoCC26XX.h:638
CryptoCC26XX_KeyLocation
CryptoCC26XX Key Store Location.
Definition: CryptoCC26XX.h:484
int intNum
Definition: CryptoCC26XX.h:693
struct CryptoCC26XX_HWAttrs CryptoCC26XX_HWAttrs
CryptoCC26XX Hardware Attributes.
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:522
Definition: CryptoCC26XX.h:490
struct CryptoCC26XX_Transaction CryptoCC26XX_Transaction
CryptoCC26XX Transaction.
uint32_t timeout
Definition: CryptoCC26XX.h:501
CryptoCC26XX Object.
Definition: CryptoCC26XX.h:714
CryptoCC26XX_Mode mode
Definition: CryptoCC26XX.h:578
uint32_t baseAddr
Definition: CryptoCC26XX.h:689
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:487
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:580
CryptoCC26XX AES-CBC Transaction.
Definition: CryptoCC26XX.h:634
Definition: CryptoCC26XX.h:485
Copyright 2017, Texas Instruments Incorporated