Mercurial > urweb
diff src/c/urweb.c @ 734:f2a2be93331c
Cookie signing working for forms
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 16 Apr 2009 19:12:12 -0400 |
parents | 9864b64b1700 |
children | 796e42c93c48 |
line wrap: on
line diff
--- a/src/c/urweb.c Thu Apr 16 15:38:01 2009 -0400 +++ b/src/c/urweb.c Thu Apr 16 19:12:12 2009 -0400 @@ -1981,3 +1981,25 @@ uw_Basis_string uw_Basis_bless(uw_context ctx, uw_Basis_string s) { return s; } + +uw_Basis_string uw_unnull(uw_Basis_string s) { + return s ? s : ""; +} + +extern int uw_hash_blocksize; + +uw_Basis_string uw_Basis_makeSigString(uw_context ctx, uw_Basis_string sig) { + uw_Basis_string r = uw_malloc(ctx, 2 * uw_hash_blocksize + 1); + int i; + + for (i = 0; i < uw_hash_blocksize; ++i) + sprintf(&r[2*i], "%.02X", ((unsigned char *)sig)[i]); + + return r; +} + +extern uw_Basis_string uw_cookie_sig(uw_context); + +uw_Basis_string uw_Basis_sigString(uw_context ctx, uw_unit u) { + return uw_cookie_sig(ctx); +}