ObjFW  Diff

Differences From Artifact [e3b3ec7fe0]:

To Artifact [eada094776]:


120
121
122
123
124
125
126
127
128
129
130
131




132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
- (void)dealloc
{
	[_bitStringValue release];

	[super dealloc];
}

- (OFData *)DEREncodedValue
{
	size_t bitStringValueCount = [_bitStringValue count];
	unsigned char lastByteBits = _bitStringLength % 8;
	unsigned char header[] = { 3, bitStringValueCount + 1, lastByteBits };




	OFMutableData *data;

	if (bitStringValueCount + 1 > UINT8_MAX ||
	    bitStringValueCount != OF_ROUND_UP_POW2(8, _bitStringLength) / 8)
		@throw [OFInvalidFormatException exception];

	data = [OFMutableData dataWithCapacity: 3 + bitStringValueCount];
	[data addItems: header
		 count: 3];
	[data addItems: [_bitStringValue items]
		 count: bitStringValueCount];

	[data makeImmutable];

	return data;
}







|



|
>
>
>
>








|







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
- (void)dealloc
{
	[_bitStringValue release];

	[super dealloc];
}

- (OFData *)ASN1DERRepresentation
{
	size_t bitStringValueCount = [_bitStringValue count];
	unsigned char lastByteBits = _bitStringLength % 8;
	unsigned char header[] = {
		OF_ASN1_TAG_NUMBER_BIT_STRING,
		bitStringValueCount + 1,
		lastByteBits
	};
	OFMutableData *data;

	if (bitStringValueCount + 1 > UINT8_MAX ||
	    bitStringValueCount != OF_ROUND_UP_POW2(8, _bitStringLength) / 8)
		@throw [OFInvalidFormatException exception];

	data = [OFMutableData dataWithCapacity: 3 + bitStringValueCount];
	[data addItems: header
		 count: sizeof(header)];
	[data addItems: [_bitStringValue items]
		 count: bitStringValueCount];

	[data makeImmutable];

	return data;
}