@@ -23,10 +23,11 @@ #import "OFString.h" #import "OFTaggedPointerNumber.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" +#import "OFNotImplementedException.h" #import "OFOutOfRangeException.h" @interface OFNumber () - (OFString *) of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options @@ -708,10 +709,25 @@ return [OFString stringWithFormat: @"%llu", self.unsignedLongLongValue]; @throw [OFInvalidFormatException exception]; } + +- (OFData *)ASN1DERRepresentation +{ + if (self.objCType[0] == 'B' && self.objCType[1] == '\0') { + char buffer[] = { + OFASN1TagNumberBoolean, + 1, + (self.boolValue ? 0xFF : 0x00) + }; + + return [OFData dataWithItems: buffer count: sizeof(buffer)]; + } else + @throw [OFNotImplementedException exceptionWithSelector: _cmd + object: self]; +} - (OFString *)JSONRepresentation { return [self of_JSONRepresentationWithOptions: 0 depth: 0]; }