pgp_sequoia: Improve tracing output sync
authorNeal H. Walfield <neal@pep.foundation>
Tue, 09 Jul 2019 10:26:17 +0200
branchsync
changeset 39077c8cdcdd8a34
parent 3905 1d3c2c487980
child 3909 40a5093a5f04
child 3910 1e9cd9e6cd29
pgp_sequoia: Improve tracing output

- When verifying a detached signature output information about the
text's size and the number of crlfs, crs and lfs.
src/pgp_sequoia.c
     1.1 --- a/src/pgp_sequoia.c	Mon Jul 08 12:31:47 2019 +0200
     1.2 +++ b/src/pgp_sequoia.c	Tue Jul 09 10:26:17 2019 +0200
     1.3 @@ -1447,6 +1447,33 @@
     1.4      if (size == 0 || sig_size == 0)
     1.5          return PEP_DECRYPT_WRONG_FORMAT;
     1.6  
     1.7 +#if TRACING > 0
     1.8 +    {
     1.9 +        int cr = 0;
    1.10 +        int crlf = 0;
    1.11 +        int lf = 0;
    1.12 +
    1.13 +        for (int i = 0; i < size; i ++) {
    1.14 +            // CR
    1.15 +            if (text[i] == '\r') {
    1.16 +                cr ++;
    1.17 +            }
    1.18 +            // LF
    1.19 +            if (text[i] == '\n') {
    1.20 +                if (i > 0 && text[i - 1] == '\r') {
    1.21 +                    cr --;
    1.22 +                    crlf ++;
    1.23 +                } else {
    1.24 +                    lf ++;
    1.25 +                }
    1.26 +            }
    1.27 +        }
    1.28 +
    1.29 +        T("Text to verify: %zd bytes with %d crlfs, %d bare crs and %d bare lfs",
    1.30 +          size, crlf, cr, lf);
    1.31 +    }
    1.32 +#endif
    1.33 +
    1.34      cookie.recipient_keylist = new_stringlist(NULL);
    1.35      if (!cookie.recipient_keylist)
    1.36          ERROR_OUT(NULL, PEP_OUT_OF_MEMORY, "out of memory");