bsod.cpp,CrashlogAutoSubmit: add active skin name to xml crashlogs. fixes #597
[enigma2.git] / lib / python / Plugins / SystemPlugins / CrashlogAutoSubmit / __init__.py
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cabaadd533e7aa080abfc4a3fed2d3f5963b28dd 100755 (executable)
@@ -0,0 +1,40 @@
+import sha\r
+\r
+def bin2long(s):\r
+       return reduce( lambda x,y:(x<<8L)+y, map(ord, s))\r
+\r
+def long2bin(l):\r
+       res = ""\r
+       for byte in range(128):\r
+               res += chr((l >> (1024 - (byte + 1) * 8)) & 0xff)\r
+       return res\r
+\r
+def rsa_pub1024(src, mod):\r
+       return long2bin(pow(bin2long(src), 65537, bin2long(mod)))\r
+       \r
+def decrypt_block(src, mod):\r
+       if len(src) != 128 and len(src) != 202:\r
+               return None\r
+       dest = rsa_pub1024(src[:128], mod)\r
+       hash = sha.new(dest[1:107])\r
+       if len(src) == 202:\r
+               hash.update(src[131:192])       \r
+       result = hash.digest()\r
+       if result == dest[107:127]:\r
+               return dest\r
+       return None\r
+\r
+def validate_cert(cert, key):\r
+       buf = decrypt_block(cert[8:], key) \r
+       if buf is None:\r
+               return None\r
+       return buf[36:107] + cert[139:196]\r
+\r
+def read_random():\r
+       try:\r
+               fd = open("/dev/urandom", "r")\r
+               buf = fd.read(8)\r
+               fd.close()\r
+               return buf\r
+       except:\r
+               return None
\ No newline at end of file