Overview
Comment: | Migrate OFScryptTests to ObjFWTest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | objfwtest |
Files: | files | file ages | folders |
SHA3-256: |
86a2f1e2bfa438b835c278194cebdaec |
User & Date: | js on 2024-02-11 14:13:44 |
Other Links: | branch diff | manifest | tags |
Context
2024-02-11
| ||
14:26 | Migrate OFCharacterSetTests to ObjFWTest check-in: 4127a58b04 user: js tags: objfwtest | |
14:13 | Migrate OFScryptTests to ObjFWTest check-in: 86a2f1e2bf user: js tags: objfwtest | |
13:55 | Clean up various leftovers to fix the build check-in: 80406ae7bf user: js tags: objfwtest | |
Changes
Modified new_tests/Makefile from [4907351109] to [a58e6edb61].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFColorTests.m \ OFIRITests.m \ OFNumberTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ ${USE_SRCS_PLUGINS} SRCS_PLUGINS = OFPluginTests.m include ../buildsys.mk .PHONY: run run-on-ios run-on-android run: | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFColorTests.m \ OFIRITests.m \ OFNumberTests.m \ OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ ${USE_SRCS_PLUGINS} SRCS_PLUGINS = OFPluginTests.m include ../buildsys.mk .PHONY: run run-on-ios run-on-android run: |
︙ | ︙ |
Modified new_tests/OFPBKDF2Tests.m from [4ebe320029] to [39698719c4].
︙ | ︙ | |||
43 44 45 46 47 48 49 | /* Test vectors from RFC 6070 */ - (void)testRFC6070TestVector1 { unsigned char key[25]; OFPBKDF2((OFPBKDF2Parameters){ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 68 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 95 96 97 98 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 157 158 159 160 161 162 163 164 165 166 167 168 | /* Test vectors from RFC 6070 */ - (void)testRFC6070TestVector1 { unsigned char key[25]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 1, .salt = (unsigned char *)"salt", .saltLength = 4, .password = "password", .passwordLength = 8, .key = key, .keyLength = 20, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\x0C\x60\xC8\x0F\x96\x1F\x0E\x71\xF3\xA9\xB5" "\x24\xAF\x60\x12\x06\x2F\xE0\x37\xA6", 20), 0); } - (void)testRFC6070TestVector2 { unsigned char key[25]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 2, .salt = (unsigned char *)"salt", .saltLength = 4, .password = "password", .passwordLength = 8, .key = key, .keyLength = 20, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\xEA\x6C\x01\x4D\xC7\x2D\x6F\x8C\xCD\x1E\xD9" "\x2A\xCE\x1D\x41\xF0\xD8\xDE\x89\x57", 20), 0); } - (void)testRFC6070TestVector3 { unsigned char key[25]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 4096, .salt = (unsigned char *)"salt", .saltLength = 4, .password = "password", .passwordLength = 8, .key = key, .keyLength = 20, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\x4B\x00\x79\x01\xB7\x65\x48\x9A\xBE\xAD\x49" "\xD9\x26\xF7\x21\xD0\x65\xA4\x29\xC1", 20), 0); } #if 0 /* This test takes too long, even on a fast machine. */ - (void)testRFC6070TestVector4 { unsigned char key[25]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 16777216, .salt = (unsigned char *)"salt", .saltLength = 4, .password = "password", .passwordLength = 8, .key = key, .keyLength = 20, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\xEE\xFE\x3D\x61\xCD\x4D\xA4\xE4\xE9\x94\x5B" "\x3D\x6B\xA2\x15\x8C\x26\x34\xE9\x84", 20), 0); } #endif - (void)testRFC6070TestVector5 { unsigned char key[25]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 4096, .salt = (unsigned char *)"saltSALTsaltSALTsalt" "SALTsaltSALTsalt", .saltLength = 36, .password = "passwordPASSWORDpassword", .passwordLength = 24, .key = key, .keyLength = 25, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\x3D\x2E\xEC\x4F\xE4\x1C\x84\x9B\x80\xC8\xD8" "\x36\x62\xC0\xE4\x4A\x8B\x29\x1A\x96\x4C\xF2\xF0\x70\x38", 25), 0); } - (void)testRFC6070TestVector6 { unsigned char key[25]; OFPBKDF2((OFPBKDF2Parameters){ .HMAC = _HMAC, .iterations = 4096, .salt = (unsigned char *)"sa\0lt", .saltLength = 5, .password = "pass\0word", .passwordLength = 9, .key = key, .keyLength = 16, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(key, "\x56\xFA\x6A\xA7\x55\x48\x09\x9D\xCC\x37\xD7" "\xF0\x34\x25\xE0\xC3", 16), 0); } @end |
Renamed and modified tests/OFScryptTests.m [3717bd0eab] to new_tests/OFScryptTests.m [0924135d9a].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #include "config.h" #include <string.h> | | > > > | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | * file. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFScryptTests: OTTestCase @end /* Test vectors form RFC 7914 */ static const unsigned char salsa20Input[64] = { 0x7E, 0x87, 0x9A, 0x21, 0x4F, 0x3E, 0xC9, 0x86, 0x7C, 0xA9, 0x40, 0xE6, 0x41, 0x71, 0x8F, 0x26, 0xBA, 0xEE, 0x55, 0x5B, 0x8C, 0x61, 0xC1, 0xB5, 0x0D, 0xF8, 0x46, 0x11, 0x6D, 0xCD, 0x3B, 0x1D, 0xEE, 0x24, 0xF3, 0x19, 0xDF, 0x9B, 0x3D, 0x85, 0x14, 0x12, 0x1E, 0x4B, 0x5A, 0xC5, 0xAA, 0x32, 0x76, 0x02, 0x1D, 0x29, 0x09, 0xC7, 0x48, 0x29, 0xED, 0xEB, 0xC6, 0x8D, |
︙ | ︙ | |||
129 130 131 132 133 134 135 | 0xAB, 0xE5, 0xEE, 0x98, 0x20, 0xAD, 0xAA, 0x47, 0x8E, 0x56, 0xFD, 0x8F, 0x4B, 0xA5, 0xD0, 0x9F, 0xFA, 0x1C, 0x6D, 0x92, 0x7C, 0x40, 0xF4, 0xC3, 0x37, 0x30, 0x40, 0x49, 0xE8, 0xA9, 0x52, 0xFB, 0xCB, 0xF4, 0x5C, 0x6F, 0xA7, 0x7A, 0x41, 0xA4 }; #endif | | | < < < < < | | | | | > > > > | | | | > > > > | | | | | > > > > | > > | | | > > > > | > > | | > | > > > | | > > | > | > > > | | | < < > > | 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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 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 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | 0xAB, 0xE5, 0xEE, 0x98, 0x20, 0xAD, 0xAA, 0x47, 0x8E, 0x56, 0xFD, 0x8F, 0x4B, 0xA5, 0xD0, 0x9F, 0xFA, 0x1C, 0x6D, 0x92, 0x7C, 0x40, 0xF4, 0xC3, 0x37, 0x30, 0x40, 0x49, 0xE8, 0xA9, 0x52, 0xFB, 0xCB, 0xF4, 0x5C, 0x6F, 0xA7, 0x7A, 0x41, 0xA4 }; #endif @implementation OFScryptTests - (void)testSalsa20_8Core { uint32_t salsa20Buffer[16]; memcpy(salsa20Buffer, salsa20Input, 64); OFSalsa20_8Core(salsa20Buffer); OTAssertEqual(memcmp(salsa20Buffer, salsa20Output, 64), 0); } - (void)testBlockMix { uint32_t blockMixBuffer[32]; OFScryptBlockMix(blockMixBuffer, blockMixInput.u32, 1); OTAssertEqual(memcmp(blockMixBuffer, blockMixOutput, 128), 0); } - (void)testROMix { uint32_t ROMixBuffer[32], ROMixTmp[17 * 32]; memcpy(ROMixBuffer, ROMixInput, 128); OFScryptROMix(ROMixBuffer, 1, 16, ROMixTmp); OTAssertEqual(memcmp(ROMixBuffer, ROMixOutput, 128), 0); } - (void)testRFC7941TestVector1 { unsigned char output[64]; OFScrypt((OFScryptParameters){ .blockSize = 1, .costFactor = 16, .parallelization = 1, .salt = (unsigned char *)"", .saltLength = 0, .password = "", .passwordLength = 0, .key = output, .keyLength = 64, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(output, testVector1, 64), 0); } - (void)testRFC7941TestVector2 { unsigned char output[64]; OFScrypt((OFScryptParameters){ .blockSize = 8, .costFactor = 1024, .parallelization = 16, .salt = (unsigned char *)"NaCl", .saltLength = 4, .password = "password", .passwordLength = 8, .key = output, .keyLength = 64, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(output, testVector2, 64), 0); } /* The third test vector is too expensive for m68k. */ #ifndef OF_M68K - (void)testRFC7941TestVector3 { unsigned char output[64]; OFScrypt((OFScryptParameters){ .blockSize = 8, .costFactor = 16384, .parallelization = 1, .salt = (unsigned char *)"SodiumChloride", .saltLength = 14, .password = "pleaseletmein", .passwordLength = 13, .key = output, .keyLength = 64, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(output, testVector3, 64), 0); } #endif /* The forth test vector is too expensive to include it in the tests. */ #if 0 - (void)testRFC7941TestVector4 { unsigned char output[64]; OFScrypt((OFScryptParameters){ .blockSize = 8, .costFactor = 1048576, .parallelization = 1, .salt = (unsigned char *)"SodiumChloride", .saltLength = 14, .password = "pleaseletmein", .passwordLength = 13, .key = output, .keyLength = 64, .allowsSwappableMemory = true }); OTAssertEqual(memcmp(output, testVector4, 64), 0); } #endif @end |
Modified tests/Makefile from [d5ceff4e50] to [58ce3dc37f].
︙ | ︙ | |||
37 38 39 40 41 42 43 | OFObjectTests.m \ OFRIPEMD160HashTests.m \ OFSHA1HashTests.m \ OFSHA224HashTests.m \ OFSHA256HashTests.m \ OFSHA384HashTests.m \ OFSHA512HashTests.m \ | < | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | OFObjectTests.m \ OFRIPEMD160HashTests.m \ OFSHA1HashTests.m \ OFSHA224HashTests.m \ OFSHA256HashTests.m \ OFSHA384HashTests.m \ OFSHA512HashTests.m \ OFSetTests.m \ OFStreamTests.m \ OFStringTests.m \ OFSystemInfoTests.m \ OFValueTests.m \ OFXMLElementBuilderTests.m \ OFXMLNodeTests.m \ |
︙ | ︙ |
Modified tests/TestsAppDelegate.h from [25e93e8938] to [3ea4afb148].
︙ | ︙ | |||
171 172 173 174 175 176 177 | - (void)runtimeARCTests; @end @interface TestsAppDelegate (OFRIPEMD160HashTests) - (void)RIPEMD160HashTests; @end | < < < < | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | - (void)runtimeARCTests; @end @interface TestsAppDelegate (OFRIPEMD160HashTests) - (void)RIPEMD160HashTests; @end @interface TestsAppDelegate (OFSHA1HashTests) - (void)SHA1HashTests; @end @interface TestsAppDelegate (OFSHA224HashTests) - (void)SHA224HashTests; @end |
︙ | ︙ |
Modified tests/TestsAppDelegate.m from [e4e9204b3b] to [5e0d241d80].
︙ | ︙ | |||
397 398 399 400 401 402 403 | [self RIPEMD160HashTests]; [self SHA1HashTests]; [self SHA224HashTests]; [self SHA256HashTests]; [self SHA384HashTests]; [self SHA512HashTests]; [self HMACTests]; | < | 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | [self RIPEMD160HashTests]; [self SHA1HashTests]; [self SHA224HashTests]; [self SHA256HashTests]; [self SHA384HashTests]; [self SHA512HashTests]; [self HMACTests]; #ifdef HAVE_CODEPAGE_437 [self INIFileTests]; #endif #ifdef OF_HAVE_SOCKETS [self socketTests]; [self TCPSocketTests]; [self UDPSocketTests]; |
︙ | ︙ |