Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck if the file is correct using sha1withRsa via openssl functions
    primarykey
    data
    text
    <h2>Hi, i have file_data(xml format) and file_signature(ASN1 DER), and also have certificate(X509 ASN1 DER). I want to check if file_data is correct, but I have some problems. what I'm doing:</h2> <p>Main Idea: Some company A creates file_data, then using SHA1 gets hash of the file_data, and encrypts this hash using RSA private key and gets file_signature. Then company A sends me file_data and file_signature and certificate. I get public key from certificate get file_signature and decrypt file_signature using public key and get hash_1. Then i get file_data and use SHA1 to get hash_2. If hash_1 and hash_2 is equal, i can trust to content of the file_data, am I right? </p> <p>Implementation:</p> <ol> <li>Load certificate: <code>d2i_X509_fp()</code> function. Now I have certificate.</li> <li>Get public key of the certificate: <code>X509_extract_key</code>, now i have public key.</li> <li><strong>Now i want to load file_signature to decrypt it using public key, BUT file_signature has ASN1 DER format how I can load it, what function in OpenSSl should I use?</strong></li> <li>Suppose I read file_signature, now I must decrypt it using my public key, is there any API for this purpose?</li> <li>Suppose I decrypt file_signature and get hash_1.</li> <li>Now I must load file_data and get hash of it using SHA1 function hash_2, what function I must use? <code>SHA1()</code>, or <code>SHA1_Init, SHA1_Update, SHA1_Finish</code>?</li> <li>Suppose I get hash_1 and hash_2, how i must compare them, using <code>memcmp</code>?</li> <li>Suppose I compare them, if they are equal, i can use file_data.</li> </ol> <p>another question is that file_signature is 128 byte len and when i decrypt it i get 128 byte hash_1(Am I rigth) , but when i get hash of the file_data hash_2 it's length is only 20 bytes, so how I can compare them, or I misunderstand something?</p> <p>Thanks for your help! p.s. sorry for my english;). </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload