From 1ba082356a4678a73485ad17313e9d3eeaae834a Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 14 Nov 2016 17:37:13 -0500 Subject: [PATCH] Explicitly include newlines in numeric fingerprint More straight forward than fudging / verifying different layout widths. // FREEBIE --- SignalServiceKit.podspec | 2 +- src/Security/OWSFingerprint.m | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/SignalServiceKit.podspec b/SignalServiceKit.podspec index 84f3b70cf..aabb1cb1c 100644 --- a/SignalServiceKit.podspec +++ b/SignalServiceKit.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "SignalServiceKit" - s.version = "0.7.0" + s.version = "0.7.1" s.summary = "An Objective-C library for communicating with the Signal messaging service." s.description = <<-DESC diff --git a/src/Security/OWSFingerprint.m b/src/Security/OWSFingerprint.m index 5c61cf262..0e77d64db 100644 --- a/src/Security/OWSFingerprint.m +++ b/src/Security/OWSFingerprint.m @@ -155,16 +155,28 @@ static uint32_t const OWSFingerprintDefaultHashIterations = 5200; } } +/** + * Formats numeric fingerprint, 3 lines in groups of 5 digits. + */ - (NSString *)displayableText { NSString *input = self.text; - NSMutableArray *chunks = [NSMutableArray new]; - for (uint i = 0; i < input.length / 5; i++) { - NSString *nextChunk = [input substringWithRange:NSMakeRange(i * 5, 5)]; - [chunks addObject:nextChunk]; + NSMutableArray *lines = [NSMutableArray new]; + + uint lineLength = self.text.length / 3; + for (uint i = 0; i < 3; i++) { + NSString *line = [input substringWithRange:NSMakeRange(i * lineLength, lineLength)]; + + NSMutableArray *chunks = [NSMutableArray new]; + for (uint i = 0; i < line.length / 5; i++) { + NSString *nextChunk = [line substringWithRange:NSMakeRange(i * 5, 5)]; + [chunks addObject:nextChunk]; + } + [lines addObject:[chunks componentsJoinedByString:@" "]]; } - return [chunks componentsJoinedByString:@" "]; + + return [lines componentsJoinedByString:@"\n"]; }