Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : Sometimes it might be helpful to see only 1 or a few records in HEX (rather than the entire file w/ HEX ON). When VIEWing or EDITing a file use the line command HX to show that line in HEX. To show 3 records, enter HX3. To turn the hex off enter HX (for 1) or HX3 (for 3). Or in the Command area, enter HEX OFF.

Google
 
Web mainframegurukul.com

3DES encryption with clear key

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> COBOL
  View previous topic :: View next topic  
Author Message
marcusmonteiro
Member


Joined: 05 Mar 2018
Posts: 1
Location: Warsaw, Poland

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Mar 05, 2018 3:01 pm    Post subject: 3DES encryption with clear key Reply with quote

I'm trying to write a Cobol program with the following interface:

Objective
Receives a clear encryption key and a clear text and returns a cyphered text using the 3DES algorithm.

Inputs:
CLEAR_KEY: A 32-character string of hexadecimal characters to be used as the encryption key.
CLEAR_TEXT: A 16-character string.

Output:
CYPHERED_TEXT: A 16-character string.

I have access to DB2 and ICSF callable services.

I tried these three approaches:

Using CSNBSYE

77 CSNBSYE PIC X(7) VALUE 'CSNBSYE'.
01 CSNBSYE-PARAMETERS.
02 RETURN-CODE PIC 9(8) COMP.
02 REASON-CODE PIC 9(8) COMP.
02 EXIT-DATA-LENGTH PIC 9(8) COMP.
02 EXIT-DATA PIC X(32).
02 RULE-ARRAY-COUNT PIC 9(8) COMP.
02 RULE-ARRAY PIC X(8).
02 KEY-IDENTIFIER-LENGTH PIC 9(8) COMP.
02 KEY-IDENTIFIER PIC X(32).
02 KEY-PARMS-LENGTH PIC 9(8) COMP.
02 KEY-PARMS PIC X(32).
02 BLOCK-SIZE PIC 9(8) COMP.
02 INIT-VECTOR-LENGTH PIC 9(8) COMP.
02 INIT-VECTOR PIC X(8).
02 CHAIN-DATA-LENGTH PIC 9(8) COMP.
02 CHAIN-DATA PIC X(16).
02 CLEAR-TEXT-LENGTH PIC 9(8) COMP.
02 CLEAR-TEXT PIC X(16).
02 CYPHERED-TEXT-LENGTH PIC 9(8) COMP.
02 CYPHERED-TEXT PIC X(16).
02 OPTIONAL-DATA-LENGTH PIC 9(8) COMP.
02 OPTIONAL-DATA PIC X(32).

INITIALIZE CSNBSYE-PARAMETERS.

MOVE 1 TO RULE-ARRAY-COUNT.
MOVE 'DES ' TO RULE-ARRAY.
MOVE 16 TO KEY-IDENTIFIER-LENGTH.
MOVE '2DF65FD88EA9E17E3C66950387F91DE2' TO KEY-IDENTIFIER.
MOVE 8 TO BLOCK-SIZE
INIT-VECTOR-LENGTH.
MOVE ALL ZEROS TO INIT-VECTOR.
MOVE 16 TO CHAIN-DATA-LENGTH.
MOVE LOW-VALUES TO CHAIN-DATA.
MOVE 16 TO CLEAR-TEXT-LENGTH
CYPHERED-TEXT-LENGTH.
MOVE ALL ZEROS TO CLEAR-TEXT.

CALL CSNBSYE USING RETURN-CODE,
REASON-CODE,
EXIT-DATA-LENGTH,
EXIT-DATA,
RULE-ARRAY-COUNT,
RULE-ARRAY,
KEY-IDENTIFIER-LENGTH,
KEY-IDENTIFIER,
KEY-PARMS-LENGTH,
KEY-PARMS,
BLOCK-SIZE,
INIT-VECTOR-LENGTH,
INIT-VECTOR,
CHAIN-DATA-LENGTH,
CHAIN-DATA,
CLEAR-TEXT-LENGTH,
CLEAR-TEXT,
CYPHERED-TEXT-LENGTH,
CYPHERED-TEXT,
OPTIONAL-DATA-LENGTH,
OPTIONAL-DATA.

Using CSNBECO

77 CSNBECO PIC X(7) VALUE 'CSNBECO'.
01 CSNBECO-PARAMETERS.
02 RETURN-CODE PIC 9(8) COMP.
02 REASON-CODE PIC 9(8) COMP.
02 EXIT-DATA-LENGTH PIC 9(8) COMP.
02 EXIT-DATA PIC X(32).
02 CLEAR-KEY PIC X(32).
02 CLEAR-TEXT PIC X(16).
02 CYPHERED-TEXT PIC X(16).

INITIALIZE CSNBECO-PARAMETERS.

MOVE '2DF65FD88EA9E17E3C66950387F91DE2' TO CLEAR-KEY.
MOVE ALL ZEROS TO CLEAR-TEXT.

CALL CSNBSYE USING RETURN-CODE,
REASON-CODE,
EXIT-DATA-LENGTH,
EXIT-DATA,
CLEAR-KEY,
CLEAR-TEXT,
CYPHERED-TEXT.

Using DB2's ENCRYPT_TDES

01 WS.
02 CLEAR-TEXT PIC X(16).
02 CYPHERED-TEXT PIC X(16).

MOVE ALL ZEROS TO CLEAR-TEXT.

EXEC SQL
SELECT ENCRYPT_TDES(:CLEAR-TEXT, '2DF65FD88EA9E17E3C66950387F91DE2')
INTO :CYPHERED-TEXT
FROM SYSIBM.SYSDUMMY1
END-EXEC.
But none of these approaches returned the result I expected. The result I'm expecting is the same obtained from testing in this website: http://tripledes.online-domain-tools.com/ , with the following data:

Input type: Text

Input Text: 0000000000000000 (HEX)

Function: 3DES

Mode: CBC

Key: 2DF65FD88EA9E17E3C66950387F91DE2 (HEX)

Init Vector: 00 00 00 00 00 00 00 00

Encrypt!

Encrypted Text (result): 87 30 e1 ef 98 3d f2 b4 (HEX) | . 0 = (STRING)

My question is: how can I obtain the result above in a Cobol program, using any of the tools provided by IBM?

Thank you!
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> COBOL All times are GMT + 5 Hours
Page 1 of 1



 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts Split a file based on header value 0 Gunex2 62 Tue Jun 05, 2018 12:44 pm
Gunex2 View latest post
No new posts Compare 2 files with dynamic value for key in Jcl 0 karthi88698 328 Mon Apr 09, 2018 10:41 am
karthi88698 View latest post
No new posts Conver the HEX values 2 deepu2pani 1171 Fri Aug 11, 2017 1:22 pm
shrikant View latest post
No new posts level 88 condition with short alphanumeric literal VALUE 0 mhoward 838 Thu Mar 09, 2017 9:24 pm
mhoward View latest post
No new posts cobol jcl query 1 Ashok23 1125 Sun Feb 05, 2017 10:29 pm
William Collins View latest post
 


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB