├── .gitattributes ├── .gitignore ├── LICENSE ├── Pkgs ├── Maven │ ├── DiceRIoTEmulator │ │ ├── DiceRIoTEmulator.iml │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── microsoft │ │ │ │ └── msr │ │ │ │ ├── DiceEmulator │ │ │ │ └── DICE.java │ │ │ │ └── RiotEmulator │ │ │ │ └── RIoT.java │ │ └── target │ │ │ ├── DiceRIoTEmulator-1.0-javadoc.jar │ │ │ ├── DiceRIoTEmulator-1.0-sources.jar │ │ │ ├── DiceRIoTEmulator-1.0.jar │ │ │ ├── apidocs │ │ │ ├── allclasses-frame.html │ │ │ ├── allclasses-noframe.html │ │ │ ├── com │ │ │ │ └── microsoft │ │ │ │ │ └── msr │ │ │ │ │ ├── DiceEmulator │ │ │ │ │ ├── DICE.html │ │ │ │ │ ├── class-use │ │ │ │ │ │ └── DICE.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ │ │ └── RiotEmulator │ │ │ │ │ ├── RIoT.DeviceAuthBundle.html │ │ │ │ │ ├── RIoT.html │ │ │ │ │ ├── class-use │ │ │ │ │ ├── RIoT.DeviceAuthBundle.html │ │ │ │ │ └── RIoT.html │ │ │ │ │ ├── package-frame.html │ │ │ │ │ ├── package-summary.html │ │ │ │ │ ├── package-tree.html │ │ │ │ │ └── package-use.html │ │ │ ├── constant-values.html │ │ │ ├── deprecated-list.html │ │ │ ├── help-doc.html │ │ │ ├── index-all.html │ │ │ ├── index.html │ │ │ ├── overview-frame.html │ │ │ ├── overview-summary.html │ │ │ ├── overview-tree.html │ │ │ ├── package-list │ │ │ ├── script.js │ │ │ └── stylesheet.css │ │ │ ├── classes │ │ │ └── com │ │ │ │ └── microsoft │ │ │ │ └── msr │ │ │ │ ├── DiceEmulator │ │ │ │ └── DICE.class │ │ │ │ └── RiotEmulator │ │ │ │ ├── RIoT$DeviceAuthBundle.class │ │ │ │ └── RIoT.class │ │ │ ├── javadoc-bundle-options │ │ │ ├── javadoc-options-javadoc-resources.xml │ │ │ └── package-list │ │ │ ├── maven-archiver │ │ │ └── pom.properties │ │ │ ├── maven-status │ │ │ └── maven-compiler-plugin │ │ │ │ ├── compile │ │ │ │ └── default-compile │ │ │ │ │ ├── createdFiles.lst │ │ │ │ │ └── inputFiles.lst │ │ │ │ └── testCompile │ │ │ │ └── default-testCompile │ │ │ │ └── inputFiles.lst │ │ │ ├── riot-1.0-SNAPSHOT-jar-with-dependencies.jar │ │ │ └── riot-1.0-SNAPSHOT.jar │ ├── README.txt │ └── Test │ │ ├── Test.iml │ │ ├── out │ │ └── production │ │ │ └── Test │ │ │ └── Emulator │ │ │ ├── Main$NulledTrustManager.class │ │ │ └── Main.class │ │ └── src │ │ └── Emulator │ │ └── Main.java ├── NuGet │ ├── DiceRiotEmulator │ │ ├── DiceRiotEmulator.sln │ │ └── DiceRiotEmulator │ │ │ ├── DiceRiotEmulator.1.0.0.nuspec │ │ │ ├── DiceRiotEmulator.csproj │ │ │ └── RiotEngine.cs │ ├── DiceRiotTst │ │ ├── drtester.sln │ │ └── drtester │ │ │ ├── Program.cs │ │ │ └── drtester.csproj │ └── README.txt └── npm │ └── README.txt ├── README.md ├── Reference ├── Makefile ├── RIoT │ ├── Makefile │ ├── RIoTCrypt │ │ ├── Makefile │ │ ├── RiotCrypt.c │ │ ├── aes.c │ │ ├── base64.c │ │ ├── bignum.c │ │ ├── derenc.c │ │ ├── ecdh.c │ │ ├── ecdsa.c │ │ ├── ecp.c │ │ ├── ecp_curves.c │ │ ├── hkdf.c │ │ ├── hmac_drbg.c │ │ ├── include │ │ │ ├── RiotCrypt.h │ │ │ ├── base64.h │ │ │ ├── derenc.h │ │ │ ├── mbedtls │ │ │ │ ├── aes.h │ │ │ │ ├── bignum.h │ │ │ │ ├── bn_mul.h │ │ │ │ ├── check_config.h │ │ │ │ ├── config.h │ │ │ │ ├── ecdh.h │ │ │ │ ├── ecdsa.h │ │ │ │ ├── ecp.h │ │ │ │ ├── ecp_internal.h │ │ │ │ ├── hkdf.h │ │ │ │ ├── hmac_drbg.h │ │ │ │ ├── md.h │ │ │ │ ├── md2.h │ │ │ │ ├── md4.h │ │ │ │ ├── md5.h │ │ │ │ ├── md_internal.h │ │ │ │ ├── platform.h │ │ │ │ ├── platform_util.h │ │ │ │ ├── ripemd160.h │ │ │ │ ├── sha1.h │ │ │ │ ├── sha256.h │ │ │ │ └── sha512.h │ │ │ └── x509bldr.h │ │ ├── md.c │ │ ├── platform_util.c │ │ ├── sha1.c │ │ ├── sha256.c │ │ └── x509bldr.c │ ├── RIoTester.c │ └── include │ │ └── RiotStatus.h ├── RIoTEmulator.c └── RIoTEmulator.h ├── SECURITY.md ├── Simulation ├── DICE RIoT.sln ├── DICE │ ├── DICE.vcxproj │ ├── DICE.vcxproj.filters │ ├── DiceCore.cpp │ ├── DiceSha256.c │ ├── DiceSha256.h │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h ├── FW │ ├── Loader.cpp │ ├── Loader.h │ ├── Loader.vcxproj │ ├── Loader.vcxproj.filters │ ├── dllmain.cpp │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h └── RIoT │ └── Core │ ├── RIoT.cpp │ ├── RIoT.h │ ├── RIoT.vcxproj │ ├── RIoT.vcxproj.filters │ ├── RIoTCrypt │ ├── Makefile │ ├── RiotCrypt.c │ ├── aes.c │ ├── base64.c │ ├── bignum.c │ ├── derenc.c │ ├── ecdh.c │ ├── ecdsa.c │ ├── ecp.c │ ├── ecp_curves.c │ ├── hkdf.c │ ├── hmac_drbg.c │ ├── include │ │ ├── RiotCrypt.h │ │ ├── base64.h │ │ ├── derenc.h │ │ ├── mbedtls │ │ │ ├── aes.h │ │ │ ├── bignum.h │ │ │ ├── bn_mul.h │ │ │ ├── check_config.h │ │ │ ├── config.h │ │ │ ├── ecdh.h │ │ │ ├── ecdsa.h │ │ │ ├── ecp.h │ │ │ ├── ecp_internal.h │ │ │ ├── hkdf.h │ │ │ ├── hmac_drbg.h │ │ │ ├── md.h │ │ │ ├── md2.h │ │ │ ├── md4.h │ │ │ ├── md5.h │ │ │ ├── md_internal.h │ │ │ ├── platform.h │ │ │ ├── platform_util.h │ │ │ ├── ripemd160.h │ │ │ ├── sha1.h │ │ │ ├── sha256.h │ │ │ └── sha512.h │ │ └── x509bldr.h │ ├── md.c │ ├── platform_util.c │ ├── sha1.c │ ├── sha256.c │ └── x509bldr.c │ ├── RIoTSim.h │ ├── RiotStatus.h │ ├── dllmain.cpp │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h └── Tools ├── DICETest ├── App.config ├── CertChecker.cs ├── ChainChecker.cs ├── DICETest.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── README.txt └── packages.config ├── Docs ├── Notes.txt └── RiotUtils.docx ├── README ├── RIoT ├── App.config ├── CertMaker.cs ├── ExtensionDecoder.cs ├── ExtensionDecoder2.cs ├── Helpers.cs ├── HttpsListener.cs ├── HubControl.cs ├── IoTDevice.cs ├── Main.cs ├── Properties │ └── AssemblyInfo.cs ├── RIoT.csproj ├── TLSClient.cs ├── TLSServer.cs ├── UpdateDemo.cs └── packages.config ├── RIoTDemo ├── App.config ├── DeviceStatus.Designer.cs ├── DeviceStatus.cs ├── DeviceStatus.resx ├── MainPage.Designer.cs ├── MainPage.cs ├── MainPage.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── RIoTDemo.csproj └── packages.config ├── RIoTUtils.sln └── TlsClient ├── ReadMe.txt ├── TlsClient.cpp ├── TlsClient.vcxproj ├── TlsClient.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # DICE test tools 5 | *.pem 6 | 7 | 8 | # User-specific files 9 | *.suo 10 | *.user 11 | *.userosscache 12 | *.sln.docstates 13 | 14 | # User-specific files (MonoDevelop/Xamarin Studio) 15 | *.userprefs 16 | 17 | # Build results 18 | [Dd]ebug/ 19 | [Dd]ebugPublic/ 20 | [Rr]elease/ 21 | [Rr]eleases/ 22 | x64/ 23 | x86/ 24 | bld/ 25 | [Bb]in/ 26 | [Oo]bj/ 27 | [Ll]og/ 28 | 29 | # Visual Studio 2015 cache/options directory 30 | .vs/ 31 | # Uncomment if you have tasks that create the project's static files in wwwroot 32 | #wwwroot/ 33 | 34 | # MSTest test Results 35 | [Tt]est[Rr]esult*/ 36 | [Bb]uild[Ll]og.* 37 | 38 | # NUNIT 39 | *.VisualState.xml 40 | TestResult.xml 41 | 42 | # Build Results of an ATL Project 43 | [Dd]ebugPS/ 44 | [Rr]eleasePS/ 45 | dlldata.c 46 | 47 | # DNX 48 | project.lock.json 49 | artifacts/ 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # NCrunch 117 | _NCrunch_* 118 | .*crunch*.local.xml 119 | nCrunchTemp_* 120 | 121 | # MightyMoose 122 | *.mm.* 123 | AutoTest.Net/ 124 | 125 | # Web workbench (sass) 126 | .sass-cache/ 127 | 128 | # Installshield output folder 129 | [Ee]xpress/ 130 | 131 | # DocProject is a documentation generator add-in 132 | DocProject/buildhelp/ 133 | DocProject/Help/*.HxT 134 | DocProject/Help/*.HxC 135 | DocProject/Help/*.hhc 136 | DocProject/Help/*.hhk 137 | DocProject/Help/*.hhp 138 | DocProject/Help/Html2 139 | DocProject/Help/html 140 | 141 | # Click-Once directory 142 | publish/ 143 | 144 | # Publish Web Output 145 | *.[Pp]ublish.xml 146 | *.azurePubxml 147 | # TODO: Comment the next line if you want to checkin your web deploy settings 148 | # but database connection strings (with potential passwords) will be unencrypted 149 | *.pubxml 150 | *.publishproj 151 | 152 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 153 | # checkin your Azure Web App publish settings, but sensitive information contained 154 | # in these scripts will be unencrypted 155 | PublishScripts/ 156 | 157 | # NuGet Packages 158 | *.nupkg 159 | # The packages folder can be ignored because of Package Restore 160 | **/packages/* 161 | # except build/, which is used as an MSBuild target. 162 | !**/packages/build/ 163 | # Uncomment if necessary however generally it will be regenerated when needed 164 | #!**/packages/repositories.config 165 | # NuGet v3's project.json files produces more ignoreable files 166 | *.nuget.props 167 | *.nuget.targets 168 | 169 | # Microsoft Azure Build Output 170 | csx/ 171 | *.build.csdef 172 | 173 | # Microsoft Azure Emulator 174 | ecf/ 175 | rcf/ 176 | 177 | # Windows Store app package directories and files 178 | AppPackages/ 179 | BundleArtifacts/ 180 | Package.StoreAssociation.xml 181 | _pkginfo.txt 182 | 183 | # Visual Studio cache files 184 | # files ending in .cache can be ignored 185 | *.[Cc]ache 186 | # but keep track of directories ending in .cache 187 | !*.[Cc]ache/ 188 | 189 | # Others 190 | ClientBin/ 191 | ~$* 192 | *~ 193 | *.dbmdl 194 | *.dbproj.schemaview 195 | *.pfx 196 | *.publishsettings 197 | node_modules/ 198 | orleans.codegen.cs 199 | 200 | # Since there are multiple workflows, uncomment next line to ignore bower_components 201 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 202 | #bower_components/ 203 | 204 | # RIA/Silverlight projects 205 | Generated_Code/ 206 | 207 | # Backup & report files from converting an old project file 208 | # to a newer Visual Studio version. Backup files are not needed, 209 | # because we have git ;-) 210 | _UpgradeReport_Files/ 211 | Backup*/ 212 | UpgradeLog*.XML 213 | UpgradeLog*.htm 214 | 215 | # SQL Server files 216 | *.mdf 217 | *.ldf 218 | 219 | # Business Intelligence projects 220 | *.rdl.data 221 | *.bim.layout 222 | *.bim_*.settings 223 | 224 | # Microsoft Fakes 225 | FakesAssemblies/ 226 | 227 | # GhostDoc plugin setting file 228 | *.GhostDoc.xml 229 | 230 | # Node.js Tools for Visual Studio 231 | .ntvs_analysis.dat 232 | 233 | # Visual Studio 6 build log 234 | *.plg 235 | 236 | # Visual Studio 6 workspace options file 237 | *.opt 238 | 239 | # Visual Studio LightSwitch build output 240 | **/*.HTMLClient/GeneratedArtifacts 241 | **/*.DesktopClient/GeneratedArtifacts 242 | **/*.DesktopClient/ModelManifest.xml 243 | **/*.Server/GeneratedArtifacts 244 | **/*.Server/ModelManifest.xml 245 | _Pvt_Extensions 246 | 247 | # Paket dependency manager 248 | .paket/paket.exe 249 | paket-files/ 250 | 251 | # FAKE - F# Make 252 | .fake/ 253 | 254 | # JetBrains Rider 255 | .idea/ 256 | *.sln.iml 257 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/DiceRIoTEmulator.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | DiceRIoTEmulator 7 | Developers can use the software emulator for DICE/RIoT to simulate inputs 8 | to DICE hardware and create RIoT keys and certificates based on that input. 9 | 10 | com.microsoft.msr 11 | DiceRIoTEmulator 12 | 1.0 13 | 14 | 15 | 16 | org.bouncycastle 17 | bcprov-jdk15on 18 | [1.66,) 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-source-plugin 26 | 3.0.1 27 | 28 | 29 | attach-sources 30 | 31 | jar 32 | 33 | 34 | 35 | 36 | 37 | org.apache.maven.plugins 38 | maven-javadoc-plugin 39 | 3.0.0-M1 40 | 41 | 42 | attach-javadocs 43 | 44 | jar 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | microsoft 55 | Microsoft 56 | 57 | 58 | http://github.com/Microsoft/RIoT/ 59 | 60 | 61 | MIT License 62 | http://opensource.org/licenses/MIT 63 | repo 64 | 65 | 66 | 67 | scm:git:git@github.com:Microsoft/RIoT.git 68 | scm:git:git@github.com:Microsoft/RIoT.git 69 | https://github.com/Microsoft/RIoT.git 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/src/main/java/com/microsoft/msr/DiceEmulator/DICE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) Microsoft. All rights reserved. 4 | * Licensed under the MIT license. See LICENSE file in the project root for full license information. 5 | * 6 | */ 7 | package com.microsoft.msr.DiceEmulator; 8 | 9 | import java.security.MessageDigest; 10 | import java.security.NoSuchAlgorithmException; 11 | 12 | /** 13 | * The DICE class is used to emulate DICE-enabled hardware. It is a dependency 14 | * of the RIoT emulator. The RIoT emulator is used to create keys and certificates 15 | * for identification and attestation of Azure IoT devices. The emulator can be 16 | * used for developing solutions on platforms that do not have DiceEmulator hardware, or 17 | * can be used to create a software-only asymmetric-key based device identity (with 18 | * no hardware protection for the keys). 19 | */ 20 | public class DICE { 21 | /** 22 | * Hashing function for DICE emulation (SHA256) 23 | * 24 | * @param buf Byte buffer from which digest is computed 25 | * @return Digest of 'buf' 26 | * @throws NoSuchAlgorithmException When no "SHA-256" 27 | */ 28 | public static byte[] DiceSHA256(byte[] buf) 29 | throws NoSuchAlgorithmException { 30 | MessageDigest md = MessageDigest.getInstance("SHA-256"); 31 | md.update(buf); 32 | return md.digest(); 33 | } 34 | 35 | /** 36 | * Hashing function for DICE emulation (SHA256) 37 | * 38 | * @param buf1 First byte buffer to be included in digest 39 | * @param buf2 Second byte buffer to be included in digest 40 | * @return Digest of 'buf1' and 'buf2' 41 | * @throws NoSuchAlgorithmException When no "SHA-256" 42 | */ 43 | public static byte[] DiceSHA256(byte[] buf1, byte[] buf2) 44 | throws NoSuchAlgorithmException { 45 | MessageDigest md = MessageDigest.getInstance("SHA-256"); 46 | md.update(buf1); 47 | md.update(buf2); 48 | return md.digest(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/DiceRIoTEmulator-1.0-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/DiceRIoTEmulator/target/DiceRIoTEmulator-1.0-javadoc.jar -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/DiceRIoTEmulator-1.0-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/DiceRIoTEmulator/target/DiceRIoTEmulator-1.0-sources.jar -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/DiceRIoTEmulator-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/DiceRIoTEmulator/target/DiceRIoTEmulator-1.0.jar -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 |

All Classes

14 |
15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 |

All Classes

14 |
15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/com/microsoft/msr/DiceEmulator/class-use/DICE.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.microsoft.msr.DiceEmulator.DICE (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 23 | 26 | 27 |
28 | 29 | 30 |
Skip navigation links
31 | 32 | 33 | 34 | 44 |
45 | 72 | 73 |
74 |

Uses of Class
com.microsoft.msr.DiceEmulator.DICE

75 |
76 |
No usage of com.microsoft.msr.DiceEmulator.DICE
77 | 78 |
79 | 80 | 81 |
Skip navigation links
82 | 83 | 84 | 85 | 95 |
96 | 123 | 124 |

Copyright © 2017. All rights reserved.

125 | 126 | 127 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/com/microsoft/msr/DiceEmulator/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.microsoft.msr.DiceEmulator (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 |

com.microsoft.msr.DiceEmulator

14 |
15 |

Classes

16 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/com/microsoft/msr/DiceEmulator/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.microsoft.msr.DiceEmulator Class Hierarchy (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 23 | 26 | 27 |
28 | 29 | 30 |
Skip navigation links
31 | 32 | 33 | 34 | 44 |
45 | 72 | 73 |
74 |

Hierarchy For Package com.microsoft.msr.DiceEmulator

75 | Package Hierarchies: 76 | 79 |
80 |
81 |

Class Hierarchy

82 | 89 |
90 | 91 |
92 | 93 | 94 |
Skip navigation links
95 | 96 | 97 | 98 | 108 |
109 | 136 | 137 |

Copyright © 2017. All rights reserved.

138 | 139 | 140 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/com/microsoft/msr/DiceEmulator/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Package com.microsoft.msr.DiceEmulator (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 23 | 26 | 27 |
28 | 29 | 30 |
Skip navigation links
31 | 32 | 33 | 34 | 44 |
45 | 72 | 73 |
74 |

Uses of Package
com.microsoft.msr.DiceEmulator

75 |
76 |
No usage of com.microsoft.msr.DiceEmulator
77 | 78 |
79 | 80 | 81 |
Skip navigation links
82 | 83 | 84 | 85 | 95 |
96 | 123 | 124 |

Copyright © 2017. All rights reserved.

125 | 126 | 127 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/com/microsoft/msr/RiotEmulator/class-use/RIoT.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.microsoft.msr.RiotEmulator.RIoT (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 23 | 26 | 27 |
28 | 29 | 30 |
Skip navigation links
31 | 32 | 33 | 34 | 44 |
45 | 72 | 73 |
74 |

Uses of Class
com.microsoft.msr.RiotEmulator.RIoT

75 |
76 |
No usage of com.microsoft.msr.RiotEmulator.RIoT
77 | 78 |
79 | 80 | 81 |
Skip navigation links
82 | 83 | 84 | 85 | 95 |
96 | 123 | 124 |

Copyright © 2017. All rights reserved.

125 | 126 | 127 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/com/microsoft/msr/RiotEmulator/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.microsoft.msr.RiotEmulator (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 |

com.microsoft.msr.RiotEmulator

14 |
15 |

Classes

16 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Constant Field Values (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 23 | 26 | 27 |
28 | 29 | 30 |
Skip navigation links
31 | 32 | 33 | 34 | 44 |
45 | 72 | 73 |
74 |

Constant Field Values

75 |

Contents

76 |
77 | 78 |
79 | 80 | 81 |
Skip navigation links
82 | 83 | 84 | 85 | 95 |
96 | 123 | 124 |

Copyright © 2017. All rights reserved.

125 | 126 | 127 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Deprecated List (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 23 | 26 | 27 |
28 | 29 | 30 |
Skip navigation links
31 | 32 | 33 | 34 | 44 |
45 | 72 | 73 |
74 |

Deprecated API

75 |

Contents

76 |
77 | 78 |
79 | 80 | 81 |
Skip navigation links
82 | 83 | 84 | 85 | 95 |
96 | 123 | 124 |

Copyright © 2017. All rights reserved.

125 | 126 | 127 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | DiceRIoTEmulator 1.0 API 8 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | <noscript> 70 | <div>JavaScript is disabled on your browser.</div> 71 | </noscript> 72 | <h2>Frame Alert</h2> 73 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview List (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 |
All Classes
14 |
15 |

Packages

16 | 20 |
21 |

 

22 | 23 | 24 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 23 | 26 | 27 |
28 | 29 | 30 |
Skip navigation links
31 | 32 | 33 | 34 | 44 |
45 | 72 | 73 |
74 |

DiceRIoTEmulator 1.0 API

75 |
76 |
77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
Packages 
PackageDescription
com.microsoft.msr.DiceEmulator 
com.microsoft.msr.RiotEmulator 
94 |
95 | 96 |
97 | 98 | 99 |
Skip navigation links
100 | 101 | 102 | 103 | 113 |
114 | 141 | 142 |

Copyright © 2017. All rights reserved.

143 | 144 | 145 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/overview-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Class Hierarchy (DiceRIoTEmulator 1.0 API) 8 | 9 | 10 | 11 | 12 | 13 | 23 | 26 | 27 |
28 | 29 | 30 |
Skip navigation links
31 | 32 | 33 | 34 | 44 |
45 | 72 | 73 |
74 |

Hierarchy For All Packages

75 | Package Hierarchies: 76 | 80 |
81 |
82 |

Class Hierarchy

83 | 92 |
93 | 94 |
95 | 96 | 97 |
Skip navigation links
98 | 99 | 100 | 101 | 111 |
112 | 139 | 140 |

Copyright © 2017. All rights reserved.

141 | 142 | 143 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/package-list: -------------------------------------------------------------------------------- 1 | com.microsoft.msr.DiceEmulator 2 | com.microsoft.msr.RiotEmulator 3 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/apidocs/script.js: -------------------------------------------------------------------------------- 1 | function show(type) 2 | { 3 | count = 0; 4 | for (var key in methods) { 5 | var row = document.getElementById(key); 6 | if ((methods[key] & type) != 0) { 7 | row.style.display = ''; 8 | row.className = (count++ % 2) ? rowColor : altColor; 9 | } 10 | else 11 | row.style.display = 'none'; 12 | } 13 | updateTabs(type); 14 | } 15 | 16 | function updateTabs(type) 17 | { 18 | for (var value in tabs) { 19 | var sNode = document.getElementById(tabs[value][0]); 20 | var spanNode = sNode.firstChild; 21 | if (value == type) { 22 | sNode.className = activeTableTab; 23 | spanNode.innerHTML = tabs[value][1]; 24 | } 25 | else { 26 | sNode.className = tableTab; 27 | spanNode.innerHTML = "" + tabs[value][1] + ""; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/classes/com/microsoft/msr/DiceEmulator/DICE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/DiceRIoTEmulator/target/classes/com/microsoft/msr/DiceEmulator/DICE.class -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/classes/com/microsoft/msr/RiotEmulator/RIoT$DeviceAuthBundle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/DiceRIoTEmulator/target/classes/com/microsoft/msr/RiotEmulator/RIoT$DeviceAuthBundle.class -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/classes/com/microsoft/msr/RiotEmulator/RIoT.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/DiceRIoTEmulator/target/classes/com/microsoft/msr/RiotEmulator/RIoT.class -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/javadoc-bundle-options/javadoc-options-javadoc-resources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | src/main/javadoc 10 | 11 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/javadoc-bundle-options/package-list: -------------------------------------------------------------------------------- 1 | java.applet 2 | java.awt 3 | java.awt.color 4 | java.awt.datatransfer 5 | java.awt.dnd 6 | java.awt.event 7 | java.awt.font 8 | java.awt.geom 9 | java.awt.im 10 | java.awt.im.spi 11 | java.awt.image 12 | java.awt.image.renderable 13 | java.awt.print 14 | java.beans 15 | java.beans.beancontext 16 | java.io 17 | java.lang 18 | java.lang.annotation 19 | java.lang.instrument 20 | java.lang.invoke 21 | java.lang.management 22 | java.lang.ref 23 | java.lang.reflect 24 | java.math 25 | java.net 26 | java.nio 27 | java.nio.channels 28 | java.nio.channels.spi 29 | java.nio.charset 30 | java.nio.charset.spi 31 | java.nio.file 32 | java.nio.file.attribute 33 | java.nio.file.spi 34 | java.rmi 35 | java.rmi.activation 36 | java.rmi.dgc 37 | java.rmi.registry 38 | java.rmi.server 39 | java.security 40 | java.security.acl 41 | java.security.cert 42 | java.security.interfaces 43 | java.security.spec 44 | java.sql 45 | java.text 46 | java.text.spi 47 | java.time 48 | java.time.chrono 49 | java.time.format 50 | java.time.temporal 51 | java.time.zone 52 | java.util 53 | java.util.concurrent 54 | java.util.concurrent.atomic 55 | java.util.concurrent.locks 56 | java.util.function 57 | java.util.jar 58 | java.util.logging 59 | java.util.prefs 60 | java.util.regex 61 | java.util.spi 62 | java.util.stream 63 | java.util.zip 64 | javax.accessibility 65 | javax.activation 66 | javax.activity 67 | javax.annotation 68 | javax.annotation.processing 69 | javax.crypto 70 | javax.crypto.interfaces 71 | javax.crypto.spec 72 | javax.imageio 73 | javax.imageio.event 74 | javax.imageio.metadata 75 | javax.imageio.plugins.bmp 76 | javax.imageio.plugins.jpeg 77 | javax.imageio.spi 78 | javax.imageio.stream 79 | javax.jws 80 | javax.jws.soap 81 | javax.lang.model 82 | javax.lang.model.element 83 | javax.lang.model.type 84 | javax.lang.model.util 85 | javax.management 86 | javax.management.loading 87 | javax.management.modelmbean 88 | javax.management.monitor 89 | javax.management.openmbean 90 | javax.management.relation 91 | javax.management.remote 92 | javax.management.remote.rmi 93 | javax.management.timer 94 | javax.naming 95 | javax.naming.directory 96 | javax.naming.event 97 | javax.naming.ldap 98 | javax.naming.spi 99 | javax.net 100 | javax.net.ssl 101 | javax.print 102 | javax.print.attribute 103 | javax.print.attribute.standard 104 | javax.print.event 105 | javax.rmi 106 | javax.rmi.CORBA 107 | javax.rmi.ssl 108 | javax.script 109 | javax.security.auth 110 | javax.security.auth.callback 111 | javax.security.auth.kerberos 112 | javax.security.auth.login 113 | javax.security.auth.spi 114 | javax.security.auth.x500 115 | javax.security.cert 116 | javax.security.sasl 117 | javax.sound.midi 118 | javax.sound.midi.spi 119 | javax.sound.sampled 120 | javax.sound.sampled.spi 121 | javax.sql 122 | javax.sql.rowset 123 | javax.sql.rowset.serial 124 | javax.sql.rowset.spi 125 | javax.swing 126 | javax.swing.border 127 | javax.swing.colorchooser 128 | javax.swing.event 129 | javax.swing.filechooser 130 | javax.swing.plaf 131 | javax.swing.plaf.basic 132 | javax.swing.plaf.metal 133 | javax.swing.plaf.multi 134 | javax.swing.plaf.nimbus 135 | javax.swing.plaf.synth 136 | javax.swing.table 137 | javax.swing.text 138 | javax.swing.text.html 139 | javax.swing.text.html.parser 140 | javax.swing.text.rtf 141 | javax.swing.tree 142 | javax.swing.undo 143 | javax.tools 144 | javax.transaction 145 | javax.transaction.xa 146 | javax.xml 147 | javax.xml.bind 148 | javax.xml.bind.annotation 149 | javax.xml.bind.annotation.adapters 150 | javax.xml.bind.attachment 151 | javax.xml.bind.helpers 152 | javax.xml.bind.util 153 | javax.xml.crypto 154 | javax.xml.crypto.dom 155 | javax.xml.crypto.dsig 156 | javax.xml.crypto.dsig.dom 157 | javax.xml.crypto.dsig.keyinfo 158 | javax.xml.crypto.dsig.spec 159 | javax.xml.datatype 160 | javax.xml.namespace 161 | javax.xml.parsers 162 | javax.xml.soap 163 | javax.xml.stream 164 | javax.xml.stream.events 165 | javax.xml.stream.util 166 | javax.xml.transform 167 | javax.xml.transform.dom 168 | javax.xml.transform.sax 169 | javax.xml.transform.stax 170 | javax.xml.transform.stream 171 | javax.xml.validation 172 | javax.xml.ws 173 | javax.xml.ws.handler 174 | javax.xml.ws.handler.soap 175 | javax.xml.ws.http 176 | javax.xml.ws.soap 177 | javax.xml.ws.spi 178 | javax.xml.ws.spi.http 179 | javax.xml.ws.wsaddressing 180 | javax.xml.xpath 181 | org.ietf.jgss 182 | org.omg.CORBA 183 | org.omg.CORBA.DynAnyPackage 184 | org.omg.CORBA.ORBPackage 185 | org.omg.CORBA.TypeCodePackage 186 | org.omg.CORBA.portable 187 | org.omg.CORBA_2_3 188 | org.omg.CORBA_2_3.portable 189 | org.omg.CosNaming 190 | org.omg.CosNaming.NamingContextExtPackage 191 | org.omg.CosNaming.NamingContextPackage 192 | org.omg.Dynamic 193 | org.omg.DynamicAny 194 | org.omg.DynamicAny.DynAnyFactoryPackage 195 | org.omg.DynamicAny.DynAnyPackage 196 | org.omg.IOP 197 | org.omg.IOP.CodecFactoryPackage 198 | org.omg.IOP.CodecPackage 199 | org.omg.Messaging 200 | org.omg.PortableInterceptor 201 | org.omg.PortableInterceptor.ORBInitInfoPackage 202 | org.omg.PortableServer 203 | org.omg.PortableServer.CurrentPackage 204 | org.omg.PortableServer.POAManagerPackage 205 | org.omg.PortableServer.POAPackage 206 | org.omg.PortableServer.ServantLocatorPackage 207 | org.omg.PortableServer.portable 208 | org.omg.SendingContext 209 | org.omg.stub.java.rmi 210 | org.w3c.dom 211 | org.w3c.dom.bootstrap 212 | org.w3c.dom.events 213 | org.w3c.dom.ls 214 | org.w3c.dom.views 215 | org.xml.sax 216 | org.xml.sax.ext 217 | org.xml.sax.helpers 218 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/maven-archiver/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven 2 | #Tue Nov 07 12:59:26 PST 2017 3 | version=1.0 4 | groupId=com.microsoft.msr 5 | artifactId=DiceRIoTEmulator 6 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | com\microsoft\msr\DiceEmulator\DICE.class 2 | com\microsoft\msr\RiotEmulator\RIoT$DeviceAuthBundle.class 3 | com\microsoft\msr\RiotEmulator\RIoT.class 4 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst: -------------------------------------------------------------------------------- 1 | C:\Users\dennisma\Sync\inp\RIoT\__inp\java\RIoTJava\riot\src\main\java\com\microsoft\msr\RiotEmulator\RIoT.java 2 | C:\Users\dennisma\Sync\inp\RIoT\__inp\java\RIoTJava\riot\src\main\java\com\microsoft\msr\DiceEmulator\DICE.java 3 | -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/DiceRIoTEmulator/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/riot-1.0-SNAPSHOT-jar-with-dependencies.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/DiceRIoTEmulator/target/riot-1.0-SNAPSHOT-jar-with-dependencies.jar -------------------------------------------------------------------------------- /Pkgs/Maven/DiceRIoTEmulator/target/riot-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/DiceRIoTEmulator/target/riot-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /Pkgs/Maven/README.txt: -------------------------------------------------------------------------------- 1 | The DICE/RIoT Emulator package and tests for Java -------------------------------------------------------------------------------- /Pkgs/Maven/Test/Test.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Pkgs/Maven/Test/out/production/Test/Emulator/Main$NulledTrustManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/Test/out/production/Test/Emulator/Main$NulledTrustManager.class -------------------------------------------------------------------------------- /Pkgs/Maven/Test/out/production/Test/Emulator/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Pkgs/Maven/Test/out/production/Test/Emulator/Main.class -------------------------------------------------------------------------------- /Pkgs/NuGet/DiceRiotEmulator/DiceRiotEmulator.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26403.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiceRiotEmulator", "DiceRiotEmulator\DiceRiotEmulator.csproj", "{2C19F991-35B6-45F4-AD66-9BC3B91D14E8}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2C19F991-35B6-45F4-AD66-9BC3B91D14E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {2C19F991-35B6-45F4-AD66-9BC3B91D14E8}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {2C19F991-35B6-45F4-AD66-9BC3B91D14E8}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {2C19F991-35B6-45F4-AD66-9BC3B91D14E8}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Pkgs/NuGet/DiceRiotEmulator/DiceRiotEmulator/DiceRiotEmulator.1.0.0.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | DiceRiotEmulator 5 | 1.0.0 6 | DICE/RIoT Emulator 7 | Microsoft Research 8 | diceriot,Microsoft 9 | https://github.com/Microsoft/RIoT/blob/master/LICENSE 10 | https://github.com/Microsoft/RIoT/ 11 | false 12 | Developers can use the software emulator for DICE/RIoT to simulate inputs to DICE hardware and create RIoT keys and certificates based on that input. 13 | The DICE/RIoT Emulator for .Net 14 | © Microsoft Corporation. All rights reserved. 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Pkgs/NuGet/DiceRiotEmulator/DiceRiotEmulator/DiceRiotEmulator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0 4 | Microsoft 5 | © Microsoft Corporation. All rights reserved. 6 | true 7 | The DICE/RIoT Emulator for .Net 8 | 9 | Developers can use the software emulator for DICE/RIoT to simulate inputs to DICE hardware and create RIoT keys and certificates based on that input. 10 | https://github.com/Microsoft/RIoT/blob/master/LICENSE 11 | https://github.com/Microsoft/RIoT/ 12 | The .NET Standard DICE/RIoT Emulator 13 | Microsoft Research 14 | 1.0.1 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Pkgs/NuGet/DiceRiotTst/drtester.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26403.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "drtester", "drtester\drtester.csproj", "{3A3806A1-82C7-4E8F-9084-D27B988A5D7F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3A3806A1-82C7-4E8F-9084-D27B988A5D7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3A3806A1-82C7-4E8F-9084-D27B988A5D7F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3A3806A1-82C7-4E8F-9084-D27B988A5D7F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3A3806A1-82C7-4E8F-9084-D27B988A5D7F}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Pkgs/NuGet/DiceRiotTst/drtester/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Diagnostics; 4 | using System.Threading; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using DiceRiotEmulator; 10 | 11 | namespace drtester 12 | { 13 | class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | byte[] uds = new byte[32]; 18 | byte[] fwid = new byte[32]; 19 | fwid[0] = 1; 20 | 21 | var bundle = DiceRiotEmulator.RIoTEngine.CreateDeviceAuthBundle(uds, fwid); 22 | 23 | string challengePoPCN = "CN=XXXXyyyyZZZZ"; 24 | var popCertPem = DiceRiotEmulator.RIoTEngine.CreateDevIDPoP(bundle, challengePoPCN); 25 | 26 | File.WriteAllText("AliasCert.PEM", bundle.AliasCredential.CertPem); 27 | File.WriteAllText("DeviceIDCert.PEM", bundle.DeviceIDCredential.CertPem); 28 | File.WriteAllText("DeviceIDSelfSignedCert.PEM", bundle.SelfSignedDeviceIDCredential.CertPem); 29 | File.WriteAllText("RootCert.PEM", bundle.RootCredential.CertPem); 30 | File.WriteAllText("DevIDCSR.PEM", bundle.Csr.CsrPem); 31 | 32 | File.WriteAllBytes("AliasCert.CER", bundle.AliasCredential.Cert.GetEncoded()); 33 | File.WriteAllBytes("DeviceIDCert.CER", bundle.DeviceIDCredential.Cert.GetEncoded()); 34 | File.WriteAllBytes("DeviceIDSelfSignedCert.CER", bundle.SelfSignedDeviceIDCredential.Cert.GetEncoded()); 35 | File.WriteAllBytes("RootCert.CER", bundle.RootCredential.Cert.GetEncoded()); 36 | File.WriteAllText("DevIDPopCert.PEM", popCertPem); 37 | 38 | string helpString = 39 | "Certificate and chain validation:\n" + 40 | "Vendor chain: openssl verify -verbose -purpose sslclient -show_chain -trusted rootCert.PEM -untrusted DeviceIDCert.PEM AliasCert.PEM\n" + 41 | "Self signed: openssl verify -verbose -purpose sslclient -show_chain -trusted DeviceIDSelfSignedCert.PEM AliasCert.PEM\n" + 42 | "CSR: openssl req -text -in DevIDCSR.PEM\n" + 43 | "dump: openssl x509 -text -in AliasCert.pem\n"; 44 | 45 | Console.WriteLine(helpString); 46 | Debug.WriteLine(helpString); 47 | 48 | Thread.Sleep(3000); 49 | 50 | return; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Pkgs/NuGet/DiceRiotTst/drtester/drtester.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | Exe 4 | netcoreapp2.1 5 | Microsoft 6 | Copyright © 2018 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Pkgs/NuGet/README.txt: -------------------------------------------------------------------------------- 1 | The project/nuspec and test application for the DICE/RIoT Emulator for .Net -------------------------------------------------------------------------------- /Pkgs/npm/README.txt: -------------------------------------------------------------------------------- 1 | DICE/RIoT Emulator package and tests for Node.js -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RIoT Reference Architecture 2 | ## Introduction 3 | Robust, Resilient, Recoverable Internet of Things (RIoT), from Microsoft Research, is an architecture for providing foundational trust services to computing devices. Device Identity Composition Engine ([DICE](https://trustedcomputinggroup.org/work-groups/dice-architectures/)) is an industry hardware/firmware standard that is the foundation on which RIoT is built. 4 | 5 | This repository contains a RIoT reference implementation for a DICE Architecture that provides cryptographically strong device identity and device attestation. Together, DICE and RIoT also provide a foundation for device recovery and resiliency ([Cyber Resilient Platform Initiative](https://aka.ms/cyres)), secure and verifiable updates, data at rest protection (sealing), and a host of other security-critical use cases. 6 | 7 | The Device Provisioning Service (DPS) from Azure IoT uses DICE and RIoT for secure device identity and attestation. The DPS X.509-based protocols rely on the cryptographic keys and certificates produced by RIoT and the Root of Trust for Measurement (RTM) provided by DICE in hardware. 8 | 9 | For more info on DPS from Azure IoT [this](https://docs.microsoft.com/en-us/azure/iot-dps/) is a good place to start. 10 | 11 | ## The RIoT Repo 12 | The RIoT repository is organized as follows: 13 | * _Reference_ - A software emulator for DICE/RIoT. The reference code can be used by developers to simulate inputs to DICE hardware and create DICE/RIoT keys and certificates based on those inputs. The emulator is useful during dev/test to provide user-controlled inputs in a more developer-friendly environment. The DICE/RIoT reference enables a much faster development cycle than working only with real hardware. 14 | * _Simulation_ - A simulated DICE/RIoT-based MCU software stack. The RIoT reference presents a simulated DICE device, the RIoT reference code itself, and very simple device firmware layer. These three self-contained elements represent the basic components of a simple DICE-based MCU. 15 | * _Pkgs_ - The packages directory contains the metadata and source code for supporting DICE/RIoT development in other languages. In addition to the C-language reference, DICE/RIoT emulators and tests are also provided in Java (Maven), C# (NuGet), and javascript (npm). 16 | * _Tools_ - Sources, tools and tests enabling RIoT development and validation. 17 | 18 | ## Contributing 19 | For more information on DICE, and to learn how you can contribute, we encourage you to check out the [DICE Workgroup](https://trustedcomputinggroup.org/work-groups/dice-architectures/) in the [Trusted Computing Group](https://trustedcomputinggroup.org/). For questions, comments, or contributions to the RIoT project from MSR, feel free to contact us at riotdev@microsoft.com. 20 | 21 | ## Privacy & Cookies 22 | https://go.microsoft.com/fwlink/?LinkId=521839 23 | 24 | -------------------------------------------------------------------------------- /Reference/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS ?= -DRIOTBUILD -DRIOTSECP384R1 -Os 2 | 3 | WARNING_CFLAGS ?= -Wall -Wextra 4 | 5 | INCLUDES ?= -I./RIoT/RIoTCrypt/include -I./RIoT/include 6 | LOCAL_CFLAGS = $(WARNING_CFLAGS) $(INCLUDES) -D_FILE_OFFSET_BITS=64 7 | LOCAL_LDFLAGS = -L./RIoT/RIoTCrypt -lmbedcrypto 8 | 9 | EMU_KEYS_CERTS = AliasCert.der AliasCert.pem AliasKey.der AliasKey.pem DeviceIDCrt.der DeviceIDCrt.pem DeviceIDPublic.der DeviceIDPublic.pem R00tCrt.der R00tCrt.pem 10 | 11 | # DEBUG 12 | #LOCAL_CFLAGS += -g3 -O0 13 | 14 | .SILENT: 15 | 16 | .PHONY: all clean 17 | 18 | all: riotemulator 19 | 20 | riotemulator: lib RIoTEmulator.o 21 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) RIoTEmulator.o $(LOCAL_LDFLAGS) -o $@ 22 | 23 | .c.o: 24 | echo " CC $<" 25 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@ 26 | 27 | lib: 28 | make -C RIoT 29 | 30 | clean: 31 | rm -f *.o ./RIoT/*.o 32 | rm -f ./RIoT/RIoTCrypt/*.o ./RIoT/RIoTCrypt/libmbed* 33 | rm -f ./RIoT/riotester ./riotemulator 34 | rm -f $(EMU_KEYS_CERTS) 35 | 36 | -------------------------------------------------------------------------------- /Reference/RIoT/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS ?= -DRIOTBUILD -DRIOTSECP384R1 -Os 2 | 3 | # REMOVE -Wno* BELOW 4 | WARNING_CFLAGS ?= -Wall -Wextra 5 | 6 | INCLUDES ?= -I./RIoTCrypt/include -I./include 7 | LOCAL_CFLAGS = $(WARNING_CFLAGS) $(INCLUDES) -D_FILE_OFFSET_BITS=64 8 | LOCAL_LDFLAGS = -L./RIoTCrypt -lmbedcrypto 9 | 10 | # DEBUG 11 | #LOCAL_CFLAGS += -g3 -O0 12 | 13 | .SILENT: 14 | 15 | .PHONY: all clean 16 | 17 | all: riotester 18 | 19 | riotester: lib RIoTester.o 20 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) RIoTester.o $(LOCAL_LDFLAGS) -o $@ 21 | 22 | .c.o: 23 | echo " CC $<" 24 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@ 25 | 26 | lib: 27 | make CRYPTO_INCLUDES:="-I../RIoTCrypt/include -I../include" -C RIoTCrypt 28 | 29 | clean: 30 | rm -f *.o ./RIoTCrypt/*.o ./RIoTCrypt/libmbed* 31 | 32 | -------------------------------------------------------------------------------- /Reference/RIoT/RIoTCrypt/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Also see "include/mbedtls/config.h" 3 | 4 | CFLAGS ?= -DRIOTBUILD -DRIOTSECP384R1 -Os 5 | WARNING_CFLAGS ?= -Wall -Wextra 6 | LDFLAGS ?= 7 | 8 | CRYPTO_INCLUDES ?= -I./include -I../include 9 | LOCAL_CFLAGS = $(WARNING_CFLAGS) $(CRYPTO_INCLUDES) -D_FILE_OFFSET_BITS=64 10 | LOCAL_LDFLAGS = 11 | 12 | # DEBUG 13 | #LOCAL_CFLAGS += -g3 -O0 14 | 15 | SOEXT_CRYPTO=so.3 16 | 17 | # Set AR_DASH= (empty string) to use an ar implementation that does not accept 18 | # the - prefix for command line options (e.g. llvm-ar) 19 | AR_DASH ?= - 20 | 21 | ARFLAGS = $(AR_DASH)src 22 | 23 | DLEXT ?= so 24 | 25 | OBJS_CRYPTO= aes.o \ 26 | base64.o \ 27 | bignum.o \ 28 | derenc.o \ 29 | ecdh.o \ 30 | ecdsa.o \ 31 | ecp.o \ 32 | ecp_curves.o \ 33 | hkdf.o \ 34 | hmac_drbg.o \ 35 | md.o \ 36 | sha1.o \ 37 | sha256.o \ 38 | x509bldr.o \ 39 | platform_util.o \ 40 | RiotCrypt.o 41 | 42 | LOCAL_CFLAGS+=$(THIRDPARTY_INCLUDES) 43 | OBJS_CRYPTO+=$(THIRDPARTY_CRYPTO_OBJECTS) 44 | 45 | .SILENT: 46 | 47 | .PHONY: all static shared clean 48 | 49 | ifndef SHARED 50 | all: static 51 | else 52 | all: shared static 53 | endif 54 | 55 | static: libmbedcrypto.a 56 | 57 | shared: libmbedcrypto.$(DLEXT) 58 | 59 | # crypto 60 | libmbedcrypto.a: $(OBJS_CRYPTO) 61 | echo " AR $@" 62 | $(AR) $(ARFLAGS) $@ $(OBJS_CRYPTO) 63 | 64 | libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) 65 | echo " LD $@" 66 | $(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO) 67 | 68 | libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO) 69 | echo " LN $@ -> $<" 70 | ln -sf $< $@ 71 | 72 | .c.o: 73 | echo " CC $<" 74 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@ 75 | 76 | clean: 77 | rm -f *.o libmbed* $(OBJS_CRYPTO) 78 | 79 | -------------------------------------------------------------------------------- /Reference/RIoT/RIoTCrypt/hkdf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * HKDF implementation -- RFC 5869 3 | * 4 | * Copyright (C) 2016-2018, ARM Limited, All Rights Reserved 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 8 | * not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * This file is part of mbed TLS (https://tls.mbed.org) 20 | */ 21 | #if !defined(MBEDTLS_CONFIG_FILE) 22 | #include "mbedtls/config.h" 23 | #else 24 | #include MBEDTLS_CONFIG_FILE 25 | #endif 26 | 27 | #if defined(MBEDTLS_HKDF_C) 28 | 29 | #include 30 | #include "mbedtls/hkdf.h" 31 | #include "mbedtls/platform_util.h" 32 | 33 | int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt, 34 | size_t salt_len, const unsigned char *ikm, size_t ikm_len, 35 | const unsigned char *info, size_t info_len, 36 | unsigned char *okm, size_t okm_len ) 37 | { 38 | int ret; 39 | unsigned char prk[MBEDTLS_MD_MAX_SIZE]; 40 | 41 | ret = mbedtls_hkdf_extract( md, salt, salt_len, ikm, ikm_len, prk ); 42 | 43 | if( ret == 0 ) 44 | { 45 | ret = mbedtls_hkdf_expand( md, prk, mbedtls_md_get_size( md ), 46 | info, info_len, okm, okm_len ); 47 | } 48 | 49 | mbedtls_platform_zeroize( prk, sizeof( prk ) ); 50 | 51 | return( ret ); 52 | } 53 | 54 | int mbedtls_hkdf_extract( const mbedtls_md_info_t *md, 55 | const unsigned char *salt, size_t salt_len, 56 | const unsigned char *ikm, size_t ikm_len, 57 | unsigned char *prk ) 58 | { 59 | unsigned char null_salt[MBEDTLS_MD_MAX_SIZE] = { '\0' }; 60 | 61 | if( salt == NULL ) 62 | { 63 | size_t hash_len; 64 | 65 | if( salt_len != 0 ) 66 | { 67 | return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA; 68 | } 69 | 70 | hash_len = mbedtls_md_get_size( md ); 71 | 72 | if( hash_len == 0 ) 73 | { 74 | return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA; 75 | } 76 | 77 | salt = null_salt; 78 | salt_len = hash_len; 79 | } 80 | 81 | return( mbedtls_md_hmac( md, salt, salt_len, ikm, ikm_len, prk ) ); 82 | } 83 | 84 | int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, 85 | size_t prk_len, const unsigned char *info, 86 | size_t info_len, unsigned char *okm, size_t okm_len ) 87 | { 88 | size_t hash_len; 89 | size_t where = 0; 90 | size_t n; 91 | size_t t_len = 0; 92 | size_t i; 93 | int ret = 0; 94 | mbedtls_md_context_t ctx; 95 | unsigned char t[MBEDTLS_MD_MAX_SIZE]; 96 | 97 | if( okm == NULL ) 98 | { 99 | return( MBEDTLS_ERR_HKDF_BAD_INPUT_DATA ); 100 | } 101 | 102 | hash_len = mbedtls_md_get_size( md ); 103 | 104 | if( prk_len < hash_len || hash_len == 0 ) 105 | { 106 | return( MBEDTLS_ERR_HKDF_BAD_INPUT_DATA ); 107 | } 108 | 109 | if( info == NULL ) 110 | { 111 | info = (const unsigned char *) ""; 112 | info_len = 0; 113 | } 114 | 115 | n = okm_len / hash_len; 116 | 117 | if( (okm_len % hash_len) != 0 ) 118 | { 119 | n++; 120 | } 121 | 122 | /* 123 | * Per RFC 5869 Section 2.3, okm_len must not exceed 124 | * 255 times the hash length 125 | */ 126 | if( n > 255 ) 127 | { 128 | return( MBEDTLS_ERR_HKDF_BAD_INPUT_DATA ); 129 | } 130 | 131 | mbedtls_md_init( &ctx ); 132 | 133 | if( (ret = mbedtls_md_setup( &ctx, md, 1) ) != 0 ) 134 | { 135 | goto exit; 136 | } 137 | 138 | /* 139 | * Compute T = T(1) | T(2) | T(3) | ... | T(N) 140 | * Where T(N) is defined in RFC 5869 Section 2.3 141 | */ 142 | for( i = 1; i <= n; i++ ) 143 | { 144 | size_t num_to_copy; 145 | unsigned char c = i & 0xff; 146 | 147 | ret = mbedtls_md_hmac_starts( &ctx, prk, prk_len ); 148 | if( ret != 0 ) 149 | { 150 | goto exit; 151 | } 152 | 153 | ret = mbedtls_md_hmac_update( &ctx, t, t_len ); 154 | if( ret != 0 ) 155 | { 156 | goto exit; 157 | } 158 | 159 | ret = mbedtls_md_hmac_update( &ctx, info, info_len ); 160 | if( ret != 0 ) 161 | { 162 | goto exit; 163 | } 164 | 165 | /* The constant concatenated to the end of each T(n) is a single octet. 166 | * */ 167 | ret = mbedtls_md_hmac_update( &ctx, &c, 1 ); 168 | if( ret != 0 ) 169 | { 170 | goto exit; 171 | } 172 | 173 | ret = mbedtls_md_hmac_finish( &ctx, t ); 174 | if( ret != 0 ) 175 | { 176 | goto exit; 177 | } 178 | 179 | num_to_copy = i != n ? hash_len : okm_len - where; 180 | memcpy( okm + where, t, num_to_copy ); 181 | where += hash_len; 182 | t_len = hash_len; 183 | } 184 | 185 | exit: 186 | mbedtls_md_free( &ctx ); 187 | mbedtls_platform_zeroize( t, sizeof( t ) ); 188 | 189 | return( ret ); 190 | } 191 | 192 | #endif /* MBEDTLS_HKDF_C */ 193 | -------------------------------------------------------------------------------- /Reference/RIoT/RIoTCrypt/include/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #ifndef RIOT_BASE64_H 6 | #define RIOT_BASE64_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define Base64Length(l) ((l == 0) ? (1) : (((((l - 1) / 3) + 1) * 4) + 1)) 13 | 14 | int 15 | Base64Encode( 16 | const unsigned char *Input, 17 | uint32_t Length, 18 | char *Output, 19 | uint32_t *OutLen 20 | ); 21 | 22 | int 23 | Base64Decode( 24 | const char *Input, 25 | unsigned char *Output, 26 | uint32_t *OutLen 27 | ); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Reference/RIoT/RIoTCrypt/include/derenc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #pragma once 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define DER_MAX_PEM 0x500 12 | #define DER_MAX_TBS 0x500 13 | #define DER_MAX_NESTED 0x10 14 | 15 | // 16 | // Context structure for the DER-encoder. This structure contains a fixed- 17 | // length array for nested SEQUENCES (which imposes a nesting limit). 18 | // The buffer use for encoded data is caller-allocted. 19 | // 20 | typedef struct 21 | { 22 | uint8_t *Buffer; // Encoded data 23 | uint32_t Length; // Size, in bytes, of Buffer 24 | uint32_t Position; // Current buffer position 25 | 26 | // SETS, SEQUENCES, etc. can be nested. This array contains the start of 27 | // the payload for collection types and is set by DERStartSequenceOrSet(). 28 | // Collections are "popped" using DEREndSequenceOrSet(). 29 | int CollectionStart[DER_MAX_NESTED]; 30 | int CollectionPos; 31 | } DERBuilderContext; 32 | 33 | // We only have a small subset of potential PEM encodings 34 | enum CertType { 35 | CERT_TYPE = 0, 36 | PUBLICKEY_TYPE, 37 | ECC_PRIVATEKEY_TYPE, 38 | CERT_REQ_TYPE, 39 | LAST_CERT_TYPE 40 | }; 41 | 42 | void 43 | DERInitContext( 44 | DERBuilderContext *Context, 45 | uint8_t *Buffer, 46 | uint32_t Length 47 | ); 48 | 49 | int 50 | DERGetEncodedLength( 51 | DERBuilderContext *Context 52 | ); 53 | 54 | 55 | int 56 | DERAddOID( 57 | DERBuilderContext *Context, 58 | int *Values 59 | ); 60 | 61 | int 62 | DERAddUTF8String( 63 | DERBuilderContext *Context, 64 | const char *Str 65 | ); 66 | 67 | int 68 | DERAddPrintableString( 69 | DERBuilderContext *Context, 70 | const char *Str 71 | ); 72 | 73 | 74 | int 75 | DERAddUTCTime( 76 | DERBuilderContext *Context, 77 | const char *Str 78 | ); 79 | 80 | int 81 | DERAddIntegerFromArray( 82 | DERBuilderContext *Context, 83 | uint8_t *Val, 84 | uint32_t NumBytes 85 | ); 86 | 87 | int 88 | DERAddInteger( 89 | DERBuilderContext *Context, 90 | int Val 91 | ); 92 | 93 | int 94 | DERAddShortExplicitInteger( 95 | DERBuilderContext *Context, 96 | int Val 97 | ); 98 | 99 | int 100 | DERAddBoolean( 101 | DERBuilderContext *Context, 102 | bool Val 103 | ); 104 | 105 | 106 | int 107 | DERAddBitString( 108 | DERBuilderContext *Context, 109 | uint8_t *BitString, 110 | uint32_t BitStringNumBytes 111 | ); 112 | 113 | int 114 | DERAddOctetString( 115 | DERBuilderContext *Context, 116 | uint8_t *OctetString, 117 | uint32_t OctetStringLen 118 | ); 119 | 120 | int 121 | DERStartSequenceOrSet( 122 | DERBuilderContext *Context, 123 | bool Sequence 124 | ); 125 | 126 | int 127 | DERStartExplicit( 128 | DERBuilderContext *Context, 129 | uint32_t Num 130 | ); 131 | 132 | int 133 | DERStartEnvelopingOctetString( 134 | DERBuilderContext *Context 135 | ); 136 | 137 | int 138 | DERStartEnvelopingBitString( 139 | DERBuilderContext *Context 140 | ); 141 | 142 | int 143 | DERPopNesting( 144 | DERBuilderContext *Context 145 | ); 146 | 147 | int 148 | DERGetNestingDepth( 149 | DERBuilderContext *Context 150 | ); 151 | 152 | int 153 | DERTbsToCert( 154 | DERBuilderContext *Context 155 | ); 156 | 157 | int 158 | DERtoPEM( 159 | DERBuilderContext *Context, 160 | uint32_t Type, 161 | char *PEM, 162 | uint32_t *Length 163 | ); 164 | 165 | #ifdef __cplusplus 166 | } 167 | #endif 168 | -------------------------------------------------------------------------------- /Reference/RIoT/RIoTCrypt/include/mbedtls/md_internal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file md_internal.h 3 | * 4 | * \brief Message digest wrappers. 5 | * 6 | * \warning This in an internal header. Do not include directly. 7 | * 8 | * \author Adriaan de Jong 9 | */ 10 | /* 11 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * This file is part of mbed TLS (https://tls.mbed.org) 27 | */ 28 | #ifndef MBEDTLS_MD_WRAP_H 29 | #define MBEDTLS_MD_WRAP_H 30 | 31 | #if !defined(MBEDTLS_CONFIG_FILE) 32 | #include "mbedtls/config.h" 33 | #else 34 | #include MBEDTLS_CONFIG_FILE 35 | #endif 36 | 37 | #include "mbedtls/md.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** 44 | * Message digest information. 45 | * Allows message digest functions to be called in a generic way. 46 | */ 47 | struct mbedtls_md_info_t 48 | { 49 | /** Name of the message digest */ 50 | const char * name; 51 | 52 | /** Digest identifier */ 53 | mbedtls_md_type_t type; 54 | 55 | /** Output length of the digest function in bytes */ 56 | unsigned char size; 57 | 58 | /** Block length of the digest function in bytes */ 59 | unsigned char block_size; 60 | }; 61 | 62 | #if defined(MBEDTLS_MD2_C) 63 | extern const mbedtls_md_info_t mbedtls_md2_info; 64 | #endif 65 | #if defined(MBEDTLS_MD4_C) 66 | extern const mbedtls_md_info_t mbedtls_md4_info; 67 | #endif 68 | #if defined(MBEDTLS_MD5_C) 69 | extern const mbedtls_md_info_t mbedtls_md5_info; 70 | #endif 71 | #if defined(MBEDTLS_RIPEMD160_C) 72 | extern const mbedtls_md_info_t mbedtls_ripemd160_info; 73 | #endif 74 | #if defined(MBEDTLS_SHA1_C) 75 | extern const mbedtls_md_info_t mbedtls_sha1_info; 76 | #endif 77 | #if defined(MBEDTLS_SHA256_C) 78 | extern const mbedtls_md_info_t mbedtls_sha224_info; 79 | extern const mbedtls_md_info_t mbedtls_sha256_info; 80 | #endif 81 | #if defined(MBEDTLS_SHA512_C) 82 | extern const mbedtls_md_info_t mbedtls_sha384_info; 83 | extern const mbedtls_md_info_t mbedtls_sha512_info; 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* MBEDTLS_MD_WRAP_H */ 91 | -------------------------------------------------------------------------------- /Reference/RIoT/RIoTCrypt/include/x509bldr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #ifndef _RIOT_X509_BLDR_H 6 | #define _RIOT_X509_BLDR_H 7 | 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | // KeyUsage :: = BIT STRING { 14 | // digitalSignature(0), 15 | // nonRepudiation(1), 16 | // keyEncipherment(2), 17 | // dataEncipherment(3), 18 | // keyAgreement(4), 19 | // keyCertSign(5), 20 | // cRLSign(6) 21 | // } 22 | #define RIOT_X509_KEY_USAGE 0x04 // keyCertSign 23 | #define RIOT_X509_SNUM_LEN 0x08 // In bytes 24 | 25 | // Const x509 "to be signed" data 26 | typedef struct 27 | { 28 | uint8_t SerialNum[RIOT_X509_SNUM_LEN]; 29 | const char *IssuerCommon; 30 | const char *IssuerOrg; 31 | const char *IssuerCountry; 32 | const char *ValidFrom; 33 | const char *ValidTo; 34 | const char *SubjectCommon; 35 | const char *SubjectOrg; 36 | const char *SubjectCountry; 37 | } RIOT_X509_TBS_DATA; 38 | 39 | int 40 | X509GetDeviceCertTBS( 41 | DERBuilderContext *Tbs, 42 | RIOT_X509_TBS_DATA *TbsData, 43 | RIOT_ECC_PUBLIC *DevIdKeyPub, 44 | uint8_t *RootKeyPub, 45 | uint32_t RootKeyPubLen 46 | ); 47 | 48 | int 49 | X509MakeDeviceCert( 50 | DERBuilderContext *DeviceIDCert, 51 | RIOT_ECC_SIGNATURE *TbsSig 52 | ); 53 | 54 | int 55 | X509GetAliasCertTBS( 56 | DERBuilderContext *Tbs, 57 | RIOT_X509_TBS_DATA *TbsData, 58 | RIOT_ECC_PUBLIC *AliasKeyPub, 59 | RIOT_ECC_PUBLIC *DevIdKeyPub, 60 | uint8_t *Fwid, 61 | uint32_t FwidLen 62 | ); 63 | 64 | int 65 | X509MakeAliasCert( 66 | DERBuilderContext *AliasCert, 67 | RIOT_ECC_SIGNATURE *TbsSig 68 | ); 69 | 70 | int 71 | X509GetDEREccPub( 72 | DERBuilderContext *Context, 73 | RIOT_ECC_PUBLIC Pub 74 | ); 75 | 76 | int 77 | X509GetDEREcc( 78 | DERBuilderContext *Context, 79 | RIOT_ECC_PUBLIC Pub, 80 | RIOT_ECC_PRIVATE Priv 81 | ); 82 | 83 | int 84 | X509GetDERCsrTbs( 85 | DERBuilderContext *Context, 86 | RIOT_X509_TBS_DATA *TbsData, 87 | RIOT_ECC_PUBLIC *DeviceIDPub 88 | ); 89 | 90 | int 91 | X509GetDERCsr( 92 | DERBuilderContext *Context, 93 | RIOT_ECC_SIGNATURE *Signature 94 | ); 95 | 96 | int 97 | X509GetRootCertTBS( 98 | DERBuilderContext *Tbs, 99 | RIOT_X509_TBS_DATA *TbsData, 100 | RIOT_ECC_PUBLIC *RootKeyPub 101 | ); 102 | 103 | int 104 | X509MakeRootCert( 105 | DERBuilderContext *AliasCert, 106 | RIOT_ECC_SIGNATURE *TbsSig 107 | ); 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | #endif -------------------------------------------------------------------------------- /Reference/RIoT/RIoTCrypt/platform_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Common and shared functions used by multiple modules in the Mbed TLS 3 | * library. 4 | * 5 | * Copyright (C) 2018, Arm Limited, All Rights Reserved 6 | * SPDX-License-Identifier: Apache-2.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 9 | * not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 16 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * This file is part of Mbed TLS (https://tls.mbed.org) 21 | */ 22 | 23 | /* 24 | * Ensure gmtime_r is available even with -std=c99; must be defined before 25 | * config.h, which pulls in glibc's features.h. Harmless on other platforms. 26 | */ 27 | #if !defined(_POSIX_C_SOURCE) 28 | #define _POSIX_C_SOURCE 200112L 29 | #endif 30 | 31 | #if !defined(MBEDTLS_CONFIG_FILE) 32 | #include "mbedtls/config.h" 33 | #else 34 | #include MBEDTLS_CONFIG_FILE 35 | #endif 36 | 37 | #include "mbedtls/platform_util.h" 38 | #include "mbedtls/platform.h" 39 | //#include "mbedtls/threading.h" 40 | 41 | #include 42 | #include 43 | 44 | #if !defined(MBEDTLS_PLATFORM_ZEROIZE_ALT) 45 | /* 46 | * This implementation should never be optimized out by the compiler 47 | * 48 | * This implementation for mbedtls_platform_zeroize() was inspired from Colin 49 | * Percival's blog article at: 50 | * 51 | * http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html 52 | * 53 | * It uses a volatile function pointer to the standard memset(). Because the 54 | * pointer is volatile the compiler expects it to change at 55 | * any time and will not optimize out the call that could potentially perform 56 | * other operations on the input buffer instead of just setting it to 0. 57 | * Nevertheless, as pointed out by davidtgoldblatt on Hacker News 58 | * (refer to http://www.daemonology.net/blog/2014-09-05-erratum.html for 59 | * details), optimizations of the following form are still possible: 60 | * 61 | * if( memset_func != memset ) 62 | * memset_func( buf, 0, len ); 63 | * 64 | * Note that it is extremely difficult to guarantee that 65 | * mbedtls_platform_zeroize() will not be optimized out by aggressive compilers 66 | * in a portable way. For this reason, Mbed TLS also provides the configuration 67 | * option MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure 68 | * mbedtls_platform_zeroize() to use a suitable implementation for their 69 | * platform and needs. 70 | */ 71 | static void * (* const volatile memset_func)( void *, int, size_t ) = memset; 72 | 73 | void mbedtls_platform_zeroize( void *buf, size_t len ) 74 | { 75 | MBEDTLS_INTERNAL_VALIDATE( len == 0 || buf != NULL ); 76 | 77 | if( len > 0 ) 78 | memset_func( buf, 0, len ); 79 | } 80 | #endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */ 81 | 82 | #if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT) 83 | #include 84 | #if !defined(_WIN32) && (defined(unix) || \ 85 | defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \ 86 | defined(__MACH__))) 87 | #include 88 | #endif /* !_WIN32 && (unix || __unix || __unix__ || 89 | * (__APPLE__ && __MACH__)) */ 90 | 91 | #if !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \ 92 | ( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \ 93 | _POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) 94 | /* 95 | * This is a convenience shorthand macro to avoid checking the long 96 | * preprocessor conditions above. Ideally, we could expose this macro in 97 | * platform_util.h and simply use it in platform_util.c, threading.c and 98 | * threading.h. However, this macro is not part of the Mbed TLS public API, so 99 | * we keep it private by only defining it in this file 100 | */ 101 | #if ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) 102 | #define PLATFORM_UTIL_USE_GMTIME 103 | #endif /* ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) */ 104 | 105 | #endif /* !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \ 106 | ( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \ 107 | _POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) */ 108 | 109 | struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt, 110 | struct tm *tm_buf ) 111 | { 112 | #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) 113 | return( ( gmtime_s( tm_buf, tt ) == 0 ) ? tm_buf : NULL ); 114 | #elif !defined(PLATFORM_UTIL_USE_GMTIME) 115 | return( gmtime_r( tt, tm_buf ) ); 116 | #else 117 | struct tm *lt; 118 | 119 | #if defined(MBEDTLS_THREADING_C) 120 | if( mbedtls_mutex_lock( &mbedtls_threading_gmtime_mutex ) != 0 ) 121 | return( NULL ); 122 | #endif /* MBEDTLS_THREADING_C */ 123 | 124 | lt = gmtime( tt ); 125 | 126 | if( lt != NULL ) 127 | { 128 | memcpy( tm_buf, lt, sizeof( struct tm ) ); 129 | } 130 | 131 | #if defined(MBEDTLS_THREADING_C) 132 | if( mbedtls_mutex_unlock( &mbedtls_threading_gmtime_mutex ) != 0 ) 133 | return( NULL ); 134 | #endif /* MBEDTLS_THREADING_C */ 135 | 136 | return( ( lt == NULL ) ? NULL : tm_buf ); 137 | #endif /* _WIN32 && !EFIX64 && !EFI32 */ 138 | } 139 | #endif /* MBEDTLS_HAVE_TIME_DATE && MBEDTLS_PLATFORM_GMTIME_R_ALT */ 140 | -------------------------------------------------------------------------------- /Reference/RIoT/include/RiotStatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #ifndef _RIOT_STATUS_H 6 | #define _RIOT_STATUS_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef enum RIOT_STATUS { 13 | RIOT_SUCCESS = 0, 14 | RIOT_FAILURE = RIOT_SUCCESS + 0x80, 15 | RIOT_INVALID_PARAMETER, 16 | RIOT_INVALID_STATE, 17 | } RIOT_STATUS; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Reference/RIoTEmulator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | 6 | #ifndef _RIOT_EMULATOR_H 7 | #define _RIOT_EMULATOR_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #endif -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /Simulation/DICE RIoT.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DICE", "DICE\DICE.vcxproj", "{0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RIoT", "RIoT\Core\RIoT.vcxproj", "{B7AF6C41-115E-4926-A8B3-7842FFE9D605}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07} = {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07} 11 | EndProjectSection 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FW", "FW\Loader.vcxproj", "{FD767D67-E637-4AD0-A99A-6C35CE32E4A4}" 14 | ProjectSection(ProjectDependencies) = postProject 15 | {B7AF6C41-115E-4926-A8B3-7842FFE9D605} = {B7AF6C41-115E-4926-A8B3-7842FFE9D605} 16 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07} = {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07} 17 | EndProjectSection 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|x64 = Debug|x64 22 | Debug|x86 = Debug|x86 23 | Release|x64 = Release|x64 24 | Release|x86 = Release|x86 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07}.Debug|x64.ActiveCfg = Debug|Win32 28 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07}.Debug|x64.Build.0 = Debug|Win32 29 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07}.Debug|x86.ActiveCfg = Debug|Win32 30 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07}.Debug|x86.Build.0 = Debug|Win32 31 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07}.Release|x64.ActiveCfg = Release|Win32 32 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07}.Release|x64.Build.0 = Release|Win32 33 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07}.Release|x86.ActiveCfg = Release|Win32 34 | {0E4A2BB0-FBC0-4F2D-80A7-A10359BF6B07}.Release|x86.Build.0 = Release|Win32 35 | {B7AF6C41-115E-4926-A8B3-7842FFE9D605}.Debug|x64.ActiveCfg = Debug|Win32 36 | {B7AF6C41-115E-4926-A8B3-7842FFE9D605}.Debug|x64.Build.0 = Debug|Win32 37 | {B7AF6C41-115E-4926-A8B3-7842FFE9D605}.Debug|x86.ActiveCfg = Debug|Win32 38 | {B7AF6C41-115E-4926-A8B3-7842FFE9D605}.Debug|x86.Build.0 = Debug|Win32 39 | {B7AF6C41-115E-4926-A8B3-7842FFE9D605}.Release|x64.ActiveCfg = Release|Win32 40 | {B7AF6C41-115E-4926-A8B3-7842FFE9D605}.Release|x64.Build.0 = Release|Win32 41 | {B7AF6C41-115E-4926-A8B3-7842FFE9D605}.Release|x86.ActiveCfg = Release|Win32 42 | {B7AF6C41-115E-4926-A8B3-7842FFE9D605}.Release|x86.Build.0 = Release|Win32 43 | {FD767D67-E637-4AD0-A99A-6C35CE32E4A4}.Debug|x64.ActiveCfg = Debug|Win32 44 | {FD767D67-E637-4AD0-A99A-6C35CE32E4A4}.Debug|x64.Build.0 = Debug|Win32 45 | {FD767D67-E637-4AD0-A99A-6C35CE32E4A4}.Debug|x86.ActiveCfg = Debug|Win32 46 | {FD767D67-E637-4AD0-A99A-6C35CE32E4A4}.Debug|x86.Build.0 = Debug|Win32 47 | {FD767D67-E637-4AD0-A99A-6C35CE32E4A4}.Release|x64.ActiveCfg = Release|Win32 48 | {FD767D67-E637-4AD0-A99A-6C35CE32E4A4}.Release|x64.Build.0 = Release|Win32 49 | {FD767D67-E637-4AD0-A99A-6C35CE32E4A4}.Release|x86.ActiveCfg = Release|Win32 50 | {FD767D67-E637-4AD0-A99A-6C35CE32E4A4}.Release|x86.Build.0 = Release|Win32 51 | EndGlobalSection 52 | GlobalSection(SolutionProperties) = preSolution 53 | HideSolutionNode = FALSE 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /Simulation/DICE/DICE.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {92acde2d-b9a9-4383-b930-b710808212dd} 14 | 15 | 16 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 17 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Ignore 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Ignore 37 | 38 | 39 | Ignore 40 | 41 | 42 | -------------------------------------------------------------------------------- /Simulation/DICE/DiceSha256.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2001, Aaron D. Gifford 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the copyright holder nor the names of contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $Id: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $ 30 | */ 31 | 32 | // 33 | // 4-MAY-2015; DICE adaptation (DennisMa;MSFT). 34 | // 35 | #ifndef __DICE_CRYPTO_SHA256_H__ 36 | #define __DICE_CRYPTO_SHA256_H__ 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef int asb; 42 | 43 | typedef uint8_t sha2_uint8_t; // Exactly 1 byte 44 | typedef uint32_t sha2_word32; // Exactly 4 bytes 45 | typedef uint64_t sha2_word64; // Exactly 8 bytes 46 | 47 | #ifndef SHA256_BLOCK_LENGTH 48 | #define SHA256_BLOCK_LENGTH 64 49 | #endif 50 | #ifndef SHA256_DIGEST_LENGTH 51 | #define SHA256_DIGEST_LENGTH 32 52 | #endif 53 | 54 | typedef uint64_t hashMagic_t; 55 | 56 | #if HOST_IS_LITTLE_ENDIAN 57 | #define HASH_MAGIC_VALUE (0x4078746368736168LL) 58 | #else 59 | #define HASH_MAGIC_VALUE (0x6861736863747840LL) 60 | #endif 61 | 62 | typedef struct _DICE_SHA256_CONTEXT { 63 | uint32_t state[8]; 64 | hashMagic_t magic; 65 | uint64_t bitcount; 66 | uint8_t buffer[SHA256_BLOCK_LENGTH]; 67 | } DICE_SHA256_CONTEXT; 68 | 69 | // 70 | // Initialize the hash context 71 | // @param context the hash context 72 | // 73 | void DICE_SHA256_Init(DICE_SHA256_CONTEXT *context); 74 | 75 | // 76 | // Update the digest using the specific bytes 77 | // @param context the hash context 78 | // @param buf the bytes to digest 79 | // @param bufSize the number of bytes to digest 80 | // 81 | void DICE_SHA256_Update(DICE_SHA256_CONTEXT *context, 82 | const sha2_uint8_t *data, size_t len); 83 | 84 | // 85 | // Retrieve the final digest 86 | // @param context the hash context 87 | // @param digest the buffer to hold the digest. Must be of size SHA256_DIGEST_LENGTH 88 | // 89 | void DICE_SHA256_Final(DICE_SHA256_CONTEXT *context, sha2_uint8_t *digest); 90 | 91 | // 92 | // Hash a block of data 93 | // @param context the hash context 94 | // @param buf the buffer containing the data to hash 95 | // @param bufSize the number of bytes in the buffer 96 | // @param digest the buffer to hold the digest. Must be of size SHA256_DIGEST_LENGTH 97 | // 98 | void DiceSHA256Ctx(DICE_SHA256_CONTEXT *context, 99 | const uint8_t *buf, size_t bufSize, 100 | uint8_t *digest); 101 | 102 | // 103 | // Hash a block of data 104 | // @param buf the buffer containing the data to hash 105 | // @param bufSize the number of bytes in the buffer 106 | // @param digest the buffer to hold the digest. Must be of size SHA256_DIGEST_LENGTH 107 | // 108 | void DiceSHA256(const uint8_t *buf, size_t bufSize, 109 | uint8_t *digest); 110 | 111 | void DiceSHA256_2(const uint8_t *buf1, size_t bufSize1, 112 | const uint8_t *buf2, size_t bufSize2, 113 | uint8_t *digest); 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | #endif 118 | 119 | -------------------------------------------------------------------------------- /Simulation/DICE/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /Simulation/DICE/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "targetver.h" 3 | #include 4 | #include 5 | #define WIN32_LEAN_AND_MEAN 6 | #include 7 | #include 8 | #include "DiceSha256.h" -------------------------------------------------------------------------------- /Simulation/DICE/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | -------------------------------------------------------------------------------- /Simulation/FW/Loader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #include "stdafx.h" 6 | 7 | // There are lots of ways to force a new FWID value. However, to 8 | // maintain a consistent FWID value accross "boots", the default 9 | // linker option that randomizes base addresses must be disabled. 10 | 11 | FW_API void FirmwareEntry( 12 | char *r00tCert, 13 | RIOT_ECC_PUBLIC *DeviceIDPub, 14 | char *DeviceCert, 15 | RIOT_ECC_PUBLIC *AliasKeyPub, 16 | RIOT_ECC_PRIVATE *AliasKeyPriv, 17 | char *AliasKeyCert 18 | ) 19 | { 20 | UINT32 i; 21 | 22 | UNREFERENCED_PARAMETER(DeviceIDPub); 23 | UNREFERENCED_PARAMETER(AliasKeyPub); 24 | UNREFERENCED_PARAMETER(AliasKeyPriv); 25 | 26 | printf("FW: Begin.\n"); 27 | 28 | printf("FW: r00tCertificate:\n %s", r00tCert); 29 | printf("\nFW: DeviceCertificate:\n %s", DeviceCert); 30 | printf("\nFW: AliasKeyCertificate:\n %s", AliasKeyCert); 31 | 32 | i = 50; 33 | do { 34 | printf("\rFW: \"Running\" \\"); 35 | Sleep(10); 36 | printf("\rFW: \"Running\" |"); 37 | Sleep(10); 38 | printf("\rFW: \"Running\" /"); 39 | Sleep(10); 40 | printf("\rFW: \"Running\" -"); 41 | Sleep(10); 42 | } while (i--); 43 | 44 | printf("\nFW: Reboot!\n"); 45 | Sleep(300); 46 | return; 47 | } 48 | -------------------------------------------------------------------------------- /Simulation/FW/Loader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #include "RIoT.h" 10 | #include "RIoTSim.h" 11 | 12 | #ifdef LOADER_EXPORTS 13 | #define FW_API __declspec(dllexport) 14 | #else 15 | #define FW_API __declspec(dllimport) 16 | #endif 17 | 18 | FW_API void FirmwareEntry( 19 | char *rootCert, 20 | RIOT_ECC_PUBLIC *DeviceIDPub, 21 | char *DeiceCert, 22 | RIOT_ECC_PUBLIC *AliasKeyPub, 23 | RIOT_ECC_PRIVATE *AliasKeyPriv, 24 | char *AliasKeyCert 25 | ); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /Simulation/FW/Loader.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Ignore 9 | 10 | 11 | Ignore 12 | 13 | 14 | 15 | 16 | Ignore 17 | 18 | 19 | Ignore 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | {246e2e3b-b4ca-4a5e-8c5c-4fc07fe1f88d} 28 | 29 | 30 | {68d94a60-4cbc-42b1-b668-6f18d91c12d5} 31 | 32 | 33 | {086194d6-5a29-4de0-b4e2-890204396e6c} 34 | 35 | 36 | -------------------------------------------------------------------------------- /Simulation/FW/dllmain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #include "stdafx.h" 6 | 7 | BOOL APIENTRY DllMain( HMODULE hModule, 8 | DWORD ul_reason_for_call, 9 | LPVOID lpReserved 10 | ) 11 | { 12 | UNREFERENCED_PARAMETER(hModule); 13 | UNREFERENCED_PARAMETER(lpReserved); 14 | switch (ul_reason_for_call) 15 | { 16 | case DLL_PROCESS_ATTACH: 17 | case DLL_THREAD_ATTACH: 18 | case DLL_THREAD_DETACH: 19 | case DLL_PROCESS_DETACH: 20 | break; 21 | } 22 | return TRUE; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Simulation/FW/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #include "stdafx.h" -------------------------------------------------------------------------------- /Simulation/FW/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #pragma once 6 | 7 | #include "targetver.h" 8 | #include 9 | #define WIN32_LEAN_AND_MEAN 10 | #include 11 | 12 | // Includes 13 | #include "Loader.h" -------------------------------------------------------------------------------- /Simulation/FW/targetver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #pragma once 6 | #include 7 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RIoT.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #ifndef _RIOT_H 6 | #define _RIOT_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include "RiotStatus.h" 13 | #include "RiotCrypt.h" 14 | #include "base64.h" 15 | #include "derenc.h" 16 | #include "x509bldr.h" 17 | 18 | #define RIOT_SUCCESS(a) (a == (RIOT_OK)) 19 | 20 | // 21 | // Key derivation labels used by both RIoT Devices and External Infrastructure 22 | // 23 | #define RIOT_LABEL_IDENTITY "Identity" 24 | #define RIOT_LABEL_ALIAS "Alias" 25 | #define RIOT_LABEL_PROTECTOR "Encrypt" 26 | #define RIOT_LABEL_INTEGRITY "HMAC" 27 | #define RIOT_LABEL_AIK "AikProtector" 28 | #define RIOT_LABEL_SK "Sealing" 29 | #define RIOT_LABEL_MK "Migration" 30 | #define RIOT_LABEL_AK "Attestation" 31 | 32 | // 33 | // Macro for label sizes (skip strlen()). 34 | // 35 | #define lblSize(a) (sizeof(a) - 1) 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RIoTCrypt/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Also see "include/mbedtls/config.h" 3 | 4 | CFLAGS ?= -DRIOTBUILD -DRIOTSECP384R1 -Os 5 | WARNING_CFLAGS ?= -Wall -Wextra 6 | LDFLAGS ?= 7 | 8 | CRYPTO_INCLUDES ?= -I./include -I../include 9 | LOCAL_CFLAGS = $(WARNING_CFLAGS) $(CRYPTO_INCLUDES) -D_FILE_OFFSET_BITS=64 10 | LOCAL_LDFLAGS = 11 | 12 | # DEBUG 13 | #LOCAL_CFLAGS += -g3 -O0 14 | 15 | SOEXT_CRYPTO=so.3 16 | 17 | # Set AR_DASH= (empty string) to use an ar implementation that does not accept 18 | # the - prefix for command line options (e.g. llvm-ar) 19 | AR_DASH ?= - 20 | 21 | ARFLAGS = $(AR_DASH)src 22 | 23 | DLEXT ?= so 24 | 25 | OBJS_CRYPTO= aes.o \ 26 | base64.o \ 27 | bignum.o \ 28 | derenc.o \ 29 | ecdh.o \ 30 | ecdsa.o \ 31 | ecp.o \ 32 | ecp_curves.o \ 33 | hkdf.o \ 34 | hmac_drbg.o \ 35 | md.o \ 36 | sha1.o \ 37 | sha256.o \ 38 | x509bldr.o \ 39 | platform_util.o \ 40 | RiotCrypt.o 41 | 42 | LOCAL_CFLAGS+=$(THIRDPARTY_INCLUDES) 43 | OBJS_CRYPTO+=$(THIRDPARTY_CRYPTO_OBJECTS) 44 | 45 | .SILENT: 46 | 47 | .PHONY: all static shared clean 48 | 49 | ifndef SHARED 50 | all: static 51 | else 52 | all: shared static 53 | endif 54 | 55 | static: libmbedcrypto.a 56 | 57 | shared: libmbedcrypto.$(DLEXT) 58 | 59 | # crypto 60 | libmbedcrypto.a: $(OBJS_CRYPTO) 61 | echo " AR $@" 62 | $(AR) $(ARFLAGS) $@ $(OBJS_CRYPTO) 63 | 64 | libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) 65 | echo " LD $@" 66 | $(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO) 67 | 68 | libmbedcrypto.so: libmbedcrypto.$(SOEXT_CRYPTO) 69 | echo " LN $@ -> $<" 70 | ln -sf $< $@ 71 | 72 | .c.o: 73 | echo " CC $<" 74 | $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@ 75 | 76 | clean: 77 | rm -f *.o libmbed* $(OBJS_CRYPTO) 78 | 79 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RIoTCrypt/hkdf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * HKDF implementation -- RFC 5869 3 | * 4 | * Copyright (C) 2016-2018, ARM Limited, All Rights Reserved 5 | * SPDX-License-Identifier: Apache-2.0 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 8 | * not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * This file is part of mbed TLS (https://tls.mbed.org) 20 | */ 21 | #if !defined(MBEDTLS_CONFIG_FILE) 22 | #include "mbedtls/config.h" 23 | #else 24 | #include MBEDTLS_CONFIG_FILE 25 | #endif 26 | 27 | #if defined(MBEDTLS_HKDF_C) 28 | 29 | #include 30 | #include "mbedtls/hkdf.h" 31 | #include "mbedtls/platform_util.h" 32 | 33 | int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt, 34 | size_t salt_len, const unsigned char *ikm, size_t ikm_len, 35 | const unsigned char *info, size_t info_len, 36 | unsigned char *okm, size_t okm_len ) 37 | { 38 | int ret; 39 | unsigned char prk[MBEDTLS_MD_MAX_SIZE]; 40 | 41 | ret = mbedtls_hkdf_extract( md, salt, salt_len, ikm, ikm_len, prk ); 42 | 43 | if( ret == 0 ) 44 | { 45 | ret = mbedtls_hkdf_expand( md, prk, mbedtls_md_get_size( md ), 46 | info, info_len, okm, okm_len ); 47 | } 48 | 49 | mbedtls_platform_zeroize( prk, sizeof( prk ) ); 50 | 51 | return( ret ); 52 | } 53 | 54 | int mbedtls_hkdf_extract( const mbedtls_md_info_t *md, 55 | const unsigned char *salt, size_t salt_len, 56 | const unsigned char *ikm, size_t ikm_len, 57 | unsigned char *prk ) 58 | { 59 | unsigned char null_salt[MBEDTLS_MD_MAX_SIZE] = { '\0' }; 60 | 61 | if( salt == NULL ) 62 | { 63 | size_t hash_len; 64 | 65 | if( salt_len != 0 ) 66 | { 67 | return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA; 68 | } 69 | 70 | hash_len = mbedtls_md_get_size( md ); 71 | 72 | if( hash_len == 0 ) 73 | { 74 | return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA; 75 | } 76 | 77 | salt = null_salt; 78 | salt_len = hash_len; 79 | } 80 | 81 | return( mbedtls_md_hmac( md, salt, salt_len, ikm, ikm_len, prk ) ); 82 | } 83 | 84 | int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, 85 | size_t prk_len, const unsigned char *info, 86 | size_t info_len, unsigned char *okm, size_t okm_len ) 87 | { 88 | size_t hash_len; 89 | size_t where = 0; 90 | size_t n; 91 | size_t t_len = 0; 92 | size_t i; 93 | int ret = 0; 94 | mbedtls_md_context_t ctx; 95 | unsigned char t[MBEDTLS_MD_MAX_SIZE]; 96 | 97 | if( okm == NULL ) 98 | { 99 | return( MBEDTLS_ERR_HKDF_BAD_INPUT_DATA ); 100 | } 101 | 102 | hash_len = mbedtls_md_get_size( md ); 103 | 104 | if( prk_len < hash_len || hash_len == 0 ) 105 | { 106 | return( MBEDTLS_ERR_HKDF_BAD_INPUT_DATA ); 107 | } 108 | 109 | if( info == NULL ) 110 | { 111 | info = (const unsigned char *) ""; 112 | info_len = 0; 113 | } 114 | 115 | n = okm_len / hash_len; 116 | 117 | if( (okm_len % hash_len) != 0 ) 118 | { 119 | n++; 120 | } 121 | 122 | /* 123 | * Per RFC 5869 Section 2.3, okm_len must not exceed 124 | * 255 times the hash length 125 | */ 126 | if( n > 255 ) 127 | { 128 | return( MBEDTLS_ERR_HKDF_BAD_INPUT_DATA ); 129 | } 130 | 131 | mbedtls_md_init( &ctx ); 132 | 133 | if( (ret = mbedtls_md_setup( &ctx, md, 1) ) != 0 ) 134 | { 135 | goto exit; 136 | } 137 | 138 | /* 139 | * Compute T = T(1) | T(2) | T(3) | ... | T(N) 140 | * Where T(N) is defined in RFC 5869 Section 2.3 141 | */ 142 | for( i = 1; i <= n; i++ ) 143 | { 144 | size_t num_to_copy; 145 | unsigned char c = i & 0xff; 146 | 147 | ret = mbedtls_md_hmac_starts( &ctx, prk, prk_len ); 148 | if( ret != 0 ) 149 | { 150 | goto exit; 151 | } 152 | 153 | ret = mbedtls_md_hmac_update( &ctx, t, t_len ); 154 | if( ret != 0 ) 155 | { 156 | goto exit; 157 | } 158 | 159 | ret = mbedtls_md_hmac_update( &ctx, info, info_len ); 160 | if( ret != 0 ) 161 | { 162 | goto exit; 163 | } 164 | 165 | /* The constant concatenated to the end of each T(n) is a single octet. 166 | * */ 167 | ret = mbedtls_md_hmac_update( &ctx, &c, 1 ); 168 | if( ret != 0 ) 169 | { 170 | goto exit; 171 | } 172 | 173 | ret = mbedtls_md_hmac_finish( &ctx, t ); 174 | if( ret != 0 ) 175 | { 176 | goto exit; 177 | } 178 | 179 | num_to_copy = i != n ? hash_len : okm_len - where; 180 | memcpy( okm + where, t, num_to_copy ); 181 | where += hash_len; 182 | t_len = hash_len; 183 | } 184 | 185 | exit: 186 | mbedtls_md_free( &ctx ); 187 | mbedtls_platform_zeroize( t, sizeof( t ) ); 188 | 189 | return( ret ); 190 | } 191 | 192 | #endif /* MBEDTLS_HKDF_C */ 193 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RIoTCrypt/include/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #ifndef RIOT_BASE64_H 6 | #define RIOT_BASE64_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define Base64Length(l) ((l == 0) ? (1) : (((((l - 1) / 3) + 1) * 4) + 1)) 13 | 14 | int 15 | Base64Encode( 16 | const unsigned char *Input, 17 | uint32_t Length, 18 | char *Output, 19 | uint32_t *OutLen 20 | ); 21 | 22 | int 23 | Base64Decode( 24 | const char *Input, 25 | unsigned char *Output, 26 | uint32_t *OutLen 27 | ); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RIoTCrypt/include/derenc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #pragma once 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define DER_MAX_PEM 0x500 12 | #define DER_MAX_TBS 0x500 13 | #define DER_MAX_NESTED 0x10 14 | 15 | // 16 | // Context structure for the DER-encoder. This structure contains a fixed- 17 | // length array for nested SEQUENCES (which imposes a nesting limit). 18 | // The buffer use for encoded data is caller-allocted. 19 | // 20 | typedef struct 21 | { 22 | uint8_t *Buffer; // Encoded data 23 | uint32_t Length; // Size, in bytes, of Buffer 24 | uint32_t Position; // Current buffer position 25 | 26 | // SETS, SEQUENCES, etc. can be nested. This array contains the start of 27 | // the payload for collection types and is set by DERStartSequenceOrSet(). 28 | // Collections are "popped" using DEREndSequenceOrSet(). 29 | int CollectionStart[DER_MAX_NESTED]; 30 | int CollectionPos; 31 | } DERBuilderContext; 32 | 33 | // We only have a small subset of potential PEM encodings 34 | enum CertType { 35 | CERT_TYPE = 0, 36 | PUBLICKEY_TYPE, 37 | ECC_PRIVATEKEY_TYPE, 38 | CERT_REQ_TYPE, 39 | LAST_CERT_TYPE 40 | }; 41 | 42 | void 43 | DERInitContext( 44 | DERBuilderContext *Context, 45 | uint8_t *Buffer, 46 | uint32_t Length 47 | ); 48 | 49 | int 50 | DERGetEncodedLength( 51 | DERBuilderContext *Context 52 | ); 53 | 54 | 55 | int 56 | DERAddOID( 57 | DERBuilderContext *Context, 58 | int *Values 59 | ); 60 | 61 | int 62 | DERAddUTF8String( 63 | DERBuilderContext *Context, 64 | const char *Str 65 | ); 66 | 67 | int 68 | DERAddPrintableString( 69 | DERBuilderContext *Context, 70 | const char *Str 71 | ); 72 | 73 | 74 | int 75 | DERAddUTCTime( 76 | DERBuilderContext *Context, 77 | const char *Str 78 | ); 79 | 80 | int 81 | DERAddIntegerFromArray( 82 | DERBuilderContext *Context, 83 | uint8_t *Val, 84 | uint32_t NumBytes 85 | ); 86 | 87 | int 88 | DERAddInteger( 89 | DERBuilderContext *Context, 90 | int Val 91 | ); 92 | 93 | int 94 | DERAddShortExplicitInteger( 95 | DERBuilderContext *Context, 96 | int Val 97 | ); 98 | 99 | int 100 | DERAddBoolean( 101 | DERBuilderContext *Context, 102 | bool Val 103 | ); 104 | 105 | 106 | int 107 | DERAddBitString( 108 | DERBuilderContext *Context, 109 | uint8_t *BitString, 110 | uint32_t BitStringNumBytes 111 | ); 112 | 113 | int 114 | DERAddOctetString( 115 | DERBuilderContext *Context, 116 | uint8_t *OctetString, 117 | uint32_t OctetStringLen 118 | ); 119 | 120 | int 121 | DERStartSequenceOrSet( 122 | DERBuilderContext *Context, 123 | bool Sequence 124 | ); 125 | 126 | int 127 | DERStartExplicit( 128 | DERBuilderContext *Context, 129 | uint32_t Num 130 | ); 131 | 132 | int 133 | DERStartEnvelopingOctetString( 134 | DERBuilderContext *Context 135 | ); 136 | 137 | int 138 | DERStartEnvelopingBitString( 139 | DERBuilderContext *Context 140 | ); 141 | 142 | int 143 | DERPopNesting( 144 | DERBuilderContext *Context 145 | ); 146 | 147 | int 148 | DERGetNestingDepth( 149 | DERBuilderContext *Context 150 | ); 151 | 152 | int 153 | DERTbsToCert( 154 | DERBuilderContext *Context 155 | ); 156 | 157 | int 158 | DERtoPEM( 159 | DERBuilderContext *Context, 160 | uint32_t Type, 161 | char *PEM, 162 | uint32_t *Length 163 | ); 164 | 165 | #ifdef __cplusplus 166 | } 167 | #endif 168 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RIoTCrypt/include/mbedtls/md_internal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file md_internal.h 3 | * 4 | * \brief Message digest wrappers. 5 | * 6 | * \warning This in an internal header. Do not include directly. 7 | * 8 | * \author Adriaan de Jong 9 | */ 10 | /* 11 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | * This file is part of mbed TLS (https://tls.mbed.org) 27 | */ 28 | #ifndef MBEDTLS_MD_WRAP_H 29 | #define MBEDTLS_MD_WRAP_H 30 | 31 | #if !defined(MBEDTLS_CONFIG_FILE) 32 | #include "mbedtls/config.h" 33 | #else 34 | #include MBEDTLS_CONFIG_FILE 35 | #endif 36 | 37 | #include "mbedtls/md.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** 44 | * Message digest information. 45 | * Allows message digest functions to be called in a generic way. 46 | */ 47 | struct mbedtls_md_info_t 48 | { 49 | /** Name of the message digest */ 50 | const char * name; 51 | 52 | /** Digest identifier */ 53 | mbedtls_md_type_t type; 54 | 55 | /** Output length of the digest function in bytes */ 56 | unsigned char size; 57 | 58 | /** Block length of the digest function in bytes */ 59 | unsigned char block_size; 60 | }; 61 | 62 | #if defined(MBEDTLS_MD2_C) 63 | extern const mbedtls_md_info_t mbedtls_md2_info; 64 | #endif 65 | #if defined(MBEDTLS_MD4_C) 66 | extern const mbedtls_md_info_t mbedtls_md4_info; 67 | #endif 68 | #if defined(MBEDTLS_MD5_C) 69 | extern const mbedtls_md_info_t mbedtls_md5_info; 70 | #endif 71 | #if defined(MBEDTLS_RIPEMD160_C) 72 | extern const mbedtls_md_info_t mbedtls_ripemd160_info; 73 | #endif 74 | #if defined(MBEDTLS_SHA1_C) 75 | extern const mbedtls_md_info_t mbedtls_sha1_info; 76 | #endif 77 | #if defined(MBEDTLS_SHA256_C) 78 | extern const mbedtls_md_info_t mbedtls_sha224_info; 79 | extern const mbedtls_md_info_t mbedtls_sha256_info; 80 | #endif 81 | #if defined(MBEDTLS_SHA512_C) 82 | extern const mbedtls_md_info_t mbedtls_sha384_info; 83 | extern const mbedtls_md_info_t mbedtls_sha512_info; 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* MBEDTLS_MD_WRAP_H */ 91 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RIoTCrypt/include/x509bldr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #ifndef _RIOT_X509_BLDR_H 6 | #define _RIOT_X509_BLDR_H 7 | 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | // KeyUsage :: = BIT STRING { 14 | // digitalSignature(0), 15 | // nonRepudiation(1), 16 | // keyEncipherment(2), 17 | // dataEncipherment(3), 18 | // keyAgreement(4), 19 | // keyCertSign(5), 20 | // cRLSign(6) 21 | // } 22 | #define RIOT_X509_KEY_USAGE 0x04 // keyCertSign 23 | #define RIOT_X509_SNUM_LEN 0x08 // In bytes 24 | 25 | // Const x509 "to be signed" data 26 | typedef struct 27 | { 28 | uint8_t SerialNum[RIOT_X509_SNUM_LEN]; 29 | const char *IssuerCommon; 30 | const char *IssuerOrg; 31 | const char *IssuerCountry; 32 | const char *ValidFrom; 33 | const char *ValidTo; 34 | const char *SubjectCommon; 35 | const char *SubjectOrg; 36 | const char *SubjectCountry; 37 | } RIOT_X509_TBS_DATA; 38 | 39 | int 40 | X509GetDeviceCertTBS( 41 | DERBuilderContext *Tbs, 42 | RIOT_X509_TBS_DATA *TbsData, 43 | RIOT_ECC_PUBLIC *DevIdKeyPub, 44 | uint8_t *RootKeyPub, 45 | uint32_t RootKeyPubLen 46 | ); 47 | 48 | int 49 | X509MakeDeviceCert( 50 | DERBuilderContext *DeviceIDCert, 51 | RIOT_ECC_SIGNATURE *TbsSig 52 | ); 53 | 54 | int 55 | X509GetAliasCertTBS( 56 | DERBuilderContext *Tbs, 57 | RIOT_X509_TBS_DATA *TbsData, 58 | RIOT_ECC_PUBLIC *AliasKeyPub, 59 | RIOT_ECC_PUBLIC *DevIdKeyPub, 60 | uint8_t *Fwid, 61 | uint32_t FwidLen 62 | ); 63 | 64 | int 65 | X509MakeAliasCert( 66 | DERBuilderContext *AliasCert, 67 | RIOT_ECC_SIGNATURE *TbsSig 68 | ); 69 | 70 | int 71 | X509GetDEREccPub( 72 | DERBuilderContext *Context, 73 | RIOT_ECC_PUBLIC Pub 74 | ); 75 | 76 | int 77 | X509GetDEREcc( 78 | DERBuilderContext *Context, 79 | RIOT_ECC_PUBLIC Pub, 80 | RIOT_ECC_PRIVATE Priv 81 | ); 82 | 83 | int 84 | X509GetDERCsrTbs( 85 | DERBuilderContext *Context, 86 | RIOT_X509_TBS_DATA *TbsData, 87 | RIOT_ECC_PUBLIC *DeviceIDPub 88 | ); 89 | 90 | int 91 | X509GetDERCsr( 92 | DERBuilderContext *Context, 93 | RIOT_ECC_SIGNATURE *Signature 94 | ); 95 | 96 | int 97 | X509GetRootCertTBS( 98 | DERBuilderContext *Tbs, 99 | RIOT_X509_TBS_DATA *TbsData, 100 | RIOT_ECC_PUBLIC *RootKeyPub 101 | ); 102 | 103 | int 104 | X509MakeRootCert( 105 | DERBuilderContext *AliasCert, 106 | RIOT_ECC_SIGNATURE *TbsSig 107 | ); 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | #endif -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RIoTCrypt/platform_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Common and shared functions used by multiple modules in the Mbed TLS 3 | * library. 4 | * 5 | * Copyright (C) 2018, Arm Limited, All Rights Reserved 6 | * SPDX-License-Identifier: Apache-2.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 9 | * not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 16 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * This file is part of Mbed TLS (https://tls.mbed.org) 21 | */ 22 | 23 | /* 24 | * Ensure gmtime_r is available even with -std=c99; must be defined before 25 | * config.h, which pulls in glibc's features.h. Harmless on other platforms. 26 | */ 27 | #if !defined(_POSIX_C_SOURCE) 28 | #define _POSIX_C_SOURCE 200112L 29 | #endif 30 | 31 | #if !defined(MBEDTLS_CONFIG_FILE) 32 | #include "mbedtls/config.h" 33 | #else 34 | #include MBEDTLS_CONFIG_FILE 35 | #endif 36 | 37 | #include "mbedtls/platform_util.h" 38 | #include "mbedtls/platform.h" 39 | //#include "mbedtls/threading.h" 40 | 41 | #include 42 | #include 43 | 44 | #if !defined(MBEDTLS_PLATFORM_ZEROIZE_ALT) 45 | /* 46 | * This implementation should never be optimized out by the compiler 47 | * 48 | * This implementation for mbedtls_platform_zeroize() was inspired from Colin 49 | * Percival's blog article at: 50 | * 51 | * http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html 52 | * 53 | * It uses a volatile function pointer to the standard memset(). Because the 54 | * pointer is volatile the compiler expects it to change at 55 | * any time and will not optimize out the call that could potentially perform 56 | * other operations on the input buffer instead of just setting it to 0. 57 | * Nevertheless, as pointed out by davidtgoldblatt on Hacker News 58 | * (refer to http://www.daemonology.net/blog/2014-09-05-erratum.html for 59 | * details), optimizations of the following form are still possible: 60 | * 61 | * if( memset_func != memset ) 62 | * memset_func( buf, 0, len ); 63 | * 64 | * Note that it is extremely difficult to guarantee that 65 | * mbedtls_platform_zeroize() will not be optimized out by aggressive compilers 66 | * in a portable way. For this reason, Mbed TLS also provides the configuration 67 | * option MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure 68 | * mbedtls_platform_zeroize() to use a suitable implementation for their 69 | * platform and needs. 70 | */ 71 | static void * (* const volatile memset_func)( void *, int, size_t ) = memset; 72 | 73 | void mbedtls_platform_zeroize( void *buf, size_t len ) 74 | { 75 | MBEDTLS_INTERNAL_VALIDATE( len == 0 || buf != NULL ); 76 | 77 | if( len > 0 ) 78 | memset_func( buf, 0, len ); 79 | } 80 | #endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */ 81 | 82 | #if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT) 83 | #include 84 | #if !defined(_WIN32) && (defined(unix) || \ 85 | defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \ 86 | defined(__MACH__))) 87 | #include 88 | #endif /* !_WIN32 && (unix || __unix || __unix__ || 89 | * (__APPLE__ && __MACH__)) */ 90 | 91 | #if !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \ 92 | ( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \ 93 | _POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) 94 | /* 95 | * This is a convenience shorthand macro to avoid checking the long 96 | * preprocessor conditions above. Ideally, we could expose this macro in 97 | * platform_util.h and simply use it in platform_util.c, threading.c and 98 | * threading.h. However, this macro is not part of the Mbed TLS public API, so 99 | * we keep it private by only defining it in this file 100 | */ 101 | #if ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) 102 | #define PLATFORM_UTIL_USE_GMTIME 103 | #endif /* ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) */ 104 | 105 | #endif /* !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \ 106 | ( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \ 107 | _POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) */ 108 | 109 | struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt, 110 | struct tm *tm_buf ) 111 | { 112 | #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) 113 | return( ( gmtime_s( tm_buf, tt ) == 0 ) ? tm_buf : NULL ); 114 | #elif !defined(PLATFORM_UTIL_USE_GMTIME) 115 | return( gmtime_r( tt, tm_buf ) ); 116 | #else 117 | struct tm *lt; 118 | 119 | #if defined(MBEDTLS_THREADING_C) 120 | if( mbedtls_mutex_lock( &mbedtls_threading_gmtime_mutex ) != 0 ) 121 | return( NULL ); 122 | #endif /* MBEDTLS_THREADING_C */ 123 | 124 | lt = gmtime( tt ); 125 | 126 | if( lt != NULL ) 127 | { 128 | memcpy( tm_buf, lt, sizeof( struct tm ) ); 129 | } 130 | 131 | #if defined(MBEDTLS_THREADING_C) 132 | if( mbedtls_mutex_unlock( &mbedtls_threading_gmtime_mutex ) != 0 ) 133 | return( NULL ); 134 | #endif /* MBEDTLS_THREADING_C */ 135 | 136 | return( ( lt == NULL ) ? NULL : tm_buf ); 137 | #endif /* _WIN32 && !EFIX64 && !EFI32 */ 138 | } 139 | #endif /* MBEDTLS_HAVE_TIME_DATE && MBEDTLS_PLATFORM_GMTIME_R_ALT */ 140 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RIoTSim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #ifndef _RIOT_DLL_H 6 | #define _RIOT_DLL_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include 13 | 14 | #ifdef RIOT_EXPORTS 15 | #define RIOT_API __declspec(dllexport) 16 | #else 17 | #define RIOT_API __declspec(dllimport) 18 | #endif 19 | 20 | RIOT_API void RiotStart(const BYTE *, const uint32_t, const TCHAR *); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif -------------------------------------------------------------------------------- /Simulation/RIoT/Core/RiotStatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #ifndef _RIOT_STATUS_H 6 | #define _RIOT_STATUS_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef enum RIOT_STATUS { 13 | RIOT_SUCCESS = 0, 14 | RIOT_FAILURE = RIOT_SUCCESS + 0x80, 15 | RIOT_INVALID_PARAMETER, 16 | RIOT_LOAD_MODULE_FAILED, 17 | RIOT_BAD_FORMAT, 18 | RIOT_INVALID_BOOT_MODE, 19 | RIOT_INVALID_STATE, 20 | RIOT_INVALID_METADATA, 21 | RIOT_INVALID_DEVICE_ID, 22 | RIOT_INVALID_MODULE, 23 | RIOT_INVALID_MODULE_DIGEST, 24 | RIOT_MODULE_UPDATE_FAILED, 25 | RIOT_METADATA_WRITE_FAILED, 26 | RIOT_STATE_UPDATE_FAILED, 27 | RIOT_INVALID_VENDOR_SIGNING_KEY, 28 | RIOT_INVALID_VENDOR_SIGNATURE, 29 | RIOT_INVALID_DEVICE_SIGNATURE, 30 | RIOT_INVALID_TICKET_SIGNATURE, 31 | RIOT_MODULE_UPDATE_NOT_APPROVED, 32 | RIOT_FAILED_UPDATE_POLICY, 33 | } RIOT_STATUS; 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/dllmain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #include "stdafx.h" 6 | 7 | BOOL APIENTRY DllMain( HMODULE hModule, 8 | DWORD ul_reason_for_call, 9 | LPVOID lpReserved 10 | ) 11 | { 12 | UNREFERENCED_PARAMETER(hModule); 13 | UNREFERENCED_PARAMETER(lpReserved); 14 | switch (ul_reason_for_call) 15 | { 16 | case DLL_PROCESS_ATTACH: 17 | case DLL_THREAD_ATTACH: 18 | case DLL_THREAD_DETACH: 19 | case DLL_PROCESS_DETACH: 20 | break; 21 | } 22 | return TRUE; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Simulation/RIoT/Core/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #include "stdafx.h" -------------------------------------------------------------------------------- /Simulation/RIoT/Core/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #pragma once 6 | 7 | #include "targetver.h" 8 | #include 9 | #include 10 | #define WIN32_LEAN_AND_MEAN 11 | #include 12 | 13 | #include "RIoT.h" 14 | 15 | #include "RIoTSim.h" -------------------------------------------------------------------------------- /Simulation/RIoT/Core/targetver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. See LICENSE in the project root. 4 | */ 5 | #pragma once 6 | #include 7 | -------------------------------------------------------------------------------- /Tools/DICETest/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Tools/DICETest/ChainChecker.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Microsoft Copyright, 2017 3 | * Author: pengland 4 | */ 5 | namespace DICETest 6 | { 7 | using System.Security.Cryptography.X509Certificates; 8 | 9 | /// 10 | /// Checks a chain using the system (rather than bouncy castle) chain validator. BC seems to have 11 | /// problems with EKU - clientAuth 12 | /// 13 | class ChainChecker 14 | { 15 | public static bool CheckChain(Org.BouncyCastle.X509.X509Certificate[] certs) 16 | { 17 | int numCerts = certs.Length; 18 | var sysCerts = new System.Security.Cryptography.X509Certificates.X509Certificate2[numCerts]; 19 | for(int j=0;j 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6} 8 | Exe 9 | DICETest 10 | DICETest 11 | v4.5.2 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | bin\Debug\DICETest.xml 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\packages\BouncyCastle.1.8.1\lib\BouncyCastle.Crypto.dll 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Tools/DICETest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("DICETest")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("DICETest")] 12 | [assembly: AssemblyCopyright("Copyright © 2017")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("3717e055-2380-4a9f-8d6e-7e6b980ea3c6")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Tools/DICETest/README.txt: -------------------------------------------------------------------------------- 1 |  2 | DICETest is a command-line tool for doing basic validation of the certificates 3 | produced by a DICE/RIoT implementation. 4 | 5 | Example usage: 6 | 7 | // Check the validity of various certificate chains 8 | DICETest -chain AliasCert.PEM DeviceIDCert.PEM RootCert.PEM 9 | DICETest -chain AliasCert.PEM DeviceIDCert.PEM IntermediateCert.PEM RootCert.PEM 10 | DICETest -chain AliasCert.PEM DeviceIDSelfSignedCert.PEM 11 | 12 | // Check a "proof of posession" DeviceID certificate for the given root cert 13 | DICETest -pop CN=XXXXyyyyZZZZ DevIDPopCert.PEM RootCert.PEM 14 | 15 | // Check that the CSR is valid (self-signed) 16 | DICETest -csr DevIDCSR.PEM 17 | 18 | -------------------------------------------------------------------------------- /Tools/DICETest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Tools/Docs/Notes.txt: -------------------------------------------------------------------------------- 1 | 2 | This solution contains tools and utilities for testing DICE/RIoT systems. 3 | 4 | DICETest - Command-line tool that checks certificates and certificate chains created by DICE/RIoT systems 5 | RIoT - More in-depth certificate testing, including TLS tests 6 | RIoTDemo - (deprecated) 7 | TlsClient - (deprecated) -------------------------------------------------------------------------------- /Tools/Docs/RiotUtils.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/RIoT/2a1f1d04d69f61e23df4c046f2b761a178c50333/Tools/Docs/RiotUtils.docx -------------------------------------------------------------------------------- /Tools/README: -------------------------------------------------------------------------------- 1 | DICE/RIoT Test and Tools -------------------------------------------------------------------------------- /Tools/RIoT/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Tools/RIoT/ExtensionDecoder2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | /* 7 | * This will be a RIoT extension decoder that doesn't use BC. 8 | * INCOMPLETE 9 | * 10 | * */ 11 | 12 | 13 | 14 | namespace RIoT 15 | { 16 | internal enum DerTags 17 | { 18 | Integer = 2, 19 | BitString = 3, 20 | Sequence = 16, 21 | Oid = 6 22 | } 23 | 24 | internal class ExtensionDecoder2 25 | { 26 | internal ExtensionDecoder2(byte[] extension) 27 | { 28 | 29 | } 30 | } 31 | 32 | internal class DERSequence 33 | { 34 | byte[] Data; 35 | // this describes the data in this sequence 36 | int Start; 37 | int TotalLength; 38 | int PayloadStart; 39 | int PayloadLength; 40 | int EndPointer; 41 | // This is 42 | int ParsePointer; 43 | 44 | internal DERSequence(byte[] _x, int _start) 45 | { 46 | Data = _x; 47 | Start = _start; 48 | ParsePointer = Start; 49 | if (Data[ParsePointer++] != (byte)DerTags.Sequence) 50 | { 51 | throw new Exception($"Not a sequence: start = {Start}"); 52 | } 53 | PayloadLength = GetDEREncodedInt(); 54 | PayloadStart = ParsePointer; 55 | //TotalLength = PayloadLength + headerLength; 56 | EndPointer = Start + TotalLength; 57 | if (Start + TotalLength > Data.Length) throw new Exception($"Sequence length of {PayloadLength}, but only {Data.Length - Start}"); 58 | } 59 | internal DERSequence GetSequence() 60 | { 61 | var s = new DERSequence(Data, ParsePointer); 62 | ParsePointer += s.TotalLength; 63 | return s; 64 | } 65 | internal int GetShortInt() 66 | { 67 | var tag = (byte)Data[ParsePointer++]; 68 | if (tag != (byte)DerTags.Integer) throw new Exception($"Integer tag expected at {ParsePointer}"); 69 | int dataLen = GetDEREncodedInt(); 70 | if (dataLen > 1) throw new NotImplementedException(); 71 | return (int)Data[ParsePointer++]; 72 | } 73 | internal int GetOctetString() 74 | { 75 | var tag = (byte)Data[ParsePointer++]; 76 | if (tag != (byte)DerTags.Integer) throw new Exception($"Integer tag expected at {ParsePointer}"); 77 | int dataLen = GetDEREncodedInt(); 78 | if (dataLen > 1) throw new NotImplementedException(); 79 | return (int)Data[ParsePointer++]; 80 | } 81 | 82 | 83 | internal int GetOID() 84 | { 85 | var tag = Data[ParsePointer++]; 86 | if (tag != (byte)DerTags.Oid) throw new Exception($"OID tag expected at {ParsePointer}"); 87 | int intLen = GetDEREncodedInt(); 88 | ParsePointer += intLen; 89 | return 0; 90 | } 91 | private int GetDEREncodedInt() 92 | { 93 | if (ParsePointer >= EndPointer) throw new Exception("overflow"); 94 | uint n = (uint)Data[ParsePointer++]; 95 | // if n<127, then it's the length 96 | if (n < 127) return (int)n; 97 | // if n>127 then it's the number of bytes. We only care about 98 | // small numbers 99 | if (n == 1) 100 | { 101 | if (ParsePointer >= EndPointer) throw new Exception("e2"); 102 | return (int)Data[ParsePointer++]; 103 | } 104 | if (n == 2) 105 | { 106 | if (ParsePointer >= EndPointer) throw new Exception("e2"); 107 | int t = Data[ParsePointer++] * 256; 108 | if (ParsePointer >= EndPointer) throw new Exception("e2"); 109 | return t + Data[ParsePointer++]; 110 | } 111 | 112 | throw new Exception("Number too big"); 113 | } 114 | 115 | 116 | } 117 | /* 118 | internal class DerHeader 119 | { 120 | // todo - sequence overflow 121 | internal static int GetLength(byte[] x, int pos) 122 | { 123 | uint n = (uint)x[pos]; 124 | // if n<127, then it's the length 125 | if (n < 127) return (int)n; 126 | // if n>127 then it's the number of bytes. We only care about 127 | // small numbers 128 | if (n == 1) return (int)x[pos + 1]; 129 | if (n == 2) return x[pos + 1] * 256 + x[pos + 2]; 130 | throw new Exception("Number too big"); 131 | } 132 | internal static int GetLengthLength(byte[] x, int pos) 133 | { 134 | uint n = (uint)x[pos]; 135 | if (n < 127) return 1; 136 | return (int)n + 1; 137 | } 138 | 139 | } 140 | */ 141 | } 142 | -------------------------------------------------------------------------------- /Tools/RIoT/HttpsListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Security; 6 | using System.Security.Cryptography.X509Certificates; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace RIoT 11 | { 12 | class HttpsListener 13 | { 14 | 15 | static internal void StartListener(string _serverCert, string _serverKey, string serverCA, string _clientCert, string _clientKey) 16 | { 17 | // note that the programmatic cert creation and installation didn't work so did this - 18 | // makecert.exe - r - a sha1 - n CN = localhost - sky exchange - pe - b 01 / 01 / 2000 - e 01 / 01 / 2050 - ss my 19 | // then this 20 | // C:\Repos\RIoT Development\Utlilities\RIoTUtils\bin\Debug\Certs>netsh http add sslcert ipport=0.0.0.0:5556 appid={20a30499-7f02-446f-8716-e85fcdbb0ce4} certhash=360e6b474436076ff6cca4b1281fda021c276dbb 21 | // SSL Certificate successfully added 22 | 23 | 24 | 25 | // we need to add the server cert to the store for HttpListener to use it 26 | string serverPfxFile = "ServerCert.PFX"; 27 | Helpers.MakePFXFile(_serverCert, _serverKey, serverPfxFile, null); 28 | Helpers.DeleteCertsByIssuer("MSR_TEST"); 29 | 30 | Helpers.InstallCert(serverCA); 31 | Helpers.InstallCert(serverPfxFile); 32 | Helpers.SetCertForPort(serverPfxFile, 5556); 33 | 34 | string clientPfxFile = "ClientCert.PFX"; 35 | Helpers.MakePFXFile(_clientCert, _clientKey, clientPfxFile, null); 36 | 37 | 38 | 39 | // ‎9970e392d44f8d08c158660f1a0b05838f6201f0 40 | 41 | // ‎360e6b474436076ff6cca4b1281fda021c276dbb 42 | SSLValidator.OverrideValidation(); 43 | 44 | var listener = new HttpListener(); 45 | 46 | listener.Prefixes.Add("https://127.0.0.1:5556/ABC/"); 47 | listener.Start(); 48 | Console.WriteLine("Listening..."); 49 | 50 | 51 | SslTcpClient.RunClient(_clientCert, _clientKey); 52 | 53 | /* 54 | // make a request 55 | //You must change the path to point to your .cer file location. 56 | X509Certificate Cert = X509Certificate.CreateFromCertFile("ClientCert.PFX"); 57 | // Handle any certificate errors on the certificate from the server. 58 | // You must change the URL to point to your Web server. 59 | HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://127.0.0.1:5556/ABC/123"); 60 | Request.ClientCertificates.Add(Cert); 61 | Request.UserAgent = "Client Cert Sample"; 62 | Request.Method = "GET"; 63 | var responseFromServer = Request.GetResponseAsync(); 64 | //string respx = responseFromServer.Result.ToString(); 65 | 66 | */ 67 | 68 | var context = listener.GetContext(); 69 | HttpListenerRequest request = context.Request; 70 | // Obtain a response object. 71 | HttpListenerResponse response = context.Response; 72 | 73 | var cert = request.GetClientCertificate(); 74 | 75 | // Construct a response. 76 | string responseString = " Hello world!"; 77 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); 78 | // Get a response stream and write the response to it. 79 | response.ContentLength64 = buffer.Length; 80 | System.IO.Stream output = response.OutputStream; 81 | output.Write(buffer, 0, buffer.Length); 82 | // You must close the output stream. 83 | output.Close(); 84 | listener.Stop(); 85 | 86 | 87 | } 88 | } 89 | public static class SSLValidator 90 | { 91 | private static RemoteCertificateValidationCallback _orgCallback; 92 | 93 | private static bool OnValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 94 | { 95 | return true; 96 | } 97 | 98 | public static void OverrideValidation() 99 | { 100 | _orgCallback = ServicePointManager.ServerCertificateValidationCallback; 101 | ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(OnValidateCertificate); 102 | ServicePointManager.Expect100Continue = true; 103 | } 104 | 105 | public static void RestoreValidation() 106 | { 107 | ServicePointManager.ServerCertificateValidationCallback = _orgCallback; 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Tools/RIoT/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RIoT")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RIoT")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("20a30499-7f02-446f-8716-e85fcdbb0ce4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Tools/RIoT/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 14 | 16 | 17 | 18 | 20 | 22 | 24 | 26 | 28 | 29 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 51 | 52 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/DeviceStatus.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace RIoTDemo 2 | { 3 | partial class DeviceStatus 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.pic = new System.Windows.Forms.PictureBox(); 32 | this.status = new System.Windows.Forms.TextBox(); 33 | this.DeviceID = new System.Windows.Forms.Label(); 34 | this.message = new System.Windows.Forms.TextBox(); 35 | this.pownMe = new System.Windows.Forms.Button(); 36 | ((System.ComponentModel.ISupportInitialize)(this.pic)).BeginInit(); 37 | this.SuspendLayout(); 38 | // 39 | // pic 40 | // 41 | this.pic.Location = new System.Drawing.Point(19, 45); 42 | this.pic.Name = "pic"; 43 | this.pic.Size = new System.Drawing.Size(187, 137); 44 | this.pic.TabIndex = 0; 45 | this.pic.TabStop = false; 46 | // 47 | // status 48 | // 49 | this.status.Location = new System.Drawing.Point(19, 206); 50 | this.status.Name = "status"; 51 | this.status.Size = new System.Drawing.Size(104, 20); 52 | this.status.TabIndex = 1; 53 | // 54 | // DeviceID 55 | // 56 | this.DeviceID.AutoSize = true; 57 | this.DeviceID.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 58 | this.DeviceID.Location = new System.Drawing.Point(19, 4); 59 | this.DeviceID.Name = "DeviceID"; 60 | this.DeviceID.Size = new System.Drawing.Size(136, 29); 61 | this.DeviceID.TabIndex = 2; 62 | this.DeviceID.Text = "UnknownID"; 63 | // 64 | // message 65 | // 66 | this.message.Location = new System.Drawing.Point(19, 180); 67 | this.message.Name = "message"; 68 | this.message.Size = new System.Drawing.Size(187, 20); 69 | this.message.TabIndex = 3; 70 | // 71 | // pownMe 72 | // 73 | this.pownMe.Location = new System.Drawing.Point(129, 206); 74 | this.pownMe.Name = "pownMe"; 75 | this.pownMe.Size = new System.Drawing.Size(75, 23); 76 | this.pownMe.TabIndex = 4; 77 | this.pownMe.Text = "P0wn Me!"; 78 | this.pownMe.UseVisualStyleBackColor = true; 79 | this.pownMe.Click += new System.EventHandler(this.pownMe_Click); 80 | // 81 | // DeviceStatus 82 | // 83 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 84 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 85 | this.Controls.Add(this.pownMe); 86 | this.Controls.Add(this.message); 87 | this.Controls.Add(this.DeviceID); 88 | this.Controls.Add(this.status); 89 | this.Controls.Add(this.pic); 90 | this.Name = "DeviceStatus"; 91 | this.Size = new System.Drawing.Size(231, 241); 92 | ((System.ComponentModel.ISupportInitialize)(this.pic)).EndInit(); 93 | this.ResumeLayout(false); 94 | this.PerformLayout(); 95 | 96 | } 97 | 98 | #endregion 99 | 100 | private System.Windows.Forms.PictureBox pic; 101 | private System.Windows.Forms.TextBox status; 102 | private System.Windows.Forms.Label DeviceID; 103 | private System.Windows.Forms.TextBox message; 104 | private System.Windows.Forms.Button pownMe; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/DeviceStatus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace RIoTDemo 12 | { 13 | internal enum CurrentState 14 | { 15 | Good, 16 | OldFirmware, 17 | BadFirmware 18 | } 19 | 20 | public partial class DeviceStatus : UserControl 21 | { 22 | internal string Id="Unknown"; 23 | internal int MyVersionNumber = 0; 24 | internal CurrentState State = CurrentState.BadFirmware; 25 | internal Bitmap Picture = new Bitmap(100, 100); 26 | String LastMessage; 27 | internal DateTime LastMessageTime; 28 | internal KnownColor PicColor = KnownColor.Black; 29 | 30 | internal bool AmIPOwned = false; 31 | internal bool P0wnedStatusChanged = false; 32 | 33 | 34 | public DeviceStatus() 35 | { 36 | InitializeComponent(); 37 | } 38 | 39 | void SetVersionNumber(int newVersionNumber) 40 | { 41 | if (newVersionNumber == MyVersionNumber) return; 42 | MyVersionNumber = newVersionNumber; 43 | UpdateGUI(); 44 | } 45 | internal void NotifyNewMessage(string m) 46 | { 47 | LastMessage = m; 48 | LastMessageTime = DateTime.Now; 49 | 50 | } 51 | 52 | internal void UpdateGUI() 53 | { 54 | if(LastMessage!=null) 55 | { 56 | message.Text = LastMessage; 57 | pic.BackColor = Color.FromKnownColor((KnownColor) PicColor); 58 | LastMessage = null; 59 | } 60 | 61 | if (AmIPOwned) 62 | { 63 | pownMe.BackColor = Color.Red; 64 | } 65 | else 66 | { 67 | pownMe.BackColor = Color.Green; 68 | } 69 | 70 | //this.pic. = Picture; 71 | this.DeviceID.Text = Id; 72 | this.status.Text = $"Version Number {MyVersionNumber}"; 73 | switch(State) 74 | { 75 | case CurrentState.Good: 76 | this.BackColor = Color.Green; 77 | break; 78 | case CurrentState.OldFirmware: 79 | this.BackColor = Color.Yellow; 80 | break; 81 | case CurrentState.BadFirmware: 82 | this.BackColor = Color.Red; 83 | break; 84 | default: 85 | this.BackColor = Color.Red; 86 | break; 87 | } 88 | 89 | 90 | 91 | } 92 | 93 | private void pownMe_Click(object sender, EventArgs e) 94 | { 95 | AmIPOwned = !AmIPOwned; 96 | P0wnedStatusChanged = true; 97 | 98 | 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/MainPage.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace RIoTDemo 2 | { 3 | partial class MainPage 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.timer1 = new System.Windows.Forms.Timer(this.components); 33 | this.button1 = new System.Windows.Forms.Button(); 34 | this.VersionNumber = new System.Windows.Forms.Label(); 35 | this.SuspendLayout(); 36 | // 37 | // button1 38 | // 39 | this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 40 | this.button1.Location = new System.Drawing.Point(13, 13); 41 | this.button1.Name = "button1"; 42 | this.button1.Size = new System.Drawing.Size(145, 42); 43 | this.button1.TabIndex = 0; 44 | this.button1.Text = "StartUpdate"; 45 | this.button1.UseVisualStyleBackColor = true; 46 | this.button1.Click += new System.EventHandler(this.button1_Click); 47 | // 48 | // VersionNumber 49 | // 50 | this.VersionNumber.AutoSize = true; 51 | this.VersionNumber.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 52 | this.VersionNumber.Location = new System.Drawing.Point(201, 20); 53 | this.VersionNumber.Name = "VersionNumber"; 54 | this.VersionNumber.Size = new System.Drawing.Size(312, 24); 55 | this.VersionNumber.TabIndex = 1; 56 | this.VersionNumber.Text = "Target Firmware Version Number: 0"; 57 | // 58 | // MainPage 59 | // 60 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 61 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 62 | this.ClientSize = new System.Drawing.Size(805, 504); 63 | this.Controls.Add(this.VersionNumber); 64 | this.Controls.Add(this.button1); 65 | this.Name = "MainPage"; 66 | this.Text = "Device Status"; 67 | this.Paint += new System.Windows.Forms.PaintEventHandler(this.MainPage_Paint); 68 | this.ResumeLayout(false); 69 | this.PerformLayout(); 70 | 71 | } 72 | 73 | #endregion 74 | 75 | private System.Windows.Forms.Timer timer1; 76 | private System.Windows.Forms.Button button1; 77 | private System.Windows.Forms.Label VersionNumber; 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace RIoTDemo 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new MainPage()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RIoTDemo")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RIoTDemo")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("70669fd8-b9bb-4ea2-b9bb-6e387b2e5788")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace RIoTDemo.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RIoTDemo.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace RIoTDemo.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Tools/RIoTDemo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Tools/RIoTUtils.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.6 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RIoT", "RIoT\RIoT.csproj", "{20A30499-7F02-446F-8716-E85FCDBB0CE4}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TlsClient", "TlsClient\TlsClient.vcxproj", "{E144BF89-3BEA-402C-B58A-A3DB2AC68F67}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{590E0BE7-0E85-4923-AD6D-7DA0E2F7FF1C}" 11 | ProjectSection(SolutionItems) = preProject 12 | Docs\Notes.txt = Docs\Notes.txt 13 | Docs\RiotUtils.docx = Docs\RiotUtils.docx 14 | EndProjectSection 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RIoTDemo", "RIoTDemo\RIoTDemo.csproj", "{70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DICETest", "DICETest\DICETest.csproj", "{3717E055-2380-4A9F-8D6E-7E6B980EA3C6}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Debug|x64 = Debug|x64 24 | Debug|x86 = Debug|x86 25 | Release|Any CPU = Release|Any CPU 26 | Release|x64 = Release|x64 27 | Release|x86 = Release|x86 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Debug|x64.ActiveCfg = Debug|Any CPU 33 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Debug|x64.Build.0 = Debug|Any CPU 34 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Debug|x86.ActiveCfg = Debug|Any CPU 35 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Debug|x86.Build.0 = Debug|Any CPU 36 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Release|x64.ActiveCfg = Release|Any CPU 39 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Release|x64.Build.0 = Release|Any CPU 40 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Release|x86.ActiveCfg = Release|Any CPU 41 | {20A30499-7F02-446F-8716-E85FCDBB0CE4}.Release|x86.Build.0 = Release|Any CPU 42 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Debug|Any CPU.ActiveCfg = Debug|Win32 43 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Debug|x64.ActiveCfg = Debug|x64 44 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Debug|x64.Build.0 = Debug|x64 45 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Debug|x86.ActiveCfg = Debug|Win32 46 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Debug|x86.Build.0 = Debug|Win32 47 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Release|Any CPU.ActiveCfg = Release|Win32 48 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Release|x64.ActiveCfg = Release|x64 49 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Release|x64.Build.0 = Release|x64 50 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Release|x86.ActiveCfg = Release|Win32 51 | {E144BF89-3BEA-402C-B58A-A3DB2AC68F67}.Release|x86.Build.0 = Release|Win32 52 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Debug|x64.ActiveCfg = Debug|Any CPU 55 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Debug|x64.Build.0 = Debug|Any CPU 56 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Debug|x86.ActiveCfg = Debug|Any CPU 57 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Debug|x86.Build.0 = Debug|Any CPU 58 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Release|Any CPU.Build.0 = Release|Any CPU 60 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Release|x64.ActiveCfg = Release|Any CPU 61 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Release|x64.Build.0 = Release|Any CPU 62 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Release|x86.ActiveCfg = Release|Any CPU 63 | {70669FD8-B9BB-4EA2-B9BB-6E387B2E5788}.Release|x86.Build.0 = Release|Any CPU 64 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 65 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Debug|Any CPU.Build.0 = Debug|Any CPU 66 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Debug|x64.ActiveCfg = Debug|Any CPU 67 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Debug|x64.Build.0 = Debug|Any CPU 68 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Debug|x86.ActiveCfg = Debug|Any CPU 69 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Debug|x86.Build.0 = Debug|Any CPU 70 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Release|Any CPU.ActiveCfg = Release|Any CPU 71 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Release|Any CPU.Build.0 = Release|Any CPU 72 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Release|x64.ActiveCfg = Release|Any CPU 73 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Release|x64.Build.0 = Release|Any CPU 74 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Release|x86.ActiveCfg = Release|Any CPU 75 | {3717E055-2380-4A9F-8D6E-7E6B980EA3C6}.Release|x86.Build.0 = Release|Any CPU 76 | EndGlobalSection 77 | GlobalSection(SolutionProperties) = preSolution 78 | HideSolutionNode = FALSE 79 | EndGlobalSection 80 | GlobalSection(ExtensibilityGlobals) = postSolution 81 | EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8 82 | EndGlobalSection 83 | EndGlobal 84 | -------------------------------------------------------------------------------- /Tools/TlsClient/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : TlsClient Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this TlsClient application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your TlsClient application. 9 | 10 | 11 | TlsClient.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | TlsClient.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | TlsClient.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named TlsClient.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /Tools/TlsClient/TlsClient.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /Tools/TlsClient/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // TlsClient.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Tools/TlsClient/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #define _CRT_SECURE_NO_WARNINGS 9 | 10 | #include "targetver.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | // just need this for Sleep() - a debugging aid 23 | #define WIN32_LEAN_AND_MEAN 24 | #include 25 | 26 | 27 | #ifndef UNUSED 28 | # define UNUSED(x) ((void)(x)) 29 | #endif 30 | 31 | #ifndef TRUE 32 | # define TRUE 1 33 | #endif 34 | 35 | #ifndef FALSE 36 | # define FALSE 0 37 | #endif 38 | 39 | #ifndef HOST_NAME 40 | # define HOST_NAME "localhost" 41 | #endif 42 | 43 | #ifndef HOST_PORT 44 | # define HOST_PORT "5556" 45 | #endif 46 | 47 | #ifndef HOST_RESOURCE 48 | # define HOST_RESOURCE "/cgi-bin/randbyte?nbytes=32&format=h" 49 | #endif 50 | 51 | # define ASSERT(x) { \ 52 | if(!(x)) { \ 53 | fprintf(stderr, "Assertion: %s: function %s, line %d\n", (char*)(__FILE__), (char*)(__func__), (int)__LINE__); \ 54 | } \ 55 | } 56 | 57 | 58 | // TODO: reference additional headers your program requires here 59 | -------------------------------------------------------------------------------- /Tools/TlsClient/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | --------------------------------------------------------------------------------