diff options
author | Tarun Gupta <tarun1995gupta@gmail.com> | 2015-07-26 08:19:02 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2015-08-17 15:06:09 (GMT) |
commit | afac50e2a7bfaf70d53a8265194b5a5ca13034f8 (patch) | |
tree | 255a9b20fd99995eb6c68c46f13a26221ccae46a /test/com/isode/stroke/stringcodecs/PBKDF2Test.java | |
parent | f56f245c1f7e768caf356a0e7b57f428cf8cc6da (diff) | |
download | stroke-afac50e2a7bfaf70d53a8265194b5a5ca13034f8.zip stroke-afac50e2a7bfaf70d53a8265194b5a5ca13034f8.tar.bz2 |
Remove unnecessary Crypto functions from StringCodecs.
Remove SHA1 and HMACSHA1 from StringCodecs as they are already provided by CryptoProvider,
and is equivalent to Swiften.
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
Add tests for Base64 and PBKDF2, which passes.
Change-Id: Ife05f185a10a79c9d69a12235f1b0397d022d992
Diffstat (limited to 'test/com/isode/stroke/stringcodecs/PBKDF2Test.java')
-rw-r--r-- | test/com/isode/stroke/stringcodecs/PBKDF2Test.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/com/isode/stroke/stringcodecs/PBKDF2Test.java b/test/com/isode/stroke/stringcodecs/PBKDF2Test.java new file mode 100644 index 0000000..e76ca5e --- /dev/null +++ b/test/com/isode/stroke/stringcodecs/PBKDF2Test.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2010-2013 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ +/* + * Copyright (c) 2015 Tarun Gupta. + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +package com.isode.stroke.stringcodecs; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.junit.Before; +import com.isode.stroke.base.ByteArray; +import com.isode.stroke.base.SafeByteArray; +import com.isode.stroke.stringcodecs.PBKDF2; +import com.isode.stroke.crypto.CryptoProvider; +import com.isode.stroke.crypto.JavaCryptoProvider; + +public class PBKDF2Test { + + private CryptoProvider crypto; + + @Before + public void setUp() { + crypto = new JavaCryptoProvider(); + } + + @Test + public void testGetResult_I1() { + ByteArray result = PBKDF2.encode(new SafeByteArray("password"), new ByteArray("salt"), 1, crypto); + + assertEquals(new ByteArray("0c60c80f961f0e71f3a9b524af6012062fe037a6"), new ByteArray(Hexify.hexify(result))); + } + + @Test + public void testGetResult_I2() { + ByteArray result = PBKDF2.encode(new SafeByteArray("password"), new ByteArray("salt"), 2, crypto); + + assertEquals(new ByteArray("ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957"), new ByteArray(Hexify.hexify(result))); + } + + @Test + public void testGetResult_I4096() { + ByteArray result = PBKDF2.encode(new SafeByteArray("password"), new ByteArray("salt"), 4096, crypto); + + assertEquals(new ByteArray("4b007901b765489abead49d926f721d065a429c1"), new ByteArray(Hexify.hexify(result))); + } +} |