Skip to content

Commit

Permalink
Add code for generating SSDP xep example values
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Dec 1, 2023
1 parent 0d423aa commit 79459a0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Monal/Classes/HelperTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
@import UniformTypeIdentifiers;
@import QuickLookThumbnailing;

#import "SCRAM.h"

@interface KSCrash()
@property(nonatomic,readwrite,retain) NSString* basePath;
@end
Expand Down Expand Up @@ -356,11 +358,9 @@ +(void) initSystem
[self installExceptionHandler];
}
else
{
[self configureXcodeLogging];
}

[SwiftHelpers initSwiftHelpers];

[self activityLog];
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Monal/Classes/SCRAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 29 additions & 1 deletion Monal/Classes/SCRAM.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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

0 comments on commit 79459a0

Please sign in to comment.