AES-GCM example

AES-GCM example

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,


4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


// 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 ) ;


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

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.




Hi Jing,

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

regards, Igor

Leave a Comment

Please sign in to add a comment. Not a member? Join today