Differences From Artifact [64757d3fa2]:
- File src/OFASN1ObjectIdentifier.m — part of check-in [c7f0229795] at 2020-01-02 01:51:34 on branch trunk — Update copyright (user: js, size: 4136) [annotate] [blame] [check-ins using]
To Artifact [13ae15fdce]:
- File
src/OFASN1ObjectIdentifier.m
— part of check-in
[d74f244ab7]
at
2020-08-12 20:56:32
on branch trunk
— Avoid using (u)intmax_t in methods
It is not guaranteed that a type encoding for it exists. (user: js, size: 4153) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
42 43 44 45 46 47 48 | { self = [super init]; @try { if (subidentifiers.count < 1) @throw [OFInvalidFormatException exception]; | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | { 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]; } |
︙ | ︙ | |||
71 72 73 74 75 76 77 | { void *pool = objc_autoreleasePoolPush(); OFMutableArray OF_GENERIC(OFNumber *) *subidentifiers; @try { const unsigned char *items = DEREncodedContents.items; size_t count = DEREncodedContents.count; | | | | | | | | 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 | { 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]; |
︙ | ︙ |