|
Packit |
1fb8d4 |
/*
|
|
Packit |
1fb8d4 |
Password Encryptor
|
|
Packit Service |
5a9772 |
|
|
Packit |
1fb8d4 |
Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
|
|
Packit Service |
5a9772 |
|
|
Packit Service |
5a9772 |
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
Packit Service |
5a9772 |
If a copy of the MPL was not distributed with this file, You can obtain one at
|
|
Packit Service |
5a9772 |
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 Service |
5a9772 |
@interface Encryptor : NSObject
|
|
Packit Service |
5a9772 |
{
|
|
Packit Service |
5a9772 |
@private
|
|
Packit Service |
5a9772 |
NSData *_encryption_key;
|
|
Packit Service |
5a9772 |
NSString *_plaintext_password;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit Service |
5a9772 |
@property(readonly) NSString *plaintextPassword;
|
|
Packit |
1fb8d4 |
|
|
Packit Service |
5a9772 |
- (id)initWithPassword:(NSString *)plaintext_password;
|
|
Packit |
1fb8d4 |
|
|
Packit Service |
5a9772 |
- (NSData *)encryptData:(NSData *)plaintext_data;
|
|
Packit Service |
5a9772 |
- (NSData *)decryptData:(NSData *)encrypted_data;
|
|
Packit Service |
5a9772 |
- (NSData *)encryptString:(NSString *)plaintext_string;
|
|
Packit Service |
5a9772 |
- (NSString *)decryptString:(NSData *)encrypted_string;
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
@end
|