7 #import <Foundation/Foundation.h>
9 // Initial messages are versioned and not typed for negotiation.
10 NS_ASSUME_NONNULL_BEGIN
12 NSData
* extractStartFromInitialMessage(NSData
* initialMessage
, uint64_t* version
, NSString
* _Nullable
* _Nullable uuidString
, NSError
** error
);
14 size_t sizeof_initialmessage(NSData
*data
);
15 size_t sizeof_initialmessage_version1(NSData
*data
, uint64_t version1
, NSData
*uuid
);
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
);
24 const uint8_t* _Nullable
decode_initialmessage(NSData
* _Nonnull
* _Nonnull data
, NSError
** error
,
25 const uint8_t* der
, const uint8_t *der_end
);
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
);
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
,
35 const uint8_t* der
, const uint8_t *der_end
);
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
,
42 const uint8_t* der
, const uint8_t *der_end
);
44 @interface
NSData(KCJoiningMessages
)
46 + (nullable instancetype
) dataWithEncodedString
: (NSString
*) string
47 error
: (NSError
**) error
;
49 + (nullable instancetype
) dataWithEncodedSequenceData
: (NSData
*) data1
51 error
: (NSError
**) error
;
53 - (bool) decodeSequenceData
: (NSData
* _Nullable
* _Nonnull
) data1
54 data
: (NSData
* _Nullable
* _Nonnull
) data2
55 error
: (NSError
** _Nullable
) error
;
58 + (nullable instancetype
) dataWithEncodedSequenceString
: (NSString
*) string
60 error
: (NSError
**) error
;
62 - (bool) decodeSequenceString
: (NSString
* _Nullable
* _Nonnull
) string
63 data
: (NSData
* _Nullable
* _Nonnull
) data
64 error
: (NSError
** _Nullable
) error
;
67 @interface
NSString(KCJoiningMessages
)
68 + (nullable instancetype
) decodeFromDER
: (NSData
*)der error
: (NSError
** _Nullable
) error
;
71 // Subsequent messages have a message type
83 kLargestMessageType
= kUnknown
,
85 } KCJoiningMessageType
;
88 @interface KCJoiningMessage
: NSObject
90 @
property (readonly
) KCJoiningMessageType type
;
91 @
property (readonly
) NSData
* firstData
;
92 @
property (nullable
, readonly
) NSData
* secondData
;
94 @
property (readonly
) NSData
* der
;
96 + (nullable instancetype
) messageWithDER
: (NSData
*) message
97 error
: (NSError
**) error
;
99 + (nullable instancetype
) messageWithType
: (KCJoiningMessageType
) type
100 data
: (NSData
*) firstData
101 error
: (NSError
**) error
;
103 + (nullable instancetype
) messageWithType
: (KCJoiningMessageType
) type
104 data
: (NSData
*) firstData
105 payload
: (NSData
*) secondData
106 error
: (NSError
**) error
;
109 - (nullable instancetype
) initWithDER
: (NSData
*) message
110 error
: (NSError
**) error NS_DESIGNATED_INITIALIZER
;
112 - (nullable instancetype
) initWithType
: (KCJoiningMessageType
) type
113 data
: (NSData
*) firstData
114 payload
: (nullable NSData
*) secondData
115 error
: (NSError
**) error NS_DESIGNATED_INITIALIZER
;
118 - (instancetype
) init NS_UNAVAILABLE
;
122 NS_ASSUME_NONNULL_END