mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			44 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			44 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Matlab
		
	
| 
											10 years ago
										 | // | ||
|  | //  TSAttachementsTest.m | ||
|  | //  Signal | ||
|  | // | ||
|  | //  Created by Frederic Jacobs on 21/12/14. | ||
|  | //  Copyright (c) 2014 Open Whisper Systems. All rights reserved. | ||
|  | // | ||
|  | 
 | ||
|  | #import <XCTest/XCTest.h> | ||
|  | 
 | ||
|  | #import "TSAttachmentStream.h" | ||
|  | #import "Cryptography.h" | ||
|  | 
 | ||
| 
											10 years ago
										 | @interface TSAttachmentsTest : XCTestCase | ||
| 
											10 years ago
										 | 
 | ||
|  | @end | ||
|  | 
 | ||
| 
											10 years ago
										 | @implementation TSAttachmentsTest | ||
| 
											10 years ago
										 | 
 | ||
|  | - (void)setUp { | ||
|  |     [super setUp]; | ||
|  |     // Put setup code here. This method is called before the invocation of each test method in the class. | ||
|  | } | ||
|  | 
 | ||
|  | - (void)tearDown { | ||
|  |     // Put teardown code here. This method is called after the invocation of each test method in the class. | ||
|  |     [super tearDown]; | ||
|  | } | ||
|  | 
 | ||
| 
											10 years ago
										 | - (void)testAttachmentEncryptionDecryption { | ||
| 
											10 years ago
										 |     NSData *plaintext = [Cryptography generateRandomBytes:100]; | ||
|  |     NSString *contentType = @"img/jpg"; | ||
|  |     uint64_t identifier   = 3063578577793591963; | ||
|  |     NSNumber *number      = [NSNumber numberWithUnsignedLongLong:identifier]; | ||
|  |      | ||
|  |     TSAttachmentEncryptionResult *encryptionResult = [Cryptography encryptAttachment:plaintext contentType:contentType identifier:[number stringValue]]; | ||
|  |      | ||
|  |     NSData *plaintextBis = [Cryptography decryptAttachment:encryptionResult.body withKey:encryptionResult.pointer.encryptionKey]; | ||
|  |      | ||
| 
											10 years ago
										 |     XCTAssert([plaintext isEqualToData:plaintextBis], @"Attachments encryption failed"); | ||
| 
											10 years ago
										 | } | ||
|  | 
 | ||
|  | @end |