On 24-Feb-2015 04:42 -0600,
anil...@gmail.com wrote:
> I have facing an issue where I am getting 16 position as garbage
> value. When we are trying the see decrypted value of a field then
> Decryption API returning the garbage value at 16th position character
> and rest of decrypted character value's are correct.
>
> Decrypted value>>>122222222222222u222
>
> below code returns the Decrypted value as below when data of field
> is greater than 15 character. It has garbage value at 16th position
> which is wrong.
> Decrypted value>>>122222222222222u222
>
> value should be return as: 1222222222222222222
> but API return garbage value at 16th position
> ........ VALUE returns as: 122222222222222u222
>
> Code details-
> <<SNIP>>
>
> WORKING-STORAGE SECTION.
>
> 90798A EXEC SQL
> 90798A SET OPTION COMMIT = *NONE
> 90798A END-EXEC.
> 90798A
> 90798A EXEC SQL
> 90798A SET OPTION DATFMT = *ISO
> 90798A END-EXEC.
> 90798A
> 90798A EXEC SQL
> 90798A SET OPTION TIMFMT = *ISO
> 90798A END-EXEC.
> 90798A
> EXEC SQL
> INCLUDE SQLCA
> END-EXEC.
>
> <<SNIP>>
As I understand, there is support for only *one* SET OPTION
statement; in a test of the pre-compiler against embedded SQL, I found
that only the final SET OPTION specifications were honored, but I have
not performed a similar test for COBOL. The <kwd=value> pairs can be
specified as comma-separated; see the syntax diagram for the SET OPTION
statement:
<
http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/db2/rbafzsoption.htm>
> * Parameter for the API - QC3DECDT
> 01 IN-CIPHER-DATA PIC X(1024).
> 01 OUT-DECRYPTED-VALUE PIC X(36) VALUE SPACES.
> 01 LENGTH-CIPHER-DATA PIC 9(8) USAGE BINARY VALUE 32.
> <<SNIP>>
> 01 CRYPTO-SP PIC X(1) VALUE '0'.
> 01 CRPTO-DEVICE PIC X(10) VALUE SPACES.
> 01 WS-CLEAR-DATA PIC X(36).
> 01 LOA-DECRYPTED-VALUE PIC 9(8) USAGE BINARY VALUE 1024.
> 01 LENGTH-DECRYPTED-VALUE PIC 9(8) USAGE BINARY.
> <<SNIP>>
> CALL 'QC3DECDT' USING IN-CIPHER-DATA
> LENGTH-CIPHER-DATA
> ALGO
> ALGO-FMT-NAME
> KEYD
> KEYD-FMT-NAME
> CRYPTO-SP
> CRPTO-DEVICE
> OUT-DECRYPTED-VALUE
> LOA-DECRYPTED-VALUE
> LENGTH-DECRYPTED-VALUE
> ERR.
>
>
> MOVE OUT-DECRYPTED-VALUE TO
> WS-DECRYPTED-VALUE(WS-FIELD-COUNT).
>
> <<SNIP>>
>
> Any inputs/insights will really help us.
Conspicuously incorrect [though no idea if that is the origin for the
difficulty] is that the value supplied for the "Length of area provided
for clear data" [10th] parameter with LOA-DECRYPTED-VALUE as the
argument for that input seems incorrectly to be passing a decimal value
of 1024. That would be a major problem, because the argument passed as
OUT-DECRYPTED-VALUE for the output of the "Clear data" [9th] parameter
is declared with only 36 bytes of storage.
FWiW the "Length of clear data returned" [11th] parameter with
LENGTH-DECRYPTED-VALUE as the argument for output seems to be
unreferenced in the program when deciding what portion of the
OUT-DECRYPTED-VALUE gets moved. Only that length\portion of the
returned /clear/ data should be moved elsewhere, as any remaining data
beyond that length is _undefined_ such that any /garbage/ could appear
there yet remain valid; i.e. the user code should not refer to anything
beyond what is revealed to the API as valid return-data.
<
http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/qc3decdt.htm>
--
Regards, Chuck