method to decrypt AES128 in RPGLE

2920 pts.
Tags:
AS400 RPGLE
Hi, How to decrypt AES128 in RPGLE
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 70  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    You need the encryption key before you do anything, then basically the code looks like this.
    varchar = decrypt(varchar text, varchar key [, int algorithm 
              [, varchar IV]]);
    nvarchar = decrypt(nvarchar text, nvarchar key [, int algorithm
              [, varchar IV]]);
    For more info check out the IBM link 
    https://www.ibm.com/support/knowledgecenter/en/SSULQD_7.1.0/com.ibm.nz.sqltk.doc/r_sqlext_encrypt_decrypt.html
    135,465 pointsBadges:
    report
  • 6r
    hi
    2,920 pointsBadges:
    report
  • 6r
    error:Msg id  Sv Number Seq     Message text                                        
    RNF7030 30      6 000600  The name or indicator ENCRYPT is not defined.       
    RNF7503 30      6 000600  Expression contains an operand that is not defined. 
    * * * * *   E N D   O F   A D D I T I O N A L   D I A G N O S T I C   M E S S 
    2,920 pointsBadges:
    report
  • 6r
    Line   <---------------------- Source Specifications ------------------------- 
    Number ....1....+....2....+....3....+....4....+....5....+....6....+....7....+. 
                              S o u r c e   L i s t i n g                          
         1                                                                         
         2 dt1               s             50    inz('abcde')                      
         3 dt2               s             50                                      
         4 dk                s             50    inz('16-9d15-ec98bcc81ec4275OIM1T 
         5 d                                     +I')                              
         6 C                   EVAL      T2= ENCRYPT(t1:k:1)                       
         7 C     T2            DSPLY                                               
         8 C                   EVAL      *INLR=*ON                                 
           * * * * *   E N D   O F   S O U R C E   * * * * *                       
    2,920 pointsBadges:
    report
  • 6r
    so above is the code and error for encryption.
    2,920 pointsBadges:
    report
  • 6r
    so could someone please advise how to rectify this error in above code?



    2,920 pointsBadges:
    report
  • 6r
    Experts could you please advised?? 


    2,920 pointsBadges:
    report
  • 6r
    Any updates please? 
    2,920 pointsBadges:
    report
  • 6r
    tried this link but unable to run java code from as400 could somebody please advise as soon as possible?

    https://www.includehelp.com/java-programs/encrypt-decrypt-string-using-aes-128-bits-encryption-algorithm.aspx
    2,920 pointsBadges:
    report
  • ToddN2000
    Your original question was how to decrypt,  Your error and code example are for encrypting. I don't see any cod on how you have T2 defined
    135,465 pointsBadges:
    report
  • 6r
    in t2 we are saving output. and it's defined in my code as a stand alone field with length 50.
    2,920 pointsBadges:
    report
  • TheRealRaven
    Since the error refers to "ENCRYPT", please show the definition of it in your program.

    If you want to 'decrypt', why is ENCRYPT involved?
    36,370 pointsBadges:
    report
  • 6r
    00 denc              s            256                                      
    00 dpsw              s             33    inz('6-9d15-ec98bcc81ec4275OIM1TS 
    00 d                                     -I')                              
    00 Dtext             s             13                                      
    00                                                                         
    00 c                   eval      text = 'whatever text'                    
    00  /free                                                                  
    00    exec SQL Set :enc = encrypt_AES(text,psw);                           
    00    eval *inlr=*on;                                                      
    2,920 pointsBadges:
    report
  • 6r
    trying to do both encyption and decryption but in debug value of enc is coming as blanks only for encryption here.
    2,920 pointsBadges:
    report
  • 6r
    also tried replacing encrypt by decrypt in both the cases debug value of enc is blank only.
    2,920 pointsBadges:
    report
  • 6r
    so it seems nether encryption nor decryption is working here.
    2,920 pointsBadges:
    report
  • 6r
    any updates by experts please?
    2,920 pointsBadges:
    report
  • Splat
    What, if anything, are you seeing in the job log?
    12,915 pointsBadges:
    report
  • 6r
    tried below program to decrypt Base64 encoded data 0001.00 HDFTACTGRP(*NO) BNDDIR('QC2LE') option(*srcstmt : *nodebugio)           
    0002.00 h actgrp(*new)                                                          
    0003.00 ddata             s             89a   inz('u3VtNgfyWU9faZc3Iaa8ZWbE5UZC 
    0004.00 d                                     -7yA4MyW0ghflt9dNQNDpCcgMZiG/kXPE 
    0005.00 d                                     -2CHL93B4iKiODHxxdVA==')          
    0006.00 dsecretkey        s             16a   varying inz('661e275OIM1ULYLJ')   
    0007.00 dencrypted        s             16a                                     
    0008.00 dascharacters     s             32a                                     
    0009.00 dAES_CONTROL      DS                  Qualified                         
    0010.00 dfunctionid                      2a                                     
    0011.00 ddatalen                         5u 0                                   
    0012.00 doperation                       1a                                     
    0013.00 dmode                            1a                                     
    0014.00 dblocklen                        1a                                     
    0015.00 dmaclen                          1a                                     
    0016.00 dinitVector                     32a                            
    0017.00 dreserved                        7a                                    
    0018.00 dkeyoption                       1a                                    
    0019.00 dkeyschedule                      *                                    
    0020.00 dkey                            32a                                    
    0021.00 dcipher           pr                  extproc('_CIPHER')               
    0022.00 dreceiver                         *                                    
    0023.00 dcontrol                        96a                                    
    0024.00 dsource                           *                                    
    0025.00 dcvthc            pr                  extproc('cvthc')                 
    0026.00 drcvhex                           *   VALUE                            
    0027.00 dsrcchr                           *   VALUE                            
    0028.00 drcvlen                         10i 0 VALUE                            
    0029.00 dhex              s              2a                                    
    0030.00 dp_recv           s               *                                    
    0031.00 dp_src            s               *                                    
    0032.00                                                                        
    0033.00  /FREE                                                                 
    0034.00      AES_Control = *ALLx'00';                                          
    0035.00           AES_Control.functionID = x'0015';                            
    0036.00           AES_Control.datalen  = %size(data);                          
    0037.00           AES_Control.operation = x'00';                               
    0038.00           AES_Control.mode = x'00';             // 0=ECB               
    0039.00                     AES_Control.blockLen = x'10';         // 16        
    0040.00                     AES_Control.MACLen   = x'00';         //  0        
    0041.00                     AES_Control.keyOption = x'10';                     
    0042.00                                                                        
    0043.00                     AES_Control.key = secretKey;                       
    0044.00      p_recv = %addr(encrypted);                                        
    0045.00          p_src  = %addr(data);                                         
    0046.00          cipher( p_recv : AES_Control : p_src);                        
    0047.00                                                                        
    0048.00                    p_recv = %addr(asCharacters);                       
    0049.00                    p_src  = %addr(encrypted);                          
    0050.00                    cvthc ( p_recv : p_src : %size(asCharacters));      
    0051.00                    dsply asCharacters;                             
    0052.00         data = *blanks;                                            
    0053.00                                                                    
    0054.00         AES_Control = *ALLx'00';                                   
    0055.00         AES_Control.functionID = x'0015';                          
    0056.00         AES_Control.datalen  = %size(data);                        
    0057.00         AES_Control.operation = x'01';        //                   
    0058.00         AES_Control.mode = x'00';             // 0=ECB             
    0059.00         AES_Control.blockLen = x'10';         // 16                
    0060.00                   AES_Control.MACLen   = x'00';         //  0      
    0061.00                   AES_Control.keyOption = x'10';         // use    
    0062.00                                                                    
    0063.00                   AES_Control.key = secretKey;                     
    0064.00        p_recv = %addr(data);                                       
    0065.00        p_src  = %addr(encrypted);                                  
    0066.00                                                                    
    0067.00        cipher( p_recv : AES_Control : p_src);                      
    0070.00        *inlr = *on;        
    0071.00    /end-free               
    
    **************
    but when comparing decrypted data from this website 
    https://www.devglan.com/online-tools/aes-encryption-decryption

    results can not be compared at all means whatever output of decrypted data from
    abve rpgle program is not equal to data of website*for decryption part we need to focus)
    2,920 pointsBadges:
    report
  • 6r
    The problem is that this code works for      H DFTACTGRP(*NO) BNDDIR('QC2LE') option(*SRCSTMT: *NODEBUGIO)
         H ACTGRP(*NEW)
    
         D data            s             16A   inz('My coded message')
         D secretKey       s             16A   varying inz('Secret Password')
         D encrypted       s             16A
         D asCharacters    s             32A
    
         D AES_Control     ds                  qualified
         D   functionID                   2A
         D   dataLen                      5U 0
         D   operation                    1A
          *    x'00' = Encrypt, x'01' = Decrypt
         D   mode                         1A
          *    x'00' = ECB, x'01' = CBC
         D   blockLen                     1A
         D   MACLen                       1A
         D   initVector                  32A
         D   reserved                     7A
         D   keyOption                    1A		
          *    x'00'=KeySched. x'10'=16-byte, x'18'=24-byte, x'20'=32-byte key
         D   keySchedule                   *
         D   key                         32A
    
         D cipher          PR                  extproc('_CIPHER')
         D  receiver                       *
         D  control                      96A
         D  source                         *
    
         D cvthc           Pr                  ExtProc( 'cvthc' )
         D  RcvHex                         *   Value
         D  SrcChr                         *   Value
         D  RcvLen                       10i 0 Value
    
         D Hex             s              2a
    
         D p_recv          s               *
         D p_src           s               *
    
          /free
    
              //  The following will encrypt "data" using the AES
              //  algorithm with the secret key "key", and place
              //  the result into "encrypted"
    
              AES_Control = *ALLx'00';
              AES_Control.functionID = x'0015';
              AES_Control.datalen  = %size(data);
              AES_Control.operation = x'00';        // 0=Encrypt,1=Decrypt
              AES_Control.mode = x'00';             // 0=ECB
              AES_Control.blockLen = x'10';         // 16
              AES_Control.MACLen   = x'00';         //  0
              AES_Control.keyOption = x'10';         // use 16-byte key
              AES_Control.key = secretKey;
    
              p_recv = %addr(encrypted);
              p_src  = %addr(data);
    
              cipher( p_recv : AES_Control : p_src);
    
              p_recv = %addr(asCharacters);
              p_src  = %addr(encrypted);
              cvthc ( p_recv : p_src : %size(asCharacters));
              dsply asCharacters;
    
              //  The following will decrypt "encrypted" using the AES
              //  algorithm with the secret key "key", and place the
              //  result in "data".  We blank out data ahead of time
              //  to ensure that it's contents aren't carried over from
              //  the code above.
    
              data = *blanks;
    
              AES_Control = *ALLx'00';
              AES_Control.functionID = x'0015';
              AES_Control.datalen  = %size(data);
              AES_Control.operation = x'01';        // 0=Encrypt,1=Decrypt
              AES_Control.mode = x'00';             // 0=ECB
              AES_Control.blockLen = x'10';         // 16
              AES_Control.MACLen   = x'00';         //  0
              AES_Control.keyOption = x'10';         // use 16-byte key
              AES_Control.key = secretKey;
    
              p_recv = %addr(data);
              p_src  = %addr(encrypted);
    
              cipher( p_recv : AES_Control : p_src);
    
              dsply data;
    
              *inlr = *on;
          /end-free
    
    **************
    but does not work for previous data as 'u3VtNgfyWU9faZcIaa8ZWbE5UZCf7yA4MyW0ghflt9dNQNDpCcgMZiG/kXPECHL93B4iKiODHxxdVA=='
    and for this complex key :-661e275OIM1ULYLJ

    Thanks
    2,920 pointsBadges:
    report
  • TheRealRaven
    @6r : Not sure why/how you'd compare anything against that web site. Much more info is needed about exactly what you did step by step. We can't verify anything without that.

    Running under IBM i, you'll very likely be using an EBCDIC character set. The web site is almost certainly using an ASCII-based character set with very different hew representations. You'll need to ensure that your input/output hex representations match appropriately for all relevant parameters.

    Since you probably can't control any encodings for the web site, you'll probably need to do matching character conversions on IBM i for all character data, both input and output. Comparisons will otherwise likely be meaningless.
    36,370 pointsBadges:
    report
  • 6r
    so how to do it in rpgle program my input encoded string is in base64 format and that after decrypting it in rpgle program it\s not matching with that website so how can i match them and verify whether whatever i have decrypted is correct only currently i have this website by which i can verify but it seems like this rpgle program is unable to decrypt the cipher input feed in same format like website is doing.

    how can i ensure that my input/output hex representations match appropriately for all relevant parameters. with respect to as400 program\s output and website input output?
    2,920 pointsBadges:
    report
  • ToddN2000
    @6r: When it comes to reviewing samples of code showing you  encrypting/decrypting, use the code you find as a guide only.  You might never be able to decrypt somebody else sample code. The reason is, its just an example of the logic. They may have changed the data used in the example. Try it with your own data and you own key. This way you know what is expected going in an out of your application. Most users when posting code examples will change things like IP's, Libraries, file names to protect their own systems from hackers.  If we used our real IP, file and library it makes it easier for a data breach. 
    135,465 pointsBadges:
    report
  • 6r
    can i write a rpg or cl program to achieve this decryption in a programmatic way if yes then how?
    2,920 pointsBadges:
    report
  • ToddN2000
    @6r: The issue is the key may be different. Check with the owner of the data to insure you are trying to decipher the data with the correct key.  
    135,465 pointsBadges:
    report
  • TheRealRaven
    @6r : I don't know what you mean by "...my input encoded string is in base64 format...". Is it sent to you as base64? Are you generating the base64? What is the original encoding of the base64 characters? Was it transferred from another system? (How?) What is the original message encoding character set? If you decode the base64, what is the result? (I might assume that it's the original encrypted text, i.e., the message you want to decrypt, but...?) Too many unknowns.
    36,370 pointsBadges:
    report
  • 6r
    Hi,

    1) I did CALL QSYS/QP2TERM 
    2)openssl
    3)executed this command 
    echo 'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL
    93B4iKiODHxxdVA==' | openssl enc -d -aes-128-ecb -K 363631653237354f494d31554
    c594c4a -nopad -nosalt -base64 -A
    4) then got this decrypted data :-707fbe32-0dbc-41e0-888f-5bc40de8c20d2P9AMPCTQ4CZ                ¢ 

    echo 'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL
    93B4iKiODHxxdVA==' | openssl enc -d -aes-128-ecb -K 363631653237354f494d31554
    c594c4a -nopad -nosalt -base64 -A                                            
    707fbe32-0dbc-41e0-888f-5bc40de8c20d2P9AMPCTQ4CZ      

              ¢            

    5) Now I want to decrypt it programmatically for the same i am trying below program but getting errors:-

     Columns . . . :    6  76            Edit                             RISHI/RS1 
     SEU==>                                                                EXAMPLE6 
     FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++ 
    0009.00 D outrec          ds           132                                      
    0010.00                                                                         
    0011.00 C     UNIXPARM      PLIST                                               
    0012.00 C                   PARM                    CMD                         
    0013.00 C                   PARM                    MODE                        
    0014.00  /free                                                                  
    0015.00      cmd = 'echo u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCc 
    0016.00      gMZiG/kXPE4vv2CHL93B4iKiODHxxdVA==  | openssl enc -d -aes-128-ecb  
    0016.01      -K 363631653237354f494d31554c594c4a -nopad -nosalt -base64 -A out  
    0016.02      string.txt ;                                                       
    0016.03                                                                         
    0016.04                                                                         
    0017.00                                                                         
    0018.00                                                                         
    0019.00      read UNIX record;                                                  
    0020.00      dow not %eof(UNIX);                                                
    0021.00         outrec = record;                                                
                                                                                    
     F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle       
     F16=Repeat find       F17=Repeat change          F24=More keys                 
    Character literal has missing trailing apostrophe; trailing apostrophe ass... + 

         FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN
         FQSYSPRT   O    F  132        PRINTER
    
         D cmd             s           5000a
         D mode            s              1A   inz('P')
    
         D record          ds          1000
         D outrec          ds           132
    
         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
          /free
              cmd = 'ssh bcserv3.klements.com ps axww "|" +
                     grep boxrelay "|" grep -v grep';
              open UNIX;
    
              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;
    
              close UNIX;
              *inlr = *on;
          /end-free
    

    So here in cmd i am trying to replace that command with echo 'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL
    93B4iKiODHxxdVA==' | openssl enc -d -aes-128-ecb -K 363631653237354f494d31554
    c594c4a -nopad -nosalt -base64 -A  out.string.txt

    So i want to avoid this error so that i could test progrmatically also it's working fine.       
    2,920 pointsBadges:
    report
  • 6r
    is noone here??
    2,920 pointsBadges:
    report
  • 6r
    any iseries expert can you please advise here?

    thanks
    2,920 pointsBadges:
    report
  • ToddN2000
    @6r: Try checking out the IBM site on how to do it programatically.
    135,465 pointsBadges:
    report
  • ToddN2000
    @6r: looks like there are a lot more steps need than the code samples you provided. I did not think you could use the command as a parameter in a interactive or batch job. There had to be other parameters need for decryption .

    135,465 pointsBadges:
    report
  • TheRealRaven
    This line isn't formatted properly:
    0015.00      cmd = 'echo u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCc 
    0016.00      gMZiG/kXPE4vv2CHL93B4iKiODHxxdVA==  | openssl enc -d -aes-128-ecb  
    0016.01      -K 363631653237354f494d31554c594c4a -nopad -nosalt -base64 -A out  
    0016.02      string.txt ;
    There is no apostrophe after the "==" terminator (at least, none shows in the post).

    Since you're trying to embed apostrophes in constant text, the embedded apostrophes need to be doubled. Further, the entire constant text then needs to be enclosed in apostrophes.
    36,370 pointsBadges:
    report
  • 6r
    Now the compiler is not recognizing 'echo' command itself and giving these below errors:-
     Msg id  Sv Number Message text                                                
    *RNF2318 00      1 No overflow indicator is specified; indicator assigned and  
                       automatic skip to 06 generated.                             
    *RNF3530 00      2 Data structure has no valid subfields.                      
    *RNF0604 20      1 The token is not valid; token is ignored.                   
    *RNF5377 20      1 The end of the expression is expected.                      
    *RNF7030 30      1 The name or indicator is not defined.                       
    *RNF7062 30      1 There is no OPEN for a file that specifies user-controlled  
                       open; the File specification is ignored.                    
           * * * * *   E N D   O F   M E S S A G E   S U M M A R Y   * * * * *
    I tried below code:-

         FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN
         FQSYSPRT   O    F  132        PRINTER

         D cmd             s           5000a
         D mode            s              1A   inz('P')
         Dvar1             s             88    INZ('u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC+
         D                                     -yW0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL9+
         D                                     -B4iKiODHxxdVA==')
         D record          ds          1000
         D outrec          ds           132

         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
          /free
              cmd = "echo VAR1 !openssl enc -d -aes-128-ecb -K             Q+
              363631653237354f494d31554c594c4a -nopad -nosalt -base64 -A
              -out string" ;
              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;

              close UNIX;
              *inlr = *on;
          /end-free

    2,920 pointsBadges:
    report
  • 6r
    we can use cmd for passing unix commands from rpgle programs please see below sample programs for the same:-

    example 1:-
         FUNIX      CF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN
         FQSYSPRT   O    F  132        PRINTER

         D cmd             s           5000a
         D record          s           1000a
         D outrec          s            132a

         IUNIX      NS
         I                                  1 1000  Record

         C     UNIXPARM      PLIST
         C                   PARM                    CMD
          /free
              cmd = 'cd /tmp; ls';
              open UNIX;

              read UNIX;
              dow not %eof(UNIX);
                 outrec = record;
                 except;
                 read UNIX;
              enddo;

              *inlr = *on;
          /end-free

         OQSYSPRT   E
         O                       outrec             132



    example 2:-

         FUNIX      O    F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN

         D cmd             s           5000a

         C     UNIXPARM      PLIST
         C                   PARM                    CMD
          /free
              cmd = 'cat - > /tmp/myfile.txt';
              open UNIX;

              except writeToIfs;
              close UNIX;

              *inlr = *on;
          /end-free

         OUNIX      E            writeToIfs
         O                                              'This is some silly -
         O                                              text to put in the IFS'
         O          E            writeToIfs
         O                                              'And this is line 2.'


    example 3:-

         FUNIX      UF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN

         D cmd             s           5000a
         D record          s           1000a
         D AsciiData       c                   x'48656c6c6f'

         IUNIX      NS
         I                                  1 1000  record

         C     UNIXPARM      PLIST
         C                   PARM                    CMD
          /free
              cmd = 'iconv -f 819 -t 0';
              open UNIX;

              except writeAscii;
              read UNIX;
              dsply (%subst(record:1:5));

              close UNIX;

              *inlr = *on;
          /end-free

         OUNIX      E            writeAscii
         O                       AsciiData            5


    example 4:-

         FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN
         FQSYSPRT   O    F  132        PRINTER

         D cmd             s           5000a

         D record          ds          1000
         D outrec          ds           132

         C     UNIXPARM      PLIST
         C                   PARM                    CMD
          /free
              cmd = 'cd /tmp; ls';
              open UNIX;

              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;

              close UNIX;
              *inlr = *on;
          /end-free


    example 5:-

         FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN
         FQSYSPRT   O    F  132        PRINTER

         D cmd             s           5000a
         D mode            s              1A   inz('P')

         D record          ds          1000
         D outrec          ds           132

         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
          /free
              cmd = 'cd /tmp; ls';
              open UNIX;

              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;

              close UNIX;
              *inlr = *on;
          /end-free
    *********

    example 6:-

         FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN
         FQSYSPRT   O    F  132        PRINTER

         D cmd             s           5000a
         D mode            s              1A   inz('P')

         D record          ds          1000
         D outrec          ds           132

         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
          /free
              cmd = 'ssh bcserv3.klements.com ps axww "|" +
                     grep boxrelay "|" grep -v grep';
              open UNIX;

              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;

              close UNIX;
              *inlr = *on;
          /end-free
    ***
    example 7:-

         FUNIX      CF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN
         FQSYSPRT   O    F  132        PRINTER

         D cmd             s           5000a

         D record          ds          1000
         D lat             s             11p 7
         D lon             s             11p 7

         C     UNIXPARM      PLIST
         C                   PARM                    CMD
          /free
              cmd = 'PATH=$PATH:/usr/local/ZendSvr6/bin && +
                    iconv -f 37 -t 819 | +
                    php-cli /www/zendsvr/htdocs/geocode.php';
              open UNIX;

              record = '1600 W Pennsylvania Av, Washington DC';
              write UNIX record;

              read UNIX record;
              lat = %dec(record: 11: 7);

              read UNIX record;
              lon = %dec(record: 11: 7);

              close UNIX;

              dsply ('lat=' + %char(lat));
              dsply ('lon=' + %char(lon));
              *inlr = *on;
          /end-free
    *****
    example 8:-

            dcl-f UNIX special(1000) pgmname('UNIXCMD') plist(unixparm) usropn;
            dcl-f QSYSPRT printer(132) usage(*output);
            dcl-s cmd char(5000);
            dcl-ds record len(1000) end-ds;
            dcl-ds outrec len(132) end-ds;

         C     UNIXPARM      PLIST
         C                   PARM                    cmd

            cmd = 'cd /tmp; ls';
            open UNIX;

            read UNIX record;
            dow not %eof(UNIX);
               outrec = record;
               write QSYSPRT outrec;
               read UNIX record;
            enddo;

            close UNIX;
            *inlr = *on;
    ***
    example 9

    **FREE
    // This is the same as EXAMPLE1 except that it uses
    // "fully free" format and the Open Access interface
    //
    dcl-f UNIX disk(1000) handler('UNIXCMDOA': cmd) usropn;
    dcl-f QSYSPRT printer(132) usage(*output);
    dcl-s cmd char(5000);
    dcl-ds record len(1000) end-ds;
    dcl-ds outrec len(132) end-ds;

    cmd = 'cd /tmp; ls';
    open UNIX;

    read UNIX record;
    dow not %eof(UNIX);
       outrec = record;
       write QSYSPRT outrec;
       read UNIX record;
    enddo;

    *inlr = *on;
    ****
    example 10:-

    **FREE
    // This is the same as EXAMPLE3, except that it is in "fully free"
    // format and uses Open Access instead of Special Files
    //
    dcl-f UNIX disk(5) usage(*input:*output) handler('UNIXCMDOA':cmd);
    dcl-s cmd char(5000) inz('iconv -f 819 -t 0');
    dcl-ds record len(5) end-ds;
    dcl-c AsciiData x'48656c6c6f';

    record = AsciiData;
    write UNIX record;
    read UNIX record;
    dsply record;

    *inlr = *on;
    ***
    example 11:-

    **FREE
    // This is the same as EXAMPLE5 except that it uses
    // "fully free" format and the Open Access interface
    //
    // To use different "modes" with open access, you prefix
    // the command:
    //    pase: use the PASE interface
    //     qsh: use the QShell interface (also qshell: works too)
    //     raw: use raw mode, specify your own shell
    // the default mode is "qsh"
    //
    // This example demonstrates the PASE mode.
    //
    dcl-f UNIX disk(1000) handler('UNIXCMDOA': cmd) usropn;
    dcl-f QSYSPRT printer(132) usage(*output);
    dcl-s cmd char(5000);
    dcl-ds record len(1000) end-ds;
    dcl-ds outrec len(132) end-ds;

    cmd = 'pase:cd /tmp; ls';
    open UNIX;

    read UNIX record;
    dow not %eof(UNIX);
       outrec = record;
       write QSYSPRT outrec;
       read UNIX record;
    enddo;

    *inlr = *on;


    **************

    Thanks so similar to above examples i tried to pass that echo openssl command to decrypt data stored in some particular directory in some xml file and then i am trying to extract that field and then decrypt it using tis openssl command but it's not working and ending up in multiple compilation errors.
    2,920 pointsBadges:
    report
  • 6r
    Ok, So any updates on the same please now?


    Thanks


    2,920 pointsBadges:
    report
  • ToddN2000
    @6r: unfortunately I have to call it quits at this point. It's been over 30 years since I worked with Unix. Is there a particular reason you need to use it? 
    135,465 pointsBadges:
    report
  • 6r
    ya i need to decrypt that encoded token present in xml file for that only i was trying to decrypt that data present in that xml file and i have been trying this code **free
       dcl-s encodedExchangeToken varchar(88);
       dcl-s string char(45);
       DCL-f UNIX usage(*input) special(1000) PGMNAME('UNIXCMD')
                                        PLIST(UNIXPARM) USROPN;
       DCL-F QSYSPRT usage(*output);
    
       dcl-s cmd  char(5000);
       dcl-s mode char(1) inz('P');
       dcl-ds record(1000);
       dcl-ds outrec(132);
    
         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
       XML-INTO encodedExchangeToken %XML('/home/I0RS01HU/INPUT.+
       xml':'doc=file case=any path=+
       TokenExchangeResponse/encodedExchangeToken');
              cmd = 'encodedExchangeToken'! openssl enc -d -aes-+          Q+
       128-ecb -d -aes-128-ecb-k 363631653237354f494d31554c594c4+          Q+
       a  -nopad -nosalt -base64 -A  -OUT string;                          Q+
              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;
    
              close UNIX;
              *inlr = *on;
    
    but it's ending up in multiple compilation errors once these are over then i will modify it to write decrypted data in another output xml file.
    may be some other iseries xml experts if you could guide me where i am wrong here
    please find attached spooled file as well for more clarification. 5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page      1
     
      Command  . . . . . . . . . . . . :   CRTBNDRPG
        Issued by  . . . . . . . . . . :     I0RS01HU
      Program  . . . . . . . . . . . . :   EX7
        Library  . . . . . . . . . . . :     RISHI
      Text 'description' . . . . . . . :   *SRCMBRTXT
     
      Source Member  . . . . . . . . . :   EX7
      Source File  . . . . . . . . . . :   RS1
        Library  . . . . . . . . . . . :     RISHI
        CCSID  . . . . . . . . . . . . :     870
      Text 'description' . . . . . . . :
      Last Change  . . . . . . . . . . :   19-10-31  14:49:16
     
      Generation severity level  . . . :   10
      Default activation group . . . . :   *YES
      Compiler options . . . . . . . . :   *XREF      *GEN       *NOSECLVL  *SHOWCPY
                                           *EXPDDS    *EXT       *NOSHOWSKP *NOSRCSTMT
                                           *DEBUGIO   *UNREF     *NOEVENTF
      Debugging views  . . . . . . . . :   *SOURCE
      Debug encryption key . . . . . . :   *NONE
      Output . . . . . . . . . . . . . :   *PRINT
      Optimization level . . . . . . . :   *NONE
      Source listing indentation . . . :   *NONE
      Type conversion options  . . . . :   *NONE
      Sort sequence  . . . . . . . . . :   *HEX
      Language identifier  . . . . . . :   *JOBRUN
      Replace program  . . . . . . . . :   *NO
      User profile . . . . . . . . . . :   *USER
      Authority  . . . . . . . . . . . :   *LIBCRTAUT
      Truncate numeric . . . . . . . . :   *YES
      Fix numeric  . . . . . . . . . . :   *NONE
      Target release . . . . . . . . . :   *PRV
      Allow null values  . . . . . . . :   *NO
      Define condition names . . . . . :   *NONE
      Enable performance collection  . :   *PEP
      Profiling data . . . . . . . . . :   *NOCOL
      Licensed Internal Code options . :
      Generate program interface . . . :   *NO
      Include directory  . . . . . . . :
      Preprocessor options . . . . . . :   *NONE
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page      3
     
    Line   <---------------------- Source Specifications -----------------------------------------------------> DO   CHANGE SRC SEQ
    Number ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 NUM  DATE   ID  NUMBER
     
                              S o u r c e   L i s t i n g
     
         1 **free                                                                                                    191031     000100
     
     
         2    dcl-s encodedExchangeToken varchar(88);                                                                191031     000200
         3    dcl-s string char(45);                                                                                 191031     000300
     
     
         4    DCL-f UNIX usage(*input) special(1000) PGMNAME('UNIXCMD')                                              191031     000400
    ======>                            aaaaaaa       bbbbbbb
    *RNF2401 20 a      000400  Keyword is not allowed for a DISK file; keyword is ignored.
    *RNF2401 20 b      000400  Keyword is not allowed for a DISK file; keyword is ignored.
         5                                     PLIST(UNIXPARM) USROPN;                                               191031     000500
    ======>                                    aaaaa
    *RNF2401 20 a      000500  Keyword is not allowed for a DISK file; keyword is ignored.
    *RNF2120 40      4 000400  External descriptions for file UNIX not found; file is
                               ignored.
         6    DCL-F QSYSPRT usage(*output);                                                                          191031     000600
    ======>         aaaaaaa
    ======>         bbbbbbb
    *RNF2121 30 a      000600  Record format QSYSPRT in file QSYSPRT already defined;
                               record format is ignored.
    *RNF2109 40 b      000600  All Record Formats for externally-described file QSYSPRT
                               ignored or dropped due to error; file ignored.
            *--------------------------------------------------------------------------------------------*
            *                               RPG name         External name                               *
            * File name. . . . . . . . . :  QSYSPRT          QSYS2924/QSYSPRT                            *
            * Record format(s) . . . . . :  (Not used)       QSYSPRT                                     *
            *--------------------------------------------------------------------------------------------*
         7                                                                                                           000000     000700
     
     
         8    dcl-s cmd  char(5000);                                                                                 191031     000800
         9    dcl-s mode char(1) inz('P');                                                                           191031     000900
        10    dcl-ds record(1000);                                                                                   191031     001000
    ======>                abbbbc
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page      3
     
    Line   <---------------------- Source Specifications -----------------------------------------------------> DO   CHANGE SRC SEQ
    Number ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 NUM  DATE   ID  NUMBER
    *RNF3308 20 a      001000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      001000  Keyword name is not valid; the keyword is ignored.
    *RNF0633 20 c      001000  An unexpected right parenthesis was encountered; right
                               parenthesis is ignored.
        11    dcl-ds outrec(132);                                                                                    191031     001100
    ======>                abbbc
    *RNF0203 30     10 001000  NESTED DATA STRUCTURE ONLY VALID IF PARENT DATA STRUCTURE
                               IS QUALIFIED; END-DS ASSUMED FOR RECORD.
    *RNF3530 00     10 001000  Data structure RECORD has no valid subfields.
    *RNF3308 20 a      001100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      001100  Keyword name is not valid; the keyword is ignored.
    *RNF0633 20 c      001100  An unexpected right parenthesis was encountered; right
                               parenthesis is ignored.
        12                                                                                                           000000     001200
        13      C     UNIXPARM      PLIST                                                                            000000     001300
    ======>           aaaaaaaa      bbbbb
    *RNF3308 20 a      001300  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      001300  Keyword name is not valid; the keyword is ignored.
        14      C                   PARM                    CMD                                                      000000     001400
    ======>     a                   bbbb                    ccc
    *RNF3308 20 a      001400  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      001400  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 c      001400  Keyword name is not valid; the keyword is ignored.
        15      C                   PARM                    MODE                                                     000000     001500
    ======>     a                   bbbb                    cccc
    *RNF3308 20 a      001500  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      001500  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 c      001500  Keyword name is not valid; the keyword is ignored.
        16    XML-INTO encodedExchangeToken %XML('/home/I0RS01HU/INPUT.+                                             191031     001600
    ======>   aaaaaaaa bbbbbbbbbbbbbbbbbbbb cccc
    *RNF3308 20 a      001600  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      001600  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 c      001600  Keyword name is not valid; the keyword is ignored.
        17    xml':'doc=file case=any path=+                                                                         191031     001700
    ======>   aaabbbcccdeeee ffffghhh iiiij
    *RNF0312 20 a      001700  A right parenthesis is expected but is not found.
    *RNF0607 00 b      001700  Text is skipped to recover from the previous error.
    *RNF3308 20 c      001700  Keyword name is not valid; the keyword is ignored.
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page      4
     
    Line   <---------------------- Source Specifications -----------------------------------------------------> DO   CHANGE SRC SEQ
    Number ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 NUM  DATE   ID  NUMBER
    *RNF3308 20 d      001700  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 e      001700  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 f      001700  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 g      001700  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 h      001700  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 i      001700  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 j      001700  Keyword name is not valid; the keyword is ignored.
        18    TokenExchangeResponse/encodedExchangeToken');                                                          191031     001800
    ======>   aaaaaaaaaaaaaaaaaaaaabcccccccccccccccccccc  d
    *RNF3308 20     17 001700  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 a      001800  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      001800  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 c      001800  Keyword name is not valid; the keyword is ignored.
    *RNF0267 20 d      001800  Character literal has missing trailing apostrophe; trailing
                               apostrophe assumed.
    *RNF3308 20     18 001800  Keyword name is not valid; the keyword is ignored.
        19           cmd = 'encodedExchangeToken'! openssl enc -d -aes-+          Q+                                 191031     001900
    ======>          aaa b ccccccccccccccccccccccd eeeeeee fff gh ijjjjk          l
    *RNF3308 20 a      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 c      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 d      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 e      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 f      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 g      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 h      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 i      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 j      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 k      001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 l      001900  Keyword name is not valid; the keyword is ignored.
        20    128-ecb -d -aes-128-ecb-k 363631653237354f494d31554c594c4+          Q+                                 191031     002000
    ======>   aaabccc de fggggggggggggg hhhhhhhhhhhhhhhiiiiiiiiiiiiiiiij          k
    *RNF3308 20     19 001900  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 a      002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 c      002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 d      002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 e      002000  Keyword name is not valid; the keyword is ignored.
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page      5
     
    Line   <---------------------- Source Specifications -----------------------------------------------------> DO   CHANGE SRC SEQ
    Number ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 NUM  DATE   ID  NUMBER
    *RNF3308 20 f      002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 g      002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 h      002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 i      002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 j      002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 k      002000  Keyword name is not valid; the keyword is ignored.
        21    a  -nopad -nosalt -base64 -A  -OUT string;                          Q+                                 191031     002100
    ======>   a  bccccc deeeeee fgggggg hi  jkkk llllll                           m
    *RNF3308 20     20 002000  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 a      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 b      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 c      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 d      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 e      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 f      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 g      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 h      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 i      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 j      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 k      002100  Keyword name is not valid; the keyword is ignored.
    *RNF3308 20 l      002100  Keyword name is not valid; the keyword is ignored.
    *RNF5508 30 m      002100  End of free-format statement is not blank.
    *RNF3556 20     11 001100  END-DS statement missing for a group containing free-form
                               statements.
     
     
        22           read UNIX record;                                                                               000000     002200
        23           dow not %eof(UNIX);                                                                        B01  000000     002300
        24              outrec = record;                                                                         01  000000     002400
        25              write QSYSPRT outrec;                                                                    01  000000     002500
        26              read UNIX record;                                                                        01  000000     002600
        27           enddo;                                                                                     E01  000000     002700
        28                                                                                                           000000     002800
        29           close UNIX;                                                                                     000000     002900
        30           *inlr = *on;                                                                                    000000     003000
    *RNF7030 30     13 001300  The name or indicator C is not defined.
     
           * * * * *   E N D   O F   S O U R C E   * * * * *
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page      6
     
    Line   <---------------------- Source Specifications -----------------------------------------------------> DO   CHANGE SRC SEQ
    Number ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 NUM  DATE   ID  NUMBER
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page      7
     
              A d d i t i o n a l   D i a g n o s t i c   M e s s a g e s
     
     Msg id  Sv Number Seq     Message text
    *RNF7503 30     22 002200  Expression contains an operand that is not defined.
    *RNF7503 30     25 002500  Expression contains an operand that is not defined.
    *RNF7503 30     26 002600  Expression contains an operand that is not defined.
     
     * * * * *   E N D   O F   A D D I T I O N A L   D I A G N O S T I C   M E S S A G E S   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page      8
     
                              C r o s s   R e f e r e n c e
     
          File and Record References:
     
             File              Device             References (D=Defined)
               Record
             QSYSPRT           DISK                    6D      6D     25
             UNIX              DISK                    4D     22      23      26
                                                      29
     
          Global Field References:
     
             Field             Attributes         References (D=Defined M=Modified)
             *INLR             N(1)                   30M
    *RNF7030 C                 **UNDEF**              13D
    *RNF7031 CMD               A(5000)                 8D
    *RNF7031 ENCODEDEXCHANGETOKEN...
                               A(88)                   2D
                               VARYING(2)
    *RNF7031 MODE              A(1)                    9D
             OUTREC            DS(1)                  11D     24M     25
             RECORD            DS(1)                  10D     22M     24      26M
    *RNF7031 STRING            A(45)                   3D
     
          Indicator References:
     
             Indicator                            References (D=Defined M=Modified)
             LR                                       30M
     
           * * * * *   E N D   O F   C R O S S   R E F E R E N C E   * * * * *
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page      9
     
                          E x t e r n a l   R e f e r e n c e s
     
          Statically bound procedures:
             Procedure                            References
             No references in the source.
     
          Imported fields:
             Field             Attributes         Defined
             No references in the source.
     
          Exported fields:
             Field             Attributes         Defined
             No references in the source.
     
       * * * * *   E N D   O F   E X T E R N A L   R E F E R E N C E S   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page     10
     
                              M e s s a g e   S u m m a r y
     
     Msg id  Sv Number Message text
    *RNF0607 00      1 Text is skipped to recover from the previous error.
    *RNF3530 00      1 Data structure has no valid subfields.
    *RNF7031 00      4 The name or indicator is not referenced.
    *RNF0267 20      1 Character literal has missing trailing apostrophe; trailing
                       apostrophe assumed.
    *RNF0312 20      1 A right parenthesis is expected but is not found.
    *RNF0633 20      2 An unexpected right parenthesis was encountered; right
                       parenthesis is ignored.
    *RNF2401 20      3 Keyword is not allowed for a DISK file; keyword is ignored.
    *RNF3308 20     65 Keyword name is not valid; the keyword is ignored.
    *RNF3556 20      1 END-XX statement missing for a group containing free-form
                       statements.
    *RNF0203 30      1 Refer to the compiler listing where this message was first
                       issued.
    *RNF2121 30      1 Record-format name in externally-described file already
                       defined; record format ignored.
    *RNF5508 30      1 End of free-format statement is not blank.
    *RNF7030 30      1 The name or indicator is not defined.
    *RNF7503 30      3 Expression contains an operand that is not defined.
    *RNF2109 40      1 All Record Formats for externally-described file ignored or
                       dropped due to error; File ignored.
    *RNF2120 40      1 External description not found for file specified as
                       externally described; file ignored.
     
           * * * * *   E N D   O F   M E S S A G E   S U M M A R Y   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' ' IT
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX7                ' '       19-11-01 15:35:09        Page     11
     
                                F i n a l   S u m m a r y
     
      Message Totals:
     
        Information  (00) . . . . . . . :        6
        Warning      (10) . . . . . . . :        0
        Error        (20) . . . . . . . :       73
        Severe Error (30+)  . . . . . . :        9
        ---------------------------------  -------
        Total . . . . . . . . . . . . . :       88
     
     
      Source Totals:
     
        Records . . . . . . . . . . . . :       30
        Specifications  . . . . . . . . :       26
        Data records  . . . . . . . . . :        0
        Comments  . . . . . . . . . . . :        3
     
             * * * * *   E N D   O F   F I N A L   S U M M A R Y   * * * * *
    Compilation stopped. Severity 40 errors found in program.
              * * * * *   E N D   O F   C O M P I L A T I O N   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' ' IT
    
    2,920 pointsBadges:
    report
  • 6r
    any other as400 expert could you please guiide whats going wrong with this code,it's trying to read this input xml file's encodedexchangetoken field's value and then trying to write decrypted value using openssl and aes128 algorithm in string1.txt .
    input xml:-
    This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <span class="button collapse-button" style="user-select: none; cursor: pointer; display: inline-block; margin-left: -10px; width: 10px; background-image: url("data:image/svg+xml,"); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; vertical-align: bottom; height: 10px;"><TokenExchangeResponse xmlns="http://schemas.nav.gov.hu/OSA/1.0/api" xmlns:ns2="http://schemas.nav.gov.hu/OSA/1.0/data">
    <span class="button collapse-button" style="user-select: none; cursor: pointer; display: inline-block; margin-left: -10px; width: 10px; background-image: url("data:image/svg+xml,"); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; vertical-align: bottom; height: 10px;"><header>
    <requestId>XXXXXXX6614</requestId>
    <timestamp>2019-10-22T09:53:40.541Z</timestamp>
    <requestVersion>1.1</requestVersion>
    <headerVersion>1.0</headerVersion>
    </header>
    <span class="button collapse-button" style="user-select: none; cursor: pointer; display: inline-block; margin-left: -10px; width: 10px; background-image: url("data:image/svg+xml,"); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; vertical-align: bottom; height: 10px;"><result>
    <funcCode>OK</funcCode>
    </result>
    <span class="button collapse-button" style="user-select: none; cursor: pointer; display: inline-block; margin-left: -10px; width: 10px; background-image: url("data:image/svg+xml,"); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; vertical-align: bottom; height: 10px;"><software>
    <softwareId>R1RL002AAAAAAAAAAA</softwareId>
    <softwareName>string</softwareName>
    <softwareOperation>LOCAL_SOFTWARE</softwareOperation>
    <softwareMainVersion>string</softwareMainVersion>
    <softwareDevName>string</softwareDevName>
    <softwareDevContact>string</softwareDevContact>
    <softwareDevCountryCode>HU</softwareDevCountryCode>
    <softwareDevTaxNumber>string</softwareDevTaxNumber>
    </software>
    <span class="button collapse-button" style="user-select: none; cursor: pointer; display: inline-block; margin-left: -10px; width: 10px; background-image: url("data:image/svg+xml,"); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; vertical-align: bottom; height: 10px;"><encodedExchangeToken>
    u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL93B4iKiODHxxdVA==
    </encodedExchangeToken>
    <tokenValidityFrom>2019-10-22T11:57:16.646+02:00</tokenValidityFrom>
    <tokenValidityTo>2019-10-22T12:02:16.646+02:00</tokenValidityTo>
    </TokenExchangeResponse>
    2,920 pointsBadges:
    report
  • 6r
         FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM)
         FQSYSPRT   O    F  132        PRINTER
         dencodedExcha...
         dngeToken         s             88
         DSTRING1          S            100
         D cmd             s           5000a
         D mode            s              1A   inz('P')
         D record          ds          1000
         D outrec          ds           132
    
         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
          /free
           XML-INTO encodedExchangeToken %XML('/home/I0RS01HU/+
           /INPUT.xml':'doc=file case=any path=+
           TokenExchangeResponse/encodedExchangeToken');
              cmd = 'echo encodedExchangeToken!openssl +
              enc -d -aes-128-ecb -K +
              363631653237354f494d31554c594c4a -nopad -nosalt +
              -base64 -A -out string1.txt';
              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;
    
              close UNIX;
              *inlr = *on;
          /end-free
    
    2,920 pointsBadges:
    report
  • 6r
    any updates from as400 cum unix expert please?
    2,920 pointsBadges:
    report
  • 6r
    tried below code as well it keeps giving compilation error     FUNIX IF F 1000 SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN
         FQSYSPRT   O    F  132        PRINTER
    
         D cmd             s           5000a
         D mode            s              1A   inz('P')
    
         D record          ds          1000
         D outrec          ds           132
    
         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
          /free
              cmd = 'echo 'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4My'+
              'W0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL93B4iKiODHxxdVA=='+
           "!" openssl enc -d -aes-128-ecb -K 363631653237354f494d+
            31554c594c4a -nopad -nosalt -base64 -A -out record';
              open UNIX;
              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;
    
              close UNIX;
              *inlr = *on;
          /end-free
    
    2,920 pointsBadges:
    report
  • 6r
    after correcting compilattion errors below code is still not decrypting desired value in record field.     FUNIX IF F 1000 SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM)   usropn
         FQSYSPRT   O    F  132        PRINTER
         dencodedExcha...
         dngeToken         s             88
         DSTRING1          S            100
         D cmd             s           5000a
         D mode            s              1A   inz('P')
         D record          ds          1000
         D outrec          ds           132
    
         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
          /free
           XML-INTO encodedExchangeToken %XML('/home/I0RS01HU/+
           /INPUT.xml':'doc=file case=any path=+
           TokenExchangeResponse/encodedExchangeToken');
              cmd = 'echo encodedExchangeToken ö openssl +
              enc -d -aes-128-ecb -K +
              363631653237354f494d31554c594c4a -nopad -nosalt +
              -base64 -A -out record';
              open UNIX;
              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;
    
              close UNIX;
              *inlr = *on;
          /end-free
    
    
    2,920 pointsBadges:
    report
  • 6r
    any updates from iseries experts on the same please?

    Thanks
    2,920 pointsBadges:
    report
  • ToddN2000
    One thing that may be causing your problems from what I was able to dig up is mentioned on this discussion. you need a specific product installed on the i-series or you cannot use OPENSSL. 
    135,465 pointsBadges:
    report
  • 6r
    is there not any iseries expert available on this forum to sort out this issue please?
    2,920 pointsBadges:
    report
  • 6r
    that product is already installed on my system that's why i was able to decrypt that value interactively now next challenge is to decrypt the same thing programatically where i have been struggling for a long period.
    2,920 pointsBadges:
    report
  • 6r
    this is the recent code i tried :-

         FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM)   usropn
         FQSYSPRT   O    F  132        PRINTER
         dencodedExcha...
         dngeToken         s             88
         DSTRING1          S            100
         D cmd             s           5000a
         D mode            s              1A   inz('P')
         D record          ds          1000
         D outrec          ds           132
    
         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
          /free
           XML-INTO encodedExchangeToken %XML('/home/I0RS01HU/+
           /INPUT.xml':'doc=file case=any path=+
           TokenExchangeResponse/encodedExchangeToken');
              cmd = 'echo encodedExchangeToken | openssl +
              enc -d -aes-128-ecb -K +
              363631653237354f494d31554c594c4a -nopad -nosalt +
              -base64 -A -out record';
              open UNIX;
              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;
    
              close UNIX;
              *inlr = *on;
          /end-free
    

    But it does not write any decrypted value in record field and it keeps giving below value only:-
                                 Evaluate Expression                               
                                                                                   
    Previous debug expressions                                                     
                                                                                   
    > EVAL record                                                                  
      RECORD =                                                                     
                ....5...10...15...20...25...30...35...40...45...50...55...60       
           1   'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/'      
          61   'kXPE4vv2CHL93B4iKiODHxxdVA==| openssl enc -d -aes-128-ecb -K'      
         121   ' 363631653237354f494d31554c594c4a -nopad -nosalt -base64 -A '      
         181   '-out record                                                 '      
         241   '                                                            '      
         301   '                                                            '      
         361   '                                                            '      
         421   '                                                            '      
         481   '                                                            '      
         541   '                                                            '      
         601   '                                                            '      
                                                                           More... 
    Debug . . .                                                                    
                                                                                   
    2,920 pointsBadges:
    report
  • 6r
    any updates by iseries experts please?
    2,920 pointsBadges:
    report
  • carlosdl
    Being so insistent is not going to make a difference, unfortunately.

    Remember that people here are volunteers, who devote their time to try to help others.  They are not staff of some paid support service.

    There are some very good experts on the iSeries here in the community.  If they have not been able to help you until now, it is probably because some issues are not easy to diagnose and correct without access to the system or a lot more information about it.

    If this is so important and you cannot do it, I would consider hiring a consultant.
    85,430 pointsBadges:
    report
  • 6r
    program code i already pasted only thing which needs to be checked why decrypted value is not getting populated in record field in this program what is wrong here, where as when we execute this command (openssl in pase) in interactive way it does show the result.If there are so many iseries experts present  here then why do i not receive multiple advises on regular basis on this forum  and why do i need to follow up now and then again and again.
    Is this forum forum for paid service only ?
    2,920 pointsBadges:
    report
  • carlosdl
    So, let me see if I understand the situation correctly.

    You want free help to do a job for which you are getting paid, and you want people who are trying to help you for free, to give you updates on a regular basis, and you don't want to need to be following up.

    Is that right?

    It really sounds like what an employer would demand.

    Sorry.  I really don't mean to be rude, but when you ask for free help, you really have to be patient and respectful of other people's time, because they have also a real job they have to attend, which is obviously more important than helping others do their job.

    If they can help you, they will.  Just be patient, and as I suggested before, if you need to get this done urgently and it is out of your skillset, consider other options.
    85,430 pointsBadges:
    report
  • carlosdl
    Or maybe you just need to take a step back, and try to approach the problem one step at a time, asking very specific questions as they arise.

    I know nothing about the iSeries, but I just read the whole thread, and I can see that you have tried many different things.

    You mentioned that you were able to get the results you want interactively, so, the obvious next step would be trying to implement the same approach programmatically.

    When you did it interactively you used the string you want to decrypt as a constant, but in your last attempt you added additional complexity by now reading it from an XML file.  Why would you try that, if you have not been able to make something simpler work?

    The key to making that work could have been what @TheRealRaven mentioned almost a week ago:

    "Since you're trying to embed apostrophes in constant text, the embedded apostrophes need to be doubled. Further, the entire constant text then needs to be enclosed in apostrophes."

    Did you pay attention to it?  Why didn't you say something  about it?
    85,430 pointsBadges:
    report
  • 6r
    if i do as advised then program does not compile at all

    please lates code after incorporating suggested changes and spool files for the same changes :-
         FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')
         F                                     PLIST(UNIXPARM) USROPN
         FQSYSPRT   O    F  132        PRINTER
    
         D cmd             s           5000a
         D mode            s              1A   inz('P')
    
         D record          ds          1000
         D outrec          ds           132
    
         C     UNIXPARM      PLIST
         C                   PARM                    CMD
         C                   PARM                    MODE
          /free
              cmd = 'echo '"u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4My+
              W0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL93B4iKiODHxxdVA=="'+
           "!" openssl enc -d -aes-128-ecb -K 363631653237354f494d+
            31554c594c4a -nopad -nosalt -base64 -A -out record';
              open UNIX;
              read UNIX record;
              dow not %eof(UNIX);
                 outrec = record;
                 write QSYSPRT outrec;
                 read UNIX record;
              enddo;
    
              close UNIX;
              *inlr = *on;
          /end-free
    *************************
    spool file of above changed program code when i inserted double quotes in constant text and then put Further, the entire constant text then needs to be enclosed in apostrophes.
    
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX6                ' '       19-11-02 11:22:02        Page      1
     
      Command  . . . . . . . . . . . . :   CRTBNDRPG
        Issued by  . . . . . . . . . . :     I0RS01HU
      Program  . . . . . . . . . . . . :   EX6
        Library  . . . . . . . . . . . :     RISHI
      Text 'description' . . . . . . . :   *SRCMBRTXT
     
      Source Member  . . . . . . . . . :   EX6
      Source File  . . . . . . . . . . :   RS1
        Library  . . . . . . . . . . . :     RISHI
        CCSID  . . . . . . . . . . . . :     870
      Text 'description' . . . . . . . :
      Last Change  . . . . . . . . . . :   19-11-02  11:21:58
     
      Generation severity level  . . . :   10
      Default activation group . . . . :   *YES
      Compiler options . . . . . . . . :   *XREF      *GEN       *NOSECLVL  *SHOWCPY
                                           *EXPDDS    *EXT       *NOSHOWSKP *NOSRCSTMT
                                           *DEBUGIO   *UNREF     *NOEVENTF
      Debugging views  . . . . . . . . :   *SOURCE
      Debug encryption key . . . . . . :   *NONE
      Output . . . . . . . . . . . . . :   *PRINT
      Optimization level . . . . . . . :   *NONE
      Source listing indentation . . . :   *NONE
      Type conversion options  . . . . :   *NONE
      Sort sequence  . . . . . . . . . :   *HEX
      Language identifier  . . . . . . :   *JOBRUN
      Replace program  . . . . . . . . :   *YES
      User profile . . . . . . . . . . :   *USER
      Authority  . . . . . . . . . . . :   *LIBCRTAUT
      Truncate numeric . . . . . . . . :   *YES
      Fix numeric  . . . . . . . . . . :   *NONE
      Target release . . . . . . . . . :   *PRV
      Allow null values  . . . . . . . :   *NO
      Define condition names . . . . . :   *NONE
      Enable performance collection  . :   *PEP
      Profiling data . . . . . . . . . :   *NOCOL
      Licensed Internal Code options . :
      Generate program interface . . . :   *NO
      Include directory  . . . . . . . :
      Preprocessor options . . . . . . :   *NONE
     
                                                         ' '   ' '
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX6                ' '       19-11-02 11:22:02        Page      3
     
    Line   <---------------------- Source Specifications ----------------------------><---- Comments ----> Do  Page  Change Src Seq
    Number ....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 Num Line  Date   Id  Number
     
                              S o u r c e   L i s t i n g
     
     
     
         1 FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')                                                  000000     000100
         2 F                                     PLIST(UNIXPARM) USROPN                                              000000     000200
         3 FQSYSPRT   O    F  132        PRINTER                                                                     000000     000300
         4                                                                                                           000000     000400
     
     
         5 D cmd             s           5000a                                                                       000000     000500
         6 D mode            s              1A   inz('P')                                                            000000     000600
         7                                                                                                           000000     000700
         8 D record          ds          1000                                                                        000000     000800
    ======>  aaaaaa
    *RNF3530 00 a      000800  Data structure RECORD has no valid subfields.
         9 D outrec          ds           132                                                                        000000     000900
        10                                                                                                           000000     001000
    *RNF3530 00      9 000900  Data structure OUTREC has no valid subfields.
    *RNF2318 00      3 000300  Overflow indicator *INOA is assigned to PRINTER file
                               QSYSPRT.
     
     
        11 C     UNIXPARM      PLIST                                                                                 000000     001100
        12 C                   PARM                    CMD                                                           000000     001200
        13 C                   PARM                    MODE                                                          000000     001300
        14  /free                                                                                                    000000     001400
        15      cmd = 'echo 'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4My'+                                                191102     001500
    ======>                  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    *RNF5377 20 a      001500  The end of the expression is expected.
        16      'W0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL93B4iKiODHxxdVA=='+                                                191102     001600
        17   "!" openssl enc -d -aes-128-ecb -K 363631653237354f494d+                                                191102     001700
        18    31554c594c4a -nopad -nosalt -base64 -A -out record';                                                   191102     001800
        19      open UNIX;                                                                                           191102     001900
        20      read UNIX record;                                                                                    000000     002000
        21      dow not %eof(UNIX);                                                                        B01       000000     002100
        22         outrec = record;                                                                         01       000000     002200
     
                                                         ' '   ' '
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX6                ' '       19-11-02 11:22:02        Page      3
     
    Line   <---------------------- Source Specifications ----------------------------><---- Comments ----> Do  Page  Change Src Seq
    Number ....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10 Num Line  Date   Id  Number
        23         write QSYSPRT outrec;                                                                    01       000000     002300
        24         read UNIX record;                                                                        01       000000     002400
        25      enddo;                                                                                     E01       000000     002500
        26                                                                                                           000000     002600
        27      close UNIX;                                                                                          000000     002700
        28      *inlr = *on;                                                                                         000000     002800
        29  /end-free                                                                                                000000     002900
     
           * * * * *   E N D   O F   S O U R C E   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' '
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX6                ' '       19-11-02 11:22:02        Page      4
     
              A d d i t i o n a l   D i a g n o s t i c   M e s s a g e s
     
     Msg id  Sv Number Seq     Message text
    *RNF7030 30     15 001500  The name or indicator U3VTNGF... is not defined.
     
     * * * * *   E N D   O F   A D D I T I O N A L   D I A G N O S T I C   M E S S A G E S   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' '
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX6                ' '       19-11-02 11:22:02        Page      5
     
                              C r o s s   R e f e r e n c e
     
          File and Record References:
     
             File              Device             References (D=Defined)
               Record
             QSYSPRT           PRINTER                 3D     23
             UNIX              SPECIAL                 1D     19      20      21
                                                      24      27
     
          Global Field References:
     
             Field             Attributes         References (D=Defined M=Modified)
             *INLR             N(1)                   28M
             CMD               A(5000)                 5D     12M     15M
             MODE              A(1)                    6D     13M
             OUTREC            DS(132)                 9D     22M     23
             RECORD            DS(1000)                8D     20M     22      24M
             UNIXPARM          PLIST                   2      11D
    *RNF7030 U3VTNGFYWU9FAZC3IAA8ZWBE5UZCFMC17YA4MY...
                               **UNDEF**              15
     
          Indicator References:
     
             Indicator                            References (D=Defined M=Modified)
             LR                                       28M
     
           * * * * *   E N D   O F   C R O S S   R E F E R E N C E   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' '
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX6                ' '       19-11-02 11:22:02        Page      6
     
                          E x t e r n a l   R e f e r e n c e s
     
          Statically bound procedures:
             Procedure                            References
             No references in the source.
     
          Imported fields:
             Field             Attributes         Defined
             No references in the source.
     
          Exported fields:
             Field             Attributes         Defined
             No references in the source.
     
       * * * * *   E N D   O F   E X T E R N A L   R E F E R E N C E S   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' '
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX6                ' '       19-11-02 11:22:02        Page      7
     
                              M e s s a g e   S u m m a r y
     
     Msg id  Sv Number Message text
    *RNF2318 00      1 No overflow indicator is specified; indicator assigned and
                       automatic skip to 06 generated.
    *RNF3530 00      2 Data structure has no valid subfields.
    *RNF5377 20      1 The end of the expression is expected.
    *RNF7030 30      1 The name or indicator is not defined.
     
           * * * * *   E N D   O F   M E S S A G E   S U M M A R Y   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' '
     5770WDS V7R3M0  160422 RN        IBM ILE RPG             RISHI/EX6                ' '       19-11-02 11:22:02        Page      8
     
                                F i n a l   S u m m a r y
     
      Message Totals:
     
        Information  (00) . . . . . . . :        3
        Warning      (10) . . . . . . . :        0
        Error        (20) . . . . . . . :        1
        Severe Error (30+)  . . . . . . :        1
        ---------------------------------  -------
        Total . . . . . . . . . . . . . :        5
     
     
      Source Totals:
     
        Records . . . . . . . . . . . . :       29
        Specifications  . . . . . . . . :       23
        Data records  . . . . . . . . . :        0
        Comments  . . . . . . . . . . . :        0
     
             * * * * *   E N D   O F   F I N A L   S U M M A R Y   * * * * *
    Compilation stopped. Severity 30 errors found in program.
              * * * * *   E N D   O F   C O M P I L A T I O N   * * * * *
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
                                                         ' '   ' '
    
    2,920 pointsBadges:
    report
  • 6r
    But some how if we don't hard code this text value in program and directly read from that input XML file, as my previously pasted program was reading it from input XML file then why was it not showing the decrypted value in record field, whereas the same when we execute interactively shows the decrypted value on the console itself.

    2,920 pointsBadges:
    report
  • ToddN2000
    @6r: We try to respond when we can and see if we can provide additional information. We try to help a poster fix their issue but sometimes we cannot due to insufficient information. Sometimes we ask for additional information and get none. We can point you in a direction that may resolve your issues and never hear back if it worked. I know a lot of us do this for the benefit of the community, we don't get paid. Would you volunteer to help others for free.  Those of us regulars that are still working, have to fit this into our time to helping other between putting out IT fires, meeting project deadlines, implementing new websites, writing code and user manuals. Sometimes it may be a few days or weeks before we can get back to the site.  You have been given a few suggestions. The only thing I'm thinking now and like I said it been decades since I worked with Unix. Some commands, regardless of the language are specific. Some will work interactively from a command line only and not in a program or batch process.

    Have you asked on any other site? What have they given you for a response?

    Google the issue and there are a lot of sites that address your issue.This is a good one. https://archive.midrange.com/midrange-l/201909/msg00267.html

    I have poked around at a few and NONE are using Unix.. Is there a reason you are using it?

    135,465 pointsBadges:
    report
  • 6r
    ya,that i have already gone through and that did not serve my purpose also reason for using openssl is that it has worked well in interactive way so i think it should work in programmatic way as well.
    2,920 pointsBadges:
    report
  • carlosdl
    "if i do as advised then program does not compile at all".

    I don't think you have tried "as advised".  If you were not sure what he meant, it would have been a good idea to ask.

    As I said before, I have never worked with the iSeries, but based on my experience with other platforms, I would assume that @TheRealRaven meant to use 2 single quotes (not double quotes) as a way to escape the single quote that needs to be inside of a string that is also enclosed in quotes.

    So, I would try something like this:

    cmd = 'echo ''u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4My'+
           'W0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL93B4iKiODHxxdVA=='''+
           ' | openssl enc -d -aes-128-ecb -K 363631653237354f494d'+
           '31554c594c4a -nopad -nosalt -base64 -A';

    Here I assumed that the '+' sign is some kind of concatenation operator.  If that is not the case, and it is only used to indicate that the instruction continues in the next line, then it would be something like this:

    	   cmd = 'echo ''u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4My+
           W0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL93B4iKiODHxxdVA==''+
            | openssl enc -d -aes-128-ecb -K 363631653237354f494d+
           31554c594c4a -nopad -nosalt -base64 -A';

    If this doesn't help, I will definitely not be able to offer any additional recommendation, as this is really out of my area.

    Good luck.

    85,430 pointsBadges:
    report
  • 6r
    it's actually just the whole string in encodedexchangetoken field 
    'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL
    93B4iKiODHxxdVA=='

    which i tried as per advise but still expected decrypted value is not coming inside it please see my code and corresponding values in debug session for record field and cmd field.result of below coding :-
    00      cmd = 'echo ''u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4My'+    
    00     'W0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL93B4iKiODHxxdVA=='''+    
    00   ' |  openssl enc -d -aes-128-ecb -K 363631653237354f494d'+   
    00   '31554c594c4a -nopad -nosalt -base64 -A -out record';        
    00      open UNIX;                                                
    
    
    
                                  Evaluate Expression                               
                                                                                    
     Previous debug expressions                                                     
                                                                                    
     > EVAL cmd                                                                     
       CMD =                                                                        
                 ....5...10...15...20...25...30...35...40...45...50...55...60       
            1   'echo 'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCc'      
           61   'gMZiG/kXPE4vv2CHL93B4iKiODHxxdVA==' |  openssl enc -d -aes-1'      
          121   '28-ecb -K 363631653237354f494d31554c594c4a -nopad -nosalt -b'      
          181   'ase64 -A -out record                                        '      
          241   '                                                            '      
          301   '                                                            '      
          361   '                                                            '      
          421   '                                                            '      
          481   '                                                            '      
          541   '                                                            '      
          601   '                                                            '      
                                                                            More... 
     Debug . . .                                                                    
                                                                                    
     F3=Exit   F9=Retrieve   F12=Cancel   F16=Repeat find   F19=Left   F20=Right    
     F21=Command entry       F23=Display output                                     
                                  Evaluate Expression                               
               
    
    Result of RECORD Field during same debug session:-
                                                                         
     Previous debug expressions                                                     
                                                                                    
     > EVAL record                                                                  
       RECORD =                                                                     
                 ....5...10...15...20...25...30...35...40...45...50...55...60       
            1   'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/'      
           61   'kXPE4vv2CHL93B4iKiODHxxdVA== | openssl enc -d -aes-128-ecb -'      
          121   'K 363631653237354f494d31554c594c4a -nopad -nosalt -base64 -A'      
          181   ' -out record                                                '      
          241   '                                                            '      
          301   '                                                            '      
          361   '                                                            '      
          421   '                                                            '      
          481   '                                                            '      
          541   '                                                            '      
          601   '                                                            '      
                                                                            More... 
     Debug . . .                                                                    
    
    
    ************************************************************************************************
    
    2,920 pointsBadges:
    report
  • 6r
    one more strange thing is happening when I am just debugging  and testing only this value 'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL
    93B4iKiODHxxdVA==
    '  then in debug mode that pipe symbol automatically changes to some different character and becomes like '!' or some times to some other different character how is it happening it's  very strange.
    please see value got changed in debug mode:-

                                Display Module Source                              
                                                                                   
    Program:   EX6            Library:   RISHI          Module:   EX6              
        16           'W0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL93B4iKiODHxxdVA=='''+       
        17         ' !  openssl enc -d -aes-128-ecb -K 363631653237354f494d'+      
        18         '31554c594c4a -nopad -nosalt -base64 -A -out record';           
        19            open UNIX;                                                   
        20            read UNIX record;                                            
        21            dow not %eof(UNIX);                                          
        22               outrec = record;                                          
        23               write QSYSPRT outrec;                                     
        24               read UNIX record;                                         
        25            enddo;                                                       
        26                                                                         
        27            close UNIX;                                                  
        28            *inlr = *on;                                                 
        29        /end-free                                      
    2,920 pointsBadges:
    report
  • ToddN2000
    @6r: What is the debug value of OUTREC used in the RPG program?
    135,465 pointsBadges:
    report
  • 6r
    In parallel to this I have been trying that IBM API called 'Qc3DecryptData' also to decrypt the data and key present in attached below sample program but it's ending up in multiple compilation errors :-
    *RNF5248 20      1 ENDyy operation out of sequence; an END is assumed.         
    *RNF0637 30      1 An operand was expected but was not found; specification is 
                       ignored.                                                    
    *RNF0955 30      1 Item is not valid as the left-hand side of an EVAL operatio 
    *RNF3765 30      1 Not enough parameters specified in the procedure interface. 
    *RNF5141 30      1 ENDyy is specified without associated structured operation. 
    *RNF5347 30      1 An assignment operator is expected with the EVAL operation. 
    *RNF5410 30      1 The prototype for the call is not defined.                  
    *RNF5507 30      1 A semi-colon is not specified at the end of a free-format   
                       statement.                                                  
    *RNF7030 30      4 The name or indicator is not defined.                       
    *RNF7503 30      3 Expression contains an operand that is not defined.         
           * * * * *   E N D   O F   M E S S A G E   S U M M A R Y   * * * * *     
         h nomain bnddir ('QC2LE')
         FCUSPI     UF   E             DISK    USROPN
         FCUSDTA    UF A E             DISK    PREFIX(C) USROPN
         D/COPY QSYSINC/QRPGLESRC,QUSEC
         D/COPY QSYSINC/QRPGLESRC,QC3CCI
         DBILL_CUS         Pr            10I 0 EXTPROC('Bill_Cus')
         d*create_bill     pr            10i 0 extproc('create_bill')
         d cusdta                         1    const
         d balance                       10  2 value
         dcrtalgctx        pr                  extproc('Qc3CreateAlgorithmConte+
         d                                              t')
         dalgd                            1    const
         dalgFormat                       8    const
         dAESctx                          8
         derrCod                          1
         dCrtKeyCtx        PR                  extproc('Qc3CreateKeyContext')
         DKEY                             1    CONST
         DKEYSIZE                        10I 0 CONST
         DKEYFORMAT                       1    CONST
         DKEYTYPE                        10I 0 CONST
         DKEYFORM                         1    CONST
         DKEYENCKEY                       8    CONST  OPTIONS(*OMIT)
         DKEYENCALG                       8    CONST  OPTIONS(*OMIT)
         DKEYTKN                          8
         DERRCOD                          1
         DDESTROYKEYCTX    PR                  EXTPROC ('Qc3DestroyKeyContext')
         DKEYTKN                          8    CONST
         DERRCOD                          1
         DDestroyAlgCtx    PR                  EXTPROC('Qc3DestroyAlgorithmCont+
         D                                             ext')
         dAESTkn                          8    CONST
         Derrcod                          1
         dDecryptData      pr                  extproc('Qc3DecryptData')
         Dencdata                         1    const
         D encDataSize                   10i 0 const
         D algDesc                        1    const
         D algDescFmt                     8    const
         D keyDesc                        1    const
         D keyDescFmt                     8    const
         D csp                            1    const
         D cspDevNam                     10    const options(*omit)
         D clrDta                         1
         D clrLenPrv                     10i 0 const
         D clrLenRtn                     10i 0
         D clrLenPrv                     10i 0 const
         D clrLenRtn                     10i 0
         D errCod                         1
    
         DPrint            pr            10i 0 extproc('printf')
         D charString                     1    const options(*nopass)
         PBill_Cus         b                   export
         DBill_Cus         pi            10i 0
         D csp             s              1    inz('0')
         D error           s             10i 0 inz(-1)
         D ok              s             10i 0 inz(0)
         D rtn             s             10i 0
         D rtnLen          s             10i 0
         D plainLen        s             10i 0
         D cipherLen       s             10i 0
         D kekTkn          s              8
         D AESctx          s              8
         D KEKctx          s              8
         D FKctx           s              8
         D keySize         s             10i 0
         D keyType         s             10i 0
         D keyFormat       s              1
         D keyForm         s              1
         D inCusInfo       s             80
         D inCusNum        s              8  0
         D ECUSDTA         s             80
         C                   eval      QUSBPRV = 0
          *    * Create an AES algorithm context for the key-encrypting key
          *    *(KEK)
         C                   eval      QC3D0200 = *loval
         C                   eval      QC3BCA = 22
         C                   eval      QC3BL = 16
         C                   eval      QC3MODE = '1'
         C                   eval      QC3PO = '0'
         C                   callp     CrtAlgCtx( QC3D0200 :'ALGD0200'
         C                                       :AESctx   :QUSEC)
          * Create a key context for the key-encrypting key (KEK)
         C                   eval      keySize = %size(QC3D040000)
         C                   eval      keyFormat = '0'
         C                   eval      keyType = 22
         C                   eval      keyForm = '0'
         C                   eval      QC3D040000 = *loval
         C                   eval      QC3KS00 = 'CUSKEYFILEMY_LIB'
         C                   eval      QC3RL = 'CUSDTAKEK'
         C                   callp     CrtKeyCtx( QC3D040000 :keySize :'4'
         C                                       :keyType    :keyForm :*omit
         c                                       :*omit    :kekctx    :QUSEC)
          * Open CUSPI file
         C                   open(e)   cuspi
         C                   if        %error = '1'
         C                   callp     Print('Open of Customer Processing -
          *                        Information File (CUSPI) failed')
         C                   return    error
         C                   endif
         c*Read first (only) record to get encrypted file key
         C                   read(e)   cuspirec
         C                   if        %eof = '1'
         C                   callp     Print('Customer Processing information cuspi-
         C                             record missing')
         C                   close     cuspi
         c                   return    error
         C                   endif
         C                   close     cuspi
               * Create a key context for the file key
         C                   eval      keySize = %size(KEY)
         C                   eval      keyFormat = '0'
         C                   eval      keyType = 22
         C                   eval      keyForm = '1'
         C                   callp     CrtKeyCtx( KEY     :keySize   :keyFormat    +
         c                             :keytype :keyform  :KEKctx                  +
         c                             AESctx  :FKctx    :QUSEC)
         c*Wipe out the encrypted file key value from program storage
         C                   eval      Key = *loval
          *  Open CUSDTA
         C                   open(e)   cusdta
         C                   if        %error = '1'
         C                   callp     Print('Open of CUSDTA file failed')
         c                   close     cuspi
         c                   return    error
         c                   endif
          * read each record of CUSDTA
         C                   READ(E)   CUSDTAREC
         C                   DOW       %EOF <> '1'
         C*If accounts receivable balance > 0, decrypt customer data and
          * create a bill
         C*                  if        CARBAL > 0
          * Decrypt customer information
         C                   eval      QC3IV = CIV
         C                   eval      plainLen = %size(CCUSDTA)
         C                   eval      cipherLen = %size(ECUSDTA)
         C                   callp     DecryptData( CCUSDTA    :cipherLen
         C                                         :QC3D0200   :'ALGD0200'
         C                                         :FKctx      :'KEYD0100'
         C                                         :csp        :*OMIT
         C                                         :ECUSDTA    :plainLen
         C                                         :rtnLen     :QUSEC)
         C*                  callp     Create_Bill( ECUSDTA :CARBAL)
         C                   endif
         C                   read(e)   cusdtarec
         C                   enddo
          * Cleanup
         C                   eval      ecusdta = *loval
         C                   callp     DestroyKeyCtx( FKctx  :QUSEC)
         C                   callp     DestroyKeyCtx( KEKctx :QUSEC)
         C                   callp     DestroyAlgCtx( AESctx  :QUSEC)
         C                   close     cusdta
         C                   return    ok
    
         c                   eval      *inlr = *on
         P                 e
    
    2,920 pointsBadges:
    report
  • 6r
    it's coming as blanks in debug mode:-

                                  Evaluate Expression                               
                                                                                    
     Previous debug expressions                                                     
                                                                                    
          541   '                                                            '      
          601   '                                                            '      
          661   '                                                            '      
          721   '                                                            '      
          781   '                                                            '      
          841   '                                                            '      
          901   '                                                            '      
          961   '                                        '                          
     > EVAL outrec                                                                  
       OUTREC =                                                                     
                 ....5...10...15...20...25...30...35...40...45...50...55...60       
            1   '                                                            '      
           61   '                                                            '      
          121   '            '                                                      
                                                                             Bottom 
     Debug . . .                                                                    
                                                                                    
     F3=Exit   F9=Retrieve   F12=Cancel   F16=Repeat find   F19=Left   F20=Right    
     F21=Command entry       F23=Display output                                     
                                                                                    
    2,920 pointsBadges:
    report
  • 6r
    it's coming as blanks                              Evaluate Expression                               
                                                                                    
     Previous debug expressions                                                     
                                                                                    
          541   '                                                            '      
          601   '                                                            '      
          661   '                                                            '      
          721   '                                                            '      
          781   '                                                            '      
          841   '                                                            '      
          901   '                                                            '      
          961   '                                        '                          
     > EVAL outrec                                                                  
       OUTREC =                                                                     
                 ....5...10...15...20...25...30...35...40...45...50...55...60       
            1   '                                                            '      
           61   '                                                            '      
          121   '            '                                                      
                                                                             Bottom 
     Debug . . .                                                                    
                                                                                    
     F3=Exit   F9=Retrieve   F12=Cancel   F16=Repeat find   F19=Left   F20=Right    
     F21=Command entry       F23=Display output                                     
                                                                                    
    2,920 pointsBadges:
    report
  • 6r
    it's coming as blanks only:-
                                  Evaluate Expression                               
                                                                                    
     Previous debug expressions                                                     
                                                                                    
          541   '                                                            '      
          601   '                                                            '      
          661   '                                                            '      
          721   '                                                            '      
          781   '                                                            '      
          841   '                                                            '      
          901   '                                                            '      
          961   '                                        '                          
     > EVAL outrec                                                                  
       OUTREC =                                                                     
                 ....5...10...15...20...25...30...35...40...45...50...55...60       
            1   '                                                            '      
           61   '                                                            '      
          121   '            '                                                      
                                                                             Bottom 
     Debug . . .                                                                    
                                                                                    
     F3=Exit   F9=Retrieve   F12=Cancel   F16=Repeat find   F19=Left   F20=Right    
     F21=Command entry       F23=Display output                                     
                                                                                    
    2,920 pointsBadges:
    report
  • 6r
    Previous debug expressions                                                     
                                                                                   
    > EVAL outrec                                                                  
      OUTREC =                                                                     
                ....5...10...15...20...25...30...35...40...45...50...55...60       
           1   'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/'      
          61   'kXPE4vv2CHL93B4iKiODHxxdVA==¦ openssl enc -d -aes-128-ecb -K'      
         121   ' 36363165323'                                                      
                                                                                   
                                                                                   
                                                                                   
                                                                                   Previous debug expressions                                                     
                                                                                   
    > EVAL outrec                                                                  
      OUTREC =                                                                     
                ....5...10...15...20...25...30...35...40...45...50...55...60       
           1   'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/'      
          61   'kXPE4vv2CHL93B4iKiODHxxdVA==¦ openssl enc -d -aes-128-ecb -K'      
         121   ' 36363165323'                                                      
                                                                                   
                                                                                   
                                                                                   
                                                                                   
    2,920 pointsBadges:
    report
  • 6r
                                  Evaluate Expression                               
                                                                                    
     Previous debug expressions                                                     
                                                                                    
     > EVAL outrec                                                                  
       OUTREC =                                                                     
                 ....5...10...15...20...25...30...35...40...45...50...55...60       
            1   'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/'      
           61   'kXPE4vv2CHL93B4iKiODHxxdVA== ¦ openssl enc -d -aes-128-ecb -'      
          121   'K 3636316532'                                                      
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                             Bottom 
     Debug . . .                                                                    
                                                                                     Evaluate Expression                               
                                                                                    
     Previous debug expressions                                                     
                                                                                    
     > EVAL outrec                                                                  
       OUTREC =                                                                     
                 ....5...10...15...20...25...30...35...40...45...50...55...60       
            1   'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/'      
           61   'kXPE4vv2CHL93B4iKiODHxxdVA== ¦ openssl enc -d -aes-128-ecb -'      
          121   'K 3636316532'                                                      
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                                    
                                                                             Bottom 
     Debug . . .                                                                    
                                                                                    
    2,920 pointsBadges:
    report
  • 6r
                                  Evaluate Expression                              
                                                                                   
     Previous debug expressions                                                    
                                                                                   
     > EVAL outrec                                                                 
       OUTREC =                                                                    
                 ....5...10...15...20...25...30...35...40...45...50...55...60      
            1   'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/'     
           61   'kXPE4vv2CHL93B4iKiODHxxdVA== ¦ openssl enc -d -aes-128-ecb -'     
          121   'K 3636316532'                                                     
                                                                                   
                                                                                   
                                                                                   
                                                                                   
                                                                                   
                                                                                   
                                                                                   
                                                                                   
                                                                             Bottom
     Debug . . .                                                                   
                                                                                   
     F3=Exit   F9=Retrieve   F12=Cancel   F16=Repeat find   F19=Left   F20=Right   
    2,920 pointsBadges:
    report
  • 6r
    However I was able to remove many of compilation errors after following those  IBM links :-

    https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/apis/qc3BillCusILERPG.htm

    https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/apis/qc3Scenario.htm

    still few errors exist:-
    *RNF7031 00     98 The name or indicator is not referenced.                   
    *RNF0267 20      1 Character literal has missing trailing apostrophe; trailing
                       apostrophe assumed.                                        
    *RNF0312 20      1 A right parenthesis is expected but is not found.          
    *RNF1304 20      1 The NOMAIN keyword is not valid when the CRTBNDRPG command 
                       used to create a program.                                  
    *RNF0637 30      1 An operand was expected but was not found; specification is
                       ignored.                                                   
    *RNF5406 30      1 The call passed fewer parameters than the prototype indicat
                       are required.                                              
    *RNF7536 30      1 The type of the parameter specified for the call does not  
                       match the prototype.                                        

    But As openssl seems to be easier task so I was more focussing on that so if anyone on this forum able to let me know what is going wrong with openssl program then it would be much appreciated.

    Thanks Much...
    2,920 pointsBadges:
    report
  • 6r
    so any updates please?
    2,920 pointsBadges:
    report
  • 6r
    for openssl part i meant.
    2,920 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: