Re: [Jsdsi-users] KeyPairs generated by other APIs ==> Exception
Status: Pre-Alpha
Brought to you by:
sajma
From: Somaya A. <som...@ya...> - 2006-01-15 14:59:18
|
Hi Sameer, Dont bother yourself with the code. Ill 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 <som...@ya...> 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 <aj...@gm...> 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! > > > > û > > > > > > > > > > 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õ隊X¬²š'²ŠÃu¼'¦[§Ââ°ÃŨº > > æÃk¢è!âËÅ W¬~Šé(r)â Ã¥zk¶ŠC£ > > > å¡§mâ¦Ã©ÃÃ@^Ú­Ã^ž§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ú+Âé÷ù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. |