summaryrefslogtreecommitdiff
path: root/rpmio/tax.c
blob: 9c2f5a9bb3838c5acdd976f3f7dc17f3ef261a62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "system.h"
                                                                                
#include <beecrypt/base64.h>
#include <beecrypt/mpbarrett.h>
#include <beecrypt/mp.h>
#include <popt.h>

#include "debug.h"

const char * applechallenge = "09KF45soMYmvj6dpsUGiIg==";

#if 1
const char * rsaaeskey = "\
5QYIqmdZGTONY5SHjEJrqAhaa0W9wzDC5i6q221mdGZJ5ubO6Kg\
yhC6U83wpY87TFdPRdfPQl2kVC7+Uefmx1bXdIUo07ZcJsqMbgtje4w2JQw0b\
Uw2BlzNPmVGQOxfdpGc3LXZzNE0jI1D4conUEiW6rrzikXBhk7Y/i2naw13ayy\
xaSwtkiJ0ltBQGYGErbV2tx43QSNj7O0JIG9GrF2GZZ6/UHo4VH+ZXgQ4NZvP/\
QXPCsLutZsvusFDzIEq7TN1fveINOiwrzlN+bckEixvhXlvoQTWE2tjbmQYhMvO\
FIly5gNbZiXi0l5AdolX4jDC2vndFHqWDks/3sPikNg==\
";
#else
const char * rsaaeskey = "5QYIqmdZGTONY5SHjEJrqAhaa0W9wzDC5i6q221mdGZJ5ubO6KgyhC6U83wpY87TFdPRdfPQl2kVC7+Uefmx1bXdIUo07ZcJsqMbgtje4w2JQw0bUw2BlzNPmVGQOxfdpGc3LXZzNE0jI1D4conUEiW6rrzikXBhk7Y/i2naw13ayyxaSwtkiJ0ltBQGYGErbV2tx43QSNj7O0JIG9GrF2GZZ6/UHo4VH+ZXgQ4NZvP/QXPCsLutZsvusFDzIEq7TN1fveINOiwrzlN+bckEixvhXlvoQTWE2tjbmQYhMvOFIly5gNbZiXi0l5AdolX4jDC2vndFHqWDks/3sPikNg==";
#endif

const char * aesiv = "zcZmAZtqh7uGcEwPXk0QeA==";

const char * appleresponse = "\
u+msU8Cc7KBrVPjI/Ir8fOL8+C5D3Jsw1+acaW3MNTndrTQAeb/a\
5m10UVBX6wb/DYQGY+b28ksSwBjN0nFOk4Y2cODEf83FAh7B\
mkLpmpkpplp7zVXQ+Z9DcB6gC60ZsS3t98aoR7tSzVLKZNgi2X2sC+vGsz\
utQxX03HK008VjcdngHv3g1p2knoETd07T6eVfZCmPqp6Ga7Dj8VIIj/GEP3\
AjjDx3lJnQBXUDmxM484YXLXZjWFXCiY8GJt6whjf7/2c3rIoT3Z7PQpEvPmM\
1MXU9cv4NL59Y/q0OAVQ38foOz7eGAhfvjOsCnHU25aik7/7ToIYt1tyVtap/kA==\
";

/**
 * Convert to hex.
 * @param t		target buffer (returned)
 * @param s		source bytes
 * @param nbytes	no. of bytes
 * @return		target buffer
 */
static inline
char * pgpHexCvt(char *t, const byte *s, int nbytes)
{
    static char hex[] = "0123456789abcdef";
    while (nbytes-- > 0) {
	unsigned int i;
	i = *s++;
	*t++ = hex[ (i >> 4) & 0xf ];
	*t++ = hex[ (i     ) & 0xf ];
    }
    *t = '\0';
    return t;
}

/**
 * Return hex formatted representation of bytes.
 * @todo Remove static buffer. 
 * @param p		bytes
 * @param plen		no. of bytes
 * @return		hex formatted string
 */
static inline
char * pgpHexStr(const byte *p, unsigned int plen)
{
    static char prbuf[2048];
    char *t = prbuf;
    t = pgpHexCvt(t, p, plen);
    return prbuf;
}

static int doit(const char * msg, const char * sig)
{
    unsigned char * dec;
    size_t declen;
    int rc;

    if ((rc = b64decode(sig, (void **)&dec, &declen)) != 0) {
	fprintf(stderr, "*** b64decode returns %d\n", rc);
	return rc;
    }

    fprintf(stderr, "*** %p[%d] %s\n", dec, declen, msg);
    if (declen == 256) {
	fprintf(stderr, "%s\n", pgpHexStr(dec, declen/2));
	fprintf(stderr, "%s\n", pgpHexStr(dec+declen/2, declen/2));
    } else {
	fprintf(stderr, "%s\n", pgpHexStr(dec, declen));
    }

    return 0;

}

int
main (int argc, char *argv[])
{

    doit("applechallenge", applechallenge);
    doit("rsaaeskey", rsaaeskey);
    doit("aesiv", aesiv);
    doit("appleresponse", appleresponse);
}