Core not accepting new private key

Hi
my Core does not accept a new private key:

$sudo dfu-util -d 1d50:607f -a 1 -s 0x00002000 -v -D core_private.der
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Filter on vendor = 0x1d50 product = 0x607f
Opening DFU capable USB device… ID 1d50:607f
Run-time device DFU version 011a
Found DFU: [1d50:607f] devnum=0, cfg=1, intf=0, alt=1, name="@SPI Flash : SST25x/0x00000000/512*04Kg"
Claiming USB DFU Interface…
Setting Alternate Setting #1
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
No valid DFU suffix signature
Warning: File has no DFU suffix
DfuSe interface name: "SPI Flash : SST25x"
Memory segment at 0x00000000 512 x 4096 = 2097152 (rew)
Downloading to address = 0x00002000, size = 610
Poll timeout 50 ms
Error during second get_status
state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was

I am running Mac OS X and I have a Spark with an chip antenna. After booting the Core flashes cyan and red in a mixing mode. I hope you can help me.
Lukas

Do you have spark-cli installed? It might be easier to repair a core’s key.

The funny thing is that (if i remembered correctly), the key needs to be of even bytes for the filesize.

You can attempt to generate a key again till you get a even filesize before flashing to the core :wink:

1 Like

Yes I have spark-cli installed. When I run spark keys doctor I get the following output:

$ spark keys doctor 55ff6a065075555344121787
FOUND DFU DEVICE 1d50:607f
running openssl genrsa -out 55ff6a065075555344121787_new.pem 1024
running openssl rsa -in 55ff6a065075555344121787_new.pem -pubout -out 55ff6a065075555344121787_new.pub.pem
running openssl rsa -in 55ff6a065075555344121787_new.pem -outform DER -out 55ff6a065075555344121787_new.der
New Key Created!
FOUND DFU DEVICE 1d50:607f
FOUND DFU DEVICE 1d50:607f
running dfu-util -d 1d50:607f -a 1 -s 0x00002000:1024 -U pre_55ff6a065075555344121787_new.der
running openssl rsa -in pre_55ff6a065075555344121787_new.der -inform DER -pubout -out pre_55ff6a065075555344121787_new.pub.pem
Error saving key… Error: Command failed: unable to load Private Key
140735159190352:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:150:

Error saving key… Error: Command failed: unable to load Private Key
140735159190352:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:150:

Make sure your core is in DFU mode (blinking yellow), and that your computer is online.
Error - Error: Command failed: unable to load Private Key
140735159190352:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:150:

What is your spark --version?

My spark --version is 0.3.9

Can you try to do a sudo npm update -g spark-cli?

Also, perform spark keys doctor core_id in a directory like Desktop for example in the Terminal…

I updated spark-cli succesfully. My spark version is now 0.3.95.
From spark keys server 55ff6a065075555344121787 I get:

Please specify a server key in DER format.

Opps sorry… It should be spark keys doctor core_id

The same error again:

$ spark keys doctor 55ff6a065075555344121787
FOUND DFU DEVICE 1d50:607f
running openssl genrsa -out 55ff6a065075555344121787_new.pem 1024
running openssl rsa -in 55ff6a065075555344121787_new.pem -pubout -out 55ff6a065075555344121787_new.pub.pem
running openssl rsa -in 55ff6a065075555344121787_new.pem -outform DER -out 55ff6a065075555344121787_new.der
New Key Created!
FOUND DFU DEVICE 1d50:607f
FOUND DFU DEVICE 1d50:607f
running dfu-util -d 1d50:607f -a 1 -s 0x00002000:1024 -U pre_55ff6a065075555344121787_new.der
running openssl rsa -in pre_55ff6a065075555344121787_new.der -inform DER -pubout -out pre_55ff6a065075555344121787_new.pub.pem
Error saving key… Error: Command failed: unable to load Private Key
140735159190352:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:150:

Error saving key… Error: Command failed: unable to load Private Key
140735159190352:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:150:

Make sure your core is in DFU mode (blinking yellow), and that your computer is online.
Error - Error: Command failed: unable to load Private Key
140735159190352:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:150:

Hmmm… It seems like an OpenSSL issue… Are you on Mac OSx 10.9 or earlier?

Might want to update OpenSSL and try again for that matter…

I installed (again) and updated openssl with homebrew, but I am still getting the same error.
I have now openssl-1.0.1h and I am running OS X Yosemite Beta :), but also tried the whole thing before the update.
Any suggestions?

Thanks for your help

Lukas

Hi @Lukas,

I’m not sure why, but it looks like your copy of OpenSSL is generating bad keys? I’ll try sending you a key, and can you load it with:

spark keys load core.der
spark keys send 55ff6a065075555344121787 core.pub.pem

Thanks,
David

Hi @Dave,

I got your keys, but when I tried to load them I still got the same error:

$ dfu-util -d 1d50:607f -a 1 -s 0x00002000:leave -v -D core.der
[...]
Error saving key… Error: Command failed: unable to load Private Key
140735161660240:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:150:

Lukas

Hi Lukas,

Hmm… Looks like the ‘save’ command is trying to convert your key into a usable format and failing, maybe try the dfu command directly:

dfu-util -d 1d50:607f -a 1 -s 0x00002000:leave -v -D core.der
spark keys send 55ff6a065075555344121787 core.pub.pem

Thanks,
David

Hi Dave

I tried

dfu-util -d 1d50:607f -a 1 -s 0x00002000:leave -v -D core.der

, but I got an dfuERROR:

$ dfu-util -d 1d50:607f -a 1 -s 0x00002000:leave -v -D core.der
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Filter on vendor = 0x1d50 product = 0x607f
Opening DFU capable USB device... ID 1d50:607f
Run-time device DFU version 011a
Found DFU: [1d50:607f] devnum=0, cfg=1, intf=0, alt=1, name="@SPI Flash : SST25x/0x00000000/512*04Kg"
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
No valid DFU suffix signature
Warning: File has no DFU suffix
DfuSe interface name: "SPI Flash : SST25x"
Memory segment at 0x00000000 512 x 4096 = 2097152 (rew)
Downloading to address = 0x00002000, size = 609
   Poll timeout 50 ms
Error during second get_status
state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was

Thanks for your support up to now

Lukas

Hi Dave

I now also tried the whole key refreshing out with another computer(Mac). I still got the same error.

Lukas

Hmmm…

I wonder if maybe there is an issue with your external flash, can you try writing some other things and see how those do?

spark flash --factory tinker

Hi Dave

I tried spark flash --factory tinker and got the following output. Seems to be the same error:

    $ spark flash --factory tinker
FOUND DFU DEVICE 1d50:607f
checking file  /usr/local/lib/node_modules/spark-cli/binaries/spark_tinker.bin
spawning dfu-util -d 1d50:607f -a 1 -i 0 -s 0x00020000 -D /usr/local/lib/node_modules/spark-cli/binaries/spark_tinker.bin
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Filter on vendor = 0x1d50 product = 0x607f
Opening DFU capable USB device... ID 1d50:607f
Run-time device DFU version 011a
Found DFU: [1d50:607f] devnum=0, cfg=1, intf=0, alt=1, name="@SPI Flash : SST25x/0x00000000/512*04Kg"
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
No valid DFU suffix signature
Warning: File has no DFU suffix
DfuSe interface name: "SPI Flash : SST25x"
Downloading to address = 0x00020000, size = 78828
Error during second get_status
state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was
Error writing firmware... 

Lukas

Hi Dave

I got an antenna for my second core just today. It works as expected! I got it to work with the basic blink application. I now measured the temperature of my first core (the one with the problem and the chip antenna) and got a result of up to 62°C. Could it be a hardware problem? I also can´t do a firmware reset (green blinking forever).

Lukas

Hi Lukas,

Try this same command on your “good” Core, don’t worry it shouldn’t hurt it. It just updates the factory firmware in serial flash:

spark flash --factory tinker

If that works, then also try spark flash --usb tinker on the “bad” Core in DFU mode and if that works we can safely say the “bad” Core has a serial flash memory issue.