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

CkKipParams() public method

Initializes a new instance of the CkKipParams class.
public CkKipParams ( ulong mechanism, ObjectHandle key, byte seed ) : System
mechanism ulong Underlying cryptographic mechanism (CKM)
key ObjectHandle Handle to a key that will contribute to the entropy of the derived key (CKM_KIP_DERIVE) or will be used in the MAC operation (CKM_KIP_MAC)
seed byte Input seed
return System
        public CkKipParams(ulong? mechanism, ObjectHandle key, byte[] seed)
        {
            _lowLevelStruct.Mechanism = IntPtr.Zero;
            _lowLevelStruct.Key = 0;
            _lowLevelStruct.Seed = IntPtr.Zero;
            _lowLevelStruct.SeedLen = 0;

            if (mechanism != null)
            {
                byte[] bytes = ConvertUtils.ULongToBytes(mechanism.Value);
                _lowLevelStruct.Mechanism = UnmanagedMemory.Allocate(bytes.Length);
                UnmanagedMemory.Write(_lowLevelStruct.Mechanism, bytes);
            }

            if (key == null)
                throw new ArgumentNullException("key");
            
            _lowLevelStruct.Key = key.ObjectId;

            if (seed != null)
            {
                _lowLevelStruct.Seed = UnmanagedMemory.Allocate(seed.Length);
                UnmanagedMemory.Write(_lowLevelStruct.Seed, seed);
                _lowLevelStruct.SeedLen = Convert.ToUInt64(seed.Length);
            }
        }