Overview
Comment: | Add more ASN.1 string types (IA5 and octet string) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6410235ae3fc0893584410947dc182fc |
User & Date: | js on 2018-10-13 22:43:49 |
Other Links: | manifest | tags |
Context
2018-10-13
| ||
22:58 | OFASN1*: Add -[description] check-in: d3207b2a3d user: js tags: trunk | |
22:43 | Add more ASN.1 string types (IA5 and octet string) check-in: 6410235ae3 user: js tags: trunk | |
21:40 | Initial ASN.1 DER parsing support check-in: d276166f70 user: js tags: trunk | |
Changes
Modified src/Makefile from [80f64e4680] to [597d11897b].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | + + | include ../extra.mk SUBDIRS = ${RUNTIME} exceptions ${ENCODINGS} forwarding invocation SUBDIRS_AFTER = ${BRIDGE} DISTCLEAN = objfw-defs.h SHARED_LIB = ${OBJFW_SHARED_LIB} STATIC_LIB = ${OBJFW_STATIC_LIB} FRAMEWORK = ${OBJFW_FRAMEWORK} LIB_MAJOR = ${OBJFW_LIB_MAJOR} LIB_MINOR = ${OBJFW_LIB_MINOR} SRCS = OFASN1Boolean.m \ OFASN1IA5String.m \ OFASN1Integer.m \ OFASN1Null.m \ OFASN1OctetString.m \ OFASN1UTF8String.m \ OFASN1Value.m \ OFApplication.m \ OFArray.m \ OFAutoreleasePool.m \ OFBlock.m \ OFCharacterSet.m \ |
︙ |
Added src/OFASN1IA5String.h version [979959c6d4].
|
Added src/OFASN1IA5String.m version [2c948a64a3].
|
Added src/OFASN1OctetString.h version [e75e49a18e].
|
Added src/OFASN1OctetString.m version [7e32247b16].
|
Modified src/OFASN1UTF8String.h from [5546a22768] to [e216804d88].
︙ | |||
22 23 24 25 26 27 28 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | - + + + + + + | @class OFString; /*! * @brief An ASN.1 UTF-8 string. */ @interface OFASN1UTF8String: OFASN1Value { |
Modified src/OFASN1UTF8String.m from [73edad1684] to [6af5a5eda9].
︙ | |||
20 21 22 23 24 25 26 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | - + - + - + + + + + + | #import "OFASN1UTF8String.h" #import "OFData.h" #import "OFString.h" #import "OFInvalidArgumentException.h" @implementation OFASN1UTF8String |
Modified src/OFASN1Value.h from [5fc1ae337b] to [6d36bcbbbd].
︙ | |||
38 39 40 41 42 43 44 | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | - + - + + + - + - + - + + + | } of_asn1_tag_class_t; /*! * @brief ASN.1 tag number. */ typedef enum { /*! Boolean */ |
︙ |
Modified src/OFData+ASN1DERValue.m from [a444610f3e] to [53e3bd957f].
︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | + + + - - - | * file. */ #include "config.h" #import "OFData+ASN1DERValue.h" #import "OFASN1Boolean.h" #import "OFASN1IA5String.h" #import "OFASN1Integer.h" #import "OFASN1Null.h" #import "OFASN1OctetString.h" #import "OFASN1UTF8String.h" #import "OFASN1Value.h" #import "OFArray.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" enum { ASN1_TAG_CONSTRUCTED_MASK = 0x20 }; int _OFData_ASN1DERValue_reference; static size_t parseObject(OFData *self, id *object, size_t depthLimit); static OFArray * parseSequence(OFData *contents, size_t depthLimit) { OFMutableArray *ret = [OFMutableArray array]; size_t count = [contents count]; |
︙ | |||
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | + + + + + + + + | switch (tag) { case OF_ASN1_TAG_NUMBER_BOOLEAN: valueClass = [OFASN1Boolean class]; break; case OF_ASN1_TAG_NUMBER_INTEGER: valueClass = [OFASN1Integer class]; break; case OF_ASN1_TAG_NUMBER_OCTET_STRING: valueClass = [OFASN1OctetString class]; break; case OF_ASN1_TAG_NUMBER_NULL: valueClass = [OFASN1Null class]; break; case OF_ASN1_TAG_NUMBER_UTF8_STRING: valueClass = [OFASN1UTF8String class]; break; case OF_ASN1_TAG_NUMBER_SEQUENCE: @throw [OFInvalidFormatException exception]; case OF_ASN1_TAG_NUMBER_SEQUENCE | ASN1_TAG_CONSTRUCTED_MASK: *object = parseSequence(contents, depthLimit - 1); return bytesConsumed; case OF_ASN1_TAG_NUMBER_IA5_STRING: valueClass = [OFASN1IA5String class]; break; default: valueClass = [OFASN1Value class]; break; } *object = [valueClass valueWithTagClass: tag >> 6 tagNumber: tag & 0x1F |
︙ |
Modified src/OFData.h from [4bcaa7696d] to [0fbb22f9e6].
︙ | |||
279 280 281 282 283 284 285 | 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | - + | * @return The specified item of the OFData */ - (const void *)itemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER; /*! * @brief Returns the data in the specified range as a new OFData. * |
︙ |
Modified tests/OFDataASN1DERValueTests.m from [b66444c495] to [d5ac350acb].
︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | + + + | * file. */ #include "config.h" #import "OFData.h" #import "OFASN1Boolean.h" #import "OFASN1IA5String.h" #import "OFASN1Integer.h" #import "OFASN1Null.h" #import "OFASN1OctetString.h" #import "OFASN1UTF8String.h" #import "OFArray.h" #import "OFString.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" static OFString *module = @"OFData+ASN1DERValue"; @implementation TestsAppDelegate (OFDataASN1DERValueTests) |
︙ | |||
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + | "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" count: 11] ASN1DERValue]) EXPECT_EXCEPTION(@"Detection of truncated integer", OFTruncatedDataException, [[OFData dataWithItems: "\x02\x02\x00" count: 3] ASN1DERValue]) TEST(@"Parsing of octet string", [[[[OFData dataWithItems: "\x04\x0CHello World!" count: 14] ASN1DERValue] octetStringValue] isEqual: [OFData dataWithItems: "Hello World!" count: 12]] && [[[[OFData dataWithItems: "\x04\x81\x80xxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxx" count: 131] ASN1DERValue] octetStringValue] isEqual: [OFData dataWithItems: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxx" count: 128]]) EXPECT_EXCEPTION(@"Detection of out of range octet string", OFOutOfRangeException, [[OFData dataWithItems: "\x16\x89" "\x01\x01\x01\x01\x01\x01\x01\x01\x01" count: 11] ASN1DERValue]) EXPECT_EXCEPTION(@"Detection of truncated octet string", OFTruncatedDataException, [[OFData dataWithItems: "\x16\x01" count: 2] ASN1DERValue]) TEST(@"Parsing of NULL", [[[OFData dataWithItems: "\x05\x00" count: 2] ASN1DERValue] isKindOfClass: [OFASN1Null class]]) EXPECT_EXCEPTION(@"Detection of invalid NULL", OFInvalidFormatException, [[OFData dataWithItems: "\x05\x01\x00" count: 3] ASN1DERValue]) TEST(@"Parsing of UTF-8 string", [[[[OFData dataWithItems: "\x0C\x0EHällo Wörld!" |
︙ | |||
163 164 165 166 167 168 169 170 171 172 | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + | count: 2] ASN1DERValue]) EXPECT_EXCEPTION(@"Parsing of truncated sequence #2", OFTruncatedDataException, [[OFData dataWithItems: "\x30\x04\x02\x01\x01\x00\x00" count: 7] ASN1DERValue]) TEST(@"Parsing of IA5String", [[[[OFData dataWithItems: "\x16\x0CHello World!" count: 14] ASN1DERValue] IA5StringValue] isEqual: @"Hello World!"] && [[[[OFData dataWithItems: "\x16\x81\x80xxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxx" count: 131] ASN1DERValue] IA5StringValue] isEqual: @"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" @"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" @"xxxxxxxxxxxxxxxx"]) EXPECT_EXCEPTION(@"Detection of invalid IA5String", OFInvalidEncodingException, [[OFData dataWithItems: "\x16\x02ä" count: 4] ASN1DERValue]) EXPECT_EXCEPTION(@"Detection of out of range IA5String", OFOutOfRangeException, [[OFData dataWithItems: "\x16\x89" "\x01\x01\x01\x01\x01\x01\x01\x01\x01" count: 11] ASN1DERValue]) EXPECT_EXCEPTION(@"Detection of truncated IA5String", OFTruncatedDataException, [[OFData dataWithItems: "\x16\x01" count: 2] ASN1DERValue]) [pool drain]; } @end |