mirror of
				https://github.com/drwetter/testssl.sh.git
				synced 2025-11-03 23:35:26 +01:00 
			
		
		
		
	Minor code cleanup
This PR cleans up the code in a few places by using "case" statements in a few places where the value of a variable is checked multiple times.
This commit is contained in:
		
							
								
								
									
										27
									
								
								testssl.sh
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								testssl.sh
									
									
									
									
									
								
							@@ -12217,8 +12217,10 @@ check_tls_serverhellodone() {
 | 
				
			|||||||
          [[ $remaining -lt 10 ]] && return 1
 | 
					          [[ $remaining -lt 10 ]] && return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          tls_content_type="${tls_hello_ascii:i:2}"
 | 
					          tls_content_type="${tls_hello_ascii:i:2}"
 | 
				
			||||||
          [[ "$tls_content_type" != 14 ]] && [[ "$tls_content_type" != 15 ]] && \
 | 
					          case "$tls_content_type" in
 | 
				
			||||||
               [[ "$tls_content_type" != 16 ]] && [[ "$tls_content_type" != 17 ]] && return 2
 | 
					               14|15|16|17) ;;
 | 
				
			||||||
 | 
					               *) return 2 ;;
 | 
				
			||||||
 | 
					          esac
 | 
				
			||||||
          i=$i+2
 | 
					          i=$i+2
 | 
				
			||||||
          tls_protocol="${tls_hello_ascii:i:4}"
 | 
					          tls_protocol="${tls_hello_ascii:i:4}"
 | 
				
			||||||
          [[ -z "$DETECTED_TLS_VERSION" ]] && DETECTED_TLS_VERSION="$tls_protocol"
 | 
					          [[ -z "$DETECTED_TLS_VERSION" ]] && DETECTED_TLS_VERSION="$tls_protocol"
 | 
				
			||||||
@@ -12298,13 +12300,11 @@ check_tls_serverhellodone() {
 | 
				
			|||||||
               done
 | 
					               done
 | 
				
			||||||
               tls_content_type="${plaintext:plaintext_len:2}"
 | 
					               tls_content_type="${plaintext:plaintext_len:2}"
 | 
				
			||||||
               decrypted_response+="${tls_content_type}0301$(printf "%04X" $((plaintext_len/2)))${plaintext:0:plaintext_len}"
 | 
					               decrypted_response+="${tls_content_type}0301$(printf "%04X" $((plaintext_len/2)))${plaintext:0:plaintext_len}"
 | 
				
			||||||
               if [[ "$tls_content_type" == 16 ]]; then
 | 
					               case "$tls_content_type" in
 | 
				
			||||||
                    tls_handshake_ascii+="${plaintext:0:plaintext_len}"
 | 
					                    15) tls_alert_ascii+="${plaintext:0:plaintext_len}" ;;
 | 
				
			||||||
               elif [[ "$tls_content_type" == 15 ]]; then
 | 
					                    16) tls_handshake_ascii+="${plaintext:0:plaintext_len}" ;;
 | 
				
			||||||
                    tls_alert_ascii+="${plaintext:0:plaintext_len}"
 | 
					                    *) return 2 ;;
 | 
				
			||||||
               else
 | 
					               esac
 | 
				
			||||||
                    return 2
 | 
					 | 
				
			||||||
               fi
 | 
					 | 
				
			||||||
          fi
 | 
					          fi
 | 
				
			||||||
     done
 | 
					     done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -12529,11 +12529,10 @@ parse_tls_serverhello() {
 | 
				
			|||||||
               fi
 | 
					               fi
 | 
				
			||||||
          fi
 | 
					          fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if [[ $tls_content_type == 16 ]]; then
 | 
					          case "$tls_content_type" in
 | 
				
			||||||
               tls_handshake_ascii="$tls_handshake_ascii${tls_hello_ascii:i:msg_len}"
 | 
					               15) tls_alert_ascii="$tls_alert_ascii${tls_hello_ascii:i:msg_len}" ;;
 | 
				
			||||||
          elif [[ $tls_content_type == 15 ]]; then   # TLS ALERT
 | 
					               16) tls_handshake_ascii="$tls_handshake_ascii${tls_hello_ascii:i:msg_len}" ;;
 | 
				
			||||||
               tls_alert_ascii="$tls_alert_ascii${tls_hello_ascii:i:msg_len}"
 | 
					          esac
 | 
				
			||||||
          fi
 | 
					 | 
				
			||||||
     done
 | 
					     done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     # Now check the alert messages.
 | 
					     # Now check the alert messages.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user