예제 #1
0
        private void NegotiateWithEncryptionCapabilitiesContext(EncryptionAlgorithm cipherId)
        {
            if (cipherId == EncryptionAlgorithm.ENCRYPTION_NONE)
            {
                throw new ArgumentException("CipherId should be either AES-128-CCM or AES-128-GCM.");
            }

            #region Check Applicability
            TestConfig.CheckDialect(DialectRevision.Smb311);
            TestConfig.CheckCapabilities(NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_ENCRYPTION);
            TestConfig.CheckEncryptionAlgorithm(cipherId);
            #endregion

            BaseTestSite.Log.Add(
                LogEntryKind.TestStep,
                "Client sends NEGOTIATE request with dialect 3.11, SMB2_ENCRYPTION_CAPABILITIES context. {0} is as the preferred cipher algorithm. ", cipherId);
            BaseTestSite.Log.Add(
                LogEntryKind.TestStep,
                "Server should reply NEGOTIATE response with dialect 3.11, SMB2_ENCRYPTION_CAPABILITIES context and {0} as cipher algorithm. ", cipherId);
            PreauthIntegrityHashID[] preauthHashAlgs = new PreauthIntegrityHashID[] { PreauthIntegrityHashID.SHA_512 };
            EncryptionAlgorithm[]    encryptionAlgs  = new EncryptionAlgorithm[] {
                cipherId,
                cipherId == EncryptionAlgorithm.ENCRYPTION_AES128_CCM? EncryptionAlgorithm.ENCRYPTION_AES128_GCM : EncryptionAlgorithm.ENCRYPTION_AES128_CCM
            };
            client.NegotiateWithContexts(
                Packet_Header_Flags_Values.NONE,
                TestConfig.RequestDialects,
                capabilityValue: Capabilities_Values.GLOBAL_CAP_DIRECTORY_LEASING | Capabilities_Values.GLOBAL_CAP_LARGE_MTU | Capabilities_Values.GLOBAL_CAP_LEASING | Capabilities_Values.GLOBAL_CAP_ENCRYPTION,
                preauthHashAlgs: preauthHashAlgs,
                encryptionAlgs: encryptionAlgs);
            BaseTestSite.Assert.AreEqual(cipherId, client.SelectedCipherID, "The selected Cipher Id should be {0}", cipherId);
        }
        private void NegotiateWithEncryptionCapabilitiesContext(EncryptionAlgorithm cipherId, bool sendCipherArray = false)
        {
            if (cipherId == EncryptionAlgorithm.ENCRYPTION_NONE)
            {
                throw new ArgumentException("CipherId should be either AES-128-CCM or AES-128-GCM.");
            }

            #region Check Applicability
            TestConfig.CheckDialect(DialectRevision.Smb311);
            TestConfig.CheckCapabilities(NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_ENCRYPTION);
            TestConfig.CheckEncryptionAlgorithm(cipherId);
            #endregion

            BaseTestSite.Log.Add(
                LogEntryKind.TestStep,
                "Client sends NEGOTIATE request with dialect 3.11, SMB2_ENCRYPTION_CAPABILITIES context. {0} is as the preferred cipher algorithm. ", cipherId);
            BaseTestSite.Log.Add(
                LogEntryKind.TestStep,
                "Server should reply NEGOTIATE response with dialect 3.11, SMB2_ENCRYPTION_CAPABILITIES context and {0} as cipher algorithm. ", cipherId);
            PreauthIntegrityHashID[] preauthHashAlgs = new PreauthIntegrityHashID[] { PreauthIntegrityHashID.SHA_512 };
            EncryptionAlgorithm[]    encryptionAlgs  = null;
            if (sendCipherArray)
            {
                encryptionAlgs = new EncryptionAlgorithm[] {
                    cipherId,
                    cipherId == EncryptionAlgorithm.ENCRYPTION_AES128_CCM? EncryptionAlgorithm.ENCRYPTION_AES128_GCM : EncryptionAlgorithm.ENCRYPTION_AES128_CCM
                };
            }
            else
            {
                encryptionAlgs = new EncryptionAlgorithm[] { cipherId };
            }

            client.NegotiateWithContexts(
                Packet_Header_Flags_Values.NONE,
                TestConfig.RequestDialects,
                capabilityValue: Capabilities_Values.GLOBAL_CAP_DIRECTORY_LEASING | Capabilities_Values.GLOBAL_CAP_LARGE_MTU | Capabilities_Values.GLOBAL_CAP_LEASING | Capabilities_Values.GLOBAL_CAP_ENCRYPTION,
                preauthHashAlgs: preauthHashAlgs,
                encryptionAlgs: encryptionAlgs);

            if (sendCipherArray)
            {
                BaseTestSite.Assert.IsTrue(
                    TestConfig.SupportedEncryptionAlgorithmList.Contains(client.SelectedCipherID),
                    "[MS-SMB2] 3.3.5.4 The server MUST set Connection.CipherId to one of the ciphers in the client's " +
                    "SMB2_ENCRYPTION_CAPABILITIES Ciphers array in an implementation-specific manner.");
            }
            else
            {
                BaseTestSite.Assert.AreEqual(cipherId, client.SelectedCipherID, "The selected Cipher Id should be {0}", cipherId);
            }
        }