1/* Copyright (c) 1998,2011,2014 Apple Inc.  All Rights Reserved.
2 *
3 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
4 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
5 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
7 * INC.  ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
8 * EXPOSE YOU TO LIABILITY.
9 ***************************************************************************
10 *
11 * NSCryptors.h - common cryptographic protocols
12 *
13 * Revision History
14 * ----------------
15 *  ??? 1994	Blaine Garst at NeXT
16 *	Created.
17 */
18
19
20#import <Foundation/NSObject.h>
21#import <Foundation/NSData.h>
22#import <Foundation/NSString.h>
23
24
25/************ Utilities ******************************************/
26
27#ifdef	NeXT
28
29NSString *NSPromptForPassPhrase(NSString *prompt);
30	// useful for command line (/dev/tty) programs
31
32#endif 	NeXT
33
34/************ Data Hashing Protocol *****************/
35
36@protocol NSDataDigester
37+ digester;				// provides a concrete digester
38
39// primitives
40- (void)digestData:(NSData *)data;	// use for multi-bite messages
41- (NSData *)messageDigest;		// provide digest; re-init
42
43// conveniences that only use the above primitives
44// all in one gulp (eats salt first, if present)
45- (NSData *)digestData:(NSData *)data withSalt:(NSData *)salt;
46
47@end
48
49
50/******  Encryption/Decryption Protocol ***********/
51
52@protocol NSCryptor
53- (NSData *)encryptData:(NSData *)input;
54- (NSData *)decryptData:(NSData *)input;
55- (unsigned)keyBitsize;
56@end
57
58
59/*************** Public Key Services *************/
60
61@protocol NSPublicKey
62- (NSString *)publicKeyString;
63- (NSString *)algorithmName;	// "Diffie-Hellman" "FEE" ...
64- (NSString *)usageName;	// "Blaine Garst - home"
65- (NSData *)padWithPublicKey:(id <NSPublicKey>)otherKey;
66- (unsigned)keyBitsize;
67@end
68
69/********* Key Ring ************************/
70
71@protocol NSKeyRing
72- keyForUsageName:(NSString *)user;
73@end
74
75/********** Digital Signatures **************/
76
77// protocol adapted by various signature schemes (FEE, DSA, RSA...)
78@protocol NSDigitalSignature
79- (NSData *)digitalSignatureForData:(NSData *)message;
80  // generate a signature for the data
81
82- (BOOL)isValidDigitalSignature:(NSData *)sig forData:(NSData *)data;
83@end
84