00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include <cc++/common.h>
00041
00042 #ifdef CCXX_NAMESPACES
00043 using namespace std;
00044 using namespace ost;
00045 #endif
00046
00047
00048 int main(int argc, char *argv[])
00049 {
00050 unsigned char test[44];
00051 unsigned char buf[4];
00052 uint32 crc;
00053 int i;
00054
00055 cout << "CRC32 Algorithm Test\n\n";
00056
00057 cout << "AAL-5 Test #1 - 40 Octets filled with \"0\" - ";
00058 cout << "CRC32 = 0x864d7f99\n";
00059
00060 for (i = 0; i < 40; i++)
00061 test[i] = 0x0;
00062 test[40] = test[41] = test[42] = 0x0;
00063 test[43] = 0x28;
00064
00065 CRC32Digest crc1;
00066 crc1.putDigest(test, 44);
00067 crc1.getDigest(buf);
00068 crc = *(uint32 *)buf;
00069 cout << "Test #1 CRC32 = " << hex << crc << "\n\n";
00070 if (crc == 0x864d7f99)
00071 cout << "Test #1 PASSED\n\n\n";
00072 else
00073 cout << "Test #1 FAILED\n\n\n";
00074
00075
00076 cout << "AAL-5 Test #2 - 40 Octets filled with \"1\" - ";
00077 cout << "CRC32 = 0xc55e457a\n";
00078
00079 for (i = 0; i < 40; i++)
00080 test[i] = 0xFF;
00081 test[40] = test[41] = test[42] = 0x0;
00082 test[43] = 0x28;
00083
00084 CRC32Digest crc2;
00085 crc2.putDigest(test, 44);
00086 crc2.getDigest(buf);
00087 crc = *(uint32 *)buf;
00088 cout << "Test #2 CRC32 = " << hex << crc << "\n\n";
00089 if (crc == 0xc55e457a)
00090 cout << "Test #2 PASSED\n\n\n";
00091 else
00092 cout << "Test #2 FAILED\n\n\n";
00093
00094 cout << "AAL-5 Test #3 - 40 Octets counting 1 to 40 - ";
00095 cout << "CRC32 = 0xbf671ed0\n";
00096
00097 for (i = 0; i < 40; i++)
00098 test[i] = i+1;
00099 test[40] = test[41] = test[42] = 0x0;
00100 test[43] = 0x28;
00101
00102 CRC32Digest crc3;
00103 crc3.putDigest(test, 44);
00104 crc3.getDigest(buf);
00105 crc = *(uint32 *)buf;
00106 cout << "Test #3 CRC32 = " << hex << crc << "\n\n";
00107 if (crc == 0xbf671ed0)
00108 cout << "Test #3 PASSED\n\n\n";
00109 else
00110 cout << "Test #3 FAILED\n\n\n";
00111
00112 }