Net.Pkcs11Interop.HighLevelAPI81.MechanismParams.CkPkcs5Pbkd2Params.CkPkcs5Pbkd2Params C# (CSharp) Method

CkPkcs5Pbkd2Params() public method

Initializes a new instance of the CkPkcs5Pbkd2Params class.
public CkPkcs5Pbkd2Params ( ulong saltSource, byte saltSourceData, ulong iterations, ulong prf, byte prfData, byte password ) : System
saltSource ulong Source of the salt value (CKZ)
saltSourceData byte Data used as the input for the salt source
iterations ulong Number of iterations to perform when generating each block of random data
prf ulong Pseudo-random function to used to generate the key (CKP)
prfData byte Data used as the input for PRF in addition to the salt value
password byte Password to be used in the PBE key generation
return System
        public CkPkcs5Pbkd2Params(ulong saltSource, byte[] saltSourceData, ulong iterations, ulong prf, byte[] prfData, byte[] password)
        {
            _lowLevelStruct.SaltSource = 0;
            _lowLevelStruct.SaltSourceData = IntPtr.Zero;
            _lowLevelStruct.SaltSourceDataLen = 0;
            _lowLevelStruct.Iterations = 0;
            _lowLevelStruct.Prf = 0;
            _lowLevelStruct.PrfData = IntPtr.Zero;
            _lowLevelStruct.PrfDataLen = 0;
            _lowLevelStruct.Password = IntPtr.Zero;
            _lowLevelStruct.PasswordLen = IntPtr.Zero;

            _lowLevelStruct.SaltSource = saltSource;

            if (saltSourceData != null)
            {
                _lowLevelStruct.SaltSourceData = UnmanagedMemory.Allocate(saltSourceData.Length);
                UnmanagedMemory.Write(_lowLevelStruct.SaltSourceData, saltSourceData);
                _lowLevelStruct.SaltSourceDataLen = Convert.ToUInt64(saltSourceData.Length);
            }

            _lowLevelStruct.Iterations = iterations;

            _lowLevelStruct.Prf = prf;

            if (prfData != null)
            {
                _lowLevelStruct.PrfData = UnmanagedMemory.Allocate(prfData.Length);
                UnmanagedMemory.Write(_lowLevelStruct.PrfData, prfData);
                _lowLevelStruct.PrfDataLen = Convert.ToUInt64(prfData.Length);
            }

            if (password != null)
            {
                _lowLevelStruct.Password = UnmanagedMemory.Allocate(password.Length);
                UnmanagedMemory.Write(_lowLevelStruct.Password, password);

                ulong passwordLength = Convert.ToUInt32(password.Length);
                _lowLevelStruct.PasswordLen = UnmanagedMemory.Allocate(UnmanagedMemory.SizeOf(typeof(ulong)));
                UnmanagedMemory.Write(_lowLevelStruct.PasswordLen, BitConverter.GetBytes(passwordLength));
            }
        }