Skip to content

Commit af70717

Browse files
smaillet-msmortezag
authored andcommittedSep 14, 2015
- adding in support for legacy crypto, which was removed previously. Turns out it is still needed by TinyBooter/mfdeploy for firmware signature checks as a small footprint crypto lib.
- added default keys for signing. Users should create their own keys for security but providing a key prevents errors from hitting the build until they get to understanding that phase of things.
1 parent 7e18234 commit af70717

10 files changed

+45
-12
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
[Oo]bj/
3131
ipch/
3232

33+
!/tools/bin/
34+
3335
#uVision
3436
*.uvguix*
3537
Listings/
@@ -39,3 +41,4 @@ Listings/
3941
/DeviceCode/Targets/OS/Win32/DeviceCode/WinPcap_Eth/Dependencies/WpdPack/
4042

4143
*.axfdump
44+
/crypto/lib

‎crypto/dotNetMF.proj

+19-12
Original file line numberDiff line numberDiff line change
@@ -52,39 +52,46 @@
5252
<CryptoStub Condition="'$(PLATFORM_FAMILY)'=='SHC'" >true</CryptoStub>
5353
<CryptoStub Condition="'$(COMPILER_TOOL)' =='GCCOP'" >true</CryptoStub>
5454

55+
<!--
56+
Force thumb2fp to use the same lib as thumb2 (There's no floating point code in the crypto libs)
57+
so this saves replicating the libs into another directory for the instruction set and then again
58+
for the tool chain.
59+
-->
60+
<CryptoInstructionSet Condition="'$(INSTRUCTION_SET)'=='thumb2fp'">thumb2</CryptoInstructionSet>
61+
<CryptoInstructionSet Condition="'$(INSTRUCTION_SET)'!='thumb2fp'">$(INSTRUCTION_SET)</CryptoInstructionSet>
5562
<CustomTargets Condition="'$(CryptoStub)'=='false'">CryptoLib</CustomTargets>
56-
<CustomTargets Condition="'$(INSTRUCTION_SET)'=='x86'">CryptoLibX86</CustomTargets>
63+
<CustomTargets Condition="'$(CryptoInstructionSet)'=='x86'">CryptoLibX86</CustomTargets>
5764
</PropertyGroup>
5865

5966

60-
<PropertyGroup Condition="'$(INSTRUCTION_SET)'!='x86'">
61-
<LibSrc >lib\$(INSTRUCTION_SET)\$(DOTNETMF_COMPILER)\crypto.$(LIB_EXT)</LibSrc>
62-
<LibSrc Condition="'$(COMPILER_TOOL)'=='ARM' AND !EXISTS('$(LibSrc)')" >lib\$(INSTRUCTION_SET)\RVDS4.0\crypto.$(LIB_EXT)</LibSrc>
63-
<LibSrc Condition="'$(COMPILER_TOOL)'=='GCC'" >lib\$(INSTRUCTION_SET)\RVDS3.1\crypto.$(LIB_EXT)</LibSrc>
64-
<LibSrc Condition="'$(COMPILER_TOOL)'=='ARC'" >lib\$(INSTRUCTION_SET)\MTWR8.0\crypto.$(LIB_EXT)</LibSrc>
67+
<PropertyGroup Condition="'$(CryptoInstructionSet)'!='x86'">
68+
<LibSrc >lib\$(CryptoInstructionSet)\$(DOTNETMF_COMPILER)\crypto.$(LIB_EXT)</LibSrc>
69+
<LibSrc Condition="'$(COMPILER_TOOL)'=='ARM' AND !EXISTS('$(LibSrc)')" >lib\$(CryptoInstructionSet)\RVDS4.0\crypto.$(LIB_EXT)</LibSrc>
70+
<LibSrc Condition="'$(COMPILER_TOOL)'=='GCC'" >lib\$(CryptoInstructionSet)\RVDS3.1\crypto.$(LIB_EXT)</LibSrc>
71+
<LibSrc Condition="'$(COMPILER_TOOL)'=='ARC'" >lib\$(CryptoInstructionSet)\MTWR8.0\crypto.$(LIB_EXT)</LibSrc>
6572
<LibSrc Condition="!EXISTS('$(LibSrc)')" >$(LIB_DIR)\crypto_stub.$(LIB_EXT)</LibSrc>
6673
<LibTo>crypto.$(LIB_EXT)</LibTo>
6774
</PropertyGroup>
6875

69-
<ItemGroup Condition="'$(INSTRUCTION_SET)'=='x86'">
70-
<LibFiles Include="lib\$(INSTRUCTION_SET)\crypto.lib" Condition="EXISTS('lib\$(INSTRUCTION_SET)\crypto.lib')">
76+
<ItemGroup Condition="'$(CryptoInstructionSet)'=='x86'">
77+
<LibFiles Include="lib\$(CryptoInstructionSet)\crypto.lib" Condition="EXISTS('lib\$(CryptoInstructionSet)\crypto.lib')">
7178
<DestFile>crypto.lib</DestFile>
7279
</LibFiles>
73-
<LibFiles Include="lib\$(INSTRUCTION_SET)\crypto.pdb" Condition="Exists('lib\$(INSTRUCTION_SET)\crypto.pdb')">
80+
<LibFiles Include="lib\$(CryptoInstructionSet)\crypto.pdb" Condition="Exists('lib\$(CryptoInstructionSet)\crypto.pdb')">
7481
<DestFile>crypto.pdb</DestFile>
7582
</LibFiles>
76-
<LibFiles Include="$(LIB_DIR)\crypto_stub.lib" Condition="!Exists('lib\$(INSTRUCTION_SET)\crypto.lib')">
83+
<LibFiles Include="$(LIB_DIR)\crypto_stub.lib" Condition="!Exists('lib\$(CryptoInstructionSet)\crypto.lib')">
7784
<DestFile>crypto.lib</DestFile>
7885
</LibFiles>
7986
</ItemGroup>
8087

8188
<Import Project="$(SPOCLIENT)\tools\targets\Microsoft.SPOT.System.Targets" />
8289

83-
<ItemGroup Condition="'$(INSTRUCTION_SET)'!='x86'">
90+
<ItemGroup Condition="'$(CryptoInstructionSet)'!='x86'">
8491
<ExtraCleanFiles Include="$(LIB_DIR)\$(LibTo)"/>
8592
</ItemGroup>
8693

87-
<ItemGroup Condition="'$(INSTRUCTION_SET)'=='x86'">
94+
<ItemGroup Condition="'$(CryptoInstructionSet)'=='x86'">
8895
<ExtraCleanFiles Include="@(LibFiles -> '$(LIB_DIR)\%(Filename)%(Extension)')" />
8996
</ItemGroup>
9097

‎setup/Features/Tools.wxs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<ComponentRef Id="Component_BuildHelper"/>
1212
<ComponentRef Id="Component_MFDeploy"/>
1313
<ComponentRef Id="Component_MFDeployEngine"/>
14+
<ComponentRef Id="Component_Crypto"/>
1415
<ComponentRef Id="COMPONENT_TRUETYPEFONTS"/>
1516
<ComponentRef Id="Component_ToolsDirectoryShortcut"/>
1617
<!--

‎setup/UnManagedAssemblies/build.dirproj

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
TinyCLR.wixproj;
88
TFConvert.wixproj;
99
BuildHelper.wixproj;
10+
Crypto.wixproj
1011
" />
1112
</ItemGroup>
1213

‎tools/bin/BLANK.KEY

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
<KeyPair xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<PrivateKey>//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8=</PrivateKey>
4+
<PublicKey>//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8=</PublicKey>
5+
</KeyPair>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
this is an example of how to use the signature facilities in the metadata processor to be uploaded to the device with the tinybooter
2+
the bin file must be signed and upload must use the hex file
3+
4+
the public key is heardcoded in the tinybooter and must match the private key
5+
6+
of course a decent Key management strategy generates the private key only once and does not keep it in the source tree
7+
8+
use the sign_file script to sign files after building them
9+
remember to sign the binary files and to upload the corresponding hex files
10+
if the signature files are placed in the same directory where the hex files are and if they have the same name plus the ".sig" extension, than FlashLiteClient will load the signature automatically
11+
12+
MetaDataProcessor.exe
13+
-dump_key tinybooter_public_key.bin
14+
-dump_key tinybooter_private_key.bin
15+
-sign_file %SPOCLIENT%_BUILD\arm\FLASH\release\AUXD\bin\tinyclr.bin\ER_DAT tinybooter_private_key.bin %SPOCLIENT%_BUILD\arm\FLASH\release\AUXD\bin\tinyclr.hex\ER_DAT.sig
16+
-verify_signature %SPOCLIENT%_BUILD\arm\FLASH\release\AUXD\bin\tinyclr.bin\ER_DAT tinybooter_public_key.bin %SPOCLIENT%_BUILD\arm\FLASH\release\AUXD\bin\tinyclr.hex\ER_DAT.sig

‎tools/bin/tinybooter_private_key.bin

260 Bytes
Binary file not shown.
260 Bytes
Binary file not shown.

‎tools/bin/tinybooter_public_key.bin

260 Bytes
Binary file not shown.

‎tools/bin/tinybooter_public_key_1.txt

260 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.