Class CryptoManager

    • Constructor Detail

      • CryptoManager

        public CryptoManager​(ServerContext serverContext,
                             CryptoManagerCfg config)
                      throws InitializationException
        Creates a new instance of this crypto manager object from a given configuration, plus some static member initialization.
        Parameters:
        serverContext - The server context.
        config - The configuration of this crypto manager.
        Throws:
        InitializationException - If a problem occurs while creating this CryptoManager that is not the result of a problem in the configuration.
    • Method Detail

      • encryptUsingReplicatedKey

        public byte[] encryptUsingReplicatedKey​(String cipherTransformation,
                                                int keyLengthBits,
                                                byte[] data)
                                         throws GeneralSecurityException,
                                                CryptoManagerException
        Encrypts the data in the provided byte array using the requested cipher algorithm.

        It should only be used when cipher keys are exchanged by replication of cn=admin data, such as reversible password storage schemes. All other uses of encryption should use CryptoManager.CipherService instead.

        Parameters:
        cipherTransformation - The algorithm/mode/padding to use for the cipher.
        keyLengthBits - The length in bits of the encryption key this method is to use. Note the specified key length and transformation must be compatible.
        data - The plain-text data to be encrypted.
        Returns:
        A byte array containing the encrypted representation of the provided data.
        Throws:
        GeneralSecurityException - If a problem occurs while encrypting the data.
        CryptoManagerException - If a problem occurs managing the encryption key or producing the cipher.
      • decryptUsingReplicatedKey

        public byte[] decryptUsingReplicatedKey​(byte[] data)
                                         throws GeneralSecurityException,
                                                CryptoManagerException
        Decrypts the data in the provided byte array using cipher specified by the key identifier prologue to the data. cipher.

        It should only be used when cipher keys are exchanged by replication of cn=admin data, such as reversible password storage schemes. All other uses of encryption should use CryptoManager.CipherService instead.

        Parameters:
        data - The cipher-text data to be decrypted.
        Returns:
        A byte array containing the clear-text representation of the provided data.
        Throws:
        GeneralSecurityException - If a problem occurs while encrypting the data.
        CryptoManagerException - If a problem occurs reading the key identifier or initialization vector from the data prologue, or using these values to initialize a Cipher.
      • getDeploymentPepper

        public byte[] getDeploymentPepper()
        Returns the secret deployment-wide pepper which can be used as additional salt when hashing passwords and other secrets.
        Returns:
        The secret deployment-wide pepper.