summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-05-03 20:39:27 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-05-05 19:43:14 (GMT)
commit772b2ec0243d7b55d91e4027d828881d18093ed0 (patch)
tree83a58b2b97f3992165ee20c05e0630452eb50457 /Swiften/StringCodecs
parent0b3db8fd68abee7269d5a38aabd8a816e099eae5 (diff)
downloadswift-772b2ec0243d7b55d91e4027d828881d18093ed0.zip
swift-772b2ec0243d7b55d91e4027d828881d18093ed0.tar.bz2
Replace ByteArray by typedef.
Diffstat (limited to 'Swiften/StringCodecs')
-rw-r--r--Swiften/StringCodecs/Base64.cpp2
-rw-r--r--Swiften/StringCodecs/HMACSHA1.cpp19
-rw-r--r--Swiften/StringCodecs/HMACSHA1.h4
-rw-r--r--Swiften/StringCodecs/Hexify.cpp2
-rw-r--r--Swiften/StringCodecs/Hexify.h5
-rw-r--r--Swiften/StringCodecs/MD5.cpp5
-rw-r--r--Swiften/StringCodecs/MD5.h4
-rw-r--r--Swiften/StringCodecs/PBKDF2.cpp7
-rw-r--r--Swiften/StringCodecs/SHA1.cpp10
-rw-r--r--Swiften/StringCodecs/UnitTest/Base64Test.cpp7
-rw-r--r--Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp5
-rw-r--r--Swiften/StringCodecs/UnitTest/HexifyTest.cpp2
-rw-r--r--Swiften/StringCodecs/UnitTest/MD5Test.cpp9
-rw-r--r--Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp13
-rw-r--r--Swiften/StringCodecs/UnitTest/SHA1Test.cpp33
15 files changed, 66 insertions, 61 deletions
diff --git a/Swiften/StringCodecs/Base64.cpp b/Swiften/StringCodecs/Base64.cpp
index a77fc93..4ec2e16 100644
--- a/Swiften/StringCodecs/Base64.cpp
+++ b/Swiften/StringCodecs/Base64.cpp
@@ -17,7 +17,7 @@ namespace Swift {
std::string Base64::encode(const ByteArray &s) {
int i;
- int len = s.getSize();
+ int len = s.size();
char tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
int a, b, c;
diff --git a/Swiften/StringCodecs/HMACSHA1.cpp b/Swiften/StringCodecs/HMACSHA1.cpp
index 6f88d68..e583e3b 100644
--- a/Swiften/StringCodecs/HMACSHA1.cpp
+++ b/Swiften/StringCodecs/HMACSHA1.cpp
@@ -10,13 +10,14 @@
#include <Swiften/StringCodecs/SHA1.h>
#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/Algorithm.h>
namespace Swift {
static const unsigned int B = 64;
ByteArray HMACSHA1::getResult(const ByteArray& key, const ByteArray& data) {
- assert(key.getSize() <= B);
+ assert(key.size() <= B);
// Create the padded key
ByteArray paddedKey(key);
@@ -24,17 +25,17 @@ ByteArray HMACSHA1::getResult(const ByteArray& key, const ByteArray& data) {
// Create the first value
ByteArray x(paddedKey);
- for (unsigned int i = 0; i < x.getSize(); ++i) {
+ for (unsigned int i = 0; i < x.size(); ++i) {
x[i] ^= 0x36;
}
- x += data;
+ append(x, data);
// Create the second value
ByteArray y(paddedKey);
- for (unsigned int i = 0; i < y.getSize(); ++i) {
+ for (unsigned int i = 0; i < y.size(); ++i) {
y[i] ^= 0x5c;
}
- y += SHA1::getHash(x);
+ append(y, SHA1::getHash(x));
return SHA1::getHash(y);
}
@@ -53,19 +54,19 @@ ByteArray HMACSHA1::getResult(const ByteArray& key, const ByteArray& data) {
void HMACSHA1::getResult(const ByteArray& key, const ByteArray& data, ByteArray& result) {
// Create first value
- size_t xSize = B + data.getSize();
+ size_t xSize = B + data.size();
unsigned char* x = (unsigned char*) malloc(xSize * sizeof(unsigned char));
memset(x, 0, B);
- memcpy(x, key.getData(), key.getSize());
+ memcpy(x, key.getData(), key.size());
for (unsigned int i = 0; i < (B>>32); ++i) {
x[i<<32] ^= 0x36363636;
}
- memcpy(x + B, data.getData(), data.getSize());
+ memcpy(x + B, data.getData(), data.size());
// Create the second value
unsigned char y[B + 20];
memset(y, 0, B);
- memcpy(y, key.getData(), key.getSize());
+ memcpy(y, key.getData(), key.size());
for (unsigned int i = 0; i < (B>>32); ++i) {
y[i<<32] ^= 0x5c5c5c5c;
}
diff --git a/Swiften/StringCodecs/HMACSHA1.h b/Swiften/StringCodecs/HMACSHA1.h
index cc6cb04..39c6e4e 100644
--- a/Swiften/StringCodecs/HMACSHA1.h
+++ b/Swiften/StringCodecs/HMACSHA1.h
@@ -6,9 +6,9 @@
#pragma once
-namespace Swift {
- class ByteArray;
+#include <Swiften/Base/ByteArray.h>
+namespace Swift {
class HMACSHA1 {
public:
static ByteArray getResult(const ByteArray& key, const ByteArray& data);
diff --git a/Swiften/StringCodecs/Hexify.cpp b/Swiften/StringCodecs/Hexify.cpp
index 05b7d66..367743c 100644
--- a/Swiften/StringCodecs/Hexify.cpp
+++ b/Swiften/StringCodecs/Hexify.cpp
@@ -25,7 +25,7 @@ std::string Hexify::hexify(const ByteArray& data) {
std::ostringstream result;
result << std::hex;
- for (unsigned int i = 0; i < data.getSize(); ++i) {
+ for (unsigned int i = 0; i < data.size(); ++i) {
result << std::setw(2) << std::setfill('0') << boost::numeric_cast<unsigned int>(static_cast<unsigned char>(data[i]));
}
return std::string(result.str());
diff --git a/Swiften/StringCodecs/Hexify.h b/Swiften/StringCodecs/Hexify.h
index f85db15..9815e21 100644
--- a/Swiften/StringCodecs/Hexify.h
+++ b/Swiften/StringCodecs/Hexify.h
@@ -6,12 +6,9 @@
#pragma once
-#include <string>
+#include <Swiften/Base/ByteArray.h>
namespace Swift {
-
- class ByteArray;
-
class Hexify {
public:
static std::string hexify(unsigned char byte);
diff --git a/Swiften/StringCodecs/MD5.cpp b/Swiften/StringCodecs/MD5.cpp
index 07dcd8b..9e69172 100644
--- a/Swiften/StringCodecs/MD5.cpp
+++ b/Swiften/StringCodecs/MD5.cpp
@@ -36,6 +36,7 @@
#include <Swiften/StringCodecs/MD5.h>
#include <cassert>
+#include <string.h>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Base/Platform.h>
@@ -356,8 +357,8 @@ ByteArray MD5::getHash(const ByteArray& data) {
md5_state_t state;
md5_init(&state);
- md5_append(&state, reinterpret_cast<const md5_byte_t*>(data.getData()), data.getSize());
- md5_finish(&state, reinterpret_cast<md5_byte_t*>(digest.getData()));
+ md5_append(&state, reinterpret_cast<const md5_byte_t*>(vecptr(data)), data.size());
+ md5_finish(&state, reinterpret_cast<md5_byte_t*>(vecptr(digest)));
return digest;
}
diff --git a/Swiften/StringCodecs/MD5.h b/Swiften/StringCodecs/MD5.h
index b896529..93c48e9 100644
--- a/Swiften/StringCodecs/MD5.h
+++ b/Swiften/StringCodecs/MD5.h
@@ -6,9 +6,9 @@
#pragma once
-namespace Swift {
- class ByteArray;
+#include <Swiften/Base/ByteArray.h>
+namespace Swift {
class MD5 {
public:
static ByteArray getHash(const ByteArray& data);
diff --git a/Swiften/StringCodecs/PBKDF2.cpp b/Swiften/StringCodecs/PBKDF2.cpp
index f5b6126..c4a5a7f 100644
--- a/Swiften/StringCodecs/PBKDF2.cpp
+++ b/Swiften/StringCodecs/PBKDF2.cpp
@@ -6,16 +6,17 @@
#include <Swiften/StringCodecs/PBKDF2.h>
#include <Swiften/StringCodecs/HMACSHA1.h>
+#include <Swiften/Base/Concat.h>
namespace Swift {
ByteArray PBKDF2::encode(const ByteArray& password, const ByteArray& salt, int iterations) {
- ByteArray u = HMACSHA1::getResult(password, salt + ByteArray("\0\0\0\1", 4));
- ByteArray result = u;
+ ByteArray u = HMACSHA1::getResult(password, concat(salt, createByteArray("\0\0\0\1", 4)));
+ ByteArray result(u);
int i = 1;
while (i < iterations) {
u = HMACSHA1::getResult(password, u);
- for (unsigned int j = 0; j < u.getSize(); ++j) {
+ for (unsigned int j = 0; j < u.size(); ++j) {
result[j] ^= u[j];
}
++i;
diff --git a/Swiften/StringCodecs/SHA1.cpp b/Swiften/StringCodecs/SHA1.cpp
index eb667a8..5001fb2 100644
--- a/Swiften/StringCodecs/SHA1.cpp
+++ b/Swiften/StringCodecs/SHA1.cpp
@@ -185,7 +185,7 @@ SHA1::SHA1() {
SHA1& SHA1::update(const std::vector<unsigned char>& input) {
std::vector<unsigned char> inputCopy(input);
- Update(&context, (boost::uint8_t*) ByteArray::data(inputCopy), inputCopy.size());
+ Update(&context, (boost::uint8_t*) vecptr(inputCopy), inputCopy.size());
return *this;
}
@@ -193,7 +193,7 @@ std::vector<unsigned char> SHA1::getHash() const {
std::vector<unsigned char> digest;
digest.resize(20);
CTX contextCopy(context);
- Final((boost::uint8_t*) ByteArray::data(digest), &contextCopy);
+ Final((boost::uint8_t*) vecptr(digest), &contextCopy);
return digest;
}
@@ -201,12 +201,12 @@ ByteArray SHA1::getHash(const ByteArray& input) {
CTX context;
Init(&context);
- std::vector<unsigned char> inputCopy(input.getVector());
- Update(&context, (boost::uint8_t*) ByteArray::data(inputCopy), inputCopy.size());
+ std::vector<unsigned char> inputCopy(input);
+ Update(&context, (boost::uint8_t*) vecptr(inputCopy), inputCopy.size());
ByteArray digest;
digest.resize(20);
- Final((boost::uint8_t*) digest.getData(), &context);
+ Final((boost::uint8_t*) vecptr(digest), &context);
return digest;
}
diff --git a/Swiften/StringCodecs/UnitTest/Base64Test.cpp b/Swiften/StringCodecs/UnitTest/Base64Test.cpp
index 211e684..d1ad5d7 100644
--- a/Swiften/StringCodecs/UnitTest/Base64Test.cpp
+++ b/Swiften/StringCodecs/UnitTest/Base64Test.cpp
@@ -9,6 +9,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <QA/Checker/IO.h>
#include <Swiften/StringCodecs/Base64.h>
using namespace Swift;
@@ -24,12 +25,12 @@ class Base64Test : public CppUnit::TestFixture {
public:
void testEncode() {
- std::string result(Base64::encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"));
+ std::string result(Base64::encode(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890")));
CPPUNIT_ASSERT_EQUAL(std::string("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejEyMzQ1Njc4OTA="), result);
}
void testEncode_NonAscii() {
- std::string result(Base64::encode(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed")));
+ std::string result(Base64::encode(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed")));
CPPUNIT_ASSERT_EQUAL(std::string("QgayPKawpkPSDYmwT/WM94uAlu0="), result);
}
@@ -40,7 +41,7 @@ class Base64Test : public CppUnit::TestFixture {
void testDecode() {
ByteArray result(Base64::decode("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejEyMzQ1Njc4OTA="));
- CPPUNIT_ASSERT_EQUAL(ByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), result);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), result);
}
void testDecode_NoData() {
diff --git a/Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp b/Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp
index 600765a..efb613f 100644
--- a/Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp
+++ b/Swiften/StringCodecs/UnitTest/HMACSHA1Test.cpp
@@ -9,6 +9,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <QA/Checker/IO.h>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/StringCodecs/HMACSHA1.h>
@@ -21,8 +22,8 @@ class HMACSHA1Test : public CppUnit::TestFixture {
public:
void testGetResult() {
- ByteArray result(HMACSHA1::getResult("foo", "foobar"));
- CPPUNIT_ASSERT_EQUAL(ByteArray("\xa4\xee\xba\x8e\x63\x3d\x77\x88\x69\xf5\x68\xd0\x5a\x1b\x3d\xc7\x2b\xfd\x4\xdd"), result);
+ ByteArray result(HMACSHA1::getResult(createByteArray("foo"), createByteArray("foobar")));
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xa4\xee\xba\x8e\x63\x3d\x77\x88\x69\xf5\x68\xd0\x5a\x1b\x3d\xc7\x2b\xfd\x4\xdd"), result);
}
};
diff --git a/Swiften/StringCodecs/UnitTest/HexifyTest.cpp b/Swiften/StringCodecs/UnitTest/HexifyTest.cpp
index 9643d00..9cbd0d4 100644
--- a/Swiften/StringCodecs/UnitTest/HexifyTest.cpp
+++ b/Swiften/StringCodecs/UnitTest/HexifyTest.cpp
@@ -21,7 +21,7 @@ class HexifyTest : public CppUnit::TestFixture {
public:
void testHexify() {
- CPPUNIT_ASSERT_EQUAL(std::string("4206b23ca6b0a643d20d89b04ff58cf78b8096ed"), Hexify::hexify(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed")));
+ CPPUNIT_ASSERT_EQUAL(std::string("4206b23ca6b0a643d20d89b04ff58cf78b8096ed"), Hexify::hexify(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed")));
}
void testHexify_Byte() {
diff --git a/Swiften/StringCodecs/UnitTest/MD5Test.cpp b/Swiften/StringCodecs/UnitTest/MD5Test.cpp
index 3f764d2..c66d422 100644
--- a/Swiften/StringCodecs/UnitTest/MD5Test.cpp
+++ b/Swiften/StringCodecs/UnitTest/MD5Test.cpp
@@ -9,6 +9,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <QA/Checker/IO.h>
#include <Swiften/StringCodecs/MD5.h>
#include <Swiften/Base/ByteArray.h>
@@ -22,15 +23,15 @@ class MD5Test : public CppUnit::TestFixture {
public:
void testGetHash_Empty() {
- ByteArray result(MD5::getHash(""));
+ ByteArray result(MD5::getHash(createByteArray("")));
- CPPUNIT_ASSERT_EQUAL(ByteArray("\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e", 16), result);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e", 16), result);
}
void testGetHash_Alphabet() {
- ByteArray result(MD5::getHash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"));
+ ByteArray result(MD5::getHash(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")));
- CPPUNIT_ASSERT_EQUAL(ByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f", 16), result);
}
};
diff --git a/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp b/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp
index 7952471..ae55ac8 100644
--- a/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp
+++ b/Swiften/StringCodecs/UnitTest/PBKDF2Test.cpp
@@ -9,6 +9,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <QA/Checker/IO.h>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/StringCodecs/PBKDF2.h>
@@ -23,21 +24,21 @@ class PBKDF2Test : public CppUnit::TestFixture {
public:
void testGetResult_I1() {
- ByteArray result(PBKDF2::encode("password", "salt", 1));
+ ByteArray result(PBKDF2::encode(createByteArray("password"), createByteArray("salt"), 1));
- CPPUNIT_ASSERT_EQUAL(ByteArray("\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6"), result);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6"), result);
}
void testGetResult_I2() {
- ByteArray result(PBKDF2::encode("password", "salt", 2));
+ ByteArray result(PBKDF2::encode(createByteArray("password"), createByteArray("salt"), 2));
- CPPUNIT_ASSERT_EQUAL(ByteArray("\xea\x6c\x1\x4d\xc7\x2d\x6f\x8c\xcd\x1e\xd9\x2a\xce\x1d\x41\xf0\xd8\xde\x89\x57"), result);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xea\x6c\x1\x4d\xc7\x2d\x6f\x8c\xcd\x1e\xd9\x2a\xce\x1d\x41\xf0\xd8\xde\x89\x57"), result);
}
void testGetResult_I4096() {
- ByteArray result(PBKDF2::encode("password", "salt", 4096));
+ ByteArray result(PBKDF2::encode(createByteArray("password"), createByteArray("salt"), 4096));
- CPPUNIT_ASSERT_EQUAL(ByteArray("\x4b\x00\x79\x1\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26\xf7\x21\xd0\x65\xa4\x29\xc1", 20), result);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x4b\x00\x79\x1\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26\xf7\x21\xd0\x65\xa4\x29\xc1", 20), result);
}
};
diff --git a/Swiften/StringCodecs/UnitTest/SHA1Test.cpp b/Swiften/StringCodecs/UnitTest/SHA1Test.cpp
index 76b71f9..004b646 100644
--- a/Swiften/StringCodecs/UnitTest/SHA1Test.cpp
+++ b/Swiften/StringCodecs/UnitTest/SHA1Test.cpp
@@ -9,6 +9,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <QA/Checker/IO.h>
#include <Swiften/StringCodecs/SHA1.h>
using namespace Swift;
@@ -28,36 +29,36 @@ class SHA1Test : public CppUnit::TestFixture {
public:
void testGetHash() {
SHA1 sha;
- sha.update(ByteArray::create("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
+ sha.update(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
- CPPUNIT_ASSERT_EQUAL(ByteArray::create("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha.getHash());
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha.getHash());
}
void testGetHash_TwoUpdates() {
SHA1 sha;
- sha.update(ByteArray::create("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<"));
- sha.update(ByteArray::create("http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
+ sha.update(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<"));
+ sha.update(createByteArray("http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
- CPPUNIT_ASSERT_EQUAL(ByteArray::create("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha.getHash());
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha.getHash());
}
void testGetHash_TwoGetHash() {
SHA1 sha;
- sha.update(ByteArray::create("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
+ sha.update(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
sha.getHash();
- CPPUNIT_ASSERT_EQUAL(ByteArray::create("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha.getHash());
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha.getHash());
}
void testGetHash_InterleavedUpdate() {
SHA1 sha;
- sha.update(ByteArray::create("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<"));
+ sha.update(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<"));
sha.getHash();
- sha.update(ByteArray::create("http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
+ sha.update(createByteArray("http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
- CPPUNIT_ASSERT_EQUAL(ByteArray::create("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha.getHash());
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), sha.getHash());
}
@@ -65,27 +66,27 @@ class SHA1Test : public CppUnit::TestFixture {
SHA1 sha;
sha.update(std::vector<unsigned char>());
- CPPUNIT_ASSERT_EQUAL(ByteArray::create("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), sha.getHash());
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), sha.getHash());
}
void testGetHashStatic() {
- ByteArray result(SHA1::getHash("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
- CPPUNIT_ASSERT_EQUAL(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result);
+ ByteArray result(SHA1::getHash(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<")));
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result);
}
void testGetHashStatic_Twice() {
- ByteArray input("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<");
+ ByteArray input(createByteArray("client/pc//Exodus 0.9.1<http://jabber.org/protocol/caps<http://jabber.org/protocol/disco#info<http://jabber.org/protocol/disco#items<http://jabber.org/protocol/muc<"));
SHA1::getHash(input);
ByteArray result(SHA1::getHash(input));
- CPPUNIT_ASSERT_EQUAL(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed"), result);
}
void testGetHashStatic_NoData() {
ByteArray result(SHA1::getHash(ByteArray()));
- CPPUNIT_ASSERT_EQUAL(ByteArray("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), result);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09"), result);
}
};