Blame client/iOS/Models/Encryptor.h

Packit 1fb8d4
/*
Packit 1fb8d4
 Password Encryptor
Packit 1fb8d4
 
Packit 1fb8d4
 Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
Packit 1fb8d4
 
Packit 1fb8d4
 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. 
Packit 1fb8d4
 If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
/* Encrypts data using AES 128 with a 256 bit key derived using PBKDF2-HMAC-SHA1  */
Packit 1fb8d4
Packit 1fb8d4
#import <Foundation/Foundation.h>
Packit 1fb8d4
Packit 1fb8d4
// Encryption block cipher config
Packit 1fb8d4
#define TSXEncryptorBlockCipherAlgo kCCAlgorithmAES128
Packit 1fb8d4
#define TSXEncryptorBlockCipherKeySize kCCKeySizeAES256
Packit 1fb8d4
#define TSXEncryptorBlockCipherOptions kCCOptionPKCS7Padding
Packit 1fb8d4
#define TSXEncryptorBlockCipherBlockSize 16
Packit 1fb8d4
Packit 1fb8d4
// Key generation: If any of these are changed, existing password stores will no longer work
Packit 1fb8d4
#define TSXEncryptorPBKDF2Rounds 100
Packit 1fb8d4
#define TSXEncryptorPBKDF2Salt "9D¶3L}S¿lA[e€3C«"
Packit 1fb8d4
#define TSXEncryptorPBKDF2SaltLen TSXEncryptorBlockCipherOptions
Packit 1fb8d4
#define TSXEncryptorPBKDF2KeySize TSXEncryptorBlockCipherKeySize
Packit 1fb8d4
Packit 1fb8d4
Packit 1fb8d4
@interface Encryptor : NSObject {
Packit 1fb8d4
@private
Packit 1fb8d4
	NSData* _encryption_key;
Packit 1fb8d4
	NSString* _plaintext_password;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
@property(readonly) NSString* plaintextPassword;
Packit 1fb8d4
Packit 1fb8d4
- (id)initWithPassword:(NSString*)plaintext_password;
Packit 1fb8d4
Packit 1fb8d4
- (NSData*)encryptData:(NSData*)plaintext_data;
Packit 1fb8d4
- (NSData*)decryptData:(NSData*)encrypted_data;
Packit 1fb8d4
- (NSData*)encryptString:(NSString*)plaintext_string;
Packit 1fb8d4
- (NSString*)decryptString:(NSData*)encrypted_string;
Packit 1fb8d4
Packit 1fb8d4
@end