Thread: [Jsdsi-users] KeyPair
Status: Pre-Alpha
Brought to you by:
sajma
From: <mar...@or...> - 2004-08-11 18:16:17
|
Hi I will save and load a KeyPair, but i can't it. I trying with this: KeyPair gk = jsdsi.util.KeyPairFactory.create("RSA",2048); FileOutputStream fos = new FileOutputStream("gk.pub"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(gk.toString()); oos.close(); How can't I load this object and retype in a KeyPair? This code don't work: KeyPair gk; FileInputStream fos = new FileInputStream("gk.pub"); ObjectInputStream oos = new ObjectInputStream(fos); gk = (KeyPair) oos.readObject(); oos.close(); Thanx. Marek Lany |
From: Luis P. <lp...@ne...> - 2004-08-11 19:22:15
|
Marek, It help if u send the exact error. But try this: - If the error is "SPKI not found", then u have to load jsdsi provider, i.e, jsdsi.Provider.install() and cryptix provider. But, if your problem is a ClassCastException then u have an error on = your code and u should change this(following your code): java.security.KeyPair gk =3D jsdsi.util.KeyPairFactory.create("RSA", 2048); java.io.FileOutputStream fos =3D new java.io.FileOutputStream("gde/tests/test.pub"); java.io.ObjectOutputStream oos =3D new java.io.ObjectOutputStream(fos); // I have changed things here, tooked "toString()"=09 oos.writeObject(gk); // Doesn't make sense writing an object like gk.toString()!! // writeObject serializes the object. U can't cast from "String" to "KeyPair"=20 oos.close(); java.security.KeyPair gk; java.io.FileInputStream fos =3D new java.io.FileInputStream("gde/tests/test.pub"); java.io.ObjectInputStream oos =3D new java.io.ObjectInputStream(fos); gk =3D (java.security.KeyPair)oos.readObject(); oos.close(); =09 -- Lu=EDs Pedro _____________________ yahoo: lpv_pt msn: lp...@ne... =20 =BB -----Original Message----- =BB From: jsd...@li...=20 =BB [mailto:jsd...@li...] On=20 =BB Behalf Of Marek L=E1ny =BB Sent: quarta-feira, 11 de Agosto de 2004 19:16 =BB To: jsd...@li... =BB Subject: [Jsdsi-users] KeyPair =BB =20 =BB Hi =BB =20 =BB I will save and load a KeyPair, but i can't it. I trying=20 =BB with this: =BB KeyPair gk =3D = jsdsi.util.KeyPairFactory.create("RSA",2048); =BB FileOutputStream fos =3D new FileOutputStream("gk.pub"); =BB ObjectOutputStream oos =3D new ObjectOutputStream(fos); =BB oos.writeObject(gk.toString()); =BB oos.close(); =BB =20 =BB How can't I load this object and retype in a KeyPair?=20 =BB This code don't =BB work: =BB =20 =BB KeyPair gk; =BB FileInputStream fos =3D new FileInputStream("gk.pub"); =BB ObjectInputStream oos =3D new ObjectInputStream(fos); =BB gk =3D (KeyPair) oos.readObject(); =BB oos.close(); =BB =20 =BB Thanx. =BB =20 =BB Marek Lany =BB =20 =BB =20 =BB =20 =BB ------------------------------------------------------- =BB SF.Net email is sponsored by Shop4tech.com-Lowest price=20 =BB on Blank Media =BB 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only = $33 =BB Save 50% off Retail on Ink & Toner - Free Shipping and Free = Gift. =BB http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 =BB _______________________________________________ =BB Jsdsi-users mailing list =BB Jsd...@li... =BB https://lists.sourceforge.net/lists/listinfo/jsdsi-users |
From: Sean R. <sra...@ae...> - 2004-08-12 10:32:30
|
Luis Pedro wrote: >Marek, > >It help if u send the exact error. But try this: > - If the error is "SPKI not found", then u have to load jsdsi >provider, i.e, jsdsi.Provider.install() and cryptix provider. > >But, if your problem is a ClassCastException then u have an error on your >code and u should change this(following your code): > > java.security.KeyPair gk = jsdsi.util.KeyPairFactory.create("RSA", >2048); > java.io.FileOutputStream fos = new >java.io.FileOutputStream("gde/tests/test.pub"); > java.io.ObjectOutputStream oos = new >java.io.ObjectOutputStream(fos); >// I have changed things here, tooked "toString()" > oos.writeObject(gk); >// Doesn't make sense writing an object like gk.toString()!! >// writeObject serializes the object. U can't cast from "String" to >"KeyPair" > oos.close(); > > java.security.KeyPair gk; > java.io.FileInputStream fos = new >java.io.FileInputStream("gde/tests/test.pub"); > java.io.ObjectInputStream oos = new java.io.ObjectInputStream(fos); > gk = (java.security.KeyPair)oos.readObject(); > oos.close(); > > -- Luís Pedro > > >_____________________ >yahoo: lpv_pt > msn: lp...@ne... > > > >» -----Original Message----- >» From: jsd...@li... >» [mailto:jsd...@li...] On >» Behalf Of Marek Lány >» Sent: quarta-feira, 11 de Agosto de 2004 19:16 >» To: jsd...@li... >» Subject: [Jsdsi-users] KeyPair >» >» Hi >» >» I will save and load a KeyPair, but i can't it. I trying >» with this: >» KeyPair gk = jsdsi.util.KeyPairFactory.create("RSA",2048); >» FileOutputStream fos = new FileOutputStream("gk.pub"); >» ObjectOutputStream oos = new ObjectOutputStream(fos); >» oos.writeObject(gk.toString()); >» oos.close(); >» >» How can't I load this object and retype in a KeyPair? >» This code don't >» work: >» >» KeyPair gk; >» FileInputStream fos = new FileInputStream("gk.pub"); >» ObjectInputStream oos = new ObjectInputStream(fos); >» gk = (KeyPair) oos.readObject(); >» oos.close(); >» >» Thanx. >» >» Marek Lany >» >» >» >» ------------------------------------------------------- >» SF.Net email is sponsored by Shop4tech.com-Lowest price >» on Blank Media >» 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 >» Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. >» http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 >» _______________________________________________ >» Jsdsi-users mailing list >» Jsd...@li... >» https://lists.sourceforge.net/lists/listinfo/jsdsi-users > > > >------------------------------------------------------- >SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media >100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 >Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. >http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 >_______________________________________________ >Jsdsi-users mailing list >Jsd...@li... >https://lists.sourceforge.net/lists/listinfo/jsdsi-users > > > > Marek, did Luis help you out? An alternative is to use jsdsi.sexp.ObjOutputStream and jsdsi.sexp.ObjInputStream instead of the java.io.ObjectXxxStream classes though both approaches should work (with Luis's suggestions). Sean -- Dr. Sean Radford, MBBS, MSc sra...@ae... http://www.aegeus-technology.com/ |