Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix wrong dongle_id check. Add define (DEBUG) to save dongle_id, jig_…

…response and jig_challenge.
  • Loading branch information...
commit bafad614569647276c166c491c292932c6721971 1 parent c6fffc8
Álvaro Fernández Rojas authored

Showing 3 changed files with 44 additions and 18 deletions. Show diff stats Hide diff stats

  1. +26 0 Makefile
  2. +17 16 main.c
  3. +1 2  usb_desc.h
26 Makefile
@@ -4,6 +4,7 @@ CCS_FLAGS_NBL = +FH +Y9 -T -L -E -M -P -J -D -A
4 4 CCS_FLAGS_WBLHID = $(CCS_FLAGS_NBL) +GWBOOTLOADERHID="true"
5 5 CCS_FLAGS_WBLMCHP = $(CCS_FLAGS_NBL) +GWBOOTLOADERMCHP="true"
6 6 CCS_FLAGS_LEDS = +GLEDR1="PIN_B4" +GLEDR2="PIN_B1" +GLEDR3="PIN_C0" +GLEDG1="PIN_B5" +GLEDG2="PIN_C1"
  7 +CCS_FLAGS_DEBUG = +GDEBUG="true"
7 8 ZIP = zip -r
8 9 BUILD_DIR = build
9 10 CLEAN_FILES = *.err *.esym *.cod *.sym *.hex *.lst *.zip $(BUILD_DIR)
@@ -35,6 +36,31 @@ all:
35 36 mv build/PSGradePIC_$(VERSION).zip ./
36 37 rm -f -r $(BUILD_DIR)
37 38
  39 +debug:
  40 + #HEX with HID Bootloader.
  41 + $(CCS_COMPILER) $(CCS_FLAGS_WBLHID) $(CCS_FLAGS_LEDS) $(CCS_SOURCE) $(CCS_FLAGS_DEBUG)
  42 +
  43 + #HEX with MCHP Bootloader.
  44 + $(CCS_COMPILER) $(CCS_FLAGS_WBLMCHP) $(CCS_FLAGS_LEDS) $(CCS_SOURCE) $(CCS_FLAGS_DEBUG)
  45 +
  46 + #HEX without Bootloader.
  47 + $(CCS_COMPILER) $(CCS_FLAGS_NBL) $(CCS_FLAGS_LEDS) $(CCS_SOURCE) $(CCS_FLAGS_DEBUG)
  48 +
  49 + #Create build structure.
  50 + rm -f -r $(BUILD_DIR)
  51 + mkdir $(BUILD_DIR);
  52 +
  53 + #Fix MCHP Bootloader
  54 + sed -i '1i :020000040000FA..' PSGradePIC*_wBTL_MCHP.hex
  55 +
  56 + #Move each payload to its directory.
  57 + mv PSGradePIC*.hex $(BUILD_DIR);
  58 +
  59 + #Zip all HEX.
  60 + cd $(BUILD_DIR) && $(ZIP) "PSGradePIC_$(VERSION)_DEBUG" *
  61 + mv build/PSGradePIC_$(VERSION)_DEBUG.zip ./
  62 + rm -f -r $(BUILD_DIR)
  63 +
