[Style] Coding style fixes.

* No trailing white spaces
 * No sapces before tabs
 * "int *var" and not "int * var"
This commit is contained in:
Piotr Esden-Tempski
2013-06-30 22:09:25 -07:00
parent 035c67ced6
commit 647b878031
5 changed files with 78 additions and 77 deletions

View File

@@ -1,8 +1,8 @@
/** @addtogroup crypto_defines /** @addtogroup crypto_defines
*
* @warning The CRYP subsystem is present only in a limited set of devices,
* see next section for list of supported devices.
* *
* @warning The CRYP subsystem is present only in a limited set of devices,
* see next section for list of supported devices.
*
* @section crypto_api_supported Supported devices * @section crypto_api_supported Supported devices
* *
* - STM32F205 * - STM32F205
@@ -15,16 +15,16 @@
* - STM32F417 <i>(tested)</i> * - STM32F417 <i>(tested)</i>
* - STM32F427 * - STM32F427
* - STM32F437 * - STM32F437
*
* @section crypto_api_theory Theory of operation
* *
* * @section crypto_api_theory Theory of operation
* *
* @section crypto_api_basic Basic handling API *
* *
* @section crypto_api_basic Basic handling API
*
* *
* @b Example @b 1: Blocking mode * @b Example @b 1: Blocking mode
* *
* @code * @code
* //[enable-clocks] * //[enable-clocks]
* crypto_set_key(CRYPTO_KEY_128BIT,key); * crypto_set_key(CRYPTO_KEY_128BIT,key);
@@ -33,33 +33,16 @@
* crypto_set_algorithm(ENCRYPT_AES_ECB); * crypto_set_algorithm(ENCRYPT_AES_ECB);
* crypto_start(); * crypto_start();
* foreach(block in blocks) * foreach(block in blocks)
* crypto_process_block(plaintext,ciphertext,blocksize); * crypto_process_block(plaintext,ciphertext,blocksize);
* crypto_stop(); * crypto_stop();
* @endcode * @endcode
* *
* @section crypto_api_interrupt Interrupt supported handling API * @section crypto_api_interrupt Interrupt supported handling API
* *
* @warning This operation mode is currently not supported. * @warning This operation mode is currently not supported.
* *
* @b Example @b 2: Interrupt mode * @b Example @b 2: Interrupt mode
*
* @code
* //[enable-clocks]
* crypto_set_key(CRYPTO_KEY_128BIT,key);
* crypto_set_iv(iv); // only in CBC or CTR mode
* crypto_set_datatype(CRYPTO_DATA_16BIT);
* crypto_set_algorithm(ENCRYPT_AES_ECB);
* crypto_start();
* [... API to be described later ...]
* crypto_stop();
* @endcode
* *
* @section crypto_api_dma DMA handling API
*
* @warning This operation mode is currently not supported.
*
* @b Example @b 3: DMA mode
*
* @code * @code
* //[enable-clocks] * //[enable-clocks]
* crypto_set_key(CRYPTO_KEY_128BIT,key); * crypto_set_key(CRYPTO_KEY_128BIT,key);
@@ -67,7 +50,24 @@
* crypto_set_datatype(CRYPTO_DATA_16BIT); * crypto_set_datatype(CRYPTO_DATA_16BIT);
* crypto_set_algorithm(ENCRYPT_AES_ECB); * crypto_set_algorithm(ENCRYPT_AES_ECB);
* crypto_start(); * crypto_start();
* [... API to be described later ...] * [... API to be described later ...]
* crypto_stop();
* @endcode
*
* @section crypto_api_dma DMA handling API
*
* @warning This operation mode is currently not supported.
*
* @b Example @b 3: DMA mode
*
* @code
* //[enable-clocks]
* crypto_set_key(CRYPTO_KEY_128BIT,key);
* crypto_set_iv(iv); // only in CBC or CTR mode
* crypto_set_datatype(CRYPTO_DATA_16BIT);
* crypto_set_algorithm(ENCRYPT_AES_ECB);
* crypto_start();
* [... API to be described later ...]
* crypto_stop(); * crypto_stop();
* @endcode * @endcode
*/ */
@@ -107,7 +107,7 @@ specific memorymap.h header before including this header file.*/
/* --- CRYP registers ------------------------------------------------------ */ /* --- CRYP registers ------------------------------------------------------ */
/** @defgroup crypto_registers_gen Registers (Generic) /** @defgroup crypto_registers_gen Registers (Generic)
* *
* @brief Register access to the CRYP controller. (All chips) * @brief Register access to the CRYP controller. (All chips)
* *
* @ingroup crypto_defines * @ingroup crypto_defines
*/ */
@@ -237,7 +237,7 @@ specific memorymap.h header before including this header file.*/
/** @defgroup crypto_api_gen API (Generic) /** @defgroup crypto_api_gen API (Generic)
* *
* @brief API for the CRYP controller * @brief API for the CRYP controller
* *
* @ingroup crypto_defines * @ingroup crypto_defines
*/ */
/**@{*/ /**@{*/
@@ -256,7 +256,7 @@ typedef enum {
DECRYPT_DES_CBC = CRYP_CR_ALGOMODE_DES_CBC | CRYP_CR_ALGODIR, DECRYPT_DES_CBC = CRYP_CR_ALGOMODE_DES_CBC | CRYP_CR_ALGODIR,
DECRYPT_AES_ECB = CRYP_CR_ALGOMODE_AES_ECB | CRYP_CR_ALGODIR, DECRYPT_AES_ECB = CRYP_CR_ALGOMODE_AES_ECB | CRYP_CR_ALGODIR,
DECRYPT_AES_CBC = CRYP_CR_ALGOMODE_AES_CBC | CRYP_CR_ALGODIR, DECRYPT_AES_CBC = CRYP_CR_ALGOMODE_AES_CBC | CRYP_CR_ALGODIR,
DECRYPT_AES_CTR = CRYP_CR_ALGOMODE_AES_CTR, /* XOR is same ENC as DEC */ DECRYPT_AES_CTR = CRYP_CR_ALGOMODE_AES_CTR,/* XOR is same ENC as DEC */
} crypto_mode_t; } crypto_mode_t;
typedef enum { typedef enum {
CRYPTO_KEY_128BIT = 0, CRYPTO_KEY_128BIT = 0,
@@ -271,7 +271,7 @@ typedef enum {
CRYPTO_DATA_BIT, CRYPTO_DATA_BIT,
} crypto_datatype_t; } crypto_datatype_t;
BEGIN_DECLS BEGIN_DECLS
void crypto_wait_busy(void); void crypto_wait_busy(void);
void crypto_set_key(crypto_keysize_t keysize, uint64_t key[]); void crypto_set_key(crypto_keysize_t keysize, uint64_t key[]);
void crypto_set_iv(uint64_t iv[]); void crypto_set_iv(uint64_t iv[]);
@@ -279,13 +279,14 @@ void crypto_set_datatype(crypto_datatype_t datatype);
void crypto_set_algorithm(crypto_mode_t mode); void crypto_set_algorithm(crypto_mode_t mode);
void crypto_start(void); void crypto_start(void);
void crypto_stop(void); void crypto_stop(void);
uint32_t crypto_process_block(uint32_t * inp, uint32_t * outp, uint32_t length); uint32_t crypto_process_block(uint32_t *inp, uint32_t *outp, uint32_t length);
END_DECLS END_DECLS
/**@}*/ /**@}*/
/**@}*/ /**@}*/
#endif #endif
/** @cond */ /** @cond */
#else #else
#warning "crypto_common_f24.h should not be included explicitly, only via crypto.h" #warning "crypto_common_f24.h should not be included explicitly, "
"only via crypto.h"
#endif #endif
/** @endcond */ /** @endcond */

View File

@@ -1,7 +1,7 @@
/** @defgroup crypto_defines CRYPTO Defines /** @defgroup crypto_defines CRYPTO Defines
* *
* @brief <b>Defined Constants and Types for the STM32F2xx CRYP Controller</b> * @brief <b>Defined Constants and Types for the STM32F2xx CRYP Controller</b>
* *
* @ingroup STM32F2xx_defines * @ingroup STM32F2xx_defines
* *
* @version 1.0.0 * @version 1.0.0

View File

@@ -1,14 +1,14 @@
/** @defgroup crypto_defines CRYPTO Defines /** @defgroup crypto_defines CRYPTO Defines
* *
* @brief <b>Defined constants and Types for the STM32F4xx Crypto Coprocessor * @brief <b>Defined constants and Types for the STM32F4xx Crypto Coprocessor
* *
* @ingroup STM32F4xx_defines * @ingroup STM32F4xx_defines
* *
* @version 1.0.0 * @version 1.0.0
* *
* @date 22 Jun 2013 * @date 22 Jun 2013
* *
* LGPL License Terms @ref lgpl_license * LGPL License Terms @ref lgpl_license
*/ */
/* /*
@@ -46,10 +46,10 @@
/**@{*/ /**@{*/
/* CRYP_CSGCMCCMxR: Crypto context registers CCM mode, i=0-7*/ /* CRYP_CSGCMCCMxR: Crypto context registers CCM mode, i=0-7*/
#define CRYP_CSGCMCCMR(i) MMIO32(CRYP_BASE + 0x50 + (i) * 4) #define CRYP_CSGCMCCMR(i) MMIO32(CRYP_BASE + 0x50 + (i) * 4)
/* CRYP_CSGCMxR: Crypto context registers all modes, i=0-7*/ /* CRYP_CSGCMxR: Crypto context registers all modes, i=0-7*/
#define CRYP_CSGCMR(i) MMIO32(CRYP_BASE + 0x70 + (i) * 4) #define CRYP_CSGCMR(i) MMIO32(CRYP_BASE + 0x70 + (i) * 4)
/* --- CRYP_CR values ------------------------------------------------------ */ /* --- CRYP_CR values ------------------------------------------------------ */
@@ -70,9 +70,9 @@
/** @defgroup crypto_api API (for F42xx or F43xx only) /** @defgroup crypto_api API (for F42xx or F43xx only)
* *
* @brief API for the CRYP controller. * @brief API for the CRYP controller.
* *
* @warning Only for F42xx and 43xx * @warning Only for F42xx and 43xx
* *
* @ingroup crypto_defines * @ingroup crypto_defines
*/ */
@@ -82,14 +82,14 @@ typedef enum {
ENCRYPT_GCM = CRYP_CR_ALGOMODE_TDES_ECB | CRYP_CR_ALGOMODE3, ENCRYPT_GCM = CRYP_CR_ALGOMODE_TDES_ECB | CRYP_CR_ALGOMODE3,
ENCRYPT_CCM = CRYP_CR_ALGOMODE_TDES_CBC | CRYP_CR_ALGOMODE3, ENCRYPT_CCM = CRYP_CR_ALGOMODE_TDES_CBC | CRYP_CR_ALGOMODE3,
DECRYPT_GCM = CRYP_CR_ALGOMODE_TDES_ECB | CRYP_CR_ALGOMODE3 | DECRYPT_GCM = CRYP_CR_ALGOMODE_TDES_ECB | CRYP_CR_ALGOMODE3 |
CRYP_CR_ALGODIR, CRYP_CR_ALGODIR,
DECRYPT_CCM = CRYP_CR_ALGOMODE_TDES_CBC | CRYP_CR_ALGOMODE3 | DECRYPT_CCM = CRYP_CR_ALGOMODE_TDES_CBC | CRYP_CR_ALGOMODE3 |
CRYP_CR_ALGODIR, CRYP_CR_ALGODIR,
} crypto_mode_mac_t; } crypto_mode_mac_t;
BEGIN_DECLS BEGIN_DECLS
void crypto_context_swap(uint32_t * buf); void crypto_context_swap(uint32_t *buf);
void crypto_set_mac_algorithm(crypto_mode_mac_t mode); void crypto_set_mac_algorithm(crypto_mode_mac_t mode);
END_DECLS END_DECLS

