× 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.



I do a couple of things differently.  I will only describe if you are
passing one piece of information at a time.  We allow for multiple calls
to add to the cipher call.  The process should be like this:

1. Call the cipher routine with the data using the control character of
x'00'
2. Call the cipher routine with a length of 0 for the data and the
control with a value of x'03'

When you call the cipher routine the second time, the hash will be
returned.

Two more things...  Make sure you allocate the memory for the data to be
hashed and  release it when you are done.  I have found inconsistent
results if the memory for the data being sent is not allocated before
calling the cipher routine.  Finally, I call the procedure XLATEB
(translate bytes) before calling the cipher call.

DTo819            s            256A 

 *                                                      
DConvert          PR                  EXTPROC('_XLATEB')
D                                 *   VALUE             
D                                 *   VALUE             
D                               10u 0 VALUE              

callp Convert(message      
              :%ADDR(to819)
              :length);    


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Yivi
Sent: Friday, December 23, 2005 3:14 AM
To: RPG programming on the AS400 / iSeries
Subject: Cipher MI instruction (MD5 function)

Hi there,

I am trying to to use the MD5 function to store/check passwords, but
things aren't working as expected. Or, to put it better, they work as
expected but only once.

The second time the cipher function is invoked in the same program
execution, it will generate a MCH5601 exception, and be done with it.
First time works perfectly, but the second will always fail.

I declare the procedures I am using:

Dcvthc PR EXTPROC('cvthc')
D 1
D 1
D 10i 0 VALUE

DCipher PR EXTPROC('_CIPHER')
D * VALUE
D * VALUE
D * VALUE
I declare the control ds and work variables (as seen in
http://archive.midrange.com/midrange-l/200006/msg01334.html)

DControls     DS
D Function      5i  0 inz(5)
D HashAlg       1     inz(x'00')
D Sequence      1     inz(x'00')
D DataLngth     10i 0
D Unused        8     inz(*LOVAL)
D HashCtxPtr    *     inz(%addr(HashWorkArea))
DHashWorkArea S 96    inz(*LOVAL)
DDestinoHex   S 16
DDestinoChr   S 32
DDestinoPtr   S *     inz(%addr(DestinoHex))
DFuentePtr    S *     inz(%addr(Fuente))
DFuente       S 8
I check against user provided password (CONTRA) against the one stored (
USER.CONTRA, already stored in DB)

dow CONTRA <> USER.CONTRA;
  exFmt AskForPass;
  fuente    = CONTRA;
  DataLngth = %len(%trimr(fuente));
  Cipher(%addr(DestinoPtr) : %addr(Controls) : %addr(FuentePtr));
  CVTHC(DestinoChr : DestinoHex :%size(DestinoChr)); endDo;

If the user puts his/her password correctly in the first attempt, things
go on and everything is nice. Otherwise, he gets another chance, and
then the program will fail (right or wrong password, it doesn't matter)
giving error message MCH5601, reason code X'0000'.

I tried to find clues at
http://publib.boulder.ibm.com/iseries/v5r1/ic2924/tstudio/tech_ref/mi/CI
PHER.htm
but
it didn't help.

Anyone has a deeper insight on this?

Regards,

I.-
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.



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.