updates.
[silc.git] / lib / silccrypt / silccipher.c
index 0c8b6c77b18a5197aba5daaf228747917ae6720f..5eba8bcae6562293268833c56968a90cd452635c 100644 (file)
@@ -93,7 +93,7 @@ int silc_cipher_register(SilcCipherObject *cipher)
 {
   struct SilcCipherListStruct *new, *c;
 
-  SILC_LOG_DEBUG(("Registering new cipher"));
+  SILC_LOG_DEBUG(("Registering new cipher `%s'", cipher->name));
 
   new = silc_calloc(1, sizeof(*new));
   new->cipher = silc_calloc(1, sizeof(*new->cipher));
@@ -314,33 +314,58 @@ char *silc_cipher_get_supported()
   return list;
 }
 
+/* Encrypts */
+
+int silc_cipher_encrypt(SilcCipher cipher, const unsigned char *src,
+                       unsigned char *dst, unsigned int len, 
+                       unsigned char *iv)
+{
+  return cipher->cipher->encrypt(cipher->context, src, dst, len, iv);
+}
+
+/* Decrypts */
+
+int silc_cipher_decrypt(SilcCipher cipher, const unsigned char *src,
+                       unsigned char *dst, unsigned int len, 
+                       unsigned char *iv)
+{
+  return cipher->cipher->decrypt(cipher->context, src, dst, len, iv);
+}
+
+/* Sets the key for the cipher */
+
+int silc_cipher_set_key(SilcCipher cipher, const unsigned char *key,
+                       unsigned int keylen)
+{
+  return cipher->cipher->set_key(cipher->context, key, keylen);
+}
+
 /* Sets the IV (initial vector) for the cipher. */
 
-void silc_cipher_set_iv(SilcCipher itself, const unsigned char *iv)
+void silc_cipher_set_iv(SilcCipher cipher, const unsigned char *iv)
 {
-  memset(&itself->iv, 0, sizeof(itself->iv));
-  memcpy(&itself->iv, iv, itself->cipher->block_len);
+  memset(&cipher->iv, 0, sizeof(cipher->iv));
+  memcpy(&cipher->iv, iv, cipher->cipher->block_len);
 }
 
 /* Returns the IV (initial vector) of the cipher. The IV is returned 
    to 'iv' argument. */
 
-void silc_cipher_get_iv(SilcCipher itself, unsigned char *iv)
+void silc_cipher_get_iv(SilcCipher cipher, unsigned char *iv)
 {
-  memcpy(iv, &itself->iv, itself->cipher->block_len);
+  memcpy(iv, &cipher->iv, cipher->cipher->block_len);
 }
 
 /* Returns the key length of the cipher. */
 
-unsigned int silc_cipher_get_key_len(SilcCipher itself, 
-                                    const unsigned char *name)
+unsigned int silc_cipher_get_key_len(SilcCipher cipher)
 {
-  return itself->cipher->key_len;
+  return cipher->cipher->key_len;
 }
 
 /* Returns the block size of the cipher. */
 
-unsigned int silc_cipher_get_block_len(SilcCipher itself)
+unsigned int silc_cipher_get_block_len(SilcCipher cipher)
 {
-  return itself->cipher->block_len;
+  return cipher->cipher->block_len;
 }