Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-04


oracle.security.crypto.core
Class PKCS12PBE

java.lang.Object
  extended by oracle.security.crypto.core.PBE
      extended by oracle.security.crypto.core.PKCS12PBE


public final class PKCS12PBE
extends PBE

Class to perform password-based encryption, as defined in the PKCS#12 specification.

Since:
3.0

Field Summary
static int SHA_128RC2_CBC
          The SHA1 with RC2 CBC 128 bits PKCS#12 mode.
static int SHA_128RC4
          The SHA1 with RC4 128 bits PKCS#12 mode.
static int SHA_2_3DES_CBC
          The SHA1 with Triple DES CBC 112 bits PKCS#12 mode.
static int SHA_3_3DES_CBC
          The SHA1 with Triple DES CBC 168 bits PKCS#12 mode.
static int SHA_40RC2_CBC
          The SHA1 with RC2 CBC 40 bits PKCS#12 mode.
static int SHA_40RC4
          The SHA1 with RC4 40 bits PKCS#12 mode.

 

Fields inherited from class oracle.security.crypto.core.PBE
algID, cipherAlgID, mdAlgID

 

Constructor Summary
PKCS12PBE()
          Standard contstructor.

 

Method Summary
static byte[] createPKCS12MacKey(AlgorithmIdentifier algID, java.lang.String password, byte[] salt, int iterationCount, int keyLength)
          Creates a PKCS#12 MAC key according to the PKCS#12 specifications.
 byte[] decrypt(java.lang.String password, byte[] data)
          Decrypt an array of bytes, and return the decrypted array of bytes.
 PrivateKey decryptPrivateKey(java.lang.String password, byte[] encPrivKey)
          Decrypt a private key, and return the decrypted key.
 SymmetricKey decryptSymmetricKey(java.lang.String password, byte[] encSymKey)
          Decrypt a symmetric key, and return the decrypted key.
 byte[] encrypt(java.lang.String password, byte[] data)
          Encrypt an array of bytes, and return the encrypted array of bytes.
 byte[] encryptPrivateKey(java.lang.String password, PrivateKey privKey)
          Encrypt a private key, and return the encrypted key.
 byte[] encryptSymmetricKey(java.lang.String password, SymmetricKey symKey)
          Encrypt a symmetric key, and return the encrypted key.
 void initialize(AlgorithmIdentifier algID)
          Initializes this PBE instance with the specified algorithm identifier.
 void initialize(int mode)
          Initializes this PBE instance with the specified PBE parameters.
 void initialize(int mode, byte[] salt, int iterationCount)
          Initializes this PBE instance with the specified PBE parameters.

 

Methods inherited from class oracle.security.crypto.core.PBE
getAlgID, getInstance

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

SHA_128RC4

public static final int SHA_128RC4
The SHA1 with RC4 128 bits PKCS#12 mode.
See Also:
Constant Field Values

SHA_40RC4

public static final int SHA_40RC4
The SHA1 with RC4 40 bits PKCS#12 mode.
See Also:
Constant Field Values

SHA_3_3DES_CBC

public static final int SHA_3_3DES_CBC
The SHA1 with Triple DES CBC 168 bits PKCS#12 mode.
See Also:
Constant Field Values

SHA_2_3DES_CBC

public static final int SHA_2_3DES_CBC
The SHA1 with Triple DES CBC 112 bits PKCS#12 mode.
See Also:
Constant Field Values

SHA_128RC2_CBC

public static final int SHA_128RC2_CBC
The SHA1 with RC2 CBC 128 bits PKCS#12 mode.
See Also:
Constant Field Values

SHA_40RC2_CBC

public static final int SHA_40RC2_CBC
The SHA1 with RC2 CBC 40 bits PKCS#12 mode.
See Also:
Constant Field Values

Constructor Detail

PKCS12PBE

public PKCS12PBE()
Standard contstructor.

Method Detail

initialize

public void initialize(AlgorithmIdentifier algID)
                throws AlgorithmIdentifierException
Initializes this PBE instance with the specified algorithm identifier.
Specified by:
initialize in class PBE
Parameters:
algID - The algorithm identifier used to initialize this PBE. It should be a instance of PBEAlgorithmIdentifier.
Throws:
AlgorithmIdentifierException

initialize

public void initialize(int mode,
                       byte[] salt,
                       int iterationCount)
                throws AlgorithmIdentifierException
Initializes this PBE instance with the specified PBE parameters.
Specified by:
initialize in class PBE
Parameters:
mode - The mode to use with this PBE. The mode is a PKCS12PBE mode value.
salt - The salt to use during the key generation.
iterationCount - The iteration count to use during the key generation.
Throws:
AlgorithmIdentifierException

initialize

public void initialize(int mode)
                throws AlgorithmIdentifierException
Initializes this PBE instance with the specified PBE parameters.
Specified by:
initialize in class PBE
Parameters:
mode - The mode to use with this PBE. The mode is a PKCS12PBE mode value.
Throws:
AlgorithmIdentifierException

encrypt

public byte[] encrypt(java.lang.String password,
                      byte[] data)
               throws CipherException
Encrypt an array of bytes, and return the encrypted array of bytes.
Specified by:
encrypt in class PBE
Parameters:
password - The password to use to generate the key.
data - The data to encrypt.
Returns:
The encrypted data.
Throws:
CipherException

decrypt

public byte[] decrypt(java.lang.String password,
                      byte[] data)
               throws CipherException
Decrypt an array of bytes, and return the decrypted array of bytes.
Specified by:
decrypt in class PBE
Parameters:
password - The password to use to generate the key.
data - The data to decrypt.
Returns:
The decrypted data.
Throws:
CipherException

encryptPrivateKey

public byte[] encryptPrivateKey(java.lang.String password,
                                PrivateKey privKey)
                         throws CipherException
Encrypt a private key, and return the encrypted key.
Specified by:
encryptPrivateKey in class PBE
Parameters:
password - The password to use to generate the key.
privKey - The private key to encrypt.
Returns:
A byte array containing the encrypted private key.
Throws:
CipherException

decryptPrivateKey

public PrivateKey decryptPrivateKey(java.lang.String password,
                                    byte[] encPrivKey)
                             throws CipherException,
                                    java.io.IOException
Decrypt a private key, and return the decrypted key.
Specified by:
decryptPrivateKey in class PBE
Parameters:
password - The password to use to generate the key.
encPrivKey - The byte array containing the encrypted private key.
Returns:
The decrypted private key.
Throws:
CipherException
java.io.IOException

encryptSymmetricKey

public byte[] encryptSymmetricKey(java.lang.String password,
                                  SymmetricKey symKey)
                           throws CipherException
Encrypt a symmetric key, and return the encrypted key.
Specified by:
encryptSymmetricKey in class PBE
Parameters:
password - The password to use to generate the key.
symKey - The symmetric key to encrypt.
Returns:
A byte array containing the encrypted symmetric key.
Throws:
CipherException

decryptSymmetricKey

public SymmetricKey decryptSymmetricKey(java.lang.String password,
                                        byte[] encSymKey)
                                 throws CipherException
Decrypt a symmetric key, and return the decrypted key.
Specified by:
decryptSymmetricKey in class PBE
Parameters:
password - The password to use to generate the key.
encSymKey - The byte array containing the encrypted symmetric key.
Returns:
The decrypted symmetric key.
Throws:
CipherException

createPKCS12MacKey

public static byte[] createPKCS12MacKey(AlgorithmIdentifier algID,
                                        java.lang.String password,
                                        byte[] salt,
                                        int iterationCount,
                                        int keyLength)
                                 throws CipherException
Creates a PKCS#12 MAC key according to the PKCS#12 specifications.
Parameters:
algID - The message digest algorithm identifier to use to generate the key. It is typically SHA1.
password - The password to use to generate the key.
salt - The salt value to use during the key generation.
iterationCount - The iteration count to use during the key generation.
keyLength - The length of the key material that will be returned,
Returns:
A byte array containing the PKCS#12 MAC key.
Throws:
CipherException

Skip navigation links

Oracle Fusion Middleware Crypto Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-04


Copyright © 2005, 2011 , Oracle. All rights reserved.