I'm getting the CPF9DEC (Cryptographic service provider not valid) error when calling Qc3EncryptData to encrypt data using triple DES. I'm passing in the value of '0' for this 'Cryptographic service provider' parameter (parameter 8). According to the IBM doc (see link below), value of '0' means any CSP (The system will choose an appropriate CSP to perform the encryption operation). Any idea how I can get pass this error?
https://www.ibm.com/docs/en/i/7.4?topic=ssw_ibm_i_74/apis/qc3encdt.htm#algd0200
Below is the strip down version of my code:
* algorithm DS
D ALGD0200...
D DS qualified
D algorithm 10i 0 inz(21)
D algorithmBlockLen...
D 10i 0 inz(8)
D mode 1 inz('1')
D padOption 1 inz('2')
D padChar 1 inz(x'00')
D reserved 1 inz(x'00')
D MACLen 10i 0 inz(0)
D keySize 10i 0 inz(0)
D inzVector 32 inz('myvector')
* key DS
D KEYD0200...
D DS qualified
D keyType 10i 0 inz(21)
D keyLen 10i 0 inz(24)
D keyFormat 1 inz('0')
D reserved 3 inz(*allx'00')
D key 32 inz('123456789012345678901234')
* error DS
D reffldIBMErrorDS...
D DS qualified template
D totalLen 10I 0 Inz(%Size(reffldIBMErrorDS))
D resultLen 10I 0 inz(0)
D msgID 7A
D reserved 1A inz(x'00')
D msgDta 256A
* ibm encrypt api
D Qc3EncryptData PR extProc('Qc3DecryptData')
D piClearData 65535A options(*varsize) const
D piClearDataLen...
D 10I 0 const
D piClearDataFormatName...
D 8 const
D piAlgorithm 64A const options(*varsize)
D piAlgorithmFormat...
D 8A const
D piKeyDesc 512A const options(*varsize)
D piKeyFormat 8A const
D piCryptoServiceProvider...
D 1A Const
D piCryptoDeviceName...
D 10A Const options(*omit)
D piEncData 65535A options(*varsize)
D piEncDataSize 10I 0 const
D piEncDataLen 10I 0
D piApiErrorDS likeds(reffldIBMErrorDS)
D options(*varsize)
D myClearData s 3000 inz('Hello World')
D myEncData s 65535A
D myEncDataLen s 10I 0
D myIBMApiErr ds likeDS(reffldIBMErrorDS)
D inz(*likeds)
/free
// encrypt the data
Qc3EncryptData(myClearData :%len(%trimr(myClearData))
:'DATA0100'
:ALGD0200 :'ALGD0200'
:KEYD0200 :'KEYD0200'
:'0' :' '
:myEncData :%size(myEncData)
:myEncDataLen :myIBMApiErr
);
*inlr = *on;
/end-free