1 /* *****************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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[in] pinCB implementation of generate PIN callback
48 void SetGeneratePinCB(GeneratePinCallback pinCB);
51 * Function to setting input PIN callback from user
53 * @param[in] 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[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.
65 OCStackResult GeneratePin(char* pinBuffer, size_t bufferSize);
68 * Function to input PIN callback via input callback
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.
74 OCStackResult InputPin(char* pinBuffer, size_t bufferSize);
79 * This function is used by OTM and SRM to
80 * register device UUID is required to derive the temporal PSK.
82 void SetUuidForRandomPinOxm(const OicUuid_t* uuid);
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.
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.
95 * @return The number of bytes written to @p result or a value
96 * less than zero on error.
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__
107 #endif //PIN_CALLBACK_DEF_H_