Merge tizen_5.0 codes into tizen_4.0
[platform/upstream/iotivity.git] / resource / csdk / security / include / oxmverifycommon.h
1 //******************************************************************
2 //
3 // Copyright 2016 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 _OXM_VERIFY_COMMON_
22 #define _OXM_VERIFY_COMMON_
23
24 #include "securevirtualresourcetypes.h"
25 #include "casecurityinterface.h"
26
27 #ifdef __cplusplus
28  extern "C" {
29 #endif // __cplusplus
30
31 /** Verification Number Length */
32 #define MUTUAL_VERIF_NUM_LEN (3)
33
34 /** Label Length */
35 #define LABEL_LEN (30)
36
37 /**
38  * Verification Method Option definition
39  * This type supports multiple bit set.
40  */
41  typedef enum VerifyOptionBitmask
42 {
43     NOT_APPLICABLE              = 0x0,
44     DISPLAY_NUM                 = (0x1 << 0),
45     USER_CONFIRM                = (0x1 << 1)
46 } VerifyOptionBitmask_t;
47
48 /**
49  * Function pointer to display verification PIN
50  */
51 typedef OCStackResult (*DisplayNumCallback)(void * ctx, uint8_t verifNum[MUTUAL_VERIF_NUM_LEN]);
52
53 /**
54  * Function pointer to get user confirmation
55  */
56 typedef OCStackResult (*UserConfirmCallback)(void * ctx);
57
58 /**
59  * Function pointer to notify user input state
60  */
61 typedef OCStackResult (*InputStateCallback)(void * ctx);
62
63 /**
64  * Function pointer to notify user selected OXM
65  */
66 typedef void (*InformOxmSelectedCallback_t)(OicSecOxm_t oxmSel);
67
68 /**
69  * Context for displaying verification PIN
70  */
71 typedef struct DisplayNumContext
72 {
73     DisplayNumCallback callback;
74     void * context;
75 } DisplayNumContext_t;
76
77 /**
78  * Context for getting user confirmation
79  */
80 typedef struct UserConfirmContext
81 {
82     UserConfirmCallback callback;
83     void * context;
84 } UserConfirmContext_t;
85
86 /**
87  * Context for notifying user input state
88  */
89 typedef struct InputStateContext
90 {
91     InputStateCallback callback;
92     void * context;
93 } InputStateContext_t;
94
95 /**
96  * Set Callback for displaying verification PIN
97  */
98 void SetDisplayNumCB(void * ptr, DisplayNumCallback displayNumCB);
99
100 /**
101  * Unset Callback for displaying verification PIN
102  */
103 void* UnsetDisplayNumCB();
104
105 /**
106  * Set Callback for getting user confirmation
107  */
108 void SetUserConfirmCB(void * ptr, UserConfirmCallback userConfirmCB);
109
110 /**
111  * Unset Callback for getting user confirmation
112  */
113 void* UnsetUserConfirmCB();
114
115 /**
116  * Set Callback for notifying user input state
117  */
118 void SetInputStateCB(void * ptr, UserConfirmCallback userConfirmCB);
119
120 /**
121  * Unset Callback for notifying user input state
122  */
123 void* UnsetInputStateCB();
124
125 /**
126  * Set verification method option.
127  * The default is both display PIN and get user confirmation.
128  */
129 void SetVerifyOption(VerifyOptionBitmask_t verifyOption);
130
131 /**
132  * Set notify selected OXM callback
133  */
134 void SetInformOxmSelCB(InformOxmSelectedCallback_t informOxmSelCB);
135
136 /**
137  * Set notify selected OXM callback
138  */
139 void UnsetInformOxmSelCB();
140
141 /**
142  * Call the Callback for Verifying Ownership Transfer process.
143  */
144 OCStackResult VerifyOwnershipTransfer(uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN],
145                                 VerifyOptionBitmask_t verifyOption);
146
147 /**
148  * Call the Callback for notifying user input state
149  */
150 OCStackResult NotifyInputState(void);
151
152 #ifdef __cplusplus
153 }
154 #endif
155
156 #endif
157