|
You have KEY within the quoted string starting with ! openssl and ending
with -A';
End the quoted string prior to KEY and then resume it following KEY (and
add + before and after so everything is nicely concatenated...)
As for the DLEs, again I have to, based on provided information, assume the
XML file is the source -- that is, whoever is writing/construction the XML.
On Fri, Nov 22, 2019 at 8:20 AM Rishi Seth <rishiseth99@xxxxxxxxx> wrote:
Hi,is
I tried below code in which i have kept hex value of key in a file called
k1 and field called key in this file but the problem is that my program
able to read key value from this file but the momentof
i try to execute this cmd command inside my program and check the value
cmd field in debug mode i get it like below :-from
EVAL cmd
CMD =
....5...10...15...20...25...30...35...40...45...50...55...60
1 'echo 'jkYrd7QTBwv6ghTV0SnrqCdwJ8TnpZAk8+oVlNXwt7aDHoJSQWBsh4'
61 'R7cggjSc+34vv2CHL93B4iKiODHxxdVA==' ! openssl enc -d -aes-12'
121 '8-ecb -K key -nopad -nosalt -base64 -A '
181 ' '
241 ' '
i was expecting like it took encodedexchangetoken field value from that
xml file using xml into builtin function and showing it's value in
encodedexchangetoken field.
but when i read file in my code it does not pick the key field's value
this below code i am just wondering how can i pass key field's value towrote:
openssl command rather than hardcoding inside my program.
*******
FUNIX IF F 1000 SPECIAL PGMNAME('UNIXCMD')
F PLIST(UNIXPARM) USROPN
fk1 if e disk
F*QSYSPRT O F 1000 PRINTER
dencodedExcha...
dngeToken s 500 VARYING
DPOS2 S 5U 0
D cmd s 5000a
D mode s 1A inz('P')
DN1 S 2P 0
D Åcommand s 512a
d QCMDEXC PR ExtPgm('QCMDEXC')
d command 500a const
d clength 15p 5 const
D record ds 1000
D outrec s 1000 varying inz
C UNIXPARM PLIST
C PARM CMD
C PARM MODE
/free
RECORD = *BLANKS;
OUTREC = *BLANKS;
XML-INTO encodedExchangeToken %XML('/home/I0RS01HU/+
IN2.xml':'doc=file case=any path=+
TokenExchangeResponse/encodedExchangeToken');
eval encodedExchangeToken =%trimr(encodedExchangeToken);
READ rec;
dsply key;
cmd = 'echo ' + '''' + encodedExchangeToken + ''' ! openssl +
enc -d -aes-128-ecb -K KEY +
-nopad -nosalt -base64 -A';
open UNIX;
read UNIX record;
dow not %eof(UNIX);
pos2 = %scan(x'10' :record);
Record = %subst(Record :1 :(Pos2 - 1));
eval outrec = %trimr(record);
EVAL N1 = %LEN(OUTREC);
DSPLY N1;
//Delete the TESTFILE
Åcommand = 'DLTF FILE(rishi/TESTFILE)';
QCMDEXC(%trim(Åcommand): %len(%trim(Åcommand)));
Åcommand = *blanks;
Åcommand = 'CRTPF FILE(RISHI/TESTFILE) RCDLEN(' + %char(N1) +
')';
QCMDEXC(%trim(Åcommand): %len(%trim(Åcommand)));
//Write into file
EXEC SQL
INSERT INTO rishi/TESTFILE VALUES (:outrec);
// dsply %subst(outrec:1:48);
read UNIX record;
enddo;
close UNIX;
return;
/end-free
Thanks
On Thu, Nov 21, 2019 at 11:38 PM Rishi Seth <rishiseth99@xxxxxxxxx>
is
Ok, thanks for these details,
Is it possible not to hardcode the key value used here and use it as a
variable field like field of some file etc.so that each time once key
andchanged we may not have to change the program code and do not need to
recompile it?
Also in input XML we were not focused on other field's only target was
just to fetch this 'encodedexchangetoken' field out of that XML file
imaginewhatever data comes inside this field that should have been decryptedusing
AES 128 Algorithm so far this program seems to be working fine onlything i
was worried because of DLEs but could there be some more junk valuesmight
come like these DLEs in decrypted value, Which currently we can't
wrote:and låter on this program might crash as we have not thought of or havenot
considered handling regarding those probable junk values (Or so called
some other type of DLEs etc.) as of now?
Thanks much.....
On Thu, Nov 21, 2019, 21:17 Bruce Vining <bruce.vining@xxxxxxxxx>
itneeded
I did not get around to actually trying out Qc3DecryptData.
Yesterday the DLEs in the debug eval of record really told me all I
to know. This morning I looked more at the debug eval
of encodedExchangeToken, saw the leading x'0058' and realized you had
trailing88defined as varying length. That value tells me that XML-INTO returned
thebytes and the -base64 argument to enc told me it was base64 indicating
actual length received (based64 decoded) was 66 bytes with two
"someone"pad
characters (the == from record) leaving 64 "real" bytes. The last 16
bytes
(the DLEs) then must have been in the original stream (OK, maybe AES
decryption and base64 decoding uses DLEs for errors or somesuch though
I've
never seen that behavior or found it documented). In any case
withis
adding 16 bytes to encodedExchangeToken prior to your receiving it
thePostXML-INTO. As you did not provide the XML file (as requested with 8.
the contents of /home/I0RS01HU/INPUT.xml) I'm assuming it's there in
and Ifile and that XML-INTO didn't add it (an add which I've never seen
changing.have played with it, XML-INTO, in the past).
As you now have it working with openssl enc I wouldn't bother
biased
Personally I use the i cryptographic APIs (but I'm also somewhat
support.when it comes to system APIs) when doing development.
When the SQL encrypt and decrypt functions first came out I did take a
quick look at them and immediately saw that there were a whole lot of
features (that I sometimes use) that the SQL interfaces do not
intosendingSo
I would not use them unless forced to -- meaning that someone was
me data encrypted using say ENCRYPT_AES. To date I have never run
mightdatathat situation.
I do however wonder why base64 is being used as it appears to be text
being exchanged (with the exception of the DLEs) and what padding
beof
done if say the "real" data was only 45 bytes rather than a multiple
16call
such as 48.
Hope this helps,
On Thu, Nov 21, 2019 at 10:09 AM Rishi Seth <rishiseth99@xxxxxxxxx>
wrote:
Hi,
How could we say or conclude so because whenever i interactively
inopenssl command the same DLE seems to be coming that time as well
XMLthe
result of pase ?supplied
so does this mean xml itself is faulty i mean the value which is
in XML (specially data in that encodedexchangetoken field in that
wasAES128file
itself is faulty ?)case
secondly were you able to run that 'Qc3DecryptData' API program
successfully could you please share your program example for current
as i tried to use Qc3DecryptData API for same decryption (Using
Algorithm) but it did not work because i did not know how the data
alsohowencrypted only decryption thing i was focused on, as i did not know
the
data was encoded so may be those sql encrypt and decrypt function
APIdid
not work for this case also when you would have used thatQc3DecryptData
API was your program capable to handle each time different XML filesdata
like the one which i shared was having XML into kind of builtinfunctions
so it was capable to handle those different XMLs.
1) If same decrypted value could be achived using Qc3DecryptData'
bruce.vining@xxxxxxxxx>yesCould you please share that program code example ?
2) Can same result be achieved using SQL Decrypt function as well if
then could you please share that as well?approaches
3) Which way should be best technically among of all these 3
in case same decrypted value could be achieved using openssl,
Qc3DecryptData API,SQL Decrypt function ?
Thanks much...
On Thu, Nov 21, 2019 at 1:44 PM Bruce Vining <
possible),bruce.vining@xxxxxxxxx>wrote:
The DLEs are in the original XML stream being received.
On Wed, Nov 20, 2019 at 3:17 PM Bruce Vining <
if Iwrote:
Since Rishi has provided the encrypted stream and the key I'll,
find
the time (which as I'm currently free of work should be
terminal?ordecrypt
using Qc3DecryptData and at least find out if it's in the stream
sk@xxxxxxxxxxxxxxxx>being
added later when running cmd through the UNIXCMD interface...
On Wed, Nov 20, 2019 at 1:12 PM Scott Klement <
maybewrote:
The other possibility is that the PASE shell is inserting them,
thinking it needs to escape something for the sake of a
assume
On 11/20/2019 9:32 AM, Bruce Vining wrote:
As I cannot imagine Scott inserting those DLEs I have to
relatedthey
are in
the XML document.--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription
affiliateaffiliateaffiliateaffiliatequestions.
Help support midrange.com by shopping at amazon.com with our
link: https://amazon.midrange.com
--
Thanks and Regards,
Bruce
931-505-1915
--
Thanks and Regards,
Bruce
931-505-1915
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
link: https://amazon.midrange.com--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
link: https://amazon.midrange.com
--
Thanks and Regards,
Bruce
931-505-1915
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
--link: https://amazon.midrange.com
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
Thanks and Regards,
Bruce
931-505-1915
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.