Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame^] | 1 | From c54afe45c1be25c4819b0f762cf03a24e6343ce5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Satish Kumar <satish.kumar01@arm.com> |
| 3 | Date: Sun, 13 Feb 2022 09:49:51 +0000 |
| 4 | Subject: [PATCH 16/19] Integrate remaining psa-ipc client APIs. |
| 5 | |
| 6 | Upstream-Status: Pending |
| 7 | Signed-off-by: Satish Kumar <satish.kumar01@arm.com> |
| 8 | Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> |
| 9 | --- |
| 10 | .../caller/psa_ipc/crypto_caller_aead.h | 297 +++++++++++++++++- |
| 11 | .../caller/psa_ipc/crypto_caller_sign_hash.h | 35 +++ |
| 12 | .../psa_ipc/crypto_caller_verify_hash.h | 33 +- |
| 13 | 3 files changed, 352 insertions(+), 13 deletions(-) |
| 14 | |
| 15 | diff --git a/components/service/crypto/client/caller/psa_ipc/crypto_caller_aead.h b/components/service/crypto/client/caller/psa_ipc/crypto_caller_aead.h |
| 16 | index 78517fe32ca9..f6aadd8b9098 100644 |
| 17 | --- a/components/service/crypto/client/caller/psa_ipc/crypto_caller_aead.h |
| 18 | +++ b/components/service/crypto/client/caller/psa_ipc/crypto_caller_aead.h |
| 19 | @@ -152,7 +152,27 @@ static inline psa_status_t crypto_caller_aead_encrypt_setup( |
| 20 | psa_key_id_t key, |
| 21 | psa_algorithm_t alg) |
| 22 | { |
| 23 | - return PSA_ERROR_NOT_SUPPORTED; |
| 24 | + struct service_client *ipc = context; |
| 25 | + struct rpc_caller *caller = ipc->caller; |
| 26 | + psa_status_t status; |
| 27 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 28 | + .sfn_id = TFM_CRYPTO_AEAD_ENCRYPT_SETUP_SID, |
| 29 | + .key_id = key, |
| 30 | + .alg = alg, |
| 31 | + .op_handle = (*op_handle), |
| 32 | + }; |
| 33 | + |
| 34 | + struct psa_invec in_vec[] = { |
| 35 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)} |
| 36 | + }; |
| 37 | + struct psa_outvec out_vec[] = { |
| 38 | + {.base = psa_ptr_to_u32(op_handle), .len = sizeof(uint32_t)} |
| 39 | + }; |
| 40 | + |
| 41 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 42 | + IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec)); |
| 43 | + |
| 44 | + return status; |
| 45 | } |
| 46 | |
| 47 | static inline psa_status_t crypto_caller_aead_decrypt_setup( |
| 48 | @@ -161,7 +181,26 @@ static inline psa_status_t crypto_caller_aead_decrypt_setup( |
| 49 | psa_key_id_t key, |
| 50 | psa_algorithm_t alg) |
| 51 | { |
| 52 | - return PSA_ERROR_NOT_SUPPORTED; |
| 53 | + struct service_client *ipc = context; |
| 54 | + struct rpc_caller *caller = ipc->caller; |
| 55 | + psa_status_t status; |
| 56 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 57 | + .sfn_id = TFM_CRYPTO_AEAD_DECRYPT_SETUP_SID, |
| 58 | + .key_id = key, |
| 59 | + .alg = alg, |
| 60 | + .op_handle = (*op_handle), |
| 61 | + }; |
| 62 | + |
| 63 | + struct psa_invec in_vec[] = { |
| 64 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)} |
| 65 | + }; |
| 66 | + struct psa_outvec out_vec[] = { |
| 67 | + {.base = psa_ptr_to_u32(op_handle), .len = sizeof(uint32_t)} |
| 68 | + }; |
| 69 | + |
| 70 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 71 | + IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec)); |
| 72 | + return status; |
| 73 | } |
| 74 | |
| 75 | static inline psa_status_t crypto_caller_aead_generate_nonce( |
| 76 | @@ -171,7 +210,27 @@ static inline psa_status_t crypto_caller_aead_generate_nonce( |
| 77 | size_t nonce_size, |
| 78 | size_t *nonce_length) |
| 79 | { |
| 80 | - return PSA_ERROR_NOT_SUPPORTED; |
| 81 | + struct service_client *ipc = context; |
| 82 | + struct rpc_caller *caller = ipc->caller; |
| 83 | + psa_status_t status; |
| 84 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 85 | + .sfn_id = TFM_CRYPTO_AEAD_GENERATE_NONCE_SID, |
| 86 | + .op_handle = op_handle, |
| 87 | + }; |
| 88 | + |
| 89 | + struct psa_invec in_vec[] = { |
| 90 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)}, |
| 91 | + }; |
| 92 | + struct psa_outvec out_vec[] = { |
| 93 | + {.base = psa_ptr_to_u32(&op_handle), .len = sizeof(uint32_t)}, |
| 94 | + {.base = psa_ptr_to_u32(nonce), .len = nonce_size} |
| 95 | + }; |
| 96 | + |
| 97 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 98 | + IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec)); |
| 99 | + |
| 100 | + *nonce_length = out_vec[1].len; |
| 101 | + return status; |
| 102 | } |
| 103 | |
| 104 | static inline psa_status_t crypto_caller_aead_set_nonce( |
| 105 | @@ -180,7 +239,25 @@ static inline psa_status_t crypto_caller_aead_set_nonce( |
| 106 | const uint8_t *nonce, |
| 107 | size_t nonce_length) |
| 108 | { |
| 109 | - return PSA_ERROR_NOT_SUPPORTED; |
| 110 | + struct service_client *ipc = context; |
| 111 | + struct rpc_caller *caller = ipc->caller; |
| 112 | + psa_status_t status; |
| 113 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 114 | + .sfn_id = TFM_CRYPTO_AEAD_SET_NONCE_SID, |
| 115 | + .op_handle = op_handle, |
| 116 | + }; |
| 117 | + |
| 118 | + struct psa_invec in_vec[] = { |
| 119 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)}, |
| 120 | + {.base = psa_ptr_to_u32(nonce), .len = nonce_length} |
| 121 | + }; |
| 122 | + struct psa_outvec out_vec[] = { |
| 123 | + {.base = psa_ptr_to_u32(&op_handle), .len = sizeof(uint32_t)} |
| 124 | + }; |
| 125 | + |
| 126 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 127 | + IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec)); |
| 128 | + return status; |
| 129 | } |
| 130 | |
| 131 | static inline psa_status_t crypto_caller_aead_set_lengths( |
| 132 | @@ -189,7 +266,27 @@ static inline psa_status_t crypto_caller_aead_set_lengths( |
| 133 | size_t ad_length, |
| 134 | size_t plaintext_length) |
| 135 | { |
| 136 | - return PSA_ERROR_NOT_SUPPORTED; |
| 137 | + struct service_client *ipc = context; |
| 138 | + struct rpc_caller *caller = ipc->caller; |
| 139 | + psa_status_t status; |
| 140 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 141 | + .sfn_id = TFM_CRYPTO_AEAD_SET_LENGTHS_SID, |
| 142 | + .ad_length = ad_length, |
| 143 | + .plaintext_length = plaintext_length, |
| 144 | + .op_handle = op_handle, |
| 145 | + }; |
| 146 | + |
| 147 | + struct psa_invec in_vec[] = { |
| 148 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)}, |
| 149 | + }; |
| 150 | + struct psa_outvec out_vec[] = { |
| 151 | + {.base = psa_ptr_to_u32(&op_handle), .len = sizeof(uint32_t)} |
| 152 | + }; |
| 153 | + |
| 154 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 155 | + IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec)); |
| 156 | + |
| 157 | + return status; |
| 158 | } |
| 159 | |
| 160 | static inline psa_status_t crypto_caller_aead_update_ad( |
| 161 | @@ -198,7 +295,35 @@ static inline psa_status_t crypto_caller_aead_update_ad( |
| 162 | const uint8_t *input, |
| 163 | size_t input_length) |
| 164 | { |
| 165 | - return PSA_ERROR_NOT_SUPPORTED; |
| 166 | + struct service_client *ipc = context; |
| 167 | + struct rpc_caller *caller = ipc->caller; |
| 168 | + psa_status_t status; |
| 169 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 170 | + .sfn_id = TFM_CRYPTO_AEAD_UPDATE_AD_SID, |
| 171 | + .op_handle = op_handle, |
| 172 | + }; |
| 173 | + |
| 174 | + /* Sanitize the optional input */ |
| 175 | + if ((input == NULL) && (input_length != 0)) { |
| 176 | + return PSA_ERROR_INVALID_ARGUMENT; |
| 177 | + } |
| 178 | + |
| 179 | + struct psa_invec in_vec[] = { |
| 180 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)}, |
| 181 | + {.base = psa_ptr_const_to_u32(input), .len = input_length} |
| 182 | + }; |
| 183 | + struct psa_outvec out_vec[] = { |
| 184 | + {.base = psa_ptr_to_u32(&op_handle), .len = sizeof(uint32_t)} |
| 185 | + }; |
| 186 | + |
| 187 | + size_t in_len = IOVEC_LEN(in_vec); |
| 188 | + |
| 189 | + if (input == NULL) { |
| 190 | + in_len--; |
| 191 | + } |
| 192 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 193 | + in_len, out_vec, IOVEC_LEN(out_vec)); |
| 194 | + return status; |
| 195 | } |
| 196 | |
| 197 | static inline psa_status_t crypto_caller_aead_update( |
| 198 | @@ -210,7 +335,38 @@ static inline psa_status_t crypto_caller_aead_update( |
| 199 | size_t output_size, |
| 200 | size_t *output_length) |
| 201 | { |
| 202 | - return PSA_ERROR_NOT_SUPPORTED; |
| 203 | + struct service_client *ipc = context; |
| 204 | + struct rpc_caller *caller = ipc->caller; |
| 205 | + psa_status_t status; |
| 206 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 207 | + .sfn_id = TFM_CRYPTO_AEAD_UPDATE_SID, |
| 208 | + .op_handle = op_handle, |
| 209 | + }; |
| 210 | + |
| 211 | + /* Sanitize the optional input */ |
| 212 | + if ((input == NULL) && (input_length != 0)) { |
| 213 | + return PSA_ERROR_INVALID_ARGUMENT; |
| 214 | + } |
| 215 | + |
| 216 | + struct psa_invec in_vec[] = { |
| 217 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)}, |
| 218 | + {.base = psa_ptr_const_to_u32(input), .len = input_length} |
| 219 | + }; |
| 220 | + struct psa_outvec out_vec[] = { |
| 221 | + {.base = psa_ptr_to_u32(&op_handle), .len = sizeof(uint32_t)}, |
| 222 | + {.base = psa_ptr_const_to_u32(output), .len = output_size}, |
| 223 | + }; |
| 224 | + |
| 225 | + size_t in_len = IOVEC_LEN(in_vec); |
| 226 | + |
| 227 | + if (input == NULL) { |
| 228 | + in_len--; |
| 229 | + } |
| 230 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 231 | + in_len, out_vec, IOVEC_LEN(out_vec)); |
| 232 | + |
| 233 | + *output_length = out_vec[1].len; |
| 234 | + return status; |
| 235 | } |
| 236 | |
| 237 | static inline psa_status_t crypto_caller_aead_finish( |
| 238 | @@ -223,7 +379,48 @@ static inline psa_status_t crypto_caller_aead_finish( |
| 239 | size_t tag_size, |
| 240 | size_t *tag_length) |
| 241 | { |
| 242 | - return PSA_ERROR_NOT_SUPPORTED; |
| 243 | + struct service_client *ipc = context; |
| 244 | + struct rpc_caller *caller = ipc->caller; |
| 245 | + psa_status_t status; |
| 246 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 247 | + .sfn_id = TFM_CRYPTO_AEAD_FINISH_SID, |
| 248 | + .op_handle = op_handle, |
| 249 | + }; |
| 250 | + |
| 251 | + /* Sanitize the optional output */ |
| 252 | + if ((aeadtext == NULL) && (aeadtext_size != 0)) { |
| 253 | + return PSA_ERROR_INVALID_ARGUMENT; |
| 254 | + } |
| 255 | + |
| 256 | + struct psa_invec in_vec[] = { |
| 257 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)}, |
| 258 | + }; |
| 259 | + struct psa_outvec out_vec[] = { |
| 260 | + {.base = psa_ptr_to_u32(&op_handle), .len = sizeof(uint32_t)}, |
| 261 | + {.base = psa_ptr_const_to_u32(tag), .len = tag_size}, |
| 262 | + {.base = psa_ptr_const_to_u32(aeadtext), .len = aeadtext_size} |
| 263 | + }; |
| 264 | + |
| 265 | + size_t out_len = IOVEC_LEN(out_vec); |
| 266 | + |
| 267 | + if (aeadtext == NULL || aeadtext_size == 0) { |
| 268 | + out_len--; |
| 269 | + } |
| 270 | + if ((out_len == 3) && (aeadtext_length == NULL)) { |
| 271 | + return PSA_ERROR_INVALID_ARGUMENT; |
| 272 | + } |
| 273 | + |
| 274 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 275 | + IOVEC_LEN(in_vec), out_vec, out_len); |
| 276 | + |
| 277 | + *tag_length = out_vec[1].len; |
| 278 | + |
| 279 | + if (out_len == 3) { |
| 280 | + *aeadtext_length = out_vec[2].len; |
| 281 | + } else { |
| 282 | + *aeadtext_length = 0; |
| 283 | + } |
| 284 | + return status; |
| 285 | } |
| 286 | |
| 287 | static inline psa_status_t crypto_caller_aead_verify( |
| 288 | @@ -235,14 +432,94 @@ static inline psa_status_t crypto_caller_aead_verify( |
| 289 | const uint8_t *tag, |
| 290 | size_t tag_length) |
| 291 | { |
| 292 | - return PSA_ERROR_NOT_SUPPORTED; |
| 293 | + struct service_client *ipc = context; |
| 294 | + struct rpc_caller *caller = ipc->caller; |
| 295 | + psa_status_t status; |
| 296 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 297 | + .sfn_id = TFM_CRYPTO_AEAD_VERIFY_SID, |
| 298 | + .op_handle = op_handle, |
| 299 | + }; |
| 300 | + |
| 301 | + /* Sanitize the optional output */ |
| 302 | + if ((plaintext == NULL) && (plaintext_size != 0)) { |
| 303 | + return PSA_ERROR_INVALID_ARGUMENT; |
| 304 | + } |
| 305 | + |
| 306 | + struct psa_invec in_vec[] = { |
| 307 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)}, |
| 308 | + {.base = psa_ptr_const_to_u32(tag), .len = tag_length} |
| 309 | + }; |
| 310 | + struct psa_outvec out_vec[] = { |
| 311 | + {.base = psa_ptr_to_u32(&op_handle), .len = sizeof(uint32_t)}, |
| 312 | + {.base = psa_ptr_const_to_u32(plaintext), .len = plaintext_size}, |
| 313 | + }; |
| 314 | + |
| 315 | + size_t out_len = IOVEC_LEN(out_vec); |
| 316 | + |
| 317 | + if (plaintext == NULL || plaintext_size == 0) { |
| 318 | + out_len--; |
| 319 | + } |
| 320 | + if ((out_len == 2) && (plaintext_length == NULL)) { |
| 321 | + return PSA_ERROR_INVALID_ARGUMENT; |
| 322 | + } |
| 323 | + |
| 324 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 325 | + IOVEC_LEN(in_vec), out_vec, out_len); |
| 326 | + |
| 327 | + if (out_len == 2) { |
| 328 | + *plaintext_length = out_vec[1].len; |
| 329 | + } else { |
| 330 | + *plaintext_length = 0; |
| 331 | + } |
| 332 | + return status; |
| 333 | } |
| 334 | |
| 335 | static inline psa_status_t crypto_caller_aead_abort( |
| 336 | struct service_client *context, |
| 337 | uint32_t op_handle) |
| 338 | { |
| 339 | - return PSA_ERROR_NOT_SUPPORTED; |
| 340 | + struct service_client *ipc = context; |
| 341 | + struct rpc_caller *caller = ipc->caller; |
| 342 | + psa_status_t status; |
| 343 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 344 | + .sfn_id = TFM_CRYPTO_AEAD_ABORT_SID, |
| 345 | + .op_handle = op_handle, |
| 346 | + }; |
| 347 | + |
| 348 | + struct psa_invec in_vec[] = { |
| 349 | + {.base = psa_ptr_to_u32(&iov), .len = sizeof(struct psa_ipc_crypto_pack_iovec)}, |
| 350 | + }; |
| 351 | + struct psa_outvec out_vec[] = { |
| 352 | + {.base = psa_ptr_to_u32(&op_handle), .len = sizeof(uint32_t)}, |
| 353 | + }; |
| 354 | + |
| 355 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 356 | + IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec)); |
| 357 | + return status; |
| 358 | +} |
| 359 | + |
| 360 | +static inline size_t crypto_caller_aead_max_update_size(const struct service_client *context) |
| 361 | +{ |
| 362 | + /* Returns the maximum number of bytes that may be |
| 363 | + * carried as a parameter of the mac_update operation |
| 364 | + * using the packed-c encoding. |
| 365 | + */ |
| 366 | + size_t payload_space = context->service_info.max_payload; |
| 367 | + size_t overhead = iov_size; |
| 368 | + |
| 369 | + return (payload_space > overhead) ? payload_space - overhead : 0; |
| 370 | +} |
| 371 | + |
| 372 | +static inline size_t crypto_caller_aead_max_update_ad_size(const struct service_client *context) |
| 373 | +{ |
| 374 | + /* Returns the maximum number of bytes that may be |
| 375 | + * carried as a parameter of the mac_update operation |
| 376 | + * using the packed-c encoding. |
| 377 | + */ |
| 378 | + size_t payload_space = context->service_info.max_payload; |
| 379 | + size_t overhead = iov_size; |
| 380 | + |
| 381 | + return (payload_space > overhead) ? payload_space - overhead : 0; |
| 382 | } |
| 383 | |
| 384 | #ifdef __cplusplus |
| 385 | diff --git a/components/service/crypto/client/caller/psa_ipc/crypto_caller_sign_hash.h b/components/service/crypto/client/caller/psa_ipc/crypto_caller_sign_hash.h |
| 386 | index 71d88cededf5..e4a2b167defb 100644 |
| 387 | --- a/components/service/crypto/client/caller/psa_ipc/crypto_caller_sign_hash.h |
| 388 | +++ b/components/service/crypto/client/caller/psa_ipc/crypto_caller_sign_hash.h |
| 389 | @@ -57,6 +57,41 @@ static inline psa_status_t crypto_caller_sign_hash(struct service_client *contex |
| 390 | return status; |
| 391 | } |
| 392 | |
| 393 | +static inline psa_status_t crypto_caller_sign_message(struct service_client *context, |
| 394 | + psa_key_id_t id, |
| 395 | + psa_algorithm_t alg, |
| 396 | + const uint8_t *hash, |
| 397 | + size_t hash_length, |
| 398 | + uint8_t *signature, |
| 399 | + size_t signature_size, |
| 400 | + size_t *signature_length) |
| 401 | +{ |
| 402 | + struct service_client *ipc = context; |
| 403 | + struct rpc_caller *caller = ipc->caller; |
| 404 | + psa_status_t status; |
| 405 | + struct psa_ipc_crypto_pack_iovec iov = { |
| 406 | + .sfn_id = TFM_CRYPTO_SIGN_MESSAGE_SID, |
| 407 | + .key_id = id, |
| 408 | + .alg = alg, |
| 409 | + }; |
| 410 | + struct psa_invec in_vec[] = { |
| 411 | + { .base = psa_ptr_to_u32(&iov), .len = iov_size }, |
| 412 | + { .base = psa_ptr_const_to_u32(hash), .len = hash_length }, |
| 413 | + }; |
| 414 | + struct psa_outvec out_vec[] = { |
| 415 | + { .base = psa_ptr_to_u32(signature), .len = signature_size }, |
| 416 | + }; |
| 417 | + |
| 418 | + status = psa_call(caller, TFM_CRYPTO_HANDLE, PSA_IPC_CALL, in_vec, |
| 419 | + IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec)); |
| 420 | + |
| 421 | + *signature_length = out_vec[0].len; |
| 422 | + |
| 423 | + return status; |
| 424 | +} |
| 425 | + |
| 426 | + |
| 427 | + |
| 428 | #ifdef __cplusplus |
| 429 | } |
| 430 | #endif |
| 431 | diff --git a/components/service/crypto/client/caller/psa_ipc/crypto_caller_verify_hash.h b/components/service/crypto/client/caller/psa_ipc/crypto_caller_verify_hash.h |
| 432 | index e16f6e5450af..cc9279ee79f2 100644 |
| 433 | --- a/components/service/crypto/client/caller/psa_ipc/crypto_caller_verify_hash.h |
| 434 | +++ b/components/service/crypto/client/caller/psa_ipc/crypto_caller_verify_hash.h |
| 435 | @@ -24,19 +24,20 @@ |
| 436 | extern "C" { |
| 437 | #endif |
| 438 | |
| 439 | -static inline psa_status_t crypto_caller_verify_hash(struct service_client *context, |
| 440 | +static inline psa_status_t crypto_caller_common(struct service_client *context, |
| 441 | psa_key_id_t id, |
| 442 | psa_algorithm_t alg, |
| 443 | const uint8_t *hash, |
| 444 | size_t hash_length, |
| 445 | const uint8_t *signature, |
| 446 | - size_t signature_length) |
| 447 | + size_t signature_length, |
| 448 | + uint32_t sfn_id) |
| 449 | { |
| 450 | struct service_client *ipc = context; |
| 451 | struct rpc_caller *caller = ipc->caller; |
| 452 | psa_status_t status; |
| 453 | struct psa_ipc_crypto_pack_iovec iov = { |
| 454 | - .sfn_id = TFM_CRYPTO_VERIFY_HASH_SID, |
| 455 | + .sfn_id = sfn_id, |
| 456 | .key_id = id, |
| 457 | .alg = alg, |
| 458 | }; |
| 459 | @@ -52,6 +53,32 @@ static inline psa_status_t crypto_caller_verify_hash(struct service_client *cont |
| 460 | return status; |
| 461 | } |
| 462 | |
| 463 | +static inline psa_status_t crypto_caller_verify_hash(struct service_client *context, |
| 464 | + psa_key_id_t id, |
| 465 | + psa_algorithm_t alg, |
| 466 | + const uint8_t *hash, |
| 467 | + size_t hash_length, |
| 468 | + const uint8_t *signature, |
| 469 | + size_t signature_length) |
| 470 | +{ |
| 471 | + |
| 472 | + return crypto_caller_common(context,id,alg,hash,hash_length, |
| 473 | + signature,signature_length, TFM_CRYPTO_VERIFY_HASH_SID); |
| 474 | +} |
| 475 | + |
| 476 | +static inline psa_status_t crypto_caller_verify_message(struct service_client *context, |
| 477 | + psa_key_id_t id, |
| 478 | + psa_algorithm_t alg, |
| 479 | + const uint8_t *hash, |
| 480 | + size_t hash_length, |
| 481 | + const uint8_t *signature, |
| 482 | + size_t signature_length) |
| 483 | +{ |
| 484 | + |
| 485 | + return crypto_caller_common(context,id,alg,hash,hash_length, |
| 486 | + signature,signature_length, TFM_CRYPTO_VERIFY_MESSAGE_SID); |
| 487 | +} |
| 488 | + |
| 489 | #ifdef __cplusplus |
| 490 | } |
| 491 | #endif |
| 492 | -- |
| 493 | 2.38.0 |
| 494 | |