0

Im trying to implement RSA based on custom padding value.

cipher.init(ENCRYPT_MODE, publicKey,oaepParameter, secureRandom); 

I would like to change the secureRandom function to somthing else. Basically like to feed custom defined byte[] (could be random/ based on specific logic) to the Cipher init method. Is there any way i can acheive this

3
  • Your best bet is to use the "RSA/ECB/NoPadding" transformation specification and then perform your own custom padding before encryption. Commented Jun 15, 2023 at 16:16
  • @PresidentJamesK.Polk, Is there no other way to change the existing padding methods to take custom byte array as input for padding ? I could see options in python but not in java. Like in python PKCS1_OAEP.new( self.pubkey,hashAlgo=,mgfunc=,randfunc=) do we have somthing like this in java Commented Jun 16, 2023 at 5:37
  • You can supply your own SecureRandom implementation, but it's a little tricky. There should be examples of that here on Stack Overflow, I think I might even have an answer on that. See my answer to a different question for how to choose the hash function and MGF hash function in OAEP padding. Commented Jun 16, 2023 at 14:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.