If if argument is NULL, use cipher's internal IV automatically.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 24 Nov 2002 16:28:06 +0000 (16:28 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 24 Nov 2002 16:28:06 +0000 (16:28 +0000)
CHANGES
lib/silccore/silcmessage.c
lib/silccore/silcpacket.c
lib/silccrypt/silccipher.c
lib/silccrypt/silccipher.h

diff --git a/CHANGES b/CHANGES
index 69d1d07fcf2b568670089970ab3f27588e0b79f4..8985607de9118f987561a2a30d83daf6a71c2a25 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+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
index f1fbe932e7809829167371c26025b2fac51b253b..e3fd64f970cb17556abd27cb35a6eec618429aa1 100644 (file)
@@ -98,8 +98,7 @@ bool silc_message_payload_decrypt(unsigned char *data,
 
   /* 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;
 }
 
@@ -191,7 +190,7 @@ bool silc_message_payload_encrypt(unsigned char *data,
   /* 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);
index fbbb4a695ec34674ebc5705d1262bf2341aab2cb..0c3bcb9118c4581c9086db9e139e25e0b21ead0c 100644 (file)
@@ -85,8 +85,7 @@ void silc_packet_encrypt(SilcCipher cipher, SilcHmac hmac, SilcUInt32 sequence,
   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
@@ -502,8 +501,8 @@ static int silc_packet_decrypt(SilcCipher cipher, SilcHmac hmac,
     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;
 
@@ -528,8 +527,7 @@ static int silc_packet_decrypt(SilcCipher cipher, SilcHmac hmac,
        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;
index b233e3f9485d3668fd1cb87769f01f5a623729a4..72d984b35cebbcf324ae9fac7ba17814134668ec 100644 (file)
@@ -315,7 +315,8 @@ bool silc_cipher_encrypt(SilcCipher cipher, const unsigned char *src,
                         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 */
@@ -324,7 +325,8 @@ bool silc_cipher_decrypt(SilcCipher cipher, const unsigned char *src,
                         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 */
index dd5541a7c92d2462db5b15659c97e93b2aaeb522..95478d2e6f428710bc2932ca43f3dbb9407e1820 100644 (file)
@@ -241,7 +241,8 @@ char *silc_cipher_get_supported(void);
  * 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,
@@ -259,7 +260,8 @@ 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,