Exemplo n.º 1
0
SKYETEK_STATUS 
SkyeTekReader_SelectTags(
    LPSKYETEK_READER            lpReader, 
    SKYETEK_TAGTYPE             tagType, 
    SKYETEK_TAG_SELECT_CALLBACK callback, 
    unsigned char               inv, 
    unsigned char               loop, 
    void                        *user
    )
{
  LPPROTOCOLIMPL lppi;
  PROTOCOL_FLAGS flags;
  ST_CALLBACK_DATA cd;

  if( lpReader == NULL || lpReader->lpProtocol == NULL || lpReader->lpDevice == NULL )
    return SKYETEK_INVALID_PARAMETER;
  
  flags.isInventory = inv;
  flags.isLoop = loop;
  cd.callback = callback;
  cd.user = user;

  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  return lppi->SelectTags(lpReader,tagType,SkyeTekReader_SelectTagsCallback,flags,(void *)&cd,2000);
}
Exemplo n.º 2
0
SKYETEK_STATUS 
SkyeTekReader_EnterPaymentScanMode(
    LPSKYETEK_READER     lpReader
    )
{
  LPPROTOCOLIMPL lppi;
  if( lpReader == NULL || lpReader->lpProtocol == NULL || lpReader->lpDevice == NULL )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  return lppi->EnterPaymentScanMode(lpReader, SKYETEK_TIMEOUT);
}
Exemplo n.º 3
0
SKYETEK_STATUS 
SkyeTekReader_Bootload(
    LPSKYETEK_READER     lpReader
    )
{
  LPPROTOCOLIMPL lppi;
  if( lpReader == NULL || lpReader->lpProtocol == NULL || lpReader->lpDevice == NULL )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  return lppi->Bootload(lpReader,100);
}
/*
// Expects
// SEQUENCE {
//   macKeyName         [1] OCTET STRING OPTIONAL,
//   macKey                 OCTET STRING,
//   cipherKeyName      [2] OCTET STRING OPTIONAL,
//   cipherKey              OCTET STRING OPTIONAL
// }
*/
SKYETEK_STATUS 
Iso14443ATag_SetupSecureMemoryTag(
    LPSKYETEK_READER          lpReader,
    LPSKYETEK_TAG             lpTag,
    LPSKYETEK_KEY             lpKeyHMAC,
    LPSKYETEK_KEY             lpKeyCipher,
		int                       useKeyDerivationFunction
    )
{
  LPPROTOCOLIMPL lppi;
  SKYETEK_STATUS status;
  LPSKYETEK_DATA lpDataS;
  st_asn1_context context;

  if( lpReader == NULL || lpReader->lpProtocol == NULL || 
      lpReader->lpProtocol->internal == NULL ||
      lpReader->lpDevice == NULL || lpTag == NULL || 
      lpKeyHMAC == NULL || lpKeyHMAC->lpData == NULL || lpKeyHMAC->lpData->data == NULL || lpKeyHMAC->lpData->size < 1 )
    return SKYETEK_INVALID_PARAMETER;

  lpDataS = SkyeTek_AllocateData(1024);
  if( lpDataS == NULL )
    return SKYETEK_OUT_OF_MEMORY;

  st_asn1_allocate_context(&context);
  st_asn1_init(context, ST_ASN1_ENCODE,lpDataS->data,lpDataS->size);
  st_asn1_start_sequence(context);
  if( lpKeyHMAC->name != NULL && _tcslen(lpKeyHMAC->name) > 0) {
    st_asn1_start_context_specific(context, 1);
    st_asn1_write_octet_string(context, (unsigned char *)lpKeyHMAC->name, _tcslen(lpKeyHMAC->name)*sizeof(TCHAR));
    st_asn1_finish_context_specific(context, 1);
  }
  st_asn1_write_octet_string(context, lpKeyHMAC->lpData->data, lpKeyHMAC->lpData->size);
  if( lpKeyCipher != NULL && lpKeyCipher->lpData != NULL && lpKeyCipher->lpData->data != NULL && lpKeyCipher->lpData->size > 0 ) {
    if( lpKeyCipher->name != NULL && _tcslen(lpKeyCipher->name) > 0) {
      st_asn1_start_context_specific(context, 2);
      st_asn1_write_octet_string(context, (unsigned char *)lpKeyCipher->name, _tcslen(lpKeyCipher->name)*sizeof(TCHAR));
      st_asn1_finish_context_specific(context, 2);
    }
    st_asn1_write_octet_string(context, lpKeyCipher->lpData->data, lpKeyCipher->lpData->size);
  }

	if (useKeyDerivationFunction)
		st_asn1_write_boolean(context, 1);
	
  st_asn1_finish_sequence(context);
	lpDataS->size = st_asn1_finalize(context);
  st_asn1_free_context(&context);

  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  status = lppi->SetupSecureMemoryTag(lpReader,lpTag,lpDataS,10000);
  SkyeTek_FreeData(lpDataS);
  return status;
}
Exemplo n.º 5
0
SKYETEK_STATUS 
SkyeTekReader_GetDebugMessages(
  LPSKYETEK_READER     lpReader,
  LPSKYETEK_DATA      *lpData
  )
{
  LPPROTOCOLIMPL lppi;
  if( lpReader == NULL || lpReader->lpProtocol == NULL || lpReader->lpProtocol->internal == NULL )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  return lppi->GetDebugMessages(lpReader, lpData,10000);
}
Exemplo n.º 6
0
SKYETEK_STATUS 
SkyeTekReader_AuthenticateReader(
    LPSKYETEK_READER     lpReader, 
    LPSKYETEK_KEY        lpKey
    )
{
  LPPROTOCOLIMPL lppi;
  if( lpReader == NULL || lpReader->lpProtocol == NULL || 
      lpReader->lpDevice == NULL || lpKey == NULL || lpKey->lpData == NULL )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  return lppi->AuthenticateReader(lpReader,lpKey->lpData,SKYETEK_TIMEOUT);
}
Exemplo n.º 7
0
SKYETEK_API SKYETEK_STATUS 
SkyeTekReader_ScanPayments(
    LPSKYETEK_READER              lpReader,
    SKYETEK_PAYMENT_SCAN_CALLBACK callback,
    void                          *user
    )
{
  LPPROTOCOLIMPL lppi;
  if( lpReader == NULL || lpReader->lpProtocol == NULL || 
      lpReader->lpDevice == NULL || callback == NULL )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  return lppi->ScanPayments(lpReader, callback, user, SKYETEK_TIMEOUT);
}
Exemplo n.º 8
0
SKYETEK_STATUS 
SkyeTekReader_UploadFirmware(
    LPSKYETEK_READER                      lpReader, 
    TCHAR                                  *file, 
    unsigned char                         defaultsOnly,
    SKYETEK_FIRMWARE_UPLOAD_CALLBACK      callback, 
    void                                  *user
    )
{
  LPPROTOCOLIMPL lppi;
  if( lpReader == NULL || lpReader->lpProtocol == NULL || lpReader->lpDevice == NULL )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  return lppi->UploadFirmware(lpReader,file,defaultsOnly,callback,user);
}
Exemplo n.º 9
0
SKYETEK_STATUS 
Iso14443BTag_SendTagPassword(
    LPSKYETEK_READER     lpReader,
    LPSKYETEK_TAG        lpTag,
    LPSKYETEK_DATA       lpData
    )
{
  LPPROTOCOLIMPL lppi;
  if( lpReader == NULL || lpReader->lpProtocol == NULL || 
      lpReader->lpProtocol->internal == NULL ||
      lpReader->lpDevice == NULL || lpTag == NULL || 
      lpData == NULL || lpData->data == NULL || lpData->size == 0 )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  return lppi->SendTagPassword(lpReader,lpTag,lpData,ISO14443B_TIMEOUT);
}
Exemplo n.º 10
0
SKYETEK_STATUS 
SkyeTekReader_SetDefaultSystemParameter(
    LPSKYETEK_READER             lpReader, 
    SKYETEK_SYSTEM_PARAMETER     parameter, 
    LPSKYETEK_DATA               lpData
    )
{
  LPPROTOCOLIMPL lppi;
  SKYETEK_ADDRESS addr;
  SKYETEK_STATUS st;
  if( lpReader == NULL || lpReader->lpProtocol == NULL || 
      lpReader->lpDevice == NULL || lpData == NULL )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  if( (st = STR_GetSystemAddrForParm(parameter,&addr,lpReader->lpProtocol->version)) != SKYETEK_SUCCESS )
    return st;
  return lppi->SetDefaultSystemParameter(lpReader,&addr,lpData,SKYETEK_TIMEOUT);
}
Exemplo n.º 11
0
SKYETEK_STATUS 
SkyeTekReader_LoadKey(
    LPSKYETEK_READER     lpReader, 
    LPSKYETEK_KEY        lpKey
    )
{
  LPPROTOCOLIMPL lppi;
  SKYETEK_ADDRESS addr;

  if( lpReader == NULL || lpReader->lpProtocol == NULL || 
    lpReader->lpDevice == NULL || lpKey == NULL )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;

  addr.start = lpKey->number;
  addr.blocks = 1;

  return lppi->LoadKey(lpReader,&addr,500);
}
Exemplo n.º 12
0
SKYETEK_STATUS 
SkyeTekReader_StoreKey(
    LPSKYETEK_READER     lpReader,
    SKYETEK_TAGTYPE      type,
    LPSKYETEK_KEY        lpKey
    )
{
  LPPROTOCOLIMPL lppi;
  SKYETEK_ADDRESS addr;

  if( lpReader == NULL || lpReader->lpProtocol == NULL || 
    lpReader->lpDevice == NULL || lpKey == NULL || lpKey->lpData == NULL )
    return SKYETEK_INVALID_PARAMETER;
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;

  addr.start = lpKey->number;
  addr.blocks = 1;

  return lppi->StoreKey(lpReader,type,&addr,lpKey->lpData,SKYETEK_TIMEOUT);
}
Exemplo n.º 13
0
SKYETEK_STATUS 
SkyeTekReader_GetSystemParameter(
    LPSKYETEK_READER             lpReader, 
    SKYETEK_SYSTEM_PARAMETER     parameter,
    LPSKYETEK_DATA               *lpData
    )
{
  LPPROTOCOLIMPL lppi;
  SKYETEK_ADDRESS addr;
  SKYETEK_STATUS st;
  if( lpReader == NULL || lpReader->lpProtocol == NULL || 
      lpReader->lpDevice == NULL || lpData == NULL )
    return SKYETEK_INVALID_PARAMETER;
  
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  if( (st = STR_GetSystemAddrForParm(parameter,&addr,lpReader->lpProtocol->version)) != SKYETEK_SUCCESS )
    return st;
  if( parameter == SYS_OPTIMAL_POWER_C1G1 || parameter == SYS_OPTIMAL_POWER_C1G2 || 
    parameter == SYS_OPTIMAL_POWER_180006B || parameter == SYS_RSSI_VALUES )
    return lppi->GetSystemParameter(lpReader,&addr,lpData,10000);
  else
    return lppi->GetSystemParameter(lpReader,&addr,lpData,SKYETEK_TIMEOUT);
}
LPSKYETEK_READER 
GetReader(
  LPSKYETEK_DEVICE    lpDevice, 
  LPPROTOCOLIMPL      lpPI,
  unsigned int        ver
  )
{
  LPSKYETEK_READER lpReader = NULL;
  SKYETEK_READER tmpReader;
  SKYETEK_STATUS status;
  SKYETEK_ADDRESS addr;
  LPSKYETEK_DATA lpData = NULL;
  TCHAR *str = NULL;
  int i = 0;
  unsigned int ix = 0;

  if( lpDevice == NULL )
    return NULL;

  /* Fill temp reader for system calls */
  if( ver == 2 )
  {
    tmpReader.id = SkyeTek_AllocateID(1);
    if( tmpReader.id != NULL )
      tmpReader.id->id[0] = 0xFF;
  }
  else
  {
    tmpReader.id = SkyeTek_AllocateID(4);
    if( tmpReader.id != NULL )
      for( i = 0; i < 4; i++ )
        tmpReader.id->id[i] = 0xFF;
  }
  tmpReader.sendRID = 1;
  tmpReader.lpDevice = lpDevice;
  tmpReader.internal = &SkyetekReaderImpl;

  status = STR_GetSystemAddrForParm(SYS_FIRMWARE,&addr,ver);
  if( status != SKYETEK_SUCCESS )
    goto failure;
  status = lpPI->GetSystemParameter(&tmpReader, &addr, &lpData,100);
  if( status != SKYETEK_SUCCESS || lpData == NULL )
    goto failure;

  lpReader = (LPSKYETEK_READER)malloc(sizeof(SKYETEK_READER));
  if( lpReader == NULL )
  {
    SkyeTek_FreeData(lpData);
    goto failure;
  }
  memset(lpReader, 0, sizeof(SKYETEK_READER));

  str = SkyeTek_GetStringFromData(lpData);
  if( str != NULL )
  {
    _tcscpy(lpReader->firmware,str);
    SkyeTek_FreeString(str);
  }

  if( ver == 2 && lpData != NULL && lpData->data != NULL && lpData->size > 0 )
  {
    switch(lpData->data[0])
    {
      case 0x00:
      case 0x01:
      case 0x50:
      case 0x60:
      case 0xA0:
      case 0xC0:
      case 0xD0:
        _tcscpy(lpReader->model, _T("M1")); 
        break;
      case 0xE0:
        _tcscpy(lpReader->model, _T("M8")); 
        break;
		  case 0x20:
        _tcscpy(lpReader->model, _T("M2")); 
        break;
		  default:
        _tcscpy(lpReader->model, _T("??")); 
    }
  }
  SkyeTek_FreeData(lpData);

  if( ver == 3 )
  {
    SKYETEK_Sleep(100);
    status = STR_GetSystemAddrForParm(SYS_PRODUCT,&addr,ver);
    if( status != SKYETEK_SUCCESS )
      goto failure;
    status = lpPI->GetSystemParameter(&tmpReader, &addr, &lpData,100);
    if( status == SKYETEK_SUCCESS && lpData->data != NULL && lpData->size >= 2 )
    {
      switch(lpData->data[1])
      {
      case 0x02:
        _tcscpy(lpReader->model, _T("M2"));
        break;
      case 0x04:
        _tcscpy(lpReader->model, _T("M4"));
        break;
      case 0x2A:
        _tcscpy(lpReader->model, _T("M2A"));
        break;
      case 0x07:
        _tcscpy(lpReader->model, _T("M7"));
        break;
      case 0x09:
        _tcscpy(lpReader->model, _T("M9"));
        break;
	  case 0x0A:
		_tcscpy(lpReader->model, _T("M10"));
		break;
      default:
        _tcscpy(lpReader->model, _T("??"));
        break;
      }
      SkyeTek_FreeData(lpData);
    }
    else
      _tcscpy(lpReader->model, _T("??"));
  }

  SKYETEK_Sleep(100);
  status = STR_GetSystemAddrForParm(SYS_READER_NAME,&addr,ver);
  if( status != SKYETEK_SUCCESS )
    goto failure;
  status = lpPI->GetSystemParameter(&tmpReader, &addr, &lpData,100);
  if( status != SKYETEK_SUCCESS )
  {
    free(lpReader);
    goto failure;
  }
  if( lpData != NULL && lpData->size > 0 && lpData->data != NULL )
  {
    /* make sure we have a null pointer */
    i = 0;
    for( ix = 0; ix < lpData->size; ix++ )
    {
      if( lpData->data[ix] == '\0' )
      {
        i = 1;
        break;
      }
    }
    if( i == 1 )
	{
		//Reader name is stored in standard ascii
		for(ix = 0; ix < lpData->size; ix++)
			lpReader->readerName[ix] = (TCHAR)lpData->data[ix];
	}
  }
  SkyeTek_FreeData(lpData);

  SKYETEK_Sleep(100);
  status = STR_GetSystemAddrForParm(SYS_SERIALNUMBER,&addr,ver);
  if( status != SKYETEK_SUCCESS )
    goto failure;
  status = lpPI->GetSystemParameter(&tmpReader, &addr, &lpData,100);
  if( status != SKYETEK_SUCCESS )
  {
    free(lpReader);
    goto failure;
  }
  str = SkyeTek_GetStringFromData(lpData);
  if( str != NULL )
  {
    _tcscpy(lpReader->serialNumber, str);
    SkyeTek_FreeString(str);
  }
  SkyeTek_FreeData(lpData);

  SKYETEK_Sleep(100);
  status = STR_GetSystemAddrForParm(SYS_RID,&addr,ver);
  if( status != SKYETEK_SUCCESS )
    goto failure;
  status = lpPI->GetSystemParameter(&tmpReader, &addr, &lpData,100);
  if( status != SKYETEK_SUCCESS )
	{
	  free(lpReader);
	  goto failure;
	}
	lpReader->id = (LPSKYETEK_ID)lpData;
  lpReader->internal = &SkyetekReaderImpl;
  lpReader->lpDevice = lpDevice;
  lpReader->lpProtocol = (LPSKYETEK_PROTOCOL)malloc(sizeof(SKYETEK_PROTOCOL));
  if( lpReader->lpProtocol == NULL )
  {
    free(lpReader);
    goto failure;
  }
  lpReader->lpProtocol->version = ver;
  lpReader->lpProtocol->internal = lpPI;
  _tcscpy(lpReader->manufacturer, _T("SkyeTek"));
  str = SkyeTek_GetStringFromID(lpReader->id);
  if( str == NULL )
  {
    free(lpReader);
    goto failure;
  }
  _tcscpy(lpReader->rid,str);

  /* TODO: See if Reader Name can be used */
  _stprintf(lpReader->friendly, _T("%s-%s-%s"), lpReader->manufacturer, lpReader->model, str);
  SkyeTek_FreeString(str);

  return lpReader;
failure:
  SkyeTek_FreeID(tmpReader.id);
  return NULL;
}
Exemplo n.º 15
0
SKYETEK_STATUS 
SkyeTekReader_GetTags(
    LPSKYETEK_READER   lpReader, 
    SKYETEK_TAGTYPE    tagType, 
    LPSKYETEK_TAG      **lpTags, 
    unsigned short     *count
    )
{
  LPPROTOCOLIMPL lppi;
  unsigned int num;
  unsigned int ix = 0, iy = 0;
  LPTAGTYPE_ARRAY *tagTypes = NULL;
  LPSKYETEK_DATA *lpData = NULL;
  SKYETEK_STATUS status;

  if( lpReader == NULL || lpReader->lpProtocol == NULL || lpReader->lpDevice == NULL )
    return SKYETEK_INVALID_PARAMETER;

  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;

  status = lppi->GetTags(lpReader,tagType,&tagTypes,&lpData,&num,5000);
  if( status != SKYETEK_SUCCESS )
    return status;

  if( num > 0 )
  {
    *lpTags = (LPSKYETEK_TAG *)malloc(num * sizeof(LPSKYETEK_TAG));
    if( *lpTags == NULL )
    {
      status = SKYETEK_OUT_OF_MEMORY;
      goto failure;
    }

    for( ix = 0; ix < num; ix++ )
    {
      status = CreateTagImpl(tagTypes[ix]->type, (LPSKYETEK_ID)lpData[ix], &((*lpTags)[ix]));
      if( status != SKYETEK_SUCCESS )
        goto failure;
    }
  }

  *count = num;
  status = SKYETEK_SUCCESS;
  goto cleanup;

failure:
  /* Clean up partially created tags */
  for( iy = 0; iy < ix; iy ++ )
    FreeTagImpl((*lpTags)[iy]);
cleanup:
  /* Clean up memory from protocol */
  if( lpData != NULL )
  {
    for( ix = 0; ix < num; ix++ )
    {
      SkyeTek_FreeData(lpData[ix]);
    }
    free(lpData);
  }
  if( tagTypes != NULL )
    free(tagTypes);
  return status;
}
/*
// Expects
// SEQUENCE {
//   interface            ENUMERATED { 7816-4(1) }
//   CHOICE {
//     iso7816-4         [1] SEQUENCE {
//       CLA        OCTET-STRING,
//       INS        OCTET-STRING,
//       P1_P2      OCTET-STRING,
//       DATA       OCTET-STRING OPTIONAL,
//       Le         INTEGER }
//   }
// }
// Returns
// OCTET-STRING
*/
SKYETEK_STATUS 
Iso14443ATag_TransportSend(
    LPSKYETEK_READER     lpReader,
    LPSKYETEK_TAG        lpTag,
    SKYETEK_TRANSPORT    transport,
    SKYETEK_BLOCK        block,
    LPSKYETEK_DATA       lpCla,
    LPSKYETEK_DATA       lpIns,
    LPSKYETEK_DATA       lpP1p2,
    LPSKYETEK_DATA       lpData, 
    unsigned int         le,
    LPSKYETEK_DATA       *lpRecvData
    )
{
  LPPROTOCOLIMPL lppi;
  SKYETEK_STATUS status;
  LPSKYETEK_DATA lpDataS;
  LPSKYETEK_DATA lpDataR = NULL;
  st_asn1_context context;
  int64 w;
  
  if( lpReader == NULL || lpReader->lpProtocol == NULL || 
      lpReader->lpProtocol->internal == NULL ||
      lpReader->lpDevice == NULL || lpTag == NULL || 
      lpCla == NULL || lpCla->data == NULL || lpCla->size == 0 ||
      lpIns == NULL || lpIns->data == NULL || lpIns->size == 0 ||
      lpP1p2 == NULL || lpP1p2->data == NULL || lpP1p2->size == 0 ||
      lpRecvData == NULL )
    return SKYETEK_INVALID_PARAMETER;

  lpDataS = SkyeTek_AllocateData(1024);
  if( lpDataS == NULL )
    return SKYETEK_OUT_OF_MEMORY;

  st_asn1_allocate_context(&context);
  st_asn1_init(context, ST_ASN1_ENCODE,lpDataS->data,lpDataS->size);
  st_asn1_start_sequence(context);
  w = transport;
  st_asn1_write_enumerated(context,w);
  if( transport == T7816D4 )
  {
    st_asn1_start_context_specific(context, 1);
    st_asn1_start_sequence(context);
    st_asn1_write_octet_string(context, lpCla->data, lpCla->size);
    st_asn1_write_octet_string(context, lpIns->data, lpIns->size);
    st_asn1_write_octet_string(context, lpP1p2->data, lpP1p2->size);
    if( lpData != NULL && lpData->data != NULL && lpData->size > 0 )
      st_asn1_write_octet_string(context, lpData->data, lpData->size);
    w = le;
    st_asn1_write_integer(context,w);
    st_asn1_finish_sequence(context);
    st_asn1_finish_context_specific(context, 1);
  }
  st_asn1_finish_sequence(context);
	lpDataS->size = st_asn1_finalize(context);
  st_asn1_free_context(&context);
  
  lppi = (LPPROTOCOLIMPL)lpReader->lpProtocol->internal;
  status = lppi->InterfaceSend(lpReader,lpTag,lpDataS,&lpDataR,5000);
  if( status != SKYETEK_SUCCESS )
  {
    SkyeTek_FreeData(lpDataS);
    return status;
  }
  if( lpDataR == NULL || lpDataR->data == NULL || lpDataR->size == 0 )
    return SKYETEK_SUCCESS;
  
  *lpRecvData = SkyeTek_AllocateData(lpDataR->size);
  if( *lpRecvData == NULL )
    return SKYETEK_OUT_OF_MEMORY;
  st_asn1_allocate_context(&context);
  st_asn1_init(context, ST_ASN1_ENCODE,lpDataR->data,lpDataR->size);
  st_asn1_read_octet_string(context, (*lpRecvData)->data, &(*lpRecvData)->size);
  st_asn1_free_context(&context);
  
  return SKYETEK_SUCCESS;
}