From: Edwin W. <ed...@wo...> - 2005-12-29 21:46:30
|
--On 29-12-2005 14:40 -0600 Robert Engels <re...@ix...> wrote: > > > Using getEncoded() on keys returned Cryptix KeyPair factory does not > work. > > The It throws a ClassNotFoundException looking for the MPIOutputStream > which is not included in the provider jar (the source is included in the > distribution though). That's a bug. Thanks, will fix it in the next release. > I think it is because the above code returns instances of > RSAPublicKeyCryptix rather than RSAPublicKeyImpl. > > Even if the class was encluded, it does not seem to be valid anyway, > since getEncoded() should probably write the key using the ASN format > always (at least according to the API). > > The "Sun" provider returns keys where getEncoded() returns the X509 > format. Well... If I remember correctly, the choice of the format was left up to the provider, but I see now that Sun is a bit more specific in recent API docs. (That said, I fail to see how their specification would work for ElGamal, or other public key schemes that are not that well specified in standards). I'm not too inclined to change it: IMHO, using getEncoded() is not a reliable way to get an encoded form. I'd suggest using the interfaces in java.security.interfaces: both the Cryptix and Sun keys implement the RSAPublicKey and RSAPrivate(Crt)Key interfaces. Should you need ASN.1 representations: these can be generated from the BigIntegers you can get from the methods from these interfaces. -- Edwin |