Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am new to bouncy castle, and i tried to encrypt the file using publickey in bouncy castle, but after encrypting client can't decrypt file, it shows error privatekey not found, i traced the problem in signature generator,kindly help me with this problem

What I have tried:

Private Function InitSignatureGenerator(ByVal compressedOut As Stream) As PgpSignatureGenerator
           Const IsCritical As Boolean = False
           Const IsNested As Boolean = False
           Dim tag As PublicKeyAlgorithmTag = m_encryptionKeys.SecretKey.PublicKey.Algorithm
           Dim pgpSignatureGenerator As New PgpSignatureGenerator(tag, HashAlgorithmTag.Sha1)

           pgpSignatureGenerator.InitSign(PgpSignature.BinaryDocument, m_encryptionKeys.PrivateKey)
           For Each userId As String In m_encryptionKeys.SecretKey.PublicKey.GetUserIds()
               Dim subPacketGenerator As New PgpSignatureSubpacketGenerator()
               subPacketGenerator.SetSignerUserId(IsCritical, userId)
               pgpSignatureGenerator.SetHashedSubpackets(subPacketGenerator.Generate())


               Exit For
           Next
           pgpSignatureGenerator.GenerateOnePassVersion(IsNested).Encode(compressedOut)
           Return pgpSignatureGenerator
       End Function
Posted
Updated 20-Jun-17 3:42am
Comments
selvam palanisamy 29-Jun-17 6:00am    
I finished this with adding additional key..

1 solution

The following article may help you: Using Password-based Encryption on Android[^].
 
Share this answer
 
Comments
selvam palanisamy 21-Jun-17 0:17am    
thanks richard, but my doubt is i just want to add two keys, public key and private while encrypting dont want to sign, any suggestions?
Richard MacCutchan 21-Jun-17 3:31am    
Sorry, I have not used Asymmetric. You will need to study the documentation closely, or use Google to find sample code.
selvam palanisamy 21-Jun-17 3:33am    
Thanks richard
selvam palanisamy 24-Jun-17 6:50am    
NOw its working i forgot to add dh sub key, but the problem is now for bad packet error in small size of files..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900