mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 14:11:35 +00:00
implemented crypto and started pairing
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
FBAB29F219EDB08B00929691 /* MDNSManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBAB29F119EDB08B00929691 /* MDNSManager.m */; };
|
FBAB29F219EDB08B00929691 /* MDNSManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBAB29F119EDB08B00929691 /* MDNSManager.m */; };
|
||||||
FBAB29F619EDE0F800929691 /* Computer.m in Sources */ = {isa = PBXBuildFile; fileRef = FBAB29F519EDE0F800929691 /* Computer.m */; };
|
FBAB29F619EDE0F800929691 /* Computer.m in Sources */ = {isa = PBXBuildFile; fileRef = FBAB29F519EDE0F800929691 /* Computer.m */; };
|
||||||
FBAB29FC19EE13AA00929691 /* CryptoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBAB29FB19EE13AA00929691 /* CryptoManager.m */; };
|
FBAB29FC19EE13AA00929691 /* CryptoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBAB29FB19EE13AA00929691 /* CryptoManager.m */; };
|
||||||
|
FBC8622D19F0BEFB0087327B /* HttpManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBC8622C19F0BEFB0087327B /* HttpManager.m */; };
|
||||||
FBCC0E9A19EF9703009729EB /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FBCC0E9819EF9703009729EB /* libcrypto.a */; };
|
FBCC0E9A19EF9703009729EB /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FBCC0E9819EF9703009729EB /* libcrypto.a */; };
|
||||||
FBCC0E9B19EF9703009729EB /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FBCC0E9919EF9703009729EB /* libssl.a */; };
|
FBCC0E9B19EF9703009729EB /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FBCC0E9919EF9703009729EB /* libssl.a */; };
|
||||||
FBCC0E9D19F00659009729EB /* mkcert.c in Sources */ = {isa = PBXBuildFile; fileRef = FBCC0E9C19F00659009729EB /* mkcert.c */; };
|
FBCC0E9D19F00659009729EB /* mkcert.c in Sources */ = {isa = PBXBuildFile; fileRef = FBCC0E9C19F00659009729EB /* mkcert.c */; };
|
||||||
@@ -62,6 +63,13 @@
|
|||||||
remoteGlobalIDString = FB290CED19B2C406004C83CF;
|
remoteGlobalIDString = FB290CED19B2C406004C83CF;
|
||||||
remoteInfo = Limelight;
|
remoteInfo = Limelight;
|
||||||
};
|
};
|
||||||
|
FBC8623219F346A60087327B /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = FBC8622E19F346A60087327B /* limelight-common.xcodeproj */;
|
||||||
|
proxyType = 2;
|
||||||
|
remoteGlobalIDString = FB290E2E19B37A4E004C83CF;
|
||||||
|
remoteInfo = "limelight-common";
|
||||||
|
};
|
||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -118,6 +126,9 @@
|
|||||||
FBAB29F519EDE0F800929691 /* Computer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Computer.m; sourceTree = "<group>"; };
|
FBAB29F519EDE0F800929691 /* Computer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Computer.m; sourceTree = "<group>"; };
|
||||||
FBAB29FA19EE13AA00929691 /* CryptoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoManager.h; sourceTree = "<group>"; };
|
FBAB29FA19EE13AA00929691 /* CryptoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoManager.h; sourceTree = "<group>"; };
|
||||||
FBAB29FB19EE13AA00929691 /* CryptoManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CryptoManager.m; sourceTree = "<group>"; };
|
FBAB29FB19EE13AA00929691 /* CryptoManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CryptoManager.m; sourceTree = "<group>"; };
|
||||||
|
FBC8622B19F0BEFB0087327B /* HttpManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpManager.h; sourceTree = "<group>"; };
|
||||||
|
FBC8622C19F0BEFB0087327B /* HttpManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HttpManager.m; sourceTree = "<group>"; };
|
||||||
|
FBC8622E19F346A60087327B /* limelight-common.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "limelight-common.xcodeproj"; path = "../../limelight-common-c/limelight-common.xcodeproj"; sourceTree = "<group>"; };
|
||||||
FBCC0E4C19EF9703009729EB /* aes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aes.h; sourceTree = "<group>"; };
|
FBCC0E4C19EF9703009729EB /* aes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aes.h; sourceTree = "<group>"; };
|
||||||
FBCC0E4D19EF9703009729EB /* asn1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asn1.h; sourceTree = "<group>"; };
|
FBCC0E4D19EF9703009729EB /* asn1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asn1.h; sourceTree = "<group>"; };
|
||||||
FBCC0E4E19EF9703009729EB /* asn1_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asn1_mac.h; sourceTree = "<group>"; };
|
FBCC0E4E19EF9703009729EB /* asn1_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asn1_mac.h; sourceTree = "<group>"; };
|
||||||
@@ -358,6 +369,7 @@
|
|||||||
FB290CF019B2C406004C83CF /* Frameworks */ = {
|
FB290CF019B2C406004C83CF /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
FBC8622E19F346A60087327B /* limelight-common.xcodeproj */,
|
||||||
FB7E794319C8B71B00A15F68 /* libiconv.dylib */,
|
FB7E794319C8B71B00A15F68 /* libiconv.dylib */,
|
||||||
FB290DC319B2E98F004C83CF /* libxml2.dylib */,
|
FB290DC319B2E98F004C83CF /* libxml2.dylib */,
|
||||||
FB290DB819B2C877004C83CF /* libbz2.dylib */,
|
FB290DB819B2C877004C83CF /* libbz2.dylib */,
|
||||||
@@ -401,6 +413,8 @@
|
|||||||
FBAB29FB19EE13AA00929691 /* CryptoManager.m */,
|
FBAB29FB19EE13AA00929691 /* CryptoManager.m */,
|
||||||
FBCC0E9E19F00697009729EB /* mkcert.h */,
|
FBCC0E9E19F00697009729EB /* mkcert.h */,
|
||||||
FBCC0E9C19F00659009729EB /* mkcert.c */,
|
FBCC0E9C19F00659009729EB /* mkcert.c */,
|
||||||
|
FBC8622B19F0BEFB0087327B /* HttpManager.h */,
|
||||||
|
FBC8622C19F0BEFB0087327B /* HttpManager.m */,
|
||||||
);
|
);
|
||||||
path = Limelight;
|
path = Limelight;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -528,6 +542,14 @@
|
|||||||
path = FFmpeg;
|
path = FFmpeg;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
FBC8622F19F346A60087327B /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FBC8623319F346A60087327B /* liblimelight-common.a */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
FBCC0E4919EF9703009729EB /* openssl */ = {
|
FBCC0E4919EF9703009729EB /* openssl */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -871,6 +893,12 @@
|
|||||||
mainGroup = FB290CE519B2C406004C83CF;
|
mainGroup = FB290CE519B2C406004C83CF;
|
||||||
productRefGroup = FB290CEF19B2C406004C83CF /* Products */;
|
productRefGroup = FB290CEF19B2C406004C83CF /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
|
projectReferences = (
|
||||||
|
{
|
||||||
|
ProductGroup = FBC8622F19F346A60087327B /* Products */;
|
||||||
|
ProjectRef = FBC8622E19F346A60087327B /* limelight-common.xcodeproj */;
|
||||||
|
},
|
||||||
|
);
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
targets = (
|
targets = (
|
||||||
FB290CED19B2C406004C83CF /* Limelight */,
|
FB290CED19B2C406004C83CF /* Limelight */,
|
||||||
@@ -879,6 +907,16 @@
|
|||||||
};
|
};
|
||||||
/* End PBXProject section */
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXReferenceProxy section */
|
||||||
|
FBC8623319F346A60087327B /* liblimelight-common.a */ = {
|
||||||
|
isa = PBXReferenceProxy;
|
||||||
|
fileType = archive.ar;
|
||||||
|
path = "liblimelight-common.a";
|
||||||
|
remoteRef = FBC8623219F346A60087327B /* PBXContainerItemProxy */;
|
||||||
|
sourceTree = BUILT_PRODUCTS_DIR;
|
||||||
|
};
|
||||||
|
/* End PBXReferenceProxy section */
|
||||||
|
|
||||||
/* Begin PBXResourcesBuildPhase section */
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
FB290CEC19B2C406004C83CF /* Resources */ = {
|
FB290CEC19B2C406004C83CF /* Resources */ = {
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
@@ -909,6 +947,7 @@
|
|||||||
FBAB29FC19EE13AA00929691 /* CryptoManager.m in Sources */,
|
FBAB29FC19EE13AA00929691 /* CryptoManager.m in Sources */,
|
||||||
FB290D3D19B2C6E3004C83CF /* VideoDepacketizer.m in Sources */,
|
FB290D3D19B2C6E3004C83CF /* VideoDepacketizer.m in Sources */,
|
||||||
FBAB29F219EDB08B00929691 /* MDNSManager.m in Sources */,
|
FBAB29F219EDB08B00929691 /* MDNSManager.m in Sources */,
|
||||||
|
FBC8622D19F0BEFB0087327B /* HttpManager.m in Sources */,
|
||||||
FB290D0719B2C406004C83CF /* Limelight.xcdatamodeld in Sources */,
|
FB290D0719B2C406004C83CF /* Limelight.xcdatamodeld in Sources */,
|
||||||
FB290D3E19B2C6E3004C83CF /* VideoRenderer.m in Sources */,
|
FB290D3E19B2C6E3004C83CF /* VideoRenderer.m in Sources */,
|
||||||
FB290D0419B2C406004C83CF /* AppDelegate.m in Sources */,
|
FB290D0419B2C406004C83CF /* AppDelegate.m in Sources */,
|
||||||
|
|||||||
@@ -11,5 +11,6 @@
|
|||||||
@interface CryptoManager : NSObject <NSURLConnectionDelegate>
|
@interface CryptoManager : NSObject <NSURLConnectionDelegate>
|
||||||
|
|
||||||
- (void) generateKeyPairUsingSSl;
|
- (void) generateKeyPairUsingSSl;
|
||||||
|
- (NSString*) getUniqueID;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#import "CryptoManager.h"
|
#import "CryptoManager.h"
|
||||||
#import "mkcert.h"
|
#import "mkcert.h"
|
||||||
|
#import <AdSupport/ASIdentifierManager.h>
|
||||||
|
|
||||||
@implementation CryptoManager
|
@implementation CryptoManager
|
||||||
|
|
||||||
@@ -31,4 +31,18 @@
|
|||||||
freeCertKeyPair(certKeyPair);
|
freeCertKeyPair(certKeyPair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString*) getUniqueID {
|
||||||
|
// generate a UUID
|
||||||
|
NSUUID* uuid = [ASIdentifierManager sharedManager].advertisingIdentifier;
|
||||||
|
NSString* idString = [NSString stringWithString:[uuid UUIDString]];
|
||||||
|
|
||||||
|
// we need a 16byte hex-string so we take the last 17 characters
|
||||||
|
// and remove the '-' to get a 16 character string
|
||||||
|
NSMutableString* uniqueId = [NSMutableString stringWithString:[idString substringFromIndex:19]];
|
||||||
|
[uniqueId deleteCharactersInRange:NSMakeRange(4, 1)];
|
||||||
|
|
||||||
|
//NSLog(@"Unique ID: %@", uniqueId);
|
||||||
|
return [NSString stringWithString:uniqueId];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
//
|
||||||
|
// HttpManager.h
|
||||||
|
// Limelight
|
||||||
|
//
|
||||||
|
// Created by Diego Waxemberg on 10/16/14.
|
||||||
|
// Copyright (c) 2014 Limelight Stream. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface HttpManager : NSObject
|
||||||
|
- (NSString*) generatePIN;
|
||||||
|
- (NSString*) saltPIN:(NSString*)PIN;
|
||||||
|
@end
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
//
|
||||||
|
// HttpManager.m
|
||||||
|
// Limelight
|
||||||
|
//
|
||||||
|
// Created by Diego Waxemberg on 10/16/14.
|
||||||
|
// Copyright (c) 2014 Limelight Stream. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "HttpManager.h"
|
||||||
|
|
||||||
|
@implementation HttpManager {
|
||||||
|
NSString* _baseURL;
|
||||||
|
NSString* _host;
|
||||||
|
NSString* _uniqueId;
|
||||||
|
NSString* _deviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const NSString* PORT = @"47984";
|
||||||
|
|
||||||
|
|
||||||
|
- (id) initWithHost:(NSString*) host uniqueId:(NSString*) uniqueId deviceName:(NSString*) deviceName {
|
||||||
|
self = [super init];
|
||||||
|
_host = host;
|
||||||
|
_uniqueId = uniqueId;
|
||||||
|
_deviceName = deviceName;
|
||||||
|
_baseURL = [[NSString stringWithFormat:@"https://%@:%@", host, PORT]
|
||||||
|
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURL*) newPairRequestWithSalt:(NSString*)salt andCert:(NSString*)cert {
|
||||||
|
NSURL* url = [[NSURL alloc] initWithString:
|
||||||
|
[NSString stringWithFormat:@"http://%@:%@/pair?uniqueid=%@&devicename=%@&updateState=1&phrase=getservercert&salt=%@&clientcert=%@",
|
||||||
|
_host, PORT, _uniqueId, _deviceName, salt, cert]];
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) initiatePairing {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*) generatePIN {
|
||||||
|
NSString* PIN = [NSString stringWithFormat:@"%d%d%d%d",
|
||||||
|
arc4random() % 10, arc4random() % 10,
|
||||||
|
arc4random() % 10, arc4random() % 10];
|
||||||
|
NSLog(@"PIN: %@", PIN);
|
||||||
|
return PIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSData*) saltPIN:(NSString*)PIN {
|
||||||
|
NSMutableData* saltedPIN = [[NSMutableData alloc] initWithCapacity:20];
|
||||||
|
[saltedPIN appendData:[self randomBytes:16]];
|
||||||
|
[saltedPIN appendBytes:[PIN UTF8String] length:4];
|
||||||
|
|
||||||
|
NSLog(@"Salted PIN: %@", [saltedPIN description]);
|
||||||
|
|
||||||
|
return saltedPIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSData*) randomBytes:(NSInteger)length {
|
||||||
|
char* bytes = malloc(length);
|
||||||
|
arc4random_buf(bytes, length);
|
||||||
|
NSData* randomData = [NSData dataWithBytes:bytes length:length];
|
||||||
|
free(bytes);
|
||||||
|
return randomData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
#import "ConnectionHandler.h"
|
#import "ConnectionHandler.h"
|
||||||
#import "Computer.h"
|
#import "Computer.h"
|
||||||
#import "CryptoManager.h"
|
#import "CryptoManager.h"
|
||||||
|
#import "HttpManager.h"
|
||||||
|
|
||||||
@implementation MainFrameViewController
|
@implementation MainFrameViewController
|
||||||
NSString* hostAddr;
|
NSString* hostAddr;
|
||||||
@@ -87,7 +88,10 @@ MDNSManager* mDNSManager;
|
|||||||
|
|
||||||
mDNSManager = [[MDNSManager alloc] initWithCallback:self];
|
mDNSManager = [[MDNSManager alloc] initWithCallback:self];
|
||||||
[mDNSManager searchForHosts];
|
[mDNSManager searchForHosts];
|
||||||
[[[CryptoManager alloc] init] generateKeyPairUsingSSl];
|
CryptoManager* cryptMan = [[CryptoManager alloc] init];
|
||||||
|
[cryptMan getUniqueID];
|
||||||
|
HttpManager* hMan = [[HttpManager alloc] init];
|
||||||
|
[hMan saltPIN:[hMan generatePIN]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateHosts:(NSArray *)hosts {
|
- (void)updateHosts:(NSArray *)hosts {
|
||||||
|
|||||||
Reference in New Issue
Block a user