mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-12-02 20:26:57 -05:00
Optimize code for cryptutils.py
This commit is contained in:
parent
51d25f060e
commit
af5c37edd6
1 changed files with 4 additions and 2 deletions
|
@ -76,7 +76,8 @@ class cryptutils:
|
||||||
class aes:
|
class aes:
|
||||||
# GF(2^128) defined by 1 + a + a^2 + a^7 + a^128
|
# GF(2^128) defined by 1 + a + a^2 + a^7 + a^128
|
||||||
# Please note the MSB is x0 and LSB is x127
|
# Please note the MSB is x0 and LSB is x127
|
||||||
def gf_2_128_mul(self, x, y):
|
@staticmethod
|
||||||
|
def gf_2_128_mul(x, y):
|
||||||
assert x < (1 << 128)
|
assert x < (1 << 128)
|
||||||
assert y < (1 << 128)
|
assert y < (1 << 128)
|
||||||
res = 0
|
res = 0
|
||||||
|
@ -367,7 +368,8 @@ class cryptutils:
|
||||||
x = bytes.fromhex(h)
|
x = bytes.fromhex(h)
|
||||||
return b'\x00' * int(x_len - len(x)) + x
|
return b'\x00' * int(x_len - len(x)) + x
|
||||||
|
|
||||||
def os2ip(self, x):
|
@staticmethod
|
||||||
|
def os2ip(x):
|
||||||
"""Converts the byte string x representing an integer reprented using the
|
"""Converts the byte string x representing an integer reprented using the
|
||||||
big-endian convient to an integer.
|
big-endian convient to an integer.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue