Fantastic Bruce I ll try it and let you know
Thanks for your support on this
Basilio

Il 1 feb 2019 21:03, Bruce Vining <bruce.vining@xxxxxxxxx> ha scritto:
I hope that the supplier can provide you with the specifics of their
encryption. The referenced site aes.online-domain-tools.com site is a bit
vague on a few points.

What I needed to do is use hex input for the text and key (as neither were
multiples of 16 bytes), along with specifying the following values:

Input type: Text
Input text (hex) : 48454c4c4f204259204d452020202020
Function: AES
Mode: ECB
Key (hex) : 656e6372797074696f6e206b65790000

The site doesn't mention what text padding it does for AES though on the i
I tried both blank and null padding of the text field, neither of which
generated the same encrypted value the tool did
(x'8c5dacb236d9576289b05e6e58ab94cd'). Using hardcoded text blanks (x'20'
for ASCII) for the input text did work. The site does mention "If you don't
specify a key with permitted length the key is prolonged with the proper
number of null bytes at the end", however I again only found the correct
value being generated when I used hex input of the key (and not just
'encryption key'). I did also find that using text of 'HELLO BY ME12345'
and a key of 'encryption key12' (causing no padding of either element) also
worked, so there's something about the site padding that I'm missing...).
The site also prompts for an initialization vector, which is not supported
by Qc3EncryptData.

The following program did, using eval ASCIIEncTxt, generate the same
'8C5DACB236D9576289B05E6E58AB94CD' value as the tool.

h dftactgrp(*no)

d ConvClose pr 10i 0 extproc('iconv_close')
d iconv 52a value

d ConvOpen pr 52a extproc('iconv_open')
d ToCode 32a const
d FromCode 32a const

d ConvText pr 10i 0 extproc('iconv')
d iconv 52a value
d InpBfr * const
d InBfrLeft 10i 0
d OutBfr * const
d OutBfrLft 10i 0

d Encrypt pr extproc('Qc3EncryptData')
d ClrDta 16a
d LenClrDta 10i 0 const
d FmtClrDta 8a const
d ALGD0200 const likeds(ALGD0200)
d FmtAlg 8a const
d KEYD0200 const likeds(KEYD0200)
d FmtKey 8a const
d CryptoPrv 1a const
d CryptoDev 10a const
d EncDta 16a
d LenPrvEncDta 10i 0 const
d BytRtnEncDta 10i 0
d ErrCde likeds(QUSEC)

d ALGD0200 ds
d BlkCphrAlg 10i 0
d BlkLen 10i 0
d Mode 1a
d PadOpt 1a inz('0')
d PadChr 1a inz(x'00')
d Rsvd 1a inz(x'00')
d LenMAC 10i 0 inz(x'00')
d EffKeySiz 10i 0 inz(0)
d InzVector 32a inz(*allx'00')

d FromCode ds
d 8a inz('IBMCCSID')
d FromCCSID 5a inz('00037')
d ConvAlt 3a inz('000')
d SubAlt 1a inz('0')
d SSAlt 1a inz('0')
d InpLenOpt 1a inz('0')
d ErrOptMxd 1a inz('0')
d 12a inz(*allx'00')

d KEYD0200 ds
d KeyType 10i 0
d KeyLen 10i 0
d KeyFmt 1a inz('0')
d 3a inz(*allx'00')
d ASCIIKey 16a

d ToCode ds
d 8a inz('IBMCCSID')
d ToCCSID 5a inz('00819')
d 19a inz(*allx'00')

d ASCIIClrTxt s 16a
d ASCIIClrTxtPtr s * inz(%addr(ASCIIClrTxt))
d ASCIIEncTxt s 16a
d ASCIIKeyPtr s * inz(%addr(ASCIIKey))
d ConvErr s 10i 0
d EBCClrTxt s 16a inz('HELLO BY ME')
d EBCClrTxtPtr s * inz(%addr(EBCClrTxt))
d EBCKey s 16a
d EBCKeyPtr s * inz(%addr(EBCKey))
d InBfrLeft s 10i 0
d LenRtnd s 10i 0
d OutBfrLeft s 10i 0

/copy qsysinc/qrpglesrc,iconv
/copy qsysinc/qrpglesrc,qusec

/free
EBCKey = 'encryption key' + x'0000';
iconv = ConvOpen(ToCode :FromCode);
InBfrLeft = %size(EBCClrTxt);
OutBfrLeft = %size(ASCIIClrTxt);
ConvErr = ConvText(iconv :EBCClrTxtPtr :InBfrLeft
:ASCIIClrTxtPtr :OutBfrLeft);
InBfrLeft = %size(EBCKey);
OutBfrLeft = %size(ASCIIKey);
ConvErr = ConvText(iconv :EBCKeyPtr :InBfrLeft
:ASCIIKeyPtr :OutBfrLeft);
ConvErr = ConvClose(iconv);
BlkCphrAlg = 22; // AES
BlkLen = 16;
Mode = '0'; // ECB
KeyType = 22;
KeyLen = 16;
QUSBPrv = %size(QUSEC);
Encrypt(ASCIIClrTxt :%size(ASCIIClrTxt) :'DATA0100'
:ALGD0200 :'ALGD0200'
:KEYD0200 :'KEYD0200' :'0' :' '
:ASCIIEncTxt :%size(ASCIIEncTxt) :LenRtnd :QUSEC);
*inlr = *on;
return;
/end-free

I hope this helps,
Bruce

On Fri, Feb 1, 2019 at 8:06 AM Bruce Vining <bruce.vining@xxxxxxxxx> wrote:

