Top Description Constructors Methods
org.bouncycastle.jce

public Class PKCS12Util

extends Object
Class Inheritance
Imports
java.io.IOException, javax.crypto.Mac, .SecretKey, .SecretKeyFactory, javax.crypto.spec.PBEKeySpec, .PBEParameterSpec, org.bouncycastle.asn1.ASN1Encoding, .ASN1ObjectIdentifier, .ASN1OctetString, .ASN1Primitive, .DERNull, .DEROctetString, org.bouncycastle.asn1.pkcs.ContentInfo, .MacData, .Pfx, org.bouncycastle.asn1.x509.AlgorithmIdentifier, .DigestInfo

Utility class for reencoding PKCS#12 files to definite length.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static byte[]
calculatePbeMac(ASN1ObjectIdentifier oid, byte[] salt, int itCount, char[] password, byte[] data, String provider)

public static byte[]

Returns:

a byte array representing the DER encoding of the PFX structure
convertToDefiniteLength
(byte[]
- original PKCS#12 file
berPKCS12File
)

Just re-encode the outer layer of the PKCS#12 file to definite length encoding.

public static byte[]

Returns:

a byte array representing the DER encoding of the PFX structure.
convertToDefiniteLength
(byte[]
- original PKCS12 file.
berPKCS12File
,
char[] passwd, String
- provider to use for MAC calculation.
provider
)

Re-encode the PKCS#12 structure to definite length encoding at the inner layer as well, recomputing the MAC accordingly.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

PKCS12Utilback to summary
public PKCS12Util()

Method Detail

calculatePbeMacback to summary
private static byte[] calculatePbeMac(ASN1ObjectIdentifier oid, byte[] salt, int itCount, char[] password, byte[] data, String provider) throws Exception
convertToDefiniteLengthback to summary
public static byte[] convertToDefiniteLength(byte[] berPKCS12File) throws IOException

Just re-encode the outer layer of the PKCS#12 file to definite length encoding.

Parameters
berPKCS12File:byte[]

- original PKCS#12 file

Returns:byte[]

a byte array representing the DER encoding of the PFX structure

convertToDefiniteLengthback to summary
public static byte[] convertToDefiniteLength(byte[] berPKCS12File, char[] passwd, String provider) throws IOException

Re-encode the PKCS#12 structure to definite length encoding at the inner layer as well, recomputing the MAC accordingly.

Parameters
berPKCS12File:byte[]

- original PKCS12 file.

provider:String

- provider to use for MAC calculation.

Returns:byte[]

a byte array representing the DER encoding of the PFX structure.

Exceptions
IOException:
on parsing, encoding errors.