× 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.



Will do. thanks for all of the replies.

Subject: Re: Decrypt with QC3DECDT
From: jon.paris@xxxxxxxxxxxxxx
Date: Thu, 21 Nov 2013 15:17:53 -0500
To: rpg400-l@xxxxxxxxxxxx

%Len of argData is 65535? How did the data get in there?

Using the "add 1" is a hack pure and simple and needs to be dumped ASAP. It will confuse the heck out of any poor schmuck who comes after you - heck in four weeks it will confuse you. It is not needed if you do this right.

I would start by doing away with the varying keyword. It is doing nothing for you in this case (except chew up cycles) switch it to a fixed length field. You have Options varsize on the PR so it is allowing the compatible varying field to be used but it will always be copied. Change the length of the argData to something more realistic (seems like 32 might be appropriate for this case) and set the lengths accordingly.


On 2013-11-21, at 1:36 PM, Jon S <rvrratjon@xxxxxxxxxxx> wrote:

I have a file that has either a bank account number or a credit number. It appears that for the ones that are working correctly, the bank account number is always 16 characters and the credit card number is 32 characters encrypted. The ones that are failing are only 15 and 31 because of a valid leading or trailing space. I changed the program to add 1 to these and all worked fine. If I do the %len it comes up with 65535 and does not like that. How should this normally be handled, store the length when it's encrypted?

Also, I am using AES.

Subject: Re: Decrypt with QC3DECDT
From: jon.paris@xxxxxxxxxxxxxx
Date: Thu, 21 Nov 2013 12:53:25 -0500
To: rpg400-l@xxxxxxxxxxxx

I think the answer is in the category of "Dr. It hurts when I bang my head against a wall." - don't do the trim. Use %Len against the varying field directly (not the trimmed version) so that you get the right length.


On 2013-11-21, at 12:05 PM, Jon S <rvrratjon@xxxxxxxxxxx> wrote:

Looking at the encrypted field, it appears that all are 16 characters except the ones that kicked out in error which are only 15 so it appears that the last space is a valid blank character but I am only passing in 15 via the %len(%Trimr(argData) or %size(argData) causing it to error out. I am not sure how to handle that. Any suggestions? Below is the prototype for DecryptDataAPI

D decryptDataAPI...
D PR extPgm('QC3DECDT')
D argIn 65535 const options(*varsize)
D argInLen 10I 0 const
D argAlg 65535 const options(*varsize)
D argAlgFmt 8 const
D argKey 65535 const options(*varsize)
D argKeyFmt 8 const
D argCryptoPro 1 const
D argCryptoDev 10 const
D argOut 65535
D argOutBuffLen 10I 0 const
D argOutLen 10I 0
D argError likeDs(QUSEC)



Subject: Re: Decrypt with QC3DECDT
From: jon.paris@xxxxxxxxxxxxxx
Date: Thu, 21 Nov 2013 11:21:22 -0500
To: rpg400-l@xxxxxxxxxxxx

argData is a varying length field - so trim should be done on loading - doing it on the call is asking for trouble. Not sure what the compressed string looks like - but for sure it could have a valid space at the end. Also you haven't shown the Pr for decryptDataAPI so I can't tell if that is having an effect. The parm is not a varying field that is for sure.

On 2013-11-21, at 10:22 AM, Jon S <rvrratjon@xxxxxxxxxxx> wrote:

This is strange. When I encrypt the 6 character string, it returns the length as 16 for the encrypted length but when I turn around and try to decrypt it the program shows that the length of the encrypted string to be only 15. Maybe the %trimr on the %len(%Trimr(argData)) for the encrypted string is causing me the problem?

From: rvrratjon@xxxxxxxxxxx
To: rpg400-l@xxxxxxxxxxxx
Subject: RE: Decrypt with QC3DECDT
Date: Thu, 21 Nov 2013 09:11:29 -0600

Looking at it again, the clear data length is set to 65535 and the original unencrypted field was only 6 bytes.

decryptData...
B EXPORT
decryptData...
PI 65535A
argData 65535A const varying
options(*varsize)
argInLen 10I 0

svOutData S 65535A

D svOutDataLen S 10I 0
D Len S 10I 0
D svBytes S 52A
/free
svOutData = *BLANKS;
len = %size(svOutData);
len = %len(%Trim(argData));
// API
decryptDataAPI(argData: ):
QC3D0200: 'ALGD0200':
keyDesc: 'KEYD0200':
cryptoPro: cryptoDev:
svOutData: %size(svOutData): svOutDataLen:
stdError);



Subject: Re: Decrypt with QC3DECDT
From: jon.paris@xxxxxxxxxxxxxx
Date: Thu, 21 Nov 2013 10:02:33 -0500
To: rpg400-l@xxxxxxxxxxxx

Well there are probably circumstances where 16 bytes may well expand to more than 50. Assuming that normal compression techniques are in play then (say) 60 blanks if included in the encrypted string would probably compress down to 3 or 4 bytes.

Why not make the field bigger and see what you get?


On 2013-11-21, at 9:50 AM, Jon S <rvrratjon@xxxxxxxxxxx> wrote:

I am trying to use QC3DECDT to decrypt an encrypted field which was also encrypted with QC3DECDT. Sometimes (6 out of 2381 records ) I am getting CPF9DD6 which is "Length of area provided for output data is too small.". I have my clear data output length set to 50 which should be plenty big, as the first one I am getting an error on is only 16 characters encrypted. Can anyone help?

Thanks, Jon

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


Jon Paris

www.partner400.com
www.SystemiDeveloper.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@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.


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


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


Jon Paris

www.partner400.com
www.SystemiDeveloper.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@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.


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


Jon Paris

www.partner400.com
www.SystemiDeveloper.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@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.


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


Jon Paris

www.partner400.com
www.SystemiDeveloper.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@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.

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.