diff options
| author | acid-burn <acid-burn@opendreambox.org> | 2010-10-14 13:48:59 +0200 |
|---|---|---|
| committer | acid-burn <acid-burn@opendreambox.org> | 2010-10-14 13:48:59 +0200 |
| commit | da09c99b33d21db063281ee13e5d87f6a578365e (patch) | |
| tree | ffa9698279670f3ed1c2c218d5b7aa50e2f8116b | |
| parent | 211a0c7020f0e69de917cb8ce8808799b1268c8f (diff) | |
| download | enigma2-da09c99b33d21db063281ee13e5d87f6a578365e.tar.gz enigma2-da09c99b33d21db063281ee13e5d87f6a578365e.zip | |
fix line endings. refs #597
| -rwxr-xr-x | lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/__init__.py | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/__init__.py b/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/__init__.py index cabaadd5..7933e4cd 100755 --- a/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/__init__.py +++ b/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/__init__.py @@ -1,40 +1,40 @@ -import sha
-
-def bin2long(s):
- return reduce( lambda x,y:(x<<8L)+y, map(ord, s))
-
-def long2bin(l):
- res = ""
- for byte in range(128):
- res += chr((l >> (1024 - (byte + 1) * 8)) & 0xff)
- return res
-
-def rsa_pub1024(src, mod):
- return long2bin(pow(bin2long(src), 65537, bin2long(mod)))
-
-def decrypt_block(src, mod):
- if len(src) != 128 and len(src) != 202:
- return None
- dest = rsa_pub1024(src[:128], mod)
- hash = sha.new(dest[1:107])
- if len(src) == 202:
- hash.update(src[131:192])
- result = hash.digest()
- if result == dest[107:127]:
- return dest
- return None
-
-def validate_cert(cert, key):
- buf = decrypt_block(cert[8:], key)
- if buf is None:
- return None
- return buf[36:107] + cert[139:196]
-
-def read_random():
- try:
- fd = open("/dev/urandom", "r")
- buf = fd.read(8)
- fd.close()
- return buf
- except:
+import sha + +def bin2long(s): + return reduce( lambda x,y:(x<<8L)+y, map(ord, s)) + +def long2bin(l): + res = "" + for byte in range(128): + res += chr((l >> (1024 - (byte + 1) * 8)) & 0xff) + return res + +def rsa_pub1024(src, mod): + return long2bin(pow(bin2long(src), 65537, bin2long(mod))) + +def decrypt_block(src, mod): + if len(src) != 128 and len(src) != 202: + return None + dest = rsa_pub1024(src[:128], mod) + hash = sha.new(dest[1:107]) + if len(src) == 202: + hash.update(src[131:192]) + result = hash.digest() + if result == dest[107:127]: + return dest + return None + +def validate_cert(cert, key): + buf = decrypt_block(cert[8:], key) + if buf is None: + return None + return buf[36:107] + cert[139:196] + +def read_random(): + try: + fd = open("/dev/urandom", "r") + buf = fd.read(8) + fd.close() + return buf + except: return None
\ No newline at end of file |
