@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class PKCS8EncryptionHandler extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static PKCS8PrivateKey |
decryptPrivateKey(byte[] encryptedPrivateKeyBytes,
char[] encryptionPassword)
Attempts to decrypt the provided data as a PKCS #8 private key.
|
static byte[] |
encryptPrivateKey(byte[] privateKeyBytes,
char[] encryptionPassword,
PKCS8EncryptionProperties encryptionProperties)
Encrypts the provided PKCS #8 private key using the provided settings.
|
static byte[] |
encryptPrivateKey(PKCS8PrivateKey privateKey,
char[] encryptionPassword,
PKCS8EncryptionProperties encryptionProperties)
Encrypts the provided PKCS #8 private key using the provided settings.
|
@NotNull public static byte[] encryptPrivateKey(@NotNull PKCS8PrivateKey privateKey, @NotNull char[] encryptionPassword, @NotNull PKCS8EncryptionProperties encryptionProperties) throws CertException
privateKey
- The private key to encrypt. It must not be
null
.encryptionPassword
- The password to use to generate the
encryption key. It must not be null
.encryptionProperties
- The properties to use when encrypting the
key. It must not be null
.CertException
- If a problem occurs while attempting to encrypt the
provided certificate with the given settings.@NotNull public static byte[] encryptPrivateKey(@NotNull byte[] privateKeyBytes, @NotNull char[] encryptionPassword, @NotNull PKCS8EncryptionProperties encryptionProperties) throws CertException
privateKeyBytes
- The bytes that comprise the private key to
encrypt. It must not be null
.encryptionPassword
- The password to use to generate the
encryption key. It must not be null
.encryptionProperties
- The properties to use when encrypting the
key. It must not be null
.CertException
- If a problem occurs while attempting to encrypt the
provided certificate with the given settings.@NotNull public static PKCS8PrivateKey decryptPrivateKey(@NotNull byte[] encryptedPrivateKeyBytes, @NotNull char[] encryptionPassword) throws CertException
encryptedPrivateKeyBytes
- The bytes that comprise the encrypted
representation of a PKCS #8 private key.
It must not be null
.encryptionPassword
- The password used to generate the
encryption key. It must not be
null
.CertException
- If a problem occurs while attempting to decrypt the
encrypted private key.