Differences From Artifact [1ad931a1cf]:
- File
src/OFASN1ObjectIdentifier.m
— part of check-in
[c60933a59b]
at
2019-02-09 17:44:00
on branch trunk
— OFASN1*: Add designated initializer
This is in preparation for DER serialization support. (user: js, size: 4108) [annotate] [blame] [check-ins using]
To Artifact [531a8feaa4]:
- File src/OFASN1ObjectIdentifier.m — part of check-in [bceb7ed4c9] at 2019-03-08 00:35:48 on branch trunk — Use dot syntax (user: js, size: 4096) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
39 40 41 42 43 44 45 | - (instancetype)initWithSubidentifiers: (OFArray OF_GENERIC(OFNumber *) *)subidentifiers { self = [super init]; @try { | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | - (instancetype)initWithSubidentifiers: (OFArray OF_GENERIC(OFNumber *) *)subidentifiers { self = [super init]; @try { if (subidentifiers.count < 1) @throw [OFInvalidFormatException exception]; switch ([[subidentifiers objectAtIndex: 0] intMaxValue]) { case 0: case 1: case 2: break; |
︙ | ︙ | |||
69 70 71 72 73 74 75 | constructed: (bool)constructed DEREncodedContents: (OFData *)DEREncodedContents { void *pool = objc_autoreleasePoolPush(); OFMutableArray OF_GENERIC(OFNumber *) *subidentifiers; @try { | | | | | | 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 | 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; 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]; 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(uintmax_t) * 8) @throw [OFOutOfRangeException exception]; if (items[i] & 0x80) continue; if (subidentifiers.count == 0) { if (value < 40) [subidentifiers addObject: [OFNumber numberWithUIntMax: 0]]; else if (value < 80) { [subidentifiers addObject: [OFNumber numberWithUIntMax: 1]]; value -= 40; |
︙ | ︙ | |||
164 165 166 167 168 169 170 | return false; return true; } - (uint32_t)hash { | | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | return false; return true; } - (uint32_t)hash { return _subidentifiers.hash; } - (OFString *)description { return [OFString stringWithFormat: @"<OFASN1ObjectIdentifier: %@>", [_subidentifiers componentsJoinedByString: @"."]]; } @end |