|
void test_auth()
{
#if ENABLE_AUTH
BVRAuthParam param;
memset(¶m, 0, sizeof(BVRAuthParam));
{
param.iSize = sizeof(BVRAuthParam);
param.OnAuthEvent = PU_OnAuthEvent;
strcpy(param.SerialNumber, ""); //
{
strcpy(param.termInfo.Type, "PU");
strcpy(param.termInfo.ID, "PU_12456");
strcpy(param.termInfo.ModelNumber, "ModelNumber_123");
strcpy(param.termInfo.MAC, "MAC_14156");
strcpy(param.termInfo.IMEI, "IMEI_235328965jkljfkl");
strcpy(param.termInfo.HardwareProvider, "HardwareProvider_sdjgkagjnsjakdfj");
strcpy(param.termInfo.HardwareSN, "HardwareSN_GHK6BC290E7E4AF4B59DB24B576A8ABJ");
strcpy(param.termInfo.HardwareVersion, "HardwareVersion_akgjk");
strcpy(param.termInfo.SoftwareProvider, "SoftwareProvider_sadkgjaskl");
strcpy(param.termInfo.SoftwareVersion, "SoftwareVersion_sdkgj");
strcpy(param.termInfo.OSType, "OSType_214ui");
strcpy(param.termInfo.OSVersion, "OSVersion_sajkdg");
strcpy(param.termInfo.OSID, "OSID_sdajgk");
strcpy(param.termInfo.CPU, "CPU_234i");
strcpy(param.termInfo.Desc, "Desc_ad");
}
}
{
AU_RSA* rsa = NULL;
char* app_id = "app_xxxxxxxxxxxxx";
char* n = "b1d6ad586dxxxxxxxxxxxxxxxxxxxx";
char* e = "830e7aaxxxxxxxxxxxxxx";
char data[256];
int data_len = 0;
int len = 0;
char base64[512];
int base64_len;
char encrypt[512];
int encrypt_len = 0;
data_len = sizeof(data);
memset(data, 0, sizeof(data));
encrypt_len = sizeof(encrypt);
memset(encrypt, 0, sizeof(encrypt));
base64_len = sizeof(base64);
memset(base64, 0, sizeof(base64));
strcpy(param.appInfo.appId, app_id);
// 获取需要字符串
BVCSP_GetEncryptedData(data, &data_len);
#if 0
au_rsa_init();
au_rsa_key_get_hex(&rsa, n, e, NULL);
// Base64(RSA(data))
len = au_rsa_encrypt(rsa, data, data_len, encrypt, encrypt_len);
if (len > 0)
{
base64_len = base64_encode((const unsigned char*)encrypt, len, base64);
param.appInfo.ciph_data = base64;
param.appInfo.ciph_len = strlen(base64);
}
#else
char outdata[512];
int outdata_len = sizeof(outdata);
BVCSP_EncryptData(n, e, data, data_len, outdata, &outdata_len);
param.appInfo.ciph_data = outdata;
param.appInfo.ciph_len = outdata_len;
#endif
}
BVCSP_Auth(¶m);
#endif
}
|
|