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