• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Construct a public key from raw bytes?

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I receieve an RSA Key in raw bytes off the wire. It's a public key which will be used later to trade private keys. I need to construct a Key object from these raw bytes. I"m just now learning how to use the javax.crypto libraries (and BouncingCastle as a provider) and don't see how to generate a key when you already have its raw bytes.

Any help is appreciated...
 
Tom Katz
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see a constructor for RSAPublicKeySpec that takes a byte array - which I think is getting closer to what I need to do. Maybe I'm on the wrong track, but I see CTORs for DSE keys that accept raw bytes.
 
Tom Katz
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aha! Turns out the raw bytes contain the modulo and exponent needed in order to create the RSA Key. It helps to read documentation!
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you public key is output format is X.509 , you can use X509EncodedKeySpec to get it back. Just curious , I am wondering why what you got is an public key other than a certification :-) ?

Lin
 
Tom Katz
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the encryption setup had already been worked out a couple years ago, using only C/C++ code. I'm the first one to be writing a java client that will integrate the current encryption setup. Dont know if that answers your question.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic