summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-11-13 09:46:32 -0500
committerNick Mathewson <nickm@torproject.org>2015-11-13 09:46:32 -0500
commitaccb726db6ebd7cf55df719a254b7681402c2aa9 (patch)
treefb659dac7cce4c53355f4d0ed6b30315b63e3a71 /src/common
parent43609fba77ec99d73bc18b9f7368c4840c4f338a (diff)
downloadtor-accb726db6ebd7cf55df719a254b7681402c2aa9.tar.gz
tor-accb726db6ebd7cf55df719a254b7681402c2aa9.zip
Remove a little duplicated code in TAP key expansion
patch from pfrankw; closes 17587.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/crypto.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 4c41d4494d..ffbeb81089 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -2159,7 +2159,7 @@ int
crypto_expand_key_material_TAP(const uint8_t *key_in, size_t key_in_len,
uint8_t *key_out, size_t key_out_len)
{
- int i;
+ int i, r = -1;
uint8_t *cp, *tmp = tor_malloc(key_in_len+1);
uint8_t digest[DIGEST_LEN];
@@ -2171,19 +2171,16 @@ crypto_expand_key_material_TAP(const uint8_t *key_in, size_t key_in_len,
++i, cp += DIGEST_LEN) {
tmp[key_in_len] = i;
if (crypto_digest((char*)digest, (const char *)tmp, key_in_len+1))
- goto err;
+ goto exit;
memcpy(cp, digest, MIN(DIGEST_LEN, key_out_len-(cp-key_out)));
}
- memwipe(tmp, 0, key_in_len+1);
- tor_free(tmp);
- memwipe(digest, 0, sizeof(digest));
- return 0;
- err:
+ r = 0;
+ exit:
memwipe(tmp, 0, key_in_len+1);
tor_free(tmp);
memwipe(digest, 0, sizeof(digest));
- return -1;
+ return r;
}
/** Expand some secret key material according to RFC5869, using SHA256 as the