Skip to content

Commit 55f685e

Browse files
committed
sketch of the identity key stuff
1 parent 0c9cc55 commit 55f685e

14 files changed

+64
-60
lines changed

TextSecureiOS.xcodeproj/project.pbxproj

Lines changed: 26 additions & 34 deletions
Large diffs are not rendered by default.

TextSecureiOS.xcodeproj/project.pbxproj~

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,11 +2542,8 @@
25422542
B639AF0D17F5A68100B2244D /* TSNetworkManager.m in Sources */,
25432543
6FCE040C18D427CE00C33B34 /* TSStartOverSegue.m in Sources */,
25442544
B63A72161808B8AF00C353F2 /* VerificationCodeViewController.m in Sources */,
2545-
<<<<<<< HEAD
25462545
A57297DB18E7579F00C8612E /* TSScanIdentityBarcodeViewController.m in Sources */,
2547-
=======
25482546
FCD30FC918FDBBB7003BD188 /* SignUpStepsViewController.m in Sources */,
2549-
>>>>>>> b4cc1284f8f6766b71175818c20063816736fad0
25502547
8CF7BD9B1870F23D0023A781 /* TSUserKeysDatabase.m in Sources */,
25512548
8CF7BD951870C8450023A781 /* TSStorageMasterKey.m in Sources */,
25522549
B6F10B1717EF4A3A00723719 /* NSLocale+phonePrefixes.m in Sources */,
@@ -2799,10 +2796,7 @@
27992796
LIBRARY_SEARCH_PATHS = "$(inherited)/**";
28002797
PRODUCT_NAME = "$(TARGET_NAME)";
28012798
PROVISIONING_PROFILE = "93C0EB7E-BB96-48CE-9F6A-65CC2BE78DB3";
2802-
<<<<<<< HEAD
2803-
=======
28042799
TARGETED_DEVICE_FAMILY = "1,2";
2805-
>>>>>>> b4cc1284f8f6766b71175818c20063816736fad0
28062800
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/Libraries/include/**";
28072801
WRAPPER_EXTENSION = app;
28082802
};

TextSecureiOS/Security/Cryptography.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
@interface Cryptography : NSObject
1313
+(NSMutableData*) generateRandomBytes:(int)numberBytes;
1414
#pragma mark SHA and HMAC methods
15+
+(NSData*) computeSHA256:(NSData *)data truncatedToBytes:(int)truncatedBytes;
1516
+(NSString*)truncatedSHA1Base64EncodedWithoutPadding:(NSString*)string;
1617
+ (NSString*)computeSHA1DigestForString:(NSString*)input;
1718

TextSecureiOS/Security/Cryptography.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,15 @@ + (NSString*)computeSHA1DigestForString:(NSString*)input {
6464
return output;
6565
}
6666

67-
#pragma HMAC/SHA256
67+
#pragma makr SHA256
68+
+(NSData*) computeSHA256:(NSData *)data truncatedToBytes:(int)truncatedBytes {
69+
uint8_t digest[CC_SHA256_DIGEST_LENGTH];
70+
CC_SHA256(data.bytes, data.length, digest);
71+
return [[NSData dataWithBytes:digest length:CC_SHA256_DIGEST_LENGTH] subdataWithRange:NSMakeRange(0, truncatedBytes)];
72+
}
73+
74+
75+
#pragma mark HMAC/SHA256
6876
+(NSData*) computeSHA256HMAC:(NSData*)dataToHMAC withHMACKey:(NSData*)HMACKey{
6977
uint8_t ourHmac[CC_SHA256_DIGEST_LENGTH] = {0};
7078
CCHmac(kCCHmacAlgSHA256,

TextSecureiOS/Security/TSKeyManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@
4242
+(void) removeAllKeychainItems;
4343
+(BOOL) hasVerifiedPhoneNumber;
4444

45+
+(NSData*) getFingerprintFromIdentityKey:(NSData*)identityKey;
4546

4647
@end

TextSecureiOS/Security/TSKeyManager.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,9 @@ + (NSNumber*) getUserDeviceId{
100100
return [NSNumber numberWithInt:1];
101101
}
102102

103+
+(NSData*) getFingerprintFromIdentityKey:(NSData*)identityKey {
104+
//16-byte truncated sha-256 of public key including version byte
105+
return [Cryptography computeSHA256:identityKey truncatedToBytes:16];
106+
}
107+
103108
@end

TextSecureiOS/ViewControllers/Conversations/TSMessageViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ -(void) setupThread {
5050

5151

5252
-(void)verifyIdentity:(id)sender {
53-
[self performSegueWithIdentifier:@"VerifyIdentitySegue" sender:sender];
53+
[self performSegueWithIdentifier:@"IdentityVerifySegue" sender:sender];
5454
}
5555

5656
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
57-
if ([[segue identifier] isEqualToString:@"VerifyIdentitySegue"]) {
57+
if ([[segue identifier] isEqualToString:@"IdentityVerifySegue"]) {
5858

5959
((TSVerifyIdentityViewController*)segue.destinationViewController).contact = self.contact;
6060
}

0 commit comments

Comments
 (0)