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 * NSCipherFile.h - ObjC wrapper for feeCipherFile
12 *
13 * Revision History
14 * ----------------
15 * 28 Oct 96 at NeXT
16 *	Created.
17 */
18
19#import <CryptKit/CryptKit.h>
20#import <CryptKit/CipherFileTypes.h>
21
22@interface NSCipherFile : NSObject
23{
24	void	*_priv;
25}
26
27/*
28 * Alloc and return an autoreleased NSCipherFile object associated with
29 * the specified data.
30 */
31+ newFromCipherText : (NSData *)cipherText
32	encrType : (cipherFileEncrType)encrType
33	sendPubKeyData : (NSData *)sendPubKeyData
34	otherKeyData : (NSData *)otherKeyData
35	sigData : (NSData *)sigData	// optional; nil means no signature
36	userData : (unsigned)userData;	// for caller's convenience
37
38/*
39 * Obtain the contents of a feeCipherFile as NSData.
40 */
41- (NSData *)dataRepresentation;
42
43/*
44 * Alloc and return an autoreleased NSCipherFile object given a data
45 * representation.
46 */
47+ newFromDataRepresentation : (NSData *)dataRep;
48
49/*
50 * Given an NSCipherFile object, obtain its constituent parts.
51 */
52- (cipherFileEncrType)encryptionType;
53- (NSData *)cipherText;
54- (NSData *)sendPubKeyData;
55- (NSData *)otherKeyData;
56- (NSData *)sigData;
57- (unsigned)userData;
58
59/*
60 * High-level cipherFile support.
61 */
62
63/*
64 * Obtain the data representation of a NSCipherFile given the specified
65 * plainText and cipherFileEncrType.
66 * Receiver's public key is required for all encrTypes; sender's private
67 * key is required for signature generation and also for encrType
68 * CFE_PublicDES and CFE_FEED.
69 */
70+(feeReturn)createCipherFileForPrivKey : (NSFEEPublicKey *)sendPrivKey
71	recvPubKey : (NSFEEPublicKey *)recvPubKey
72	encrType : (cipherFileEncrType)encrType
73	plainText : (NSData *)plainText
74	genSig : (BOOL)genSig
75	doEnc64 : (BOOL)doEnc64			// YES ==> perform enc64
76	userData : (unsigned)userData		// for caller's convenience
77	cipherFileData : (NSData **)cipherFileData;	// RETURNED
78
79/*
80 * Parse and decrypt a data representation of an NSCipherFile object.
81 *
82 * recvPrivKey is required in all cases. If sendPubKey is present,
83 * sendPubKey - rather than the embedded sender's public key - will be
84 * used for signature validation.
85 */
86+ (feeReturn)parseCipherFileData : (NSFEEPublicKey *)recvPrivKey
87	sendPubKey : (NSFEEPublicKey *)sendPubKey
88	cipherFileData : (NSData *)cipherFileData
89	doDec64 : (BOOL)doDec64
90	encrType : (cipherFileEncrType *)encrType	// RETURNED
91	plainText : (NSData **)plainText		// RETURNED
92	sigStatus : (feeSigStatus *)sigStatus		// RETURNED
93	sigSigner : (NSString **)sigSigner		// RETURNED
94	userData : (unsigned *)userData;		// RETURNED
95
96/*
97 * Parse and decrypt an NSCipherFile object obtained via
98 * +newFromDataRepresentation.
99 *
100 * recvPrivKey is required in all cases. If sendPubKey is present,
101 * sendPubKey - rather than the embedded sender's public key - will be
102 * used for signature validation.
103 */
104- (feeReturn)decryptCipherFileData : (NSFEEPublicKey *)recvPrivKey
105	sendPubKey : (NSFEEPublicKey *)sendPubKey
106	plainText : (NSData **)plainText		// RETURNED
107	sigStatus : (feeSigStatus *)sigStatus		// RETURNED
108	sigSigner : (NSString **)sigSigner;		// RETURNED
109
110
111@end
112