📄 morepkhatest.c
字号:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0x0a, 0xd5, 0xd3, 0xde, 0x97, 0x7a, 0x76, 0xdd, 0xc1, 0x7b, 0xb6, 0xea, 0xb0, 0xc8, 0x2b, 0x7f, 0x10, 0x8e, 0xf4, 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, 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 fppqProj_exp_b3[] ={ 0x2c, 0xb6, 0x98, 0x6e, 0x6b, 0xd7, 0x18, 0x23, 0x9d, 0x0a, 0x50, 0xc8, 0x4a, 0xa4, 0xdd, 0xdb, 0x79, 0x7a, 0x42, 0x6c}; static const unsigned char fppqProj_exp_b2[] ={ 0xa9, 0x73, 0x41, 0xb8, 0x2c, 0x75, 0x73, 0x51, 0x99, 0xc6, 0xff, 0x74, 0x34, 0x97, 0xfe, 0x29, 0xfe, 0x2b, 0x33, 0x47}; static const unsigned char fppqProj_exp_b1[] ={ 0x33, 0x3e, 0x1c, 0xb8, 0x18, 0xc0, 0x19, 0xdf, 0xbd, 0x30, 0x80, 0xa2, 0xb3, 0x5b, 0x47, 0x66, 0x39, 0x8c, 0xbb, 0xae};int testEccFpPtMultkPtoQProj(int fd){ unsigned char b1data[32], b2data[32], b3data[32]; int stat, tstat; ECC_POINT_REQ ecc_mulkptoqReq; tstat = 0; memset(b1data, 0, 32); memset(b2data, 0, 32); memset(b3data, 0, 32); memset (&ecc_mulkptoqReq, 0, sizeof(ecc_mulkptoqReq)); printf("ECC Point Multiply Projective Test\n"); ecc_mulkptoqReq.opId = DPD_EC_FP_PROJ_LDCTX_kP_ULCTX; ecc_mulkptoqReq.nDataBytes = 20; ecc_mulkptoqReq.nData = (unsigned char *)fppqProj_MODULUS; ecc_mulkptoqReq.eDataBytes = 20; ecc_mulkptoqReq.eData = (unsigned char *)fppqProj_e; ecc_mulkptoqReq.buildDataBytes = 384; ecc_mulkptoqReq.buildData = (unsigned char *)fppqProj_builddata; ecc_mulkptoqReq.b1DataBytes = 32; ecc_mulkptoqReq.b1Data = b1data; ecc_mulkptoqReq.b2DataBytes = 32; ecc_mulkptoqReq.b2Data = b2data; ecc_mulkptoqReq.b3DataBytes = 32; ecc_mulkptoqReq.b3Data = b3data; stat = putKmem(fd, fppqProj_MODULUS, &ecc_mulkptoqReq.nData, ecc_mulkptoqReq.nDataBytes); if (stat) return -1; stat = putKmem(fd, fppqProj_e, &ecc_mulkptoqReq.eData, ecc_mulkptoqReq.eDataBytes); if (stat) { freeKmem(fd, &ecc_mulkptoqReq.nData); return -1; } stat = putKmem(fd, fppqProj_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 F2M Point Multiply Affine Test #2", 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, fppqProj_exp_b1, 20) != 0) { printf("ECC Point Multiply Projective Test - b1 output data mismatch:\n"); dumpm(b1data, 20); tstat = -1; } if (memcmp(b2data, fppqProj_exp_b2, 20) != 0) { printf("ECC Point Multiply Projective Test - b2 output data mismatch:\n"); dumpm(b2data, 20); tstat = -1; } if (memcmp(b3data, fppqProj_exp_b3, 20) != 0) { printf("ECC Point Multiply Projective Test - b3 output data mismatch:\n"); dumpm(b3data, 20); tstat = -1; } return(tstat);}static const unsigned char p2qf2mProj_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 p2qf2mProj_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 p2qf2mProj_builddata[] ={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a0 */ 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, /* a1 */ 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, /* a2 */ 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, /* a3 */ 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, /* b0 */ 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, /* b1 */ 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 p2qf2mProj_exp_b1[] ={ 0x02, 0x75, 0x58, 0x7c, 0x9e, 0x6f, 0xf5, 0xc1, 0x36, 0x71, 0xa5, 0x8b, 0x2f, 0x50, 0x1e, 0x7e, 0xe5, 0xf1, 0x98, 0xd9, 0x44, 0x00, 0xb2, 0x6d, 0x47, 0xbd, 0x1a, 0x1f}; static const unsigned char p2qf2mProj_exp_b2[] ={ 0x03, 0x05, 0x4d, 0xb9, 0x7a, 0x24, 0x72, 0x2d, 0x32, 0xbe, 0x9e, 0xeb, 0x28, 0xca, 0x77, 0xa7, 0xbb, 0x01, 0xee, 0x69, 0xdc, 0xa6, 0x19, 0x5c, 0xfb, 0xc0, 0xce, 0xe4};static const unsigned char p2qf2mProj_exp_b3[] ={ 0x00, 0x54, 0x20, 0x08, 0x2e, 0x28, 0xe3, 0x6f, 0xb4, 0xef, 0x7c, 0x3b, 0xb8, 0x21, 0x0f, 0x97, 0x15, 0xc2, 0xd6, 0xc6, 0x49, 0x06, 0x22, 0x41, 0x57, 0xc8, 0xf4, 0xf2};int testEccMultkPtoQf2mProj(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 Projective Test\n"); ecc_f2mmulkptoqReq.opId = DPD_EC_F2M_PROJ_LDCTX_kP_ULCTX; ecc_f2mmulkptoqReq.nDataBytes = 28; ecc_f2mmulkptoqReq.nData = (unsigned char *)p2qf2mProj_MODULUS; ecc_f2mmulkptoqReq.eDataBytes = 27; ecc_f2mmulkptoqReq.eData = (unsigned char *)p2qf2mProj_e; ecc_f2mmulkptoqReq.buildDataBytes = 384; ecc_f2mmulkptoqReq.buildData = (unsigned char *)p2qf2mProj_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, p2qf2mProj_MODULUS, &ecc_f2mmulkptoqReq.nData, ecc_f2mmulkptoqReq.nDataBytes); if (stat) return -1; stat = putKmem(fd, p2qf2mProj_e, &ecc_f2mmulkptoqReq.eData, ecc_f2mmulkptoqReq.eDataBytes); if (stat) { freeKmem(fd, &ecc_f2mmulkptoqReq.nData); return -1; } stat = putKmem(fd, p2qf2mProj_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 Projective Test", 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, p2qf2mProj_exp_b1, 28) != 0) { printf("ECC F2M Point Multiply Projective Test - b1 output data mismatch:\n"); dumpm(b1data, 28); tstat = -1; } if (memcmp(b2data, p2qf2mProj_exp_b2, 28) != 0) { printf("ECC F2M Point Multiply Projective Test - b2 output data mismatch:\n"); dumpm(b2data, 28); tstat = -1; } if (memcmp(b3data, p2qf2mProj_exp_b3, 28) != 0) { printf("ECC F2M Point Multiply Projective Test - b3 output data mismatch:\n"); dumpm(b3data, 28); tstat = -1; } return(tstat);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -