|
Hi Suren,
From what I've read about HMAC SHA1, a key is required. If you do not
provide a key, some implementations generate a random key for you. If
you want to be able to verify the hash, you'll need to save that key.
This is based on reading
https://stackoverflow.com/questions/27165107/check-hmac-sha1-without-key-in-c-sharp
and
https://stackoverflow.com/questions/25492833/what-key-is-used-by-openssl-command-for-hmac-if-key-is-not-passed-in-as-argume
In the latter, which is pretty old, it says that OpenSSL at that time,
did not require a key, but that according to a guy on the OpenSSL
mailing list, that was expected to change. The person answering the
question actually showed the OpenSSL source code that handles the key.
--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx<mailto:petercdow@xxxxxxxxx>
pdow@xxxxxxxxxxxxxx<mailto:pdow@xxxxxxxxxxxxxx> /
On 5/31/2024 4:45 PM, Suren K wrote:
Hi All,does
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
not reference a valid key context."for
Is it possible to calculate HMAC without a key or is the key mandatory
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<mailto: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<mailto: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<mailto: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.