|
Matt, You may want to also post this question to the MI400 list as it uses MI functions, etc.. Don in DC ---------------------------------- On Mon, 4 Oct 2004, Haas, Matt wrote: > Here's the background on the problem I'm having: > > For an upcoming project, I need to store some encrypted data in a cookie > which has me looking at using the CIPHER MI instruction to do this. I started > by looking at a few examples that do an MD5 hash (which doesn't work for me > since I need to decrypt it) and, of course, Scott Klement's RC4 example. I > did a little bit of research into using RC4 and it looks like it's easy to > make implementation mistakes that reduce it's security so I'm wanting to use > something better (or at least not as easy to screw up), specifically, I want > to use AES. > > I spent a little bit of time working on this today but I'm getting this error > when I run my program: "Requested function not valid or is not available on > the machine.". To double check what's installed, I ran Scott's program that > lists the installed ciphers and 128 bit AES was listed. I know the crypto > providers are installed and we're on V5R1. Anyone have any ideas? > > Here's the code: > > H DFTACTGRP(*NO) BNDDIR('QC2LE') option(*SRCSTMT: *NODEBUGIO) > H ACTGRP(*NEW) > > Dcipher PR extproc('_CIPHER') > D receiver * > D control 96A > D source * > > DAES_Controls DS > D FunctionID 2A > D DataLen 5U 0 > D Operation 1A > D Mode 1A > D BlockLength 3U 0 > D MAClength 3U 0 > D InitVector 32A > D Reserved 7A > D KeyOption 1A > D KeySchedulePtr * > D Key 32A > > DKeySchedule S 1088A > DOP_ENCRYPT C const(x'00') > DOP_DECRYPT C const(x'01') > DOP_MAC C const(x'02') > DMODE_ECB C const(x'00') > DMODE_CBC C const(x'01') > DKEYOPT_SCHEDULE C const(x'00') > DKEYOPT_16BYTE C const(x'10') > DKEYOPT_24BYTE C const(x'18') > DKEYOPT_32BYTE C const(x'20') > DFUNCID_AES C const(x'0015') > > DTestData S 32A inz('Secret Text!') > DEncrypted S 20A > DPassword S 32A inz('My Password 123') > Dp_recv s * > Dp_src s * > Ddalen s 10I 0 > > /free > AES_Controls = *ALLx'00'; > dalen=%size(aes_controls); > dalen=%len(aes_controls); > FunctionID = FUNCID_AES; > DataLen = %len(TestData); > Operation = OP_ENCRYPT; > Mode = MODE_ECB; > BlockLength = 32; > KeyOption = KEYOPT_32BYTE; > KeySchedulePtr = %addr(KeySchedule); > Key = Password; > > p_recv = %addr(Encrypted); > p_src = %addr(TestData); > > cipher( p_recv: AES_Controls: p_src); > > *inLR = *ON; > /end-free > > Thanks, > > Matt > > -- > 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.
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.