summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-07-26 08:19:02 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-08-17 15:06:09 (GMT)
commitafac50e2a7bfaf70d53a8265194b5a5ca13034f8 (patch)
tree255a9b20fd99995eb6c68c46f13a26221ccae46a /src/com/isode
parentf56f245c1f7e768caf356a0e7b57f428cf8cc6da (diff)
downloadstroke-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 'src/com/isode')
-rw-r--r--src/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticator.java2
-rw-r--r--src/com/isode/stroke/stringcodecs/HMACSHA1.java51
-rw-r--r--src/com/isode/stroke/stringcodecs/SHA1.java27
-rw-r--r--src/com/isode/stroke/tls/Certificate.java1
4 files changed, 0 insertions, 81 deletions
diff --git a/src/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticator.java b/src/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticator.java
index 9797e24..1d2b4d9 100644
--- a/src/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticator.java
+++ b/src/com/isode/stroke/sasl/SCRAMSHA1ClientAuthenticator.java
@@ -12,9 +12,7 @@ import com.isode.stroke.base.ByteArray;
import com.isode.stroke.base.SafeByteArray;
import com.ibm.icu.text.StringPrepParseException;
import com.isode.stroke.stringcodecs.Base64;
-import com.isode.stroke.stringcodecs.HMACSHA1;
import com.isode.stroke.stringcodecs.PBKDF2;
-import com.isode.stroke.stringcodecs.SHA1;
import com.isode.stroke.idn.IDNConverter;
import com.isode.stroke.crypto.CryptoProvider;
import java.text.Normalizer;
diff --git a/src/com/isode/stroke/stringcodecs/HMACSHA1.java b/src/com/isode/stroke/stringcodecs/HMACSHA1.java
deleted file mode 100644
index 36f8f80..0000000
--- a/src/com/isode/stroke/stringcodecs/HMACSHA1.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2010, Isode Limited, London, England.
- * All rights reserved.
- */
-/*
- * Copyright (c) 2010, Remko Tronçon.
- * All rights reserved.
- */
-package com.isode.stroke.stringcodecs;
-
-import com.isode.stroke.base.ByteArray;
-
-public class HMACSHA1 {
-
- private static final int B = 64;
-
- public static ByteArray getResult(ByteArray key, ByteArray data) {
- assert key.getSize() <= B;
-
- /* And an assert that does something */
- if (key.getSize() > B) {
- throw new IllegalStateException("Invalid key size.");
- }
-
- // Create the padded key
- ByteArray paddedKey = new ByteArray(key);
- for (int i = key.getSize(); i < B; ++i) {
- paddedKey.append((byte) 0x0);
- }
-
- // Create the first value
- ByteArray x = new ByteArray(paddedKey);
- byte[] xInner = x.getData();
- for (int i = 0; i < xInner.length; ++i) {
- xInner[i] ^= 0x36;
- }
- x = new ByteArray(xInner);
- x.append(data);
-
- // Create the second value
- ByteArray y = new ByteArray(paddedKey);
- byte[] yInner = y.getData();
- for (int i = 0; i < yInner.length; ++i) {
- yInner[i] ^= 0x5c;
- }
- y = new ByteArray(yInner);
- y.append(SHA1.getHash(x));
-
- return SHA1.getHash(y);
- }
-}
diff --git a/src/com/isode/stroke/stringcodecs/SHA1.java b/src/com/isode/stroke/stringcodecs/SHA1.java
deleted file mode 100644
index 9beb650..0000000
--- a/src/com/isode/stroke/stringcodecs/SHA1.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2010, Isode Limited, London, England.
- * All rights reserved.
- */
-/*
- * Copyright (c) 2010, Remko Tronçon.
- * All rights reserved.
- */
-package com.isode.stroke.stringcodecs;
-
-import com.isode.stroke.base.ByteArray;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-public class SHA1 {
-
- public static ByteArray getHash(ByteArray data) {
- MessageDigest md;
- try {
- md = MessageDigest.getInstance("SHA-1");
- } catch (NoSuchAlgorithmException ex) {
- throw new IllegalStateException("JRE doesn't have an SHA hash function", ex);
- }
- md.update(data.getData());
- return new ByteArray(md.digest());
- }
-}
diff --git a/src/com/isode/stroke/tls/Certificate.java b/src/com/isode/stroke/tls/Certificate.java
index fdd64c0..3bed6d8 100644
--- a/src/com/isode/stroke/tls/Certificate.java
+++ b/src/com/isode/stroke/tls/Certificate.java
@@ -11,7 +11,6 @@ package com.isode.stroke.tls;
import com.isode.stroke.base.ByteArray;
import com.isode.stroke.crypto.CryptoProvider;
import com.isode.stroke.stringcodecs.Hexify;
-import com.isode.stroke.stringcodecs.SHA1;
import java.util.List;
public abstract class Certificate {