Re: [Jsdsi-users] KeyPairs generated by other APIs ==> Problem Solved :)
Status: Pre-Alpha
Brought to you by:
sajma
From: Somaya A. <som...@ya...> - 2006-01-16 17:26:17
|
Hi Sameer, Yes I have checked jsdsi.util.RSAKeyPairGeneratorSpi and I found that it uses the sun provider (sun.security.rsa.RASKeyPairGenerator) to generate the KeyPairs then afterwards it changes the public key part (which is of type java.security.PublicKey) to be object of type jsdsi.PublicKey. So I have made the same thing for the public keys that are generated from outside jsdsi, like this: jsdsi.PublicKey Signee1=new jsdsi.RSAPublicKey((java.security.interfaces.RSAPublicKey) signee) And it works :) Thank you Somaya Sameer Ajmani <aj...@gm...> wrote: Look at jsdsi.properties: KeyPairGenerator.SPKI/RSA = jsdsi.util.RSAKeyPairGeneratorSpi So see jsdsi/util/RSAKeyPairGeneratorSpi.java S On 1/15/06, Somaya Aboulwafa wrote: > > I have reached an answer for my question, I found the jsdsi key generator > class, it's jsdsi.util.RSAKeyPairGeneratorSpi > > Thank you :) > > > Somaya Aboulwafa wrote: > > > Hi Sameer, > Don't bother yourself with the code. I'll try to compare how both jsdsi and > jade generates keypairs in order to figure out where the problem is. > > I have first checked jsdsi, and I have a question. > Does JSDSI have its own implementation for Key Pair Generators? If yes, > which class does this? Let me ask this question in a different way, what > does the following line call? > KeyPairGenerator kpg = KeyPairGenerator.getInstance("SPKI/" + > keyEnum.jdkName()); > In java doc, it is stated that the getInstance method work as follows: it > generates a KeyPairGenerator object that implements the specified digest > algorithm. If the default provider package provides an implementation of the > requested digest algorithm, an instance of KeyPairGenerator containing that > implementation is returned. If the algorithm is not available in the default > package, other packages are searched. > So, is the alogorithm "SPKI/RSA" supported in the default package or > supported by jsdsi provider and in both cases where?? > > Thank you for your help, > Somaya > > Somaya Aboulwafa wrote: > > > Okay, attached plz find a file; it is a small program for an agent trying to > create a certificate for another agent. Plz tell me if you have any comments > > Thanks alot, > Somaya > > Sameer Ajmani wrote: > I don't want to run the code -- just visually inspect it. > > S > > On 1/13/06, Somaya Aboulwafa wrote: > > Hi Sameer, > > > > Yes i can, but, for you to run it you'll need to > > install the Agents framework that i'm using (JADE > > multiagent framework). This is becoz, I'm using > > keypairs generated by this API. Do u have time to do > > this?! > > > > Thanks, > > Somaya > > > > --- Sameer Ajmani wrote: > > > > > On 1/5/06, Somaya Aboulwafa > > > wrote: > > > > Hello, > > > > > > > > The exception happens when trying to create an > > > > authorization certificate using this line of code: > > > > > > > > AuthCert cert = new AuthCert((Principal) > > > > signer.getPublic(), (Subject)signee. getPublic(),, > > > v, > > > > dh, c, t, p); > > > > > > > > Where signer and signee parameters are > > > > java.security.KeyPair objects generated from > > > outside > > > > the JSDSI API. > > > > > > > > The Exception is as follows: > > > > java.lang.ClassCastException: > > > > sun.security.rsa.RSAPublicKeyImpl > > > > at > > > > > > > > > > credentials.version1_0.SenderAgent.CreateCertificate(SenderAgent.java:123) > > > > at > > > > > > > > > > credentials.version1_0.SenderAgent.access$2(SenderAgent.java:111) > > > > > > > > > > > > Another exception also occurs when trying to sign > > > a > > > > certificate using the following line of code: > > > > > > > > jsdsi.Signature sig = > > > jsdsi.Signature.create(signer, > > > > cert, DigestAlgoEnum.SHA1); > > > > > > > > It is as follows: > > > > java.lang.ClassCastException: > > > > sun.security.rsa.RSAPublicKeyImpl > > > > at > > > jsdsi.Signature.create(Signature.java:199) > > > > at > > > jsdsi.Signature.create(Signature.java:157) > > > > at > > > jsdsi.Signature.create(Signature.java:109) > > > > > > Looks like the key you're passing to Signature are > > > of the wrong class. > > > Can you create a small program that throws this > > > exception? e.g., > > ; > create a key pair, then create a signature? > > > > > > S > > > > > > > > > > > Many Thanks, > > > > Somaya > > > > > > > > > > > > > > > > --- LuÃâ¢Ã s Pedro wrote: > > > > > > > > > Hello Somaya Aboulwafa, > > > > > > > > > > Could you send the Exception? > > > > > > > > > > Ãâû -----Original Message----- > > > > > Ãâû From: jsd...@li... > > > > > Ãâû > > > [mailto:jsd...@li...] > > > > > On Behalf Of > > > > > Ãâû Somaya Aboulwafa > > > > > Ãâû Sent: quinta-feira, 5 de Janeiro de 2006 7:32 > > > > > Ãâû To: jsd...@li... > > > > > Ãâû Cc: aj...@gm... > > > > > Ãâû Subject: [Jsdsi-users] KeyPai rs generated by > > > other > > > > > APIs ==> Exception > > > > > Ãâû > > > > > Ãâû Hi Sameer and everyone, > > > > > Ãâû> > > > Ãâû I'm using JSDSI with another framework (a > > > > > > Multiagent system > > > > > Ãâû framework). > > > > > Ãâû Agents in this framework have their own > > > KeyPairs. > > > > > Ãâû Whenever I try to use those KeyPairs to > > > create or > > > > > sign > > > > > Ãâû certificates using JSDSI I got an exception. > > > While > > > > > if I used > > > > > Ãâû JSDSI with KeyPairs generated by JSDSI I got > > > no > > > > > exceptions > > > > > Ãâû > > > > > Ãâû So, would you plz help me to figure out the > > > > > problem? > > > > > Ãâû > > > > > Ãâû Thanks in advance, > > > > > Ãâû Somaya > > > > > Ãâû > > > > > Ãâû > > > > > Ãâû > > > > > Ãâû > > > > > Ãâû __________________________________________ > > > > > Ãâû Yahoo! DSL âââ¬" Something to write home about. > > > > > Ãâû Just $16.99/mo. or less. > > > > > Ãâû dsl.yahoo.com > > > > > Ãâû > > > > > Ãâû > > > > > Ãâû > > > > > Ãâû > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > Ãâû This SF.net email is sponsored by: Splunk > > > Inc. Do > > > > > you grep > > > > > Ãâû through log files > > > > > Ãâû for problems? Stop! Download the new AJAX > > > search > > > > > engine that makes > > > > > Ãâû searching your log files as easy as surfing > > > the > > > > > web. > > > > > Ãâû DOWNLOAD SPLUNK! > > > > > Ãâû > > > > > > > > > > > >< BR>> > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click > > > > > > Ãâû > > > _______________________________________________ > > > > > Ãâû Jsdsi-users mailing list > > > > > Ãâû Jsd...@li... > > > > > Ãâû > > > > > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/jsdsi-users > > > > > > > > > > > > > > > > > > > > > > > > > > Ãâ¢Ã ÃËç Ãâ¢Ã¢â¬Â¦Ãâ¢Ã¢â¬ ÃËÃÂ¥ÃËðÃËç ÃËïÃËùÃâ¢Ãâ Ãâ¢Ã¢â¬ ÃËçÃâ¢Ã¢â¬Â¡ > Ãâ¢Ãâ ÃËìÃËïÃâ¢Ã¢â¬ ÃËçÃâ¢Ã¢â¬Â¡ > > > Ãâ¢Ã¢â¬Å¡ÃËñÃâ¢Ã ÃËè .. Ãâ¢Ã¢â¬ ÃËóÃËãÃâ¢Ã¢â¬Å¾Ãâ¢Ã' Ãâ¢Ã ÃËç ÃËçÃâ¢Ã¢â¬Å¾Ãâ¢Ã¢â¬Å¾Ãâ¢Ã¢â¬Â¡ > Ãâ¢Ã ÃËç Ãâ¢Ã¢â¬Â¦Ãâ¢Ã¢â¬Å¾ÃËçÃËð > > > Ãâ¢Ã'Ãâ¢Ã¢â¬Å¾ ÃËúÃËñÃâ¢Ã ÃËè .. ÃËãÃâ¢Ã¢â¬ ÃËêÃËñÃËòÃâ¢Ã¢â¬Å¡Ãâ¢Ã¢â¬ ÃËç > ÃËçÃâ¢Ã¢â¬Å¾ÃËíÃâ¢Ã ÃËçÃâ¢Ã¢â¬Â¡ > > > ÃËùÃâ¢Ã¢â¬Å¾Ãâ¢Ã¢â¬Â° ÃË(r)ÃË÷Ãâ¢Ã¢â¬Â° ÃËçÃâ¢Ã¢â¬Å¾ÃËíÃËèÃâ¢Ã ÃËè > > ; > > > > > > > > > > > > > > > > > > > > > > __________________________________________ > > > > Yahoo! DSL âââ¬" Something to write home about. > > > > Just $16.99/mo. or less. > > > > dsl.yahoo.com > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > This SF.net email is sponsored by: Splunk Inc. Do > > > you grep through log files > > > > for problems? Stop! Download the new AJAX search > > > engine that makes > > > > searching your log files as easy as surfing the > > > web. DOWNLOAD SPLUNK! > > > > > > > > > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click > > > > _______________________________________________ > > > > Jsdsi-users mailing list > > > > Jsd...@li... > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/jsdsi-users > > > > > > > > > > > > > > > > > -- > > > Sameer > > > http://ajmani.net > > > NìHYÞõÃ(c)à ¡à XÃ¬Ã²à ¡'òà Þuü'æ[çÃÂââ¬Â°ÃÅà 'èú > > > ÞæÃËkâè!ââ¬"Ãâ à Wì~à Ã(c)(r)â⬠ÃÂ¥zköà Cã > > > > > Ã¥áçmââ¬Â¦Ã(c)ÞÃâ¬@^Ãâ¡Ã ¡Ã­ÃË^à ¾Ã§zÃËZöfäzÃâ¹j÷!à > x2âêÃ¥ââââ¬Â¢Ã«Ã±Ã¦Ã¬Ãâ°Ã«,ÃºÃ·Ã¢à ¾ a{ââ¬Âº ÃÂ¥ÃÂ,à > HòÃ"4èmÃ¶à ¸Ã¿iÃâº(ñÃâ¢ÃÅâoÃÅ¡v'ïíûjYhr'Ãâï:æà > rXà "ÃÂââ¬ÂºÃ²+ìzû&j)bà ¾ > > > bòÃ'lvÃË(r)ñêÉâ¬"+-òÃÅ .íÃâ¡Ã ¸Ã¢Ã¸ÃÂëaöÃÅ¡lÿùbòÃâº,âêÃÅyú+ÃÂÃ(c)Þ÷ùbòÃâº?ââ¬"+-à > wèþ;ò+ìzû > > > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam protection around > > http://mail.yahoo.com > > > > > -- > Sameer > http://ajmani.net > > > > ________________________________ > Yahoo! Photos > Ring in the New Year with Photo Calendars. Add photos, events, holidays, > whatever.package credentials.version1_1; > > import java.security.KeyPair; > import java.security.PublicKey; > import java.security.cert.CertificateException; > > import jade.core.Agent; > import jade.core.security.SecurityHelper; > import jade.lang.acl.ACLMessage; > import jade.security.impl.JADEAuthorityImpl; > > import jsdsi.AuthCert; > import jsdsi.Certificate; > import jsdsi.Principal; > import jsdsi.StringTag; > import jsdsi.Subject; > import jsdsi.Tag; > import jsdsi.Validity; > import jsdsi.util.DateUtil; > import jsdsi.util.DigestAlgoEnum; > > /* This class for an agent is supposed to > * 1- retrieve it's keyPair > * 2- recieve the public key of the receiver agent > * 3- create a certificate and sign certificate where the subject is the > receiver agent and the signer is the current agent (My Agent) > */ > public class MyAgent extends Agent{ > > private SecurityHelper mySecurityHelper = null; > private JADEAuthorityImpl myAuthority=null; > private KeyPair myKeyPair=null; // The keyPair for the current agent (My > Agent) > private PublicKey pubKey=null; // public key of the reciever agent > > // The setup method is the first method to be executed when My Agent is > initially launched. > protected void setup(){ > System.out.println("Hello ! My Agent "+getAID().getName()+" is ready."); > > //Install the JSDSI provider .. I don't know whether is this the right place > for installing the provider or not! > jsdsi.Provider.install(); > > // Get the SecurityHelper; this is the object responsible for the security > service provided by the Jade framework > mySecurityHelper = (SecurityHelper)getHelper("jade.core.security.Security"); > > // Get the KeyPair > myAuthority= > (JADEAuthorityImpl)mySecurityHelper.getAuthority(); > myKeyPair=myAuthority.getKeyPair(); > > //Retieve the receiver agent's public key ; it is supposed that there is > another class for the reciever agent which sends its public key to this > class > //The public key is sent as a serializable object inside a message. > ACLMessage reply=receive(); > pubKey=(PublicKey)reply.getContentObject(); > > // Create and sign an Authorization crtificate > Certificate c=CreateCertificate(myKeyPair,pubKey); > } > > private Certificate CreateCertificate(KeyPair signer,PublicKey signee ){ > > Validity v = new Validity(DateUtil.newDate(), DateUtil.newDate(0,0,1)); > String dh = "plain"; > String c = "test certificate"; > Tag t = new StringTag("test"); > boolean p = false; > System.out.println("ya rab 2"); > > //Create and Sign the Certificate > //the exception occurs in this line > AuthCert cert = new AuthCert((Principal) signer.getPublic(), > (Subject)signee, v, dh, c, t, p); > > // if it use the following code instead, no exception is returned > /*KeyPair signer1=null,signee2=null; > try { > signer1 = KeyPairFactory.create(KeyEnum.RSA); > signee2 = KeyPairFactory.create(KeyEnum.RSA); > } catch (NoSuchAlgorithmException e1) { > e1.printStackTrace(); > } > > AuthCert cert = new AuthCert((Principal) signer1.getPublic(), > (Subject)signee2.getPublic(), v, dh, c, t, p); > */ > > // an exception also occurrs here > // however if i used signer1 instead of signer then no exception > jsdsi.Signature sig = jsdsi.Signature.create(signer, cert, > DigestAlgoEnum.SHA1); > > Certificate certificate=null; > try { > certificate = new Certificate(cert, sig); > } catch (CertificateException e) { > e.printStackTrace(); > } > > System.out.println(certificate.toString()); > return certificate; > } > > } > > > ________________________________ > Yahoo! Photos > Ring in the New Year with Photo Calendars. Add photos, events, holidays, > whatever. > > > > ________________________________ > Yahoo! Photos > Got holiday prints? See all the ways to get quality prints in your hands > ASAP. > > -- Sameer http://ajmani.net N¬HYÞµéX¬²'²Þu¼¦[§Ü¨º Þ¦Øk¢è!W¬~é®åzk¶C£ å¡§m éÞÀ@^Ç­È^§zØZ¶f¤zËj·!x2¢êå¢âë±æ¬É«,º·â a{ å,àHòÔ4¨m¶ÿiÛ(±ÙÜ¢oÚv'ï­ûjYhr'ׯ:ærX²+¬z»&j)b b²ÒlvÈ®±êì+-²Ê.­Ç¢¸ëa¶Úlÿùb²Û,¢êÜyú+éÞ·ùb²Û?+-wèþ;²+¬z» --------------------------------- Yahoo! Photos Showcase holiday pictures in hardcover Photo Books. You design it and well bind it! |