IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SH256/MD5 Checksum in Mainframes JCL


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pinakimishra

New User


Joined: 21 Jul 2007
Posts: 19
Location: phoenix

PostPosted: Mon Mar 04, 2024 7:56 pm
Reply with quote

I am sending a file from Mainframes to Distributed platfro via SFTP in Binary mode(Not ASCII). I need to compare the cheksum of the file in MF vs Distributed Platfrom. Can I generate a checksum in Mainframe fro the entire file? It seems CSNBOWH1 needs a text instead of doing on the entire file.

Can I use BPXBATCH in ZOS? It seems it requires USS Mainframe.

Any suggestions on how can I generate a Hash in ZOS Mainframe? Also how to know which codepage my Mainframe system uses?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Mon Mar 04, 2024 11:22 pm
Reply with quote

Code:
//*=====================================================================
//HASH    EXEC PGM=BPXBATCH                                             
//*                                                                     
//STDOUT   DD  SYSOUT=*                                                 
//STDERR   DD  SYSOUT=*                                                 
//STDPARM  DD  *                                                       
SH sha256 -r "//'SYS69.JCL(TEXT)'"                                     
             "//'SYS69.SECRET.DATA'"                                           
//*                                                                     
//*====================================================================

Code:
********************************* TOP OF DATA ****************************************
-----------------------------------------------------------                           
-       Welcome to z/OS 2.5 UNIX SYSTEM SERVICES          -                           
-             TEST SYSTEM ON THE SYSX LPAR                -                           
-----------------------------------------------------------                           
38a3aa6af230deb1e8761b90f836173893b2dcb42c8e0530063ce31e2e4f3c88  //'SYS69.JCL(TEXT)'
21771f6ccf7fc58d937dcba24e9048009d809379b7277ea3b8ddb6abd64e1e8f  //'SYS69.SECRET.DATA'     
******************************** BOTTOM OF DATA **************************************
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Mon Mar 04, 2024 11:32 pm
Reply with quote

Binary hash form instead of printable format:

Code:
//*====================================================================
//HASHBIN EXEC PGM=BPXBATCH                                           
//*                                                                   
//STDOUT   DD  SYSOUT=*                                               
//STDERR   DD  SYSOUT=*                                               
//STDPARM  DD  *                                                       
SH sha256 -b "//'SYS69.SECRET.DATA'"                                         
//*                                                                   
//*====================================================================

Code:
000001 -----------------------------------------------------------     
000002 -       Welcome to z/OS 2.5 UNIX SYSTEM SERVICES          -     
000003 -             TEST SYSTEM ON THE SYSX LPAR                -     
000004 -----------------------------------------------------------     
000005  Ï %õ"Eýl'ôs+°ç ¸Øl`¼ =t½ù¶¿O+ ±                               
       2716C7C897CA49409897B27ABDBAD41844444444444444444444444444444444
       17FCFF5D3DB2E080D03977E38D6B6EEF00000000000000000000000000000000
Back to top
View user's profile Send private message
pinakimishra

New User


Joined: 21 Jul 2007
Posts: 19
Location: phoenix

PostPosted: Tue Mar 05, 2024 10:46 pm
Reply with quote

Thanks it works. Really helpful. One more question.

I can pass the STDPARM as instream or as an input file. Can I pass this as a parm parameter instead of instream or as an i/p file?

Code:
//STEP1 EXEC PGM=BPXBATCH,REGION=0M,
//           PARM='SH sha256 -r "/TSTB.INPUT.FILE"'

It seems it probably works. But its failing with file not found

Code:
sha256: FSUM6003 input file "/TSTB.INPUT.FILE": EDC5129I No such file or directory.


May be a silly mistake but not able to figure it out.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Tue Mar 05, 2024 11:49 pm
Reply with quote

pinakimishra wrote:
Thanks it works. Really helpful. One more question.

I can pass the STDPARM as instream or as an input file. Can I pass this as a parm parameter instead of instream or as an i/p file?

Code:
//STEP1 EXEC PGM=BPXBATCH,REGION=0M,
//           PARM='SH sha256 -r "/TSTB.INPUT.FILE"'

It seems it probably works. But its failing with file not found

Code:
sha256: FSUM6003 input file "/TSTB.INPUT.FILE": EDC5129I No such file or directory.


