- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I'm tring to write a simple code about the DES encypt in CBC mode.
I was only found the ippsDESEncyptECB sample code below.
It's works fine, and in this mode we don't need the initial vector parameter.
I don't know how to declare the parameter of initial vector, can anyone show me a example about the ippsDESEncryptCBC function?
#include
#include
#include "include/ipp.h"
int main() {
int ctxSize, i;
ippsDESGetSize(&ctxSize);
printf("ctxSize=%d\n", ctxSize);
const int desBlkSize = 8;
IppsDESSpec* pCtx = (IppsDESSpec*) malloc(ctxSize);
Ipp8u key[] = {0x01,0x2,0x3,0x4,0x5,0x6,0x7,0x8};
ippsDESInit(key, pCtx);
Ipp8u ptext[] = {"quick brown fox jupm over lazy dog"};
printf("original string:%s\n", ptext);
printf("size of ptext=%d, ~desBlkSize=%d, size=%d\n", sizeof(ptext), ~(desBlkSize-1), ((sizeof(ptext)+desBlkSize-1) &~(desBlkSize-1)));
Ipp8u ctext[(sizeof(ptext)+desBlkSize-1) &~(desBlkSize-1)];
ippsDESEncryptECB(ptext, ctext, sizeof(ctext),
pCtx,
IppsCPPaddingNONE);
for(i=0;i printf("%x", ctext);
printf("\n");
Ipp8u rtext[sizeof(ctext)];
ippsDESDecryptECB(ctext, rtext, sizeof(ctext),
pCtx,
IppsCPPaddingNONE);
for(i=0;i printf("%c", rtext);
printf("\n");
return 0;
}
best regards.
I'm tring to write a simple code about the DES encypt in CBC mode.
I was only found the ippsDESEncyptECB sample code below.
It's works fine, and in this mode we don't need the initial vector parameter.
I don't know how to declare the parameter of initial vector, can anyone show me a example about the ippsDESEncryptCBC function?
#include
#include
#include "include/ipp.h"
int main() {
int ctxSize, i;
ippsDESGetSize(&ctxSize);
printf("ctxSize=%d\n", ctxSize);
const int desBlkSize = 8;
IppsDESSpec* pCtx = (IppsDESSpec*) malloc(ctxSize);
Ipp8u key[] = {0x01,0x2,0x3,0x4,0x5,0x6,0x7,0x8};
ippsDESInit(key, pCtx);
Ipp8u ptext[] = {"quick brown fox jupm over lazy dog"};
printf("original string:%s\n", ptext);
printf("size of ptext=%d, ~desBlkSize=%d, size=%d\n", sizeof(ptext), ~(desBlkSize-1), ((sizeof(ptext)+desBlkSize-1) &~(desBlkSize-1)));
Ipp8u ctext[(sizeof(ptext)+desBlkSize-1) &~(desBlkSize-1)];
ippsDESEncryptECB(ptext, ctext, sizeof(ctext),
pCtx,
IppsCPPaddingNONE);
for(i=0;i
printf("\n");
Ipp8u rtext[sizeof(ctext)];
ippsDESDecryptECB(ctext, rtext, sizeof(ctext),
pCtx,
IppsCPPaddingNONE);
for(i=0;i
printf("\n");
return 0;
}
best regards.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
according our expert you may find similar sample in IPP documentation, see"Example 2-2 AES Encryption and Decryption"
Regards,
Vladimir
according our expert you may find similar sample in IPP documentation, see"Example 2-2 AES Encryption and Decryption"
Regards,
Vladimir

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page