︙ | | | ︙ | |
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
static size_t parseObject(OFData *self, id *object, size_t depthLimit);
static OFArray *
parseSequence(OFData *contents, size_t depthLimit)
{
OFMutableArray *ret = [OFMutableArray array];
size_t count = [contents count];
if (depthLimit == 0)
@throw [OFOutOfRangeException exception];
while (count > 0) {
id object;
size_t objectLength;
|
|
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
static size_t parseObject(OFData *self, id *object, size_t depthLimit);
static OFArray *
parseSequence(OFData *contents, size_t depthLimit)
{
OFMutableArray *ret = [OFMutableArray array];
size_t count = contents.count;
if (depthLimit == 0)
@throw [OFOutOfRangeException exception];
while (count > 0) {
id object;
size_t objectLength;
|
︙ | | | ︙ | |
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
return ret;
}
static OFSet *
parseSet(OFData *contents, size_t depthLimit)
{
OFMutableSet *ret = [OFMutableSet set];
size_t count = [contents count];
OFData *previousObjectData = nil;
if (depthLimit == 0)
@throw [OFOutOfRangeException exception];
while (count > 0) {
id object;
|
|
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
return ret;
}
static OFSet *
parseSet(OFData *contents, size_t depthLimit)
{
OFMutableSet *ret = [OFMutableSet set];
size_t count = contents.count;
OFData *previousObjectData = nil;
if (depthLimit == 0)
@throw [OFOutOfRangeException exception];
while (count > 0) {
id object;
|
︙ | | | ︙ | |
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
return ret;
}
static size_t
parseObject(OFData *self, id *object, size_t depthLimit)
{
const unsigned char *items = [self items];
size_t count = [self count];
unsigned char tag;
size_t contentsLength, bytesConsumed = 0;
Class valueClass;
OFData *contents;
if (count < 2)
@throw [OFTruncatedDataException exception];
|
|
|
|
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
return ret;
}
static size_t
parseObject(OFData *self, id *object, size_t depthLimit)
{
const unsigned char *items = self.items;
size_t count = self.count;
unsigned char tag;
size_t contentsLength, bytesConsumed = 0;
Class valueClass;
OFData *contents;
if (count < 2)
@throw [OFTruncatedDataException exception];
|
︙ | | | ︙ | |
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
case OF_ASN1_TAG_NUMBER_OCTET_STRING:
valueClass = [OFASN1OctetString class];
break;
case OF_ASN1_TAG_NUMBER_NULL:
if (tag & ASN1_TAG_CONSTRUCTED_MASK)
@throw [OFInvalidFormatException exception];
if ([contents count] != 0)
@throw [OFInvalidFormatException exception];
*object = [OFNull null];
return bytesConsumed;
case OF_ASN1_TAG_NUMBER_OBJECT_IDENTIFIER:
valueClass = [OFASN1ObjectIdentifier class];
break;
|
|
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
case OF_ASN1_TAG_NUMBER_OCTET_STRING:
valueClass = [OFASN1OctetString class];
break;
case OF_ASN1_TAG_NUMBER_NULL:
if (tag & ASN1_TAG_CONSTRUCTED_MASK)
@throw [OFInvalidFormatException exception];
if (contents.count != 0)
@throw [OFInvalidFormatException exception];
*object = [OFNull null];
return bytesConsumed;
case OF_ASN1_TAG_NUMBER_OBJECT_IDENTIFIER:
valueClass = [OFASN1ObjectIdentifier class];
break;
|
︙ | | | ︙ | |
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
}
- (id)ASN1DERValueWithDepthLimit: (size_t)depthLimit
{
void *pool = objc_autoreleasePoolPush();
id object;
if ([self itemSize] != 1)
@throw [OFInvalidArgumentException exception];
if (parseObject(self, &object, depthLimit) != [self count])
@throw [OFInvalidFormatException exception];
[object retain];
objc_autoreleasePoolPop(pool);
return [object autorelease];
}
@end
|
|
|
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
}
- (id)ASN1DERValueWithDepthLimit: (size_t)depthLimit
{
void *pool = objc_autoreleasePoolPush();
id object;
if (self.itemSize != 1)
@throw [OFInvalidArgumentException exception];
if (parseObject(self, &object, depthLimit) != self.count)
@throw [OFInvalidFormatException exception];
[object retain];
objc_autoreleasePoolPop(pool);
return [object autorelease];
}
@end
|