Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

AES-GCM example

jing_w_
Beginner
440 Views

Hi all,

anybody have a good example for AES_GCM encrypt and decrypt example? Can somebody tell me if there is one available?

Thanks a lot,

Jing

0 Kudos
3 Replies
Igor_A_Intel
Employee
440 Views

hello,

// ippgcm.cpp : Defines the entry point for the console application.

//

#include <stdio.h>

#include "ipp.h"

#include "ippcp.h"

 

 

int _tmain(int argc, _TCHAR* argv[])

{

IppsRijndael128GCMState *ctx;

IppStatus rc;

unsigned char thekey[16];

Ipp32u ctxsize;

IppStatus status ; //paf;

 

memset(thekey, 0, sizeof(thekey));

if( status = ippInit() )

printf( "%d = ippInit status\n", status ) ;

ippsRijndael128GCMGetSize(&ctxsize);

printf("ctxSize = %d\n", ctxsize);

ctx = (IppsRijndael128GCMState*) ippsMalloc_8u( ctxsize ) ;

rc = ippsRijndael128GCMInit(thekey, IppsRijndaelKey128, ctx);

printf("rc = %d\n", rc);

 

unsigned char data[2048];

unsigned char edata[2048];

 

unsigned char authdata[16];

unsigned char iv[8];

unsigned char tag[16];

rc = ippsRijndael128GCMEncryptMessage(thekey, IppsRijndaelKey128, iv, sizeof(iv), authdata, sizeof(authdata), data, edata, size, tag, sizeof(tag));

if (rc != 0) {

printf("Encrc = %d\n", rc);

}

int size = 1000;

rc = ippsRijndael128GCMStart(iv, sizeof(iv), authdata, sizeof(authdata), ctx);

if (rc != 0) {

printf("Encrc = %d\n", rc);

}

rc = ippsRijndael128GCMEncrypt(data, edata, size, ctx);

if (rc != 0) {

printf("Encrc = %d\n", rc);

}

rc = ippsRijndael128GCMGetTag(tag, sizeof(tag), ctx);

if (rc != 0) {

printf("Encrc = %d\n", rc);

}

ippsFree( ctx ) ;

return 0;

}

regards, Igor

0 Kudos
jing_w_
Beginner
440 Views

Thank you very much, lgor.

I check the document, said IppsRijndael128GCM* related functions are DEPRECATED.

Do you have example which is using ippsAES_GCM* functions?

I am using Cryptography for Intel® Integrated Performance Primitives 8.0 Library.

 

Thanks,

Jing

0 Kudos
Igor_A_Intel
Employee
440 Views

Hi Jing,

changing from Rijndael signature to AES is cosmetic one - I guess you can do this simple task yourself easily.

regards, Igor

0 Kudos
Reply