summaryrefslogtreecommitdiff
path: root/src/common/crypto_ed25519.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-07-15 10:35:29 -0400
committerNick Mathewson <nickm@torproject.org>2015-07-15 10:35:29 -0400
commit3c28d95ca7c1f7086c2f840254a2d6663beaf935 (patch)
treeb90b857aff3906991532498e7bf1158ac8924a1f /src/common/crypto_ed25519.c
parent5e8edba3d80bf53e5e5c09c8a87e06d0c69e00b7 (diff)
downloadtor-3c28d95ca7c1f7086c2f840254a2d6663beaf935.tar.gz
tor-3c28d95ca7c1f7086c2f840254a2d6663beaf935.zip
Add more EINVAL errno setting on key read failures
Teor found these. This is for part of #16582.
Diffstat (limited to 'src/common/crypto_ed25519.c')
-rw-r--r--src/common/crypto_ed25519.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/common/crypto_ed25519.c b/src/common/crypto_ed25519.c
index 599a1ca9b7..1606d02c48 100644
--- a/src/common/crypto_ed25519.c
+++ b/src/common/crypto_ed25519.c
@@ -381,10 +381,13 @@ ed25519_seckey_read_from_file(ed25519_secret_key_t *seckey_out,
len = crypto_read_tagged_contents_from_file(filename, "ed25519v1-secret",
tag_out, seckey_out->seckey,
sizeof(seckey_out->seckey));
- if (len != sizeof(seckey_out->seckey))
- return -1;
+ if (len == sizeof(seckey_out->seckey)) {
+ return 0;
+ } else if (len >= 0) {
+ errno = EINVAL;
+ }
- return 0;
+ return -1;
}
/**
@@ -417,10 +420,13 @@ ed25519_pubkey_read_from_file(ed25519_public_key_t *pubkey_out,
len = crypto_read_tagged_contents_from_file(filename, "ed25519v1-public",
tag_out, pubkey_out->pubkey,
sizeof(pubkey_out->pubkey));
- if (len != sizeof(pubkey_out->pubkey))
- return -1;
+ if (len == sizeof(pubkey_out->pubkey)) {
+ return 0;
+ } else if (len >= 0) {
+ errno = EINVAL;
+ }
- return 0;
+ return -1;
}
/** Release all storage held for <b>kp</b>. */