diff options
Diffstat (limited to 'pki/base/util/src/netscape/security/provider/DSAPublicKey.java')
-rw-r--r-- | pki/base/util/src/netscape/security/provider/DSAPublicKey.java | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/pki/base/util/src/netscape/security/provider/DSAPublicKey.java b/pki/base/util/src/netscape/security/provider/DSAPublicKey.java index c3a6896ce..89262809b 100644 --- a/pki/base/util/src/netscape/security/provider/DSAPublicKey.java +++ b/pki/base/util/src/netscape/security/provider/DSAPublicKey.java @@ -34,18 +34,18 @@ import netscape.security.x509.X509Key; /** * An X.509 public key for the Digital Signature Algorithm. - * - * @author Benjamin Renaud - * + * + * @author Benjamin Renaud + * * @version 1.52, 97/12/10 - * + * * @see DSAPrivateKey * @see AlgIdDSA * @see DSA */ -public final class DSAPublicKey extends X509Key -implements java.security.interfaces.DSAPublicKey, Serializable { +public final class DSAPublicKey extends X509Key + implements java.security.interfaces.DSAPublicKey, Serializable { /** use serialVersionUID from JDK 1.1. for interoperability */ private static final long serialVersionUID = -2994193307391104133L; @@ -63,26 +63,26 @@ implements java.security.interfaces.DSAPublicKey, Serializable { * Make a DSA public key out of a public key and three parameters. */ public DSAPublicKey(BigInteger y, BigInteger p, BigInteger q, - BigInteger g) - throws InvalidKeyException { - this.y = y; - algid = new AlgIdDSA(p, q, g); + BigInteger g) + throws InvalidKeyException { + this.y = y; + algid = new AlgIdDSA(p, q, g); - try { - key = new DerValue(DerValue.tag_Integer, - y.toByteArray()).toByteArray(); - encode(); - } catch (IOException e) { - throw new InvalidKeyException("could not DER encode y: " + - e.getMessage()); - } + try { + key = new DerValue(DerValue.tag_Integer, + y.toByteArray()).toByteArray(); + encode(); + } catch (IOException e) { + throw new InvalidKeyException("could not DER encode y: " + + e.getMessage()); + } } /** * Make a DSA public key from its DER encoding (X.509). */ public DSAPublicKey(byte[] encoded) throws InvalidKeyException { - decode(encoded); + decode(encoded); } /** @@ -90,44 +90,44 @@ implements java.security.interfaces.DSAPublicKey, Serializable { * parameters could not be parsed. */ public DSAParams getParams() { - try { - if (algid instanceof DSAParams) { - return (DSAParams)algid; - } else { - DSAParameterSpec paramSpec; - AlgorithmParameters algParams = algid.getParameters(); - if (algParams == null) { - return null; - } - paramSpec = (DSAParameterSpec)algParams.getParameterSpec - (DSAParameterSpec.class); - return (DSAParams)paramSpec; - } - } catch (InvalidParameterSpecException e) { - return null; - } + try { + if (algid instanceof DSAParams) { + return (DSAParams) algid; + } else { + DSAParameterSpec paramSpec; + AlgorithmParameters algParams = algid.getParameters(); + if (algParams == null) { + return null; + } + paramSpec = (DSAParameterSpec) algParams.getParameterSpec + (DSAParameterSpec.class); + return (DSAParams) paramSpec; + } + } catch (InvalidParameterSpecException e) { + return null; + } } - + /** * Get the raw public value, y, without the parameters. - * + * */ public BigInteger getY() { - return y; + return y; } public String toString() { return "Sun DSA Public Key\n Parameters:" + algid - + "\n y:\n" + (new BigInt(y)).toString() + "\n"; + + "\n y:\n" + (new BigInt(y)).toString() + "\n"; } protected void parseKeyBits() throws InvalidKeyException { - try { - DerInputStream in = new DerInputStream(key); - y = in.getInteger().toBigInteger(); - } catch (IOException e) { - throw new InvalidKeyException("Invalid key: y value\n" + - e.getMessage()); - } + try { + DerInputStream in = new DerInputStream(key); + y = in.getInteger().toBigInteger(); + } catch (IOException e) { + throw new InvalidKeyException("Invalid key: y value\n" + + e.getMessage()); + } } } |