ObjFW  Diff

Differences From Artifact [12624c872e]:

To Artifact [1e12f722e3]:


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

- (instancetype)initWithBitStringValue: (OFData *)bitStringValue
		       bitStringLength: (size_t)bitStringLength
{
	self = [super init];

	@try {
		if ([bitStringValue count] * [bitStringValue itemSize] !=
		    bitStringLength / 8)
			@throw [OFInvalidFormatException exception];

		_bitStringValue = [bitStringValue copy];
		_bitStringLength = bitStringLength;
	} @catch (id e) {
		[self release];







|







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

- (instancetype)initWithBitStringValue: (OFData *)bitStringValue
		       bitStringLength: (size_t)bitStringLength
{
	self = [super init];

	@try {
		if (bitStringValue.count * bitStringValue.itemSize !=
		    bitStringLength / 8)
			@throw [OFInvalidFormatException exception];

		_bitStringValue = [bitStringValue copy];
		_bitStringLength = bitStringLength;
	} @catch (id e) {
		[self release];
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
	void *pool = objc_autoreleasePoolPush();
	OFData *bitStringValue;
	size_t bitStringLength;

	@try {
		unsigned char lastByteBits;
		size_t count = [DEREncodedContents count];

		if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
		    tagNumber != OF_ASN1_TAG_NUMBER_BIT_STRING || constructed)
			@throw [OFInvalidArgumentException exception];

		if ([DEREncodedContents itemSize] != 1 || count == 0)
			@throw [OFInvalidFormatException exception];

		lastByteBits =
		    *(unsigned char *)[DEREncodedContents itemAtIndex: 0];

		if (count == 1 && lastByteBits != 0)
			@throw [OFInvalidFormatException exception];







|





|







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
	void *pool = objc_autoreleasePoolPush();
	OFData *bitStringValue;
	size_t bitStringLength;

	@try {
		unsigned char lastByteBits;
		size_t count = DEREncodedContents.count;

		if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
		    tagNumber != OF_ASN1_TAG_NUMBER_BIT_STRING || constructed)
			@throw [OFInvalidArgumentException exception];

		if (DEREncodedContents.itemSize != 1 || count == 0)
			@throw [OFInvalidFormatException exception];

		lastByteBits =
		    *(unsigned char *)[DEREncodedContents itemAtIndex: 0];

		if (count == 1 && lastByteBits != 0)
			@throw [OFInvalidFormatException exception];
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
		return false;

	return true;
}

- (uint32_t)hash
{
	return [_bitStringValue hash] + (uint32_t)_bitStringLength;
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"<OFASN1BitString: %@ (%zu bits)>",
					   _bitStringValue, _bitStringLength];
}
@end







|








130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
		return false;

	return true;
}

- (uint32_t)hash
{
	return _bitStringValue.hash + (uint32_t)_bitStringLength;
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"<OFASN1BitString: %@ (%zu bits)>",
					   _bitStringValue, _bitStringLength];
}
@end