Java 类org.bouncycastle.asn1.x509.DSAParameter 实例源码

项目:ipack    文件:JDKDSAPublicKey.java   
public byte[] getEncoded()
{
    try
    {
        if (dsaSpec == null)
        {
            return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
        }

        return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:Aki-SSL    文件:JDKDSAPublicKey.java   
JDKDSAPublicKey(
    SubjectPublicKeyInfo    info)
{

    ASN1Integer              derY;

    try
    {
        derY = (ASN1Integer)info.parsePublicKey();
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("invalid info structure in DSA public key");
    }

    this.y = derY.getValue();

    if (isNotNull(info.getAlgorithm().getParameters()))
    {
        DSAParameter params = DSAParameter.getInstance(info.getAlgorithm().getParameters());

        this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
    }
}
项目:Aki-SSL    文件:JDKDSAPublicKey.java   
public byte[] getEncoded()
{
    try
    {
        if (dsaSpec == null)
        {
            return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y)).getEncoded(ASN1Encoding.DER);
        }

        return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new ASN1Integer(y)).getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:Aki-SSL    文件:BCDSAPublicKey.java   
public BCDSAPublicKey(
    SubjectPublicKeyInfo info)
{

    ASN1Integer              derY;

    try
    {
        derY = (ASN1Integer)info.parsePublicKey();
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("invalid info structure in DSA public key");
    }

    this.y = derY.getValue();

    if (isNotNull(info.getAlgorithm().getParameters()))
    {
        DSAParameter params = DSAParameter.getInstance(info.getAlgorithm().getParameters());

        this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
    }
}
项目:CryptMeme    文件:JDKDSAPublicKey.java   
public byte[] getEncoded()
{
    try
    {
        if (dsaSpec == null)
        {
            return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
        }

        return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:CryptMeme    文件:BCDSAPublicKey.java   
public BCDSAPublicKey(
    SubjectPublicKeyInfo info)
{

    ASN1Integer              derY;

    try
    {
        derY = (ASN1Integer)info.parsePublicKey();
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("invalid info structure in DSA public key");
    }

    this.y = derY.getValue();

    if (isNotNull(info.getAlgorithm().getParameters()))
    {
        DSAParameter params = DSAParameter.getInstance(info.getAlgorithm().getParameters());

        this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
    }
}
项目:irma_future_id    文件:JDKDSAPublicKey.java   
public byte[] getEncoded()
{
    try
    {
        if (dsaSpec == null)
        {
            return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
        }

        return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:irma_future_id    文件:BCDSAPublicKey.java   
public BCDSAPublicKey(
    SubjectPublicKeyInfo info)
{

    ASN1Integer              derY;

    try
    {
        derY = (ASN1Integer)info.parsePublicKey();
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("invalid info structure in DSA public key");
    }

    this.y = derY.getValue();

    if (isNotNull(info.getAlgorithm().getParameters()))
    {
        DSAParameter params = DSAParameter.getInstance(info.getAlgorithm().getParameters());

        this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
    }
}
项目:bc-java    文件:JDKDSAPublicKey.java   
public byte[] getEncoded()
{
    try
    {
        if (dsaSpec == null)
        {
            return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
        }

        return new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(y)).getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:bc-java    文件:BCDSAPublicKey.java   
public BCDSAPublicKey(
    SubjectPublicKeyInfo info)
{

    ASN1Integer              derY;

    try
    {
        derY = (ASN1Integer)info.parsePublicKey();
    }
    catch (IOException e)
    {
        throw new IllegalArgumentException("invalid info structure in DSA public key");
    }

    this.y = derY.getValue();

    if (isNotNull(info.getAlgorithm().getParameters()))
    {
        DSAParameter params = DSAParameter.getInstance(info.getAlgorithm().getParameters());

        this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
    }
}
项目:ipack    文件:JDKDSAPrivateKey.java   
JDKDSAPrivateKey(
    PrivateKeyInfo  info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    DERInteger      derX = ASN1Integer.getInstance(info.parsePrivateKey());

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:ipack    文件:JDKDSAPrivateKey.java   
/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
    try
    {
        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(getX()));

        return info.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:ipack    文件:BCDSAPublicKey.java   
public byte[] getEncoded()
{
    if (dsaSpec == null)
    {
        return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y));
    }

    return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(y));
}
项目:ipack    文件:AlgorithmParametersSpi.java   
/**
 * Return the X.509 ASN.1 structure DSAParameter.
 * <p/>
 * <pre>
 *  DSAParameter ::= SEQUENCE {
 *                   prime INTEGER, -- p
 *                   subprime INTEGER, -- q
 *                   base INTEGER, -- g}
 * </pre>
 */
protected byte[] engineGetEncoded()
{
    DSAParameter dsaP = new DSAParameter(currentSpec.getP(), currentSpec.getQ(), currentSpec.getG());

    try
    {
        return dsaP.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding DSAParameters");
    }
}
项目:ipack    文件:BCDSAPrivateKey.java   
public BCDSAPrivateKey(
    PrivateKeyInfo info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    ASN1Integer      derX = (ASN1Integer)info.parsePrivateKey();

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:Aki-SSL    文件:JDKDSAPrivateKey.java   
JDKDSAPrivateKey(
    PrivateKeyInfo  info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    ASN1Integer      derX = ASN1Integer.getInstance(info.parsePrivateKey());

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:Aki-SSL    文件:JDKDSAPrivateKey.java   
/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
    try
    {
        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new ASN1Integer(getX()));

        return info.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:Aki-SSL    文件:BCDSAPublicKey.java   
public byte[] getEncoded()
{
    if (dsaSpec == null)
    {
        return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y));
    }

    return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(y));
}
项目:Aki-SSL    文件:AlgorithmParametersSpi.java   
/**
 * Return the X.509 ASN.1 structure DSAParameter.
 * <pre>
 *  DSAParameter ::= SEQUENCE {
 *                   prime INTEGER, -- p
 *                   subprime INTEGER, -- q
 *                   base INTEGER, -- g}
 * </pre>
 */
protected byte[] engineGetEncoded()
{
    DSAParameter dsaP = new DSAParameter(currentSpec.getP(), currentSpec.getQ(), currentSpec.getG());

    try
    {
        return dsaP.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding DSAParameters");
    }
}
项目:Aki-SSL    文件:BCDSAPrivateKey.java   
public BCDSAPrivateKey(
    PrivateKeyInfo info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    ASN1Integer      derX = (ASN1Integer)info.parsePrivateKey();

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:CryptMeme    文件:JDKDSAPrivateKey.java   
JDKDSAPrivateKey(
    PrivateKeyInfo  info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    DERInteger      derX = ASN1Integer.getInstance(info.parsePrivateKey());

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:CryptMeme    文件:JDKDSAPrivateKey.java   
/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
    try
    {
        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(getX()));

        return info.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:CryptMeme    文件:BCDSAPublicKey.java   
public byte[] getEncoded()
{
    if (dsaSpec == null)
    {
        return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y));
    }

    return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(y));
}
项目:CryptMeme    文件:AlgorithmParametersSpi.java   
/**
 * Return the X.509 ASN.1 structure DSAParameter.
 * <p/>
 * <pre>
 *  DSAParameter ::= SEQUENCE {
 *                   prime INTEGER, -- p
 *                   subprime INTEGER, -- q
 *                   base INTEGER, -- g}
 * </pre>
 */
protected byte[] engineGetEncoded()
{
    DSAParameter dsaP = new DSAParameter(currentSpec.getP(), currentSpec.getQ(), currentSpec.getG());

    try
    {
        return dsaP.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding DSAParameters");
    }
}
项目:CryptMeme    文件:BCDSAPrivateKey.java   
public BCDSAPrivateKey(
    PrivateKeyInfo info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    ASN1Integer      derX = (ASN1Integer)info.parsePrivateKey();

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:hypersocket-framework    文件:X509CertificateUtils.java   
private static KeyPair loadKeyPair(PEMKeyPair privatekey)
        throws CertificateException {
    try {
        PEMKeyPair pair = (PEMKeyPair) privatekey;

        byte[] encodedPublicKey = pair.getPublicKeyInfo().getEncoded();
        byte[] encodedPrivateKey = pair.getPrivateKeyInfo().getEncoded();

        // Generate KeyPair.
        KeyFactory keyFactory = KeyFactory
                .getInstance(pair.getPublicKeyInfo().getAlgorithm()
                        .getParameters() instanceof DSAParameter ? "DSA"
                        : "RSA");

        X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(
                encodedPublicKey);
        PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);

        PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(
                encodedPrivateKey);
        PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);

        return new KeyPair(publicKey, privateKey);
    } catch (Exception e) {
        throw new CertificateException(
                "Failed to convert PEMKeyPair into JCE KeyPair", e);
    }
}
项目:irma_future_id    文件:JDKDSAPrivateKey.java   
JDKDSAPrivateKey(
    PrivateKeyInfo  info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    DERInteger      derX = ASN1Integer.getInstance(info.parsePrivateKey());

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:irma_future_id    文件:JDKDSAPrivateKey.java   
/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
    try
    {
        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(getX()));

        return info.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:irma_future_id    文件:BCDSAPublicKey.java   
public byte[] getEncoded()
{
    if (dsaSpec == null)
    {
        return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y));
    }

    return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(y));
}
项目:irma_future_id    文件:AlgorithmParametersSpi.java   
/**
 * Return the X.509 ASN.1 structure DSAParameter.
 * <p/>
 * <pre>
 *  DSAParameter ::= SEQUENCE {
 *                   prime INTEGER, -- p
 *                   subprime INTEGER, -- q
 *                   base INTEGER, -- g}
 * </pre>
 */
