midrange.com code scratchpad
Name:
Sample program is not getting compiled
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
11/07/2019 05:16:23 pm
IP:
Logged
Description:
Hi,

To test decryption API I am trying to compile sample program pasted below its the same I am trying from this iIBM URL but its not getting compiled and giving below compilation errors:-

*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.
* * * * * E N D O F M E S S A G E S U M M A R Y * * * * *
VF61 Volvo IT

IBM URL:-https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/apis/qc3BillCusILERPG.htm
Code:
  1.      h nomain bnddir ('QC2LE')
  2.      FCUSPI     UF   E             DISK    USROPN
  3.      FCUSDTA    UF A E             DISK    PREFIX(C) USROPN
  4.      D/COPY QSYSINC/QRPGLESRC,QUSEC
  5.      D/COPY QSYSINC/QRPGLESRC,QC3CCI
  6.      DBILL_CUS         Pr            10I 0 EXTPROC('Bill_Cus')
  7.      d*create_bill     pr            10i 0 extproc('create_bill')
  8.      d cusdta                         1    const
  9.      d balance                       10  2 value
  10.      dcrtalgctx        pr                  extproc('Qc3CreateAlgorithmConte+
  11.      d                                              t')
  12.      dalgd                            1    const
  13.      dalgFormat                       8    const
  14.      dAESctx                          8
  15.      derrCod                          1
  16.      dCrtKeyCtx        PR                  extproc('Qc3CreateKeyContext')
  17.      DKEY                             1    CONST
  18.      DKEYSIZE                        10I 0 CONST
  19.      DKEYFORMAT                       1    CONST
  20.      DKEYTYPE                        10I 0 CONST
  21.      DKEYFORM                         1    CONST
  22.      DKEYENCKEY                       8    CONST  OPTIONS(*OMIT)
  23.      DKEYENCALG                       8    CONST  OPTIONS(*OMIT)
  24.      DKEYTKN                          8
  25.      DERRCOD                          1
  26.      DDESTROYKEYCTX    PR                  EXTPROC ('Qc3DestroyKeyContext')
  27.      DKEYTKN                          8    CONST
  28.      DERRCOD                          1
  29.      DDestroyAlgCtx    PR                  EXTPROC('Qc3DestroyAlgorithmCont+
  30.      D                                             ext')
  31.      dAESTkn                          8    CONST
  32.      Derrcod                          1
  33.      dDecryptData      pr                  extproc('Qc3DecryptData')
  34.      Dencdata                         1    const
  35.      D encDataSize                   10i 0 const
  36.      D algDesc                        1    const
  37.      D algDescFmt                     8    const
  38.      D keyDesc                        1    const
  39.      D keyDescFmt                     8    const
  40.      D csp                            1    const
  41.      D cspDevNam                     10    const options(*omit)
  42.      D clrDta                         1
  43.      D clrLenPrv                     10i 0 const
  44.      D clrLenRtn                     10i 0
  45.      D clrLenPrv                     10i 0 const
  46.      D clrLenRtn                     10i 0
  47.      D errCod                         1
  48.  
  49.      DPrint            pr            10i 0 extproc('printf')
  50.      D charString                     1    const options(*nopass)
  51.      PBill_Cus         b                   export
  52.      DBill_Cus         pi            10i 0
  53.      D csp             s              1    inz('0')
  54.      D error           s             10i 0 inz(-1)
  55.      D ok              s             10i 0 inz(0)
  56.      D rtn             s             10i 0
  57.      D rtnLen          s             10i 0
  58.      D plainLen        s             10i 0
  59.      D cipherLen       s             10i 0
  60.      D kekTkn          s              8
  61.      D AESctx          s              8
  62.      D KEKctx          s              8
  63.      D FKctx           s              8
  64.      D keySize         s             10i 0
  65.      D keyType         s             10i 0
  66.      D keyFormat       s              1
  67.      D keyForm         s              1
  68.      D inCusInfo       s             80
  69.      D inCusNum        s              8  0
  70.      D ECUSDTA         s             80
  71.      C                   eval      QUSBPRV = 0
  72.       *    * Create an AES algorithm context for the key-encrypting key
  73.       *    *(KEK)
  74.      C                   eval      QC3D0200 = *loval
  75.      C                   eval      QC3BCA = 22
  76.      C                   eval      QC3BL = 16
  77.      C                   eval      QC3MODE = '1'
  78.      C                   eval      QC3PO = '0'
  79.      C                   callp     CrtAlgCtx( QC3D0200 :'ALGD0200'
  80.      C                                       :AESctx   :QUSEC)
  81.       * Create a key context for the key-encrypting key (KEK)
  82.      C                   eval      keySize = %size(QC3D040000)
  83.      C                   eval      keyFormat = '0'
  84.      C                   eval      keyType = 22
  85.      C                   eval      keyForm = '0'
  86.      C                   eval      QC3D040000 = *loval
  87.      C                   eval      QC3KS00 = 'CUSKEYFILEMY_LIB'
  88.      C                   eval      QC3RL = 'CUSDTAKEK'
  89.      C                   callp     CrtKeyCtx( QC3D040000 :keySize :'4'
  90.      C                                       :keyType    :keyForm :*omit
  91.      c                                       :*omit    :kekctx    :QUSEC)
  92.       * Open CUSPI file
  93.      C                   open(e)   cuspi
  94.      C                   if        %error = '1'
  95.      C                   callp     Print('Open of Customer Processing -
  96.       *                        Information File (CUSPI) failed')
  97.      C                   return    error
  98.      C                   endif
  99.      c*Read first (only) record to get encrypted file key
  100.      C                   read(e)   cuspirec
  101.      C                   if        %eof = '1'
  102.      C                   callp     Print('Customer Processing information cuspi-
  103.      C                             record missing')
  104.      C                   close     cuspi
  105.      c                   return    error
  106.      C                   endif
  107.      C                   close     cuspi
  108.            * Create a key context for the file key
  109.      C                   eval      keySize = %size(KEY)
  110.      C                   eval      keyFormat = '0'
  111.      C                   eval      keyType = 22
  112.      C                   eval      keyForm = '1'
  113.      C                   callp     CrtKeyCtx( KEY     :keySize   :keyFormat    +
  114.      c                             :keytype :keyform  :KEKctx                  +
  115.      c                             AESctx  :FKctx    :QUSEC)
  116.      c*Wipe out the encrypted file key value from program storage
  117.      C                   eval      Key = *loval
  118.       *  Open CUSDTA
  119.      C                   open(e)   cusdta
  120.      C                   if        %error = '1'
  121.      C                   callp     Print('Open of CUSDTA file failed')
  122.      c                   close     cuspi
  123.      c                   return    error
  124.      c                   endif
  125.       * read each record of CUSDTA
  126.      C                   READ(E)   CUSDTAREC
  127.      C                   DOW       %EOF <> '1'
  128.      C*If accounts receivable balance > 0, decrypt customer data and
  129.       * create a bill
  130.      C*                  if        CARBAL > 0
  131.       * Decrypt customer information
  132.      C                   eval      QC3IV = CIV
  133.      C                   eval      plainLen = %size(CCUSDTA)
  134.      C                   eval      cipherLen = %size(ECUSDTA)
  135.      C                   callp     DecryptData( CCUSDTA    :cipherLen
  136.      C                                         :QC3D0200   :'ALGD0200'
  137.      C                                         :FKctx      :'KEYD0100'
  138.      C                                         :csp        :*OMIT
  139.      C                                         :ECUSDTA    :plainLen
  140.      C                                         :rtnLen     :QUSEC)
  141.      C*                  callp     Create_Bill( ECUSDTA :CARBAL)
  142.      C                   endif
  143.      C                   read(e)   cusdtarec
  144.      C                   enddo
  145.       * Cleanup
  146.      C                   eval      ecusdta = *loval
  147.      C                   callp     DestroyKeyCtx( FKctx  :QUSEC)
  148.      C                   callp     DestroyKeyCtx( KEKctx :QUSEC)
  149.      C                   callp     DestroyAlgCtx( AESctx  :QUSEC)
  150.      C                   close     cusdta
  151.      C                   return    ok
  152.  
  153.      c                   eval      *inlr = *on
  154.      P                 e
  155.  
© 2004-2019 by midrange.com generated in 0.008s valid xhtml & css