PKCS12Util (Bouncy Castle Library 1.52 API Specification)
Date: 2015-03-01

org.bouncycastle.jce

## Class PKCS12Util

- java.lang.Object
- - org.bouncycastle.jce.PKCS12Util

-     public class PKCS12Util
      extends java.lang.Object

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PKCS12Util()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `convertToDefiniteLength(byte[] berPKCS12File)` Just re-encode the outer layer of the PKCS#12 file to definite length encoding.
    `static byte[]` | `convertToDefiniteLength(byte[] berPKCS12File, char[] passwd, java.lang.String provider)` Re-encode the PKCS#12 structure to definite length encoding at the inner layer as well, recomputing the MAC accordingly.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PKCS12Util

          public PKCS12Util()

  - ### Method Detail

    - #### convertToDefiniteLength

          public static byte[] convertToDefiniteLength(byte[] berPKCS12File)
                                                throws java.io.IOException

      Just re-encode the outer layer of the PKCS#12 file to definite length encoding.
      Parameters:
        `berPKCS12File` - - original PKCS#12 file
      Returns:
        a byte array representing the DER encoding of the PFX structure
      Throws:
        `java.io.IOException`

    - #### convertToDefiniteLength

          public static byte[] convertToDefiniteLength(byte[] berPKCS12File,
                                       char[] passwd,
                                       java.lang.String provider)
                                                throws java.io.IOException

      Re-encode the PKCS#12 structure to definite length encoding at the inner layer as well, recomputing the MAC accordingly.
      Parameters:
        `berPKCS12File` - - original PKCS12 file.
        `provider` - - provider to use for MAC calculation.
      Returns:
        a byte array representing the DER encoding of the PFX structure.
      Throws:
        `java.io.IOException` - on parsing, encoding errors.