Differences From Artifact [12624c872e]:
- File
src/OFASN1BitString.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: 3589) [annotate] [blame] [check-ins using]
To Artifact [1e12f722e3]:
- File src/OFASN1BitString.m — part of check-in [bceb7ed4c9] at 2019-03-08 00:35:48 on branch trunk — Use dot syntax (user: js, size: 3579) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
39 40 41 42 43 44 45 | - (instancetype)initWithBitStringValue: (OFData *)bitStringValue bitStringLength: (size_t)bitStringLength { self = [super init]; @try { | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | - (instancetype)initWithBitStringValue: (OFData *)bitStringValue bitStringLength: (size_t)bitStringLength { self = [super init]; @try { if (bitStringValue.count * bitStringValue.itemSize != bitStringLength / 8) @throw [OFInvalidFormatException exception]; _bitStringValue = [bitStringValue copy]; _bitStringLength = bitStringLength; } @catch (id e) { [self release]; |
︙ | ︙ | |||
64 65 66 67 68 69 70 | { void *pool = objc_autoreleasePoolPush(); OFData *bitStringValue; size_t bitStringLength; @try { unsigned char lastByteBits; | | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | { void *pool = objc_autoreleasePoolPush(); OFData *bitStringValue; size_t bitStringLength; @try { unsigned char lastByteBits; 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]; lastByteBits = *(unsigned char *)[DEREncodedContents itemAtIndex: 0]; if (count == 1 && lastByteBits != 0) @throw [OFInvalidFormatException exception]; |
︙ | ︙ | |||
130 131 132 133 134 135 136 | return false; return true; } - (uint32_t)hash { | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | return false; return true; } - (uint32_t)hash { return _bitStringValue.hash + (uint32_t)_bitStringLength; } - (OFString *)description { return [OFString stringWithFormat: @"<OFASN1BitString: %@ (%zu bits)>", _bitStringValue, _bitStringLength]; } @end |