aboutsummaryrefslogtreecommitdiff
path: root/components/service/locator/standalone/services/crypto/crypto_service_context.cpp
blob: 054581797c4729c5196a1efd8e815e2e1a6cfc5e (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
/*
 * 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>

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);

    mbed_crypto_provider_register_serializer(&m_crypto_provider,
                    TS_RPC_ENCODING_PROTOBUF, pb_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);
}