diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-10-26 22:13:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-10-26 22:13:01 +0000 |
commit | 64d3e46cfb99a711e500fa1f114e7c44bdf10040 (patch) | |
tree | 83093d92761d5c1b8b2fded713adaa19af29274c /src/util/crypto_rsa.c | |
parent | ef6f05f63769263a5201636c4b7f71eaa455cdf3 (diff) | |
download | gnunet-64d3e46cfb99a711e500fa1f114e7c44bdf10040.tar.gz gnunet-64d3e46cfb99a711e500fa1f114e7c44bdf10040.zip |
-bugfixes, code cleanup
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r-- | src/util/crypto_rsa.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index cb782282e..b5a8c85de 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -315,7 +315,7 @@ decode_public_key (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicK | |||
315 | * Encode the private key in a format suitable for | 315 | * Encode the private key in a format suitable for |
316 | * storing it into a file. | 316 | * storing it into a file. |
317 | * | 317 | * |
318 | * @returns encoding of the private key. | 318 | * @return encoding of the private key. |
319 | * The first 4 bytes give the size of the array, as usual. | 319 | * The first 4 bytes give the size of the array, as usual. |
320 | */ | 320 | */ |
321 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * | 321 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * |
@@ -778,9 +778,6 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
778 | GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); | 778 | GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); |
779 | GNUNET_CRYPTO_rsa_key_get_public (ret, &pub); | 779 | GNUNET_CRYPTO_rsa_key_get_public (ret, &pub); |
780 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey); | 780 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey); |
781 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
782 | _("I am host `%s'. Stored new private key in `%s'.\n"), | ||
783 | GNUNET_i2s (&pid), filename); | ||
784 | return ret; | 781 | return ret; |
785 | } | 782 | } |
786 | /* hostkey file exists already, read it! */ | 783 | /* hostkey file exists already, read it! */ |
@@ -807,7 +804,7 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
807 | STRERROR (ec)); | 804 | STRERROR (ec)); |
808 | LOG (GNUNET_ERROR_TYPE_ERROR, | 805 | LOG (GNUNET_ERROR_TYPE_ERROR, |
809 | _ | 806 | _ |
810 | ("This may be ok if someone is currently generating a hostkey.\n")); | 807 | ("This may be ok if someone is currently generating a private key.\n")); |
811 | } | 808 | } |
812 | short_wait (); | 809 | short_wait (); |
813 | continue; | 810 | continue; |
@@ -828,7 +825,7 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
828 | fs = 0; | 825 | fs = 0; |
829 | if (fs < sizeof (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded)) | 826 | if (fs < sizeof (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded)) |
830 | { | 827 | { |
831 | /* maybe we got the read lock before the hostkey generating | 828 | /* maybe we got the read lock before the key generating |
832 | * process had a chance to get the write lock; give it up! */ | 829 | * process had a chance to get the write lock; give it up! */ |
833 | if (GNUNET_YES != | 830 | if (GNUNET_YES != |
834 | GNUNET_DISK_file_unlock (fd, 0, | 831 | GNUNET_DISK_file_unlock (fd, 0, |
@@ -838,12 +835,12 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
838 | { | 835 | { |
839 | LOG (GNUNET_ERROR_TYPE_ERROR, | 836 | LOG (GNUNET_ERROR_TYPE_ERROR, |
840 | _ | 837 | _ |
841 | ("When trying to read hostkey file `%s' I found %u bytes but I need at least %u.\n"), | 838 | ("When trying to read key file `%s' I found %u bytes but I need at least %u.\n"), |
842 | filename, (unsigned int) fs, | 839 | filename, (unsigned int) fs, |
843 | (unsigned int) sizeof (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded)); | 840 | (unsigned int) sizeof (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded)); |
844 | LOG (GNUNET_ERROR_TYPE_ERROR, | 841 | LOG (GNUNET_ERROR_TYPE_ERROR, |
845 | _ | 842 | _ |
846 | ("This may be ok if someone is currently generating a hostkey.\n")); | 843 | ("This may be ok if someone is currently generating a private key.\n")); |
847 | } | 844 | } |
848 | short_wait (); /* wait a bit longer! */ | 845 | short_wait (); /* wait a bit longer! */ |
849 | continue; | 846 | continue; |
@@ -875,9 +872,6 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) | |||
875 | { | 872 | { |
876 | GNUNET_CRYPTO_rsa_key_get_public (ret, &pub); | 873 | GNUNET_CRYPTO_rsa_key_get_public (ret, &pub); |
877 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey); | 874 | GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey); |
878 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
879 | _("I am host `%s'. Read private key from `%s'.\n"), GNUNET_i2s (&pid), | ||
880 | filename); | ||
881 | } | 875 | } |
882 | return ret; | 876 | return ret; |
883 | } | 877 | } |
@@ -1105,10 +1099,10 @@ GNUNET_CRYPTO_rsa_key_create_stop (struct GNUNET_CRYPTO_RsaKeyGenerationContext | |||
1105 | 1099 | ||
1106 | 1100 | ||
1107 | /** | 1101 | /** |
1108 | * Setup a hostkey file for a peer given the name of the | 1102 | * Setup a key file for a peer given the name of the |
1109 | * configuration file (!). This function is used so that | 1103 | * configuration file (!). This function is used so that |
1110 | * at a later point code can be certain that reading a | 1104 | * at a later point code can be certain that reading a |
1111 | * hostkey is fast (for example in time-dependent testcases). | 1105 | * key is fast (for example in time-dependent testcases). |
1112 | * | 1106 | * |
1113 | * @param cfg_name name of the configuration file to use | 1107 | * @param cfg_name name of the configuration file to use |
1114 | */ | 1108 | */ |
@@ -1184,7 +1178,7 @@ GNUNET_CRYPTO_rsa_encrypt (const void *block, size_t size, | |||
1184 | 1178 | ||
1185 | 1179 | ||
1186 | /** | 1180 | /** |
1187 | * Decrypt a given block with the hostkey. | 1181 | * Decrypt a given block with the key. |
1188 | * | 1182 | * |
1189 | * @param key the key with which to decrypt this block | 1183 | * @param key the key with which to decrypt this block |
1190 | * @param block the data to decrypt, encoded as returned by encrypt | 1184 | * @param block the data to decrypt, encoded as returned by encrypt |