Example usage for org.bouncycastle.jcajce.provider.asymmetric.util KeyUtil getEncodedPrivateKeyInfo

List of usage examples for org.bouncycastle.jcajce.provider.asymmetric.util KeyUtil getEncodedPrivateKeyInfo

Introduction

In this page you can find the example usage for org.bouncycastle.jcajce.provider.asymmetric.util KeyUtil getEncodedPrivateKeyInfo.

Prototype

public static byte[] getEncodedPrivateKeyInfo(AlgorithmIdentifier algId, ASN1Encodable privKey) 

Source Link

Usage

From source file:org.xipki.security.bcext.BCRSAPrivateCrtKey.java

License:Open Source License

/**
 * Return a PKCS8 representation of the key. The sequence returned
 * represents a full PrivateKeyInfo object.
 *
 * @return a PKCS8 representation of the key.
 *///from   ww  w  .j av a 2 s  .  com
public byte[] getEncoded() {
    AlgorithmIdentifier algId = new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE);
    RSAPrivateKey key = new RSAPrivateKey(getModulus(), getPublicExponent(), getPrivateExponent(), getPrimeP(),
            getPrimeQ(), getPrimeExponentP(), getPrimeExponentQ(), getCrtCoefficient());
    return KeyUtil.getEncodedPrivateKeyInfo(algId, key);
}

From source file:org.xipki.security.bcext.BCRSAPrivateKey.java

License:Open Source License

public byte[] getEncoded() {
    return KeyUtil.getEncodedPrivateKeyInfo(
            new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE),
            new org.bouncycastle.asn1.pkcs.RSAPrivateKey(getModulus(), ZERO, getPrivateExponent(), ZERO, ZERO,
                    ZERO, ZERO, ZERO));//from ww  w . j av a2s  .co  m
}