Package org.xwiki.crypto.password
Interface PrivateKeyPasswordBasedEncryptor
-
@Role public interface PrivateKeyPasswordBasedEncryptor
Manage encryption of private keys using password based ciphers as defined in PKCS #8.- Since:
- 5.4RC1
- Version:
- $Id: ed7c544be6fc8bdad9f908c9a1a363f373d05e6c $
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PrivateKeyParameters
decrypt(byte[] password, byte[] encoded)
Decrypt a private key from an encoded byte array.PrivateKeyParameters
decrypt(byte[] password, EncryptedPrivateKeyInfo privateKeyInfo)
Decrypt a private key from anEncryptedPrivateKeyInfo
.byte[]
encrypt(byte[] password, PrivateKeyParameters privateKey)
Encrypt a private key using a AES 256 password based cipher in a PKCS #8 format.byte[]
encrypt(String algHint, byte[] password, byte[] encoded, PrivateKeyParameters privateKey)
Encrypt a private key using a password based cipher in a PKCS #8 format.byte[]
encrypt(String algHint, byte[] password, KeyDerivationFunctionParameters kdfParameters, PrivateKeyParameters privateKey)
Encrypt a private key in a PKCS #8 format using a random initialization vector.byte[]
encrypt(String algHint, SymmetricCipherParameters password, KeyDerivationFunction function, PrivateKeyParameters privateKey)
Encrypt a private key using a password based cipher in a PKCS #8 format.byte[]
encrypt(String algHint, SymmetricCipherParameters password, KeyDerivationFunctionParameters kdfParameters, PrivateKeyParameters privateKey)
Encrypt a private key using a password based cipher in a PKCS #8 format.byte[]
encrypt(PasswordBasedCipher cipher, PrivateKeyParameters privateKey)
Encrypt a private key using a password based cipher in a PKCS #8 format.
-
-
-
Method Detail
-
decrypt
PrivateKeyParameters decrypt(byte[] password, byte[] encoded) throws GeneralSecurityException, IOException
Decrypt a private key from an encoded byte array.- Parameters:
password
- the password used to derive the encryption key.encoded
- the encrypted key in ASN.1 format according to PKCS #8.- Returns:
- decrypted private key parameters.
- Throws:
GeneralSecurityException
- if an error occurs during decryption.IOException
- if an error occurs during decoding.
-
decrypt
PrivateKeyParameters decrypt(byte[] password, EncryptedPrivateKeyInfo privateKeyInfo) throws GeneralSecurityException, IOException
Decrypt a private key from anEncryptedPrivateKeyInfo
.- Parameters:
password
- the password used to derive the encryption key.privateKeyInfo
- the encrypted private key information.- Returns:
- decrypted private key parameters.
- Throws:
GeneralSecurityException
- if an error occurs during decryption.IOException
- if an error occurs during decoding.
-
encrypt
byte[] encrypt(String algHint, SymmetricCipherParameters password, KeyDerivationFunctionParameters kdfParameters, PrivateKeyParameters privateKey) throws GeneralSecurityException, IOException
Encrypt a private key using a password based cipher in a PKCS #8 format.- Parameters:
algHint
- the hint of the PasswordBasedCipher to use.password
- cipher parameters, using a password converted to bytes for the key.kdfParameters
- the parameters of the derivation function.privateKey
- the private key parameters to encrypt.- Returns:
- the encrypted key in ASN.1 format according to PKCS #8.
- Throws:
GeneralSecurityException
- if an error occurs during encryption.IOException
- if an error occurs during encoding.
-
encrypt
byte[] encrypt(String algHint, SymmetricCipherParameters password, KeyDerivationFunction function, PrivateKeyParameters privateKey) throws GeneralSecurityException, IOException
Encrypt a private key using a password based cipher in a PKCS #8 format.- Parameters:
algHint
- the hint of the PasswordBasedCipher to use.password
- cipher parameters, using a password converted to bytes for the key.function
- the key derivation function to use for deriving key from password.privateKey
- cipher parameters, using a password converted to bytes for the key.- Returns:
- the encrypted key in ASN.1 format according to PKCS #8.
- Throws:
GeneralSecurityException
- if an error occurs during encryption.IOException
- if an error occurs during encoding.
-
encrypt
byte[] encrypt(String algHint, byte[] password, byte[] encoded, PrivateKeyParameters privateKey) throws GeneralSecurityException, IOException
Encrypt a private key using a password based cipher in a PKCS #8 format.- Parameters:
algHint
- the hint of the PasswordBasedCipher to use.password
- the password used to derive the encryption key.encoded
- encoded parameters to initialize the cipher and derivation function.privateKey
- the private key parameters to encrypt.- Returns:
- the encrypted key in ASN.1 format according to PKCS #8.
- Throws:
GeneralSecurityException
- if an error occurs during encryption.IOException
- if an error occurs during encoding.
-
encrypt
byte[] encrypt(byte[] password, PrivateKeyParameters privateKey) throws GeneralSecurityException, IOException
Encrypt a private key using a AES 256 password based cipher in a PKCS #8 format.- Parameters:
password
- the password used to derive the encryption key.privateKey
- the private key parameters to encrypt.- Returns:
- the encrypted key in ASN.1 format according to PKCS #8.
- Throws:
GeneralSecurityException
- if an error occurs during encryption.IOException
- if an error occurs during encoding.
-
encrypt
byte[] encrypt(PasswordBasedCipher cipher, PrivateKeyParameters privateKey) throws IOException, GeneralSecurityException
Encrypt a private key using a password based cipher in a PKCS #8 format.- Parameters:
cipher
- the initialized PasswordBasedCipher to use.privateKey
- the private key parameters to encrypt.- Returns:
- the encrypted key in ASN.1 format according to PKCS #8.
- Throws:
GeneralSecurityException
- if an error occurs during encryption.IOException
- if an error occurs during encoding.
-
encrypt
byte[] encrypt(String algHint, byte[] password, KeyDerivationFunctionParameters kdfParameters, PrivateKeyParameters privateKey) throws IOException, GeneralSecurityException
Encrypt a private key in a PKCS #8 format using a random initialization vector.- Parameters:
algHint
- the hint of the PasswordBasedCipher to use.password
- the password used to derive the encryption key.kdfParameters
- the parameters of the derivation function.privateKey
- the private key parameters to encrypt.- Returns:
- the encrypted key in ASN.1 format according to PKCS #8.
- Throws:
GeneralSecurityException
- if an error occurs during encryption.IOException
- if an error occurs during encoding.
-
-