RSA-4096 decrypt a file - encryption

Can I decrypt a RSA-4096 encryption without private-key?CryptoLocker have encrypted all my work data!

You can't, you need the private key to decrypt the files.
Another option would be to brute force the private key. but brute forcing a RSA-4096 private key would take millions of eons.

Related

Private and Public Key Concept in RSA

I am actually building a file encryption solution which shall have following salient features:
ENCRYPTION SIDE
Firstly, I have to Hash the file with SHA-256 and store that hash in a separate file.
Afterwards, I have to encrypt that file using private key of sender.
A symmetric key will be generated for AES Algorithm.
I then have to encrypt the actual file with that symmetric key.
Finally, that symmetric key will be encrypted with public key of the receiver.
DECRYPTION SIDE
Decryption of hash file with public key of sender.
Decryption of encrypted asymmetric key with private key of receiver.
Decryption of that actual file with symmetric key.
Hashing the actual file again
Compare the hash generated with the hash provided by sender to validate content.
Now, I that is the complete stuff I need to implement, However, I have few queries pertaining to the keys actually; which are not clarified after surfing many web-sites.
QUERIES
What does actually meant by the private key of sender? I know, I shall have to implement it with RSA Algorithm; which works with key pair. If I (sender) will encrypt the file with public key generated in key pair that how the private key for the receiver will be generated? Is this the same key generated under key pair?
if yes then do we have to provide that key to the receive?
if no then how the data will be decrypted by the receiver? since the message is encrypted under my own key pair generated...
How can we share the relevant keys and hashes with the receiver? Since, emails and other platforms are public and shall not be used for sharing confidential data.
Please an easy explanation will be very helpful for me, I am confused with these above mentioned terms.
Thanks in advance.
What does actually meant by the private key of sender? I know, I shall have to implement it with RSA Algorithm; which works with key pair. If I (sender) will encrypt the file with public key generated in key pair that how the private key for the receiver will be generated? Is this the same key generated under key pair?
In very old documents or by very confused people, this is the way that they talk about signature generation. Normally the hashes won't be stored in a file though, unless a Merkle tree is used instead of direct hashing.
if yes then do we have to provide that key to the receive? if no then how the data will be decrypted by the receiver? since the message is encrypted under my own key pair generated...
The public key should be distributed to the other party in any way that the public key can be trusted (to be from the sender). Then the sender's public key can be used to verify the signature created over the original file.
How can we share the relevant keys and hashes with the receiver? Since, emails and other platforms are public and shall not be used for sharing confidential data.
That's up to you. Generally a trusted third party is used together with X.509 certificates. The whole thing together is called Public Key Infrasture or, even more broadly, key management.

Proper asymmetric file encryption in Go

I need a way to allow multiple people encrypting various files but only one party been able to read them all. I wrote a program in Go by following various online examples but at some point I got the following error:
Error from encryption: crypto/rsa: message too long for RSA public key size
Is RSA the wrong way to go? Is it ok if I break the file into multiple chunks and encrypt them? Is there an asymmetric block cipher that I can easily use?
I read the discussion here and it is said that RSA is not the proper way to go.
Can you also provide with an example?
If you need public key asymmetric encryption for data larger than the key size you need to use hybrid encryption. Essentially this is how HTTPS works.
Hybrid encryption is where the data is encrypted with symmetric key encryption such as AES and that key is encrypted with asymmetric key encryption such as RSA or EC (Elliptic Curve) Cryptography.
Do not break the file into multiple chunks and encrypt them.
So I ended up using GPG and my service has one unique private key and I share the public one with my users.

RSA Encryption - Public Key Encryption

