Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 1 | /* |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 2 | * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | #include <stdint.h> |
| 7 | #include <stdlib.h> |
| 8 | #include <protocols/service/crypto/packed-c/opcodes.h> |
| 9 | #include <service/crypto/provider/mbedcrypto/crypto_provider.h> |
julhal01 | 2c18fbf | 2021-02-01 08:29:28 +0000 | [diff] [blame] | 10 | #include <service/crypto/provider/mbedcrypto/trng_adapter/trng_adapter.h> |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame^] | 11 | #include <service/secure_storage/frontend/psa/its/its_frontend.h> |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 12 | #include <protocols/rpc/common/packed-c/status.h> |
| 13 | #include <psa/crypto.h> |
| 14 | |
| 15 | /* Service request handlers */ |
| 16 | static rpc_status_t nop_handler(void *context, struct call_req* req); |
| 17 | static rpc_status_t generate_key_handler(void *context, struct call_req* req); |
| 18 | static rpc_status_t destroy_key_handler(void *context, struct call_req* req); |
| 19 | static rpc_status_t open_key_handler(void *context, struct call_req* req); |
| 20 | static rpc_status_t close_key_handler(void *context, struct call_req* req); |
| 21 | static rpc_status_t export_key_handler(void *context, struct call_req* req); |
| 22 | static rpc_status_t export_public_key_handler(void *context, struct call_req* req); |
| 23 | static rpc_status_t import_key_handler(void *context, struct call_req* req); |
| 24 | static rpc_status_t sign_hash_handler(void *context, struct call_req* req); |
| 25 | static rpc_status_t verify_hash_handler(void *context, struct call_req* req); |
| 26 | static rpc_status_t asymmetric_decrypt_handler(void *context, struct call_req* req); |
| 27 | static rpc_status_t asymmetric_encrypt_handler(void *context, struct call_req* req); |
| 28 | static rpc_status_t generate_random_handler(void *context, struct call_req* req); |
| 29 | |
| 30 | /* Handler mapping table for service */ |
| 31 | static const struct service_handler handler_table[] = { |
| 32 | {TS_CRYPTO_OPCODE_NOP, nop_handler}, |
| 33 | {TS_CRYPTO_OPCODE_GENERATE_KEY, generate_key_handler}, |
| 34 | {TS_CRYPTO_OPCODE_DESTROY_KEY, destroy_key_handler}, |
| 35 | {TS_CRYPTO_OPCODE_OPEN_KEY, open_key_handler}, |
| 36 | {TS_CRYPTO_OPCODE_CLOSE_KEY, close_key_handler}, |
| 37 | {TS_CRYPTO_OPCODE_EXPORT_KEY, export_key_handler}, |
| 38 | {TS_CRYPTO_OPCODE_EXPORT_PUBLIC_KEY, export_public_key_handler}, |
| 39 | {TS_CRYPTO_OPCODE_IMPORT_KEY, import_key_handler}, |
| 40 | {TS_CRYPTO_OPCODE_SIGN_HASH, sign_hash_handler}, |
| 41 | {TS_CRYPTO_OPCODE_VERIFY_HASH, verify_hash_handler}, |
| 42 | {TS_CRYPTO_OPCODE_ASYMMETRIC_DECRYPT, asymmetric_decrypt_handler}, |
| 43 | {TS_CRYPTO_OPCODE_ASYMMETRIC_ENCRYPT, asymmetric_encrypt_handler}, |
| 44 | {TS_CRYPTO_OPCODE_GENERATE_RANDOM, generate_random_handler} |
| 45 | }; |
| 46 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 47 | struct rpc_interface *mbed_crypto_provider_init(struct mbed_crypto_provider *context, |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame^] | 48 | struct rpc_caller *storage_caller, |
julhal01 | 2c18fbf | 2021-02-01 08:29:28 +0000 | [diff] [blame] | 49 | int trng_instance) |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 50 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 51 | struct rpc_interface *rpc_interface = NULL; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 52 | |
julhal01 | 2c18fbf | 2021-02-01 08:29:28 +0000 | [diff] [blame] | 53 | trng_adapter_init(trng_instance); |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 54 | |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 55 | /* |
| 56 | * A storage provider is required for persistent key storage. As this |
| 57 | * is a mandatory feature of the crypto service, insist on a storage |
| 58 | * provider being available. |
| 59 | */ |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame^] | 60 | if (context && storage_caller) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 61 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 62 | for (size_t encoding = 0; encoding < TS_RPC_ENCODING_LIMIT; ++encoding) |
| 63 | context->serializers[encoding] = NULL; |
| 64 | |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 65 | service_provider_init(&context->base_provider, context, |
| 66 | handler_table, sizeof(handler_table)/sizeof(struct service_handler)); |
| 67 | |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame^] | 68 | struct storage_backend *storage_backend = |
| 69 | secure_storage_client_init(&context->secure_storage_client, storage_caller); |
| 70 | |
| 71 | if (storage_backend && |
| 72 | (psa_its_frontend_init(storage_backend) == PSA_SUCCESS) && |
| 73 | (psa_crypto_init() == PSA_SUCCESS)) { |
| 74 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 75 | rpc_interface = service_provider_get_rpc_interface(&context->base_provider); |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame^] | 76 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 77 | } |
| 78 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 79 | return rpc_interface; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | void mbed_crypto_provider_deinit(struct mbed_crypto_provider *context) |
| 83 | { |
| 84 | (void)context; |
julhal01 | 2c18fbf | 2021-02-01 08:29:28 +0000 | [diff] [blame] | 85 | trng_adapter_deinit(); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 86 | } |
| 87 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 88 | void mbed_crypto_provider_register_serializer(struct mbed_crypto_provider *context, |
| 89 | unsigned int encoding, const struct crypto_provider_serializer *serializer) |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 90 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 91 | if (encoding < TS_RPC_ENCODING_LIMIT) |
| 92 | context->serializers[encoding] = serializer; |
| 93 | } |
| 94 | |
| 95 | static const struct crypto_provider_serializer* get_crypto_serializer(void *context, |
| 96 | const struct call_req *req) |
| 97 | { |
| 98 | struct mbed_crypto_provider *this_instance = (struct mbed_crypto_provider*)context; |
| 99 | const struct crypto_provider_serializer* serializer = NULL; |
| 100 | unsigned int encoding = call_req_get_encoding(req); |
| 101 | |
| 102 | if (encoding < TS_RPC_ENCODING_LIMIT) serializer = this_instance->serializers[encoding]; |
| 103 | |
| 104 | return serializer; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | static rpc_status_t nop_handler(void *context, struct call_req* req) |
| 108 | { |
| 109 | /* Responds to a request by returning success */ |
| 110 | rpc_status_t rpc_status = TS_RPC_CALL_ACCEPTED; |
| 111 | psa_status_t psa_status = PSA_SUCCESS; |
| 112 | |
| 113 | (void)context; |
| 114 | call_req_set_opstatus(req, psa_status); |
| 115 | |
| 116 | return rpc_status; |
| 117 | } |
| 118 | |
| 119 | static rpc_status_t generate_key_handler(void *context, struct call_req* req) |
| 120 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 121 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 122 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 123 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 124 | |
| 125 | psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; |
| 126 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 127 | if (serializer) |
| 128 | rpc_status = serializer->deserialize_generate_key_req(req_buf, &attributes); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 129 | |
| 130 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
| 131 | |
| 132 | psa_status_t psa_status; |
| 133 | psa_key_handle_t handle; |
| 134 | |
| 135 | psa_status = psa_generate_key(&attributes, &handle); |
| 136 | |
| 137 | if (psa_status == PSA_SUCCESS) { |
| 138 | |
| 139 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 140 | rpc_status = serializer->serialize_generate_key_resp(resp_buf, handle); |
| 141 | } |
| 142 | |
| 143 | call_req_set_opstatus(req, psa_status); |
| 144 | } |
| 145 | |
| 146 | psa_reset_key_attributes(&attributes); |
| 147 | |
| 148 | return rpc_status; |
| 149 | } |
| 150 | |
| 151 | static rpc_status_t destroy_key_handler(void *context, struct call_req* req) |
| 152 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 153 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 154 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 155 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 156 | |
| 157 | psa_key_handle_t handle; |
| 158 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 159 | if (serializer) |
| 160 | rpc_status = serializer->deserialize_destroy_key_req(req_buf, &handle); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 161 | |
| 162 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
| 163 | |
| 164 | psa_status_t psa_status; |
| 165 | |
| 166 | psa_status = psa_destroy_key(handle); |
| 167 | call_req_set_opstatus(req, psa_status); |
| 168 | } |
| 169 | |
| 170 | return rpc_status; |
| 171 | } |
| 172 | |
| 173 | static rpc_status_t open_key_handler(void *context, struct call_req* req) |
| 174 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 175 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 176 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 177 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 178 | |
| 179 | psa_key_id_t id; |
| 180 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 181 | if (serializer) |
| 182 | rpc_status = serializer->deserialize_open_key_req(req_buf, &id); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 183 | |
| 184 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
| 185 | |
| 186 | psa_status_t psa_status; |
| 187 | psa_key_handle_t handle; |
| 188 | |
| 189 | psa_status = psa_open_key(id, &handle); |
| 190 | |
| 191 | if (psa_status == PSA_SUCCESS) { |
| 192 | |
| 193 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 194 | rpc_status = serializer->serialize_open_key_resp(resp_buf, handle); |
| 195 | } |
| 196 | |
| 197 | call_req_set_opstatus(req, psa_status); |
| 198 | } |
| 199 | |
| 200 | return rpc_status; |
| 201 | } |
| 202 | |
| 203 | static rpc_status_t close_key_handler(void *context, struct call_req* req) |
| 204 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 205 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 206 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 207 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 208 | |
| 209 | psa_key_handle_t handle; |
| 210 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 211 | if (serializer) |
| 212 | rpc_status = serializer->deserialize_close_key_req(req_buf, &handle); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 213 | |
| 214 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
| 215 | |
| 216 | psa_status_t psa_status; |
| 217 | |
| 218 | psa_status = psa_close_key(handle); |
| 219 | call_req_set_opstatus(req, psa_status); |
| 220 | } |
| 221 | |
| 222 | return rpc_status; |
| 223 | } |
| 224 | |
| 225 | static rpc_status_t export_key_handler(void *context, struct call_req* req) |
| 226 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 227 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 228 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 229 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 230 | |
| 231 | psa_key_handle_t handle; |
| 232 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 233 | if (serializer) |
| 234 | rpc_status = serializer->deserialize_export_key_req(req_buf, &handle); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 235 | |
| 236 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
| 237 | |
| 238 | psa_status_t psa_status; |
| 239 | psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; |
| 240 | |
| 241 | psa_status = psa_get_key_attributes(handle, &attributes); |
| 242 | |
| 243 | if (psa_status == PSA_SUCCESS) { |
| 244 | |
| 245 | size_t max_export_size = PSA_KEY_EXPORT_MAX_SIZE( |
| 246 | psa_get_key_type(&attributes), |
| 247 | psa_get_key_bits(&attributes)); |
| 248 | |
| 249 | uint8_t *key_buffer = malloc(max_export_size); |
| 250 | |
| 251 | if (key_buffer) { |
| 252 | |
| 253 | size_t export_size; |
| 254 | psa_status = psa_export_key(handle, key_buffer, max_export_size, &export_size); |
| 255 | |
| 256 | if (psa_status == PSA_SUCCESS) { |
| 257 | |
| 258 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 259 | rpc_status = serializer->serialize_export_key_resp(resp_buf, key_buffer, export_size); |
| 260 | } |
| 261 | |
| 262 | free(key_buffer); |
| 263 | } |
| 264 | else { |
| 265 | /* Failed to allocate key buffer */ |
| 266 | rpc_status = TS_RPC_ERROR_RESOURCE_FAILURE; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | call_req_set_opstatus(req, psa_status); |
| 271 | psa_reset_key_attributes(&attributes); |
| 272 | } |
| 273 | |
| 274 | return rpc_status; |
| 275 | } |
| 276 | |
| 277 | static rpc_status_t export_public_key_handler(void *context, struct call_req* req) |
| 278 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 279 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 280 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 281 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 282 | |
| 283 | psa_key_handle_t handle; |
| 284 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 285 | if (serializer) |
| 286 | rpc_status = serializer->deserialize_export_public_key_req(req_buf, &handle); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 287 | |
| 288 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
| 289 | |
| 290 | psa_status_t psa_status; |
| 291 | psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; |
| 292 | |
| 293 | psa_status = psa_get_key_attributes(handle, &attributes); |
| 294 | |
| 295 | if (psa_status == PSA_SUCCESS) { |
| 296 | |
| 297 | size_t max_export_size = PSA_KEY_EXPORT_MAX_SIZE( |
| 298 | PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(psa_get_key_type(&attributes)), |
| 299 | psa_get_key_bits(&attributes)); |
| 300 | |
| 301 | uint8_t *key_buffer = malloc(max_export_size); |
| 302 | |
| 303 | if (key_buffer) { |
| 304 | |
| 305 | size_t export_size; |
| 306 | psa_status = psa_export_public_key(handle, key_buffer, max_export_size, &export_size); |
| 307 | |
| 308 | if (psa_status == PSA_SUCCESS) { |
| 309 | |
| 310 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 311 | rpc_status = serializer->serialize_export_public_key_resp(resp_buf, key_buffer, export_size); |
| 312 | } |
| 313 | |
| 314 | free(key_buffer); |
| 315 | } |
| 316 | else { |
| 317 | /* Failed to allocate key buffer */ |
| 318 | rpc_status = TS_RPC_ERROR_RESOURCE_FAILURE; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | call_req_set_opstatus(req, psa_status); |
| 323 | psa_reset_key_attributes(&attributes); |
| 324 | } |
| 325 | |
| 326 | return rpc_status; |
| 327 | } |
| 328 | |
| 329 | static rpc_status_t import_key_handler(void *context, struct call_req* req) |
| 330 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 331 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 332 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 333 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 334 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 335 | if (serializer) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 336 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 337 | size_t key_data_len = serializer->max_deserialised_parameter_size(req_buf); |
| 338 | uint8_t *key_buffer = malloc(key_data_len); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 339 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 340 | if (key_buffer) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 341 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 342 | psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; |
| 343 | rpc_status = serializer->deserialize_import_key_req(req_buf, &attributes, key_buffer, &key_data_len); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 344 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 345 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 346 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 347 | psa_status_t psa_status; |
| 348 | psa_key_handle_t handle; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 349 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 350 | psa_status = psa_import_key(&attributes, key_buffer, key_data_len, &handle); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 351 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 352 | if (psa_status == PSA_SUCCESS) { |
| 353 | |
| 354 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 355 | rpc_status = serializer->serialize_import_key_resp(resp_buf, handle); |
| 356 | } |
| 357 | |
| 358 | call_req_set_opstatus(req, psa_status); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 359 | } |
| 360 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 361 | psa_reset_key_attributes(&attributes); |
| 362 | free(key_buffer); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 363 | } |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 364 | else { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 365 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 366 | rpc_status = TS_RPC_ERROR_RESOURCE_FAILURE; |
| 367 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | return rpc_status; |
| 371 | } |
| 372 | |
| 373 | static rpc_status_t sign_hash_handler(void *context, struct call_req* req) |
| 374 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 375 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 376 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 377 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 378 | |
| 379 | psa_key_handle_t handle; |
| 380 | psa_algorithm_t alg; |
| 381 | size_t hash_len = PSA_HASH_MAX_SIZE; |
| 382 | uint8_t hash_buffer[PSA_HASH_MAX_SIZE]; |
| 383 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 384 | if (serializer) |
| 385 | rpc_status = serializer->deserialize_sign_hash_req(req_buf, &handle, &alg, hash_buffer, &hash_len); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 386 | |
| 387 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
| 388 | |
| 389 | psa_status_t psa_status; |
| 390 | size_t sig_len; |
| 391 | uint8_t sig_buffer[PSA_SIGNATURE_MAX_SIZE]; |
| 392 | |
| 393 | psa_status = psa_sign_hash(handle, alg, |
| 394 | hash_buffer, hash_len, |
| 395 | sig_buffer, sizeof(sig_buffer), &sig_len); |
| 396 | |
| 397 | if (psa_status == PSA_SUCCESS) { |
| 398 | |
| 399 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 400 | rpc_status = serializer->serialize_sign_hash_resp(resp_buf, sig_buffer, sig_len); |
| 401 | } |
| 402 | |
| 403 | call_req_set_opstatus(req, psa_status); |
| 404 | } |
| 405 | |
| 406 | return rpc_status; |
| 407 | } |
| 408 | |
| 409 | static rpc_status_t verify_hash_handler(void *context, struct call_req* req) |
| 410 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 411 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 412 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 413 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 414 | |
| 415 | psa_key_handle_t handle; |
| 416 | psa_algorithm_t alg; |
| 417 | size_t hash_len = PSA_HASH_MAX_SIZE; |
| 418 | uint8_t hash_buffer[PSA_HASH_MAX_SIZE]; |
| 419 | size_t sig_len = PSA_SIGNATURE_MAX_SIZE; |
| 420 | uint8_t sig_buffer[PSA_SIGNATURE_MAX_SIZE]; |
| 421 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 422 | if (serializer) |
| 423 | rpc_status = serializer->deserialize_verify_hash_req(req_buf, &handle, &alg, |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 424 | hash_buffer, &hash_len, |
| 425 | sig_buffer, &sig_len); |
| 426 | |
| 427 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
| 428 | |
| 429 | psa_status_t psa_status; |
| 430 | |
| 431 | psa_status = psa_verify_hash(handle, alg, |
| 432 | hash_buffer, hash_len, |
| 433 | sig_buffer, sig_len); |
| 434 | |
| 435 | call_req_set_opstatus(req, psa_status); |
| 436 | } |
| 437 | |
| 438 | return rpc_status; |
| 439 | } |
| 440 | |
| 441 | static rpc_status_t asymmetric_decrypt_handler(void *context, struct call_req* req) |
| 442 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 443 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 444 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 445 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 446 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 447 | if (serializer) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 448 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 449 | size_t max_param_size = serializer->max_deserialised_parameter_size(req_buf); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 450 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 451 | psa_key_handle_t handle; |
| 452 | psa_algorithm_t alg; |
| 453 | size_t ciphertext_len = max_param_size; |
| 454 | uint8_t *ciphertext_buffer = malloc(ciphertext_len); |
| 455 | size_t salt_len = max_param_size; |
| 456 | uint8_t *salt_buffer = malloc(salt_len); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 457 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 458 | if (ciphertext_buffer && salt_buffer) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 459 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 460 | rpc_status = serializer->deserialize_asymmetric_decrypt_req(req_buf, |
| 461 | &handle, &alg, |
| 462 | ciphertext_buffer, &ciphertext_len, |
| 463 | salt_buffer, &salt_len); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 464 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 465 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 466 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 467 | psa_status_t psa_status; |
| 468 | psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 469 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 470 | psa_status = psa_get_key_attributes(handle, &attributes); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 471 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 472 | if (psa_status == PSA_SUCCESS) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 473 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 474 | size_t max_decrypt_size = PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE( |
| 475 | psa_get_key_type(&attributes), |
| 476 | psa_get_key_bits(&attributes), |
| 477 | alg); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 478 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 479 | size_t plaintext_len; |
| 480 | uint8_t *plaintext_buffer = malloc(max_decrypt_size); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 481 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 482 | if (plaintext_buffer) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 483 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 484 | psa_status = psa_asymmetric_decrypt(handle, alg, |
| 485 | ciphertext_buffer, ciphertext_len, |
| 486 | salt_buffer, salt_len, |
| 487 | plaintext_buffer, max_decrypt_size, &plaintext_len); |
| 488 | |
| 489 | if (psa_status == PSA_SUCCESS) { |
| 490 | |
| 491 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 492 | rpc_status = serializer->serialize_asymmetric_decrypt_resp(resp_buf, |
| 493 | plaintext_buffer, plaintext_len); |
| 494 | } |
| 495 | |
| 496 | free(plaintext_buffer); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 497 | } |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 498 | else { |
| 499 | /* Failed to allocate ouptput buffer */ |
| 500 | rpc_status = TS_RPC_ERROR_RESOURCE_FAILURE; |
| 501 | } |
| 502 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 503 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 504 | call_req_set_opstatus(req, psa_status); |
| 505 | psa_reset_key_attributes(&attributes); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 506 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 507 | } |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 508 | else { |
| 509 | /* Failed to allocate buffers */ |
| 510 | rpc_status = TS_RPC_ERROR_RESOURCE_FAILURE; |
| 511 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 512 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 513 | free(ciphertext_buffer); |
| 514 | free(salt_buffer); |
| 515 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 516 | |
| 517 | return rpc_status; |
| 518 | } |
| 519 | |
| 520 | static rpc_status_t asymmetric_encrypt_handler(void *context, struct call_req* req) |
| 521 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 522 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 523 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 524 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 525 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 526 | if (serializer) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 527 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 528 | size_t max_param_size = serializer->max_deserialised_parameter_size(req_buf); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 529 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 530 | psa_key_handle_t handle; |
| 531 | psa_algorithm_t alg; |
| 532 | size_t plaintext_len = max_param_size; |
| 533 | uint8_t *plaintext_buffer = malloc(plaintext_len); |
| 534 | size_t salt_len = max_param_size; |
| 535 | uint8_t *salt_buffer = malloc(salt_len); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 536 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 537 | if (plaintext_buffer && salt_buffer) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 538 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 539 | rpc_status = serializer->deserialize_asymmetric_encrypt_req(req_buf, |
| 540 | &handle, &alg, |
| 541 | plaintext_buffer, &plaintext_len, |
| 542 | salt_buffer, &salt_len); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 543 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 544 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 545 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 546 | psa_status_t psa_status; |
| 547 | psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 548 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 549 | psa_status = psa_get_key_attributes(handle, &attributes); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 550 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 551 | if (psa_status == PSA_SUCCESS) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 552 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 553 | size_t max_encrypt_size = PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE( |
| 554 | psa_get_key_type(&attributes), |
| 555 | psa_get_key_bits(&attributes), |
| 556 | alg); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 557 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 558 | size_t ciphertext_len; |
| 559 | uint8_t *ciphertext_buffer = malloc(max_encrypt_size); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 560 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 561 | if (ciphertext_buffer) { |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 562 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 563 | psa_status = psa_asymmetric_encrypt(handle, alg, |
| 564 | plaintext_buffer, plaintext_len, |
| 565 | salt_buffer, salt_len, |
| 566 | ciphertext_buffer, max_encrypt_size, &ciphertext_len); |
| 567 | |
| 568 | if (psa_status == PSA_SUCCESS) { |
| 569 | |
| 570 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 571 | rpc_status = serializer->serialize_asymmetric_encrypt_resp(resp_buf, |
| 572 | ciphertext_buffer, ciphertext_len); |
| 573 | } |
| 574 | |
| 575 | free(ciphertext_buffer); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 576 | } |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 577 | else { |
| 578 | /* Failed to allocate ouptput buffer */ |
| 579 | rpc_status = TS_RPC_ERROR_RESOURCE_FAILURE; |
| 580 | } |
| 581 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 582 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 583 | call_req_set_opstatus(req, psa_status); |
| 584 | psa_reset_key_attributes(&attributes); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 585 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 586 | } |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 587 | else { |
| 588 | /* Failed to allocate buffers */ |
| 589 | rpc_status = TS_RPC_ERROR_RESOURCE_FAILURE; |
| 590 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 591 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 592 | free(plaintext_buffer); |
| 593 | free(salt_buffer); |
| 594 | } |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 595 | |
| 596 | return rpc_status; |
| 597 | } |
| 598 | |
| 599 | static rpc_status_t generate_random_handler(void *context, struct call_req* req) |
| 600 | { |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 601 | rpc_status_t rpc_status = TS_RPC_ERROR_SERIALIZATION_NOT_SUPPORTED; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 602 | struct call_param_buf *req_buf = call_req_get_req_buf(req); |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 603 | const struct crypto_provider_serializer *serializer = get_crypto_serializer(context, req); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 604 | |
| 605 | size_t output_size; |
| 606 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 607 | if (serializer) |
| 608 | rpc_status = serializer->deserialize_generate_random_req(req_buf, &output_size); |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 609 | |
| 610 | if (rpc_status == TS_RPC_CALL_ACCEPTED) { |
| 611 | |
| 612 | psa_status_t psa_status; |
| 613 | uint8_t *output_buffer = malloc(output_size); |
| 614 | |
| 615 | if (output_buffer) { |
| 616 | |
| 617 | psa_status = psa_generate_random(output_buffer, output_size); |
| 618 | |
| 619 | if (psa_status == PSA_SUCCESS) { |
| 620 | |
| 621 | struct call_param_buf *resp_buf = call_req_get_resp_buf(req); |
| 622 | rpc_status = serializer->serialize_generate_random_resp(resp_buf, |
| 623 | output_buffer, output_size); |
| 624 | } |
| 625 | |
| 626 | call_req_set_opstatus(req, psa_status); |
| 627 | free(output_buffer); |
| 628 | } |
| 629 | else { |
| 630 | /* Failed to allocate output buffer */ |
| 631 | rpc_status = TS_RPC_ERROR_RESOURCE_FAILURE; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | return rpc_status; |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 636 | } |