Example usage for org.bouncycastle.asn1.pkcs DHParameter getEncoded

List of usage examples for org.bouncycastle.asn1.pkcs DHParameter getEncoded

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.pkcs DHParameter getEncoded.

Prototype

public byte[] getEncoded(String encoding) throws IOException 

Source Link

Document

Return either the default for "BER" or a DER encoding if "DER" is specified.

Usage

From source file:org.dcache.xrootd.plugins.authn.gsi.DHSession.java

License:Open Source License

/**
 * Creates an DER-encoded byte sequence from the DHParameter object
 * @param paramspec the DH parameter object
 * @return the DER-encoded byte sequence of the DH Parameter object
 *///  w ww . j  av a 2 s.c  om
private static byte[] toDER(DHParameterSpec paramspec) throws IOException {
    DHParameter derParams = new DHParameter(paramspec.getP(), // Prime
            // (public
            // key)
            paramspec.getG(), // generator
            paramspec.getP().bitLength()); // keylength of Prime

    return derParams.getEncoded("DER");
}