@@ -25,25 +25,32 @@ #import "OFInvalidFormatException.h" @implementation OFASN1Boolean @synthesize booleanValue = _booleanValue; -- (instancetype)init ++ (instancetype)booleanWithBooleanValue: (bool)booleanValue +{ + return [[[self alloc] initWithBooleanValue: booleanValue] autorelease]; +} + +- (instancetype)initWithBooleanValue: (bool)booleanValue { - OF_INVALID_INIT_METHOD + self = [super init]; + + _booleanValue = booleanValue; + + return self; } - (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass tagNumber: (of_asn1_tag_number_t)tagNumber constructed: (bool)constructed DEREncodedContents: (OFData *)DEREncodedContents { - self = [super init]; + unsigned char value; @try { - unsigned char value; - if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_BOOLEAN || constructed) @throw [OFInvalidArgumentException exception]; if ([DEREncodedContents itemSize] != 1 || @@ -52,18 +59,21 @@ value = *(unsigned char *)[DEREncodedContents itemAtIndex: 0]; if (value != 0 && value != 0xFF) @throw [OFInvalidFormatException exception]; - - _booleanValue = value; } @catch (id e) { [self release]; @throw e; } - return self; + return [self initWithBooleanValue: !!value]; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD } - (bool)isEqual: (id)object { OFASN1Boolean *boolean;