1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef PIN_CALLBACK_DEF_H_
22 #define PIN_CALLBACK_DEF_H_
24 #include "securevirtualresourcetypes.h"
25 #include "casecurityinterface.h"
31 #define OXM_RANDOM_PIN_SIZE 8
34 * Function pointer to print pin code.
36 typedef void (*GeneratePinCallback)(char* pinData, size_t pinSize);
39 * Function pointer to input pin code.
41 typedef void (*InputPinCallback)(char* pinBuf, size_t bufSize);
44 * Function to setting generate PIN callback from user.
46 * @param pinCB implementation of generate PIN callback.
48 void SetGeneratePinCB(GeneratePinCallback pinCB);
51 * Function to setting input PIN callback from user.
53 * @param pinCB implementation of input PIN callback.
55 void SetInputPinCB(InputPinCallback pinCB);
58 * Function to generate random PIN.
59 * This function will send generated PIN to user via callback.
61 * @param pinBuffer is the reference to the buffer to store the generated PIN data.
62 * @param bufferSize is the size of buffer.
64 * @return ::OC_STACK_SUCCESS in case of success or other value in case of error.
66 OCStackResult GeneratePin(char* pinBuffer, size_t bufferSize);
69 * Function to input PIN callback via input callback.
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.
74 * @return ::OC_STACK_SUCCESS in case of success or other value in ccase of error.
76 OCStackResult InputPin(char* pinBuffer, size_t bufferSize);
81 * This function is used by OTM and SRM to
82 * register device UUID is required to derive the temporal PSK.
84 void SetUuidForRandomPinOxm(const OicUuid_t* uuid);
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.
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.
97 * @return The number of bytes written to @p result or a value
98 * less than zero on error.
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__
109 #endif //PIN_CALLBACK_DEF_H_