static int et199_encrypt_excute_flie(void *encrypt, char *file_name, char *inbuf, char *outbuf, char *passwd) { ENCRYPT *encrypt_ins = (ENCRYPT *)encrypt; struct ET_CONTEXT*pContext = (struct ET_CONTEXT*)encrypt_ins->private_data; int dwRet = 0; long unsigned int len = 0; dwRet = ETVerifyPin(&pContext[0], (unsigned char *)passwd, strlen(passwd), ET_USER_PIN); if(dwRet) { if(dwRet == ET_E_KEY_REMOVED || dwRet == ET_E_NO_LIST) { return DEV_REMOVED; } PostError("et199_encrypt_excute_flie ETVerifyPin", dwRet); return VERIFYPASSWD_ERR; } dwRet = ETExecute(&pContext[0], file_name, (unsigned char *)inbuf, strlen(inbuf), (unsigned char *)outbuf, BUF_LEN, &len); if(dwRet) { if(dwRet == ET_E_KEY_REMOVED || dwRet == ET_E_NO_LIST) { return DEV_REMOVED; } PostError("et199_encrypt_excute_flie ETExecute",dwRet); return EXCUTEFILE_ERR; } return len; }
static PyObject * ETContext_execute(ETContextObject* self, PyObject *args) { BYTE lpszFileID[5]={0},*pInBuffer=NULL,bFileType,OutBuffer[256]; DWORD dwRet,dwInbufferSize,dwBytesReturned; WORD fileId; PyObject *pyRet = NULL; if(!PyArg_ParseTuple(args, "Hz#", &fileId,&pInBuffer,&dwInbufferSize)) { return NULL; } if(fileId==0){ INVALID_PARAMS("Invalid File Id!",NULL); } sprintf(lpszFileID,"%04x",fileId); dwRet = ETExecute(&self->context,lpszFileID,pInBuffer,dwInbufferSize,OutBuffer,256,&dwBytesReturned); DWRET_VALIDATE(dwRet,NULL); pyRet = Py_BuildValue("z#",OutBuffer,dwBytesReturned); Py_XINCREF(pyRet); return pyRet; }