Revert back cbor related patches.
[platform/upstream/iotivity.git] / resource / csdk / security / include / pinoxmcommon.h
1 /* *****************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * *****************************************************************/
20
21 #ifndef PIN_CALLBACK_DEF_H_
22 #define PIN_CALLBACK_DEF_H_
23
24 #include "securevirtualresourcetypes.h"
25 #include "casecurityinterface.h"
26
27 #ifdef __cplusplus
28  extern "C" {
29 #endif // __cplusplus
30
31 #define OXM_RANDOM_PIN_SIZE 8
32
33 /**
34  * Function pointer to print pin code
35  */
36 typedef void (*GeneratePinCallback)(char* pinData, size_t pinSize);
37
38 /**
39  * Function pointer to input pin code
40  */
41 typedef void (*InputPinCallback)(char* pinBuf, size_t bufSize);
42
43 /**
44  * Function to setting generate PIN callback from user
45  *
46  * @param[in] pinCB implementation of generate PIN callback
47  */
48 void SetGeneratePinCB(GeneratePinCallback pinCB);
49
50 /**
51  * Function to setting input PIN callback from user
52  *
53  * @param[in] pinCB implementation of input PIN callback
54  */
55 void SetInputPinCB(InputPinCallback pinCB);
56
57 /**
58  * Function to generate random PIN.
59  * This function will send generated PIN to user via callback.
60  *
61  * @param[in,out] pinBuffer   Buffer to store the generated PIN data.
62  * @param[in] bufferSize   Size of buffer
63  * @return OC_STACK_SUCCESS in case of success and other value otherwise.
64  */
65 OCStackResult GeneratePin(char* pinBuffer, size_t bufferSize);
66
67 /**
68  * Function to input PIN callback via input callback
69  *
70  * @param[in,out] pinBuffer Buffer to store the inputed PIN data.
71  * @param[in] bufferSize Size of buffer
72  * @return OC_STACK_SUCCESS in case of success and other value otherwise.
73  */
74 OCStackResult InputPin(char* pinBuffer, size_t bufferSize);
75
76 #ifdef __WITH_DTLS__
77
78 /**
79  * This function is used by OTM and SRM to
80  * register device UUID is required to derive the temporal PSK.
81  */
82 void SetUuidForRandomPinOxm(const OicUuid_t* uuid);
83
84 /**
85  * This internal callback is used while PIN based ownership transfer.
86  * This callback will be used to establish a temporary secure session according to
87  * TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256.
88  *
89  * @param[in]  type type of PSK data required by tinyDTLS layer during DTLS handshake.
90  * @param[in]  desc UNUSED.
91  * @param[in]  desc_len UNUSED.
92  * @param[out] result  Must be filled with the requested information.
93  * @param[in]  result_length  Maximum size of @p result.
94  *
95  * @return The number of bytes written to @p result or a value
96  *         less than zero on error.
97  */
98 int32_t GetDtlsPskForRandomPinOxm( CADtlsPskCredType_t type,
99               const unsigned char *UNUSED1, size_t UNUSED2,
100               unsigned char *result, size_t result_length);
101 #endif //__WITH_DTLS__
102
103 #ifdef __cplusplus
104 }
105 #endif
106
107 #endif //PIN_CALLBACK_DEF_H_