1 /* *****************************************************************
\r
3 * Copyright 2017 Samsung Electronics All Rights Reserved.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
19 * *****************************************************************/
\r
23 #include <mbedtls/ssl.h>
\r
40 * This function set own certificate file and key file path to use hw emulation
\r
42 * @param[in] cert_filepath path for own certificate file
\r
43 * @param[in] key_filepath path for private key file
\r
44 * @param[in] pwd password for private key file
\r
45 * @return 0 on success, otherwise a negative value
\r
47 int SSemulSetCertkeyFilepath(const char* cert_filepath,
\r
48 const char* key_filepath, const char* pwd);
\r
51 * This function get type of stored key from hw emulation
\r
53 * @param[in] keyContext key context object that identifies proper certificate chain
\r
54 * @return SSE_KEY_TYPE
\r
56 int SSemulGetKeytype(const void* keyContext);
\r
59 * This function load own certificate data from hw emulation
\r
61 * @param[in] keyContext key context object that identifies proper certificate chain
\r
62 * @param[out] cert_chain certificate chain in binary
\r
63 * @param[out] cert_chain_len total length of certificate chain
\r
64 * @return 0 on success, otherwise a negative value
\r
66 int SSemulLoadOwncert(const void* keyContext,
\r
67 uint8_t** cert_chain, size_t* cert_chain_len);
\r
70 * This function get private key length from hw emulation
\r
72 * @param[in] keyContext key context object that identifies proper certificate chain
\r
73 * @return positive value on success, otherwise a negative value or zero
\r
75 int SSemulGetKeylen(const void* keyContext);
\r
78 * This function sign hash data with RSA private key from hw emulation
\r
80 * @param[in] keyContext key context object that identifies proper certificate chain
\r
81 * @param[in] f_rng RNG function
\r
82 * @param[in] p_rng RNG parameter
\r
83 * @param[in] mode RSA key mode
\r
84 * @param[in] md_alg md algorithm
\r
85 * @param[in] hashlen length of hash
\r
86 * @param[in] hash hash data to be signed
\r
87 * @param[in] sig signature of hash
\r
88 * @return 0 on success, otherwise a negative value
\r
90 int SSemulRsaSign(const void *keyContext,
\r
91 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
\r
92 int mode, mbedtls_md_type_t md_alg, unsigned int hashlen,
\r
93 const unsigned char *hash, unsigned char *sig );
\r
96 * This function sign hash data with ECC private key from hw emulation
\r
98 * @param[in] ctx key context poniter of mbedtls_pk_context
\r
99 * @param[in] md_alg md algorithm
\r
100 * @param[in] hash hash data to be signed
\r
101 * @param[in] hashlen length of hash
\r
102 * @param[in] sig signature of hash
\r
103 * @param[in] sig_len length of signature
\r
104 * @param[in] f_rng RNG function
\r
105 * @param[in] p_rng RNG parameter
\r
106 * @return 0 on success, otherwise a negative value
\r
108 int SSemulEcdsaSign( void *ctx, mbedtls_md_type_t md_alg,
\r
109 const unsigned char *hash, size_t hash_len,
\r
110 unsigned char *sig, size_t *sig_len,
\r
111 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
\r
117 #endif // SS_EMUL_H
\r