Overview
Context
Changes
Modified src/OFASN1BitString.h
from [c2be33e12e]
to [0fbb50d9aa].
︙ | | |
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
|
*/
@property (readonly, nonatomic) size_t bitStringLength;
/**
* @brief Creates an ASN.1 BitString with the specified BitString value and
* length.
*
* @param bitStringValue The value of the BitString
* @param bitStringLength The length of the BitString in bits
* @param bitString The value of the BitString
* @param length The length of the BitString in bits
* @return A new, autoreleased OFASN1BitString
*/
+ (instancetype)bitStringWithBitStringValue: (OFData *)bitStringValue
bitStringLength: (size_t)bitStringLength;
+ (instancetype)bitStringWithBitString: (OFData *)bitString
length: (size_t)length;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated ASN.1 BitString with the specified
* BitString value and length.
*
* @param bitStringValue The value of the BitString
* @param bitStringLength The length of the BitString in bits
* @param bitString The value of the BitString
* @param length The length of the BitString in bits
* @return An initialized OFASN1BitString
*/
- (instancetype)initWithBitStringValue: (OFData *)bitStringValue
- (instancetype)initWithBitString: (OFData *)bitString
bitStringLength: (size_t)bitStringLength
OF_DESIGNATED_INITIALIZER;
length: (size_t)length OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 BitString with the specified
* arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
|
︙ | | |
Modified src/OFASN1BitString.m
from [843d69d324]
to [d3bbe5638b].
︙ | | |
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
-
-
+
+
-
+
-
-
+
-
+
-
-
-
+
+
-
-
+
+
-
-
+
+
|
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
@implementation OFASN1BitString
@synthesize bitStringValue = _bitStringValue;
@synthesize bitStringLength = _bitStringLength;
+ (instancetype)bitStringWithBitStringValue: (OFData *)bitStringValue
bitStringLength: (size_t)bitStringLength
+ (instancetype)bitStringWithBitString: (OFData *)bitString
length: (size_t)length
{
return [[[self alloc]
return [[[self alloc] initWithBitString: bitString
initWithBitStringValue: bitStringValue
bitStringLength: bitStringLength] autorelease];
length: length] autorelease];
}
- (instancetype)initWithBitStringValue: (OFData *)bitStringValue
- (instancetype)initWithBitString: (OFData *)bitString length: (size_t)length
bitStringLength: (size_t)bitStringLength
{
self = [super init];
@try {
if (bitStringValue.count * bitStringValue.itemSize !=
OF_ROUND_UP_POW2(8, bitStringLength) / 8)
if (bitString.count * bitString.itemSize !=
OF_ROUND_UP_POW2(8, length) / 8)
@throw [OFInvalidFormatException exception];
_bitStringValue = [bitStringValue copy];
_bitStringLength = bitStringLength;
_bitStringValue = [bitString copy];
_bitStringLength = length;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
void *pool = objc_autoreleasePoolPush();
OFData *bitStringValue;
size_t bitStringLength;
OFData *bitString;
size_t length;
@try {
unsigned char unusedBits;
size_t count = DEREncodedContents.count;
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_BIT_STRING || constructed)
|
︙ | | |
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
|
-
-
+
+
-
+
-
+
-
-
+
-
+
|
*/
if (count == 1 && unusedBits != 0)
@throw [OFInvalidFormatException exception];
if (SIZE_MAX / 8 < count - 1)
@throw [OFOutOfRangeException exception];
bitStringLength = (count - 1) * 8;
bitStringValue = [DEREncodedContents subdataWithRange:
length = (count - 1) * 8;
bitString = [DEREncodedContents subdataWithRange:
of_range(1, count - 1)];
if (unusedBits != 0)
bitStringLength -= unusedBits;
length -= unusedBits;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithBitStringValue: bitStringValue
self = [self initWithBitString: bitString length: length];
bitStringLength: bitStringLength];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_bitStringValue release];
[super dealloc];
}
- (OFData *)ASN1DERRepresentation
{
size_t bitStringValueCount = [_bitStringValue count];
size_t bitStringValueCount = _bitStringValue.count;
size_t roundedUpLength = OF_ROUND_UP_POW2(8, _bitStringLength);
unsigned char unusedBits = roundedUpLength - _bitStringLength;
unsigned char header[] = {
OF_ASN1_TAG_NUMBER_BIT_STRING,
bitStringValueCount + 1,
unusedBits
};
OFMutableData *data;
if (bitStringValueCount + 1 > UINT8_MAX ||
bitStringValueCount != roundedUpLength / 8)
@throw [OFInvalidFormatException exception];
data = [OFMutableData
dataWithCapacity: sizeof(header) + bitStringValueCount];
[data addItems: header count: sizeof(header)];
[data addItems: [_bitStringValue items] count: bitStringValueCount];
[data addItems: _bitStringValue.items count: bitStringValueCount];
[data makeImmutable];
return data;
}
- (bool)isEqual: (id)object
|
︙ | | |
Modified src/OFASN1Boolean.h
from [4ac9986bdd]
to [db11e25404].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
|
/**
* @brief An ASN.1 Boolean.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1Boolean: OFObject <OFASN1DERRepresentation>
{
bool _booleanValue;
bool _boolValue;
}
/**
* @brief The Boolean value.
* @brief The value of the Boolean.
*/
@property (readonly, nonatomic) bool booleanValue;
@property (readonly, nonatomic) bool boolValue;
/**
* @brief Creates an ASN.1 Boolean with the specified Boolean value.
*
* @param booleanValue The value of the Boolean
* @param bool_ The value of the Boolean
* @return A new, autoreleased OFASN1Boolean
*/
+ (instancetype)booleanWithBooleanValue: (bool)booleanValue;
+ (instancetype)booleanWithBool: (bool)bool_;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated ASN.1 Boolean with the specified
* Boolean value.
*
* @param booleanValue The value of the Boolean
* @param bool_ The value of the Boolean
* @return An initialized OFASN1Boolean
*/
- (instancetype)initWithBooleanValue: (bool)booleanValue
OF_DESIGNATED_INITIALIZER;
- (instancetype)initWithBool: (bool)bool_ OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 Boolean with the specified
* arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
|
︙ | | |
Modified src/OFASN1Boolean.m
from [ae373739b8]
to [57247a8096].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
+
-
+
-
+
-
+
-
+
|
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
@implementation OFASN1Boolean
@synthesize booleanValue = _booleanValue;
@synthesize boolValue = _boolValue;
+ (instancetype)booleanWithBooleanValue: (bool)booleanValue
+ (instancetype)booleanWithBool: (bool)bool_
{
return [[[self alloc] initWithBooleanValue: booleanValue] autorelease];
return [[[self alloc] initWithBool: bool_] autorelease];
}
- (instancetype)initWithBooleanValue: (bool)booleanValue
- (instancetype)initWithBool: (bool)bool_
{
self = [super init];
_booleanValue = booleanValue;
_boolValue = bool_;
return self;
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
|
︙ | | |
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
-
+
-
+
-
+
-
+
-
+
|
if (value != 0 && value != 0xFF)
@throw [OFInvalidFormatException exception];
} @catch (id e) {
[self release];
@throw e;
}
return [self initWithBooleanValue: !!value];
return [self initWithBool: !!value];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (OFData *)ASN1DERRepresentation
{
char buffer[] = {
OF_ASN1_TAG_NUMBER_BOOLEAN,
1,
(_booleanValue ? 0xFF : 0x00)
(_boolValue ? 0xFF : 0x00)
};
return [OFData dataWithItems: buffer count: sizeof(buffer)];
}
- (bool)isEqual: (id)object
{
OFASN1Boolean *boolean;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1Boolean class]])
return false;
boolean = object;
if (boolean->_booleanValue != _booleanValue)
if (boolean->_boolValue != _boolValue)
return false;
return true;
}
- (unsigned long)hash
{
return _booleanValue;
return _boolValue;
}
- (OFString *)description
{
return (_booleanValue
return (_boolValue
? @"<OFASN1Boolean: true>"
: @"<OFASN1Boolean: false>");
}
@end
|
Modified src/OFASN1IA5String.h
from [c74a3606bd]
to [699db44549].
︙ | | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
-
+
-
+
-
+
-
-
+
|
* @brief The string value.
*/
@property (readonly, nonatomic) OFString *stringValue;
/**
* @brief Creates an IA5String with the specified string value.
*
* @param stringValue The string value of the IA5String
* @param string The string value of the IA5String
* @return A new, autoreleased OFASN1IA5String
*/
+ (instancetype)stringWithStringValue: (OFString *)stringValue;
+ (instancetype)stringWithString: (OFString *)string;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated IA5String with the specified string
* value.
*
* @param stringValue The string value of the IA5String
* @param string The string value of the IA5String
* @return An initialized OFASN1IA5String
*/
- (instancetype)initWithStringValue: (OFString *)stringValue
OF_DESIGNATED_INITIALIZER;
- (instancetype)initWithString: (OFString *)string OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 IA5String with the specified
* arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
|
︙ | | |
Modified src/OFASN1IA5String.m
from [494960fd54]
to [5ec7f22291].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#import "OFString.h"
#import "OFInvalidArgumentException.h"
@implementation OFASN1IA5String
@synthesize IA5StringValue = _IA5StringValue;
+ (instancetype)stringWithStringValue: (OFString *)stringValue
+ (instancetype)stringWithString: (OFString *)string
{
return [[[self alloc] initWithStringValue: stringValue] autorelease];
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithStringValue: (OFString *)stringValue
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
@try {
_IA5StringValue = [stringValue copy];
_IA5StringValue = [string copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
void *pool = objc_autoreleasePoolPush();
OFString *IA5StringValue;
OFString *IA5String;
@try {
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_IA5_STRING || constructed)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidArgumentException exception];
IA5StringValue = [OFString
IA5String= [OFString
stringWithCString: DEREncodedContents.items
encoding: OF_STRING_ENCODING_ASCII
length: DEREncodedContents.count];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithStringValue: IA5StringValue];
self = [self initWithString: IA5String];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
|
︙ | | |
Modified src/OFASN1NumericString.h
from [e0198cfd1a]
to [2bcc77fb41].
︙ | | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
-
+
-
+
-
+
-
-
+
|
* @brief The string value.
*/
@property (readonly, nonatomic) OFString *stringValue;
/**
* @brief Creates an NumericString with the specified string value.
*
* @param stringValue The string value of the NumericString
* @param string The string value of the NumericString
* @return A new, autoreleased OFASN1NumericString
*/
+ (instancetype)stringWithStringValue: (OFString *)stringValue;
+ (instancetype)stringWithString: (OFString *)string;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated NumericString with the specified
* string value.
*
* @param stringValue The string value of the NumericString
* @param string The string value of the NumericString
* @return An initialized OFASN1NumericString
*/
- (instancetype)initWithStringValue: (OFString *)stringValue
OF_DESIGNATED_INITIALIZER;
- (instancetype)initWithString: (OFString *)string OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 NumericString with the
* specified arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
|
︙ | | |
Modified src/OFASN1NumericString.m
from [50fd063fbe]
to [24e3b7cea6].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
|
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
@implementation OFASN1NumericString
@synthesize numericStringValue = _numericStringValue;
+ (instancetype)stringWithStringValue: (OFString *)stringValue
+ (instancetype)stringWithString: (OFString *)string
{
return [[[self alloc] initWithStringValue: stringValue] autorelease];
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithStringValue: (OFString *)stringValue
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
const char *cString = stringValue.UTF8String;
size_t length = stringValue.UTF8StringLength;
const char *cString = string.UTF8String;
size_t length = string.UTF8StringLength;
for (size_t i = 0; i < length; i++)
if (!of_ascii_isdigit(cString[i]) && cString[i] != ' ')
@throw [OFInvalidEncodingException exception];
_numericStringValue = [stringValue copy];
_numericStringValue = [string copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
void *pool = objc_autoreleasePoolPush();
OFString *numericStringValue;
OFString *numericString;
@try {
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_NUMERIC_STRING ||
constructed)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidArgumentException exception];
numericStringValue = [OFString
numericString = [OFString
stringWithCString: DEREncodedContents.items
encoding: OF_STRING_ENCODING_ASCII
length: DEREncodedContents.count];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithStringValue: numericStringValue];
self = [self initWithString: numericString];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
|
︙ | | |
Modified src/OFASN1OctetString.h
from [547dec0827]
to [d7f4e338c8].
︙ | | |
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
-
+
-
+
-
+
-
+
|
* @brief The OctetString value.
*/
@property (readonly, nonatomic) OFData *octetStringValue;
/**
* @brief Creates an OctetString with the specified value.
*
* @param octetStringValue The OctetString value
* @param octetString The OctetString value
* @return A new, autoreleased OFASN1OctetString
*/
+ (instancetype)octetStringWithOctetStringValue: (OFData *)octetStringValue;
+ (instancetype)octetStringWithOctetString: (OFData *)octetString;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OctetString with the specified
* value.
*
* @param octetStringValue The OctetString value
* @param octetString The OctetString value
* @return An initialized OFASN1OctetString
*/
- (instancetype)initWithOctetStringValue: (OFData *)octetStringValue
- (instancetype)initWithOctetString: (OFData *)octetString
OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 OctetString with the specified
* arguments.
*
* @param tagClass The tag class of the value's type
|
︙ | | |
Modified src/OFASN1OctetString.m
from [42b0c8635d]
to [dbf5bc7d07].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
-
+
-
+
-
-
+
-
+
|
#import "OFString.h"
#import "OFInvalidArgumentException.h"
@implementation OFASN1OctetString
@synthesize octetStringValue = _octetStringValue;
+ (instancetype)octetStringWithOctetStringValue: (OFData *)octetStringValue
+ (instancetype)octetStringWithOctetString: (OFData *)octetString
{
return [[[self alloc]
return [[[self alloc] initWithOctetString: octetString] autorelease];
initWithOctetStringValue: octetStringValue] autorelease];
}
- (instancetype)initWithOctetStringValue: (OFData *)octetStringValue
- (instancetype)initWithOctetString: (OFData *)octetString
{
self = [super init];
@try {
_octetStringValue = [octetStringValue copy];
_octetStringValue = [octetString copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
︙ | | |
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
-
+
|
if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidArgumentException exception];
} @catch (id e) {
[self release];
@throw e;
}
return [self initWithOctetStringValue: DEREncodedContents];
return [self initWithOctetString: DEREncodedContents];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
|
︙ | | |
Modified src/OFASN1PrintableString.h
from [0506eb78c3]
to [15b004b863].
︙ | | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
-
+
-
+
-
+
-
-
+
|
* @brief The string value.
*/
@property (readonly, nonatomic) OFString *stringValue;
/**
* @brief Creates a PrintableString with the specified string value.
*
* @param stringValue The string value of the PrintableString
* @param string The string value of the PrintableString
* @return A new, autoreleased OFASN1PrintableString
*/
+ (instancetype)stringWithStringValue: (OFString *)stringValue;
+ (instancetype)stringWithString: (OFString *)string;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated PrintableString with the specified
* string value.
*
* @param stringValue The string value of the PrintableString
* @param string The string value of the PrintableString
* @return An initialized OFASN1PrintableString
*/
- (instancetype)initWithStringValue: (OFString *)stringValue
OF_DESIGNATED_INITIALIZER;
- (instancetype)initWithString: (OFString *)string OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 PrintableString with the
* specified arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
|
︙ | | |
Modified src/OFASN1PrintableString.m
from [d6f8fd877c]
to [633e478a84].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
-
+
-
+
-
+
-
-
+
+
|
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
@implementation OFASN1PrintableString
@synthesize printableStringValue = _printableStringValue;
+ (instancetype)stringWithStringValue: (OFString *)stringValue
+ (instancetype)stringWithString: (OFString *)string
{
return [[[self alloc] initWithStringValue: stringValue] autorelease];
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithStringValue: (OFString *)stringValue
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
const char *cString = stringValue.UTF8String;
size_t length = stringValue.UTF8StringLength;
const char *cString = string.UTF8String;
size_t length = string.UTF8StringLength;
for (size_t i = 0; i < length; i++) {
if (of_ascii_isalnum(cString[i]))
continue;
switch (cString[i]) {
case ' ':
|
︙ | | |
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
-
+
-
+
-
+
-
+
|
case '?':
continue;
default:
@throw [OFInvalidEncodingException exception];
}
}
_printableStringValue = [stringValue copy];
_printableStringValue = [string copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
void *pool = objc_autoreleasePoolPush();
OFString *printableStringValue;
OFString *printableString;
@try {
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_PRINTABLE_STRING ||
constructed)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidArgumentException exception];
printableStringValue = [OFString
printableString = [OFString
stringWithCString: DEREncodedContents.items
encoding: OF_STRING_ENCODING_ASCII
length: DEREncodedContents.count];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithStringValue: printableStringValue];
self = [self initWithString: printableString];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
|
︙ | | |
Modified src/OFASN1UTF8String.h
from [338855ca89]
to [a4b45c5c6e].
︙ | | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
-
+
-
+
-
+
-
-
+
|
* @brief The string value.
*/
@property (readonly, nonatomic) OFString *stringValue;
/**
* @brief Creates a UTF8String with the specified string value.
*
* @param stringValue The string value of the UTF8String
* @param string The string value of the UTF8String
* @return A new, autoreleased OFASN1UTF8String
*/
+ (instancetype)stringWithStringValue: (OFString *)stringValue;
+ (instancetype)stringWithString: (OFString *)string;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated UTF8String with the specified
* string value.
*
* @param stringValue The string value of the UTF8String
* @param string The string value of the UTF8String
* @return An initialized OFASN1UTF8String
*/
- (instancetype)initWithStringValue: (OFString *)stringValue
OF_DESIGNATED_INITIALIZER;
- (instancetype)initWithString: (OFString *)string OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 UTF8String with the specified
* arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
|
︙ | | |
Modified src/OFASN1UTF8String.m
from [92cd83c978]
to [53a8c373a7].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#import "OFString.h"
#import "OFInvalidArgumentException.h"
@implementation OFASN1UTF8String
@synthesize UTF8StringValue = _UTF8StringValue;
+ (instancetype)stringWithStringValue: (OFString *)stringValue
+ (instancetype)stringWithString: (OFString *)string
{
return [[[self alloc] initWithStringValue: stringValue] autorelease];
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithStringValue: (OFString *)stringValue
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
@try {
_UTF8StringValue = [stringValue copy];
_UTF8StringValue = [string copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
void *pool = objc_autoreleasePoolPush();
OFString *UTF8StringValue;
OFString *UTF8String;
@try {
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_UTF8_STRING || constructed)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidArgumentException exception];
UTF8StringValue = [OFString
UTF8String = [OFString
stringWithUTF8String: DEREncodedContents.items
length: DEREncodedContents.count];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithStringValue: UTF8StringValue];
self = [self initWithString: UTF8String];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
|
︙ | | |
Modified tests/OFASN1DERParsingTests.m
from [70f5ebfaac]
to [6d6dab178a].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
-
-
+
|
OFArray *array;
OFSet *set;
OFEnumerator *enumerator;
/* Boolean */
TEST(@"Parsing of boolean",
![[[OFData dataWithItems: "\x01\x01\x00"
count: 3] objectByParsingASN1DER]
count: 3] objectByParsingASN1DER] boolValue] &&
booleanValue] &&
[[[OFData dataWithItems: "\x01\x01\xFF"
count: 3] objectByParsingASN1DER] booleanValue])
count: 3] objectByParsingASN1DER] boolValue])
EXPECT_EXCEPTION(@"Detection of invalid boolean #1",
OFInvalidFormatException,
[[OFData dataWithItems: "\x01\x01\x01"
count: 3] objectByParsingASN1DER])
EXPECT_EXCEPTION(@"Detection of invalid boolean #2",
|
︙ | | |
Modified tests/OFASN1DERRepresentationTests.m
from [dadc73d11b]
to [c3751ee953].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
+
-
-
+
-
-
+
-
-
+
-
-
-
+
+
-
-
+
|
{
void *pool = objc_autoreleasePoolPush();
OFData *data;
module = @"OFASN1BitString";
TEST(@"-[ASN1DERRepresentation]",
(data = [OFData dataWithItems: "\xFF\x00\xF8" count: 3]) &&
[[[OFASN1BitString bitStringWithBitStringValue: data
[[[OFASN1BitString bitStringWithBitString: data length: 21]
bitStringLength: 21]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x03\x04\x03\xFF\x00\xF8" count: 6]] &&
(data = [OFData dataWithItems: "abcdefäöü" count: 12]) &&
[[[OFASN1BitString bitStringWithBitStringValue: data
[[[OFASN1BitString bitStringWithBitString: data length: 12 * 8]
bitStringLength: 12 * 8]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x03\x0D\x00" "abcdefäöü" count: 15]] &&
(data = [OFData dataWithItems: "" count: 0]) &&
[[[OFASN1BitString bitStringWithBitStringValue: data
[[[OFASN1BitString bitStringWithBitString: data length: 0]
bitStringLength: 0]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x03\x01\x00" count: 3]])
module = @"OFASN1Boolean";
TEST(@"-[ASN1DERRepresentation]",
[[[OFASN1Boolean booleanWithBooleanValue: false]
[[[OFASN1Boolean booleanWithBool: false] ASN1DERRepresentation]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x01\x01\x00" count: 3]] &&
[[[OFASN1Boolean booleanWithBooleanValue: true]
isEqual: [OFData dataWithItems: "\x01\x01\x00" count: 3]] &&
[[[OFASN1Boolean booleanWithBool: true] ASN1DERRepresentation]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x01\x01\xFF" count: 3]])
isEqual: [OFData dataWithItems: "\x01\x01\xFF" count: 3]])
module = @"OFNull";
TEST(@"-[OFASN1DERRepresentation]",
[[[OFNull null] ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x05\x00" count: 2]])
objc_autoreleasePoolPop(pool);
}
@end
|