Are SSL/TLS used for maintaining data confidentiality? In SSL/TLS, we use symmetric and asymmetric keys to encrypt the data. Does that mean that the keys are used to encrypt the data (preserve the integrity) or provide a secure channel for the data to be sent?

And as far as I know, hashing algorithms – inside of the SSL handshake protocol – are used to provide data integrity. So when data is encrypted via SSL/TLS, do they:


Encrypt the data like hash algorithm, or
Encrypt the data so that there is no eavesdropping of data? Meaning: they provide a secure channel which means they make use of symmetric, asymmetric key to preserve data confidentiality (no eavesdropping) and hashing to preserve integrity?
The answer to the first question is both.

TLS uses a custom PRF based on HMAC to generate symmetric and MAC keys from a shared secret. The shared secret is created during the asymmetric key exchange between client and server as part of the handshake.

The PRF generates key material of a required length. That length is determined by the key sizes and the key quantity. Those are related to the ciphersuite chosen. If an encryption algorithm provides both confidentiality and integrity (like AES-GCM), only 1 key per party is generated. If HMAC is used to provide integrity, 2 keys are generated. The PRF may also generated initialization vectors.

Different keys are generated for both client and server, so there are 2 keys generated for authenticated encryption algorithms, and 4 keys for algorithms that require a MAC for integrity. The keys used to encrypt the data in transit are used with symmetric algorithms. For data secured by TLS, the hash algorithms are used in the MAC, and not part of the encryption process.