From 79459a0296948ef7a93a2dfbbf913afca2dbc975 Mon Sep 17 00:00:00 2001 From: Thilo Molitor Date: Fri, 1 Dec 2023 01:52:08 +0100 Subject: [PATCH] Add code for generating SSDP xep example values --- Monal/Classes/HelperTools.m | 9 +++++---- Monal/Classes/SCRAM.h | 2 ++ Monal/Classes/SCRAM.m | 30 +++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Monal/Classes/HelperTools.m b/Monal/Classes/HelperTools.m index cdd2d24db9..66cc0f8341 100644 --- a/Monal/Classes/HelperTools.m +++ b/Monal/Classes/HelperTools.m @@ -59,6 +59,8 @@ @import UniformTypeIdentifiers; @import QuickLookThumbnailing; +#import "SCRAM.h" + @interface KSCrash() @property(nonatomic,readwrite,retain) NSString* basePath; @end @@ -356,11 +358,9 @@ +(void) initSystem [self installExceptionHandler]; } else - { [self configureXcodeLogging]; - } + [SwiftHelpers initSwiftHelpers]; - [self activityLog]; } @@ -1645,7 +1645,8 @@ +(void) configureLogging NSString* version = [infoDict objectForKey:@"CFBundleShortVersionString"]; NSString* buildDate = [NSString stringWithUTF8String:__DATE__]; NSString* buildTime = [NSString stringWithUTF8String:__TIME__]; - DDLogInfo(@"Starting: Version %@ (%@ %@ UTC, %@) on %@", version, buildDate, buildTime, [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"], [UIDevice currentDevice].systemVersion); + DDLogInfo(@"Starting: Version %@ (%@ %@ UTC, %@) on iOS/macOS %@", version, buildDate, buildTime, [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"], [UIDevice currentDevice].systemVersion); + //[SCRAM SSDPXepOutput]; [DDLog flushLog]; DDLogVerbose(@"QOS level: %@ = %d", @"QOS_CLASS_USER_INTERACTIVE", QOS_CLASS_USER_INTERACTIVE); diff --git a/Monal/Classes/SCRAM.h b/Monal/Classes/SCRAM.h index defa41e97e..e2732daf3c 100644 --- a/Monal/Classes/SCRAM.h +++ b/Monal/Classes/SCRAM.h @@ -37,6 +37,8 @@ typedef NS_ENUM(NSUInteger, MLScramStatus) { @property (nonatomic, readonly) NSString* method; @property (nonatomic, readonly) BOOL finishedSuccessfully; @property (nonatomic, readonly) BOOL ssdpSupported; + ++(void) SSDPXepOutput; @end NS_ASSUME_NONNULL_END diff --git a/Monal/Classes/SCRAM.m b/Monal/Classes/SCRAM.m index 840179b683..3a2682e20a 100644 --- a/Monal/Classes/SCRAM.m +++ b/Monal/Classes/SCRAM.m @@ -231,7 +231,7 @@ -(NSDictionary* _Nullable) parseScramString:(NSString*) str { NSString* attribute = [component substringToIndex:1]; NSString* value = [component substringFromIndex:2]; - retval[attribute] = value; + retval[attribute] = [self unquote:value]; } return retval; } @@ -244,4 +244,32 @@ -(NSString*) quote:(NSString*) str return str; } +-(NSString*) unquote:(NSString*) str +{ + //TODO: use proper saslprep to allow for non-ascii chars + str = [str stringByReplacingOccurrencesOfString:@"=2C" withString:@","]; + str = [str stringByReplacingOccurrencesOfString:@"=3D" withString:@"="]; + return str; +} + ++(void) SSDPXepOutput +{ + SCRAM* s = [[self alloc] initWithUsername:@"user" password:@"pencil" andMethod:@"SCRAM-SHA-1-PLUS"]; + + s->_clientFirstMessageBare = @"n=user,r=12C4CD5C-E38E-4A98-8F6D-15C38F51CCC6"; + s->_gssHeader = @"p=tls-exporter,,"; + + s->_serverFirstMessage = @"r=12C4CD5C-E38E-4A98-8F6D-15C38F51CCC6a09117a6-ac50-4f2f-93f1-93799c2bddf6,s=QSXCR+Q6sek8bf92,i=4096,d=dRc3RenuSY9ypgPpERowoaySQZY="; + s->_nonce = @"12C4CD5C-E38E-4A98-8F6D-15C38F51CCC6a09117a6-ac50-4f2f-93f1-93799c2bddf6"; + s->_salt = [HelperTools dataWithBase64EncodedString:@"QSXCR+Q6sek8bf92"]; + s->_iterationCount = 4096; + + NSString* client_final_msg = [s clientFinalMessageWithChannelBindingData:[@"THIS IS FAKE CB DATA" dataUsingEncoding:NSUTF8StringEncoding]]; + DDLogError(@"client_final_msg: %@", client_final_msg); + DDLogError(@"_expectedServerSignature: %@", s->_expectedServerSignature); + + [HelperTools flushLogsWithTimeout:0.250]; + exit(0); +} + @end