BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-14-2009, 12:16 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2009
Model: 8100
PIN: N/A
Carrier: vodafone
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Generate AES key with seed value

Please Login to Remove!

Hi,

How do I Generate AES key with seed value so that whenever I generate key with same seed value,I shud be able to get the same AES key?
Please help.

Thanks.
Offline  
Old 05-14-2009, 11:45 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

net.rim.device.api.crypto.AESKey(byte [] data) or other similar constructors.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 05-14-2009, 11:05 PM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2009
Model: 8100
PIN: N/A
Carrier: vodafone
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes,I have used the same.
Actually,whenever the encrypted text is generated,its different everytime.How can I generate same encrypted text everytime?
Offline  
Old 05-16-2009, 05:01 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

How are you encrypting the data? I used this KB article to start.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 05-17-2009, 11:38 PM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2009
Model: 8100
PIN: N/A
Carrier: vodafone
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Thanks for reply.
I am encrypting data in follwing manner:


System.out.println("Message to be encrypted >>> "+message);
AESKey key = new AESKey();
byte [] aesByte = key.getData();

AESstring = new String(aesByte);

AESEncryptorEngine encryptionEngine = new AESEncryptorEngine(key);

PKCS5FormatterEngine formatterEngine = new PKCS5FormatterEngine( encryptionEngine );

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

BlockEncryptor encryptor = new BlockEncryptor( formatterEngine, outputStream );

encryptor.write( message.getBytes() );

encryptor.close();

encryptedData = outputStream.toByteArray();
Offline  
Old 05-18-2009, 09:50 AM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Well, there's your problem. from the API documentation AESKey() "Creates a new random 128-bit key". So it is not surprising that you get different cyphertext each time.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 05-27-2009, 06:01 AM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2009
Model: 8100
PIN: N/A
Carrier: vodafone
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again,
Coming back to my previous thread...

I am not able to generate AES key with AESKey(keyData) .

Also whenever I print it either in the form of String or byte[] , I am not able to generate it.(print it) Actual key is never printed.

What can be done to get the key?

Please help,badly stuck in this issue.
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.