mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-02 12:01:32 +01:00
g10: Correctly compute the euclidean distance.
* g10/tofu.c (write_stats_status): Correctly compute the euclidean distance. (show_statistics): Likewise. -- Signed-off-by: Neal H. Walfield <neal@g10code.com>
This commit is contained in:
parent
ca91caabb5
commit
05b2b13efd
18
g10/tofu.c
18
g10/tofu.c
@ -2514,16 +2514,17 @@ write_stats_status (estream_t fp,
|
||||
const char *validity;
|
||||
unsigned long messages;
|
||||
|
||||
/* Use the euclidean distance rather then the sum of the magnitudes
|
||||
to ensure a balance between verified signatures and encrypted
|
||||
messages. */
|
||||
messages = sqrtu32 (signature_count) + sqrtu32 (encryption_count);
|
||||
/* 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
|
||||
verified signatures and encrypted messages. */
|
||||
messages = sqrtu32 (signature_count * signature_count
|
||||
+ encryption_count * encryption_count);
|
||||
|
||||
if (messages < 1)
|
||||
validity = "1"; /* Key without history. */
|
||||
else if (messages < sqrtu32 (2 * BASIC_TRUST_THRESHOLD))
|
||||
else if (messages < 2 * BASIC_TRUST_THRESHOLD)
|
||||
validity = "2"; /* Key with too little history. */
|
||||
else if (messages < sqrtu32 (2 * FULL_TRUST_THRESHOLD))
|
||||
else if (messages < 2 * FULL_TRUST_THRESHOLD)
|
||||
validity = "3"; /* Key with enough history for basic trust. */
|
||||
else
|
||||
validity = "4"; /* Key with a lot of history. */
|
||||
@ -2758,8 +2759,9 @@ show_statistics (tofu_dbs_t dbs, const char *fingerprint,
|
||||
" one message to this key and user id!\n"));
|
||||
|
||||
/* Cf. write_stats_status */
|
||||
if (sqrtu32 (encryption_count) + sqrtu32 (signature_count)
|
||||
< sqrtu32 (2 * BASIC_TRUST_THRESHOLD))
|
||||
if (sqrtu32 (encryption_count * encryption_count
|
||||
+ signature_count * signature_count)
|
||||
< 2 * BASIC_TRUST_THRESHOLD)
|
||||
show_warning = 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user