Skip to Content

Encryption using public key and RSA algorithm

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Jul 25 at 10:44 AM

    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/

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 27 at 03:50 PM

    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)

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 25 at 08:19 AM
    -1

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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.