38 64 clean:
39 65 #Clean files.
40 66 rm -f -r $(CLEAN_FILES)
33 main.c
@@ -262,7 +262,7 @@ void main() {
262 262 //Check dongle_id. If it should be revoked a new one is generated.
263 263 int i;
264 264 for(i = 0; i < sizeof(usb_dongle_revoke_list); i++) {
265   - if(usb_dongle_revoke_list[i] == (((dongle_id[0] << 8) & 0xFF) & (dongle_id[1] & 0xFF)) ) {
  265 + if(usb_dongle_revoke_list[i] == (((dongle_id[0] << 8) & 0xFF00) ^ (dongle_id[1] & 0xFF)) ) {
266 266 i = 0;
267 267 dongle_id[0] = rand();
268 268 dongle_id[1] = rand();
@@ -286,27 +286,28 @@ void main() {
286 286 HMACDone();
287 287 SHA1MemCpy(usb_dongle_key, SHA1_DIGESTSIZE);
288 288
289   - //Uncomment this to save the usb_dongle_key for the random dongle_id generated (EEPROM). Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
290   - /*
  289 + //Generate jig_response.
  290 + HMACInit(usb_dongle_key, SHA1_DIGESTSIZE);
  291 + HMACBlock(jig_challenge + JIG_DATA_HEADER_LEN, SHA1_DIGESTSIZE);
  292 + HMACDone();
  293 + SHA1MemCpy(jig_response + JIG_DATA_HEADER_LEN + sizeof(dongle_id), SHA1_DIGESTSIZE);
  294 +
  295 + #if defined (DEBUG)
  296 + //Save the usb_dongle_key for the random dongle_id generated (EEPROM). Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
291 297 write_eeprom(0x00, dongle_id[0]);
292 298 write_eeprom(0x01, dongle_id[1]);
293 299 for(i = 0; i < sizeof(usb_dongle_key); i++) {
294   - write_eeprom(0x10 + i, usb_dongle_key[i]);
  300 + write_eeprom(0x20 + i, usb_dongle_key[i]);
295 301 }
296   - */
297   -
298   - //Uncomment this to save the jig_challenge generated by the PS3. Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
299   - /*
  302 + //Save the jig_challenge generated by the PS3. Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
300 303 for(i = 0; i < sizeof(jig_challenge); i++) {
301   - write_eeprom(0x30 + i, jig_challenge[i]);
  304 + write_eeprom(0x50 + i, jig_challenge[i]);
302 305 }
303   - */
304   -
305   - //Generate jig_response.
306   - HMACInit(usb_dongle_key, SHA1_DIGESTSIZE);
307   - HMACBlock(jig_challenge + JIG_DATA_HEADER_LEN, SHA1_DIGESTSIZE);
308   - HMACDone();
309   - SHA1MemCpy(jig_response + JIG_DATA_HEADER_LEN + sizeof(dongle_id), SHA1_DIGESTSIZE);
  306 + //Save the jig_response generated by the dongle. Only for dev purposes :). Use USB HID Bootloader 2.6b Read funcntion to dump EEPROM.
  307 + for(i = 0; i < sizeof(jig_response); i++) {
  308 + write_eeprom(0xA0 + i, jig_response[i]);
  309 + }
  310 + #endif
310 311
311 312 nJigs = 0;
312 313 WaitJig = 2;
3  usb_desc.h
@@ -14,7 +14,6 @@
14 14 const unsigned int8 USB_DEVICE_DESC[] = {
15 15 //HUB_DEVICE
16 16 0x12, 0x01, 0x00, 0x02, 0x09, 0x00, 0x01, 0x08,
17   - //0xe3, 0x05, 0x08, 0x06, 0x64, 0x77, 0x00, 0x01,
18 17 0xAA, 0xAA, 0xCC, 0xCC, 0x00, 0x01, 0x00, 0x00,
19 18 0x00, 0x01,
20 19 //HUB_HUB_DEVICE
@@ -63,7 +62,7 @@ static unsigned int8 jig_response[64];
63 62 #define PORT5_DEVICE_SIZE 0x0012
64 63
65 64 #define HUB_DEVICE_OFFSET 0x0000
66   -#define HUB_HUB_DEVICE_OFFSET HUB_DEVICE_SIZE
  65 +#define HUB_HUB_DEVICE_OFFSET HUB_DEVICE_SIZE
67 66 #define PORT5_DEVICE_OFFSET HUB_HUB_DEVICE_OFFSET + HUB_HUB_DEVICE_SIZE
68 67
69 68 #define HUB_CONFIG_SIZE 0x0019

0 comments on commit bafad61

Please sign in to comment.
Something went wrong with that request. Please try again.