Differences From Artifact [94a9ef2a4a]:
- File src/OFASN1ObjectIdentifier.m — part of check-in [cfed9215e4] at 2018-10-14 22:41:52 on branch trunk — Add ASN.1 Object Identifier type (user: js, size: 3097) [annotate] [blame] [check-ins using]
To Artifact [84db523991]:
- File
src/OFASN1ObjectIdentifier.m
— part of check-in
[b1944fd052]
at
2018-10-27 13:01:38
on branch trunk
— Do not subclass OFASN1Value
The reason for this is that OFASN1Value requires an initializer for DER
encoding, however, it might be beneficial to create an ASN.1 type
without providing DER encoding for it. (user: js, size: 3393) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 | #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" @implementation OFASN1ObjectIdentifier @synthesize subidentifiers = _subidentifiers; - (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass tagNumber: (of_asn1_tag_number_t)tagNumber constructed: (bool)constructed DEREncodedContents: (OFData *)DEREncodedContents { | > > > > > | < < < | | | | | | | | 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 | #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" @implementation OFASN1ObjectIdentifier @synthesize subidentifiers = _subidentifiers; - (instancetype)init { OF_INVALID_INIT_METHOD } - (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 { void *pool = objc_autoreleasePoolPush(); const unsigned char *items = [DEREncodedContents items]; size_t count = [DEREncodedContents count]; OFMutableArray *subidentifiers = [OFMutableArray array]; uintmax_t 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]; 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; |
︙ | ︙ | |||
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | - (void)dealloc { [_subidentifiers release]; [super dealloc]; } - (OFString *)description { return [OFString stringWithFormat: @"<OFASN1ObjectIdentifier: %@>", [_subidentifiers componentsJoinedByString: @"."]]; } @end | > > > > > > > > > > > > > > > > > > > > | 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 | - (void)dealloc { [_subidentifiers release]; [super dealloc]; } - (bool)isEqual: (id)object { OFASN1ObjectIdentifier *objectIdentifier; if (![object isKindOfClass: [OFASN1ObjectIdentifier class]]) return false; objectIdentifier = object; if (![objectIdentifier->_subidentifiers isEqual: _subidentifiers]) return false; return true; } - (uint32_t)hash { return [_subidentifiers hash]; } - (OFString *)description { return [OFString stringWithFormat: @"<OFASN1ObjectIdentifier: %@>", [_subidentifiers componentsJoinedByString: @"."]]; } @end |