May be a silly mistake but not able to figure it out.


0) SH does not require USS file names to be quoted.
1) USS files typically have their names in lowercase, and 100% they are case sensitive.
2) the current directory for SH may be not the same where the data file is located?
Back to top
View user's profile Send private message
pinakimishra

New User


Joined: 21 Jul 2007
Posts: 19
Location: phoenix

PostPosted: Wed Mar 06, 2024 9:33 pm
Reply with quote

The directory and Filename is correct. I get the result when I do the checksum with STDPARM

Code:
//STEP1 EXEC PGM=BPXBATCH,REGION=0M
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//SYSOUT DD *
//STDPARM DD *
SH sha256 -r "//'TSTB.INPUT.FILE'"


o/p

Code:
********************************* TOP OF DATA ****************************************
e0a4027f52de62e011fddbac67f0b56681603c1202ca043a9ba33b0418880c1a  //'TSTB.INPUT.FILE'
******************************** BOTTOM OF DATA **************************************
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Wed Mar 06, 2024 9:53 pm
Reply with quote

Anyway, the message
Code:
FSUM6003 input file "/TSTB.INPUT.FILE": EDC5129I No such file or directory.
is related exclusively to the way how exactly the file name is specified?

It is a general issue with USS/Unix/Linux systems. It has nothing to do with neither BPXBATCH utility, nor with SH program itself.

I would try to test as many syntax options as possible, if there is no explicit example of passing USS file names as parameters to USS utilities.
Back to top
View user's profile Send private message
pinakimishra

New User


Joined: 21 Jul 2007
Posts: 19
Location: phoenix

PostPosted: Wed Mar 06, 2024 10:12 pm
Reply with quote

It worked. The PARM expects the single quote to be doubled which I missed earlier and tried other combinations icon_sad.gif

Code:
//STEP1 EXEC PGM=BPXBATCH,REGION=0M,
//          PARM='SH sha256 -r "//''TSTB.INPUT.FILE''"'
//STDOUT DD SYSOUT=*
Back to top
View user's profile Send private message
pinakimishra

New User


Joined: 21 Jul 2007
Posts: 19
Location: phoenix

PostPosted: Mon Mar 25, 2024 7:49 am
Reply with quote

Is there a way to get the ASCII(unicode) checksum through BPXBATCH i.e. the checksum of the file transferred through SFTP in ASCII mode instead of binary? The checksum returned by BPXBATCH is binary. Have tried the option r b T and all give the same value which is the binary checksum.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Mon Mar 25, 2024 10:24 am
Reply with quote

Maybe an additional iconv could help.
Back to top
View user's profile Send private message
pinakimishra

New User


Joined: 21 Jul 2007
Posts: 19
Location: phoenix

PostPosted: Mon Mar 25, 2024 11:58 pm
Reply with quote

Can you please give an example. I am trying iconv with bpxbatch with both i/ and o/p as Z/OS Files but they are failing with

Code:
iconv: FSUM6180 file "//'TSTB.ULDB.S.LDBD673P.LDBV6730.UNLD'": EDC5129I No such file or directory.


Whereas the BPXBATCH for SHA256 is working.

Code:
//STEP1    EXEC PGM=BPXBATCH
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//SYSOUT DD *
//STDPARM DD *
SH iconv -f IBM-1047 -t ISO8859-1
   "//'TSTB.ULDB.S.LDBD673P.LDBV6730.UNLD'"
    -o "//'TSTB.ULDB.S.LDBD673P.LDBV6730.UNL1'"
