Contiki-NG
Loading...
Searching...
No Matches
cbc.c
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-cbc
33 * @{
34 *
35 * \file
36 * Implementation of the cc2538 AES-CBC driver
37 */
38#include "contiki.h"
39#include "dev/cbc.h"
40
41#include <stdbool.h>
42#include <stdint.h>
43/*---------------------------------------------------------------------------*/
44uint8_t
45cbc_crypt_start(uint8_t encrypt, uint8_t key_area, const void *iv,
46 const void *mdata_in, void *mdata_out, uint16_t mdata_len,
47 struct process *process)
48{
49 uint32_t ctrl;
50
51 /* Program AES-CBC crypto operation */
52 ctrl = AES_AES_CTRL_CBC | /* CBC */
53 (encrypt ? AES_AES_CTRL_DIRECTION_ENCRYPT : 0); /* En/decryption */
54
55 return aes_auth_crypt_start(ctrl, key_area, iv, NULL, 0,
56 mdata_in, mdata_out, mdata_len, process);
57}
58/*---------------------------------------------------------------------------*/
59int8_t
61{
63 CRYPTO_PENDING;
64}
65
66/** @} */
Header file for the cc2538 AES-CBC driver.
#define AES_AES_CTRL_DIRECTION_ENCRYPT
Encrypt.
Definition aes.h:297
#define AES_AES_CTRL_CBC
AES-CBC mode.
Definition aes.h:291
uint8_t aes_auth_crypt_check_status(void)
Checks the status of the AES authentication/crypto operation.
Definition aes.c:270
uint8_t aes_auth_crypt_start(uint32_t ctrl, uint8_t key_area, const void *iv, const void *adata, uint16_t adata_len, const void *data_in, void *data_out, uint16_t data_len, struct process *process)
Starts an AES authentication/crypto operation.
Definition aes.c:159
uint8_t aes_auth_crypt_get_result(void *iv, void *tag)
Gets the result of the AES authentication/crypto operation.
Definition aes.c:278
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