1 /* ----------------------------------------------------------------------------
\r
2 * SAM Software Package License
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2015, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
33 /*----------------------------------------------------------------------------
\r
35 *----------------------------------------------------------------------------*/
\r
39 /*----------------------------------------------------------------------------
\r
41 *----------------------------------------------------------------------------*/
\r
43 #define MODE_SINGLE_DES 0x00
\r
44 #define MODE_TRIPLE_DES 0x01
\r
45 #define MODE_XTEA 0x02
\r
47 /*----------------------------------------------------------------------------
\r
48 * Exported functions
\r
49 *----------------------------------------------------------------------------*/
\r
52 * \brief Starts Manual encryption/decryption process.
\r
54 void tdes_start(void);
\r
57 * \brief Resets the TDES.
\r
58 * A software triggered hardware reset of the TDES interface is performed.
\r
60 void tdes_soft_reset(void);
\r
63 * \brief Configures an TDES peripheral with the specified parameters.
\r
64 * \param mode Desired value for the TDES_MR mode register (see the datasheet).
\r
66 void tdes_configure(uint32_t mode);
\r
69 * \brief Enables the selected interrupts sources on a TDES peripheral.
\r
70 * \param sources Bitwise OR of selected interrupt sources.
\r
72 void tdes_enable_it(uint32_t sources);
\r
75 * \brief Disables the selected interrupts sources on a TDES peripheral.
\r
76 * \param sources Bitwise OR of selected interrupt sources.
\r
78 void tdes_disable_it(uint32_t sources);
\r
81 * \brief Get the current status register of the given TDES peripheral.
\r
82 * \return TDES status register.
\r
84 extern uint32_t tdes_get_status(void);
\r
87 * \brief Set KEY 1/2/3.
\r
88 * \param key_word0 Key x, word 0
\r
89 * \param key_word1 Key x, word 1
\r
91 void tdes_write_key1(uint32_t key_word0, uint32_t key_word1);
\r
92 void tdes_write_key2(uint32_t key_word0, uint32_t key_word1);
\r
93 void tdes_write_key3(uint32_t key_word0, uint32_t key_word1);
\r
96 * \brief Set the two 32-bit input data registers. Allows to set the 64-bit data
\r
97 * block used for encryption/decryption.
\r
98 * \param data0 Corresponds to the first word of the data to be processed.
\r
99 * \param data1 Corresponds to the last word of the data to be processed.
\r
101 void tdes_set_input(uint32_t data0, uint32_t data1);
\r
104 * \brief Read from the two 32-bit data registers containing the 64-bit data
\r
105 * block which has been encrypted/decrypted.
\r
106 * \param data0 Points to the first word.
\r
107 * \param data1 Points to the second word.
\r
109 void tdes_get_output(uint32_t *data0, uint32_t *data1);
\r
112 * \brief Set the 64-bit initialization vector data block, which is used by
\r
113 * specific modes of operation as an additional initial input.
\r
114 * \param v0 Corresponds to the first word of the initialization vector.
\r
115 * \param v1 Corresponds to the second word of the initialization vector.
\r
117 void tdes_set_vector(uint32_t v0, uint32_t v1);
\r
120 * \brief Set the 6-bit complete rounds.
\r
121 * \param rounds Corresponds to rounds+1 complete round.
\r
123 void tdes_set_xtea_rounds(uint32_t rounds);
\r
125 #endif /* #ifndef _TDES_ */
\r