1 /***************************************************************************//**
2 * \file cy_crypto_core_des.h
3 * \version 2.120
4 *
5 * \brief
6 * This file provides constant and parameters for the API for the DES method
7 * in the Crypto driver.
8 *
9 ********************************************************************************
10 * \copyright
11 * Copyright (c) (2020-2022), Cypress Semiconductor Corporation (an Infineon company) or
12 * an affiliate of Cypress Semiconductor Corporation.
13 * SPDX-License-Identifier: Apache-2.0
14 *
15 * Licensed under the Apache License, Version 2.0 (the "License");
16 * you may not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
18 *
19 * http://www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
26 *******************************************************************************/
27
28
29 #if !defined (CY_CRYPTO_CORE_DES_H)
30 #define CY_CRYPTO_CORE_DES_H
31
32 #include "cy_device.h"
33
34 #if defined (CY_IP_MXCRYPTO)
35
36 #include "cy_crypto_common.h"
37
38 #if defined(__cplusplus)
39 extern "C" {
40 #endif
41
42 #if (CPUSS_CRYPTO_DES == 1) && defined(CY_CRYPTO_CFG_DES_C)
43
44 #include "cy_crypto_core_des_v1.h"
45 #include "cy_crypto_core_des_v2.h"
46
47 typedef cy_en_crypto_status_t (*cy_crypto_des_func_t)(CRYPTO_Type *base,
48 cy_en_crypto_dir_mode_t dirMode,
49 uint8_t const *key,
50 uint8_t *dst,
51 uint8_t const *src);
52
53 /**
54 * \addtogroup group_crypto_lld_symmetric_functions
55 * \{
56 */
57
58 /*******************************************************************************
59 * Function Name: Cy_Crypto_Core_Des
60 ****************************************************************************//**
61 *
62 * Performs the DES operation on a single block. All addresses must be 4-byte aligned.
63 * Ciphertext (dst) may overlap with plaintext (src).
64 * This function is independent from the previous Crypto state.
65 *
66 * \param base
67 * The pointer to the CRYPTO instance.
68 *
69 * \param dirMode
70 * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT
71 * (\ref cy_en_crypto_dir_mode_t)
72 *
73 * \param key
74 * The pointer to the encryption/decryption key.
75 *
76 * \param dst
77 * The pointer to the destination cipher block.
78 *
79 * \param src
80 * The pointer to the source block.
81 *
82 * \return
83 * \ref cy_en_crypto_status_t
84 *
85 * \funcusage
86 * \snippet crypto/snippet/main.c snippet_myCryptoCoreDesUse
87 *
88 *******************************************************************************/
Cy_Crypto_Core_Des(CRYPTO_Type * base,cy_en_crypto_dir_mode_t dirMode,uint8_t const * key,uint8_t * dst,uint8_t const * src)89 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Des(CRYPTO_Type *base,
90 cy_en_crypto_dir_mode_t dirMode,
91 uint8_t const *key,
92 uint8_t *dst,
93 uint8_t const *src)
94 {
95 cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED;
96
97 if (CY_CRYPTO_V1)
98 {
99 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
100 tmpResult = Cy_Crypto_Core_V1_Des(base, dirMode, key, dst, src);
101 #endif /* defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */
102 }
103 else
104 {
105 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
106 tmpResult = Cy_Crypto_Core_V2_Des(base, dirMode, key, dst, src);
107 #endif /* defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
108 }
109
110 return tmpResult;
111 }
112
113 /*******************************************************************************
114 * Function Name: Cy_Crypto_Core_Tdes
115 ****************************************************************************//**
116 *
117 * Performs the TDES operation on a single block. All addresses must be 4-byte aligned.
118 * Ciphertext (dst) may overlap with plaintext (src).
119 * This function is independent from the previous Crypto state.
120 *
121 * \param base
122 * The pointer to the CRYPTO instance.
123 *
124 * \param dirMode
125 * Can be \ref CY_CRYPTO_ENCRYPT or \ref CY_CRYPTO_DECRYPT
126 * (\ref cy_en_crypto_dir_mode_t)
127 *
128 * \param key
129 * The pointer to the encryption/decryption keys.
130 *
131 * \param dst
132 * The pointer to the destination cipher block.
133 *
134 * \param src
135 * The pointer to the source data block.
136 *
137 * \return
138 * \ref cy_en_crypto_status_t
139 *
140 * \funcusage
141 * \snippet crypto/snippet/main.c snippet_myCryptoCoreTdesUse
142 #
143 *******************************************************************************/
Cy_Crypto_Core_Tdes(CRYPTO_Type * base,cy_en_crypto_dir_mode_t dirMode,uint8_t const * key,uint8_t * dst,uint8_t const * src)144 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Tdes(CRYPTO_Type *base,
145 cy_en_crypto_dir_mode_t dirMode,
146 uint8_t const *key,
147 uint8_t *dst,
148 uint8_t const *src)
149 {
150 cy_en_crypto_status_t tmpResult = CY_CRYPTO_NOT_SUPPORTED;
151
152 if (CY_CRYPTO_V1)
153 {
154 #if defined(CY_CRYPTO_CFG_HW_V1_ENABLE)
155 tmpResult = Cy_Crypto_Core_V1_Tdes(base, dirMode, key, dst, src);
156 #endif /* defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */
157 }
158 else
159 {
160 #if defined(CY_CRYPTO_CFG_HW_V2_ENABLE)
161 tmpResult = Cy_Crypto_Core_V2_Tdes(base, dirMode, key, dst, src);
162 #endif /* defined(CY_CRYPTO_CFG_HW_V2_ENABLE) */
163 }
164
165 return tmpResult;
166 }
167
168 /** \} group_crypto_lld_symmetric_functions */
169
170 #endif /* (CPUSS_CRYPTO_DES == 1) && defined(CY_CRYPTO_CFG_DES_C) */
171
172 #if defined(__cplusplus)
173 }
174 #endif
175
176 #endif /* CY_IP_MXCRYPTO */
177
178 #endif /* #if !defined (CY_CRYPTO_CORE_DES_H) */
179
180
181 /* [] END OF FILE */
182