ObjFW  Check-in [f77aff5b45]

Overview
Comment:Add -[OFASN1Boolean DEREncodedValue]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f77aff5b452e1768395058262c2585a1160cc6ddf09630f08e95bd0e538b994c
User & Date: js on 2019-03-16 23:37:16
Other Links: manifest | tags
Context
2019-03-18
21:27
ofhttp: Only print HEAD request for -O with -v check-in: a7872e1065 user: js tags: trunk
2019-03-16
23:37
Add -[OFASN1Boolean DEREncodedValue] check-in: f77aff5b45 user: js tags: trunk
14:32
Naming consistency for 2 forgotten structs check-in: a2d31cca3d user: js tags: trunk
Changes

Modified src/OFASN1Boolean.h from [a777458522] to [771cc1162f].

29
30
31
32
33
34
35





36
37
38
39
40
41
42
}

/*!
 * @brief The Boolean value.
 */
@property (readonly, nonatomic) bool booleanValue;






/*!
 * @brief Creates an ASN.1 Boolean with the specified Boolean value.
 *
 * @param booleanValue The value of the Boolean
 * @return A new, autoreleased OFASN1Boolean
 */
+ (instancetype)booleanWithBooleanValue: (bool)booleanValue;







>
>
>
>
>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
}

/*!
 * @brief The Boolean value.
 */
@property (readonly, nonatomic) bool booleanValue;

/*!
 * @brief The Boolean in DER encoding.
 */
@property (readonly, nonatomic) OFData *DEREncodedValue;

/*!
 * @brief Creates an ASN.1 Boolean with the specified Boolean value.
 *
 * @param booleanValue The value of the Boolean
 * @return A new, autoreleased OFASN1Boolean
 */
+ (instancetype)booleanWithBooleanValue: (bool)booleanValue;

Modified src/OFASN1Boolean.m from [dc4725221d] to [c6562613f5].

69
70
71
72
73
74
75












76
77
78
79
80
81
82
	return [self initWithBooleanValue: !!value];
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}













- (bool)isEqual: (id)object
{
	OFASN1Boolean *boolean;

	if (![object isKindOfClass: [OFASN1Boolean class]])
		return false;







>
>
>
>
>
>
>
>
>
>
>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
	return [self initWithBooleanValue: !!value];
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (OFData *)DEREncodedValue
{
	char buffer[] = {
		OF_ASN1_TAG_NUMBER_BOOLEAN,
		1,
		(_booleanValue ? 0xFF : 0x00)
	};

	return [OFData dataWithItems: buffer
			       count: sizeof(buffer)];
}

- (bool)isEqual: (id)object
{
	OFASN1Boolean *boolean;

	if (![object isKindOfClass: [OFASN1Boolean class]])
		return false;

Modified tests/Makefile from [90c0cff21c] to [c16bda6408].

1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
include ../extra.mk

SUBDIRS = ${TESTPLUGIN}

CLEAN = EBOOT.PBP		\
	boot.dol		\
	${PROG_NOINST}.arm9	\
	${PROG_NOINST}.nds

PROG_NOINST = tests${PROG_SUFFIX}
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = ForwardingTests.m		\
       OFASN1DERValueTests.m		\

       OFArrayTests.m			\
       ${OFBLOCKTESTS_M}		\
       OFCharacterSetTests.m		\
       OFDataTests.m			\
       OFDateTests.m			\
       OFDictionaryTests.m		\
       OFInvocationTests.m		\













>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
include ../extra.mk

SUBDIRS = ${TESTPLUGIN}

CLEAN = EBOOT.PBP		\
	boot.dol		\
	${PROG_NOINST}.arm9	\
	${PROG_NOINST}.nds

PROG_NOINST = tests${PROG_SUFFIX}
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = ForwardingTests.m		\
       OFASN1DERValueTests.m		\
       OFASN1DEREncodedValueTests.m	\
       OFArrayTests.m			\
       ${OFBLOCKTESTS_M}		\
       OFCharacterSetTests.m		\
       OFDataTests.m			\
       OFDateTests.m			\
       OFDictionaryTests.m		\
       OFInvocationTests.m		\

Added tests/OFASN1DEREncodedValueTests.m version [40295ad8ca].

















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 *               2018, 2019
 *   Jonathan Schleifer <js@heap.zone>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "TestsAppDelegate.h"

static OFString *module;

@implementation TestsAppDelegate (OFASN1DEREncodedValueTests)
- (void)ASN1DEREncodedValueTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	module = @"OFASN1Boolean";
	TEST(@"-[DEREncodedValue]",
	    [[[OFASN1Boolean booleanWithBooleanValue: false] DEREncodedValue]
	    isEqual: [OFData dataWithItems: "\x01\x01\x00"
				     count: 3]] &&
	    [[[OFASN1Boolean booleanWithBooleanValue: true] DEREncodedValue]
	    isEqual: [OFData dataWithItems: "\x01\x01\xFF"
				     count: 3]])

	[pool drain];
}
@end

Modified tests/TestsAppDelegate.h from [dcc6d0ae02] to [912120ba9a].

85
86
87
88
89
90
91




92
93
94
95
96
97
98
- (void)outputFailure: (OFString *)test
	     inModule: (OFString *)module;
@end

@interface TestsAppDelegate (OFASN1DERValueTests)
- (void)ASN1DERValueTests;
@end





@interface TestsAppDelegate (OFArrayTests)
- (void)arrayTests;
@end

@interface TestsAppDelegate (OFBlockTests)
- (void)blockTests;







>
>
>
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
- (void)outputFailure: (OFString *)test
	     inModule: (OFString *)module;
@end

@interface TestsAppDelegate (OFASN1DERValueTests)
- (void)ASN1DERValueTests;
@end

@interface TestsAppDelegate (OFASN1DEREncodedValueTests)
- (void)ASN1DEREncodedValueTests;
@end

@interface TestsAppDelegate (OFArrayTests)
- (void)arrayTests;
@end

@interface TestsAppDelegate (OFBlockTests)
- (void)blockTests;

Modified tests/TestsAppDelegate.m from [7169202b42] to [b899b58d18].

433
434
435
436
437
438
439

440
441
442
443
444
445
446
	[self XMLElementBuilderTests];
#ifdef OF_HAVE_FILES
	[self serializationTests];
#endif
	[self JSONTests];
	[self propertyListTests];
	[self ASN1DERValueTests];

#if defined(OF_HAVE_PLUGINS)
	[self pluginTests];
#endif
#ifdef OF_WINDOWS
	[self windowsRegistryKeyTests];
#endif








>







433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
	[self XMLElementBuilderTests];
#ifdef OF_HAVE_FILES
	[self serializationTests];
#endif
	[self JSONTests];
	[self propertyListTests];
	[self ASN1DERValueTests];
	[self ASN1DEREncodedValueTests];
#if defined(OF_HAVE_PLUGINS)
	[self pluginTests];
#endif
#ifdef OF_WINDOWS
	[self windowsRegistryKeyTests];
#endif