+Sun Nov 24 18:26:42 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * If iv argument to silc_cipher_[encrypt/decrypt] is NULL, use
+ automatically the cipher's internal IV. Affected files
+ lib/silccrypt/silccipher.[ch].
+
Fri Nov 22 18:34:20 EET 2002 Pekka Riikonen <priikone@silcnet.org>
* Added support to backup router protocol for backup to tell
/* Decrypt the message */
silc_cipher_decrypt(cipher, data, data, data_len - iv_len - mac_len,
- (iv_len ? data + (data_len - iv_len - mac_len) :
- silc_cipher_get_iv(cipher)));
+ (iv_len ? data + (data_len - iv_len - mac_len) : NULL));
return TRUE;
}
/* Encrypt payload of the packet. If the IV is added to packet do
not encrypt that. */
silc_cipher_encrypt(cipher, data, data, data_len - iv_len,
- iv_len ? iv : silc_cipher_get_iv(cipher));
+ iv_len ? iv : NULL);
/* Compute the MAC of the encrypted message data */
silc_hmac_init(hmac);
if (cipher) {
SILC_LOG_DEBUG(("Encrypting packet, cipher %s, len %d",
silc_cipher_get_name(cipher), len));
- silc_cipher_encrypt(cipher, buffer->data, buffer->data, len,
- silc_cipher_get_iv(cipher));
+ silc_cipher_encrypt(cipher, buffer->data, buffer->data, len, NULL);
}
/* Compute HMAC. This assumes that MAC is computed from the entire
if (cipher) {
/* Decrypt rest of the packet */
SILC_LOG_DEBUG(("Decrypting the packet"));
- silc_cipher_decrypt(cipher, buffer->data, buffer->data, buffer->len,
- silc_cipher_get_iv(cipher));
+ silc_cipher_decrypt(cipher, buffer->data, buffer->data, buffer->len,
+ NULL);
}
return 0;
return -1;
}
silc_buffer_pull(buffer, block_len);
- silc_cipher_decrypt(cipher, buffer->data, buffer->data, len,
- silc_cipher_get_iv(cipher));
+ silc_cipher_decrypt(cipher, buffer->data, buffer->data, len, NULL);
}
return 1;
unsigned char *dst, SilcUInt32 len,
unsigned char *iv)
{
- return cipher->cipher->encrypt(cipher->context, src, dst, len, iv);
+ return cipher->cipher->encrypt(cipher->context, src, dst, len,
+ iv ? iv : cipher->iv);
}
/* Decrypts */
unsigned char *dst, SilcUInt32 len,
unsigned char *iv)
{
- return cipher->cipher->decrypt(cipher->context, src, dst, len, iv);
+ return cipher->cipher->decrypt(cipher->context, src, dst, len,
+ iv ? iv : cipher->iv);
}
/* Sets the key for the cipher */
* DESCRIPTION
*
* Encrypts data from `src' into `dst' with the specified cipher and
- * Initial Vector (IV). The `src' and `dst' maybe same buffer.
+ * Initial Vector (IV). If the `iv' is NULL then the cipher's internal
+ * IV is used. The `src' and `dst' maybe same buffer.
*
***/
bool silc_cipher_encrypt(SilcCipher cipher, const unsigned char *src,
* DESCRIPTION
*
* Decrypts data from `src' into `dst' with the specified cipher and
- * Initial Vector (IV). The `src' and `dst' maybe same buffer.
+ * Initial Vector (IV). If the `iv' is NULL then the cipher's internal
+ * IV is used. The `src' and `dst' maybe same buffer.
*
***/
bool silc_cipher_decrypt(SilcCipher cipher, const unsigned char *src,