1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <interface/keybox/keybox.h>
20 #include <lk/compiler.h>
21 #include <stddef.h>
22 #include <stdint.h>
23 #include <trusty_ipc.h>
24 
25 __BEGIN_CDECLS
26 
27 /**
28  * keybox_unwrap() - Unwraps a keybox.
29  *
30  * @wrapped_keybox:            Pointer to a wrapped keybox.
31  * @wrapped_keybox_size:       Size of the wrapped keybox.
32  * @unwrapped_keybox:          Buffer to unwrap into.
33  * @unwrapped_keybox_buf_size: Size of the buffer to unwrap into.
34  * @unwrapped_keybox_size:     Out parameter for amount of the buffer used.
35  *
36  * Unwraps a keybox using device secrets via device-specific means.
37  *
38  * Returns: 0 on success, negative error code is from uapi/err.h, positive
39  *          error code is from the &enum keybox_status in the keybox
40  *          interface.
41  */
42 int keybox_unwrap(const uint8_t* wrapped_keybox,
43                   size_t wrapped_keybox_size,
44                   uint8_t* unwrapped_keybox,
45                   size_t unwrapped_keybox_buf_size,
46                   size_t* unwrapped_keybox_size);
47 
48 __END_CDECLS
49