× 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 everyone
I am hoping someone will take pity
I have looked at this web page
http://www.iprodeveloper.com/forums/aft/134541
Where Scott Klement is answering someone's question in utilizing the api Qc3CalculateHMAC
I have written a simple program to try and get the code working (and failing miserably)
Here is the code
The error that happens (from the joblog) is
The key string length is not valid.
Once I have this working, I need to utilize SHA-256 instead of SHA-1
As always any and all help is gratefully accepted.

km003H Bnddir('TOOLBIND': 'MFGBIND')
H dftactgrp(*no) actgrp('QILE')
H option(*srcstmt:*nodebugio)
? * PROGRAM STATUS DATA STRUCTURE
? /copy copybook,psds
?
? ** PROTOTYPES
**** Prototype definitions using source file QSRVSRC
?
? *---------------------------------------------------------------------
? * Stand Alone Fields - TOP
? *---------------------------------------------------------------------
d SecretSharedKey...
d s 4 inz('xxxx')
d binaryHMAC s 20a
d SHA_1 c const(2)
D DataLen s 10i 0
d dataToHash s 500a
? *---------------------------------------------------------------------
? * Stand Alone Fields - BOTTOM
? *---------------------------------------------------------------------
?
D ErrorCode DS qualified
D bytesProv 10i 0 inz(0)
D bytesAvail 10i 0 inz(0)

D WsErrorCode DS qualified
D bytesProv 10i 0 inz(0)
D bytesAvail 10i 0 inz(0)

D my_key DS qualified
D Type 10i 0 inz(SHA_1)
D Len 10i 0
D Fmt 1a inz('0')
D 3a
D Value 256a

D Qc3CalculateHMAC...
D pr extproc('Qc3CalculateHMAC')
D pinData 32767a const options(*varsize)
D pinDataLen 10i 0 const
D pinFormat 8a const
D palgDesc 10i 0 const
D palgDescFmt 8a const
D pkeyDesc 32767a const options(*varsize)
D pkeyDescFmt 8a const
D pcryptoProv 1a const
D pcryptoDev 10a const
D pHMAC 64a options(*varsize)
D pErrorCode 32767a options(*varsize)

? *****************************************************************
/free
//---------------------------------------------------------
// Calculate the SHA-1 HMAC hash
//---------------------------------------------------------

DataToHash = 'A1B2C3D4';
my_key.len = %size(SecretSharedKey);
my_key.value = SecretSharedKey;
DataLen = %size(DataToHash);
monitor;
Qc3CalculateHMAC( DataToHash
: DataLen
: 'DATA0100'
: SHA_1
: 'ALGD0500'
: my_key
: 'KEYD0200'
: '0'
: *blanks
: binaryHMAC
: ErrorCode );
on-error;
WsErrorCode = ErrorCode;
endmon;


? *inlr = '1';
return;
/end-free
Alan Shore
Programmer/Analyst, Direct Response
E:AShore@xxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill

-----Original Message-----
From: Alan Shore
Sent: Monday, January 14, 2013 5:49 PM
To: Midrange Systems Technical Discussion
Subject: RE: HMAC Calculation

How to use the API
Like I said previously, Scott had an example on the web, but I prefer a couple of examples.

Alan Shore
Programmer/Analyst, Direct Response
E:AShore@xxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Tim Bronski
Sent: Monday, January 14, 2013 5:47 PM
To: Midrange Systems Technical Discussion
Subject: Re: HMAC Calculation

Alan, are you looking to understand what a HMAC is or how to use the API?

On 1/14/2013 7:13 PM, Alan Shore wrote:
As part of new web service transaction, I have to supply a "Hex
encoded HMAC required for client authentication and message integrity
checks" with a shared secret used as the key.

Googling HMAC AS/400. I came across the Qc3CalculateHMAC API, but the
only web page that I have found is
http://www.iprodeveloper.com/forums/aft/134541
Where Scott Klement is responding to someone's question.
Don't get me wrong, Scott has probably forgotten WAAAY more than I know.
It's just that I prefer a couple of choices for me to read and
hopefully understand If anyone can supply any more info, as always, it
would be gratefully appreciated


Alan Shore
Programmer/Analyst, Direct Response
E:AShore@xxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill


Disclaimer: This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.

--
Need secure FTP? Forget PASE...get your FREE sFTP here www.arpeggiosoftware.com

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.