Beispiel #1
0
        /// <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(ulong prfMechanism, byte[] label, CkSsl3RandomData randomInfo, byte[] contextData)
        {
            if (randomInfo == null)
            {
                throw new ArgumentNullException("randomInfo");
            }

            // Keep reference to randomInfo so GC will not free it while this object exists
            _randomInfo = randomInfo;

            if (Platform.UnmanagedLongSize == 4)
            {
                if (Platform.StructPackingSize == 0)
                {
                    _params40 = new HighLevelAPI40.MechanismParams.CkTlsKdfParams(Convert.ToUInt32(prfMechanism), label, _randomInfo._params40, contextData);
                }
                else
                {
                    _params41 = new HighLevelAPI41.MechanismParams.CkTlsKdfParams(Convert.ToUInt32(prfMechanism), label, _randomInfo._params41, contextData);
                }
            }
            else
            {
                if (Platform.StructPackingSize == 0)
                {
                    _params80 = new HighLevelAPI80.MechanismParams.CkTlsKdfParams(prfMechanism, label, _randomInfo._params80, contextData);
                }
                else
                {
                    _params81 = new HighLevelAPI81.MechanismParams.CkTlsKdfParams(prfMechanism, label, _randomInfo._params81, contextData);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Disposes object
        /// </summary>
        /// <param name="disposing">Flag indicating whether managed resources should be disposed</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!this._disposed)
            {
                if (disposing)
                {
                    // Dispose managed objects
                    if (_params40 != null)
                    {
                        _params40.Dispose();
                        _params40 = null;
                    }

                    if (_params41 != null)
                    {
                        _params41.Dispose();
                        _params41 = null;
                    }

                    if (_params80 != null)
                    {
                        _params80.Dispose();
                        _params80 = null;
                    }

                    if (_params81 != null)
                    {
                        _params81.Dispose();
                        _params81 = null;
                    }

                    // Release the reference to randomInfo so GC knows this object doesn't need it anymore
                    _randomInfo = null;
                }

                // Dispose unmanaged objects

                _disposed = true;
            }
        }