X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Frfxswf.c;h=a3486e6cc81abc396ae48f17d624dbed68d1fd5a;hp=c7d2df0e7bc92848b6e0547823070c45217f1bc3;hb=67bfacb50cd8fbbc0b52e9ae890e106845b5a879;hpb=cc13d1100afd10afff98bcbd85af571d94e95d86 diff --git a/lib/rfxswf.c b/lib/rfxswf.c index c7d2df0..a3486e6 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -39,6 +39,7 @@ #include "lame/lame.h" #include "./bitio.h" +#include "./MD5.h" // internal constants @@ -625,8 +626,42 @@ int swf_SetCXForm(TAG * t,CXFORM * cx,U8 alpha) return 0; } -int swf_GetPoint(TAG * t,SPOINT * p) { return 0; } -int swf_SetPoint(TAG * t,SPOINT * p) { return 0; } +//int swf_GetPoint(TAG * t,SPOINT * p) { return 0; } +//int swf_SetPoint(TAG * t,SPOINT * p) { return 0; } + +void swf_SetPassword(TAG * t, const char * password) +{ + /* WARNING: crypt_md5 is not reentrant */ + char* md5string = crypt_md5(password, "salt"); /* FIXME- get random salt */ + swf_SetString(t, md5string); +} + +int swf_VerifyPassword(TAG * t, const char * password) +{ + char*md5string1, *md5string2; + char*x; + char*md5, *salt; + int n; + + md5string1 = swf_GetString(t); + + if(!strncmp(md5string1, "$1$",3 )) { + return 0; + } + x = strchr(md5string1+3, '$'); + if(!x) + return 0; + n = x-(md5string1+3); + salt = (char*)malloc(n+1); + memcpy(salt, md5string1+3, n); + salt[n] = 0; + + md5string2 = crypt_md5(password, salt); + free(salt); + if(strcmp(md5string1, md5string2) != 0) + return 0; + return 1; +} // Tag List Manipulating Functions