ObjOpenSSL  Diff

Differences From Artifact [f5a1847ad4]:

To Artifact [ea8e8f249e]:


250
251
252
253
254
255
256
257

258
259
260
261
262
263
264
265
266
267
268

269
270
271
272
273

274
275
276

277
278
279
280
281
282
283
284
285
286
287
288

289
290
291
292
293

294
295
296

297
298
299
300
301
302
303
250
251
252
253
254
255
256

257
258
259
260
261
262
263
264
265
266
267

268
269
270
271
272

273
274
275

276
277
278
279
280
281
282
283
284
285
286
287

288
289
290
291
292

293
294
295

296
297
298
299
300
301
302
303







-
+










-
+




-
+


-
+











-
+




-
+


-
+








	[ret makeImmutable];
	_subjectAlternativeName = [ret retain];

	return ret;
}

- (BOOL)hasCommonNameMatchingDomain: (OFString*)domain
- (bool)hasCommonNameMatchingDomain: (OFString*)domain
{
	OFString *name;
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFList *CNs = [[self subject] objectForKey: OID_commonName];
	OFEnumerator *enumerator = [CNs objectEnumerator];

	while ((name = [enumerator nextObject]) != nil) {
		if ([self X509_isAssertedDomain: name
				    equalDomain: domain]) {
			[pool release];
			return YES;
			return true;
		}
	}

	[pool release];
	return NO;
	return false;
}

- (BOOL)hasDNSNameMatchingDomain: (OFString*)domain
- (bool)hasDNSNameMatchingDomain: (OFString*)domain
{
	OFString *name;
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDictionary *SANs = [self subjectAlternativeName];
	OFList *assertedNames = [SANs objectForKey: @"dNSName"];
	OFEnumerator *enumerator = [assertedNames objectEnumerator];

	while ((name = [enumerator nextObject]) != nil) {
		if ([self X509_isAssertedDomain: name
				    equalDomain: domain]) {
			[pool release];
			return YES;
			return true;
		}
	}

	[pool release];
	return NO;
	return false;
}

- (BOOL)hasSRVNameMatchingDomain: (OFString*)domain
- (bool)hasSRVNameMatchingDomain: (OFString*)domain
			 service: (OFString*)service
{
	size_t serviceLength;
	OFString *name;
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDictionary *SANs = [self subjectAlternativeName];
	OFList *assertedNames = [[SANs objectForKey: @"otherName"]
314
315
316
317
318
319
320
321

322
323
324
325
326
327

328
329
330

331
332
333
334
335
336
337
338
339
340
341
342
343

344
345
346

347
348
349
350
351
352
353

354
355
356
357
358
359

360
361

362
363
364
365
366
367
368
314
315
316
317
318
319
320

321
322
323
324
325
326

327
328
329

330
331
332
333
334
335
336
337
338
339
340
341
342

343
344
345

346
347
348
349
350
351
352

353
354
355
356
357
358

359
360

361
362
363
364
365
366
367
368







-
+





-
+


-
+












-
+


-
+






-
+





-
+

-
+







		if ([name hasPrefix: service]) {
			OFString *asserted;
			asserted = [name substringWithRange: of_range(
			    serviceLength, [name length] - serviceLength)];
			if ([self X509_isAssertedDomain: asserted
					    equalDomain: domain]) {
				[pool release];
				return YES;
				return true;
			}
		}
	}

	[pool release];
	return NO;
	return false;
}

- (BOOL)X509_isAssertedDomain: (OFString*)asserted
- (bool)X509_isAssertedDomain: (OFString*)asserted
		  equalDomain: (OFString*)domain
{
	/*
	 * In accordance with RFC 6125 this only allows a wildcard as the
	 * left-most label and matches only the left-most label with it.
	 * E.g. *.example.com matches foo.example.com,
	 * but not foo.bar.example.com
	 */

	size_t firstDot;

	if ([asserted caseInsensitiveCompare: domain] == OF_ORDERED_SAME)
		return YES;
		return true;

	if (![asserted hasPrefix: @"*."])
		return NO;
		return false;

	asserted = [asserted substringWithRange:
	    of_range(2, [asserted length] - 2)];

	firstDot = [domain rangeOfString: @"."].location;
	if (firstDot == OF_NOT_FOUND)
		return NO;
		return false;

	domain = [domain substringWithRange:
	    of_range(firstDot + 1, [domain length] - firstDot - 1)];

	if (![asserted caseInsensitiveCompare: domain])
		return YES;
		return true;

	return NO;
	return false;
}

- (OFDictionary*)X509_dictionaryFromX509Name: (X509_NAME*)name
{
	OFMutableDictionary *dict = [OFMutableDictionary dictionary];
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	int i, count = X509_NAME_entry_count(name);
458
459
460
461
462
463
464
465

466
467
468
469
470
471
472
473
474
475
476

477
478
479
480
481
482
483
484
485
486
487
488
458
459
460
461
462
463
464

465
466
467
468
469
470
471
472
473
474
475

476
477
478
479
480
481
482
483
484
485
486
487
488







-
+










-
+












- (OFString*)description
{
	char tmp[1024];
	OBJ_obj2txt(tmp, sizeof(tmp), OBJ_txt2obj([_string UTF8String], 1), 0);
	return [OFString stringWithUTF8String: tmp];
}

- (BOOL)isEqual: (id)object
- (bool)isEqual: (id)object
{
	if ([object isKindOfClass: [X509OID class]]) {
		X509OID *OID = object;

		return [OID->_string isEqual: _string];
	}

	if ([object isKindOfClass: [OFString class]])
		return [_string isEqual: object];

	return NO;
	return false;
}

- (uint32_t)hash
{
	return [_string hash];
}

- copy
{
	return [self retain];
}
@end