ObjFW  Diff

Differences From Artifact [f9dfdefc9d]:

To Artifact [970ef4d90d]:

  • File tests/ScryptTests.m — part of check-in [e629dc83a9] at 2019-12-27 00:41:54 on branch trunk — OFSecureData: Add allowsSwappableMemory property

    With this property, it's possible to specify whether the memory should
    be protected from swapping or not. This makes it easier for e.g. the
    crypto hash classes: They can now just always use OFSecureData without
    wasting unswappable memory if it's not needed. (user: js, size: 8415) [annotate] [blame] [check-ins using]


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

	TEST(@"ROMix",
	    R(memcpy(ROMixBuffer, ROMixInput, 128)) &&
	    R(of_scrypt_romix(ROMixBuffer, 1, 16, ROMixTmp)) &&
	    memcmp(ROMixBuffer, ROMixOutput, 128) == 0)

	TEST(@"scrypt test vector #1",
	    R(of_scrypt(1, 16, 1, (unsigned char *)"", 0, "", 0, output, 64)) &&
	    memcmp(output, testVector1, 64) == 0)

	TEST(@"scrypt test vector #2",
	    R(of_scrypt(8, 1024, 16, (unsigned char *)"NaCl", 4, "password", 8,
	    output, 64)) && memcmp(output, testVector2, 64) == 0)

	TEST(@"scrypt test vector #3",
	    R(of_scrypt(8, 16384, 1, (unsigned char *)"SodiumChloride", 14,
	    "pleaseletmein", 13, output, 64)) &&
	    memcmp(output, testVector3, 64) == 0)

	/* The forth test vector is too expensive to include it in the tests. */
#if 0
	TEST(@"scrypt test vector #4",
	    R(of_scrypt(8, 1048576, 1, (unsigned char *)"SodiumChloride", 14,
	    "pleaseletmein", 13, output, 64)) &&
	    memcmp(output, testVector4, 64) == 0)
#endif

	objc_autoreleasePoolPop(pool);
}
@end







|
|



|



|






|






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

	TEST(@"ROMix",
	    R(memcpy(ROMixBuffer, ROMixInput, 128)) &&
	    R(of_scrypt_romix(ROMixBuffer, 1, 16, ROMixTmp)) &&
	    memcmp(ROMixBuffer, ROMixOutput, 128) == 0)

	TEST(@"scrypt test vector #1",
	    R(of_scrypt(1, 16, 1, (unsigned char *)"", 0, "", 0, output, 64,
	    true)) && memcmp(output, testVector1, 64) == 0)

	TEST(@"scrypt test vector #2",
	    R(of_scrypt(8, 1024, 16, (unsigned char *)"NaCl", 4, "password", 8,
	    output, 64, true)) && memcmp(output, testVector2, 64) == 0)

	TEST(@"scrypt test vector #3",
	    R(of_scrypt(8, 16384, 1, (unsigned char *)"SodiumChloride", 14,
	    "pleaseletmein", 13, output, 64, true)) &&
	    memcmp(output, testVector3, 64) == 0)

	/* The forth test vector is too expensive to include it in the tests. */
#if 0
	TEST(@"scrypt test vector #4",
	    R(of_scrypt(8, 1048576, 1, (unsigned char *)"SodiumChloride", 14,
	    "pleaseletmein", 13, output, 64, true)) &&
	    memcmp(output, testVector4, 64) == 0)
#endif

	objc_autoreleasePoolPop(pool);
}
@end