2 * Copyright (c) 2013 TRUSTONIC LIMITED
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <TlCm/3.0/cmpMap.h>
36 #include <TlCm/tlCmApiCommon.h>
40 #include "rootpaErrors.h"
45 static mcSpid_t spid_
;
46 static mcUuid_t tltUuid_
;
47 static CallbackFunctionP callbackP_
=NULL
;
49 void setCallbackP(CallbackFunctionP callbackP
)
54 // recovery from factory reset
55 bool factoryResetAssumed()
58 void* containerP
=NULL
;
59 mcResult_t result1
=MC_DRV_OK
;
60 mcResult_t result2
=MC_DRV_OK
;
62 if((result1
=regReadAuthToken((AUTHTOKENCONTAINERP
*)&containerP
, &contSize
))==MC_DRV_OK
)
68 if((result2
=regReadRoot((ROOTCONTAINERP
*)&containerP
, &contSize
))==MC_DRV_OK
)
74 // if neither root container, nor auth token container exists, we assume that factory reset has been performed.
75 if(MC_DRV_ERR_INVALID_DEVICE_FILE
==result1
&& MC_DRV_ERR_INVALID_DEVICE_FILE
==result2
)
77 LOGD("factoryResetAssumed returning true");
83 // recovery from factory reset
89 return (sizeof(cmp_t
)); // could also use CMP_SIZE, but this way we only allocate the amount we really need
92 cmpCommandId_t
getCmpCommandId(const uint8_t* commandP
)
94 if(NULL
==commandP
) return 0xFFFFFFFF;
95 return ((cmpCommandHeaderMap_t
*)commandP
)->commandId
;
99 uint32_t getCmpReturnCode(const uint8_t* cmpMsgP
)
101 return ((cmpResponseHeader_t
*)cmpMsgP
)->returnCode
;
104 rootpaerror_t
allocateResponseBuffer(CmpMessage
* responseP
, CMTHANDLE handle
)
106 uint32_t elementIndex
=1;
109 if(!getRspElementInfo(&elementIndex
, handle
, &offset
, &(responseP
->length
)))
111 return ROOTPA_ERROR_INTERNAL
;
113 LOGD("allocateResponseBuffer, size %d", responseP
->length
);
114 responseP
->contentP
=(uint8_t*)malloc(responseP
->length
);
115 if(responseP
->contentP
==NULL
) return ROOTPA_ERROR_OUT_OF_MEMORY
;
119 bool ensureMappedBufferSize(CMTHANDLE handle
, uint32_t neededSize
)
121 if( neededSize
> handle
->mappedSize
)
123 uint8_t* newMappedP
= (uint8_t*)realloc(handle
->mappedP
, neededSize
);
126 LOGE("ensureMappedBufferSize, unable to allocate more memory %d", neededSize
);
129 handle
->mappedP
= newMappedP
;
134 rootpaerror_t
addAuthTokenContainer(uint32_t* indexP
, uint32_t* offsetP
, CMTHANDLE handle
, mcResult_t
* mcRetP
)
136 rootpaerror_t ret
=ROOTPA_ERROR_OUT_OF_MEMORY
;
137 AUTHTOKENCONTAINERP authTokenP
= NULL
;
140 if((*mcRetP
=regReadAuthToken(&authTokenP
, &contSize
))==MC_DRV_OK
)
142 if(ensureMappedBufferSize(handle
, (*offsetP
) + contSize
))
144 memcpy(handle
->mappedP
+(*offsetP
), authTokenP
, contSize
);
145 setCmdElementInfo(indexP
, handle
->wsmP
, offsetP
, contSize
);
149 else if (MC_DRV_ERR_INVALID_DEVICE_FILE
==*mcRetP
)
151 ret
=ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE
;
155 ret
=ROOTPA_ERROR_REGISTRY
;
161 rootpaerror_t
addRootContainer(uint32_t* indexP
, uint32_t* offsetP
, CMTHANDLE handle
, mcResult_t
* mcRetP
)
163 rootpaerror_t ret
=ROOTPA_ERROR_OUT_OF_MEMORY
;
164 ROOTCONTAINERP rootP
= NULL
;
167 if((*mcRetP
=regReadRoot(&rootP
, &contSize
))==MC_DRV_OK
)
169 if(ensureMappedBufferSize(handle
, (*offsetP
) + contSize
))
171 memcpy(handle
->mappedP
+(*offsetP
), rootP
, contSize
);
172 setCmdElementInfo(indexP
, handle
->wsmP
, offsetP
, contSize
);
176 else if (MC_DRV_ERR_INVALID_DEVICE_FILE
==*mcRetP
)
178 ret
=ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE
;
182 ret
=ROOTPA_ERROR_REGISTRY
;
188 rootpaerror_t
addSpContainer(uint32_t* indexP
, uint32_t* offsetP
, mcSpid_t spid
, CMTHANDLE handle
, mcResult_t
* mcRetP
)
190 rootpaerror_t ret
=ROOTPA_ERROR_OUT_OF_MEMORY
;
191 SPCONTAINERP spP
= NULL
;
194 if((*mcRetP
=regReadSp(spid
, &spP
, &contSize
))==MC_DRV_OK
)
196 if(ensureMappedBufferSize(handle
, (*offsetP
) + contSize
))
198 memcpy(handle
->mappedP
+(*offsetP
),spP
,contSize
);
199 setCmdElementInfo(indexP
, handle
->wsmP
, offsetP
, contSize
);
203 else if (MC_DRV_ERR_INVALID_DEVICE_FILE
==*mcRetP
)
205 ret
=ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE
;
209 ret
=ROOTPA_ERROR_REGISTRY
;
216 rootpaerror_t
addTltContainer(uint32_t* indexP
, uint32_t* offsetP
, const mcUuid_t
* uuidP
, mcSpid_t spid
, CMTHANDLE handle
, mcResult_t
* mcRetP
)
218 rootpaerror_t ret
=ROOTPA_ERROR_OUT_OF_MEMORY
;
219 TLTCONTAINERP tltP
= NULL
;
222 if((*mcRetP
=regReadTlt(uuidP
, &tltP
, &contSize
, spid
))==MC_DRV_OK
)
224 if(ensureMappedBufferSize(handle
, (*offsetP
) + contSize
))
226 memcpy(handle
->mappedP
+(*offsetP
),tltP
,contSize
);
227 setCmdElementInfo(indexP
, handle
->wsmP
, offsetP
, contSize
);
231 else if (MC_DRV_ERR_INVALID_DEVICE_FILE
==*mcRetP
)
233 ret
=ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE
;
237 ret
=ROOTPA_ERROR_REGISTRY
;
245 rootpaerror_t
prepareCommand(cmpCommandId_t commandId
, CmpMessage
* inCommandP
, CMTHANDLE handle
, CmpMessage
* responseP
)
247 uint8_t* outCommandP
=handle
->mappedP
;
250 uint32_t elementIndex
=1;
251 rootpaerror_t ret
=ROOTPA_OK
;
252 mcResult_t mcRet
=MC_DRV_OK
;
253 LOGI("prepareCommand command id %d length %d", commandId
, inCommandP
->length
); // this is LOGI level on purpose to indicate that CMP command has reached RootPA
255 memset(handle
->wsmP
,0,sizeOfCmp());
257 setCmdMapInfo(handle
->wsmP
, &handle
->mapInfo
);
258 setCmdCmpVersionAndCmdId(handle
->wsmP
, commandId
);
259 setCmdElementInfo(&elementIndex
, handle
->wsmP
, &offset
, inCommandP
->length
);
260 if(ensureMappedBufferSize(handle
, inCommandP
->length
))
262 memcpy(handle
->mappedP
, inCommandP
->contentP
, inCommandP
->length
);
266 responseP
->hdr
.ret
=ROOTPA_ERROR_OUT_OF_MEMORY
;
267 return ROOTPA_ERROR_OUT_OF_MEMORY
;
271 case MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION
:
272 if (callbackP_
) callbackP_(AUTHENTICATING_SOC
, ROOTPA_OK
, NULL
);
273 ret
=addAuthTokenContainer(&elementIndex
, &offset
, handle
, &mcRet
);
276 case MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION
:
277 if (callbackP_
) callbackP_(AUTHENTICATING_ROOT
, ROOTPA_OK
, NULL
);
278 ret
=addRootContainer(&elementIndex
, &offset
, handle
, &mcRet
);
281 case MC_CMP_CMD_BEGIN_SP_AUTHENTICATION
:
282 ret
=addRootContainer(&elementIndex
, &offset
, handle
, &mcRet
);
285 mcSpid_t spid
=((cmpCmdBeginSpAuthentication_t
*)outCommandP
)->cmd
.spid
;
286 ret
=addSpContainer(&elementIndex
, &offset
, spid
, handle
, &mcRet
);
289 case MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE
:
290 if (callbackP_
) callbackP_(CREATING_ROOT_CONTAINER
, ROOTPA_OK
, NULL
);
293 case MC_CMP_CMD_ROOT_CONT_UNREGISTER
:
294 if (callbackP_
) callbackP_(UNREGISTERING_ROOT_CONTAINER
, ROOTPA_OK
, NULL
);
297 case MC_CMP_CMD_SP_CONT_ACTIVATE
:
298 spid_
=((cmpCmdSpContActivate_t
*)outCommandP
)->cmd
.sdata
.spid
;
300 case MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT
:
301 spid_
=((cmpCmdSpContLockByRoot_t
*)outCommandP
)->cmd
.sdata
.spid
;
302 ret
=addSpContainer(&elementIndex
, &offset
, spid_
, handle
, &mcRet
);
304 case MC_CMP_CMD_SP_CONT_LOCK_BY_SP
:
305 spid_
=((cmpCmdSpContLockBySp_t
*)outCommandP
)->cmd
.sdata
.spid
;
307 case MC_CMP_CMD_SP_CONT_REGISTER
:
308 if (callbackP_
) callbackP_(CREATING_SP_CONTAINER
, ROOTPA_OK
, NULL
);
309 spid_
=((cmpCmdSpContRegister_t
*)outCommandP
)->cmd
.sdata
.spid
;
311 case MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE
:
312 if (callbackP_
) callbackP_(CREATING_SP_CONTAINER
, ROOTPA_OK
, NULL
);
313 spid_
=((cmpCmdSpContRegister_t
*)outCommandP
)->cmd
.sdata
.spid
;
315 case MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT
:
316 spid_
=((cmpCmdSpContUnlockByRoot_t
*)outCommandP
)->cmd
.sdata
.spid
;
317 ret
=addSpContainer(&elementIndex
, &offset
, spid_
, handle
, &mcRet
);
319 case MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP
:
320 spid_
=((cmpCmdSpContUnlockBySp_t
*)outCommandP
)->cmd
.sdata
.spid
;
322 case MC_CMP_CMD_SP_CONT_UNREGISTER
:
323 spid_
=((cmpCmdSpContUnregister_t
*)outCommandP
)->cmd
.sdata
.spid
;
325 case MC_CMP_CMD_TLT_CONT_ACTIVATE
:
326 spid_
=((cmpCmdTltContActivate_t
*)outCommandP
)->cmd
.sdata
.spid
;
327 memcpy(&tltUuid_
,&((cmpCmdTltContActivate_t
*)outCommandP
)->cmd
.sdata
.uuid
, sizeof(mcUuid_t
));
328 ret
=addTltContainer(&elementIndex
, &offset
, &tltUuid_
, spid_
, handle
, &mcRet
);
330 case MC_CMP_CMD_TLT_CONT_LOCK_BY_SP
:
331 spid_
=((cmpCmdTltContLockBySp_t
*)outCommandP
)->cmd
.sdata
.spid
;
332 memcpy(&tltUuid_
,&((cmpCmdTltContLockBySp_t
*)outCommandP
)->cmd
.sdata
.uuid
, sizeof(mcUuid_t
));
333 ret
=addTltContainer(&elementIndex
, &offset
, &tltUuid_
, spid_
, handle
, &mcRet
);
335 case MC_CMP_CMD_TLT_CONT_PERSONALIZE
:
336 ret
=addTltContainer(&elementIndex
, &offset
, &((cmpCmdTltContPersonalize_t
*)outCommandP
)->cmd
.sdata
.uuid
,
337 ((cmpCmdTltContPersonalize_t
*)outCommandP
)->cmd
.sdata
.spid
,
340 case MC_CMP_CMD_TLT_CONT_REGISTER
:
341 spid_
=((cmpCmdTltContRegister_t
*)outCommandP
)->cmd
.sdata
.spid
;
342 memcpy(&tltUuid_
,&((cmpCmdTltContRegister_t
*)outCommandP
)->cmd
.sdata
.uuid
, sizeof(mcUuid_t
));
344 case MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE
:
345 spid_
=((cmpCmdTltContRegisterActivate_t
*)outCommandP
)->cmd
.sdata
.spid
;
346 memcpy(&tltUuid_
,&((cmpCmdTltContRegisterActivate_t
*)outCommandP
)->cmd
.sdata
.uuid
, sizeof(mcUuid_t
));
348 case MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP
:
349 spid_
=((cmpCmdTltContUnlockBySp_t
*)outCommandP
)->cmd
.sdata
.spid
;
350 memcpy(&tltUuid_
,&((cmpCmdTltContUnlockBySp_t
*)outCommandP
)->cmd
.sdata
.uuid
, sizeof(mcUuid_t
));
351 ret
=addTltContainer(&elementIndex
, &offset
, &tltUuid_
, spid_
, handle
, &mcRet
);
353 case MC_CMP_CMD_TLT_CONT_UNREGISTER
:
354 spid_
=((cmpCmdTltContUnlockBySp_t
*)outCommandP
)->cmd
.sdata
.spid
;
355 memcpy(&tltUuid_
,&((cmpCmdTltContUnlockBySp_t
*)outCommandP
)->cmd
.sdata
.uuid
, sizeof(mcUuid_t
));
358 // nothing extra to do, just return ret at the end of function
362 responseP
->hdr
.ret
=ret
;
363 responseP
->hdr
.intRet
=mcRet
;
368 mcResult_t
storeContainers(cmpCommandId_t commandId
, CMTHANDLE handle
, uint32_t elementIndex
, uint32_t offset
)
370 mcResult_t mcRet
=MC_DRV_OK
;
372 LOGD(">>pacmp3 storeContainers for %d element %d offset %d", commandId
, elementIndex
, offset
);
374 // store the containers when needed
377 case MC_CMP_CMD_GENERATE_AUTH_TOKEN
:
378 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
380 mcRet
=regWriteAuthToken((AUTHTOKENCONTAINERP
) (handle
->mappedP
+offset
), length
);
388 case MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE
:
389 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
391 mcRet
=regWriteRoot((ROOTCONTAINERP
) (handle
->mappedP
+offset
), length
);
400 mcSoAuthTokenCont_t
* authTokenP
=NULL
;
401 uint32_t authTokenSize
=0;
403 mcRet
=regReadAuthToken(&authTokenP
, &authTokenSize
);
406 LOGE("pacmp3 storeContainers for %d regReadAuthToken failed %d, since this was only precaution, continuing", commandId
, mcRet
);
408 mcRet
=regDeleteAuthToken();
411 LOGE("pacmp3 storeContainers for %d regDeleteAuthToken failed %d, trying to recover", commandId
, mcRet
);
412 // try to recover, remove root, but only if there is auth token stored
415 mcRet
=regWriteAuthToken((AUTHTOKENCONTAINERP
) authTokenP
, authTokenSize
); // trying to be failsafe here. Deleting failed but rewriting the token anyway
418 regCleanupRoot(); // since we were able to restore authToken we delete root (due to an error in registry handling)
426 LOGE("pacmp3 storeContainers for %d regWriteRoot failed %d", commandId
, mcRet
);
431 case MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT
:
432 case MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT
:
433 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
435 mcRet
=regWriteRoot((ROOTCONTAINERP
) (handle
->mappedP
+offset
), length
);
444 case MC_CMP_CMD_ROOT_CONT_UNREGISTER
:
445 mcRet
=regCleanupRoot();
448 case MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT
:
449 case MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP
:
450 case MC_CMP_CMD_SP_CONT_ACTIVATE
:
451 case MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT
:
452 case MC_CMP_CMD_SP_CONT_LOCK_BY_SP
:
453 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
455 mcRet
=regWriteSp(spid_
, (SPCONTAINERP
) (handle
->mappedP
+offset
), length
);
464 case MC_CMP_CMD_SP_CONT_REGISTER
:
465 case MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE
:
467 // Root container is in the buffer first, that is why we read it first
468 // we write it last since if SP container writing fails we do not want
469 // to write root container
470 uint32_t rootLength
=0;
471 ROOTCONTAINERP rootP
=NULL
;
472 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &rootLength
))
474 rootP
=(ROOTCONTAINERP
) (handle
->mappedP
+offset
);
475 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
477 mcRet
=regWriteSp(spid_
, (SPCONTAINERP
) (handle
->mappedP
+offset
), length
);
491 mcRet
=regWriteRoot(rootP
, rootLength
);
495 LOGE("pacmp3 storeContainers for %d regWriteSp failed %d", commandId
, mcRet
);
500 case MC_CMP_CMD_SP_CONT_UNREGISTER
:
501 mcRet
=regCleanupSp(spid_
);
504 LOGE("pacmp3 storeContainers for %d regCleanupSp failed %d, , still attempting storing root", commandId
, mcRet
);
507 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
509 mcRet
=regWriteRoot((ROOTCONTAINERP
) (handle
->mappedP
+offset
), length
);
519 case MC_CMP_CMD_TLT_CONT_REGISTER
:
520 case MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE
:
522 // SP container is in the buffer first, that is why we read it first
523 // we write it last since if TLT container writing fails we do not want
524 // to write SP container
526 SPCONTAINERP spP
=NULL
;
527 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &spLength
))
529 spP
=(SPCONTAINERP
) (handle
->mappedP
+offset
);
530 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
532 mcRet
=regWriteTlt(&tltUuid_
,(TLTCONTAINERP
) (handle
->mappedP
+offset
), length
, spid_
);
546 mcRet
=regWriteSp(spid_
, spP
, spLength
);
549 LOGE("pacmp3 storeContainers for %d regWriteSp failed %d", commandId
, mcRet
);
550 regCleanupTlt(&tltUuid_
, spid_
);
555 LOGE("pacmp3 storeContainers for %d regWriteTlt failed %d", commandId
, mcRet
);
560 case MC_CMP_CMD_TLT_CONT_ACTIVATE
:
561 case MC_CMP_CMD_TLT_CONT_LOCK_BY_SP
:
562 case MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP
:
563 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
565 mcRet
=regWriteTlt(&tltUuid_
,(TLTCONTAINERP
) (handle
->mappedP
+offset
), length
, spid_
);
574 case MC_CMP_CMD_TLT_CONT_UNREGISTER
:
575 mcRet
=regCleanupTlt(&tltUuid_
, spid_
);
578 LOGE("pacmp3 storeContainers for %d regCleanupTlt failed %d, still attempting storing sp", commandId
, mcRet
);
581 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
583 mcRet
=regWriteSp(spid_
, (SPCONTAINERP
) (handle
->mappedP
+offset
), length
);
586 LOGE("pacmp3 storeContainers for %d regWriteSp failed %d", commandId
, mcRet
);
597 LOGD("pacmp3 storeContainers nothing to store");
601 LOGD("<<pacmp3 storeContainers %d %d", commandId
, mcRet
);
605 handleResponse stores the container received in response and copies the response to the buffer to be returned
606 to the client Note that the container is not store id cmtl returned an error, but the content of the response is
607 returned to the client.
609 rootpaerror_t
handleResponse(cmpCommandId_t commandId
, CmpMessage
* outResponseP
, CMTHANDLE handle
)
611 mcResult_t mcRet
=MC_DRV_OK
;
612 rootpaerror_t ret
=ROOTPA_OK
;
613 uint32_t elementIndex
=1;
617 LOGD(">>handleResponse for command %d ", commandId
);
619 if(isValidResponseTo(commandId
, handle
->wsmP
)==false)
621 LOGE("no valid response to %d", commandId
);
622 outResponseP
->hdr
.ret
=ROOTPA_ERROR_COMMAND_EXECUTION
;
623 return ROOTPA_ERROR_COMMAND_EXECUTION
;
626 ret
=allocateResponseBuffer(outResponseP
, handle
);
630 if(getRspElementInfo(&elementIndex
, handle
, &offset
, &length
))
632 memcpy(outResponseP
->contentP
, handle
->mappedP
+offset
, length
);
636 return ROOTPA_ERROR_INTERNAL
;
639 if (getCmpReturnCode(handle
->mappedP
)!=SUCCESSFUL
) // this checking is here since we want the response to be returned even in case of CMP error
641 LOGE("executeOneCmpCommand: command execution failed 0x%x", getCmpReturnCode(handle
->mappedP
));
642 outResponseP
->hdr
.intRet
=getCmpReturnCode(handle
->mappedP
);
643 return ROOTPA_ERROR_COMMAND_EXECUTION
;
648 outResponseP
->hdr
.ret
=ret
;
649 LOGE("executeOneCmpCommand: response buffer allocation failed %d (0x%x)", ret
, handle
->lasterror
);
653 mcRet
=storeContainers(commandId
, handle
, elementIndex
, offset
);
655 if(mcRet
!= MC_DRV_OK
)
657 LOGE("pacmp3 handleResponse for %d registry failed %d", commandId
, mcRet
);
658 if((mcResult_t
)-1==mcRet
)
660 ret
= ROOTPA_ERROR_INTERNAL
;
664 ret
= ROOTPA_ERROR_REGISTRY
;
666 if(0==outResponseP
->hdr
.intRet
)
668 outResponseP
->hdr
.intRet
=mcRet
;
670 outResponseP
->hdr
.ret
=ret
;
672 LOGD("<<handleResponse returning %d ", ret
);