IBM i Global

IBM i Global

Connect, learn, share, and engage with IBM Power.

 View Only
  • 1.  Calculate sha256sum of a program object

    Posted Tue July 09, 2024 09:15 AM
    Edited by Paolo Salvatore Tue July 09, 2024 09:15 AM

    Hi, 

    I'll try to explain my need.

    When I made a compilation I want to calculate the sha256sum of the source and the object generated by that source.

    For the source is not a problem, but for the program object I can't.

    Do you know some api who made the same thing as dmpobj?

    So I can take the output of the dump and pass it to the sha256sum.

    Thank you



    ------------------------------
    Paolo Salvatore
    ------------------------------



  • 2.  RE: Calculate sha256sum of a program object

    Posted Wed July 10, 2024 08:47 AM

    Ciao,

    compared to other system where the program file is a "opaque blob" that you can feed into a calculation using the stream abstraction, *PGM is a more articulate thing in the i operating system, even for security and robustness reasons.

    For example, usage information, save information etc. will change on a day by day basis.

    It depends on you want to achieve. Maybe hash a subset of attributes?

    If it is for security or audit purposes or alterations, maybe it is better to use auditing to have a track or security to prevent alterations.

    You can hash a SAVF pretty easily in the system via PASE sha256sum, if the task is binary distribution etc.



    ------------------------------
    --ft
    ------------------------------



  • 3.  RE: Calculate sha256sum of a program object

    Posted Thu October 17, 2024 08:53 AM

    To second Ace on this, 

    Perhaps signing the object with a certificate might be a viable option too?

    Reference : https://www.ibm.com/docs/en/i/7.5?topic=suasovos-scenario-details-using-apis-sign-objects-verify-object-signatures 

    (if the intention is to provide that someone didn't tamper with the objects) 



    ------------------------------
    Marius le Roux
    Owner
    MLR Consulting
    ------------------------------



  • 4.  RE: Calculate sha256sum of a program object

    Posted Thu October 17, 2024 09:11 AM

    Hi,

    In addition to what Marius and ACE has already provided, below is a link to the IBM API's page.

    Calculate Hash (QC3CALHA, Qc3CalculateHash) API - IBM Documentation



    ------------------------------
    Rohit Chauhan
    Senior Technical Specialist
    Norway
    ------------------------------



  • 5.  RE: Calculate sha256sum of a program object

    Posted Thu October 17, 2024 09:22 AM

    Have you tried to read the program object contents using IFS procedures or the IFS SQL functions?

    For the source - it's also important to think of PF-SRC members vs. IFS source files - I implemented it by trimming the line content und adding a typical CR/LF to it, to ensure that member and IFS will somehow end up with the same SHA256. 

    HTH

    Daniel



    ------------------------------
    Daniel Gross
    ------------------------------



  • 6.  RE: Calculate sha256sum of a program object

    Posted Fri October 18, 2024 02:43 AM

    Calculate MD5 Hash for Stream File

    https://archive.midrange.com/midrange-l/202012/msg00506.html



    ------------------------------
    Fernando Plaza
    IBM i System Administrator
    CD INVEST
    MADRID
    +34637503273
    ------------------------------