HELP!!! PublicKey refuses to regenerate
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Syed_Rahman
Posted On:   Sunday, October 7, 2001 03:36 PM

Hi, I have an interesting problem which might interest you. We know PublicKey can be encoded into byte-array by using "getEncoded()" method. In my case I found that array size required to store my encoded PublicKey is 444. Using objectOutputStream's "writebyte(int)" I transferred the byte array into a floppy . I found that I could regenerate the PublicKey by reading back the encoded byte-array using ObjectInputStream's "readByte()" method and then using the following snippets the Public key is regenerated.(where pub is the byte-array i.e byte[] pub=new byte[444]; containing the encoded bytes)    More>>


Hi,


I have an interesting problem which might interest you.


We know PublicKey can be encoded into byte-array by using "getEncoded()" method. In my case I found that array size required to store my encoded PublicKey is 444.


Using objectOutputStream's "writebyte(int)" I transferred the byte array into a floppy .


I found that I could regenerate the PublicKey by reading back the encoded byte-array using ObjectInputStream's "readByte()" method and then using the following snippets the Public key is regenerated.(where pub is the byte-array i.e
byte[] pub=new byte[444]; containing the encoded bytes)


X509EncodedKeySpec b = new X509EncodedKeySpec(pub);
KeyFactory kf = KeyFactory.getInstance("DSA");
PublicKey j = kf.generatePublic(b);

This has been performing nicely without any problems.


Now I have burned the 444 bytes into an EEPROM . Though the exact data bytes are read back by the program from the EEPROM, I get the following error message:-


java.security.spec.InvalidKeySpecException: Inappropriate key specification: IOE
xception: DerInputStream.getLength(): lengthTag=95, too big.
at sun.security.provider.DSAKeyFactory.engineGeneratePublic(DSAKeyFactor
y.java:74)
at java.security.KeyFactory.generatePublic(KeyFactory.java:184)
at Advanced_server_frm_eeprom.main(Compiled Code)

Can you give me any suggestions to overcome the problem. Since I have succeeded with Floppy I believe it is possible with EEPROm, just another memory element. It must be just a simple problem which I fail to see and may be, some expert will spot.


Thanking you.


With regards.


Syed Miftahur Rahman.(India).

   <<Less
About | Sitemap | Contact