예제 #1
0
static int et199_encrypt_write_data(void *encrypt, char *src_data, int length, FILE_TYPE type)
{
	ENCRYPT *encrypt_ins = (ENCRYPT *)encrypt;
	struct ET_CONTEXT*pContext = (struct ET_CONTEXT*)encrypt_ins->private_data;
	int dwRet = 0;
	if(length > DATA_FILE_LENGTH)
	{
		return WRITE_LEN_LONGER;
	}
	dwRet = ETVerifyPin(&pContext[0], (unsigned char *)encrypt_ins->dev_passwd,
		strlen(encrypt_ins->dev_passwd), ET_DEV_PIN);
	if(dwRet)
	{
		if(dwRet == ET_E_KEY_REMOVED || dwRet == ET_E_NO_LIST)
		{
			return DEV_REMOVED;
		}
		PostError("ETVerifyPin", dwRet);
		return VERIFYPASSWD_ERR;
	}

	dwRet = ETWriteFile(&pContext[0], file_name[type], 0, (unsigned char *)src_data, length);
	if(dwRet)
	{
		if(dwRet == ET_E_KEY_REMOVED || dwRet == ET_E_NO_LIST)
		{
			return DEV_REMOVED;
		}
		PostError("ETWriteFile", dwRet);
		return WRITEFILE_ERR;
	}

	return 0;
}
예제 #2
0
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;
}
예제 #3
0
static int et199_encrypt_creat_flie(void *encrypt, char *file_name, int size, char *passwd, int file_type)
{
	ENCRYPT *encrypt_ins = (ENCRYPT *)encrypt;
	struct ET_CONTEXT *pContext = (struct ET_CONTEXT *)encrypt_ins->private_data;
	int dwRet = 0;

	dwRet = ETVerifyPin(&pContext[0], (unsigned char *)passwd, strlen(passwd), ET_DEV_PIN);
	if(dwRet)
	{
		PostError("ETVerifyPin",dwRet);
		return VERIFYPASSWD_ERR;
	}
	dwRet = ETCreateFile(&pContext[0], file_name, size, file_type);
	if(dwRet)
	{
		PostError("ETCreateFile", dwRet);
		return CREATEFILE_ERR;
	}
	return SUCCESS;
}
예제 #4
0
파일: pyet199.c 프로젝트: archsh/pyet199
static PyObject *
ETContext_verify_pin(ETContextObject* self, PyObject *args)
{
  BYTE *pbPin=NULL;
  DWORD dwPinLen,dwPinType,dwRet;
  if(!PyArg_ParseTuple(args, "s#I", &pbPin,&dwPinLen,&dwPinType)) {
    return NULL;
  }
  dwRet = ETVerifyPin(&self->context,pbPin,dwPinLen,dwPinType);
  /*
  if(ET_S_SUCCESS == dwRet){
    Py_RETURN_TRUE;
  }else if(dwRet&0xF0000C00){
    Py_RETURN_FALSE;
  }else{
    DWRET_VALIDATE(dwRet,NULL);
  }
  */
  DWRET_VALIDATE(dwRet,NULL);
  Py_RETURN_TRUE;
}