- SILC_LOG_HEXDUMP(("Fully decrypted packet, len %d", buffer->len),
- buffer->data, buffer->len);
- }
-
- return TRUE;
-}
-
-/* Decrypts rest of the SILC Packet header that has been decrypted partly
- already. This decrypts the padding of the packet also. After calling
- this function the packet is ready to be parsed by calling function
- silc_packet_parse. This is used in special packet reception (protocol
- defines the way of decrypting special packets). */
-
-static int silc_packet_decrypt_rest_special(SilcCipher cipher,
- SilcHmac hmac,
- SilcBuffer buffer)
-{
- /* Decrypt rest of the header plus padding */
- if (cipher) {
- uint16 len;
-
- /* Pull MAC from packet before decryption */
- if (hmac) {
- if ((buffer->len - silc_hmac_len(hmac)) > SILC_PACKET_MIN_LEN) {
- silc_buffer_push_tail(buffer, silc_hmac_len(hmac));
- } else {
- SILC_LOG_DEBUG(("Bad MAC length in packet, packet dropped"));
- return FALSE;
- }
- }
-
- SILC_LOG_DEBUG(("Decrypting rest of the header"));
-
- /* padding length + src id len + dst id len + header length - 16
- bytes already decrypted, gives the rest of the encrypted packet */
- len = (((uint8)buffer->data[4] + (uint8)buffer->data[6] +
- (uint8)buffer->data[7] + SILC_PACKET_HEADER_LEN) -
- SILC_PACKET_MIN_HEADER_LEN);
-
- silc_buffer_pull(buffer, SILC_PACKET_MIN_HEADER_LEN);
- if (len > buffer->len) {
- SILC_LOG_DEBUG(("Garbage in header of packet, bad packet length, "
- "packet dropped"));
- return FALSE;
- }
- silc_cipher_decrypt(cipher, buffer->data, buffer->data, len, cipher->iv);
- silc_buffer_push(buffer, SILC_PACKET_MIN_HEADER_LEN);
- SILC_LOG_HEXDUMP(("packet, len %d", buffer->len),
- buffer->data, buffer->len);