1/*
2 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package sun.security.provider;
27
28import java.math.BigInteger;
29import java.security.KeyRep;
30import java.security.InvalidKeyException;
31
32/**
33 * An X.509 public key for the Digital Signature Algorithm.
34 *
35 * The difference between DSAPublicKeyImpl and DSAPublicKey is that
36 * DSAPublicKeyImpl calls writeReplace with KeyRep, and DSAPublicKey
37 * calls writeObject.
38 *
39 * See the comments in DSAKeyFactory, 4532506, and 6232513.
40 *
41 */
42
43public final class DSAPublicKeyImpl extends DSAPublicKey {
44
45    private static final long serialVersionUID = 7819830118247182730L;
46
47    /**
48     * Make a DSA public key out of a public key and three parameters.
49     * The p, q, and g parameters may be null, but if so, parameters will need
50     * to be supplied from some other source before this key can be used in
51     * cryptographic operations.  PKIX RFC2459bis explicitly allows DSA public
52     * keys without parameters, where the parameters are provided in the
53     * issuer's DSA public key.
54     *
55     * @param y the actual key bits
56     * @param p DSA parameter p, may be null if all of p, q, and g are null.
57     * @param q DSA parameter q, may be null if all of p, q, and g are null.
58     * @param g DSA parameter g, may be null if all of p, q, and g are null.
59     */
60    public DSAPublicKeyImpl(BigInteger y, BigInteger p, BigInteger q,
61                        BigInteger g)
62                throws InvalidKeyException {
63        super(y, p, q, g);
64    }
65
66    /**
67     * Make a DSA public key from its DER encoding (X.509).
68     */
69    public DSAPublicKeyImpl(byte[] encoded) throws InvalidKeyException {
70        super(encoded);
71    }
72
73    protected Object writeReplace() throws java.io.ObjectStreamException {
74        return new KeyRep(KeyRep.Type.PUBLIC,
75                        getAlgorithm(),
76                        getFormat(),
77                        getEncoded());
78    }
79}
80