Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the CkTls12KeyMatParams class.
        /// </summary>
        /// <param name="macSizeInBits">The length (in bits) of the MACing keys agreed upon during the protocol handshake phase</param>
        /// <param name="keySizeInBits">The length (in bits) of the secret keys agreed upon during the protocol handshake phase</param>
        /// <param name="ivSizeInBits">The length (in bits) of the IV agreed upon during the protocol handshake phase</param>
        /// <param name="isExport">Flag which must be set to false because export cipher suites must not be used in TLS 1.1 and later</param>
        /// <param name="randomInfo">Client's and server's random data information</param>
        /// <param name="prfHashMechanism">Base hash used in the underlying TLS1.2 PRF operation used to derive the master key (CKM)</param>
        public CkTls12KeyMatParams(ulong macSizeInBits, ulong keySizeInBits, ulong ivSizeInBits, bool isExport, CkSsl3RandomData randomInfo, ulong prfHashMechanism)
        {
            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.CkTls12KeyMatParams(Convert.ToUInt32(macSizeInBits), Convert.ToUInt32(keySizeInBits), Convert.ToUInt32(ivSizeInBits), isExport, _randomInfo._params40, Convert.ToUInt32(prfHashMechanism));
                }
                else
                {
                    _params41 = new HighLevelAPI41.MechanismParams.CkTls12KeyMatParams(Convert.ToUInt32(macSizeInBits), Convert.ToUInt32(keySizeInBits), Convert.ToUInt32(ivSizeInBits), isExport, _randomInfo._params41, Convert.ToUInt32(prfHashMechanism));
                }
            }
            else
            {
                if (Platform.StructPackingSize == 0)
                {
                    _params80 = new HighLevelAPI80.MechanismParams.CkTls12KeyMatParams(macSizeInBits, keySizeInBits, ivSizeInBits, isExport, _randomInfo._params80, prfHashMechanism);
                }
                else
                {
                    _params81 = new HighLevelAPI81.MechanismParams.CkTls12KeyMatParams(macSizeInBits, keySizeInBits, ivSizeInBits, isExport, _randomInfo._params81, prfHashMechanism);
                }
            }
        }
Exemple #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;
                    }

                    if (_returnedKeyMaterialLeftInstance == false)
                    {
                        if (_returnedKeyMaterial != null)
                        {
                            _returnedKeyMaterial.Dispose();
                            _returnedKeyMaterial = null;
                        }
                    }

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

                // Dispose unmanaged objects

                _disposed = true;
            }
        }