if (!private_message || (private_message && static_key))
iv_len = block_len;
- if (data_len <= (mac_len + iv_len + block_len))
+ if (data_len < (mac_len + iv_len + block_len))
return FALSE;
if (check_mac) {
silc_cipher_get_iv(cipher));
/* Decrypt block */
- if (!silc_cipher_decrypt(cipher, data, data, block_len, ivp))
+ if (!silc_cipher_decrypt(cipher, data, data, block_len, ivp)) {
+ SILC_ASSERT(FALSE);
return FALSE;
+ }
/* Get the payload length and decrypt rest */
totlen = 2;
if (totlen >= block_len)
if (!silc_cipher_decrypt(cipher, data + block_len, data + block_len,
(totlen - block_len) + SILC_MESSAGE_PAD(totlen),
- ivp))
+ ivp)) {
+ SILC_ASSERT(FALSE);
return FALSE;
+ }
return TRUE;
}
/* Verify the signature in SILC_MESSAGE_FLAG_SIGNED Payload */
-int silc_message_signed_verify(SilcMessagePayload message,
- SilcPublicKey remote_public_key,
- SilcHash hash)
+SilcAuthResult silc_message_signed_verify(SilcMessagePayload message,
+ SilcPublicKey remote_public_key,
+ SilcHash hash)
{
int ret = SILC_AUTH_FAILED;
SilcBuffer sign, tmp;
*
* SYNOPSIS
*
- * int silc_message_signed_verify(SilcMessagePayload message,
- * SilcPublicKey remote_public_key,
- * SilcHash hash);
+ * SilcAuthResult
+ * silc_message_signed_verify(SilcMessagePayload message,
+ * SilcPublicKey remote_public_key,
+ * SilcHash hash);
*
* DESCRIPTION
*
* returns SILC_AUTH_OK if the signature verification was successful.
*
***/
-int silc_message_signed_verify(SilcMessagePayload message,
- SilcPublicKey remote_public_key,
- SilcHash hash);
+SilcAuthResult silc_message_signed_verify(SilcMessagePayload message,
+ SilcPublicKey remote_public_key,
+ SilcHash hash);
/****f* silccore/SilcMessageAPI/silc_message_signed_get_public_key
*
SilcUInt32 paddedlen, mac_len, block_len, ivlen, psnlen;
unsigned char tmp[SILC_PACKET_MIN_HEADER_LEN], *header;
unsigned char iv[SILC_CIPHER_MAX_IV_SIZE], *packet_seq = NULL;
- SilcBool normal = TRUE;
+ SilcBool normal;
int ret;
/* Parse the packets from the data */
ivlen = psnlen = 0;
cipher = stream->receive_key[0];
hmac = stream->receive_hmac[0];
+ normal = FALSE;
if (silc_buffer_len(&stream->inbuf) <
(stream->iv_included ? SILC_PACKET_MIN_HEADER_LEN_IV :
silc_buffer_reset(&stream->inbuf);
return;
}
+ packet->stream = stream;
/* Allocate more space to packet buffer, if needed */
if (silc_buffer_truelen(&packet->buffer) < paddedlen) {
silc_buffer_pull(&stream->inbuf, paddedlen + mac_len);
/* Dispatch the packet to application */
- packet->stream = stream;
silc_packet_dispatch(packet);
}
* DESCRIPTION
*
* Destroy packet stream and the underlaying stream. This will also
- * send end of stream to the underlaying stream.
+ * close and destroy the underlaying stream.
*
***/
void silc_packet_stream_destroy(SilcPacketStream stream);