1 /***************************************************************************//**
2 * \file cy_cryptolite_utils.h
3 * \version 2.50
4 *
5 * \brief
6 *  This file provides provides helper functions
7 *  for the Cryptolite driver.
8 *
9 ********************************************************************************
10 * Copyright 2022 Cypress Semiconductor Corporation
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 *    http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *******************************************************************************/
25 #if !defined (CY_CRYPTOLITE_UTILS_H)
26 #define CY_CRYPTOLITE_UTILS_H
27 
28 #include "cy_device.h"
29 
30 #if defined(CY_IP_MXCRYPTOLITE)
31 
32 #include "cy_cryptolite_common.h"
33 
34 #if defined(__cplusplus)
35 extern "C" {
36 #endif
37 
38 
39 
40 /*******************************************************************************
41 * Function Name: Cy_Cryptolite_String2ByteArray
42 ****************************************************************************//**
43 *
44 * The function to convert hex string to byte array.
45 *
46 * \param p_dst
47 * The pointer to destination buffer where data to be copied.
48 *
49 * \param p_number_string
50 * The pointer to buffer containing the hex string.
51 *
52 * \param byteSize
53 * The size of the bytes to be converted.
54 *
55 *
56 *******************************************************************************/
57 
58 void Cy_Cryptolite_String2ByteArray (
59     uint8_t* p_dst,
60     int8_t*  p_number_string,
61     int      byte_size
62 );
63 
64 
65 /*******************************************************************************
66 * Function Name: Cy_Cryptolite_Setnumber
67 ****************************************************************************//**
68 *
69 * The function to copy the data without any alignment and boundary restriction.
70 *
71 * \param rdst
72 * The pointer to destination buffer where data to be copied.
73 *
74 * \param p_number
75 * The pointer to buffer containing the data.
76 *
77 * \param byteSize
78 * The size of the bytes to be copied.
79 *
80 *
81 *******************************************************************************/
82 void Cy_Cryptolite_Setnumber (
83     uint8_t* rdst,
84     uint8_t* p_number,
85     uint32_t size
86 );
87 
88 
89 
90 /*******************************************************************************
91 * Function Name: Cy_Cryptolite_Memcpy
92 ****************************************************************************//**
93 *
94 * The function to copy the data
95 * \note  The functions does 32 bit word copy for 4 byte aligned src and dst. This is required for OTP memory access where non-word access is restricted.
96 *        For non-aligned pointers byte copy is used.
97 *
98 * \param dst
99 * The pointer to destination buffer where data to be copied.
100 *
101 * \param src
102 * The pointer to source buffer.
103 *
104 * \param size
105 * The size of the buffer.
106 *
107 * \return
108 * \ref cy_en_cryptolite_status_t
109 *******************************************************************************/
110 
111 cy_en_cryptolite_status_t Cy_Cryptolite_Memcpy(CRYPTOLITE_Type *base, uint8_t* dst,
112                         uint8_t* src,
113                         uint32_t size);
114 
115 
116 
117 /*******************************************************************************
118 * Function Name: Cy_Cryptolite_Memset
119 ****************************************************************************//**
120 *
121 * The function to set the buffer to data of size bytes
122 *
123 * \param dst
124 * The pointer to destination buffer where data to be set.
125 *
126 * \param data
127 * The data to set in dest buffer.
128 *
129 * \param size
130 * The size of the buffer.
131 *
132 *******************************************************************************/
133 void Cy_Cryptolite_Memset (void  *dest, uint8_t data, uint32_t size);
134 
135 
136 /*******************************************************************************
137 * Function Name: Cy_Cryptolite_InvertEndianness
138 ****************************************************************************//**
139 *
140 * The function performs endian conversion of the data.
141 *
142 * \param inArrPtr
143 * The pointer to buffer containing the data.
144 *
145 * \param byteSize
146 *  The size of the inArrPtr buffer.
147 *
148 *
149 *******************************************************************************/
150 void Cy_Cryptolite_InvertEndianness(void *inArrPtr, uint32_t byteSize);
151 
152 
153 #if defined(__cplusplus)
154 }
155 #endif
156 
157 #endif /* CY_IP_MXCRYPTOLITE */
158 
159 #endif
160 /* [] END OF FILE */
161