Quantcast
Channel: SCN: Message List - Security
Viewing all articles
Browse latest Browse all 5338

Problem with digital signature of documents

$
0
0

I have a requirement to upload documents and his respected fingerprint signed (SHA1WithRSA).

 

To achive this I am using the functions modules:

 

SSF_KRN_DIGEST

SSF_KRN_SIGN_BY_AS

 

but I can´t make it work.

 

I also ask for the .pem file used to generate the PSE that I'm using to sign documents.

With this pem file I execute in openSSL this following command:

 

#Creates Message Digest of document.txt, and the sign it with MyKey.pem

dgst -sha1 -sign MyKey.pem -out document.sign document.txt

 

AND THIS WORKS! Now, with this succesfull case I try to track down the problem with the FM that I'm using, and I detected that SSF_KRN_DIGEST is given me a diferent result than openssl (so I forget for sign the document for a while...).

 

 

This are the HEX value for OpenSSL (this is the one that works):

 

3021300906052B0E03021A05000414AC
3725ACAD34E2F8B921B315DD200D715B
FDEEEB

 

And this is the HEX value of the result of FM SSF_KRN_DIGEST:

 

304006092A864886F70D010705A03330
31020100300906052B0E03021A050030
0B06092A864886F70D0107010414AC37
25ACAD34E2F8B921B315DD200D715BFD
EEEB

 

As you can see, both files do countain the digest, but the metadata and padding is different. As far as I know, it should respect the ASN.1 structure, but I can figure out whats wrong with the SSF_KRN_DIGEST call.

 

This is my code:

 

* Creamos el message diggest del archivo

CALL FUNCTION 'SSF_KRN_DIGEST'

   EXPORTING

     b_detached                         = 'X'

     ostr_input_data_l                  = lv_bin_data_len

     str_hashalg                        = 'SHA1'

  IMPORTING

    ostr_digested_data_l               = lv_digested_len

*   CRC                                =

   TABLES

     ostr_input_data                    = lt_bin_data

     ostr_digested_data                 = lt_digested_data

  EXCEPTIONS

    ssf_krn_error                      = 1

    ssf_krn_noop                       = 2

    ssf_krn_nomemory                   = 3

    ssf_krn_opinv                      = 4

    ssf_krn_nossflib                   = 5

    ssf_krn_input_data_error           = 6

    ssf_krn_invalid_par                = 7

    ssf_krn_invalid_parlen             = 8

    ssf_fb_input_parameter_error       = 9

    OTHERS                             = 10.

 

Where lt_bin_data contains the document, uploaded in binary mode.

 

Thanks in advance.

 

regards.


Viewing all articles
Browse latest Browse all 5338

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>