Skip to content

Commit

Permalink
added nonce generation algorithm for iPhone7
Browse files Browse the repository at this point in the history
  • Loading branch information
tihmstar committed Jan 5, 2017
1 parent daadf3e commit af9b9f2
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 69 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505056586.761206"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "661"
endingLineNumber = "661"
landmarkName = "isManifestBufSignedForDevice()"
startingLineNumber = "665"
endingLineNumber = "665"
landmarkName = "tssrequest()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
Expand All @@ -42,13 +42,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505054938.221216"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "267"
endingLineNumber = "267"
landmarkName = "printJString()"
landmarkType = "9">
startingLineNumber = "268"
endingLineNumber = "268">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand All @@ -74,13 +72,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505054938.221216"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "264"
endingLineNumber = "264"
landmarkName = "printJString()"
landmarkType = "9">
startingLineNumber = "265"
endingLineNumber = "265">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand All @@ -90,11 +86,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505050313.841657"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "169"
endingLineNumber = "169"
startingLineNumber = "170"
endingLineNumber = "170"
landmarkName = "getBoardconfigFromModel()"
landmarkType = "9">
</BreakpointContent>
Expand All @@ -106,11 +102,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505056586.761206"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "560"
endingLineNumber = "560"
startingLineNumber = "564"
endingLineNumber = "564"
landmarkName = "tss_populate_random()"
landmarkType = "9">
</BreakpointContent>
Expand Down Expand Up @@ -138,11 +134,13 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505056586.761206"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "577"
endingLineNumber = "577">
startingLineNumber = "581"
endingLineNumber = "581"
landmarkName = "tss_populate_random()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand All @@ -152,11 +150,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505056586.761206"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "622"
endingLineNumber = "622"
startingLineNumber = "626"
endingLineNumber = "626"
landmarkName = "tssrequest()"
landmarkType = "9">
</BreakpointContent>
Expand All @@ -168,11 +166,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505056586.761206"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "616"
endingLineNumber = "616"
startingLineNumber = "620"
endingLineNumber = "620"
landmarkName = "tssrequest()"
landmarkType = "9">
</BreakpointContent>
Expand All @@ -184,11 +182,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505056586.761206"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "613"
endingLineNumber = "613"
startingLineNumber = "617"
endingLineNumber = "617"
landmarkName = "tssrequest()"
landmarkType = "9">
</BreakpointContent>
Expand All @@ -200,12 +198,12 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505054938.221216"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "245"
endingLineNumber = "245"
landmarkName = "getBuildidentity()"
startingLineNumber = "246"
endingLineNumber = "246"
landmarkName = "getBuildidentityWithBoardconfig()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
Expand All @@ -216,12 +214,12 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505058380.15763"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "794"
endingLineNumber = "794"
landmarkName = "isVersionSignedForDevice()"
startingLineNumber = "798"
endingLineNumber = "798"
landmarkName = "isManifestSignedForDevice()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
Expand All @@ -232,11 +230,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505050313.087896"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "169"
endingLineNumber = "169"
startingLineNumber = "170"
endingLineNumber = "170"
landmarkName = "getBoardconfigFromModel()"
landmarkType = "9">
</BreakpointContent>
Expand All @@ -248,11 +246,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505050314.565001"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "170"
endingLineNumber = "170"
startingLineNumber = "171"
endingLineNumber = "171"
landmarkName = "getBoardconfigFromModel()"
landmarkType = "9">
</BreakpointContent>
Expand All @@ -264,12 +262,12 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505058380.15763"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "896"
endingLineNumber = "896"
landmarkName = "getListOfiOSForDevice()"
startingLineNumber = "900"
endingLineNumber = "900"
landmarkName = "cmpfunc()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
Expand All @@ -280,12 +278,12 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505058380.15763"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "897"
endingLineNumber = "897"
landmarkName = "getListOfiOSForDevice()"
startingLineNumber = "901"
endingLineNumber = "901"
landmarkName = "cmpfunc()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
Expand All @@ -296,11 +294,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505055004.419685"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "189"
endingLineNumber = "189"
startingLineNumber = "190"
endingLineNumber = "190"
landmarkName = "getModelFromBoardconfig()"
landmarkType = "9">
</BreakpointContent>
Expand Down Expand Up @@ -376,11 +374,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505058380.15763"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "704"
endingLineNumber = "704"
startingLineNumber = "708"
endingLineNumber = "708"
landmarkName = "isManifestBufSignedForDevice()"
landmarkType = "9">
</BreakpointContent>
Expand All @@ -392,14 +390,62 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505058380.15763"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "701"
endingLineNumber = "701"
startingLineNumber = "705"
endingLineNumber = "705"
landmarkName = "isManifestBufSignedForDevice()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505339330.866195"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "566"
endingLineNumber = "566"
landmarkName = "tss_populate_random()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505339331.806523"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "559"
endingLineNumber = "559"
landmarkName = "tss_populate_random()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "tsschecker/tsschecker.c"
timestampString = "505339333.23012"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "560"
endingLineNumber = "560"
landmarkName = "tss_populate_random()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "-d iPhone7,2--list-ios-version"
argument = "-B d11ap -l"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "-d iPhone9,2"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
Expand Down
14 changes: 9 additions & 5 deletions tsschecker/tsschecker.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifdef __APPLE__
# include <CommonCrypto/CommonDigest.h>
# define SHA1(d, n, md) CC_SHA1(d, n, md)
# define SHA384(d, n, md) CC_SHA384(d, n, md)
#else
# include <openssl/sha.h>
#endif // __APPLE__
Expand Down Expand Up @@ -549,11 +550,14 @@ int tss_populate_random(plist_t tssreq, int is64bit, t_devicevals *devVals){
snprintf(devVals->generator, 19, "0x%02x%02x%02x%02x%02x%02x%02x%02x",zz[7],zz[6],zz[5],zz[4],zz[3],zz[2],zz[1],zz[0]);
SHA1(zz, 8, (unsigned char*)nonce);
}else if (nonceLen == 32){
//this is an iPhone7 device
//nonce is derived from generator with ????
error("iPhone7 device detected! Automatic generator->nonce calculation failed. Please manually specify an apnonce with len=%u\n",(unsigned int)nonceLen);
#warning TODO implement iPhone7 generator->nonce algorithm
return -1;
unsigned char zz[8];
getRandNum((char*)zz, 8, 256);

snprintf(devVals->generator, 19, "0x%02x%02x%02x%02x%02x%02x%02x%02x",zz[7],zz[6],zz[5],zz[4],zz[3],zz[2],zz[1],zz[0]);
unsigned char genHash[48]; //SHA384 digest length

SHA384(zz, 8, genHash);
memcpy(nonce, genHash, 32);
}else{
return error("[TSSR] Automatic generator->nonce calculation failed. Unknown device with noncelen=%u\n",(unsigned int)nonceLen),-1;
}
Expand Down

0 comments on commit af9b9f2

Please sign in to comment.