|
Hi All,
I am trying to calculate HMAC for text data using (QC3CALHM,
Qc3CalculateHMAC) API without a key using the SHA1 algorithm.
When I Pass the blank Key I get the error as "CPF9DF5 The key context is
not found or was previously destroyed."
When I pass Null Key I get the error as "CPF9DF4 The key context token does
not reference a valid key context."
Is it possible to calculate HMAC without a key or is the key mandatory for
calculating HMAC?
Any help will be very much appreciated.
Code I used for the reference
/copy QSYSINC/QRPGLESRC,QC3CCI
//‚API Error Datastructure
dcl-ds ApiError qualified inz;
BytesProvided int(10:0) inz(%size(ApiError));
BytesAvailable int(10:0);
MessageId char(7);
Reserved char(1);
MessageData char(3000);
end-ds;
dcl-pr Pr_CalculateHMAC extpgm('QC3CALHM');
InputData char(500) options(*varsize);
InputLength int(10) const;
Format char(8) const;
AlgDsc char(20) options(*varsize);
AlgFmt char(8) const;
KeyDsc char(20) options(*varsize);
KeyFmt char(8) const;
Crypt char(1) const;
Cryptdev char(10) const;
HMAC char(64) options(*varsize);
CalHashErrC likeds(ApiError) options(*nopass: *varsize);
end-pr;
//‚Prototype for EBCDIC to ASCII
dcl-pr QDCXLATE extpgm('QDCXLATE');
len packed(5:0) const;
data char(32702) options(*varsize);
table char(10) const;
end-pr;
data = 'abcd';
//‚Convert the EBCDIC to ASCII
len = %len(%trimr(data));
QDCXLATE(len: data: 'QTCPASC');
QC3HA = 2;
KeyDsc = *allx'00';
//‚Generate HMAC
Pr_CalculateHMAC(data:%len(%trim(data)):'DATA0100':QC3D0500:
'ALGD0500':KeyDsc:'KEYD0100':'0':' ':hmac:
ApiError);
Regards,
Suren
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.