]> git.saurik.com Git - apple/security.git/blob - KeychainCircle/KCJoiningMessages.h
Security-58286.270.3.0.1.tar.gz
[apple/security.git] / KeychainCircle / KCJoiningMessages.h
1 //
2 // KCJoiningMessages.h
3 // KeychainCircle
4 //
5 //
6
7 #import <Foundation/Foundation.h>
8
9 // Initial messages are versioned and not typed for negotiation.
10 NS_ASSUME_NONNULL_BEGIN
11
12 NSData* extractStartFromInitialMessage(NSData* initialMessage, uint64_t* version, NSString* _Nullable * _Nullable uuidString, NSError** error);
13
14 size_t sizeof_initialmessage(NSData*data);
15 size_t sizeof_initialmessage_version1(NSData*data, uint64_t version1, NSData *uuid);
16
17
18
19 uint8_t* _Nullable encode_initialmessage(NSData* data, NSError**error,
20 const uint8_t *der, uint8_t *der_end);
21 uint8_t* _Nullable encode_initialmessage_version1(NSData* data, NSData* uuidData, uint64_t piggy_version, NSError**error,
22 const uint8_t *der, uint8_t *der_end);
23
24 const uint8_t* _Nullable decode_initialmessage(NSData* _Nonnull * _Nonnull data, NSError** error,
25 const uint8_t* der, const uint8_t *der_end);
26
27 const uint8_t* _Nullable decode_version1(NSData* _Nonnull* _Nonnull data, NSData* _Nullable* _Nullable uuid, uint64_t * _Nullable piggy_version, NSError** error,
28 const uint8_t* der, const uint8_t *der_end);
29
30 size_t sizeof_seq_data_data(NSData*data1, NSData*data2, NSError** error);
31 uint8_t* _Nullable encode_seq_data_data(NSData* data, NSData*data2, NSError**error,
32 const uint8_t *der, uint8_t *der_end);
33 const uint8_t* _Nullable decode_seq_data_data(NSData* _Nonnull * _Nonnull data1, NSData* _Nonnull * _Nonnull data2,
34 NSError** error,
35 const uint8_t* der, const uint8_t *der_end);
36
37 size_t sizeof_seq_string_data(NSString*string, NSData*data, NSError** error);
38 uint8_t* _Nullable encode_seq_string_data(NSString* string, NSData*data, NSError**error,
39 const uint8_t *der, uint8_t *der_end);
40 const uint8_t* _Nullable decode_seq_string_data(NSString* _Nonnull * _Nonnull string, NSData* _Nonnull * _Nonnull data,
41 NSError** error,
42 const uint8_t* der, const uint8_t *der_end);
43
44 @interface NSData(KCJoiningMessages)
45
46 + (nullable instancetype) dataWithEncodedString: (NSString*) string
47 error: (NSError**) error;
48
49 + (nullable instancetype) dataWithEncodedSequenceData: (NSData*) data1
50 data: (NSData*) data2
51 error: (NSError**) error;
52
53 - (bool) decodeSequenceData: (NSData* _Nullable * _Nonnull) data1
54 data: (NSData* _Nullable * _Nonnull) data2
55 error: (NSError** _Nullable) error;
56
57
58 + (nullable instancetype) dataWithEncodedSequenceString: (NSString*) string
59 data: (NSData*) data
60 error: (NSError**) error;
61
62 - (bool) decodeSequenceString: (NSString* _Nullable * _Nonnull) string
63 data: (NSData* _Nullable * _Nonnull) data
64 error: (NSError** _Nullable) error;
65 @end
66
67 @interface NSString(KCJoiningMessages)
68 + (nullable instancetype) decodeFromDER: (NSData*)der error: (NSError** _Nullable) error;
69 @end
70
71 // Subsequent messages have a message type
72 typedef enum {
73 kChallenge = 1,
74 kResponse = 2,
75 kVerification = 3,
76 kPeerInfo = 4,
77 kCircleBlob = 5,
78
79 kError = 0,
80
81 kUnknown = 255,
82
83 kLargestMessageType = kUnknown,
84
85 } KCJoiningMessageType;
86
87
88 @interface KCJoiningMessage : NSObject
89
90 @property (readonly) KCJoiningMessageType type;
91 @property (readonly) NSData* firstData;
92 @property (nullable, readonly) NSData* secondData;
93
94 @property (readonly) NSData* der;
95
96 + (nullable instancetype) messageWithDER: (NSData*) message
97 error: (NSError**) error;
98
99 + (nullable instancetype) messageWithType: (KCJoiningMessageType) type
100 data: (NSData*) firstData
101 error: (NSError**) error;
102
103 + (nullable instancetype) messageWithType: (KCJoiningMessageType) type
104 data: (NSData*) firstData
105 payload: (NSData*) secondData
106 error: (NSError**) error;
107
108
109 - (nullable instancetype) initWithDER: (NSData*) message
110 error: (NSError**) error NS_DESIGNATED_INITIALIZER;
111
112 - (nullable instancetype) initWithType: (KCJoiningMessageType) type
113 data: (NSData*) firstData
114 payload: (nullable NSData*) secondData
115 error: (NSError**) error NS_DESIGNATED_INITIALIZER;
116
117
118 - (instancetype) init NS_UNAVAILABLE;
119
120 @end
121
122 NS_ASSUME_NONNULL_END
123