当前位置: 首页>>代码示例>>C++>>正文


C++ LPPROTOCOLIMPL::SetupSecureMemoryTag方法代码示例

本文整理汇总了C++中LPPROTOCOLIMPL::SetupSecureMemoryTag方法的典型用法代码示例。如果您正苦于以下问题:C++ LPPROTOCOLIMPL::SetupSecureMemoryTag方法的具体用法?C++ LPPROTOCOLIMPL::SetupSecureMemoryTag怎么用?C++ LPPROTOCOLIMPL::SetupSecureMemoryTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPPROTOCOLIMPL的用法示例。


在下文中一共展示了LPPROTOCOLIMPL::SetupSecureMemoryTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/*
// 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;
}
开发者ID:simbits,项目名称:Ad-Hoc-Dark-Roast-Network-Travel-Mug-,代码行数:63,代码来源:Iso14443ATag.c


注:本文中的LPPROTOCOLIMPL::SetupSecureMemoryTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。