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



Yivi,

There isn't a magic bullet page to read, but all APIs tend to enjoy it most
when the variables they are using are initialized. Particularly the
"Reserved" variables which prefer to be all X'00' rather than blanks. 
When in doubt, always set your structures to X'00' or some other known
API-friendly value before calling the API or MI instruction. While not doing
so may get you a good result the first time or two you run the MI inst or
API, you will eventually have an issue "for no apparent reason".
Bottom line, always make certain things are properly initialized, and when
something happens, assume you did something wrong, like not initialize or
set something properly. 

-Bob Cozzi
www.RPGxTools.com
RPG xTools - Enjoy programming again.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Yivi
Sent: Friday, December 23, 2005 2: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/CIPHER
.htm
but
it didn't help.

Anyone has a deeper insight on this?

Regards,

I.-

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.