× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I'd take a look at the MI instruction CIPHER, available as EXTPROC('_CIPHER'). Can't say for certain whether it's of any use to you, but I think it's worth a try:

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_74/rzatk/CIPHER.htm

Function Identifier X'0015' deals specifically with AES. The 'operation' field indicates whether you wish to encrypt (X'00') or decrypt (X'01') AES data.

Thanks

Richard




-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Rob Berendt
Sent: 01 October 2019 13:39
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: Regarding Decryption of AES128 encrypted data in RPGLE and query regarding CRC 32 [PRIVATE REPLY]

Sometimes you have to plug through the documentation and figure it all out on your own. Or, you can try a web search for the api name to see if someone else has a sample.
Just to throw confusion into the mix. That API may be part of an additional LPP you need, like cryptographic services.

Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1 Group Dekko Dept 1600 Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Rishi Seth
Sent: Tuesday, October 1, 2019 8:30 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Regarding Decryption of AES128 encrypted data in RPGLE and query regarding CRC 32 [PRIVATE REPLY]

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.


But it the link they don\t have any live example for decrypting data using
API.

On Tue, Oct 1, 2019 at 2:12 PM Rob Berendt <rob@xxxxxxxxx> wrote:

It's looking that way.

If you want to try methods outside of SQL you can research
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/apis/catcrypt2.htm

For assistance from IBM you can open up a case at
https://www.ibm.com/support/home/

If they confirm the answer is a no but you'd like them to change their
minds you can open up a RFE or Request For Enhancement at

https://www.ibm.com/developerworks/rfe/execute?use_case=changeRequestLanding&BRAND_ID=352&PROD_ID=1476&x=11&y=13


Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
Rishi Seth
Sent: Tuesday, October 1, 2019 7:04 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Regarding Decryption of AES128 encrypted data in RPGLE and
query regarding CRC 32 [PRIVATE REPLY]

CAUTION: This email originated from outside of the organization. Do not
click links or open attachments unless you recognize the sender and know
the content is safe.


Hi,

Is this conclusion now true that we can not decrypt data using AES
algorithm in AS400 programming language which is encrypted using web link
in UTF8 or other ASCII values like here as mentioned in previous mails?

Thanks

On Mon, Sep 30, 2019 at 7:13 PM Peter Dow <petercdow@xxxxxxxxx> wrote:

Hi Rishi,

I went to the website you mentioned,
https://www.devglan.com/online-tools/aes-encryption-decryption, and
tried decrypting



u3VtNgfyWU9faZc3Iaa8ZWbE5UZCfmC17yA4MyW0ghflt9dNQNDpCcgMZiG/kXPE4vv2CHL93B4iKiODHxxdVA==

with password (secret key)

6-9d15-ec98bcc81ec4275OIM1TS7LI

and I noticed a couple of things.

1. Since the encryption is AES128, the password length must be 16
bytes. The pswd in your program is 31 bytes.

2. The "encrypted" data is actually base64 encoded. In order to decrypt
it in RPG, you would first have to decode it from base64, then decrypt
it.


On top of that, when I used the aforementioned website to encrypt
'whatever text', in AES with 128-bit key, mode ECB, and password
'mypasswordis16xy', the encrypted value is

x'831720A57F742CBB3A86AB24A3AA23AE'.

If I use the SQL encrypt_AES function, with the same password, the
encrypted value is

x'4CB947FF0025D5A6B96180506FFE4F23B96180506FFE4F23'.

The reason for this difference probably has something to do with the
following notes from IBM's SQL manual on the encrypt_AES function:

"The length attribute of the result depends on the arguments that are
specified:
* when /password-string/ is specified but a /hint-string/ is not
specified, the length
attribute of /data-string/ plus 24 plus the number of bytes to a
16-byte boundary.
* Otherwise, the length attribute of /data-string/ plus 64 plus the
number of bytes to
a 16-byte boundary."

Apparently IBM's encrypt_AES function includes more than just the
encrypted value in its result.

In short, it looks like you cannot use IBM's decrypt_AES function to
decrypt a value encrypted by anything other than IBM's encrypt_AES
function.

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx <mailto:petercdow@xxxxxxxxx>
pdow@xxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxx>

/
On 9/30/2019 4:50 AM, Rishi Seth wrote:
I Know below is the IBM API for same but need a real working example
which
could decrypt data which is encoded using UTF8 or ACII. with 128 bit
key
and Mode is ECB?





---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-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

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-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
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-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

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-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 thread ...

Replies:

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

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.