Mbed OS Reference
Loading...
Searching...
No Matches
crypto_common.h
Go to the documentation of this file.
1/*
2 * mbed Microcontroller Library
3 * Copyright (c) 2019 Cypress Semiconductor Corporation
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19/**
20 * \file crypto_common.h
21 * \version 1.0
22 *
23 * \brief Header file for common mbedtls acceleration functions
24 *
25 */
26
27#if !defined(CRYPTO_COMMON_H)
28#define CRYPTO_COMMON_H
29
30#if defined(MBEDTLS_CONFIG_FILE)
31#include MBEDTLS_CONFIG_FILE
32#else
33#include "config.h"
34#endif
35
36#include "mbedtls/ecp.h"
37
38#include "cy_crypto_core_sha.h"
39
40#include "cyhal_crypto_common.h"
41
42/** CRYPTO object */
43typedef struct {
44#if defined(CY_IP_MXCRYPTO_INSTANCES) || defined(CPUSS_CRYPTO_PRESENT)
45 CRYPTO_Type* base;
46 cyhal_resource_inst_t resource;
47 cyhal_crypto_feature_t feature;
48#endif
50
51bool cy_hw_crypto_reserve(cy_hw_crypto_t *obj, cyhal_crypto_feature_t feature);
52void cy_hw_crypto_release(cy_hw_crypto_t *obj);
53void cy_hw_zeroize(void *data, uint32_t dataSize);
54
55void cy_hw_sha_init(void *ctx, uint32_t ctxSize);
56void cy_hw_sha_free(void *ctx, uint32_t ctxSize);
57
58int cy_hw_sha_start (cy_hw_crypto_t *obj, cy_stc_crypto_sha_state_t *hashState,
59 cy_en_crypto_sha_mode_t shaMode, void *shaBuffers);
60
61int cy_hw_sha_update(cy_hw_crypto_t *obj, cy_stc_crypto_sha_state_t *hashState,
62 const uint8_t *in, uint32_t inlen);
63
64int cy_hw_sha_finish(cy_hw_crypto_t *obj, cy_stc_crypto_sha_state_t *hashState,
65 uint8_t *output);
66
67void cy_hw_sha_clone(void *ctxDst, const void *ctxSrc, uint32_t ctxSize,
68 cy_stc_crypto_sha_state_t *hashStateDst, void *shaBuffersDst);
69
70int cy_hw_sha_process(cy_hw_crypto_t *obj, cy_stc_crypto_sha_state_t *hashState,
71 const uint8_t *in);
72
73#endif /* (CRYPTO_COMMON_H) */
Configuration options (set of defines)
This file provides an API for Elliptic Curves over GF(P) (ECP).
CRYPTO object.
Definition: crypto_common.h:43