Changeset View
Changeset View
Standalone View
Standalone View
g10/tofu.c
Show All 36 Lines | |||||
#include "options.h" | #include "options.h" | ||||
#include "../common/mbox-util.h" | #include "../common/mbox-util.h" | ||||
#include "../common/i18n.h" | #include "../common/i18n.h" | ||||
#include "../common/ttyio.h" | #include "../common/ttyio.h" | ||||
#include "trustdb.h" | #include "trustdb.h" | ||||
#include "../common/mkdir_p.h" | #include "../common/mkdir_p.h" | ||||
#include "gpgsql.h" | #include "gpgsql.h" | ||||
#include "../common/status.h" | #include "../common/status.h" | ||||
#include "sqrtu32.h" | |||||
#include "tofu.h" | #include "tofu.h" | ||||
#define CONTROL_L ('L' - 'A' + 1) | #define CONTROL_L ('L' - 'A' + 1) | ||||
/* Number of days with signed / ecnrypted messages required to | /* Number of days with signed / ecnrypted messages required to | ||||
* indicate that enough history is available for basic trust. */ | * indicate that enough history is available for basic trust. */ | ||||
▲ Show 20 Lines • Show All 2,868 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
int summary; | int summary; | ||||
int validity; | int validity; | ||||
unsigned long days; | unsigned long days; | ||||
/* Use the euclidean distance (m = sqrt(a^2 + b^2)) rather then the | /* Use the euclidean distance (m = sqrt(a^2 + b^2)) rather then the | ||||
sum of the magnitudes (m = a + b) to ensure a balance between | sum of the magnitudes (m = a + b) to ensure a balance between | ||||
verified signatures and encrypted messages. */ | verified signatures and encrypted messages. */ | ||||
days = sqrtu32 (signature_days * signature_days | days = signature_days * signature_days + encryption_days * encryption_days; | ||||
+ encryption_days * encryption_days); | |||||
if (days < 1) | if (days < 1) | ||||
validity = 1; /* Key without history. */ | validity = 1; /* Key without history. */ | ||||
else if (days < 2 * BASIC_TRUST_THRESHOLD) | else if (days < (2 * BASIC_TRUST_THRESHOLD) * (2 * BASIC_TRUST_THRESHOLD)) | ||||
validity = 2; /* Key with too little history. */ | validity = 2; /* Key with too little history. */ | ||||
else if (days < 2 * FULL_TRUST_THRESHOLD) | else if (days < (2 * FULL_TRUST_THRESHOLD) * (2 * FULL_TRUST_THRESHOLD)) | ||||
validity = 3; /* Key with enough history for basic trust. */ | validity = 3; /* Key with enough history for basic trust. */ | ||||
else | else | ||||
validity = 4; /* Key with a lot of history. */ | validity = 4; /* Key with a lot of history. */ | ||||
if (policy == TOFU_POLICY_ASK) | if (policy == TOFU_POLICY_ASK) | ||||
summary = 0; /* Key requires attention. */ | summary = 0; /* Key requires attention. */ | ||||
else | else | ||||
summary = validity; | summary = validity; | ||||
▲ Show 20 Lines • Show All 281 Lines • ▼ Show 20 Lines | if (!outfp && !only_status_fd) | ||||
if (encryption_count == 0) | if (encryption_count == 0) | ||||
log_info (_("Warning: you have yet to encrypt" | log_info (_("Warning: you have yet to encrypt" | ||||
" a message to this key!\n")); | " a message to this key!\n")); | ||||
else if (encryption_count == 1) | else if (encryption_count == 1) | ||||
log_info (_("Warning: you have only encrypted" | log_info (_("Warning: you have only encrypted" | ||||
" one message to this key!\n")); | " one message to this key!\n")); | ||||
/* Cf. write_stats_status */ | /* Cf. write_stats_status */ | ||||
if (sqrtu32 (encryption_count * encryption_count | if ((encryption_count * encryption_count | ||||
+ signature_count * signature_count) | + signature_count * signature_count) | ||||
< 2 * BASIC_TRUST_THRESHOLD) | < ((2 * BASIC_TRUST_THRESHOLD) * (2 * BASIC_TRUST_THRESHOLD))) | ||||
show_warning = 1; | show_warning = 1; | ||||
} | } | ||||
} | } | ||||
out: | out: | ||||
xfree (fingerprint_pp); | xfree (fingerprint_pp); | ||||
return show_warning; | return show_warning; | ||||
▲ Show 20 Lines • Show All 766 Lines • Show Last 20 Lines |