~ubuntu-branches/ubuntu/utopic/mongrel2/utopic

« back to all changes in this revision

Viewing changes to src/websocket.c

  • Committer: Package Import Robot
  • Author(s): Jan Niehusmann
  • Date: 2014-06-11 15:26:26 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20140611152626-7ixr3pdpkvjk7h92
Tags: 1.9.1-1
* Update to upstream release 1.9.1
* remove binary .swf files from source tarball
* revert certificate workaround (fixed upstream)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <websocket.h>
 
2
#include <dbg.h>
2
3
#include <polarssl/sha1.h>
3
4
 
4
5
struct tagbstring WS_REQ_METHOD = bsStatic("HYBI");
48
49
 
49
50
bstring websocket_challenge(bstring input)
50
51
{
51
 
    bstring buf=bfromcstralloc(20,"");
52
 
    bstring tmpstring=bstrcpy(input);
 
52
    bstring buf=NULL;
 
53
    bstring tmpstring=NULL;
53
54
    bstring encodedSha1=NULL;
54
55
 
55
 
    bcatcstr(tmpstring, WS_GUID);
 
56
    buf = bfromcstralloc(20,"");
 
57
    check_mem(buf);
 
58
 
 
59
    tmpstring=bstrcpy(input);
 
60
    check_mem(tmpstring);
 
61
 
 
62
    check(BSTR_OK == bcatcstr(tmpstring, WS_GUID),"Failed to allocate memory");
 
63
 
56
64
    sha1((unsigned char *)bdata(tmpstring),blength(tmpstring),(unsigned char *)bdata(buf));
57
65
    buf->slen=20;
58
66
    encodedSha1=bBase64Encode(buf);
68
76
    bdestroy(encodedSha1);
69
77
    */
70
78
    return encodedSha1;
 
79
 
 
80
error:
 
81
    bdestroy(buf);
 
82
    bdestroy(tmpstring);
 
83
    bdestroy(encodedSha1);
 
84
    return NULL;
71
85
}