Give me a few minutes and I'll write up a little program mimicking your
website solution. But I can tell you that you have several problems in
regard to the actual file decryption approach.

On Fri, Feb 1, 2019 at 8:04 AM Merlino, Basilio (NissanContractor) <
b.merlino-extern@xxxxxxxxx> wrote:

Hi Bruce,

Thanks for your support, below my answer


1. Are you using binary when FTPing the file?
No but in any case the issue is present also when i decrypt the text
"HELLO BY ME" and compare it

2. How are you opening the file?
3. What is the CCSID of the system providing the decryption key?
It's a unix system
4. When you say you "convert string from ebcdic to ascii" are you
referring
to the decryption key?
No to the text "HELLO BY ME"
5. How do you detect that the decryption failed? Using debug of the text
or
by examining an output file?

Debug and compare the value with the result of
http://rc4.online-domain-tools.com/


Basilio MERLINO
Phone: +39-0690808577
Mobile: +39-3484152040



Il 01/02/2019 14:50, Bruce Vining ha scritto:

First a few questions:

1. Are you using binary when FTPing the file?
2. How are you opening the file?
3. What is the CCSID of the system providing the decryption key?
4. When you say you "convert string from ebcdic to ascii" are you
referring
to the decryption key?
5. How do you detect that the decryption failed? Using debug of the text
or
by examining an output file?

Bruce

On Fri, Feb 1, 2019 at 7:29 AM Jay Vaughn <jeffersonvaughn@xxxxxxxxx
<mailto:jeffersonvaughn@xxxxxxxxx> wrote:



Curious to see suggestions on this one.
I have nothing, sorry.

But just curious why the data wasn’t sftp’d to you instead? But I’m sure
I just don’t see the whole picture of what you are working on.

Jay




On Feb 1, 2019, at 8:18 AM, Merlino, Basilio (NissanContractor) <


b.merlino-extern@xxxxxxxxx<mailto:b.merlino-extern@xxxxxxxxx>> wrote:




Dear All,

I need to decrypt some text related data coming from a supplier, i


receive the file in an ftp folder read text and decrypt it.



In order to decrypt the information i use Qc3DecryptData (AES OR RC4


alghoritym), unforntunately i encoured in the following problem



First of all let's me say that i was not able to decrypt the data coming


from vendor so i try to understand where the problem was



First of all i have written a program that encrypt and decrypt the


phrase "HELLO BY ME" with key "key encryption" and it's work fine.



I compare the result with the one coming from the following url

http://rc4.online-domain-tools.com/

and the two values doesn't match.

So my first assumption was that there is a difference beetwen ebcdic and


ascii transcodification so i try to



- convert string from ebcdic to ascii

- run encryption

but again the two values doesn't match

Anyone can direct me ? any idea ?


Thanks to All


Basilio













***********************************************************************************************************


CONFIDENTIALITY NOTICE

This message is for the named person's use only. It may contain


confidential, proprietary or legally privileged information.



If you receive this message in error, please immediately delete it and


all copies of it from your system, destroy any hard copies of it and
notify
us by email to email.security@xxxxxxxxxxxxxxxxx<mailto:
email.security@xxxxxxxxxxxxxxxxx> with a copy of this
message. You must not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message if you are not the intended
recipient. NISSAN EUROPE and any of its subsidiaries each reserves the
right to monitor all e-mail communications through its networks.



NISSAN EUROPE is neither liable for the proper, complete transmission of


the information contained in this communication nor any delay in its
receipt. This email was scanned for the presence of computer viruses. In
the unfortunate event of infection NISSAN EUROPE does not accept
liability.



Any views expressed in this message are those of the individual sender,


except where the message states otherwise and the sender is authorised to
state them.







***********************************************************************************************************


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)


mailing list


To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx<mailto:
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<mailto:
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<mailto:support@xxxxxxxxxxxx> for any
subscription related


questions.



Help support midrange.com by shopping at amazon.com with our affiliate


link: https://amazon.midrange.com
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx<mailto:
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<mailto:
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<mailto:support@xxxxxxxxxxxx> for any
subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com








***********************************************************************************************************
CONFIDENTIALITY NOTICE

This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information.

If you receive this message in error, please immediately delete it and
all copies of it from your system, destroy any hard copies of it and notify
us by email to email.security@xxxxxxxxxxxxxxxxx with a copy of this
message. You must not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message if you are not the intended
recipient. NISSAN EUROPE and any of its subsidiaries each reserves the
right to monitor all e-mail communications through its networks.

NISSAN EUROPE is neither liable for the proper, complete transmission of
the information contained in this communication nor any delay in its
receipt. This email was scanned for the presence of computer viruses. In
the unfortunate event of infection NISSAN EUROPE does not accept liability.

Any views expressed in this message are those of the individual sender,
except where the message states otherwise and the sender is authorised to
state them.


***********************************************************************************************************
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (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



--
Thanks and Regards,
Bruce
931-505-1915
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (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

***********************************************************************************************************
CONFIDENTIALITY NOTICE

This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information.

If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify us by email to email.security@xxxxxxxxxxxxxxxxx with a copy of this message. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. NISSAN EUROPE and any of its subsidiaries each reserves the right to monitor all e-mail communications through its networks.

NISSAN EUROPE is neither liable for the proper, complete transmission of the information contained in this communication nor any delay in its receipt. This email was scanned for the presence of computer viruses. In the unfortunate event of infection NISSAN EUROPE does not accept liability.

Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them.

***********************************************************************************************************

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 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].