ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IIB9: Custom Decryption

Post new topic  Reply to topic
 IIB9: Custom Decryption « View previous topic :: View next topic » 
Author Message
akil
PostPosted: Thu Nov 27, 2014 6:00 am    Post subject: IIB9: Custom Decryption Reply with quote

Partisan

Joined: 27 May 2014
Posts: 338
Location: Mumbai

Hi

I get an incoming message that has one element encrypted using a RSA public key. I have the private key in a file. This isn't a complete certificate, it is just the key, generated via a small java program

Code:

                       KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
                        kpg.initialize(1024); // can give the key size for key pair

                        KeyPair kp = kpg.genKeyPair();

                        Key publicKey = kp.getPublic();
                        Key privateKey = kp.getPrivate();

                        KeyFactory fact = KeyFactory.getInstance("RSA");
                        RSAPublicKeySpec pub = fact.getKeySpec(kp.getPublic(), RSAPublicKeySpec.class);
                        RSAPrivateKeySpec priv = fact.getKeySpec(kp.getPrivate(), RSAPrivateKeySpec.class);

                        saveToFile("public.key", pub.getModulus(),pub.getPublicExponent());
                        saveToFile("private.key", priv.getModulus(),priv.getPrivateExponent());


Now I have to decrypt this element in the message flow, for which I have to do something like the following code

Code:

                        PrivateKey priKey = readKeyFromFile("private.key");
                        // use the private  key for decryption

                        Cipher cipher = Cipher.getInstance("RSA");
                        cipher.init(Cipher.DECRYPT_MODE, priKey);
                        decryptedData = cipher.doFinal(dataToDecrypt);
                        System.out.println(new String(decryptedData));



I am wondering how do I proceed with reading this file , earlier posts in the forum suggest that reading files isn't a good thing to do in the bus.

There are multiple environments (QA, UAT, PRD), each having its own private.key, so I can't just package the file along with the code..

Any suggestions?
[/code]
_________________
Regards
Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Thu Nov 27, 2014 11:06 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Configurable service pointing to the file?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
akil
PostPosted: Thu Nov 27, 2014 11:53 pm    Post subject: Reply with quote

Partisan

Joined: 27 May 2014
Posts: 338
Location: Mumbai

That'll take care of different files paths in different environments..

But do I go ahead and read it in the flow ?
_________________
Regards
Back to top
View user's profile Send private message Visit poster's website
akil
PostPosted: Fri Nov 28, 2014 10:06 pm    Post subject: Reply with quote

Partisan

Joined: 27 May 2014
Posts: 338
Location: Mumbai

So I decided to add 2 properties in the UDCS, the private Exponent & the private Modulus , I build the private key from this , this avoids the file read altogether ..

Interestingly if I name the property to contain the phrase 'Password', the value is masked when mqsireportproperties is called - that's pretty neat !.
_________________
Regards
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IIB9: Custom Decryption
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.