Question on signing a file with RSA (openssl) - rsa

I'm read that either signing or encrypting (or both?) with RSA has a file size limit. One way I saw to tackle that was to take the sha256sum value of the file then sign that with RSA. Ultimately, I would like to sign a license file with RSA private key, so the destination application can verify it hasn't been altered (using public key)...
I found these script which sign and verify:
https://gist.github.com/ezimuel/3cb601853db6ebc4ee49
My questions are...
Is there a file size limit when you sign (not encrypt) with RSA?
If so, is signing the sha256sum of the file a valid way around the file size limit?
I see in the sign.sh script (in link above) is using a -dgst sha256 in the command. Is that taking the sha256sum value of the file and signing that, similar to #2? Or, if not, what is it doing?
I just want to make sure a license file isn't altered in transit. I was just going to append the signature to the bottom of the file. Then, have the application run a script separate the two (content and signature) to verify no changes have been made.
Thanks in advance.

Related

Convert certificates from txt to CER

Hi there I have an exchange server for which I need to renew its Globalsign authority certificate.
After i purchased it I got a zip file with x3 txt files in (password.txt / pem.txt /private key.txt).
Exchange server can only import CER file how can I convert those to CER file ?
thanks
Assuming the contents of pem.txt start with =====BEGIN CERTIFICATE=====, you'd either just specify the path of that file, or rename pem.txt to pem.cer (or certificate.cer, or whatever you want to call it).
(And for future reference, taking a screenshot with PrintScr or Alt+PrintScr (just the focused application) and trimming it down in something like paint is better than taking a picture of a monitor)

Check if downloaded file is corrupted and delete if corrupted from iPhone

Problem:
I have to download some files from the server. In between the connection with the server is lost. And when the file is opened it opened without any problem, except that it was blank.
Question
How to check if the downloaded file from the server is corrupted or not? Is there any way to do that?
If the file is corrupted it must be deleted from the documents folder.
Thank you!
You can create a hash of the file and then use that hash to compare the current hash to the new hash.
Here's an example on creating a hash for iOS:
http://iosdevelopertips.com/core-services/create-md5-hash-from-nsstring-nsdata-or-file.html
It should work pretty well because the hash only changes if the file contents change and is unaffected by creation times, modification times, and the file name.
Edit
You can also sign your files with PGP or GPG and use your public key to verify its contents.
Hope this helps :)
Send a hash of the file with the file, and then compare the hashes.

How do I force makecert to output the private key to a file (not the Crypto store)?

I want to generate a key pair for use within my applications, but exporting them manually from the mmc is a pain.
How can I use commandline parameters, or otherwise end up with a private certificate that resides on the hard drive, suitable for later distribution?
Have a look at this article: http://msdn.microsoft.com/en-us/library/bfsktky3%28VS.80%29.aspx
Specifically, use the -sv option to save the private key to a file.

Why do some sites have a md5 string on each file?

On some sites, in their download section each file has a md5. md5 of what? i cant understand the purpose
on phpBB.com for example:
Download phpBB 3.0.6 (zip)
Size: 2.30 MiB
MD5: 63e2bde5bd03d8ed504fe181a70ec97a
It is the signature of the file's hash. The idea is that you can run MD5 against the downloaded file, then compare it against that value to make sure you did not end up with a corrupted download.
This is a checksum, for verifying that the file as-downloaded is intact, without transmission errors. If the checksum listing is on a different server than the download, it also may give a little peace of mind that the download server hasn't been hacked (with the presumption that two servers are harder to hack than one).
It's a hash of the file. Used to ensure file integrity once you download said file. You'd use an md5 checksum tool to verify the file state.
Sites will post checksums so that you can make sure the file downloaded is the same as the file they're offering. This lets you ensure that file has not been corrupted or tampered with.
On most unix operating systems you can run md5 or md5sum on a file to get the hash for it. If the hash you get matches the hash from the website, you can be reasonably certain that the file is intact. A quick Google search will get you md5sum utilities for Windows.
You might also see an SHA-1 hash sometimes. It's the same concept, but a different and more secure algorithm.
This is an md5 hash of the entire binary contents of the file. The point is that if two files have different md5 hashes, they are different. This helps you determine whether a local file on your computer is the same as the file on the website, without having to download it again. For instance:
You downloaded your local copy somewhere else and think there might be a virus inside.
Your connection is lossy and you fear the file might be corrupted by the download.
You have changed the local file name and want to know which version you have.

why are downloads sometimes tagged md5, sha1 and other hash indicators?

I've seen this all over the place:
Download here! SHA1 =
8e1ed2ce9e7e473d38a9dc7824a384a9ac34d7d0
What does it mean? How does a hash come into play as far as downloads and... What use can I make of it? Is this a legacy item where you used to have to verify some checksum after you downloaded the whole file?
It's a security measure. It allows you to verify that the file you just downloaded is the one that the author posted to the site. Note that using hashes from the same website you're getting the files from is not especially secure. Often a good place to get them from is a mailing list announcement where a PGP-signed email contains the link to the file and the hash.
Since this answer has been ranked so highly compared to the others for some reason, I'm editing it to add the other major reason mentioned first by the other authors below, which is to verify the integrity of the file after transferring it over the network.
So:
Security - verify that the file that you downloaded was the one the author originally published
Integrity - verify that the file wasn't damaged during transmission over the network.
When downloading larger files, it's often useful to perform a checksum to ensure your download was successful and not mangled along transport. There's tons of freeware apps that can be used to gen the checksum for you to validate your download. This to me is an interesting mainstreaming of procedures that popular mp3 and warez sites used to use back in the day when distributing files.
SHA1 and MD5 hashes are used to verify the integrity of files you've downloaded. They aren't necessarily a legacy technology, and can be used by tools like those in the openssl to verify whether or not your a file has been corrupted/changed from its original.
It's to ensure that you downloaded the file correctly. If you hash the downloaded the file and it matches the hash on the page, all is well.
A cryptographic hash (such as SH1 or MD5) allows you to verify that file you have has been downloaded correctly and has not been tampered with.
To go along with what everyone here is saying I use HashTab when I need to generate/compare MD5 and SHA1 hashes on Windows. It adds a new tab to the file properties window and will calculate the hashes.
With a has (MD5, SHA-1) one input matches only with one output, and then if you down load the file and calculate the hash again should obtain the same output.
If the output is different the file is corrupt.
If (hash(file) == “Hash in page”)
validFile = true;
else
validFile = false;