📄 morepkhatest.c
字号:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xed, 0xbe, 0x63, 0xac, 0x07, 0xf2, 0x60, 0x10, 0xfb, 0x91, 0xc1, 0x5f, 0x9e, 0x5d, 0x75, 0xca, 0x39, 0x3d, 0x73, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x4f, 0x3c, 0x88, 0xbf, 0xe1, 0xcc, 0xc6, 0xa2, 0x2a, 0xfe, 0xc0, 0x4a, 0x20, 0x53, 0xf3, 0x14, 0x57, 0x6c, 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x10, 0xce, 0x96, 0x4c, 0xaf, 0xf6, 0xaa, 0x50, 0xde, 0xa0, 0x75, 0x0d, 0x84, 0x5d, 0x62, 0x5c, 0xa7, 0x66, 0x11,}; static const unsigned char ptpqAff_exp_b3[] = /* 20 bytes */{ 0x68, 0x60, 0xae, 0x45, 0x94, 0x34, 0x7c, 0xe1, 0x5c, 0x9f, 0xdc, 0xd7, 0xda, 0xb6, 0xad, 0x86, 0xde, 0x0d, 0x09, 0xd7}; static const unsigned char ptpqAff_exp_b2[] = /* 20 bytes */{ 0x4f, 0xa2, 0x44, 0xb0, 0x73, 0x22, 0xb3, 0xc8, 0xa5, 0x6b, 0xb7, 0xde, 0xb0, 0x17, 0xd9, 0xc4, 0x0e, 0x1f, 0xbd, 0x8d}; static const unsigned char ptpqAff_exp_b1[] = /* 20 bytes */{ 0x31, 0x14, 0x71, 0x2d, 0xf3, 0xa2, 0x38, 0xb4, 0xe3, 0x20, 0x5d, 0x08, 0x45, 0xb5, 0xc5, 0x0c, 0xe3, 0xf5, 0xe3, 0xd1};int testEccFpPtMultkPtoQAff(int fd){ unsigned char b1data[20], b2data[20], b3data[20]; int stat, tstat; ECC_POINT_REQ ecc_mulkptoqReq; tstat = 0; memset(b1data, 0, 20); memset(b2data, 0, 20); memset(b3data, 0, 20); memset (&ecc_mulkptoqReq, 0, sizeof(ecc_mulkptoqReq)); printf("ECC Point MulK P->Q Affine Test\n"); ecc_mulkptoqReq.opId = DPD_EC_FP_AFF_LDCTX_kP_ULCTX; ecc_mulkptoqReq.nDataBytes = 20; ecc_mulkptoqReq.nData = (unsigned char *)ptpqAff_MODULUS; ecc_mulkptoqReq.eDataBytes = 20; ecc_mulkptoqReq.eData = (unsigned char *)ptpqAff_e; ecc_mulkptoqReq.buildDataBytes = 384; ecc_mulkptoqReq.buildData = (unsigned char *)ptpqAff_builddata; ecc_mulkptoqReq.b1DataBytes = 20; ecc_mulkptoqReq.b1Data = (unsigned char *)b1data; ecc_mulkptoqReq.b2DataBytes = 20; ecc_mulkptoqReq.b2Data = (unsigned char *)b2data; ecc_mulkptoqReq.b3DataBytes = 20; ecc_mulkptoqReq.b3Data = (unsigned char *)b3data; stat = putKmem(fd, ptpqAff_MODULUS, &ecc_mulkptoqReq.nData, ecc_mulkptoqReq.nDataBytes); if (stat) return -1; stat = putKmem(fd, ptpqAff_e, &ecc_mulkptoqReq.eData, ecc_mulkptoqReq.eDataBytes); if (stat) { freeKmem(fd, &ecc_mulkptoqReq.nData); return -1; } stat = putKmem(fd, ptpqAff_builddata, &ecc_mulkptoqReq.buildData, ecc_mulkptoqReq.buildDataBytes); if (stat) { freeKmem(fd, &ecc_mulkptoqReq.nData); freeKmem(fd, &ecc_mulkptoqReq.eData); return -1; } stat = putKmem(fd, NULL, &ecc_mulkptoqReq.b1Data, ecc_mulkptoqReq.b1DataBytes); if (stat) { freeKmem(fd, &ecc_mulkptoqReq.nData); freeKmem(fd, &ecc_mulkptoqReq.eData); freeKmem(fd, &ecc_mulkptoqReq.buildData); return -1; } stat = putKmem(fd, NULL, &ecc_mulkptoqReq.b2Data, ecc_mulkptoqReq.b2DataBytes); if (stat) { freeKmem(fd, &ecc_mulkptoqReq.nData); freeKmem(fd, &ecc_mulkptoqReq.eData); freeKmem(fd, &ecc_mulkptoqReq.buildData); freeKmem(fd, &ecc_mulkptoqReq.b1Data); return -1; } stat = putKmem(fd, NULL, &ecc_mulkptoqReq.b3Data, ecc_mulkptoqReq.b3DataBytes); if (stat) { freeKmem(fd, &ecc_mulkptoqReq.nData); freeKmem(fd, &ecc_mulkptoqReq.eData); freeKmem(fd, &ecc_mulkptoqReq.buildData); freeKmem(fd, &ecc_mulkptoqReq.b1Data); freeKmem(fd, &ecc_mulkptoqReq.b2Data); return -1; } armCompletion(&ecc_mulkptoqReq); stat = ioctl(fd, IOCTL_PROC_REQ, (int)&ecc_mulkptoqReq); if (stat = waitCompletion("testPKHA(): ECC Point Multiply Affine test", stat, &ecc_mulkptoqReq)) { freeKmem(fd, &ecc_mulkptoqReq.nData); freeKmem(fd, &ecc_mulkptoqReq.eData); freeKmem(fd, &ecc_mulkptoqReq.buildData); freeKmem(fd, &ecc_mulkptoqReq.b1Data); freeKmem(fd, &ecc_mulkptoqReq.b2Data); freeKmem(fd, &ecc_mulkptoqReq.b3Data); } getKmem(fd, b1data, &ecc_mulkptoqReq.b1Data, ecc_mulkptoqReq.b1DataBytes); getKmem(fd, b2data, &ecc_mulkptoqReq.b2Data, ecc_mulkptoqReq.b2DataBytes); getKmem(fd, b3data, &ecc_mulkptoqReq.b3Data, ecc_mulkptoqReq.b3DataBytes); freeKmem(fd, &ecc_mulkptoqReq.nData); freeKmem(fd, &ecc_mulkptoqReq.eData); freeKmem(fd, &ecc_mulkptoqReq.buildData); freeKmem(fd, &ecc_mulkptoqReq.b1Data); freeKmem(fd, &ecc_mulkptoqReq.b2Data); freeKmem(fd, &ecc_mulkptoqReq.b3Data); if (memcmp(b1data, ptpqAff_exp_b1, 20) != 0) { printf("ECC Point Multiply Affine Test - b1 output data mismatch:\n"); dumpm(b1data, 20); tstat = -1; } if (memcmp(b2data, ptpqAff_exp_b2, 20) != 0) { printf("ECC Point Multiply Affine Test - b2 output data mismatch:\n"); dumpm(b2data, 20); tstat = -1; } if (memcmp(b3data, ptpqAff_exp_b3, 20) != 0) { printf("ECC Point Multiply Affine Test - b3 output data mismatch:\n"); dumpm(b3data, 20); tstat = -1; } return(tstat);}static const unsigned char ptpqAff2_MODULUS[] ={ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x01};static const unsigned char ptpqAff2_e[] ={ 0x4b, 0x26, 0xda, 0x96, 0x9e, 0xc0, 0xeb, 0xf7, 0xa1, 0xea, 0x4f, 0x75, 0xaa, 0x1c, 0x96, 0xf0, 0xf6, 0x7a, 0x37, 0x7f, 0x1e, 0x9f, 0x39, 0xd4, 0x6b, 0xa5, 0x2d};static const unsigned char ptpqAff2_builddata[] ={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb2, 0x37, 0x3c, 0x16, 0xfb, 0x0b, 0xa9, 0x1b, 0x7c, 0xa8, 0x39, 0x49, 0x22, 0xfe, 0xd6, 0x1d, 0x07, 0x88, 0x43, 0x57, 0x58, 0x0a, 0x81, 0x0c, 0xaa, 0xa5, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x42, 0x21, 0x2f, 0xb2, 0x31, 0x69, 0x64, 0x14, 0x33, 0x0a, 0xb5, 0x7d, 0xbe, 0xf4, 0xd5, 0x42, 0x0c, 0xc1, 0xa8, 0x6c, 0x98, 0x96, 0x77, 0x50, 0xe6, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x11, 0xd3, 0xc3, 0xb6, 0xe7, 0x67, 0xb7, 0x15, 0xb5, 0x3c, 0xad, 0xda, 0x99, 0xa9, 0x80, 0xa4, 0xfd, 0x71, 0x45, 0xd3, 0xf4, 0xe7, 0x3b, 0x26, 0x44, 0x78, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x10, 0x00};static const unsigned char ptpqAff2_exp_b1[] ={ 0x02, 0xB3, 0x30, 0x45, 0xA0, 0x97, 0x67, 0x90, 0x3D, 0xA9, 0xA0, 0x78, 0x90, 0xA8, 0x7E, 0xA8, 0x65, 0xDE, 0x77, 0x41, 0x5D, 0x8A, 0xB9, 0xBE, 0x3E, 0x8C, 0x94, 0x69};static const unsigned char ptpqAff2_exp_b2[] ={ 0x01, 0x72, 0x3E, 0xA9, 0xA8, 0xBC, 0x14, 0x00, 0x7C, 0x80, 0x09, 0xAD, 0xCB, 0x36, 0x11, 0x31, 0xD5, 0x42, 0x02, 0x36, 0x06, 0xFE, 0xA9, 0xB9, 0x2B, 0xAE, 0x97, 0x89};int testEccF2mPtMultkPtoQAff2(int fd){ unsigned char b1data[32], b2data[32], b3data[32]; int stat, tstat; ECC_POINT_REQ ecc_f2mmulkptoqReq; tstat = 0; memset(b1data, 0, 32); memset(b2data, 0, 32); memset(b3data, 0, 32); memset (&ecc_f2mmulkptoqReq, 0, sizeof(ecc_f2mmulkptoqReq)); printf("ECC F2M Point Multiply Affine Test #2\n"); ecc_f2mmulkptoqReq.opId = DPD_EC_F2M_AFF_LDCTX_kP_ULCTX; ecc_f2mmulkptoqReq.nDataBytes = 28; ecc_f2mmulkptoqReq.nData = (unsigned char *)ptpqAff2_MODULUS; ecc_f2mmulkptoqReq.eDataBytes = 27; ecc_f2mmulkptoqReq.eData = (unsigned char *)ptpqAff2_e; ecc_f2mmulkptoqReq.buildDataBytes = 384; ecc_f2mmulkptoqReq.buildData = (unsigned char *)ptpqAff2_builddata; ecc_f2mmulkptoqReq.b1DataBytes = 32; ecc_f2mmulkptoqReq.b1Data = b1data; ecc_f2mmulkptoqReq.b2DataBytes = 32; ecc_f2mmulkptoqReq.b2Data = b2data; ecc_f2mmulkptoqReq.b3DataBytes = 32; ecc_f2mmulkptoqReq.b3Data = b3data; stat = putKmem(fd, ptpqAff2_MODULUS, &ecc_f2mmulkptoqReq.nData, ecc_f2mmulkptoqReq.nDataBytes); if (stat) return -1; stat = putKmem(fd, ptpqAff2_e, &ecc_f2mmulkptoqReq.eData, ecc_f2mmulkptoqReq.eDataBytes); if (stat) { freeKmem(fd, &ecc_f2mmulkptoqReq.nData); return -1; } stat = putKmem(fd, ptpqAff2_builddata, &ecc_f2mmulkptoqReq.buildData, ecc_f2mmulkptoqReq.buildDataBytes); if (stat) { freeKmem(fd, &ecc_f2mmulkptoqReq.nData); freeKmem(fd, &ecc_f2mmulkptoqReq.eData); return -1; } stat = putKmem(fd, NULL, &ecc_f2mmulkptoqReq.b1Data, ecc_f2mmulkptoqReq.b1DataBytes); if (stat) { freeKmem(fd, &ecc_f2mmulkptoqReq.nData); freeKmem(fd, &ecc_f2mmulkptoqReq.eData); freeKmem(fd, &ecc_f2mmulkptoqReq.buildData); return -1; } stat = putKmem(fd, NULL, &ecc_f2mmulkptoqReq.b2Data, ecc_f2mmulkptoqReq.b2DataBytes); if (stat) { freeKmem(fd, &ecc_f2mmulkptoqReq.nData); freeKmem(fd, &ecc_f2mmulkptoqReq.eData); freeKmem(fd, &ecc_f2mmulkptoqReq.buildData); freeKmem(fd, &ecc_f2mmulkptoqReq.b1Data); return -1; } stat = putKmem(fd, NULL, &ecc_f2mmulkptoqReq.b3Data, ecc_f2mmulkptoqReq.b3DataBytes); if (stat) { freeKmem(fd, &ecc_f2mmulkptoqReq.nData); freeKmem(fd, &ecc_f2mmulkptoqReq.eData); freeKmem(fd, &ecc_f2mmulkptoqReq.buildData); freeKmem(fd, &ecc_f2mmulkptoqReq.b1Data); freeKmem(fd, &ecc_f2mmulkptoqReq.b2Data); return -1; } armCompletion(&ecc_f2mmulkptoqReq); stat = ioctl(fd, IOCTL_PROC_REQ, (int)&ecc_f2mmulkptoqReq); if (stat = waitCompletion("testPKHA(): ECC F2M Point Multiply Affine Test #2", stat, &ecc_f2mmulkptoqReq)) { freeKmem(fd, &ecc_f2mmulkptoqReq.nData); freeKmem(fd, &ecc_f2mmulkptoqReq.eData); freeKmem(fd, &ecc_f2mmulkptoqReq.buildData); freeKmem(fd, &ecc_f2mmulkptoqReq.b1Data); freeKmem(fd, &ecc_f2mmulkptoqReq.b2Data); freeKmem(fd, &ecc_f2mmulkptoqReq.b3Data); } getKmem(fd, b1data, &ecc_f2mmulkptoqReq.b1Data, ecc_f2mmulkptoqReq.b1DataBytes); getKmem(fd, b2data, &ecc_f2mmulkptoqReq.b2Data, ecc_f2mmulkptoqReq.b2DataBytes); getKmem(fd, b3data, &ecc_f2mmulkptoqReq.b3Data, ecc_f2mmulkptoqReq.b3DataBytes); freeKmem(fd, &ecc_f2mmulkptoqReq.nData); freeKmem(fd, &ecc_f2mmulkptoqReq.eData); freeKmem(fd, &ecc_f2mmulkptoqReq.buildData); freeKmem(fd, &ecc_f2mmulkptoqReq.b1Data); freeKmem(fd, &ecc_f2mmulkptoqReq.b2Data); freeKmem(fd, &ecc_f2mmulkptoqReq.b3Data); if (memcmp(b1data, ptpqAff2_exp_b1, 28) != 0) { printf("ECC F2M Point Multiply Affine Test #2 - b1 output data mismatch:\n"); dumpm(b1data, 28); tstat = -1; } if (memcmp(b2data, ptpqAff2_exp_b2, 28) != 0) { printf("ECC F2M Point Multiply Affine Test #2 - b2 output data mismatch:\n"); dumpm(b2data, 28); tstat = -1; } return(tstat);}static const unsigned char fppqProj_MODULUS[] ={ 0xed, 0xbe, 0x63, 0xac, 0x07, 0xf2, 0x60, 0x10, 0xfb, 0x91, 0xc1, 0x5f, 0x9e, 0x5d, 0x75, 0xca, 0x39, 0x3d, 0x73, 0x6b}; static const unsigned char fppqProj_e[] ={ 0x02, 0x72, 0x27, 0x96, 0x6b, 0x6b, 0x9f, 0x53, 0x84, 0x1f, 0x7b, 0x03, 0x2b, 0x2f, 0xa9, 0x30, 0x35, 0x28, 0xb2, 0xf2}; static const unsigned char fppqProj_builddata[] ={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x34, 0x60, 0x37, 0x7d, 0x80, 0xa4, 0x91, 0xae, 0x4a, 0x06, 0x9f, 0xcf, 0x1c, 0xcf, 0xf3, 0x7a, 0xe0, 0x72, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -