Added preliminary Symbian support.
[silc.git] / lib / silccrypt / silcpk.c
index d9b81cbad215b45f4669bfe33c84aaee1fff7a85..cb9ef4229f3c695674728d7b91fcc3d14df41a2c 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2006 Pekka Riikonen
+  Copyright (C) 1997 - 2007 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -370,6 +370,10 @@ SilcBool silc_pkcs_silc_import_public_key(unsigned char *key,
   if (ret == -1)
     goto err;
 
+  /* Backwards compatibility */
+  if (totlen == key_len)
+    totlen -= 4;
+
   if (totlen + 4 != key_len)
     goto err;
 
@@ -816,7 +820,7 @@ SilcBool silc_pkcs_silc_import_private_key_file(unsigned char *filedata,
   /* Check file magic */
   SILC_GET32_MSB(magic, filedata);
   if (magic != SILC_PKCS_PRIVATE_KEY_MAGIC) {
-    SILC_LOG_ERROR(("Private key does not have correct magic"));
+    SILC_LOG_DEBUG(("Private key does not have correct magic"));
     return FALSE;
   }
 
@@ -859,7 +863,7 @@ SilcBool silc_pkcs_silc_import_private_key_file(unsigned char *filedata,
   silc_hash_final(sha1, keymat + 16);
 
   /* Set the key to the cipher */
-  silc_cipher_set_key(aes, keymat, 256);
+  silc_cipher_set_key(aes, keymat, 256, FALSE);
 
   /* First, verify the MAC of the private key data */
   mac_len = silc_hmac_len(sha1hmac);
@@ -1271,7 +1275,7 @@ silc_pkcs_silc_export_private_key_file(void *private_key,
   silc_hash_final(sha1, keymat + 16);
 
   /* Set the key to the cipher */
-  silc_cipher_set_key(aes, keymat, 256);
+  silc_cipher_set_key(aes, keymat, 256, TRUE);
 
   /* Encode the buffer to be encrypted.  Add padding to it too, at least
      block size of the cipher. */
@@ -1525,7 +1529,8 @@ SilcBool silc_pkcs_silc_encrypt(void *public_key,
                                SilcUInt32 src_len,
                                unsigned char *dst,
                                SilcUInt32 dst_size,
-                               SilcUInt32 *ret_dst_len)
+                               SilcUInt32 *ret_dst_len,
+                               SilcRng rng)
 {
   SilcSILCPublicKey silc_pubkey = public_key;
 
@@ -1534,7 +1539,7 @@ SilcBool silc_pkcs_silc_encrypt(void *public_key,
 
   return silc_pubkey->pkcs->encrypt(silc_pubkey->public_key,
                                    src, src_len,
-                                   dst, dst_size, ret_dst_len);
+                                   dst, dst_size, ret_dst_len, rng);
 }
 
 /* Decrypts as specified in SILC protocol specification */