source: mod_gnutls/test/pgpcrc.c @ 42829ae

debian/masterdebian/stretch-backportsjessie-backportsupstream
Last change on this file since 42829ae was d70dd6e, checked in by Thomas Klute <thomas2.klute@…>, 4 years ago

ensure cleanup of gpg v2.1 keyrings as well

depending on the version of gpg, the choices of secret keyrings, and
the behavior when exporting secret key material is different.

for example, see https://bugs.gnupg.org/gnupg/issue2324, and the fact
that secret keys are stored in different locations.

This change allows the test suite to work with all known major
versions of GnuPG.

  • Property mode set to 100644
File size: 827 bytes
Line 
1#include <unistd.h>
2#include <arpa/inet.h>
3
4/* from RFC 4880 section 6.1 */
5#define CRC24_INIT 0xB704CEL
6#define CRC24_POLY 0x1864CFBL
7
8typedef long crc24;
9crc24 crc_octets(unsigned char *octets, size_t len)
10{
11    crc24 crc = CRC24_INIT;
12    int i;
13    while (len--) {
14        crc ^= (*octets++) << 16;
15        for (i = 0; i < 8; i++) {
16            crc <<= 1;
17            if (crc & 0x1000000)
18                crc ^= CRC24_POLY;
19        }
20    }
21    return crc & 0xFFFFFFL;
22}
23
24
25int main()
26{
27    crc24 output;
28    int i = 0;
29    unsigned char o;
30    unsigned char indata[100000];
31    ssize_t rr = read(0, indata, sizeof(indata));
32    if (rr <= 0)
33        return 1;
34    output = crc_octets(indata, rr);
35    for (i = 2; i >= 0; i--) {
36        o = ((output >> (8 * i)) & 0xff);
37        write(1, &o, sizeof(o));
38    }
39    return 0;
40}
Note: See TracBrowser for help on using the repository browser.