% EncryptorWrapper - Wrapper around a parallel.internal.cluster.Encryptor
% which stores the session and salt information

% Copyright 2020 The MathWorks, Inc.

classdef EncryptorWrapper < handle
    
    properties (SetAccess = immutable)
        % Unique id for this session which is paired to the lifetime of the
        % corresponding decryptor on the job manager
        SessionID
        
        % Random byte array added to bytes to encrypt. Provided as is to
        % the corresponding decryptor.
        Salt
        
        % Type of Encryptor to create
        EncryptionAlgorithm
    end
    
    properties (SetAccess = immutable)       
        % Base encryptor
        Encryptor
    end
    
    methods
        function obj = EncryptorWrapper(encryptor, sessionID, salt, algorithm)
            obj.Encryptor = encryptor;
            obj.SessionID = sessionID;
            obj.Salt = salt;
            obj.EncryptionAlgorithm = algorithm;
        end
        
        function encryptedBytes = encrypt(obj, bytes)
            encryptedBytes = obj.Encryptor.encrypt(bytes); 
        end
    end
end

