midrange.com code scratchpad |
Name:
Decryption of encodedtokenexchange using OPENSSL AES128 Algorithm in RPGLE Program
|
Scriptlanguage:
Plain Text
|
Tabwidth:
5
|
Date:
11/01/2019 07:09:28 pm
|
IP:
Logged
|
|
Description:
Hi,
I am pasting below code which works pretty well for the interactive part of OPENSSL I mean when i execute call qsys/qp2term and then execute openssl and execute this command :-echo 'u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL
93B4iKiODHxxdVA==' | openssl enc -d -aes-128-ecb -K 363631653237354f494d31554
c594c4a -nopad -nosalt -base64 -A
then i get decrypted value of this encoded string as :- 707fbe32-0dbc-41e0-888f-5bc40de8c20d2P9AMPCTQ4CZ ยข
and when same thing programatically i am willing to achieve using openssl and reading xml file's encodedtokenexchange field value from it and then trying to decrypt it using below program code it is not writing any thing in string1.txt and gives me error like :-
Display Module Source
Program: EX9 Library: RISHI Module: EX9
15 /free
16 XML-INTO encodedExchangeToken %XML('/home/I0RS01HU/+
17 /INPUT.xml':'doc=file case=any path=+
18 TokenExchangeResponse/encodedExchangeToken');
19 cmd = 'echo encodedExchangeToken|openssl +
20 enc -d -aes-128-ecb -K +
21 363631653237354f494d31554c594c4a -nopad -nosalt +
22 -base64 -A -out string1.txt';
23 read UNIX record;
24 dow not %eof(UNIX);
25 outrec = record;
26 write QSYSPRT outrec;
27 read UNIX record;
28 enddo;
29
More...
Debug . . . EVAL string1.txt
F3=End program F6=Add/Clear breakpoint F10=Step F11=Display variable
F12=Resume F17=Watch variable F18=Work with watch F24=More keys
Identifier does not exist.
Please find my program code pasted below for more details and could you please advise what is going wrong here?
|
Code:
- 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
-
|
|
|