View File

@@ -9,7 +9,7 @@
* This library supports the cryptographic coprocessor system for the * This library supports the cryptographic coprocessor system for the
* STM32 series of ARM Cortex Microcontrollers * STM32 series of ARM Cortex Microcontrollers
* *
* LGPL License Terms @ref lgpl_license * LGPL License Terms @ref lgpl_license
*/ */
/* /*
* This file is part of the libopencm3 project. * This file is part of the libopencm3 project.
@@ -41,13 +41,13 @@
*/ */
void crypto_wait_busy(void) void crypto_wait_busy(void)
{ {
while (CRYP_SR & CRYP_SR_BUSY) ; while (CRYP_SR & CRYP_SR_BUSY);
} }
/** /**
* @brief Set key value to the controller * @brief Set key value to the controller
* @param[in] keysize crypto_keysize_t Specified size of the key. * @param[in] keysize crypto_keysize_t Specified size of the key.
* @param[in] key uint64_t[] Key value (array of 4 items) * @param[in] key uint64_t[] Key value (array of 4 items)
*/ */
void crypto_set_key(crypto_keysize_t keysize, uint64_t key[]) void crypto_set_key(crypto_keysize_t keysize, uint64_t key[])
{ {
@@ -56,7 +56,7 @@ void crypto_set_key(crypto_keysize_t keysize, uint64_t key[])
crypto_wait_busy(); crypto_wait_busy();
CRYP_CR = (CRYP_CR & ~CRYP_CR_KEYSIZE) | CRYP_CR = (CRYP_CR & ~CRYP_CR_KEYSIZE) |
(keysize << CRYP_CR_KEYSIZE_SHIFT); (keysize << CRYP_CR_KEYSIZE_SHIFT);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
CRYP_KR(i) = key[i]; CRYP_KR(i) = key[i];
@@ -66,9 +66,9 @@ void crypto_set_key(crypto_keysize_t keysize, uint64_t key[])
/** /**
* @brief Set Initialization Vector * @brief Set Initialization Vector
* *
* @param[in] iv uint64_t[] Initialization vector (array of 4 items) * @param[in] iv uint64_t[] Initialization vector (array of 4 items)
* @note Cryptographic controller must be in disabled state * @note Cryptographic controller must be in disabled state
*/ */
void crypto_set_iv(uint64_t iv[]) void crypto_set_iv(uint64_t iv[])
{ {
@@ -83,18 +83,18 @@ void crypto_set_iv(uint64_t iv[])
/** /**
* @brief Set the order of the data to be crypted * @brief Set the order of the data to be crypted
* *
* @param[in] datatype crypto_datatype_t Specified datatype of the key. * @param[in] datatype crypto_datatype_t Specified datatype of the key.
*/ */
void crypto_set_datatype(crypto_datatype_t datatype) void crypto_set_datatype(crypto_datatype_t datatype)
{ {
CRYP_CR = (CRYP_CR & ~CRYP_CR_DATATYPE) | CRYP_CR = (CRYP_CR & ~CRYP_CR_DATATYPE) |
(datatype << CRYP_CR_DATATYPE_SHIFT); (datatype << CRYP_CR_DATATYPE_SHIFT);
} }
/** /**
* @brief Set the algoritm for Encryption/decryption * @brief Set the algoritm for Encryption/decryption
* *
*@param[in] mode crypto_mode_t Mode of execution *@param[in] mode crypto_mode_t Mode of execution
*/ */
void crypto_set_algorithm(crypto_mode_t mode) void crypto_set_algorithm(crypto_mode_t mode)
@@ -137,19 +137,19 @@ void crypto_stop(void)
/** /**
* @brief Start of encryption or decryption on data buffers * @brief Start of encryption or decryption on data buffers
* *
* This blocking method transfers input buffer of specified length to the * This blocking method transfers input buffer of specified length to the
* cryptographic coprocessor, and instructs him to begin of ciphering or * cryptographic coprocessor, and instructs him to begin of ciphering or
* deciphering. It waits for data to be ready, and then fills the processed * deciphering. It waits for data to be ready, and then fills the processed
* data to output buffer. * data to output buffer.
* *
* @param[in] inp uint32_t* Input array to crypt/decrypt. * @param[in] inp uint32_t* Input array to crypt/decrypt.
* @param[in] outp uint32_t* Output array with crypted/encrypted data. * @param[in] outp uint32_t* Output array with crypted/encrypted data.
* @param[in] length uint32_t Length of the arrays * @param[in] length uint32_t Length of the arrays
* *
* @returns uint32_t Number of written words * @returns uint32_t Number of written words
*/ */
uint32_t crypto_process_block(uint32_t * inp, uint32_t * outp, uint32_t length) uint32_t crypto_process_block(uint32_t *inp, uint32_t *outp, uint32_t length)
{ {
uint32_t rd = 0, wr = 0; uint32_t rd = 0, wr = 0;

View File

@@ -1,11 +1,11 @@
/** @defgroup crypto_file CRYPTO /** @defgroup crypto_file CRYPTO
* *
* @ingroup STM32F4xx * @ingroup STM32F4xx
* *
* @brief <b>libopencm3 STM32F4xx CRYPTO</b> * @brief <b>libopencm3 STM32F4xx CRYPTO</b>
* *
* @version 1.0.0 * @version 1.0.0
* *
* @date 18 Jun 2013 * @date 18 Jun 2013
* *
*/ */
@@ -43,10 +43,10 @@ void crypto_set_mac_algorithm(crypto_mode_mac_t mode)
/** /**
* @brief Swap context * @brief Swap context
* *
*@param[in] buf uint32_t Memory space for swap (16 items length) *@param[in] buf uint32_t Memory space for swap (16 items length)
*/ */
void crypto_context_swap(uint32_t * buf) void crypto_context_swap(uint32_t *buf)
{ {
int i; int i;
/* Apply exact order of ? */ /* Apply exact order of ? */