protected byte[] engineGetEncoded()
{
    DSAParameter dsaP = new DSAParameter(currentSpec.getP(), currentSpec.getQ(), currentSpec.getG());

    try
    {
        return dsaP.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding DSAParameters");
    }
}
项目:irma_future_id    文件:BCDSAPrivateKey.java   
public BCDSAPrivateKey(
    PrivateKeyInfo info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    ASN1Integer      derX = (ASN1Integer)info.parsePrivateKey();

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:bc-java    文件:JDKDSAPrivateKey.java   
JDKDSAPrivateKey(
    PrivateKeyInfo  info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    DERInteger      derX = ASN1Integer.getInstance(info.parsePrivateKey());

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:bc-java    文件:JDKDSAPrivateKey.java   
/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
    try
    {
        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG())), new DERInteger(getX()));

        return info.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        return null;
    }
}
项目:bc-java    文件:BCDSAPublicKey.java   
public byte[] getEncoded()
{
    if (dsaSpec == null)
    {
        return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa), new ASN1Integer(y));
    }

    return KeyUtil.getEncodedSubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(y));
}
项目:bc-java    文件:AlgorithmParametersSpi.java   
/**
 * Return the X.509 ASN.1 structure DSAParameter.
 * <p/>
 * <pre>
 *  DSAParameter ::= SEQUENCE {
 *                   prime INTEGER, -- p
 *                   subprime INTEGER, -- q
 *                   base INTEGER, -- g}
 * </pre>
 */
protected byte[] engineGetEncoded()
{
    DSAParameter dsaP = new DSAParameter(currentSpec.getP(), currentSpec.getQ(), currentSpec.getG());

    try
    {
        return dsaP.getEncoded(ASN1Encoding.DER);
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding DSAParameters");
    }
}
项目:bc-java    文件:BCDSAPrivateKey.java   
public BCDSAPrivateKey(
    PrivateKeyInfo info)
    throws IOException
{
    DSAParameter    params = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
    ASN1Integer      derX = (ASN1Integer)info.parsePrivateKey();

    this.x = derX.getValue();
    this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
}
项目:ipack    文件:BCDSAPrivateKey.java   
/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
    return KeyUtil.getEncodedPrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(getX()));
}
项目:Aki-SSL    文件:BCDSAPrivateKey.java   
/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
    return KeyUtil.getEncodedPrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(getX()));
}
项目:CryptMeme    文件:BCDSAPrivateKey.java   
/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
    return KeyUtil.getEncodedPrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(getX()));
}
项目:irma_future_id    文件:BCDSAPrivateKey.java   
/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 */
public byte[] getEncoded()
{
    return KeyUtil.getEncodedPrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).toASN1Primitive()), new ASN1Integer(getX()));
}