added password support (ST_DEBUG and ST_PROTECT tags).
authorkramm <kramm>
Sun, 30 Nov 2003 10:38:15 +0000 (10:38 +0000)
committerkramm <kramm>
Sun, 30 Nov 2003 10:38:15 +0000 (10:38 +0000)
lib/rfxswf.c
lib/rfxswf.h

index c7d2df0..a3486e6 100644 (file)
@@ -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
 
index d64664a..fba3f91 100644 (file)
@@ -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: