14f8a354fSEtienne Carriere /* SPDX-License-Identifier: BSD-2-Clause */ 24f8a354fSEtienne Carriere /* 34f8a354fSEtienne Carriere * Copyright (c) 2017-2020, Linaro Limited 44f8a354fSEtienne Carriere */ 54f8a354fSEtienne Carriere 64f8a354fSEtienne Carriere #ifndef PKCS11_TA_SERIALIZER_H 74f8a354fSEtienne Carriere #define PKCS11_TA_SERIALIZER_H 84f8a354fSEtienne Carriere 94f8a354fSEtienne Carriere #include <stdbool.h> 10ee49d9f2SEtienne Carriere #include <stdint.h> 114f8a354fSEtienne Carriere 12*3158faf6SEtienne Carriere struct pkcs11_client; 13*3158faf6SEtienne Carriere struct pkcs11_session; 14*3158faf6SEtienne Carriere 154f8a354fSEtienne Carriere /* 164f8a354fSEtienne Carriere * Util routines for serializes unformated arguments in a client memref 174f8a354fSEtienne Carriere */ 184f8a354fSEtienne Carriere struct serialargs { 194f8a354fSEtienne Carriere char *start; 204f8a354fSEtienne Carriere char *next; 214f8a354fSEtienne Carriere size_t size; 224f8a354fSEtienne Carriere }; 234f8a354fSEtienne Carriere 244f8a354fSEtienne Carriere void serialargs_init(struct serialargs *args, void *in, size_t size); 254f8a354fSEtienne Carriere 264f8a354fSEtienne Carriere uint32_t serialargs_get(struct serialargs *args, void *out, size_t sz); 274f8a354fSEtienne Carriere 284f8a354fSEtienne Carriere uint32_t serialargs_get_ptr(struct serialargs *args, void **out, size_t size); 294f8a354fSEtienne Carriere 304f8a354fSEtienne Carriere uint32_t serialargs_alloc_and_get(struct serialargs *args, 314f8a354fSEtienne Carriere void **out, size_t size); 324f8a354fSEtienne Carriere 334f8a354fSEtienne Carriere bool serialargs_remaining_bytes(struct serialargs *args); 344f8a354fSEtienne Carriere 35*3158faf6SEtienne Carriere enum pkcs11_rc serialargs_get_session_from_handle(struct serialargs *args, 36*3158faf6SEtienne Carriere struct pkcs11_client *client, 37*3158faf6SEtienne Carriere struct pkcs11_session **sess); 384f8a354fSEtienne Carriere #endif /*PKCS11_TA_SERIALIZER_H*/ 39