Possible Duplicate:
RSA Encryption Problem [Size of payload data]
I need a system in which I generate digital signatures on some data using say ECDSA in bouncy castle. & then use the same signed text & further Encrypt the same text using either Elgamal Or RSA in bouncy castle. The main issue is after signing a small data (say "Hello world") using ECDSA I get output which is very large ie 54 bytes digit.
Now After signed data I use Elgamal or RSA for data encryption ... So here the RSA or Elgamal is not taking the entire input string of 54 bytes.. it only takes 32 BYtes & further text is truncated ...
links i have refered:
for ECDSA signature:
And for RSA or Elgamal: http://ox.no/posts/rsa-using-bouncycastle
sample code:
Public Function Encrypt(ByVal data As Byte(), ByVal key As AsymmetricKeyParameter) As Byte()
Dim e As New ElGamalEngine()
e.Init(True, key)
Dim blockSize As Integer = e.GetInputBlockSize()
Dim output As New List(Of Byte)()
Dim chunkPosition As Integer = 0
While chunkPosition <= data.Length
Dim chunkSize As Integer = Math.Min(blockSize, data.Length - (chunkPosition * blockSize))
output.AddRange(e.ProcessBlock(data, chunkPosition, chunkSize))
chunkPosition += blockSize
End While
Return output.ToArray()
End Function
Public Function Decrypt(ByVal data As Byte(), ByVal key As AsymmetricKeyParameter) As Byte()
Dim e As New ElGamalEngine()
e.Init(False, key)
Dim blockSize As Integer = e.GetInputBlockSize()
Dim output As New List(Of Byte)()
Dim chunkPosition As Integer = 0
While chunkPosition <= data.Length
Dim chunkSize As Integer = Math.Min(blockSize, data.Length - (chunkPosition * blockSize))
output.AddRange(e.ProcessBlock(data, chunkPosition, chunkSize))
chunkPosition += blockSize
End While
Return output.ToArray()
End Function
can you plz suggest me something on this..
Also rather than using RSA or ELgamal .. I can go for ECDSA it self for encryption?... but as per my knowledge ECDSA is just meant for Digital signing & not for Encryption . Also if we use ECDSA for Encryption as you have done above... then how do we Decrypt the data???
Thanks a lot..