|
reSIProcate/rutil
9694
|
00001 #ifdef HAVE_CONFIG_H 00002 #include "config.h" 00003 #endif 00004 00005 #include <assert.h> 00006 00007 #ifdef USE_SSL 00008 #include "rutil/ssl/SHA1Stream.hxx" 00009 00010 using namespace resip; 00011 using namespace std; 00012 #endif 00013 00014 00015 int 00016 main(void) 00017 { 00018 #ifdef USE_SSL 00019 00020 { 00021 SHA1Stream str; 00022 assert(str.getHex() == "da39a3ee5e6b4b0d3255bfef95601890afd80709"); 00023 } 00024 00025 { 00026 Data input("sip:alice@atlanta.example.com" 00027 ":a84b4c76e66710" 00028 ":314159 INVITE" 00029 ":Thu, 21 Feb 2002 13:02:03 GMT" 00030 ":sip:alice@pc33.atlanta.example.com" 00031 ":v=0\r\n" 00032 "o=UserA 2890844526 2890844526 IN IP4 pc33.atlanta.example.com\r\n" 00033 "s=Session SDP\r\n" 00034 "c=IN IP4 pc33.atlanta.example.com\r\n" 00035 "t=0 0\r\n" 00036 "m=audio 49172 RTP/AVP 0\r\n" 00037 "a=rtpmap:0 PCMU/8000\r\n"); 00038 { 00039 00040 SHA1Stream str; 00041 str << input; 00042 00043 assert(str.getHex() == "f2eec616bd43c75fd1cd300691e57301b52b3ad3"); 00044 } 00045 { 00046 SHA1Stream str; 00047 str << input; 00048 assert(str.getBin(32).size() == 4); 00049 } 00050 { 00051 SHA1Stream str; 00052 str << input; 00053 assert(str.getBin().size() == 20); 00054 } 00055 { 00056 SHA1Stream str; 00057 str << input; 00058 assert(str.getBin(128).size() == 16); 00059 } 00060 00061 Data a; 00062 Data b; 00063 { 00064 SHA1Stream str; 00065 str << input; 00066 a = str.getBin(32); 00067 cerr << "A: " << a.hex() << endl; 00068 } 00069 { 00070 SHA1Stream str; 00071 str << input; 00072 b = str.getBin(128); 00073 cerr << "B: " << b.hex() << endl; 00074 } 00075 00076 assert(memcmp(a.c_str(), b.c_str()+12, 4) == 0); 00077 } 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 cerr << "All OK" << endl; 00089 #endif 00090 00091 return 0; 00092 }
1.7.5.1