In Public key infrastructure, the MD5 of a piece of data is encrypted with the private key of a sender and this encrypted MD5 – along with the data – is again encrypted using an algorithm like AES or 3DES.
Here, the private key of a sender is used to encrypt with AES… is that correct?
This is a rough implementation of what I think I’ve understood:
- 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 is the key to encrypt, and param 2 is the DATA and hash which have been concatenated - encryptkey = RSAENCRYPT(privatekey,KEY)
= AES key, encrypted with private key of sender - masterKEY = RSAENCRYPT(publickey,KEY)
= encryptkey, encrypted with public key of receiver
Is this correct, or am I missing something important?
RSAENCRYPT
to sign a hash is wrong; the role ofencryptkey
is unclear at best (why is is computed? who will get to know it?); the formula for computation ofmasterKEY
(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