/*
//*
//STEP2 EXEC PGM=BPXBATCH,
//      PARM='SH sha256 -T "//''&DSN02''"'
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//SYSOUT DD *
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Tue Mar 26, 2024 3:15 am
Reply with quote

iconv in USS does not support (yet) MVS data set names. But you can use pipes, or files for input to iconv at this point. For ex.
Code:
sha256 -r //\'mvs_dsn\' | iconv -f IBM-1047 -t ISO8859-1 > ascii_output_of_the_sha256_command.txt
Back to top
View user's profile Send private message
pinakimishra

New User


Joined: 21 Jul 2007
Posts: 19
Location: phoenix

PostPosted: Tue Mar 26, 2024 5:12 am
Reply with quote

Seems iconvert is not working

MF File BPXBATCH SHA256- 20839707ae8842e82d82997b0b0ca0909e0446911d86dc7fc7e280dfbe28a20a

In Distributed Platform SHA256-
Checksum:60CAF6943FE76CA0B2CCD0DEDB14A1BCB457097A2E33E96ABE

I did a iconvert in Distributed Platfrom and the check sum is c821170aa6e591800a4a22482255bec6b06046a9e853aae16adfbc5df63c51f3 whereas I was expecting it to be 20839707ae8842e82d82997b0b0ca0909e0446911d86dc7fc7e280dfbe28a20a

I ran a Java program and it returns 60CAF6943FE76CA0B2CCD0DEDB14A1BCB457097A2E33E96ABE which matches with the Distributed environemnt.

I will like to find if there is any in-built functions available in Mainframe to calculate a utf-8 sha256 instead o using a Java Program.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Tue Mar 26, 2024 10:36 am
Reply with quote

Try binary hashes at this point, they should not differ between the platforms.
Back to top
View user's profile Send private message
pinakimishra

New User


Joined: 21 Jul 2007
Posts: 19
Location: phoenix

PostPosted: Tue Mar 26, 2024 11:29 pm
Reply with quote

Binary checksum works perfect. The issue is that I am sending some files through SFTP and for some reason out of 100 files I am having issues with SFTP when sending file in Binary mode and hence thinking of sending these files as ASCII.

These files are simple characters without any COMP-3, COMP etc.
Code:


For example I am sending a file which is of 26 characters but when I am doing SFTP a character 'NAK' (negeative acknowledgement gets added) .

I/P

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
2015-05-08-13.58.48.970629
2015-05-08-13.58.48.970742
2015-05-08-13.58.48.970745
2015-05-08-13.58.48.970746
2015-05-08-13.58.48.970747
2015-05-08-13.58.48.970748
2015-05-08-13.58.48.970749
2015-05-08-13.58.48.970750
2015-05-08-13.58.48.970752
2015-05-08-13.58.48.970753



O/P

ענסץ`נץ`נר`סףKץרKפרKשקנצעשענסץ`נץ`נר`סףKץרKפרKשקנקפעענסץ`נץ`נר`סףKץרKפרKשקנקפץענסץ`נץ`נר`סףKץרKפרKשקנקפצענסץ`נץ`נר`סףKץרKפרKשקנקפקענסץ`נץ`נר`סףKץרKפרKשקנקפרענסץ`נץ`נר`סףKץרKפרKשקנקפשענסץ`נץ`נר`סףKץרKפרKשקנקץנענסץ`נץ`נר`סףKץרKפרKשקנקץעענסץ`נץ`נר`סףKץרKפרKשקנקץף

The 27th character has NAK

hex value of i/p file

Code:
----+----1----+----2----+----3----+---
----+----F----+----F----+----F----+---
----+----1----+----2----+----3----+---
 -------------------------------------
2015-05-08-13.58.48.970745
FFFF6FF6FF6FF4FF4FF4FFFFFF
2015005008013B58B48B970745
 -------------------------------------
2015-05-08-13.58.48.970746
FFFF6FF6FF6FF4FF4FF4FFFFFF
2015005008013B58B48B970746
 -------------------------------------
2015-05-08-13.58.48.970747
FFFF6FF6FF6FF4FF4FF4FFFFFF
2015005008013B58B48B970747
 -------------------------------------


I don't see any special characters

The file is a simple FB File.

General Data
Management class . . : TSTPR
Storage class . . . : TSTP
Volume serial . . . : TST549
Device type . . . . : 3390
Data class . . . . . : STANDARD
Organization . . . : PS
Record format . . . : FB
Record length . . . : 26
Block size . . . . : 27976
1st extent cylinders: 1
Secondary cylinders : 1
Data set name type :
Data set encryption : NO


When I send them as ASCII the they transmit properly. Id some one can suggest what is wrong with the fiel then it will be great.

Even some files are getting truncated.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts After hours quick-fix support for IBM... Mainframe Jobs 0
No new posts Schedulers on Mainframes JCL & VSAM 7
No new posts Mainframes Job opportunity-Full time Mainframe Jobs 0
No new posts IBM z15 mainframes All Other Mainframe Topics 1
No new posts Transferring file to Mainframes IBM Tools 3
Search our Forums:

Back to Top