Re: reinitializing key object from encoded byte array

Jan Luehe (Jan.Luehe@Eng)
Wed, 2 Jul 1997 09:35:09 -0700 (PDT)

Date: Wed, 2 Jul 1997 09:35:09 -0700 (PDT)
From: Jan Luehe <Jan.Luehe@Eng>
Subject: Re: reinitializing key object from encoded byte array
To: java-security@web2.javasoft.com, dmiller@preEmptive.com

Dave:

> is it possible to create/reinitialize an object implementing
> the Key interface from a byte array generated using the
> getEncoded() method of that object? my question really is,
> if is use the getEncoded() method to store a PublicKey in
> a database as a byte array, would it be possible to read
> in that byte array from the database and initialize a
> Key object.

Currently, the Key interface does not offer support for this.
However, we have extended the "Key" interface in JDK1.2, to
provide support for what you (and many others) are asking for.

We have introduced new methods for exporting/importing keys
in various formats (ASN.1 encoded, raw, etc.).

> ...or would storage of a serialized key
> be more ideal? thanks for any help.

This would be an option, but it does not work in all
cases. One case where this might not work is when you unwrap
a (wrapped) session key which you received from another party.
Let's assume the session key was wrapped under your own public
key. Now you recover the session key using your own private key,
and use the recovered session key for decrpyting the data that
came with it. The unwrap operation would probably return the
session key as a byte array. This is where you would need
a key instantiation method as mentioned above (provided in JDK1.2).

Thanks,

Jan