Tell me more ×
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.

In Public key infra structure, The MD5 of the data is encrypted with private key of sender and this encypted md5 along with the data is again encryted using AES or 3DES algo. here key used to encrypt with AES is encrypted with private key of sender. Is this correct?

DATA// text which should be send through PKI hash = MD5(DATA)

encrypthash = RSAENCRYPT(privatekey,hash)//hash encrypted using private key of sender

cipher= AES(KEY,DATA+hash)//param 1- key to encrypt, param 2- DATA and hash are concatnated

encryptkey = RSAENCRYPT(privatekey,KEY)// AES key encrypted with private key of sender

masterKEY = RSAENCRYPT(publickey,KEY)// encryptkey encrypted with public key of receiver

its a rough implementation. Am I right?

share|improve this question
1  
1) MD5 isn't good enough for this 2) You forgot the signature padding. No padding, no security. – CodesInChaos Nov 22 '12 at 18:29
1  
How about reading PKCS#1 ? – CodesInChaos Nov 22 '12 at 18:30
You are doing it wrong. Encryption of hash with RSA private key is called signing. Note, that RSA is one of the few ciphers that provide signature as encryption with private key. The goal of second operation is not clear. Why you encrypt a symmetric key? I see you need classic sign-then-encrypt scheme. – Pavel Ognev Nov 23 '12 at 6:35
1  
This question badly needs repair before it can be answered meaningfully. In particular it is unclear which public/private key belongs to who (sender/receiver); the use of RSAENCRYPT to sign a hash is wrong; the role of encryptkey is unclear at best (why is is computed? who will get to know it?); the formula for computation of masterKEY (which makes sense) does not match the comment alongside (and I fail to grasp its intend). See this answer – fgrieu Nov 23 '12 at 16:20

closed as not a real question by fgrieu, Thomas, Maeher, PaĆ­lo Ebermann Nov 27 '12 at 18:51

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

It is not correct. Actually, your usage of RSA is entirely wrong.

In a public key scheme, there are 2 keys, one for encryption and one for decryption. If you use the private key to encrypt.... the public key would be used to decrypt. That means everyone can decrypt, as the public key is public.

If you use a public key scheme and the private key to create something, this can only be a signature. And in that case, you would have to use some kind of sign function instead of encrypt; they are not equal.

If we ignore the wrong RSA encryptions, there isn't much left:

  • You hash the data with MD5
  • you encrypt data+key with AES under key KEY.
  • you transmit KEY with RSA and the receivers public key (this is how RSA encryption is used).

However... this is just a simple "send encrypted message" algorithm: encrypt with symmetric cipher and random key, encrypt key with public key scheme and receivers public key. The MD5 hash value does not serve any purpose at all: It is not checked, it doesn't help authenticate the sender, it doesn't achieve message integrity.

But even if we assume, you wanted to sign with RSA instead of encrypting.... I still don't understand what you are trying to achieve here.

share|improve this answer

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