Unfortunately we've only got V5R3 available, and the ENCRYPT_TDES SQL
function is only available from V5R4 so that's not an option...
Regards,
Stuart
Mike Cunningham <mcunning@xxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
02/07/2008 17:01
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
To
"'rpg400-l@xxxxxxxxxxxx'" <rpg400-l@xxxxxxxxxxxx>
cc
Subject
RE: Decrypting Triple DES
Tyr using this instead of the API
/free
If Function = 'ENCRYPT';
EXEC SQL SET :ResultVarying = ENCRYPT_TDES(:InputVarying, :pw);
Endif;
If Function = 'DECRYPT';
EXEC SQL SET :ResultVarying = DECRYPT_CHAR(
cast(:InputVarying as char(5000) for bit data), :pw);
Endif;
/end-free
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of sbramley@xxxxxxxxx
Sent: Wednesday, July 02, 2008 8:18 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Decrypting Triple DES
I am attempting to use the Qc3DecryptData API to decrypt a value that has
been encrypted in Triple DES in Java.
The encryption uses the transformation DESede/CBC/PKCS5Padding - but I am
having difficulty recreating the necessary settings in RPG to decrypt the
value.
In order to try and match these settings I have specified the algorithm
(QC3BCA) = 21 for Triple DES, block length (QC3BL) = 8 for Triple DES,
Mode (QC3MODE) = '1' for CBC and I have set the pad option (QC3PO) = '2'
(as the documentation for the encryption API states that this is
equivalent to PKCS # 5 padding) however the value that is returned when I
test this is not the expected plain text string.
The Java code outputs a base 64 encoded string - to test the decryption
process I am decoding an example encrypted value and then converting this
to a hexadecimal literal in that is passed in to the API for decryption. I
have tried converting the ASCII value of the decoded string to EBCDIC and
neither works...
When I try and encrypt an identical value the result is different from
that generated in Java (both as a string and as hex values).
The encryption key and initialization vector values are identical between
the two processes (albeit as a byte array in java and a hex literal in the
RPG (at present for test purposes)).
Does anyone have any experience in using this API decrypting code that has
been encrypted using the above transformation? Is it possible?
Regards,
Stuart Bramley
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.