/// <summary>
/// Initializes a new instance of the CkTlsKdfParams class.
/// </summary>
/// <param name="prfMechanism">Hash mechanism used in the TLS 1.2 PRF construct or CKM_TLS_PRF to use with the TLS 1.0 and 1.1 PRF construct (CKM)</param>
/// <param name="label">Label for this key derivation</param>
/// <param name="randomInfo">Random data for the key derivation</param>
/// <param name="contextData">Context data for this key derivation</param>
public CkTlsKdfParams(NativeULong prfMechanism, byte[] label, CkSsl3RandomData randomInfo, byte[] contextData)
{
_lowLevelStruct.Label = IntPtr.Zero;
_lowLevelStruct.LabelLength = 0;
_lowLevelStruct.ContextData = IntPtr.Zero;
_lowLevelStruct.ContextDataLength = 0;
if (randomInfo == null)
{
throw new ArgumentNullException("randomInfo");
}
// Keep reference to randomInfo so GC will not free it while this object exists
_randomInfo = randomInfo;
_lowLevelStruct.PrfMechanism = prfMechanism;
if (label != null)
{
_lowLevelStruct.Label = UnmanagedMemory.Allocate(label.Length);
UnmanagedMemory.Write(_lowLevelStruct.Label, label);
_lowLevelStruct.LabelLength = NativeLongUtils.ConvertFromInt32(label.Length);
}
_lowLevelStruct.RandomInfo = (CK_SSL3_RANDOM_DATA)_randomInfo.ToMarshalableStructure();
if (contextData != null)
{
_lowLevelStruct.ContextData = UnmanagedMemory.Allocate(contextData.Length);
UnmanagedMemory.Write(_lowLevelStruct.ContextData, contextData);
_lowLevelStruct.ContextDataLength = NativeLongUtils.ConvertFromInt32(contextData.Length);
}
}