Mistake on this page? Email us
pt_crypto_api.h
Go to the documentation of this file.
1 /*
2  * ----------------------------------------------------------------------------
3  * Copyright 2019 ARM Ltd.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ----------------------------------------------------------------------------
19  */
20 
21 #ifndef PT_API_VERSION
22 #define PT_API_VERSION 2
23 #endif
24 #if PT_API_VERSION != 2
25 #error "Including mixed versions of Protocol API"
26 #endif
27 
28 #ifndef PT_CRYPTO_API_H_
29 #define PT_CRYPTO_API_H_
30 
31 #include <stdint.h>
33 
51 typedef void (*pt_crypto_success_handler)(const connection_id_t connection_id, const uint8_t *data, const size_t size, void *userdata);
52 
59 typedef void (*pt_crypto_failure_handler)(const connection_id_t connection_id, int error_code, void *userdata);
60 
65 
71 typedef void (*pt_crypto_get_item_failure_handler)(const connection_id_t connection_id, void *userdata);
72 
83 pt_status_t pt_crypto_get_certificate(const connection_id_t connection_id,
84  const char *name,
85  pt_crypto_get_item_success_handler success_handler,
86  pt_crypto_get_item_failure_handler failure_handler,
87  void *userdata);
88 
99 pt_status_t pt_crypto_get_public_key(const connection_id_t connection_id,
100  const char *name,
101  pt_crypto_get_item_success_handler success_handler,
102  pt_crypto_get_item_failure_handler failure_handler,
103  void *userdata);
104 
115 pt_status_t pt_crypto_generate_random(const connection_id_t connection_id,
116  const size_t size,
117  pt_crypto_success_handler success_handler,
118  pt_crypto_failure_handler failure_handler,
119  void *userdata);
120 
133 pt_status_t pt_crypto_asymmetric_sign(const connection_id_t connection_id,
134  const char *private_key_name,
135  const char *hash_digest,
136  const size_t hash_digest_size,
137  pt_crypto_success_handler success_handler,
138  pt_crypto_failure_handler failure_handler,
139  void *userdata);
140 
155 pt_status_t pt_crypto_asymmetric_verify(const connection_id_t connection_id,
156  const char *public_key_name,
157  const char *hash_digest,
158  const size_t hash_digest_size,
159  const char *signature,
160  const size_t signature_size,
161  pt_crypto_success_handler success_handler,
162  pt_crypto_failure_handler failure_handler,
163  void *userdata);
164 
165 #ifndef PARSEC_TPM_SE_SUPPORT
166 
178 pt_status_t pt_crypto_ecdh_key_agreement(const connection_id_t connection_id,
179  const char *private_key_name,
180  const char *peer_public_key,
181  const size_t peer_public_key_size,
182  pt_crypto_success_handler success_handler,
183  pt_crypto_failure_handler failure_handler,
184  void *userdata);
185 #endif // PARSEC_TPM_SE_SUPPORT
186 
192 #endif /* PT_CRYPTO_API_H_ */
void(* pt_crypto_get_item_failure_handler)(const connection_id_t connection_id, void *userdata)
Type definition for pt_crypto_get_item_failure_handler response failure handler.
Definition: pt_crypto_api.h:71
pt_status_t pt_crypto_asymmetric_verify(const connection_id_t connection_id, const char *public_key_name, const char *hash_digest, const size_t hash_digest_size, const char *signature, const size_t signature_size, pt_crypto_success_handler success_handler, pt_crypto_failure_handler failure_handler, void *userdata)
Perform asymmetric verify operation on given signature and hash digest using public key stored in sec...
pt_crypto_success_handler pt_crypto_get_item_success_handler
Type definition for pt_crypto_get_item_success_handler response success handler.
Definition: pt_crypto_api.h:64
Contains common structures and definitions for the protocol translator client.
pt_status_t pt_crypto_get_certificate(const connection_id_t connection_id, const char *name, pt_crypto_get_item_success_handler success_handler, pt_crypto_get_item_failure_handler failure_handler, void *userdata)
Retrieve a certificate from secure storage.
pt_status_t pt_crypto_asymmetric_sign(const connection_id_t connection_id, const char *private_key_name, const char *hash_digest, const size_t hash_digest_size, pt_crypto_success_handler success_handler, pt_crypto_failure_handler failure_handler, void *userdata)
Perform asymmetric sign operation using given hash digest and private key stored in secure storage on...
void(* pt_crypto_success_handler)(const connection_id_t connection_id, const uint8_t *data, const size_t size, void *userdata)
Type definition for a generic success handler returning a single buffer.
Definition: pt_crypto_api.h:51
pt_status_t pt_crypto_generate_random(const connection_id_t connection_id, const size_t size, pt_crypto_success_handler success_handler, pt_crypto_failure_handler failure_handler, void *userdata)
Generate and retrieve a random buffer from Device Management Edge.
pt_status_t pt_crypto_get_public_key(const connection_id_t connection_id, const char *name, pt_crypto_get_item_success_handler success_handler, pt_crypto_get_item_failure_handler failure_handler, void *userdata)
Retrieve a public key from secure storage.
pt_status_t pt_crypto_ecdh_key_agreement(const connection_id_t connection_id, const char *private_key_name, const char *peer_public_key, const size_t peer_public_key_size, pt_crypto_success_handler success_handler, pt_crypto_failure_handler failure_handler, void *userdata)
Perform ECDH key agreement using given peer public key and a private key stored in secure storage on ...
void(* pt_crypto_failure_handler)(const connection_id_t connection_id, int error_code, void *userdata)
Type definition for a generic failure response handler.
Definition: pt_crypto_api.h:59