comparison utils/fcsim1-mkprov.c @ 93:6041c601304d

fcsim1-mkprov: revert OTA key addition It appears that GrcardSIM2 cards (which is what we got for FCSIM1) do not support OTA after all, contrary to what we were previously led to believe by some tech support emails from Grcard - apparently those support emails and OTA descriptions referred to some other card model(s).
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 21 Apr 2021 05:38:39 +0000
parents 28fae57b3e29
children
comparison
equal deleted inserted replaced
92:5560261fc516 93:6041c601304d
91 goto usage; 91 goto usage;
92 set_iccid(argv[optind]); 92 set_iccid(argv[optind]);
93 set_imsi(argv[optind+1]); 93 set_imsi(argv[optind+1]);
94 } 94 }
95 95
96 static unsigned
97 make_odd_parity(byte)
98 unsigned byte;
99 {
100 unsigned mask, p;
101
102 p = 0;
103 for (mask = 0x80; mask; mask >>= 1)
104 if (byte & mask)
105 p = !p;
106 if (!p)
107 byte ^= 0x01;
108 return byte;
109 }
110
111 static void 96 static void
112 get_random_key(strbuf, oddpar) 97 get_random_ki(strbuf)
113 char *strbuf; 98 char *strbuf;
114 { 99 {
115 u_char bin[16]; 100 u_char bin[16];
116 char *dp; 101 char *dp;
117 unsigned n; 102 unsigned n;
119 104
120 rc = read(random_fd, bin, 16); 105 rc = read(random_fd, bin, 16);
121 if (rc != 16) { 106 if (rc != 16) {
122 fprintf(stderr, "error reading from %s\n", random_file); 107 fprintf(stderr, "error reading from %s\n", random_file);
123 exit(1); 108 exit(1);
124 }
125 if (oddpar) {
126 for (n = 0; n < 16; n++)
127 bin[n] = make_odd_parity(bin[n]);
128 } 109 }
129 dp = strbuf; 110 dp = strbuf;
130 for (n = 0; n < 16; n++) { 111 for (n = 0; n < 16; n++) {
131 sprintf(dp, "%02X", bin[n]); 112 sprintf(dp, "%02X", bin[n]);
132 dp += 2; 113 dp += 2;
137 static void 118 static void
138 make_one_card() 119 make_one_card()
139 { 120 {
140 unsigned acc_mask; 121 unsigned acc_mask;
141 char iccid_str[20], imsi_str[16], ki_str[33]; 122 char iccid_str[20], imsi_str[16], ki_str[33];
142 char msisdn_str[21], otac_str[33], otad_str[33]; 123 char msisdn_str[21];
143 124
144 nibbles_to_ascii(iccid_bin, 19, iccid_str); 125 nibbles_to_ascii(iccid_bin, 19, iccid_str);
145 nibbles_to_ascii(imsi_bin, 15, imsi_str); 126 nibbles_to_ascii(imsi_bin, 15, imsi_str);
146 acc_mask = 1 << access_class; 127 acc_mask = 1 << access_class;
147 get_random_key(ki_str, 0); 128 get_random_ki(ki_str);
148 get_random_key(otac_str, 1); 129 printf("ICCID=%s IMSI=%s ACC=%04X Ki=%s", iccid_str, imsi_str,
149 get_random_key(otad_str, 1); 130 acc_mask, ki_str);
150 printf("ICCID=%s IMSI=%s ACC=%04X Ki=%s OTA_C=%s OTA_D=%s", iccid_str,
151 imsi_str, acc_mask, ki_str, otac_str, otad_str);
152 if (msisdn_set) { 131 if (msisdn_set) {
153 fputs(" MSISDN=", stdout); 132 fputs(" MSISDN=", stdout);
154 if (msisdn_plus) 133 if (msisdn_plus)
155 putchar('+'); 134 putchar('+');
156 nibbles_to_ascii(msisdn_bin, msisdn_digits, msisdn_str); 135 nibbles_to_ascii(msisdn_bin, msisdn_digits, msisdn_str);