AESCTR.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018, 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  */
306 #ifndef ti_drivers_AESCTR__include
307 #define ti_drivers_AESCTR__include
308 
309 #include <stdbool.h>
310 #include <stddef.h>
311 #include <stdint.h>
312 
314 
315 #ifdef __cplusplus
316 extern "C" {
317 #endif
318 
319 
332 #define AESCTR_STATUS_RESERVED (-32)
333 
340 #define AESCTR_STATUS_SUCCESS (0)
341 
348 #define AESCTR_STATUS_ERROR (-1)
349 
358 #define AESCTR_STATUS_RESOURCE_UNAVAILABLE (-2)
359 
363 #define AESCTR_STATUS_CANCELED (-3)
364 
365 
387 typedef enum {
403 
407 typedef enum {
410 } AESCTR_Mode;
411 
419 typedef struct {
420  const CryptoKey *key;
421  const uint8_t *input;
426  uint8_t *output;
432  const uint8_t *initialCounter;
437  size_t inputLength;
439 
443 typedef enum {
447 
459 typedef struct {
461  void *object;
462 
464  void const *hwAttrs;
465 } AESCTR_Config;
466 
471 
487 typedef void (*AESCTR_CallbackFxn) (AESCTR_Handle handle,
488  int_fast16_t returnValue,
489  AESCTR_Operation *operation,
490  AESCTR_OperationType operationType);
491 
500 typedef struct {
503  uint32_t timeout;
506  void *custom;
509 } AESCTR_Params;
510 
517 
526 void AESCTR_init(void);
527 
540 void AESCTR_Params_init(AESCTR_Params *params);
541 
559 AESCTR_Handle AESCTR_open(uint_least8_t index, const AESCTR_Params *params);
560 
570 void AESCTR_close(AESCTR_Handle handle);
571 
580 void AESCTR_Operation_init(AESCTR_Operation *operationStruct);
581 
598 int_fast16_t AESCTR_oneStepEncrypt(AESCTR_Handle handle, AESCTR_Operation *operationStruct);
599 
616 int_fast16_t AESCTR_oneStepDecrypt(AESCTR_Handle handle, AESCTR_Operation *operationStruct);
617 
630 int_fast16_t AESCTR_cancelOperation(AESCTR_Handle handle);
631 
632 #ifdef __cplusplus
633 }
634 #endif
635 
636 #endif /* ti_drivers_AESCTR__include */
const AESCTR_Params AESCTR_defaultParams
Default AESCTR_Params structure.
Definition: AESCTR.h:408
The CryptoKey type is an opaque representation of a cryptographic key.
AESCTR_Config * AESCTR_Handle
A handle that is returned from an AESCTR_open() call.
Definition: AESCTR.h:470
void AESCTR_init(void)
This function initializes the CTR module.
CTR Parameters.
Definition: AESCTR.h:500
AESCTR Global configuration.
Definition: AESCTR.h:459
void * object
Definition: AESCTR.h:461
const CryptoKey * key
Definition: AESCTR.h:420
CryptoKey datastructure.
Definition: CryptoKey.h:210
const uint8_t * input
Definition: AESCTR.h:421
AESCTR_OperationType
Enum for the operation types supported by the driver.
Definition: AESCTR.h:443
AESCTR_ReturnBehavior
The way in which CTR function calls return after performing an encryption or decryption operation...
Definition: AESCTR.h:387
uint8_t * output
Definition: AESCTR.h:426
Definition: AESCTR.h:398
Definition: AESCTR.h:444
AESCTR_Mode
Enum for the direction of the CTR operation.
Definition: AESCTR.h:407
Struct containing the parameters required for encrypting/decrypting a message.
Definition: AESCTR.h:419
void AESCTR_Params_init(AESCTR_Params *params)
Function to initialize the AESCTR_Params struct to its defaults.
int_fast16_t AESCTR_oneStepDecrypt(AESCTR_Handle handle, AESCTR_Operation *operationStruct)
Function to perform an AESCTR decryption operation in one call.
Definition: AESCTR.h:409
Definition: AESCTR.h:388
void const * hwAttrs
Definition: AESCTR.h:464
AESCTR_CallbackFxn callbackFxn
Definition: AESCTR.h:502
int_fast16_t AESCTR_oneStepEncrypt(AESCTR_Handle handle, AESCTR_Operation *operationStruct)
Function to perform an AESCTR encryption operation in one call.
void * custom
Definition: AESCTR.h:506
int_fast16_t AESCTR_cancelOperation(AESCTR_Handle handle)
Cancels an ongoing AESCTR operation.
AESCTR_ReturnBehavior returnBehavior
Definition: AESCTR.h:501
Definition: AESCTR.h:394
AESCTR_Handle AESCTR_open(uint_least8_t index, const AESCTR_Params *params)
This function opens a given CTR peripheral.
void AESCTR_Operation_init(AESCTR_Operation *operationStruct)
Function to initialize an AESCTR_Operation struct to its defaults.
void(* AESCTR_CallbackFxn)(AESCTR_Handle handle, int_fast16_t returnValue, AESCTR_Operation *operation, AESCTR_OperationType operationType)
The definition of a callback function used by the AESCTR driver when used in AESCTR_RETURN_BEHAVIOR_C...
Definition: AESCTR.h:487
uint32_t timeout
Definition: AESCTR.h:503
const uint8_t * initialCounter
Definition: AESCTR.h:432
Definition: AESCTR.h:445
void AESCTR_close(AESCTR_Handle handle)
Function to close a CTR peripheral specified by the CTR handle.
size_t inputLength
Definition: AESCTR.h:437
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale