Skip to content

Commit 5b83a64

Browse files
andreas.larssonkegilbert
authored andcommitted
Merge branch 'mbed-os-workshop-17q2' into ublox_rearrange_odin_target
1 parent ef3b86d commit 5b83a64

File tree

39 files changed

+5579
-231
lines changed

39 files changed

+5579
-231
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/drivers/cau_api.h

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/drivers/fsl_mmcau.c

Lines changed: 513 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
/*
2+
* Copyright (c) 2015, Freescale Semiconductor, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without modification,
6+
* are permitted provided that the following conditions are met:
7+
*
8+
* o Redistributions of source code must retain the above copyright notice, this list
9+
* of conditions and the following disclaimer.
10+
*
11+
* o Redistributions in binary form must reproduce the above copyright notice, this
12+
* list of conditions and the following disclaimer in the documentation and/or
13+
* other materials provided with the distribution.
14+
*
15+
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16+
* contributors may be used to endorse or promote products derived from this
17+
* software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
#ifndef _FSL_MMCAU_H_
32+
#define _FSL_MMCAU_H_
33+
34+
#include "fsl_common.h"
35+
36+
/*******************************************************************************
37+
* API
38+
******************************************************************************/
39+
40+
/*!
41+
* @addtogroup mmcau MMCAU Peripheral Driver Wrapper
42+
* @{
43+
*/
44+
45+
#if defined(__cplusplus)
46+
extern "C" {
47+
#endif
48+
49+
/*!
50+
* @brief AES: Performs an AES key expansion.
51+
*
52+
* This function performs an AES key expansion.
53+
*
54+
* @param key Pointer to input key (128, 192, 256 bits in length).
55+
* @param keySize Key size in bytes (16, 24, 32)
56+
* @param[out] keySch Pointer to key schedule output (44, 52, 60 longwords)
57+
* @note Table below shows the requirements for the MMCAU_AES_SetKey() function when using AES128, AES192, or AES256.@n
58+
* | [in] Key Size (bits) | [out] Key Schedule Size (32 bit data values) |@n
59+
* | :---------------------: | :--------------------------------------------: |@n
60+
* | 128 | 44 |@n
61+
* | 192 | 52 |@n
62+
* | 256 | 60 |
63+
* @return Status of the operation. (kStatus_Success, kStatus_InvalidArgument, kStatus_Fail)
64+
*/
65+
status_t MMCAU_AES_SetKey(const uint8_t *key, const size_t keySize, uint8_t *keySch);
66+
67+
/*!
68+
* @brief AES: Encrypts a single 16 byte block.
69+
*
70+
* This function encrypts a single 16-byte block for AES128, AES192, and AES256.
71+
*
72+
* @param in Pointer to 16-byte block of input plaintext.
73+
* @param keySch Pointer to key schedule (44, 52, 60 longwords).
74+
* @param aesRounds Number of AES rounds (10, 12, 14 = f(key_schedule)).
75+
* @param[out] out Pointer to 16-byte block of output ciphertext.
76+
* @note Input and output blocks may overlap.@n
77+
* Table below shows the requirements for the MMCAU_AES_EncryptEcb()/MMCAU_AES_DecryptEcb()
78+
* function when using AES128, AES192 or AES256.@n
79+
* | Block Cipher | [in] Key Schedule Size (longwords) | [in] Number of AES rounds |@n
80+
* | :----------: | :--------------------------------: | :-----------------------: |@n
81+
* | AES128 | 44 | 10 |@n
82+
* | AES192 | 52 | 12 |@n
83+
* | AES256 | 60 | 14 |
84+
* @return Status of the operation. (kStatus_Success, kStatus_InvalidArgument, kStatus_Fail)
85+
*/
86+
status_t MMCAU_AES_EncryptEcb(const uint8_t *in, const uint8_t *keySch, uint32_t aesRounds, uint8_t *out);
87+
88+
/*!
89+
* @brief AES: Decrypts a single 16-byte block.
90+
*
91+
* This function decrypts a single 16-byte block for AES128, AES192, and AES256.
92+
*
93+
* @param in Pointer to 16-byte block of input ciphertext.
94+
* @param keySch Pointer to key schedule (44, 52, 60 longwords).
95+
* @param aesRounds Number of AES rounds (10, 12, 14 = f(key_schedule)).
96+
* @param[out] out Pointer to 16-byte block of output plaintext.
97+
* @note Input and output blocks may overlap.@n
98+
* Table below shows the requirements for the cau_aes_encrypt()/cau_aes_decrypt().
99+
* function when using AES128, AES192 or AES256.@n
100+
* | Block Cipher | [in] Key Schedule Size (longwords) | [in] Number of AES rounds |@n
101+
* | :----------: | :--------------------------------: | :-----------------------: |@n
102+
* | AES128 | 44 | 10 |@n
103+
* | AES192 | 52 | 12 |@n
104+
* | AES256 | 60 | 14 |
105+
* @return Status of the operation. (kStatus_Success, kStatus_InvalidArgument, kStatus_Fail)
106+
*/
107+
status_t MMCAU_AES_DecryptEcb(const uint8_t *in, const uint8_t *keySch, uint32_t aesRounds, uint8_t *out);
108+
109+
/*!
110+
* @brief DES: Checks the key parity.
111+
*
112+
* This function checks the parity of a DES key.
113+
*
114+
* @param key 64-bit DES key with parity bits.
115+
* @return kStatus_Success No error.
116+
* @return kStatus_Fail Parity error.
117+
* @return kStatus_InvalidArgument Key argument is NULL.
118+
*/
119+
status_t MMCAU_DES_ChkParity(const uint8_t *key);
120+
121+
/*!
122+
* @brief DES: Encrypts a single 8-byte block.
123+
*
124+
* This function encrypts a single 8-byte block with the DES algorithm.
125+
*
126+
* @param in Pointer to 8-byte block of input plaintext.
127+
* @param key Pointer to 64-bit DES key with parity bits.
128+
* @param[out] out Pointer to 8-byte block of output ciphertext.
129+
* @note Input and output blocks may overlap.
130+
* @return Status of the operation. (kStatus_Success, kStatus_InvalidArgument, kStatus_Fail)
131+
*/
132+
status_t MMCAU_DES_EncryptEcb(const uint8_t *in, const uint8_t *key, uint8_t *out);
133+
134+
/*!
135+
* @brief DES: Decrypts a single 8-byte block.
136+
*
137+
* This function decrypts a single 8-byte block with the DES algorithm.
138+
*
139+
* @param in Pointer to 8-byte block of input ciphertext.
140+
* @param key Pointer to 64-bit DES key with parity bits.
141+
* @param[out] out Pointer to 8-byte block of output plaintext.
142+
* @note Input and output blocks may overlap.
143+
* @return Status of the operation. (kStatus_Success, kStatus_InvalidArgument, kStatus_Fail)
144+
*/
145+
status_t MMCAU_DES_DecryptEcb(const uint8_t *in, const uint8_t *key, uint8_t *out);
146+
147+
/*!
148+
* @brief MD5: Initializes the MD5 state variables.
149+
*
150+
* This function initializes the MD5 state variables.
151+
* The output can be used as input to MMCAU_MD5_HashN().
152+
*
153+
* @param[out] md5State Pointer to 128-bit block of md5 state variables: a,b,c,d
154+
*/
155+
status_t MMCAU_MD5_InitializeOutput(uint32_t *md5State);
156+
157+
/*!
158+
* @brief MD5: Updates the MD5 state variables with n message blocks.
159+
*
160+
* This function updates the MD5 state variables for one or more input message blocks.
161+
*
162+
* @param msgData Pointer to start of input message data.
163+
* @param numBlocks Number of 512-bit blocks to process.
164+
* @param[in,out] md5State Pointer to 128-bit block of MD5 state variables: a, b, c, d.
165+
* @note Input message and digest output blocks must not overlap.
166+
* The MMCAU_MD5_InitializeOutput() function must be called when starting a new hash.
167+
* Useful when handling non-contiguous input message blocks.
168+
*/
169+
status_t MMCAU_MD5_HashN(const uint8_t *msgData, uint32_t numBlocks, uint32_t *md5State);
170+
171+
/*!
172+
* @brief MD5: Updates the MD5 state variables.
173+
*
174+
* This function updates the MD5 state variables for one or more input message blocks.
175+
* It starts a new hash as it internally calls MMCAU_MD5_InitializeOutput() first.
176+
*
177+
* @param msgData Pointer to start of input message data.
178+
* @param numBlocks Number of 512-bit blocks to process.
179+
* @param[out] md5State Pointer to 128-bit block of MD5 state variables: a, b, c, d.
180+
* @note Input message and digest output blocks must not overlap.
181+
* The MMCAU_MD5_InitializeOutput() function is not required to be called
182+
* as it is called internally to start a new hash.
183+
* All input message blocks must be contiguous.
184+
*/
185+
status_t MMCAU_MD5_Update(const uint8_t *msgData, uint32_t numBlocks, uint32_t *md5State);
186+
187+
/*!
188+
* @brief SHA1: Initializes the SHA1 state variables.
189+
*
190+
* This function initializes the SHA1 state variables.
191+
* The output can be used as input to MMCAU_SHA1_HashN().
192+
*
193+
* @param[out] sha1State Pointer to 160-bit block of SHA1 state variables: a, b, c, d, e.
194+
*/
195+
status_t MMCAU_SHA1_InitializeOutput(uint32_t *sha1State);
196+
197+
/*!
198+
* @brief SHA1: Updates the SHA1 state variables with n message blocks.
199+
*
200+
* This function updates the SHA1 state variables for one or more input message blocks.
201+
*
202+
* @param msgData Pointer to start of input message data.
203+
* @param numBlocks Number of 512-bit blocks to process.
204+
* @param[in,out] sha1State Pointer to 160-bit block of SHA1 state variables: a, b, c, d, e.
205+
* @note Input message and digest output blocks must not overlap.
206+
* The MMCAU_SHA1_InitializeOutput() function must be called when starting a new hash.
207+
* Useful when handling non-contiguous input message blocks.
208+
*/
209+
status_t MMCAU_SHA1_HashN(const uint8_t *msgData, uint32_t numBlocks, uint32_t *sha1State);
210+
211+
/*!
212+
* @brief SHA1: Updates the SHA1 state variables.
213+
*
214+
* This function updates the SHA1 state variables for one or more input message blocks.
215+
* It starts a new hash as it internally calls MMCAU_SHA1_InitializeOutput() first.
216+
*
217+
* @param msgData Pointer to start of input message data.
218+
* @param numBlocks Number of 512-bit blocks to process.
219+
* @param[out] sha1State Pointer to 160-bit block of SHA1 state variables: a, b, c, d, e.
220+
* @note Input message and digest output blocks must not overlap.
221+
* The MMCAU_SHA1_InitializeOutput() function is not required to be called
222+
* as it is called internally to start a new hash.
223+
* All input message blocks must be contiguous.
224+
*/
225+
status_t MMCAU_SHA1_Update(const uint8_t *msgData, uint32_t numBlocks, uint32_t *sha1State);
226+
227+
/*!
228+
* @brief SHA256: Initializes the SHA256 state variables.
229+
*
230+
* This function initializes the SHA256 state variables.
231+
* The output can be used as input to MMCAU_SHA256_HashN().
232+
*
233+
* @param[out] sha256State Pointer to 256-bit block of SHA2 state variables a, b, c, d, e, f, g, h.
234+
* @return kStatus_Success No error. CAU hardware support for SHA256 is present.
235+
* @return kStatus_Fail Error. CAU hardware support for SHA256 is not present.
236+
* @return kStatus_InvalidArgument Error. sha256State is NULL.
237+
*/
238+
status_t MMCAU_SHA256_InitializeOutput(uint32_t *sha256State);
239+
240+
/*!
241+
* @brief SHA256: Updates the SHA256 state variables with n message blocks.
242+
*
243+
* This function updates SHA256 state variables for one or more input message blocks.
244+
*
245+
* @param msgData Pointer to start of input message data.
246+
* @param numBlocks Number of 512-bit blocks to process.
247+
* @param[in,out] sha256State Pointer to 256-bit block of SHA2 state variables: a, b, c, d, e, f, g, h.
248+
* @note Input message and digest output blocks must not overlap.
249+
* The MMCAU_SHA256_InitializeOutput() function must be called when starting a new hash.
250+
* Useful when handling non-contiguous input message blocks.
251+
*/
252+
status_t MMCAU_SHA256_HashN(const uint8_t *input, uint32_t numBlocks, uint32_t *sha256State);
253+
254+
/*!
255+
* @brief SHA256: Updates SHA256 state variables.
256+
*
257+
* This function updates the SHA256 state variables for one or more input message blocks.
258+
* It starts a new hash as it internally calls cau_sha256_initialize_output() first.
259+
*
260+
* @param msgData Pointer to start of input message data.
261+
* @param numBlocks Number of 512-bit blocks to process.
262+
* @param[out] sha256State Pointer to 256-bit block of SHA2 state variables: a, b, c, d, e, f, g, h.
263+
* @note Input message and digest output blocks must not overlap.
264+
* The MMCAU_SHA256_InitializeOutput() function is not required to be called.
265+
* as it is called internally to start a new hash.
266+
* All input message blocks must be contiguous.
267+
*/
268+
status_t MMCAU_SHA256_Update(const uint8_t *input, uint32_t numBlocks, uint32_t *sha256State);
269+
270+
#if defined(__cplusplus)
271+
}
272+
#endif
273+
274+
/*! @}*/
275+
276+
#endif /* _FSL_MMCAU_H_ */

0 commit comments

Comments
 (0)