1 /* NSData+Crypto.h - this file is part of SOGo
2  *
3  * Copyright (C) 2012 Nicolas Höft
4  * Copyright (C) 2012-2016 Inverse inc.
5  *
6  * Author: Nicolas Höft
7  *         Inverse inc.
8  *
9  * This file is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * This file is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; see the file COPYING.  If not, write to
21  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24 
25 #ifndef NSDATA_CRYPTO_H
26 #define NSDATA_CRYPTO_H
27 
28 #import <Foundation/NSData.h>
29 
30 @class NSObject;
31 
32 @interface NSData (SOGoCryptoExtension)
33 
34 - (NSData *) asCryptedPassUsingScheme: (NSString *) passwordScheme
35                              withSalt: (NSData *) theSalt;
36 
37 - (NSData *) asLM;
38 - (NSData *) asMD4;
39 - (NSData *) asMD5;
40 - (NSData *) asSMD5UsingSalt: (NSData *) theSalt;
41 - (NSData *) asSHA1;
42 - (NSData *) asSSHAUsingSalt: (NSData *) theSalt;
43 - (NSData *) asSHA256;
44 - (NSData *) asSSHA256UsingSalt: (NSData *) theSalt;
45 - (NSData *) asSHA512;
46 - (NSData *) asSSHA512UsingSalt: (NSData *) theSalt;
47 - (NSData *) asSHA256CryptUsingSalt: (NSData *) theSalt;
48 - (NSData *) asSHA512CryptUsingSalt: (NSData *) theSalt;
49 - (NSData *) asCramMD5;
50 
51 - (NSData *) asCryptUsingSalt: (NSData *) theSalt;
52 - (NSData *) asMD5CryptUsingSalt: (NSData *) theSalt;
53 
54 - (NSData *) extractSalt: (NSString *) theScheme;
55 
56 + (NSData *) generateSaltForLength: (unsigned int) theLength
57                         withBase64: (BOOL) doBase64;
58 + (NSData *) generateSaltForLength: (unsigned int) theLength;
59 
60 + (NSString *) encodeDataAsHexString: (NSData* ) theData;
61 + (NSData *) decodeDataFromHexString: (NSString* ) theString;
62 
63 @end
64 
65 #endif /* NSDATA_CRYPTO_H */
66