Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

we normally always encrypt by public key and decrypt with private key.

  1. If i encrypt with private key, then its still secure as normal PKI ? i mean known-plain-text will not take private key on the risk ? (for example when people know the plain text and signed message with private key, then private key is safe or will compromise?

  2. When we encrypt with the public key then known-plain-text make public key compromise but private key is safe?

share|improve this question
    
the reason i asked because i herd encrypting with private key is ok but if i do then private key will compromise and i have to keep public key in a safe place ? –  Edward Jul 9 '12 at 19:42
    
cross posted: security.stackexchange.com/questions/17013/… –  CodesInChaos Jul 9 '12 at 20:52
    
What kind of padding do you use? –  CodesInChaos Jul 9 '12 at 20:53
    
    
Should this question be merged with RSA encryption with private key and decryption with a public key? –  Piotr Dobrogost Dec 11 '12 at 23:46
add comment

2 Answers

Well, first of all, this is not a generic 'public-key' question. With RSA, it can make sense to talk about 'encrypting with the private key', for most other public key algorithms, there's isn't an obvious interpretation. For example, with DSA, the public key operation (which is a signature verification) is 'plug the data from the signature, the hash of the data and the public key into a formula; the signature passes of both sides are the same value'. There's no obvious way to use this type of operation to encrypt something.

Now, in your question, you ask whether encrypting with the RSA private key is secure. Well, that depends on what you mean by secure; what precisely are you attempting preventing someone from doing? In one sense, it is not secure at all; anyone who has the public key can decrypt the message. Since it is generally true that anyone can get the public key, well, this means that this is not at all a secure encryption method.

On the other hand, you might not be assuming that this is a secure encryption method; this might be an attempt to simulate RSA signature generation. Here, you have to be careful; RSA using padding methods to translate between the message being encrypted/signed into a value to give to the raw RSA function. The security properties for an encryption padding method are different from the security properties for a signature padding method; in fact, there are real world secure encryption padding methods (for example, RSAES-PKCS1-v1_5 with e=3) that could be insecure if used as a signature padding method.

However, you may simply be asking "would the key be secure"? In some sense, that is irrelevant; usually, the only reason an attacker wants the keys is that would allow him to perform some operation; if he can perform those operations without the keys (because, for example, of the vulnerabilities mentioned in the above two paragraphs), then he doesn't need the keys. However, if you are still concerned about the keying data, well, it turns out that RSA is safe; performing RSA operations (even on attacker chosen values) doesn't leak the private key.

share|improve this answer
    
I'm not immediately seeing an attack against RSAES-PKCS1-V1_5-ENCRYPT (wrongly) used as a signature scheme that gets easier with e=3; any hint? –  fgrieu Jul 10 '12 at 6:57
    
Or perhaps there is that line of thought, where $e=3$ makes the attack easier; but it is going to be seriously hindered by the minimum of 64-bit (near) random introduced by RSAES-PKCS1-V1_5-ENCRYPT; it would work if the adversary also controlled that. BTW, 64-bit! That's so passé, and on the verge of unsafe if only a few bits of the message are unknown. –  fgrieu Jul 10 '12 at 8:43
1  
@fgrieu: well, PSAES-PKCS1-V1_5-ENCRYPT makes it easy to forge signatures, if the modulus is big enough. This is not that profound an observation; the attacker just finds a perfect cube of the form 00 02 | PS | 00 | Hash (for a preselected value of Hash which happens to be odd). If Hash is 256 bits, then a modulus size of 1k should be more than sufficient. This allows him to trivially generate forgeries for about half of all possible messages. –  poncho Jul 10 '12 at 12:10
    
I see: you are assuming the adversary can manipulate PS (or knows PS when he decides the message). I was seeing that another way, where the attacker can submit messages, but has no control over what PS will be. –  fgrieu Jul 10 '12 at 12:23
1  
@fgrieu: you're thinking about this the wrong way. To attack a signature scheme, you attempt to generate a forgery. If he can find a perfect cube of the form 00 02 | PS | 00 | Hash, then the cube root of that value (easy to compute) is a valid signature of the message with that hash. If the modulus is long enough (and hence PS is long enough) and Hash is odd, it is easy to find a cube in the above form where PS doesn't contain any zero bytes. He does all this without submitting any messages; even if he doesn't even know the modulus (other than its size). –  poncho Jul 10 '12 at 13:15
show 1 more comment

1) Yes, if you use standard schemes, the private key should remain safe.

2) The public key is always completely open, you give it to everybody. Knowledge of this public key or things it encrypted should not compromise the private key.

Both of these are basic foundations that PKI needs in order to work.

share|improve this answer
    
but Paŭlo Ebermann said here its not safe : crypto.stackexchange.com/questions/2123/… –  Edward Jul 9 '12 at 19:37
    
i herd somewhere else too that encryption doesn't matter apply by public or private key. it make the key compromise ... ! –  Edward Jul 9 '12 at 19:38
    
Note how I said "if you use standard schemes", which was basically what he also said. Raw usage is not secure, but it's fine if you use the standard schemes for padding, signing a hash, etc. –  B-Con Jul 10 '12 at 3:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.