X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fsecurity%2Fsrc%2Foxmpincommon.c;h=ad70a434fe5c8a7b301cb5496f967c326ca4bbb6;hb=7f00f942c39b7bc27c7eeecf213a239c3fe4173c;hp=7fff31dbc5cc3f3ac4180d8fcfbe11a6b2e222e1;hpb=edcfc3d2329da7b914771c0dcff5f42c9b74fd93;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/security/src/oxmpincommon.c b/resource/csdk/security/src/oxmpincommon.c index 7fff31d..ad70a43 100644 --- a/resource/csdk/security/src/oxmpincommon.c +++ b/resource/csdk/security/src/oxmpincommon.c @@ -18,7 +18,9 @@ // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +#ifndef __TIZENRT__ #include +#endif #include "ocstack.h" #include "ocrandom.h" @@ -40,6 +42,7 @@ static GeneratePinCallback gGenPinCallback = NULL; static InputPinCallback gInputPinCallback = NULL; +static ClosePinDisplayCallback gClosePinDispalyCallback = NULL; typedef struct PinOxmData { uint8_t pinData[OXM_RANDOM_PIN_MAX_SIZE + 1]; @@ -110,6 +113,18 @@ void SetGeneratePinCB(GeneratePinCallback pinCB) gGenPinCallback = pinCB; } +void SetClosePinDisplayCB(ClosePinDisplayCallback closeCB) +{ + if (NULL == closeCB) + { + OIC_LOG(ERROR, TAG, "Failed to set a callback for closing a pin."); + return; + } + + gClosePinDispalyCallback = closeCB; +} + + void UnsetInputPinCB() { gInputPinCallback = NULL; @@ -120,6 +135,19 @@ void UnsetGeneratePinCB() gGenPinCallback = NULL; } +void UnsetClosePinDisplayCB() +{ + gClosePinDispalyCallback = NULL; +} + +void ClosePinDisplay() +{ + if (gClosePinDispalyCallback) + { + gClosePinDispalyCallback(); + } +} + /** * Internal function to generate PIN element according to pinType. * This function assumes the pinType is valid. @@ -157,6 +185,10 @@ static char GenerateRandomPinElement(OicSecPinType_t pinType) { return defaultRetValue; } + else + { + curIndex -= 1; + } return allowedCharacters[OCGetRandomRange(0, curIndex)]; } @@ -241,8 +273,8 @@ OCStackResult InputPin(char* pinBuffer, size_t bufferSize) if(gInputPinCallback) { gInputPinCallback(pinBuffer, bufferSize); - OICStrcpy(g_PinOxmData.pinData, OXM_RANDOM_PIN_MAX_SIZE + 1, pinBuffer); - g_PinOxmData.pinSize = strlen(g_PinOxmData.pinData); + OICStrcpy((char*)(g_PinOxmData.pinData), OXM_RANDOM_PIN_MAX_SIZE + 1, pinBuffer); + g_PinOxmData.pinSize = strlen((char*)(g_PinOxmData.pinData)); } else { @@ -254,7 +286,7 @@ OCStackResult InputPin(char* pinBuffer, size_t bufferSize) return OC_STACK_OK; } -#ifdef _ENABLE_MULTIPLE_OWNER_ +#ifdef MULTIPLE_OWNER OCStackResult SetPreconfigPin(const char *pinBuffer, size_t pinLength) { if(NULL == pinBuffer || OXM_PRECONFIG_PIN_MAX_SIZE < pinLength) @@ -267,7 +299,7 @@ OCStackResult SetPreconfigPin(const char *pinBuffer, size_t pinLength) return OC_STACK_OK; } -#endif //_ENABLE_MULTIPLE_OWNER_ +#endif //MULTIPLE_OWNER #ifdef __WITH_DTLS__ @@ -354,7 +386,7 @@ int32_t GetDtlsPskForRandomPinOxm( CADtlsPskCredType_t type, return ret; } -#ifdef _ENABLE_MULTIPLE_OWNER_ +#ifdef MULTIPLE_OWNER int32_t GetDtlsPskForMotRandomPinOxm( CADtlsPskCredType_t type, const unsigned char *UNUSED1, size_t UNUSED2, unsigned char *result, size_t result_length) @@ -617,6 +649,6 @@ int32_t GetDtlsPskForMotPreconfPinOxm( CADtlsPskCredType_t type, return ret; } -#endif //_ENABLE_MULTIPLE_OWNER_ +#endif //MULTIPLE_OWNER #endif //__WITH_DTLS__