Modified src/Makefile
from [8ca7647682]
to [0cf0f81e38].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
include ../extra.mk
SUBDIRS = ${RUNTIME} exceptions encodings forwarding
SUBDIRS_AFTER = ${BRIDGE}
DISTCLEAN = Info.plist objfw-defs.h
SHARED_LIB = ${OBJFW_SHARED_LIB}
STATIC_LIB = ${OBJFW_STATIC_LIB}
FRAMEWORK = ${OBJFW_FRAMEWORK}
LIB_MAJOR = ${OBJFW_LIB_MAJOR}
LIB_MINOR = ${OBJFW_LIB_MINOR}
SRCS = OFASN1BitString.m \
OFASN1Boolean.m \
OFASN1Enumerated.m \
OFASN1IA5String.m \
OFASN1Integer.m \
OFASN1NumericString.m \
OFASN1ObjectIdentifier.m \
OFASN1OctetString.m \
OFASN1PrintableString.m \
OFASN1UTF8String.m \
OFASN1Value.m \
OFApplication.m \
OFArray.m \
OFBlock.m \
OFCharacterSet.m \
OFColor.m \
OFConstantString.m \
OFCountedSet.m \
OFData.m \
OFData+ASN1DERParsing.m \
OFData+CryptographicHashing.m \
OFData+MessagePackParsing.m \
OFDate.m \
OFDictionary.m \
OFEnumerator.m \
OFFileManager.m \
OFGZIPStream.m \
|
<
<
<
<
<
<
<
<
<
<
<
|
<
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
include ../extra.mk
SUBDIRS = ${RUNTIME} exceptions encodings forwarding
SUBDIRS_AFTER = ${BRIDGE}
DISTCLEAN = Info.plist objfw-defs.h
SHARED_LIB = ${OBJFW_SHARED_LIB}
STATIC_LIB = ${OBJFW_STATIC_LIB}
FRAMEWORK = ${OBJFW_FRAMEWORK}
LIB_MAJOR = ${OBJFW_LIB_MAJOR}
LIB_MINOR = ${OBJFW_LIB_MINOR}
SRCS = OFApplication.m \
OFArray.m \
OFBlock.m \
OFCharacterSet.m \
OFColor.m \
OFConstantString.m \
OFCountedSet.m \
OFData.m \
OFData+CryptographicHashing.m \
OFData+MessagePackParsing.m \
OFDate.m \
OFDictionary.m \
OFEnumerator.m \
OFFileManager.m \
OFGZIPStream.m \
|
︙ | | | ︙ | |
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
atomic_builtins.h \
atomic_no_threads.h \
atomic_osatomic.h \
atomic_powerpc.h \
atomic_sync_builtins.h \
atomic_x86.h
INCLUDES := ${SRCS:.m=.h} \
OFASN1DERRepresentation.h \
OFCollection.h \
OFCryptographicHash.h \
OFJSONRepresentation.h \
OFKernelEventObserver.h \
OFKeyValueCoding.h \
OFLocking.h \
OFMessagePackRepresentation.h \
|
<
|
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
atomic_builtins.h \
atomic_no_threads.h \
atomic_osatomic.h \
atomic_powerpc.h \
atomic_sync_builtins.h \
atomic_x86.h
INCLUDES := ${SRCS:.m=.h} \
OFCollection.h \
OFCryptographicHash.h \
OFJSONRepresentation.h \
OFKernelEventObserver.h \
OFKeyValueCoding.h \
OFLocking.h \
OFMessagePackRepresentation.h \
|
︙ | | | ︙ | |
Deleted src/OFASN1BitString.h version [0fbb50d9aa].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1DERRepresentation.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
@class OFData;
/**
* @brief An ASN.1 BitString.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1BitString: OFObject <OFASN1DERRepresentation>
{
OFData *_bitStringValue;
size_t _bitStringLength;
}
/**
* @brief The BitString value.
*/
@property (readonly, nonatomic) OFData *bitStringValue;
/**
* @brief The length of the BitString in bits.
*/
@property (readonly, nonatomic) size_t bitStringLength;
/**
* @brief Creates an ASN.1 BitString with the specified BitString value and
* length.
*
* @param bitString The value of the BitString
* @param length The length of the BitString in bits
* @return A new, autoreleased OFASN1BitString
*/
+ (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 bitString The value of the BitString
* @param length The length of the BitString in bits
* @return An initialized OFASN1BitString
*/
- (instancetype)initWithBitString: (OFData *)bitString
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
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized OFASN1BitString
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1BitString.m version [d3bbe5638b].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1BitString.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
@implementation OFASN1BitString
@synthesize bitStringValue = _bitStringValue;
@synthesize bitStringLength = _bitStringLength;
+ (instancetype)bitStringWithBitString: (OFData *)bitString
length: (size_t)length
{
return [[[self alloc] initWithBitString: bitString
length: length] autorelease];
}
- (instancetype)initWithBitString: (OFData *)bitString length: (size_t)length
{
self = [super init];
@try {
if (bitString.count * bitString.itemSize !=
OF_ROUND_UP_POW2(8, length) / 8)
@throw [OFInvalidFormatException exception];
_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 *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)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1 || count == 0)
@throw [OFInvalidFormatException exception];
unusedBits =
*(unsigned char *)[DEREncodedContents itemAtIndex: 0];
if (unusedBits > 7)
@throw [OFInvalidFormatException exception];
/*
* Can't have any bits of the last byte unused if we have no
* byte.
*/
if (count == 1 && unusedBits != 0)
@throw [OFInvalidFormatException exception];
if (SIZE_MAX / 8 < count - 1)
@throw [OFOutOfRangeException exception];
length = (count - 1) * 8;
bitString = [DEREncodedContents subdataWithRange:
of_range(1, count - 1)];
if (unusedBits != 0)
length -= unusedBits;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithBitString: bitString length: length];
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 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 makeImmutable];
return data;
}
- (bool)isEqual: (id)object
{
OFASN1BitString *bitString;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1BitString class]])
return false;
bitString = object;
if (![bitString->_bitStringValue isEqual: _bitStringValue])
return false;
if (bitString->_bitStringLength != _bitStringLength)
return false;
return true;
}
- (unsigned long)hash
{
return _bitStringValue.hash + (unsigned long)_bitStringLength;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<OFASN1BitString: %@ (%zu bits)>",
_bitStringValue, _bitStringLength];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1Boolean.h version [db11e25404].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1DERRepresentation.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @brief An ASN.1 Boolean.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1Boolean: OFObject <OFASN1DERRepresentation>
{
bool _boolValue;
}
/**
* @brief The value of the Boolean.
*/
@property (readonly, nonatomic) bool boolValue;
/**
* @brief Creates an ASN.1 Boolean with the specified Boolean value.
*
* @param bool_ The value of the Boolean
* @return A new, autoreleased OFASN1Boolean
*/
+ (instancetype)booleanWithBool: (bool)bool_;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated ASN.1 Boolean with the specified
* Boolean value.
*
* @param bool_ The value of the Boolean
* @return An initialized OFASN1Boolean
*/
- (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
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized OFASN1Boolean
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1Boolean.m version [57247a8096].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1Boolean.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
@implementation OFASN1Boolean
@synthesize boolValue = _boolValue;
+ (instancetype)booleanWithBool: (bool)bool_
{
return [[[self alloc] initWithBool: bool_] autorelease];
}
- (instancetype)initWithBool: (bool)bool_
{
self = [super init];
_boolValue = bool_;
return self;
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
unsigned char value;
@try {
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_BOOLEAN || constructed)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1 ||
DEREncodedContents.count != 1)
@throw [OFInvalidFormatException exception];
value = *(unsigned char *)[DEREncodedContents itemAtIndex: 0];
if (value != 0 && value != 0xFF)
@throw [OFInvalidFormatException exception];
} @catch (id e) {
[self release];
@throw e;
}
return [self initWithBool: !!value];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (OFData *)ASN1DERRepresentation
{
char buffer[] = {
OF_ASN1_TAG_NUMBER_BOOLEAN,
1,
(_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->_boolValue != _boolValue)
return false;
return true;
}
- (unsigned long)hash
{
return _boolValue;
}
- (OFString *)description
{
return (_boolValue
? @"<OFASN1Boolean: true>"
: @"<OFASN1Boolean: false>");
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1DERRepresentation.h version [fea4984136].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
OF_ASSUME_NONNULL_BEGIN
@class OFData;
/**
* @protocol OFASN1DERRepresentation \
* OFASN1DERRepresentation.h ObjFW/OFASN1DERRepresentation.h
*
* @brief A protocol implemented by classes that support encoding to ASN.1 DER
* representation.
*/
@protocol OFASN1DERRepresentation
/**
* @brief The object in ASN.1 DER representation.
*/
@property (readonly, nonatomic) OFData *ASN1DERRepresentation;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1Enumerated.h version [5d2a579693].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @brief An ASN.1 Enumerated.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1Enumerated: OFObject
{
long long _longLongValue;
}
/**
* @brief The integer value.
*/
@property (readonly, nonatomic) long long longLongValue;
/**
* @brief Creates an ASN.1 Enumerated with the specified integer value.
*
* @param value The `long long` value of the Enumerated
* @return A new, autoreleased OFASN1Enumerated
*/
+ (instancetype)enumeratedWithLongLong: (long long)value;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated ASN.1 Enumerated with the specified
* integer value.
*
* @param value The `long long` value of the Enumerated
* @return An initialized OFASN1Enumerated
*/
- (instancetype)initWithLongLong: (long long)value OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 Enumerated with the specified
* arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized OFASN1Enumerated
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1Enumerated.m version [eb1e77637a].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1Enumerated.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
extern long long of_asn1_der_integer_parse(const unsigned char *buffer,
size_t length);
@implementation OFASN1Enumerated
@synthesize longLongValue = _longLongValue;
+ (instancetype)enumeratedWithLongLong: (long long)value
{
return [[[self alloc] initWithLongLong: value] autorelease];
}
- (instancetype)initWithLongLong: (long long)value
{
self = [super init];
_longLongValue = value;
return self;
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
long long value;
@try {
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_ENUMERATED || constructed)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidArgumentException exception];
value = of_asn1_der_integer_parse(
DEREncodedContents.items, DEREncodedContents.count);
} @catch (id e) {
[self release];
@throw e;
}
return [self initWithLongLong: value];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (bool)isEqual: (id)object
{
OFASN1Enumerated *enumerated;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1Enumerated class]])
return false;
enumerated = object;
if (enumerated->_longLongValue != _longLongValue)
return false;
return true;
}
- (unsigned long)hash
{
return (unsigned long)_longLongValue;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<OFASN1Enumerated: %lld>",
_longLongValue];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1IA5String.h version [699db44549].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
/**
* @brief An ASN.1 IA5String.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1IA5String: OFObject
{
OFString *_IA5StringValue;
}
/**
* @brief The IA5String value.
*/
@property (readonly, nonatomic) OFString *IA5StringValue;
/**
* @brief The string value.
*/
@property (readonly, nonatomic) OFString *stringValue;
/**
* @brief Creates an IA5String with the specified string value.
*
* @param string The string value of the IA5String
* @return A new, autoreleased OFASN1IA5String
*/
+ (instancetype)stringWithString: (OFString *)string;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated IA5String with the specified string
* value.
*
* @param string The string value of the IA5String
* @return An initialized OFASN1IA5String
*/
- (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
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized OFASN1IA5String
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1IA5String.m version [5ec7f22291].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1IA5String.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
@implementation OFASN1IA5String
@synthesize IA5StringValue = _IA5StringValue;
+ (instancetype)stringWithString: (OFString *)string
{
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
@try {
_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 *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];
IA5String= [OFString
stringWithCString: DEREncodedContents.items
encoding: OF_STRING_ENCODING_ASCII
length: DEREncodedContents.count];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithString: IA5String];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_IA5StringValue release];
[super dealloc];
}
- (OFString *)stringValue
{
return self.IA5StringValue;
}
- (bool)isEqual: (id)object
{
OFASN1IA5String *IA5String;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1IA5String class]])
return false;
IA5String = object;
if (![IA5String->_IA5StringValue isEqual: _IA5StringValue])
return false;
return true;
}
- (unsigned long)hash
{
return _IA5StringValue.hash;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<OFASN1IA5String: %@>",
_IA5StringValue];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1Integer.h version [06cbc99c2c].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @brief An ASN.1 Integer.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1Integer: OFObject
{
long long _longLongValue;
}
/**
* @brief The Integer value.
*/
@property (readonly, nonatomic) long long longLongValue;
/**
* @brief Creates an ASN.1 Integer with the specified integer value.
*
* @param value The `long long` value of the Integer
* @return A new, autoreleased OFASN1Integer
*/
+ (instancetype)integerWithLongLong: (long long)value;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated ASN.1 Integer with the specified
* integer value.
*
* @param value The `long long` value of the Integer
* @return An initialized OFASN1Integer
*/
- (instancetype)initWithLongLong: (long long)value OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 Integer with the specified
* arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized OFASN1Integer
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1Integer.m version [5a16302993].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1Integer.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
long long
of_asn1_der_integer_parse(const unsigned char *buffer, size_t length)
{
unsigned long long value = 0;
/* TODO: Support for big numbers */
if (length > sizeof(unsigned long long) &&
(length != sizeof(unsigned long long) + 1 || buffer[0] != 0))
@throw [OFOutOfRangeException exception];
if (length >= 2 && ((buffer[0] == 0 && !(buffer[1] & 0x80)) ||
(buffer[0] == 0xFF && buffer[1] & 0x80)))
@throw [OFInvalidFormatException exception];
if (length >= 1 && buffer[0] & 0x80)
value = ~0ull;
while (length--)
value = (value << 8) | *buffer++;
return value;
}
@implementation OFASN1Integer
@synthesize longLongValue = _longLongValue;
+ (instancetype)integerWithLongLong: (long long)value
{
return [[[self alloc] initWithLongLong: value] autorelease];
}
- (instancetype)initWithLongLong: (long long)value
{
self = [super init];
_longLongValue = value;
return self;
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
long long value;
@try {
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_INTEGER || constructed)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidArgumentException exception];
value = of_asn1_der_integer_parse(
DEREncodedContents.items, DEREncodedContents.count);
} @catch (id e) {
[self release];
@throw e;
}
return [self initWithLongLong: value];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (bool)isEqual: (id)object
{
OFASN1Integer *integer;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1Integer class]])
return false;
integer = object;
if (integer->_longLongValue != _longLongValue)
return false;
return true;
}
- (unsigned long)hash
{
return (unsigned long)_longLongValue;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<OFASN1Integer: %lld>",
_longLongValue];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1NumericString.h version [2bcc77fb41].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
/**
* @brief An ASN.1 NumericString.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1NumericString: OFObject
{
OFString *_numericStringValue;
}
/**
* @brief The NumericString value.
*/
@property (readonly, nonatomic) OFString *numericStringValue;
/**
* @brief The string value.
*/
@property (readonly, nonatomic) OFString *stringValue;
/**
* @brief Creates an NumericString with the specified string value.
*
* @param string The string value of the NumericString
* @return A new, autoreleased OFASN1NumericString
*/
+ (instancetype)stringWithString: (OFString *)string;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated NumericString with the specified
* string value.
*
* @param string The string value of the NumericString
* @return An initialized OFASN1NumericString
*/
- (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
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized ASN.1 NumericString
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1NumericString.m version [24e3b7cea6].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1NumericString.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
@implementation OFASN1NumericString
@synthesize numericStringValue = _numericStringValue;
+ (instancetype)stringWithString: (OFString *)string
{
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
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 = [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 *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];
numericString = [OFString
stringWithCString: DEREncodedContents.items
encoding: OF_STRING_ENCODING_ASCII
length: DEREncodedContents.count];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithString: numericString];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_numericStringValue release];
[super dealloc];
}
- (OFString *)stringValue
{
return self.numericStringValue;
}
- (bool)isEqual: (id)object
{
OFASN1NumericString *numericString;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1NumericString class]])
return false;
numericString = object;
if (![numericString->_numericStringValue isEqual: _numericStringValue])
return false;
return true;
}
- (unsigned long)hash
{
return _numericStringValue.hash;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<OFASN1NumericString: %@>",
_numericStringValue];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1ObjectIdentifier.h version [e688ca72a5].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjetType);
@class OFNumber;
/**
* @brief An ASN.1 ObjectIdentifier.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1ObjectIdentifier: OFObject
{
OFArray OF_GENERIC(OFNumber *) *_subidentifiers;
}
/**
* @brief The subidentifiers of the ObjectIdentifier.
*/
@property (readonly, nonatomic) OFArray OF_GENERIC(OFNumber *) *subidentifiers;
/**
* @brief Creates an ASN.1 ObjectIdentifier with the specified subidentifiers.
*
* @param subidentifiers The subidentifiers of the ASN.1 ObjectIdentifier
* @return A new, autoreleased OFASN1ObjectIdentifier
*/
+ (instancetype)objectIdentifierWithSubidentifiers:
(OFArray OF_GENERIC(OFNumber *) *)subidentifiers;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated ASN.1 ObjectIdentifier with the
* specified subidentifiers.
*
* @param subidentifiers The subidentifiers of the ASN.1 ObjectIdentifier
* @return An initialized OFASN1ObjectIdentifier
*/
- (instancetype)initWithSubidentifiers:
(OFArray OF_GENERIC(OFNumber *) *)subidentifiers OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated ASN.1 ObjectIdentifier with the
* specified arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized OFASN1ObjectIdentifier
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1ObjectIdentifier.m version [4d9e8570e7].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1ObjectIdentifier.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFNumber.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
@implementation OFASN1ObjectIdentifier
@synthesize subidentifiers = _subidentifiers;
+ (instancetype)objectIdentifierWithSubidentifiers:
(OFArray OF_GENERIC(OFNumber *) *)subidentifiers
{
return [[[self alloc]
initWithSubidentifiers: subidentifiers] autorelease];
}
- (instancetype)initWithSubidentifiers:
(OFArray OF_GENERIC(OFNumber *) *)subidentifiers
{
self = [super init];
@try {
if (subidentifiers.count < 1)
@throw [OFInvalidFormatException exception];
switch ([[subidentifiers objectAtIndex: 0] longLongValue]) {
case 0:
case 1:
case 2:
break;
default:
@throw [OFInvalidFormatException exception];
}
_subidentifiers = [subidentifiers 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();
OFMutableArray OF_GENERIC(OFNumber *) *subidentifiers;
@try {
const unsigned char *items = DEREncodedContents.items;
size_t count = DEREncodedContents.count;
unsigned long long value = 0;
uint_fast8_t bits = 0;
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_OBJECT_IDENTIFIER ||
constructed)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1 || count == 0)
@throw [OFInvalidArgumentException exception];
subidentifiers = [OFMutableArray array];
for (size_t i = 0; i < count; i++) {
if (bits == 0 && items[i] == 0x80)
@throw [OFInvalidFormatException exception];
value = (value << 7) | (items[i] & 0x7F);
bits += 7;
if (bits > sizeof(unsigned long long) * 8)
@throw [OFOutOfRangeException exception];
if (items[i] & 0x80)
continue;
if (subidentifiers.count == 0) {
if (value < 40)
[subidentifiers addObject:
[OFNumber numberWithInt: 0]];
else if (value < 80) {
[subidentifiers addObject:
[OFNumber numberWithInt: 1]];
value -= 40;
} else {
[subidentifiers addObject:
[OFNumber numberWithInt: 2]];
value -= 80;
}
}
[subidentifiers addObject:
[OFNumber numberWithUnsignedLongLong: value]];
value = 0;
bits = 0;
}
if (items[count - 1] & 0x80)
@throw [OFInvalidFormatException exception];
[subidentifiers makeImmutable];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithSubidentifiers: subidentifiers];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_subidentifiers release];
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFASN1ObjectIdentifier *objectIdentifier;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1ObjectIdentifier class]])
return false;
objectIdentifier = object;
if (![objectIdentifier->_subidentifiers isEqual: _subidentifiers])
return false;
return true;
}
- (unsigned long)hash
{
return _subidentifiers.hash;
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"<OFASN1ObjectIdentifier: %@>",
[_subidentifiers componentsJoinedByString: @"."]];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1OctetString.h version [d7f4e338c8].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
@class OFData;
/**
* @brief An ASN.1 OctetString.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1OctetString: OFObject
{
OFData *_octetStringValue;
}
/**
* @brief The OctetString value.
*/
@property (readonly, nonatomic) OFData *octetStringValue;
/**
* @brief Creates an OctetString with the specified value.
*
* @param octetString The OctetString value
* @return A new, autoreleased OFASN1OctetString
*/
+ (instancetype)octetStringWithOctetString: (OFData *)octetString;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OctetString with the specified
* value.
*
* @param octetString The OctetString value
* @return An initialized OFASN1OctetString
*/
- (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
* @param tagNumber The tag number of the value's type
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized ASN.1 OctetString
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1OctetString.m version [dbf5bc7d07].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1OctetString.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
@implementation OFASN1OctetString
@synthesize octetStringValue = _octetStringValue;
+ (instancetype)octetStringWithOctetString: (OFData *)octetString
{
return [[[self alloc] initWithOctetString: octetString] autorelease];
}
- (instancetype)initWithOctetString: (OFData *)octetString
{
self = [super init];
@try {
_octetStringValue = [octetString 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
{
@try {
if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL ||
tagNumber != OF_ASN1_TAG_NUMBER_OCTET_STRING ||
constructed)
@throw [OFInvalidArgumentException exception];
if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidArgumentException exception];
} @catch (id e) {
[self release];
@throw e;
}
return [self initWithOctetString: DEREncodedContents];
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_octetStringValue release];
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFASN1OctetString *octetString;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1OctetString class]])
return false;
octetString = object;
if (![octetString->_octetStringValue isEqual: _octetStringValue])
return false;
return true;
}
- (unsigned long)hash
{
return _octetStringValue.hash;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<OFASN1OctetString: %@>",
_octetStringValue];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1PrintableString.h version [15b004b863].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
/**
* @brief An ASN.1 PrintableString.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1PrintableString: OFObject
{
OFString *_printableStringValue;
}
/**
* @brief The PrintableString value.
*/
@property (readonly, nonatomic) OFString *printableStringValue;
/**
* @brief The string value.
*/
@property (readonly, nonatomic) OFString *stringValue;
/**
* @brief Creates a PrintableString with the specified string value.
*
* @param string The string value of the PrintableString
* @return A new, autoreleased OFASN1PrintableString
*/
+ (instancetype)stringWithString: (OFString *)string;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated PrintableString with the specified
* string value.
*
* @param string The string value of the PrintableString
* @return An initialized OFASN1PrintableString
*/
- (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
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized OFASN1PrintableString
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1PrintableString.m version [633e478a84].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
152
153
154
155
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1PrintableString.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
@implementation OFASN1PrintableString
@synthesize printableStringValue = _printableStringValue;
+ (instancetype)stringWithString: (OFString *)string
{
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
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 ' ':
case '\'':
case '(':
case ')':
case '+':
case ',':
case '-':
case '.':
case '/':
case ':':
case '=':
case '?':
continue;
default:
@throw [OFInvalidEncodingException exception];
}
}
_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 *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];
printableString = [OFString
stringWithCString: DEREncodedContents.items
encoding: OF_STRING_ENCODING_ASCII
length: DEREncodedContents.count];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithString: printableString];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_printableStringValue release];
[super dealloc];
}
- (OFString *)stringValue
{
return self.printableStringValue;
}
- (bool)isEqual: (id)object
{
OFASN1PrintableString *printableString;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1PrintableString class]])
return false;
printableString = object;
if (![printableString->_printableStringValue isEqual:
_printableStringValue])
return false;
return true;
}
- (unsigned long)hash
{
return _printableStringValue.hash;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<OFASN1PrintableString: %@>",
_printableStringValue];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1UTF8String.h version [a4b45c5c6e].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1Value.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
/**
* @brief An ASN.1 UTF8String.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1UTF8String: OFObject
{
OFString *_UTF8StringValue;
}
/**
* @brief The UTF8String value.
*/
@property (readonly, nonatomic) OFString *UTF8StringValue;
/**
* @brief The string value.
*/
@property (readonly, nonatomic) OFString *stringValue;
/**
* @brief Creates a UTF8String with the specified string value.
*
* @param string The string value of the UTF8String
* @return A new, autoreleased OFASN1UTF8String
*/
+ (instancetype)stringWithString: (OFString *)string;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated UTF8String with the specified
* string value.
*
* @param string The string value of the UTF8String
* @return An initialized OFASN1UTF8String
*/
- (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
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized OFASN1UTF8String
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1UTF8String.m version [53a8c373a7].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1UTF8String.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
@implementation OFASN1UTF8String
@synthesize UTF8StringValue = _UTF8StringValue;
+ (instancetype)stringWithString: (OFString *)string
{
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithString: (OFString *)string
{
self = [super init];
@try {
_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 *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];
UTF8String = [OFString
stringWithUTF8String: DEREncodedContents.items
length: DEREncodedContents.count];
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithString: UTF8String];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_UTF8StringValue release];
[super dealloc];
}
- (OFString *)stringValue
{
return self.UTF8StringValue;
}
- (bool)isEqual: (id)object
{
OFASN1UTF8String *UTF8String;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1UTF8String class]])
return false;
UTF8String = object;
if (![UTF8String->_UTF8StringValue isEqual: _UTF8StringValue])
return false;
return true;
}
- (unsigned long)hash
{
return _UTF8StringValue.hash;
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<OFASN1UTF8String: %@>",
_UTF8StringValue];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1Value.h version [6ceb7a1c4f].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
@class OFData;
/**
* @brief ASN.1 tag class.
*/
typedef enum {
/** Universal */
OF_ASN1_TAG_CLASS_UNIVERSAL = 0x0,
/** Application */
OF_ASN1_TAG_CLASS_APPLICATION = 0x1,
/** Context specific */
OF_ASN1_TAG_CLASS_CONTEXT_SPECIFIC = 0x2,
/** Private */
OF_ASN1_TAG_CLASS_PRIVATE = 0x3
} of_asn1_tag_class_t;
/**
* @brief ASN.1 tag number.
*/
typedef enum {
/** Boolean */
OF_ASN1_TAG_NUMBER_BOOLEAN = 0x01,
/** Integer */
OF_ASN1_TAG_NUMBER_INTEGER = 0x02,
/** Bit string */
OF_ASN1_TAG_NUMBER_BIT_STRING = 0x03,
/** Octet string */
OF_ASN1_TAG_NUMBER_OCTET_STRING = 0x04,
/** Null */
OF_ASN1_TAG_NUMBER_NULL = 0x05,
/** Object Identifier */
OF_ASN1_TAG_NUMBER_OBJECT_IDENTIFIER = 0x06,
/** Enumerated */
OF_ASN1_TAG_NUMBER_ENUMERATED = 0x0A,
/** UTF-8 string */
OF_ASN1_TAG_NUMBER_UTF8_STRING = 0x0C,
/** Sequence */
OF_ASN1_TAG_NUMBER_SEQUENCE = 0x10,
/** Set */
OF_ASN1_TAG_NUMBER_SET = 0x11,
/** NumericString */
OF_ASN1_TAG_NUMBER_NUMERIC_STRING = 0x12,
/** PrintableString */
OF_ASN1_TAG_NUMBER_PRINTABLE_STRING = 0x13,
/** IA5String */
OF_ASN1_TAG_NUMBER_IA5_STRING = 0x16
} of_asn1_tag_number_t;
/**
* @brief A class representing an ASN.1 value.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFASN1Value: OFObject
{
of_asn1_tag_class_t _tagClass;
of_asn1_tag_number_t _tagNumber;
bool _constructed;
OFData *_DEREncodedContents;
}
/**
* @brief The tag class of the value's type.
*/
@property (readonly, nonatomic) of_asn1_tag_class_t tagClass;
/**
* @brief The tag number of the value's type.
*/
@property (readonly, nonatomic) of_asn1_tag_number_t tagNumber;
/**
* @brief Whether the value if of a constructed type.
*/
@property (readonly, nonatomic, getter=isConstructed) bool constructed;
/**
* @brief The DER-encoded contents octets of the value.
*/
@property (readonly, nonatomic) OFData *DEREncodedContents;
/**
* @brief Creates a new ASN.1 value with the specified arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return A new ASN.1 value
*/
+ (instancetype)valueWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated ASN.1 value with the specified
* arguments.
*
* @param tagClass The tag class of the value's type
* @param tagNumber The tag number of the value's type
* @param constructed Whether the value if of a constructed type
* @param DEREncodedContents The DER-encoded contents octets of the value.
* @return An initialized ASN.1 value
*/
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
OF_DESIGNATED_INITIALIZER;
@end
OF_ASSUME_NONNULL_END
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Deleted src/OFASN1Value.m version [200bca2819].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
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
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFASN1Value.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidFormatException.h"
@implementation OFASN1Value
@synthesize tagClass = _tagClass, tagNumber = _tagNumber;
@synthesize constructed = _constructed;
@synthesize DEREncodedContents = _DEREncodedContents;
+ (instancetype)valueWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
return [[[self alloc]
initWithTagClass: tagClass
tagNumber: tagNumber
constructed: constructed
DEREncodedContents: DEREncodedContents] autorelease];
}
- (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass
tagNumber: (of_asn1_tag_number_t)tagNumber
constructed: (bool)constructed
DEREncodedContents: (OFData *)DEREncodedContents
{
self = [super init];
@try {
if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidFormatException exception];
_tagClass = tagClass;
_tagNumber = tagNumber;
_constructed = constructed;
_DEREncodedContents = [DEREncodedContents copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[_DEREncodedContents release];
[super dealloc];
}
- (bool)isEqual: (id)object
{
OFASN1Value *value;
if (object == self)
return true;
if (![object isKindOfClass: [OFASN1Value class]])
return false;
value = object;
if (value->_tagClass != _tagClass)
return false;
if (value->_tagNumber != _tagNumber)
return false;
if (value->_constructed != _constructed)
return false;
if (![value->_DEREncodedContents isEqual: _DEREncodedContents])
return false;
return true;
}
- (unsigned long)hash
{
uint32_t hash;
OF_HASH_INIT(hash);
OF_HASH_ADD(hash, _tagClass & 0xFF);
OF_HASH_ADD(hash, _tagNumber & 0xFF);
OF_HASH_ADD(hash, _constructed);
OF_HASH_ADD_HASH(hash, _DEREncodedContents.hash);
OF_HASH_FINALIZE(hash);
return hash;
}
- (OFString *)description
{
return [OFString stringWithFormat:
@"<OFASN1Value:\n"
@"\tTag class = %x\n"
@"\tTag number = %x\n"
@"\tConstructed = %u\n"
@"\tDER-encoded contents = %@\n"
@">",
_tagClass, _tagNumber, _constructed,
_DEREncodedContents.description];
}
@end
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Modified src/OFData.h
from [30fd329fb3]
to [5c1ed5a74d].
︙ | | | ︙ | |
327
328
329
330
331
332
333
334
335
336
|
*/
- (void)writeToURL: (OFURL *)URL;
@end
OF_ASSUME_NONNULL_END
#import "OFMutableData.h"
#import "OFData+ASN1DERParsing.h"
#import "OFData+CryptographicHashing.h"
#import "OFData+MessagePackParsing.h"
|
<
|
327
328
329
330
331
332
333
334
335
|
*/
- (void)writeToURL: (OFURL *)URL;
@end
OF_ASSUME_NONNULL_END
#import "OFMutableData.h"
#import "OFData+CryptographicHashing.h"
#import "OFData+MessagePackParsing.h"
|
Modified src/OFData.m
from [526e2e37ba]
to [8df6dac3bd].
︙ | | | ︙ | |
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#import "base64.h"
/* References for static linking */
void
_references_to_categories_of_OFData(void)
{
_OFData_ASN1DERParsing_reference = 1;
_OFData_CryptographicHashing_reference = 1;
_OFData_MessagePackParsing_reference = 1;
}
@implementation OFData
@synthesize itemSize = _itemSize;
|
<
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#import "base64.h"
/* References for static linking */
void
_references_to_categories_of_OFData(void)
{
_OFData_CryptographicHashing_reference = 1;
_OFData_MessagePackParsing_reference = 1;
}
@implementation OFData
@synthesize itemSize = _itemSize;
|
︙ | | | ︙ | |
Modified src/OFNull.h
from [ef78922bc1]
to [69babc4028].
︙ | | | ︙ | |
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFASN1DERRepresentation.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFNull OFNull.h ObjFW/OFNull.h
*
* @brief A class for representing null values in collections.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFNull: OFObject <OFCopying, OFSerialization, OFJSONRepresentation,
OFMessagePackRepresentation, OFASN1DERRepresentation>
/**
* @brief Returns an OFNull singleton.
*
* @return An OFNull singleton
*/
+ (OFNull *)null;
@end
|
<
|
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFNull OFNull.h ObjFW/OFNull.h
*
* @brief A class for representing null values in collections.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFNull: OFObject <OFCopying, OFSerialization, OFJSONRepresentation,
OFMessagePackRepresentation>
/**
* @brief Returns an OFNull singleton.
*
* @return An OFNull singleton
*/
+ (OFNull *)null;
@end
|
︙ | | | ︙ | |
Modified src/OFNull.m
from [dd4f67b6db]
to [252ff4815f].
︙ | | | ︙ | |
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
- (OFData *)messagePackRepresentation
{
uint8_t type = 0xC0;
return [OFData dataWithItems: &type count: 1];
}
- (OFData *)ASN1DERRepresentation
{
const unsigned char bytes[] = { OF_ASN1_TAG_NUMBER_NULL, 0 };
return [OFData dataWithItems: bytes count: sizeof(bytes)];
}
- (instancetype)autorelease
{
return self;
}
- (instancetype)retain
{
|
<
<
<
<
<
<
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
- (OFData *)messagePackRepresentation
{
uint8_t type = 0xC0;
return [OFData dataWithItems: &type count: 1];
}
- (instancetype)autorelease
{
return self;
}
- (instancetype)retain
{
|
︙ | | | ︙ | |
Modified src/ObjFW.h
from [fa4bd9f945]
to [d76330f616].
︙ | | | ︙ | |
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
#import "OFRunLoop.h"
#import "OFSandbox.h"
#ifdef OF_WINDOWS
# import "OFWindowsRegistryKey.h"
#endif
#import "OFASN1BitString.h"
#import "OFASN1Boolean.h"
#import "OFASN1Enumerated.h"
#import "OFASN1IA5String.h"
#import "OFASN1Integer.h"
#import "OFASN1NumericString.h"
#import "OFASN1ObjectIdentifier.h"
#import "OFASN1OctetString.h"
#import "OFASN1PrintableString.h"
#import "OFASN1UTF8String.h"
#import "OFASN1Value.h"
#import "OFAllocFailedException.h"
#import "OFException.h"
#ifdef OF_HAVE_SOCKETS
# import "OFAcceptFailedException.h"
# import "OFAlreadyConnectedException.h"
# import "OFBindFailedException.h"
#endif
|
<
<
<
<
<
<
<
<
<
<
<
<
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#import "OFRunLoop.h"
#import "OFSandbox.h"
#ifdef OF_WINDOWS
# import "OFWindowsRegistryKey.h"
#endif
#import "OFAllocFailedException.h"
#import "OFException.h"
#ifdef OF_HAVE_SOCKETS
# import "OFAcceptFailedException.h"
# import "OFAlreadyConnectedException.h"
# import "OFBindFailedException.h"
#endif
|
︙ | | | ︙ | |
Modified tests/Makefile
from [df0dcbd5b0]
to [a491bea751].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
include ../extra.mk
SUBDIRS = ${TESTPLUGIN}
CLEAN = EBOOT.PBP \
boot.dol \
${PROG_NOINST}.arm9 \
${PROG_NOINST}.nds
DISTCLEAN = Info.plist
PROG_NOINST = tests${PROG_SUFFIX}
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = ForwardingTests.m \
OFASN1DERParsingTests.m \
OFASN1DERRepresentationTests.m \
OFArrayTests.m \
${OF_BLOCK_TESTS_M} \
OFCharacterSetTests.m \
OFDataTests.m \
OFDateTests.m \
OFDictionaryTests.m \
OFInvocationTests.m \
|
<
<
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
include ../extra.mk
SUBDIRS = ${TESTPLUGIN}
CLEAN = EBOOT.PBP \
boot.dol \
${PROG_NOINST}.arm9 \
${PROG_NOINST}.nds
DISTCLEAN = Info.plist
PROG_NOINST = tests${PROG_SUFFIX}
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = ForwardingTests.m \
OFArrayTests.m \
${OF_BLOCK_TESTS_M} \
OFCharacterSetTests.m \
OFDataTests.m \
OFDateTests.m \
OFDictionaryTests.m \
OFInvocationTests.m \
|
︙ | | | ︙ | |
Deleted tests/OFASN1DERRepresentationTests.m version [c3751ee953].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "TestsAppDelegate.h"
static OFString *module;
@implementation TestsAppDelegate (OFASN1DERRepresentationTests)
- (void)ASN1DERRepresentationTests
{
void *pool = objc_autoreleasePoolPush();
OFData *data;
module = @"OFASN1BitString";
TEST(@"-[ASN1DERRepresentation]",
(data = [OFData dataWithItems: "\xFF\x00\xF8" count: 3]) &&
[[[OFASN1BitString bitStringWithBitString: data length: 21]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x03\x04\x03\xFF\x00\xF8" count: 6]] &&
(data = [OFData dataWithItems: "abcdefäöü" count: 12]) &&
[[[OFASN1BitString bitStringWithBitString: data length: 12 * 8]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x03\x0D\x00" "abcdefäöü" count: 15]] &&
(data = [OFData dataWithItems: "" count: 0]) &&
[[[OFASN1BitString bitStringWithBitString: data length: 0]
ASN1DERRepresentation] isEqual:
[OFData dataWithItems: "\x03\x01\x00" count: 3]])
module = @"OFASN1Boolean";
TEST(@"-[ASN1DERRepresentation]",
[[[OFASN1Boolean booleanWithBool: false] ASN1DERRepresentation]
isEqual: [OFData dataWithItems: "\x01\x01\x00" count: 3]] &&
[[[OFASN1Boolean booleanWithBool: true] ASN1DERRepresentation]
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
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
Modified tests/TestsAppDelegate.h
from [34af7b06b7]
to [2fa9306569].
︙ | | | ︙ | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
}
- (void)outputTesting: (OFString *)test inModule: (OFString *)module;
- (void)outputSuccess: (OFString *)test inModule: (OFString *)module;
- (void)outputFailure: (OFString *)test inModule: (OFString *)module;
@end
@interface TestsAppDelegate (OFASN1DERParsingTests)
- (void)ASN1DERParsingTests;
@end
@interface TestsAppDelegate (OFASN1DERRepresentationTests)
- (void)ASN1DERRepresentationTests;
@end
@interface TestsAppDelegate (OFArrayTests)
- (void)arrayTests;
@end
@interface TestsAppDelegate (OFBlockTests)
- (void)blockTests;
@end
|
<
<
<
<
<
<
<
<
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
}
- (void)outputTesting: (OFString *)test inModule: (OFString *)module;
- (void)outputSuccess: (OFString *)test inModule: (OFString *)module;
- (void)outputFailure: (OFString *)test inModule: (OFString *)module;
@end
@interface TestsAppDelegate (OFArrayTests)
- (void)arrayTests;
@end
@interface TestsAppDelegate (OFBlockTests)
- (void)blockTests;
@end
|
︙ | | | ︙ | |
Modified tests/TestsAppDelegate.m
from [70ab30c579]
to [ce26788f19].
︙ | | | ︙ | |
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
[self XMLNodeTests];
[self XMLElementBuilderTests];
#ifdef OF_HAVE_FILES
[self serializationTests];
#endif
[self JSONTests];
[self propertyListTests];
[self ASN1DERParsingTests];
[self ASN1DERRepresentationTests];
#if defined(OF_HAVE_PLUGINS)
[self pluginTests];
#endif
#ifdef OF_WINDOWS
[self windowsRegistryKeyTests];
#endif
|
<
<
|
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
[self XMLNodeTests];
[self XMLElementBuilderTests];
#ifdef OF_HAVE_FILES
[self serializationTests];
#endif
[self JSONTests];
[self propertyListTests];
#if defined(OF_HAVE_PLUGINS)
[self pluginTests];
#endif
#ifdef OF_WINDOWS
[self windowsRegistryKeyTests];
#endif
|
︙ | | | ︙ | |