md5ibm-midrangecobol

Using the routine CSNBOWH on IBM I - MD5


I am trying to run the routine CSNBOWH on IBM I using COBOL ILE on the pubblic server PUB400. To do the call I used various definition taken from Internet/manuals. This is the last one I used:

     01  HASHING-TEXT.                                           
         03 WK-RETURN-CODE          PIC S9(9)  COMP-5 VALUE ZERO.
         03 REASON-CODE             PIC S9(9)  COMP-5 VALUE ZERO.
         03 EXIT-DATA-LENGTH        PIC S9(9)  COMP-5 VALUE 4.   
         03 EXIT-DATA               PIC X(4)   VALUE SPACE.      
         03 RULE-ARRAY-COUNT        PIC S9(9)  COMP-5 VALUE 1.   
         03 RULE-ARRAY              PIC X(8)   VALUE 'MD5'.      
         03 TEXT-LENGTH             PIC S9(9)  COMP-5 VALUE 64.  
         03 TEXT-MESSAGE            PIC X(64)  VALUE SPACE.      
         03 CHAINING-VECTOR-LENGTH  PIC S9(9)  COMP-5 VALUE 128. 
         03 CHAINING-VECTOR         PIC X(128) VALUE SPACE.      
         03 HASH-LENGTH             PIC S9(9)  COMP-5 VALUE 16.  
         03 HASH                    PIC X(16).                   


 CALL  'CSNBOWH'  USING     WK-RETURN-CODE         
                             REASON-CODE           
                             EXIT-DATA-LENGTH      
                             EXIT-DATA             
                             RULE-ARRAY-COUNT      
                             RULE-ARRAY            
                             TEXT-LENGTH           
                             TEXT-MESSAGE          
                             CHAINING-VECTOR-LENGTH
                             CHAINING-VECTOR       
                             HASH-LENGTH           
                             HASH.                 

However I always get the message MCH3401 "The message text for 'MCH3401' follows: 'Cannot resolve to object CSNBOWH. Type and Subtype X'0201' Authority X'0000'.'"

What you think I don't have the access to this routine? I try to use also the routines CSNBOWH1 CSNEOWH and CSNEOWH1 with the same result.

I read various manuals on IBM platform and I was thinking that I could use CSNBOWH routine to do hashing. The manual are the following: https://www.ibm.com/docs/en/zos/3.1.0?topic=vdiam-one-way-hash-generate-csnbowh-csnbowh1-csneowh-csneowh1 IBM i 7.3 Security Cryptography

However, I am not sure I am in the right direction. If you know an other way in COBOL to get the MD5 will be good to know.

Thank you


Solution

  • You need the following installed on your system

    5770-SS1 5050 – IBM i Option 35, CCA Cryptographic Service Provider
    

    It is not installed by default. A WRKOBJ *ALL/CSNBOWH *PGM will tell, or when QSYSINC/H MBR(CSUCINCL) exists.

    pub400 doesn't have it, maybe Holger can be persuaded?

    Good reference (albeit with C code) IBM i 7.3 Security Cryptography

    Update:

    You asked for another possibility to create MD5 hashes.

    There is C code on the Net that can be used for that. For Example: https://gist.github.com/creationix/4710780

    That code would need to be ported to the IBM i (AS400); I personally see no big problem with that.