Change name of encoding type
[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 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 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 pinBuffer is the reference to the buffer to store the generated PIN data.
62  * @param bufferSize is the size of buffer.
63  *
64  * @return ::OC_STACK_SUCCESS in case of success or other value in case of error.
65  */
66 OCStackResult GeneratePin(char* pinBuffer, size_t bufferSize);
67
68 /**
69  * Function to input PIN callback via input callback.
70  *
71  * @param[in,out] pinBuffer is the reference to the buffer to store the inputed PIN data.
72  * @param[in] bufferSize is the size of buffer.
73  *
74  * @return ::OC_STACK_SUCCESS in case of success or other value in ccase of error.
75  */
76 OCStackResult InputPin(char* pinBuffer, size_t bufferSize);
77
78 #ifdef __WITH_DTLS__
79
80 /**
81  * This function is used by OTM and SRM to
82  * register device UUID is required to derive the temporal PSK.
83  */
84 void SetUuidForRandomPinOxm(const OicUuid_t* uuid);
85
86 /**
87  * This internal callback is used while PIN based ownership transfer.
88  * This callback will be used to establish a temporary secure session according to
89  * TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256.
90  *
91  * @param[in]  type type of PSK data required by tinyDTLS layer during DTLS handshake.
92  * @param[in]  desc UNUSED.
93  * @param[in]  desc_len UNUSED.
94  * @param[out] result  Must be filled with the requested information.
95  * @param[in]  result_length  Maximum size of @p result.
96  *
97  * @return The number of bytes written to @p result or a value
98  *         less than zero on error.
99  */
100 int32_t GetDtlsPskForRandomPinOxm( CADtlsPskCredType_t type,
101               const unsigned char *UNUSED1, size_t UNUSED2,
102               unsigned char *result, size_t result_length);
103 #endif //__WITH_DTLS__
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif //PIN_CALLBACK_DEF_H_