mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
more cleanup
svn:r242
This commit is contained in:
parent
f39ca8a3aa
commit
fe1aba7f15
@ -599,8 +599,8 @@ int crypto_cipher_encrypt_init_cipher(crypto_cipher_env_t *env)
|
|||||||
|
|
||||||
if (crypto_cipher_evp_cipher(env->type, 1)) {
|
if (crypto_cipher_evp_cipher(env->type, 1)) {
|
||||||
RETURN_SSL_OUTCOME(EVP_EncryptInit((EVP_CIPHER_CTX *)env->aux,
|
RETURN_SSL_OUTCOME(EVP_EncryptInit((EVP_CIPHER_CTX *)env->aux,
|
||||||
crypto_cipher_evp_cipher(env->type, 1),
|
crypto_cipher_evp_cipher(env->type, 1),
|
||||||
env->key, env->iv));
|
env->key, env->iv));
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -612,8 +612,8 @@ int crypto_cipher_decrypt_init_cipher(crypto_cipher_env_t *env)
|
|||||||
|
|
||||||
if (crypto_cipher_evp_cipher(env->type, 0)) {
|
if (crypto_cipher_evp_cipher(env->type, 0)) {
|
||||||
RETURN_SSL_OUTCOME(EVP_EncryptInit((EVP_CIPHER_CTX *)env->aux,
|
RETURN_SSL_OUTCOME(EVP_EncryptInit((EVP_CIPHER_CTX *)env->aux,
|
||||||
crypto_cipher_evp_cipher(env->type, 0),
|
crypto_cipher_evp_cipher(env->type, 0),
|
||||||
env->key, env->iv));
|
env->key, env->iv));
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <limits.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ my_gettimeofday(struct timeval *timeval)
|
|||||||
long
|
long
|
||||||
tv_udiff(struct timeval *start, struct timeval *end)
|
tv_udiff(struct timeval *start, struct timeval *end)
|
||||||
{
|
{
|
||||||
|
long udiff;
|
||||||
long secdiff = end->tv_sec - start->tv_sec;
|
long secdiff = end->tv_sec - start->tv_sec;
|
||||||
if (secdiff+1 > LONG_MAX/1000000) {
|
if (secdiff+1 > LONG_MAX/1000000) {
|
||||||
log(LOG_NOTICE, "tv_udiff(): comparing times too far apart.");
|
log(LOG_NOTICE, "tv_udiff(): comparing times too far apart.");
|
||||||
@ -30,7 +32,12 @@ tv_udiff(struct timeval *start, struct timeval *end)
|
|||||||
end->tv_sec--;
|
end->tv_sec--;
|
||||||
end->tv_usec += 1000000L;
|
end->tv_usec += 1000000L;
|
||||||
}
|
}
|
||||||
return secdiff*1000000L + (end->tv_usec - start->tv_usec);
|
udiff = secdiff*1000000L + (end->tv_usec - start->tv_usec);
|
||||||
|
if(udiff < 0) {
|
||||||
|
log(LOG_NOTICE, "tv_udiff(): start is after end. Returning 0.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return udiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tv_cmp(struct timeval *a, struct timeval *b) {
|
int tv_cmp(struct timeval *a, struct timeval *b) {
|
||||||
|
Loading…
Reference in New Issue
Block a user