Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Encryption using public key and RSA algorithm

sap-tabrez
Explorer
0 Kudos

I am having a challenge in encrypting a password and App-Key for e-Invoice process :

1) Encryption has to be done based on a public key [ length = 394 chars ]

2) Encryption has to be done based on RSA algorithm

I am trying out my best in class :

cl_sec_sxml_xencryption=>encrypt_string

5 REPLIES 5

how2kode
Explorer
0 Kudos

Try this class 'cl_sec_sxml_writer'

ex:

cl_sec_sxml_writer=>encrypt(

EXPORTING
plaintext = xtext
key = xkey
algorithm = cl_sec_sxml_writer=>co_aes256_algorithm
IMPORTING
ciphertext = ciphertext ).

0 Kudos

it's symmetric encryption while the OP is asking about asymmetric encryption.

0 Kudos

Have you worked on this concept.. i am also facing the issue , do i need to convert the key from string to xstring format then pass in this class

0 Kudos

Using asymmetric encryption will be a bit typical as you will have to manage the public and private keys somehow within the SAP system (probably through some service) as the keys won't be stored inside the SAP but rather on the AD.

My best bet would be that you probably have to write the whole class/function for encryption and decryption inside the SAP system utilizing PGP or you can take a look at the FM 'SSF_KRN_ENVELOPE' i have never used it so can't vouch for it.

Lastly if you just want to encrypt the invoice same for all users then you can go ahead with the symmetric encryption as mentioned in this blog:

https://blogs.sap.com/2019/08/26/aes-encryption-in-abap/

0 Kudos

I had the same Problem and i used CALL FUNCTION 'SSFW_KRN_ENVELOPE'. To use the CALL FUNCTION 'SSFW_KRN_ENVELOPE' you need a structure from the strustcab. So I created this strustcab-structure with a certificate which contained this public key. (You can use any Certificate and replace manually the Public Key in it)