aboutsummaryrefslogtreecommitdiff
path: root/components/service/locator/standalone/services/crypto/crypto_service_context.cpp
blob: e76122480a09fae85a54e76f533095ffcc5ea18c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "crypto_service_context.h"
#include <service/crypto/provider/serializer/protobuf/pb_crypto_provider_serializer.h>
#include <service/crypto/provider/serializer/packed-c/packedc_crypto_provider_serializer.h>

crypto_service_context::crypto_service_context(const char *sn) :
    standalone_service_context(sn),
    m_crypto_provider(),
    m_storage_provider(),
    m_storage_caller()
{

}

crypto_service_context::~crypto_service_context()
{

}

void crypto_service_context::do_init()
{
    struct rpc_interface *storage_ep = sfs_provider_init(&m_storage_provider);
    struct rpc_caller *storage_caller = direct_caller_init_default(&m_storage_caller,
                                                                    storage_ep);
    struct rpc_interface *crypto_ep = mbed_crypto_provider_init(&m_crypto_provider,
                                                                    storage_caller, NULL);

    mbed_crypto_provider_register_serializer(&m_crypto_provider,
                    TS_RPC_ENCODING_PROTOBUF, pb_crypto_provider_serializer_instance());

    mbed_crypto_provider_register_serializer(&m_crypto_provider,
                    TS_RPC_ENCODING_PACKED_C, packedc_crypto_provider_serializer_instance());

    standalone_service_context::set_rpc_interface(crypto_ep);
}

void crypto_service_context::do_deinit()
{
    mbed_crypto_provider_deinit(&m_crypto_provider);
    direct_caller_deinit(&m_storage_caller);
}