⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ccmp.c

📁 freescale ppc sec2加解密单元驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
    0x8f, 0xd2, 0x19, 0xd7, 0xdb, 0xdd, 0xc0, 0xc8,    0xe7, 0xf4, 0xc7, 0x9d, 0x20, 0x7e, 0x0d, 0xa4,    0xe7, 0x74, 0x87, 0xef, 0xba, 0xba, 0xf0, 0xbe,    0x29, 0x12, 0xc9, 0xe9, 0x62, 0x3b, 0xe3, 0x36,    0x38, 0xed, 0x35, 0x92, 0xd9, 0xef, 0xbf, 0xf0,    0x24, 0x4e, 0x09, 0xfa, 0xa0, 0xbd, 0xab, 0x22,    0xbd, 0x7b, 0xdb, 0x9f, 0x56, 0x26, 0x74, 0x4b,    0x96, 0x4a, 0x53, 0x57, 0xa2, 0xc6, 0x2e, 0x94,    0x2c, 0x4a, 0xbb, 0x00, 0x76, 0x1f, 0x67, 0x48,    0x90, 0xcb, 0x8c, 0xbe, 0xc4, 0x77, 0x2a, 0xdf,    0x5b, 0xe5, 0x54, 0x07, 0xa9, 0x4c, 0xeb, 0xac,    0x9c, 0x13, 0x19, 0x14, 0x64, 0x85, 0xd3, 0xef,    0x47, 0x28, 0xed, 0x5f, 0xfd, 0xcd, 0x6d, 0x8f,    0x9f, 0x72, 0xaa, 0x02, 0x68, 0xc3, 0x6e, 0xb9,    0x43, 0x22, 0x91, 0x09, 0x0f, 0x29, 0x1e, 0xab,    0x0d, 0x0d, 0xae, 0x43, 0x0b, 0x23, 0xa7, 0x63,    0x48, 0xf2, 0xe1, 0x58, 0x21, 0xf0, 0x6f, 0xc0,    0x8c, 0xbf, 0xba, 0xe0, 0x8d, 0xdf, 0xfd, 0x91,    0xe1, 0xc2, 0x93, 0x77, 0x42, 0xc7, 0x94, 0xb4,    0x0d, 0xa6, 0xf5, 0x26, 0xb1, 0xf2, 0x52, 0x23,    0xf4, 0x27, 0xd4, 0x56, 0x6f, 0xa6, 0xf6, 0x28,    0x89, 0x89, 0xe1, 0xe6, 0x32, 0xa4, 0x51, 0x67,    0xfe, 0x30, 0xb8, 0x25, 0x24, 0x67, 0x93, 0xac,    0x1e, 0x1b, 0x21, 0xb2, 0x92, 0x78, 0x66, 0xf4,    0xc2, 0xee, 0xe1, 0xd0, 0x21, 0x83, 0xe5, 0x8e,    0x4e, 0x36, 0x6c, 0xfa, 0xd5, 0xc7, 0x65, 0x96,    0x21, 0x42, 0xa1, 0x7f, 0xeb, 0xd2, 0xbb, 0x48,    0x19, 0x38, 0x3e, 0xb0, 0x9f, 0xb6, 0x4f, 0x21,    0x25, 0xcf, 0xe6, 0xc7, 0x50, 0x9d, 0x5c, 0xcb,    0xa2, 0x50, 0x81, 0x32, 0x85, 0x90, 0x03, 0x01,    0x25, 0xa0, 0x06, 0x39, 0x5a, 0x17, 0xf3, 0x0d,    0x35, 0x19, 0x32, 0xc7, 0x24, 0x25, 0xf6, 0x58,    0x8c, 0x1a, 0xe9, 0xf7, 0xfc, 0xcc, 0xf2, 0x9b,    0x80, 0x21, 0x4e, 0x11, 0x5b, 0x4b, 0xf0, 0xab,    0x07, 0xdd, 0xc9, 0xb2, 0x90, 0xa6, 0x3e, 0x3d,    0x14, 0x0c, 0x64, 0x6b, 0x4f, 0x57, 0xab, 0x5f,    0xc8, 0x5a, 0x68, 0xb1, 0xa7, 0x3f, 0x2b, 0xe9,    0x5f, 0x23, 0x35, 0x57, 0xbf, 0xc3, 0xfd, 0xb1,    0x14, 0xfa, 0x6b, 0x50, 0x06, 0x7f, 0x61, 0x4d,    0x3e, 0xd6, 0x00, 0x7c, 0x79, 0xb1, 0xba, 0xa0,    0x9c, 0xda, 0x17, 0xfc, 0x78, 0x8c, 0x57, 0xb9,    0x10, 0x22, 0xd2, 0x0a, 0xfe, 0x2d, 0x87, 0xf8,    0x9e, 0x5c, 0x8c, 0x19, 0x77, 0x98, 0x66, 0x5d,    0x8f, 0x6a, 0xb7, 0xe2, 0xe6, 0x91, 0xdb, 0x35,    0x83, 0xc2, 0x53, 0x9f, 0x88, 0x9a, 0x5e, 0x61,    0xbb, 0x21, 0xbe, 0x18, 0xd3, 0xdc, 0x3a, 0xef,    0x99, 0x1f, 0xb6, 0x08, 0xcd, 0xef, 0x46, 0xa8,    0x7c, 0xa2, 0x01, 0x60, 0x1c, 0xf1, 0x52, 0x7a,    0x50, 0x61, 0x56, 0xfa, 0x40, 0x28, 0xd7, 0x58,    0xc6, 0x49, 0xff, 0xd7, 0x78, 0xdb, 0xf6, 0x7f,    0xbd, 0x40, 0x36, 0xa4, 0x98, 0x0f, 0xdf, 0xc3,    0xf1, 0x41, 0x33, 0x1c, 0x6d, 0x04, 0xd7, 0x84,    0xfd, 0x96, 0xed, 0x8b, 0x47, 0xa4, 0x5d, 0xc1,    0x7e, 0x17, 0x74, 0x69, 0xa0, 0x88, 0xe1, 0x43,    0x85, 0xa7, 0x35, 0x25, 0x86, 0x7f, 0x26, 0xb7,    0xab, 0xe9, 0xcf, 0x74, 0x78, 0x03, 0x83, 0x3c,    0x81, 0xbe, 0x14, 0xb9, 0x3b, 0x3b, 0x33, 0xf4,    0xcd, 0x23, 0x83, 0xd3, 0x72, 0xeb, 0xaf, 0x4a,    0xfe, 0xa7, 0xc5, 0x82, 0xee, 0x95, 0x0d, 0x12,    0x01, 0x6c, 0x17, 0x55, 0x66, 0xdb, 0x88, 0x3d,    0x95, 0x34, 0x09, 0x7a, 0x50, 0xc9, 0x9c, 0xce,    0x0b, 0x0e, 0x8f, 0x1b, 0x11, 0xdb, 0xfb, 0x4d,    0x30, 0x2b, 0xad, 0x9c, 0x2c, 0x9f, 0xa5, 0x72,    0x27, 0xc8, 0x82, 0x5c, 0x75, 0x4a, 0xda, 0x7d,    0xb3, 0xf3, 0x2d, 0x22, 0xf5, 0x1c, 0xda, 0x9f,    0xc5, 0x80, 0x59, 0x4f, 0x34, 0x2d, 0x1d, 0x6a,    0x49, 0xf1, 0x5b, 0xc1, 0x33, 0x71, 0x8b, 0x54,    0xda, 0xc0, 0xa6, 0xdd, 0x05, 0x17, 0x6e, 0x7d,    0xf0, 0xd9, 0x1f, 0x6d, 0xa8, 0x5a, 0x63, 0x81,    0x29, 0x09, 0x0a, 0x96, 0xd9, 0xcf, 0x29, 0x87,    0x78, 0x4d, 0x20, 0x64, 0x16, 0x3d, 0xcc, 0x71,    0x07, 0x0f, 0x64, 0x41, 0xe2, 0x3f, 0x40, 0xa9,    0x77, 0xfe, 0x64, 0x43, 0x02, 0xbc, 0x31, 0x7f,    0xd6, 0x24, 0x79, 0xd0, 0x69, 0xab, 0x11, 0x8b,    0x0f, 0xd3, 0x78, 0xc3, 0xe5, 0xcf, 0xbd, 0xb8,    0x28, 0xe7, 0xd3, 0xa1, 0xf0, 0x69, 0xc0, 0x37,    0x4c, 0x1f, 0xc6, 0x2a, 0xe6, 0xd8, 0x31, 0x24,    0x11, 0xbc, 0x70, 0x67, 0x95, 0x75, 0x72, 0xb1,    0x57, 0x45, 0xa9, 0x43, 0xec, 0xfd, 0xf9, 0x50,    0x50, 0xef, 0x70, 0x16, 0xcd, 0xb4, 0x73, 0x8c,    0x10, 0xc5, 0x32, 0xed, 0xef, 0xf1, 0x2e, 0x4b,    0xc3, 0x84, 0xf2, 0x2f, 0xab, 0xf5, 0xe6, 0x1a,    0x48, 0xe8, 0x05, 0x88, 0x00, 0x00, 0x00, 0x00};/* 32 bytes */static const unsigned char expect_ctx_out[] ={    /*  computed mac out */    0x4f, 0x4a, 0xf3, 0x3f, 0x10, 0x29, 0xfc, 0xb2,    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,    /* mic out */    0x46, 0x39, 0xdc, 0x6c, 0x8e, 0x9c, 0xf4, 0xb9,    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};static unsigned char cipher[976 + 32];int testccmp(int fd){    CCMP_REQ CcmpReq;    int status, device = 0;            memset(&CcmpReq, 0, sizeof(CcmpReq));    CcmpReq.opId           = DPD_802_11_CCMP_OUTBOUND;    /* inputs */    CcmpReq.ctxBytes       = 56;    CcmpReq.context        = (unsigned char *)context;    CcmpReq.keyBytes       = 16;    CcmpReq.keyData        = (unsigned char *)key;    CcmpReq.AADBytes       = 32;    CcmpReq.AADData        = (unsigned char *)AAheader;    CcmpReq.FrameDataBytes = 972;    CcmpReq.FrameData      = (unsigned char *)plaintext;    /* outputs */    CcmpReq.cryptDataBytes = 972;    CcmpReq.cryptDataOut   = cipher;    CcmpReq.MICBytes       = 32;    CcmpReq.MICData        = &cipher[CcmpReq.cryptDataBytes];    status = putKmem(fd, context, &CcmpReq.context, CcmpReq.ctxBytes);    if (status)        return status;        status = putKmem(fd, key, &CcmpReq.keyData,  CcmpReq.keyBytes);    if (status) {        freeKmem(fd, &CcmpReq.context);        return status;    }    status = putKmem(fd, plaintext, &CcmpReq.FrameData,  CcmpReq.FrameDataBytes);    if (status) {        freeKmem(fd, &CcmpReq.context);        freeKmem(fd, &CcmpReq.keyData);        return status;    }    status = putKmem(fd, AAheader, &CcmpReq.AADData,  CcmpReq.AADBytes);    if (status) {        freeKmem(fd, &CcmpReq.context);        freeKmem(fd, &CcmpReq.keyData);        freeKmem(fd, &CcmpReq.FrameData);        return status;    }    status = putKmem(fd, NULL, &CcmpReq.MICData,  CcmpReq.MICBytes);    if (status) {        freeKmem(fd, &CcmpReq.context);        freeKmem(fd, &CcmpReq.keyData);        freeKmem(fd, &CcmpReq.FrameData);        freeKmem(fd, &CcmpReq.AADData);        return status;    }    status = putKmem(fd, NULL, &CcmpReq.cryptDataOut,  CcmpReq.cryptDataBytes);    if (status) {        freeKmem(fd, &CcmpReq.context);        freeKmem(fd, &CcmpReq.keyData);        freeKmem(fd, &CcmpReq.FrameData);        freeKmem(fd, &CcmpReq.AADData);        freeKmem(fd, &CcmpReq.MICData);        return status;    }    armCompletion(&CcmpReq);    status = ioctl(fd, IOCTL_PROC_REQ, (int)&CcmpReq);    if (status = waitCompletion("testccmp(): CCMP packet test", status, &CcmpReq))    {        freeKmem(fd, &CcmpReq.context);        freeKmem(fd, &CcmpReq.keyData);        freeKmem(fd, &CcmpReq.FrameData);        freeKmem(fd, &CcmpReq.AADData);        freeKmem(fd, &CcmpReq.MICData);        freeKmem(fd, &CcmpReq.cryptDataOut);        return -1;    }    getKmem(fd, cipher, &CcmpReq.cryptDataOut, CcmpReq.cryptDataBytes);    getKmem(fd, &cipher[CcmpReq.cryptDataBytes], &CcmpReq.MICData, CcmpReq.MICBytes);        freeKmem(fd, &CcmpReq.context);    freeKmem(fd, &CcmpReq.keyData);    freeKmem(fd, &CcmpReq.FrameData);    freeKmem(fd, &CcmpReq.AADData);    freeKmem(fd, &CcmpReq.MICData);    freeKmem(fd, &CcmpReq.cryptDataOut);    if (memcmp((unsigned char *)expected_out, cipher, CcmpReq.cryptDataBytes) != 0)    {        printf("PAYLOAD OUT DOES NOT MATCH:\n");        dumpm(cipher, CcmpReq.cryptDataBytes);        return -1;    }    printf("Payload Out Matches Expected\n");    if (memcmp((unsigned char *)expect_ctx_out, &cipher[CcmpReq.cryptDataBytes], 16) != 0)    {        printf("Computed MAC OUT DOES NOT MATCH:\n");        dumpm(&cipher[CcmpReq.cryptDataBytes], 16);        return -1;    }    printf("Computed MAC Matches Expected\n");    if (memcmp((unsigned char *) &expect_ctx_out[16], &cipher[CcmpReq.cryptDataBytes + 16], 16) != 0)    {                   printf("MIC OUT DOES NOT MATCH:\n");        dumpm(&cipher[CcmpReq.cryptDataBytes + 16], 16);        return -1;    }    printf ("MIC OUT Matches Expected\n");        return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -