Hi,
I have done the following steps
1. Created a File PSE in ECC(private key using RSA with SHA-1 (1024) ). Exported the certificate (.cert) file.
2. Used this .cert file (public key) to encrypt a message in java. See the code below.
3. While trying to decrypt the message in ABAP (using SSF_KRN_ENVELOPE and the private key created in the step above), I am getting 'SSF 12 Decoding Failed'.
Has anyone done this before? Is it possible to achieve something like this. What am I doing wrong?
Java Code
String certFile = req.getPrivateResourcePath()+"/ECDparam.cert";
InputStream inStream = new FileInputStream(certFile);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream);
inStream.close();
SsfSigRcpList rcplist = new SsfSigRcpList();
SsfSigRcpInfo rcpinfo = new SsfSigRcpInfo(cert);
rcplist.add(rcpinfo);
// Read the public key from certificate file
byte [] tempPub = null;
String sPub = null;
RSAPublicKey pubkey = (RSAPublicKey) cert.getPublicKey();
tempPub = pubkey.getEncoded();
sPub = new String( tempPub );
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, pubkey);
String message = "This is my secret message.";
byte[] messageBytes = message.getBytes();
byte[] ciphertextBytes = cipher.doFinal(messageBytes);
ABAP Code
Encrypted message is copied from the output of the java program and passed to the string 'EXAMPLE' in the code below.
DATA: SIG_ID LIKE SSFINFO-ID VALUE 'CN=ECDparam, OU=I0020847400, OU=SAP Web AS, O=SAP Trust Community, C=DE',
SIG_PROF LIKE SSFINFO-PROFILE VALUE '/usr/sap/ECD/DVEBMGS00/sec/ECDparams.pse',
SIG_PWD LIKE SSFINFO-PASSWORD VALUE ''.
REFRESH: DEV_RECIP_LIST.
CLEAR: DEV_RECIP_LIST.
DEV_RECIP_LIST-ID = SIG_ID .
DEV_RECIP_LIST-PROFILE = SIG_PROF.
APPEND DEV_RECIP_LIST.
DATA EXAMPLE TYPE STRING.
EXAMPLE = 'y¨Ç!ÈXÐ$ñÉ>/‚gr3á|#œáÿ²ke’“ϱ;®†™“w¤#Ÿ Ë™!·ÓÝ•ÞAÒ·N²ºTÞoÈ›)¦9iÞ0’„
ÙÆùÑcç·j·»vîg“R;$RØX4Ýu†g¨¸ÈÖ>ÜmP#g²IÚoÛÐF4'.
PERFORM CONVERT_TO_UTF8
USING EXAMPLE
CHANGING IN_DATA_TABLE-BINDATA.
PARAMS-INDATALEN = xstrlen( IN_DATA_TABLE-BINDATA ).
APPEND IN_DATA_TABLE.
CALL FUNCTION 'SSF_KRN_DEVELOPE'
EXPORTING
SSFTOOLKIT = TOOLKIT
STR_FORMAT = WRAPPER
B_OUTDEC = OUT_DEC
IO_SPEC = IO_SPEC
OSTR_ENVELOPED_DATA_L = PARAMS-INDATALEN
IMPORTING
OSTR_OUTPUT_DATA_L = PARAMS-OUTDATALEN
CRC = SSFRC
TABLES
OSTR_ENVELOPED_DATA = IN_DATA_TABLE
RECIPIENT = DEV_RECIP_LIST
OSTR_OUTPUT_DATA = OUT_DATA_TABLE
EXCEPTIONS
SSF_KRN_ERROR = 399
SSF_KRN_NOOP = 201
SSF_KRN_NOMEMORY = 202
SSF_KRN_OPINV = 203
SSF_KRN_RECIPIENT_ERROR = 206
SSF_KRN_INPUT_DATA_ERROR = 208
SSF_KRN_INVALID_PAR = 209
SSF_KRN_INVALID_PARLEN = 210
SSF_FB_INPUT_PARAMETER_ERROR = 211
OTHERS = 212.
Error log from SM21.
Any pointers/suggestions.
Regards,
Sharadha