diff options
author | Özgür Kesim <oec@codeblau.de> | 2021-12-15 14:27:00 +0100 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2021-12-15 14:32:22 +0100 |
commit | f27fe484c60be69e762e038a84331a3a72111957 (patch) | |
tree | b635f3bfd5c72e0a705c78e7c7d3b62a9a976433 /src/util/crypto_ecc_setup.c | |
parent | 10b9070e6db17b146784cd789cd7d4fa43b9e5ff (diff) | |
download | gnunet-f27fe484c60be69e762e038a84331a3a72111957.tar.gz gnunet-f27fe484c60be69e762e038a84331a3a72111957.zip |
GNUNET_CRYPTO_eddsa_key_from_file handles do_create correctly
The function GNUNET_CRYPTO_eddsa_key_from_file returns now
- GNUNET_OK on success,
- GNUNET_NO if do_create was set but we found an existing file,
- GNUNET_SYSERR on failure _or_ if the file didn't exist and
do_create was not set
Fixes #7106
Diffstat (limited to 'src/util/crypto_ecc_setup.c')
-rw-r--r-- | src/util/crypto_ecc_setup.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/util/crypto_ecc_setup.c b/src/util/crypto_ecc_setup.c index f7cd8c6d9..21ce48eef 100644 --- a/src/util/crypto_ecc_setup.c +++ b/src/util/crypto_ecc_setup.c | |||
@@ -134,8 +134,10 @@ read_from_file (const char *filename, | |||
134 | * @param filename name of file to use to store the key | 134 | * @param filename name of file to use to store the key |
135 | * @param do_create should a file be created? | 135 | * @param do_create should a file be created? |
136 | * @param[out] pkey set to the private key from @a filename on success | 136 | * @param[out] pkey set to the private key from @a filename on success |
137 | * @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but | 137 | * @return - #GNUNET_OK on success, |
138 | * we found an existing file, #GNUNET_SYSERR on failure | 138 | * - #GNUNET_NO if @a do_create was set but we found an existing file, |
139 | * - #GNUNET_SYSERR on failure _or_ if the file didn't exist and @a | ||
140 | * do_create was not set | ||
139 | */ | 141 | */ |
140 | enum GNUNET_GenericReturnValue | 142 | enum GNUNET_GenericReturnValue |
141 | GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, | 143 | GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, |
@@ -152,6 +154,11 @@ GNUNET_CRYPTO_eddsa_key_from_file (const char *filename, | |||
152 | /* file existed, report that we didn't create it... */ | 154 | /* file existed, report that we didn't create it... */ |
153 | return (do_create) ? GNUNET_NO : GNUNET_OK; | 155 | return (do_create) ? GNUNET_NO : GNUNET_OK; |
154 | } | 156 | } |
157 | else if (! do_create) | ||
158 | { | ||
159 | return GNUNET_SYSERR; | ||
160 | } | ||
161 | |||
155 | GNUNET_CRYPTO_eddsa_key_create (pkey); | 162 | GNUNET_CRYPTO_eddsa_key_create (pkey); |
156 | ret = GNUNET_DISK_fn_write (filename, | 163 | ret = GNUNET_DISK_fn_write (filename, |
157 | pkey, | 164 | pkey, |