FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
Encryptor.h
1/*
2 Password Encryptor
3
4 Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9 */
10
11/* Encrypts data using AES 128 with a 256 bit key derived using PBKDF2-HMAC-SHA1 */
12
13#import <Foundation/Foundation.h>
14
15// Encryption block cipher config
16#define TSXEncryptorBlockCipherAlgo kCCAlgorithmAES128
17#define TSXEncryptorBlockCipherKeySize kCCKeySizeAES256
18#define TSXEncryptorBlockCipherOptions kCCOptionPKCS7Padding
19#define TSXEncryptorBlockCipherBlockSize 16
20
21// Key generation: If any of these are changed, existing password stores will no longer work
22#define TSXEncryptorPBKDF2Rounds 100
23#define TSXEncryptorPBKDF2Salt "9D¶3L}S¿lA[e€3C«"
24#define TSXEncryptorPBKDF2SaltLen TSXEncryptorBlockCipherOptions
25#define TSXEncryptorPBKDF2KeySize TSXEncryptorBlockCipherKeySize
26
27@interface Encryptor : NSObject
28{
29 @private
30 NSData *_encryption_key;
31 NSString *_plaintext_password;
32}
33
34@property(readonly) NSString *plaintextPassword;
35
36- (id)initWithPassword:(NSString *)plaintext_password;
37
38- (NSData *)encryptData:(NSData *)plaintext_data;
39- (NSData *)decryptData:(NSData *)encrypted_data;
40- (NSData *)encryptString:(NSString *)plaintext_string;
41- (NSString *)decryptString:(NSData *)encrypted_string;
42
43@end