I would like to use RSA encryption on a large file (>25 MB).
Is it possible or are there limitations using a Public Key/Private Key for a large app?
I am exposing a public key to clients and not allowing anyone but the recipient to view the contents with the private key. So the business case makes sense although it will be slower than symmetrical encryption.
Thanks,
RSA cannot encrypt a payload larger than its key size (minus some overhead for padding). To bypass this limitation you'll need to generate a symmetric key, use that to encrypt the larger file, then encrypt the symmetric key itself with RSA (with OAEP or PKCS1v1.5 padding).
Cryptographic Message Syntax (CMS) and PKCS7 (CMS's predecessor) support this use case already so there's no need to invent your own protocol.

Can RSA be both used as encryption and signature?

I am sorry but my mind suddenly goes blank for this question....
EDIT (Scenario)
If I want information to bypass simple filters like f-ck, is it OK to encrypt the information with public key, and sign by private key?
The public key may have already exchanged by both sides, and it is even hard to get the public key.
EDIT 2
The information itself may not that much credential.
The point of encryption and signature is for bypassing and integrity.
RSA is two algorithms: one for asymmetric encryption and one for signatures. It so happens that both algorithms can use the same private key structure (this is a source of confusion: many documentations, including the RSA standard, try to explain the signature as "an encryption with the private key", which is, at best, inaccurate).
Using the same key for both usages is possible, but not really recommended, because interactions between both kind of usages have not been fully explored; also, keys for encryption and keys for signatures usually have different life cycles with distinct protection mechanisms (for instance, you normally want to keep a backup of the private key for encryption, to prevent data loss: losing the private key means losing all data which has been encrypted with that key; while you do not want a backup of the signature key).
Your scenario is a bit unclear. Asymmetric encryption uses the public key, while generating the signature uses the private key. If A wants to send a message to B with encryption (for confidentiality) and a signature (for integrity), then A will encrypt the data with a public key for which B knows the private key; and A will sign the data with a private key for which B knows the public key. This calls for two pairs of key: one pair is used for encryption and decryption (A encrypts, B decrypts, B knows the private key), and the other pair is used for signatures (A signs, B verifies, A knows the private key). If both A and B know the private key, then they have a shared secret, and it is much simpler (and faster) to use symmetric encryption (AES) and integrity checks (HMAC).
Standard disclaimer: you look like you are designing your own cryptographic protocol. Do not do this. This road leads to the same security failures that countless other smart people have stumbled upon. Use a tried-and-proven protocol such as SSL/TLS or OpenPGP.
Yes:
encryption: you encrypt with public
key, decrypt with private (obviously)
signing: you encrypt the content digest (hash) with private key, verify with public
See http://en.wikipedia.org/wiki/RSA#Signing_messages

Why shouldn't a private key be stored verbatim or in plain text on the local computer?

I was reading this:
http://msdn.microsoft.com/en-us/library/tswxhw92(VS.80).aspx
The first sentence says: "Asymmetric private keys should never be stored verbatim or in plain text on the local computer."
What's the problem with this? And how does a key container solve it.
The reason I'm asking is that I want to generate an asymmetric key pair. The application I'm writing will encrypt information it sends back to me with the public key. I was thinking of storing the public/private key pair in our source control system so that it gets backed up. Shouldn't I be doing that? If not, how should I store the private key so that it can be reliably backed up?
Thanks.
-scott
Update: Does 'never' in the quoted sentence really mean never. Or does it mean I shouldn't be storing keys to source control unless I'm not prepared to take the risk that a hacker could potentially retrieve the keys from our source control system or from a backup taken from it.
Yes, the "never" in the quoted sentence really does mean never.
If the key is stored in plaintext, then anyone with access to that file can read or duplicate your key, then use it to impersonate you. If you display that file on-screen for whatever reason (looking up the key, open the wrong file, editing other information in the file, etc.), then anyone walking past can see it, potentially memorize it, and use it to impersonate you.
A private crypto key is a non-shared secret. If you don't keep it non-shared and secret, it can't do its job properly.
A common solution is to encrypt private keys in the keychain e.g. by using some password-based encryption scheme.
The private key is needed in order to decrypt bits encrypted with the public key, and vice versa. Since the public key is public by definition, you want to keep its private counterpart secret.
Especially when public key crypto is used for digital signatures, it's important to keep the private key secret. Being able to produce digital signatures that can be verified with your public key essentially proves that whoever made the signature had access to your private key.
If you can guarantee that no one but you, or software you trust, can access files on your computer, you don't need to encrypt your private keys. But these are tough assumptions to make.
Because a malicious user can read your key, if he/she gets a hold of your files. Not sure, what the key container does, but I would guess that it encrypts the keys before writing them to a file.

Resources