Contiki-NG
Loading...
Searching...
No Matches
cbc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
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 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 * OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31/**
32 * \addtogroup cc2538-aes
33 * @{
34 *
35 * \defgroup cc2538-cbc cc2538 AES-CBC
36 *
37 * Driver for the cc2538 AES-CBC mode of the security core
38 * @{
39 *
40 * \file
41 * Header file for the cc2538 AES-CBC driver
42 */
43#ifndef CBC_H_
44#define CBC_H_
45
46#include "contiki.h"
47#include "dev/aes.h"
48
49#include <stdbool.h>
50#include <stdint.h>
51/*---------------------------------------------------------------------------*/
52/** \name AES-CBC constants
53 * @{
54 */
55#define CBC_IV_LEN AES_IV_LEN
56/** @} */
57/*---------------------------------------------------------------------------*/
58/** \name AES-CBC functions
59 * @{
60 */
61
62/** \brief Starts a CBC crypto operation
63 * \param encrypt \c true to encrypt, or \c false to decrypt
64 * \param key_area Area in Key RAM where the key is stored (0 to
65 * \c AES_KEY_AREAS - 1)
66 * \param iv Pointer to 128-bit initialization vector
67 * \param mdata_in Pointer to input message in SRAM
68 * \param mdata_out Pointer to output message in SRAM (may be \p mdata_in)
69 * \param mdata_len Length of message in octets
70 * \param process Process to be polled upon completion of the operation, or
71 * \c NULL
72 * \return \c CRYPTO_SUCCESS if successful, or CRYPTO/AES/CBC error code
73 */
74uint8_t cbc_crypt_start(uint8_t encrypt, uint8_t key_area, const void *iv,
75 const void *mdata_in, void *mdata_out,
76 uint16_t mdata_len, struct process *process);
77
78/** \brief Checks the status of the CBC crypto operation
79 * \return \c CRYPTO_PENDING if operation still pending, \c CRYPTO_SUCCESS if
80 * successful, or CRYPTO/AES/CBC error code
81 * \note This function must be called only after \c cbc_crypt_start().
82 */
83int8_t cbc_crypt_check_status(void);
84
85/** @} */
86
87#endif /* CBC_H_ */
88
89/**
90 * @}
91 * @}
92 */
Header file for the cc2538 AES driver.
uint8_t cbc_crypt_start(uint8_t encrypt, uint8_t key_area, const void *iv, const void *mdata_in, void *mdata_out, uint16_t mdata_len, struct process *process)
Starts a CBC crypto operation.
Definition cbc.c:45
int8_t cbc_crypt_check_status(void)
Checks the status of the CBC crypto operation.
Definition cbc.c:60