× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.