WOWW: Refactor decryption logic
This removes unnecessary empty else blocks and makes for easier reading.
This commit is contained in:
parent
26bec7e580
commit
db24903e4a
|
@ -2035,39 +2035,32 @@ handle_packet_header(packet_info* pinfo,
|
||||||
|
|
||||||
WowwPreviousValues_t * original_header_values = wmem_tree_lookup32(wowwConversation->headers_need_decryption, pinfo->num);
|
WowwPreviousValues_t * original_header_values = wmem_tree_lookup32(wowwConversation->headers_need_decryption, pinfo->num);
|
||||||
|
|
||||||
if (original_header_values) {
|
if (original_header_values && !session_key_is_fully_deduced(wowwConversation->known_indices, headerSize, original_header_values->idx)) {
|
||||||
// Header has been seen before
|
// If we have seen the header before AND
|
||||||
|
// we still can't decrypt it
|
||||||
// Original value will need to be used for deduction
|
// there's nothing to do but wait until we get more information
|
||||||
if (!session_key_is_fully_deduced(wowwConversation->known_indices, headerSize, original_header_values->idx)) {
|
return NULL;
|
||||||
// Not ready yet
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Header can be decrypted and added to map
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// Header has not been seen before
|
|
||||||
if (!session_key_is_fully_deduced(wowwConversation->known_indices, headerSize, participant->idx)) {
|
|
||||||
// Packet isn't decryptable, make sure to do it later
|
|
||||||
WowwPreviousValues_t* array_index = wmem_alloc(wmem_file_scope(), 2);
|
|
||||||
array_index->idx = participant->idx;
|
|
||||||
array_index->last_encrypted_value = participant->last_encrypted_value;
|
|
||||||
wmem_tree_insert32(wowwConversation->headers_need_decryption, pinfo->num, array_index);
|
|
||||||
|
|
||||||
if (WOWW_CLIENT_TO_SERVER) {
|
if (!original_header_values && !session_key_is_fully_deduced(wowwConversation->known_indices, headerSize, participant->idx)) {
|
||||||
deduce_header(wowwConversation->session_key, wowwConversation->known_indices, header, participant);
|
// If we haven't seen the header before AND
|
||||||
} else {
|
// we can't decrypt it now
|
||||||
// Skip the packet, but remember to acknowledge that values changed
|
// we make sure it gets decrypted later
|
||||||
participant->idx = (participant->idx + headerSize) % WOWW_SESSION_KEY_LENGTH;
|
WowwPreviousValues_t* array_index = wmem_alloc(wmem_file_scope(), 2);
|
||||||
participant->last_encrypted_value = header[headerSize - 1];
|
array_index->idx = participant->idx;
|
||||||
}
|
array_index->last_encrypted_value = participant->last_encrypted_value;
|
||||||
|
wmem_tree_insert32(wowwConversation->headers_need_decryption, pinfo->num, array_index);
|
||||||
|
|
||||||
return NULL;
|
// If it's a server header we can use it to deduce the session key
|
||||||
}
|
if (WOWW_CLIENT_TO_SERVER) {
|
||||||
else {
|
deduce_header(wowwConversation->session_key, wowwConversation->known_indices, header, participant);
|
||||||
// Header can be decrypted and added to map
|
} else {
|
||||||
|
// Skip the packet, but remember to acknowledge that values changed
|
||||||
|
participant->idx = (participant->idx + headerSize) % WOWW_SESSION_KEY_LENGTH;
|
||||||
|
participant->last_encrypted_value = header[headerSize - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint8* idx = &participant->idx;
|
guint8* idx = &participant->idx;
|
||||||
|
|
Loading…
Reference in New Issue