void CLibTesterDlg::VerifyIssuserPublicKeyWithSignature_SDA()
{
//PBOC
//
//Step 1 (CAPK index = 0x57)
BYTE byPublicKeyXA[32] = {0xE8, 0x10, 0x5E, 0x77, 0x86, 0x1F, 0xD2, 0xEB, 0x72, 0x7C, 0x84, 0xE3, 0x6D, 0x3D, 0x4A, 0x56,
0x66, 0xBD, 0x0A, 0xDC, 0xE8, 0x78, 0x1F, 0x01, 0x45, 0xD3, 0xD8, 0x2D, 0x72, 0xB9, 0x27, 0x48};
BYTE byPublicKeyYA[32] = {0xE2, 0x2D, 0x54, 0x04, 0xC6, 0xC4, 0x1F, 0x3E, 0xC8, 0xB7, 0x90, 0xDE, 0x2F, 0x61, 0xCF, 0x29,
0xFA, 0xEC, 0xB1, 0x68, 0xC7, 0x9F, 0x5C, 0x86, 0x66, 0x76, 0x2D, 0x53, 0xCC, 0x26, 0xA4, 0x60};
SetupBasiSMAlgorithm(byPublicKeyXA, byPublicKeyYA);
//Step 2
BYTE byData[] = {0x12, 0x62, 0x28, 0x00, 0x01, 0x12, 0x20, 0x00, 0x00, 0x01, 0x04, 0x00, 0x11, 0x40,
0x9F, 0x48, 0x3B, 0xF2, 0xCC, 0x71, 0xC5, 0x09, 0x37, 0x28, 0x31, 0x80, 0x61, 0xE3, 0xF7, 0x68,
0xEA, 0x7C, 0x17, 0x0F, 0x82, 0xDD, 0x8C, 0x4B, 0x97, 0x9F, 0xBD, 0x8C, 0x76, 0xA1, 0x29, 0xF9,
0x3F, 0xB5, 0x74, 0x6E, 0x96, 0xF5, 0xE4, 0x9B, 0x98, 0x7F, 0xFB, 0x52, 0x1E, 0x47, 0x3B, 0x25,
0xE1, 0xB0, 0x17, 0xC3, 0x0B, 0xE3, 0xFC, 0x63, 0x8B, 0xA1, 0x4D, 0x5F, 0xA4, 0xAA, 0xDC, 0x16};
BYTE byR[32] = {0xB1, 0xE1, 0xA0, 0x2E, 0xD6, 0x2D, 0x81, 0x12, 0x68, 0xC4, 0xA2, 0x12, 0x3C, 0xD8, 0xB2, 0x66,
0x90, 0xBC, 0xE1, 0x4B, 0xB7, 0xA0, 0x17, 0x13, 0xC0, 0x1C, 0x2D, 0x2F, 0xF2, 0x89, 0x2D, 0x15};
BYTE byS[32] = {0x96, 0xA7, 0xD9, 0xD1, 0x31, 0xC7, 0x38, 0x13, 0xC3, 0xA3, 0xD6, 0xF8, 0x51, 0xDC, 0xDA, 0x91,
0x7E, 0x98, 0x69, 0x23, 0xF9, 0x8D, 0xD2, 0x44, 0x4A, 0xDC, 0x8E, 0xF0, 0xD0, 0xCE, 0x1E, 0x2A};
//Step 2
BYTE byHash[32] = {0};
SM3_GenZaHash(byHash);
//Step 3
BYTE byFullData[1024] = {0};
int nFillLen = 0;
memcpy(byFullData, byHash, 32);
nFillLen += 32;
memcpy(byFullData+nFillLen, byData, sizeof(byData));
nFillLen += sizeof(byData);
SM3(byFullData, nFillLen, byHash);
BOOL bRet = SM2_VerifySignature(byHash, 32, byR, byS);
CString strLog;
GetDlgItem(IDC_LOG_EDIT)->GetWindowText(strLog);
if (bRet)
{
strLog += _T("VerifyIssuserPublicKeyWithSignature OK!\r\n");
}
else
{
strLog += _T("VerifyIssuserPublicKeyWithSignature Failed!\r\n");
}
GetDlgItem(IDC_LOG_EDIT)->SetWindowText(strLog);
}
void CLibTesterDlg::VerifyIccPublicKeyWithSignature_SDA()
{
//PBOC
//
//Step 1 (Issuer public key)
BYTE byPublicKeyXA[32] = {0x9F, 0x48, 0x3B, 0xF2, 0xCC, 0x71, 0xC5, 0x09, 0x37, 0x28, 0x31, 0x80, 0x61, 0xE3, 0xF7, 0x68,
0xEA, 0x7C, 0x17, 0x0F, 0x82, 0xDD, 0x8C, 0x4B, 0x97, 0x9F, 0xBD, 0x8C, 0x76, 0xA1, 0x29, 0xF9};
BYTE byPublicKeyYA[32] = {0x3F, 0xB5, 0x74, 0x6E, 0x96, 0xF5, 0xE4, 0x9B, 0x98, 0x7F, 0xFB, 0x52, 0x1E, 0x47, 0x3B, 0x25,
0xE1, 0xB0, 0x17, 0xC3, 0x0B, 0xE3, 0xFC, 0x63, 0x8B, 0xA1, 0x4D, 0x5F, 0xA4, 0xAA, 0xDC, 0x16};
SetupBasiSMAlgorithm(byPublicKeyXA, byPublicKeyYA);
//Step 2
BYTE byHash[32] = {0};
SM3_GenZaHash(byHash);
//Step 3
BYTE byData[] = {0x13, 0xDA, 0xC1,
0x5A, 0x08, 0x62, 0x28, 0x00, 0x01, 0x00, 0x00, 0x11, 0x17, 0x5F, 0x34, 0x01, 0x01};
BYTE byR[32] = {0xDE, 0xF7, 0xDF, 0xA2, 0xCB, 0x51, 0x8B, 0xC5, 0xC3, 0xF6, 0x99, 0x2A, 0xC1, 0xA0, 0xA1, 0x9C,
0x43, 0x1E, 0xD8, 0xB9, 0xE2, 0x80, 0xF2, 0xAC, 0xE6, 0x13, 0xF3, 0xD5, 0x74, 0xB7, 0xE6, 0x08};
BYTE byS[32] = {0xEC, 0xE5, 0xF3, 0xE2, 0x13, 0x5D, 0x26, 0x52, 0xEC, 0x41, 0x18, 0x02, 0x2F, 0x25, 0x3F, 0x1E,
0x90, 0x98, 0x82, 0xE3, 0x50, 0x99, 0xBE, 0x8A, 0x03, 0x3E, 0xE2, 0xF2, 0xAF, 0xE4, 0x58, 0xA8};
BYTE byFullData[1024] = {0};
int nFillLen = 0;
memcpy(byFullData, byHash, 32);
nFillLen += 32;
memcpy(byFullData+nFillLen, byData, sizeof(byData));
nFillLen += sizeof(byData);
SM3(byFullData, nFillLen, byHash); //Get Hash for Signature
BOOL bRet = SM2_VerifySignature(byHash, 32, byR, byS);
CString strLog;
GetDlgItem(IDC_LOG_EDIT)->GetWindowText(strLog);
if (bRet)
{
strLog += _T("VerifyIccPublicKeyWithSignature OK!\r\n");
}
else
{
strLog += _T("VerifyIccPublicKeyWithSignature Failed!\r\n");
}
GetDlgItem(IDC_LOG_EDIT)->SetWindowText(strLog);
}
void CLibTesterDlg::VerifyIssuserPublicKeyWithSignature2_SDA()
{
//PBOC
//
//Step 1 (CAPK index = 0x57)
BYTE byPublicKeyXA[32] = {0xE8, 0x10, 0x5E, 0x77, 0x86, 0x1F, 0xD2, 0xEB, 0x72, 0x7C, 0x84, 0xE3, 0x6D, 0x3D, 0x4A, 0x56,
0x66, 0xBD, 0x0A, 0xDC, 0xE8, 0x78, 0x1F, 0x01, 0x45, 0xD3, 0xD8, 0x2D, 0x72, 0xB9, 0x27, 0x48};
BYTE byPublicKeyYA[32] = {0xE2, 0x2D, 0x54, 0x04, 0xC6, 0xC4, 0x1F, 0x3E, 0xC8, 0xB7, 0x90, 0xDE, 0x2F, 0x61, 0xCF, 0x29,
0xFA, 0xEC, 0xB1, 0x68, 0xC7, 0x9F, 0x5C, 0x86, 0x66, 0x76, 0x2D, 0x53, 0xCC, 0x26, 0xA4, 0x60};
SetupBasiSMAlgorithm(byPublicKeyXA, byPublicKeyYA);
//Step 2
BYTE byData[] = {0x12, 0x62, 0x28, 0x00, 0x01, 0x12, 0x20, 0x00, 0x00, 0x01, 0x04, 0x00, 0x11, 0x40,
0x9F, 0x48, 0x3B, 0xF2, 0xCC, 0x71, 0xC5, 0x09, 0x37, 0x28, 0x31, 0x80, 0x61, 0xE3, 0xF7, 0x68,
0xEA, 0x7C, 0x17, 0x0F, 0x82, 0xDD, 0x8C, 0x4B, 0x97, 0x9F, 0xBD, 0x8C, 0x76, 0xA1, 0x29, 0xF9,
0x3F, 0xB5, 0x74, 0x6E, 0x96, 0xF5, 0xE4, 0x9B, 0x98, 0x7F, 0xFB, 0x52, 0x1E, 0x47, 0x3B, 0x25,
0xE1, 0xB0, 0x17, 0xC3, 0x0B, 0xE3, 0xFC, 0x63, 0x8B, 0xA1, 0x4D, 0x5F, 0xA4, 0xAA, 0xDC, 0x16};
BYTE byR[32] = {0xB1, 0xE1, 0xA0, 0x2E, 0xD6, 0x2D, 0x81, 0x12, 0x68, 0xC4, 0xA2, 0x12, 0x3C, 0xD8, 0xB2, 0x66,
0x90, 0xBC, 0xE1, 0x4B, 0xB7, 0xA0, 0x17, 0x13, 0xC0, 0x1C, 0x2D, 0x2F, 0xF2, 0x89, 0x2D, 0x15};
BYTE byS[32] = {0x96, 0xA7, 0xD9, 0xD1, 0x31, 0xC7, 0x38, 0x13, 0xC3, 0xA3, 0xD6, 0xF8, 0x51, 0xDC, 0xDA, 0x91,
0x7E, 0x98, 0x69, 0x23, 0xF9, 0x8D, 0xD2, 0x44, 0x4A, 0xDC, 0x8E, 0xF0, 0xD0, 0xCE, 0x1E, 0x2A};
BOOL bRet = SM2_VerifySignature2(byData, sizeof(byData), byR, byS);
CString strLog;
GetDlgItem(IDC_LOG_EDIT)->GetWindowText(strLog);
if (bRet)
{
strLog += _T("VerifyIssuserPublicKeyWithSignature2 OK!\r\n");
}
else
{
strLog += _T("VerifyIssuserPublicKeyWithSignature2 Failed!\r\n");
}
GetDlgItem(IDC_LOG_EDIT)->SetWindowText(strLog);
}
void CLibTesterDlg::VerifyIccPublicKeyWithSignature2_SDA()
{
//PBOC
//
//Step 1 (Issuer public key)
BYTE byPublicKeyXA[32] = {0x9F, 0x48, 0x3B, 0xF2, 0xCC, 0x71, 0xC5, 0x09, 0x37, 0x28, 0x31, 0x80, 0x61, 0xE3, 0xF7, 0x68,
0xEA, 0x7C, 0x17, 0x0F, 0x82, 0xDD, 0x8C, 0x4B, 0x97, 0x9F, 0xBD, 0x8C, 0x76, 0xA1, 0x29, 0xF9};
BYTE byPublicKeyYA[32] = {0x3F, 0xB5, 0x74, 0x6E, 0x96, 0xF5, 0xE4, 0x9B, 0x98, 0x7F, 0xFB, 0x52, 0x1E, 0x47, 0x3B, 0x25,
0xE1, 0xB0, 0x17, 0xC3, 0x0B, 0xE3, 0xFC, 0x63, 0x8B, 0xA1, 0x4D, 0x5F, 0xA4, 0xAA, 0xDC, 0x16};
SetupBasiSMAlgorithm(byPublicKeyXA, byPublicKeyYA);
//Step 2
BYTE byData[] = {0x13, 0xDA, 0xC1,
0x5A, 0x08, 0x62, 0x28, 0x00, 0x01, 0x00, 0x00, 0x11, 0x17, 0x5F, 0x34, 0x01, 0x01};
BYTE byR[32] = {0xDE, 0xF7, 0xDF, 0xA2, 0xCB, 0x51, 0x8B, 0xC5, 0xC3, 0xF6, 0x99, 0x2A, 0xC1, 0xA0, 0xA1, 0x9C,
0x43, 0x1E, 0xD8, 0xB9, 0xE2, 0x80, 0xF2, 0xAC, 0xE6, 0x13, 0xF3, 0xD5, 0x74, 0xB7, 0xE6, 0x08};
BYTE byS[32] = {0xEC, 0xE5, 0xF3, 0xE2, 0x13, 0x5D, 0x26, 0x52, 0xEC, 0x41, 0x18, 0x02, 0x2F, 0x25, 0x3F, 0x1E,
0x90, 0x98, 0x82, 0xE3, 0x50, 0x99, 0xBE, 0x8A, 0x03, 0x3E, 0xE2, 0xF2, 0xAF, 0xE4, 0x58, 0xA8};
BOOL bRet = SM2_VerifySignature2(byData, sizeof(byData), byR, byS);
CString strLog;
GetDlgItem(IDC_LOG_EDIT)->GetWindowText(strLog);
if (bRet)
{
strLog += _T("VerifyIccPublicKeyWithSignature2 OK!\r\n");
}
else
{
strLog += _T("VerifyIccPublicKeyWithSignature2 Failed!\r\n");
}
GetDlgItem(IDC_LOG_EDIT)->SetWindowText(strLog);
}
[SM国密算法][OpenSSL] PBOC Offline Data验证之SDA
最新推荐文章于 2018-04-08 14:55:00 发布