diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-04-26 18:09:50 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-04-26 18:09:50 +0000 |
commit | f6dbe5a0d42dcf82d440ef24b7a879854c3da14f (patch) | |
tree | 94476491174ca63cc79c4d105b940def1ab9c8f4 /src/or/test.c | |
parent | b410dff6c078022a7478ce2d17c07ccb38104081 (diff) | |
download | tor-f6dbe5a0d42dcf82d440ef24b7a879854c3da14f.tar.gz tor-f6dbe5a0d42dcf82d440ef24b7a879854c3da14f.zip |
Refactor crypto error handling to be more like TLS error handling:
crypto_perror is a no-no, since an operation can set more than one
error.
Also, fix a bug in the unix crypto_seed_rng: mixing stdio with
/dev/urandom is a bad idea, since fopen can make all kinds of weird
extraneous syscalls (mmap, fcntl, stat64, etc.) and since fread tends
to buffer data in big chunks, thus depleting the entropy pool.
svn:r1717
Diffstat (limited to 'src/or/test.c')
-rw-r--r-- | src/or/test.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/or/test.c b/src/or/test.c index c773e86a4d..48e4a4f9ae 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -242,7 +242,6 @@ test_crypto() crypto_cipher_env_t *env1, *env2; crypto_pk_env_t *pk1, *pk2; char *data1, *data2, *data3, *cp; - FILE *f; int i, j, p, len; data1 = tor_malloc(1024); @@ -376,16 +375,11 @@ test_crypto() PK_PKCS1_OAEP_PADDING)); /* File operations: save and load private key */ - f = fopen("/tmp/tor_test/pkey1", "wb"); - test_assert(! crypto_pk_write_private_key_to_file(pk1, f)); - fclose(f); - f = fopen("/tmp/tor_test/pkey1", "rb"); - test_assert(! crypto_pk_read_private_key_from_file(pk2, f)); - fclose(f); - test_eq(15, crypto_pk_private_decrypt(pk2, data1, 128, data3, - PK_PKCS1_OAEP_PADDING)); + test_assert(! crypto_pk_write_private_key_to_filename(pk1, + "/tmp/tor_test/pke1y")); + test_assert(! crypto_pk_read_private_key_from_filename(pk2, - "/tmp/tor_test/pkey1")); + "/tmp/tor_test/pke1y")); test_eq(15, crypto_pk_private_decrypt(pk2, data1, 128, data3, PK_PKCS1_OAEP_PADDING)); |