diff --git a/SmartDeviceLink/private/SDLProtocol.m b/SmartDeviceLink/private/SDLProtocol.m index 93bf5870d..ea2cc84e0 100644 --- a/SmartDeviceLink/private/SDLProtocol.m +++ b/SmartDeviceLink/private/SDLProtocol.m @@ -178,14 +178,14 @@ - (void)startServiceWithType:(SDLServiceType)serviceType payload:(nullable NSDat - (void)startSecureServiceWithType:(SDLServiceType)serviceType payload:(nullable NSData *)payload tlsInitializationHandler:(void (^)(BOOL success, NSError *error))tlsInitializationHandler { SDLLogD(@"Attempting to start TLS for service type: %hhu", serviceType); [self sdl_initializeTLSEncryptionWithCompletionHandler:^(BOOL success, NSError *error) { + tlsInitializationHandler(success, error); if (!success) { // We can't start the service because we don't have encryption, return the error - tlsInitializationHandler(success, error); BLOCK_RETURN; } // TLS initialization succeeded. Build and send the message. - SDLProtocolMessage *message = [self sdl_createStartServiceMessageWithType:serviceType encrypted:YES payload:nil]; + SDLProtocolMessage *message = [self sdl_createStartServiceMessageWithType:serviceType encrypted:YES payload:payload]; SDLLogD(@"TLS initialized, sending start service with encryption for message: %@", message); [self sdl_sendDataToTransport:message.data onService:serviceType]; }]; @@ -470,13 +470,14 @@ - (void)sdl_sendRawData:(NSData *)data onService:(SDLServiceType)service encrypt NSError *encryptError = nil; data = [self.securityManager encryptData:data withError:&encryptError]; - if (encryptError) { + // If the data fails to encrypt, fail out of sending this chunk of data. + if ((data.length == 0) || (encryptError != nil)) { SDLLogE(@"Error attempting to encrypt raw data for service: %@, error: %@", @(service), encryptError); + return; } } SDLProtocolMessage *message = [SDLProtocolMessage messageWithHeader:header andPayload:data]; - if (message.size < [[SDLGlobals sharedGlobals] mtuSizeForServiceType:service]) { SDLLogV(@"Sending protocol message: %@", message); [self sdl_sendDataToTransport:message.data onService:header.serviceType]; @@ -531,7 +532,7 @@ - (void)sdl_processMessages { NSError *decryptError = nil; payload = [self.securityManager decryptData:payload withError:&decryptError]; - if (decryptError) { + if (decryptError != nil) { SDLLogE(@"Error attempting to decrypt a payload with error: %@", decryptError); return; } diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m index fd4349887..f6d982a57 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m @@ -93,19 +93,19 @@ }); }); - describe(@"check cell eqality", ^{ + describe(@"check cell equality", ^{ it(@"should compare cells and return true if cells equal", ^{ testCell = [[SDLMenuCell alloc] initWithTitle:someTitle secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:nil secondaryArtwork:someSecondaryArtwork submenuLayout:testLayout subCells:@[]]; testCell2 = [[SDLMenuCell alloc] initWithTitle:someTitle secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:nil secondaryArtwork:someSecondaryArtwork submenuLayout:testLayout subCells:@[]]; - expect([testCell isEqual:testCell2]).to(equal(true)); + expect([testCell isEqual:testCell2]).to(beTrue()); }); it(@"should compare cells and return false if not equal ", ^{ testCell = [[SDLMenuCell alloc] initWithTitle:@"True" secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:nil secondaryArtwork:someSecondaryArtwork submenuLayout:testLayout subCells:@[]]; testCell2 = [[SDLMenuCell alloc] initWithTitle:@"False" secondaryText:nil tertiaryText:nil icon:nil secondaryArtwork:nil submenuLayout:testLayout subCells:@[]]; - expect([testCell isEqual:testCell2]).to(equal(false)); + expect([testCell isEqual:testCell2]).to(beFalse()); }); it(@"should compare cells and return true if cells equal", ^{ @@ -115,7 +115,7 @@ testCell2 = [[SDLMenuCell alloc] initWithTitle:someTitle icon:nil submenuLayout:testLayout subCells:@[]]; #pragma clang diagnostic pop - expect([testCell isEqual:testCell2]).to(equal(true)); + expect([testCell isEqual:testCell2]).to(beTrue()); }); it(@"should compare cells and return false if not equal ", ^{ @@ -125,7 +125,7 @@ testCell2 = [[SDLMenuCell alloc] initWithTitle:@"False" icon:nil submenuLayout:testLayout subCells:@[]]; #pragma clang diagnostic pop - expect([testCell isEqual:testCell2]).to(equal(false)); + expect([testCell isEqual:testCell2]).to(beFalse()); }); }); });