From 67bfacb50cd8fbbc0b52e9ae890e106845b5a879 Mon Sep 17 00:00:00 2001 From: kramm Date: Sun, 30 Nov 2003 10:38:15 +0000 Subject: [PATCH] added password support (ST_DEBUG and ST_PROTECT tags). --- lib/rfxswf.c | 39 +++++++++++++++++++++++++++++++++++++-- lib/rfxswf.h | 7 +++++-- 2 files changed, 42 insertions(+), 4 deletions(-) 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 diff --git a/lib/rfxswf.h b/lib/rfxswf.h index d64664a..fba3f91 100644 --- a/lib/rfxswf.h +++ b/lib/rfxswf.h @@ -236,17 +236,20 @@ int swf_SetU8(TAG * t,U8 v); // resets Bitcount int swf_SetU16(TAG * t,U16 v); int swf_SetU32(TAG * t,U32 v); -int swf_GetPoint(TAG * t,SPOINT * p); // resets Bitcount +//int swf_GetPoint(TAG * t,SPOINT * p); // resets Bitcount int swf_GetRect(TAG * t,SRECT * r); int swf_GetMatrix(TAG * t,MATRIX * m); int swf_GetCXForm(TAG * t,CXFORM * cx,U8 alpha); -int swf_SetPoint(TAG * t,SPOINT * p); // resets Bitcount +//int swf_SetPoint(TAG * t,SPOINT * p); // resets Bitcount int swf_SetRect(TAG * t,SRECT * r); int swf_SetMatrix(TAG * t,MATRIX * m); int swf_SetCXForm(TAG * t,CXFORM * cx,U8 alpha); int swf_SetRGB(TAG * t,RGBA * col); int swf_SetRGBA(TAG * t,RGBA * col); +void swf_SetPassword(TAG * t, const char * password); + +int swf_VerifyPassword(TAG * t, const char * password); // helper functions: -- 1.7.10.4