comparison miscprog/pircksum.c @ 181:bf4286245c74

Pirelli's RF calibration cracked
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 13 Jul 2014 01:11:22 +0000
parents
children
comparison
equal deleted inserted replaced
180:25b54c5ad6c2 181:bf4286245c74
1 /*
2 * This program has been used to verify and refine my understanding of the
3 * checksum scheme used for Pirelli's RF calibration data.
4 */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 main(argc, argv)
11 char **argv;
12 {
13 FILE *f;
14 u_long offset, len;
15 u_char inb, accum;
16
17 if (argc != 4) {
18 fprintf(stderr, "usage: %s fact.bin offset len\n", argv[0]);
19 exit(1);
20 }
21 f = fopen(argv[1], "r");
22 if (!f) {
23 perror(argv[1]);
24 exit(1);
25 }
26 offset = strtoul(argv[2], 0, 16);
27 len = strtoul(argv[3], 0, 16);
28 fseek(f, offset, SEEK_SET);
29 for (accum = 0; len; len--) {
30 inb = getc(f);
31 accum += inb;
32 }
33 inb = getc(f);
34 printf("Computed cksum %02X, following byte %02X\n", accum, inb);
35 exit(0);
36 }