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



You've not shown how any of the length fields are defined or populated Brian


Jon P.

On Feb 9, 2023, at 9:13 AM, Brian Garland via RPG400-L <rpg400-l@xxxxxxxxxxxxxxxxxx> wrote:

I did find one translation issue and am now getting CPF9DCE "A data length
is not valid". This is a pretty vague message.

Given the data I'm passing I think I am passing the correct lengths. This
makes me think I may be passing some wrong data so the error means "not
expected" more than "wrong for the data passed" so I need to verify some
assumptions I made about the parameters.

If you see anything that I'm doing wrong please let me know.


Parm 1 - Signature - The actual JWT
Parm 2 - Length of parm 1
Parm 3 - Input Data - The decoded header and payload from the JWT
Parm 4 - Length of parm 3
Parm 5 - 'DATA0100'
Parm 6 - ALGD0400 structure
DCL-DS ALGD0400;
Algorithm INT(10) INZ(50);
BlockFormat CHAR(1) INZ('1');
Reserved CHAR(3) INZ(*LOVAL);
SigningAlgo INT(10) INZ(3);
END-DS;
Parm 7 - 'ALGD0400'
Parm 8 - KEYD0600 structure
DCL-DS KEYD0600;
PEMLength INT(10) INZ(0);
PEMReserved CHAR(4) INZ(*LOVAL);
PEMCertificate CHAR(8000) CCSID(*HEX);
END-DS;
Parm 9 - 'KEYD0600'
Parm 10 - '1'
Parm 11 - ' '
Parm 12 - standard error DS


Prototype:
DCL-PR VerifySignature EXTPROC('Qc3VerifySignature');
Signature POINTER VALUE;
SignatureLen INT(10) CONST;
InputData POINTER VALUE;
InputDataLen INT(10) CONST;
InputDataFormat CHAR(8) CONST;
AlgorithmDesc POINTER VALUE;
AlgorithmDescFormat CHAR(8) CONST;
KeyDesc POINTER VALUE;
KeyDescFormat CHAR(8) CONST;
CryptoProvider CHAR(1) CONST;
CrpytoDevice CHAR(10) CONST;
APIError POINTER VALUE;
END-PR;

Call:
VerifySignature(%ADDR(Token):TokenLen:
%ADDR(Input):InputLen:'DATA0100':
%ADDR(ALGD0400):'ALGD0400':
%ADDR(KEYD0600):'KEYD0600':
'1':' ':%ADDR(apierror));


For testing, the JWT and public certificate are stored in regular RPGLE
CHAR variables. I'm able to decode the JWT to get the header and payload
in order to create the string for the input data parm (header + '.' +
payload). I put the JWT and the input data into *UTF8 variables before
passing them to the API.

PEMCertificate (in KEYD0600) is set to the text of the PEM formatted
certificate which for this test is set in an RPG string and then translated
to ASCII using QDCXLATE.

certificate = '-----BEGIN CERTIFICATE-----' + x'25' + etc.


Brian

--
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or company to whom they are addressed.
Do not disclose, distribute, or copy this email to others outside your
company. If you have received this email in error, please notify the sender
immediately and delete this email from your system.
--
This is the RPG programming on IBM i (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@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.



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.