mirror of
https://github.com/elseif/MikroTikPatch.git
synced 2025-01-23 13:35:09 +03:00
Merge pull request #74 from vnxme/system-random
Some checks failed
Patch Mikrotik RouterOS 7.x / Set_BuildTime (push) Has been cancelled
Patch Mikrotik RouterOS 6.x / Set_BuildTime (push) Has been cancelled
Patch Mikrotik RouterOS 7.x / Patch_RouterOS (arm64, stable) (push) Has been cancelled
Patch Mikrotik RouterOS 7.x / Patch_RouterOS (arm64, testing) (push) Has been cancelled
Patch Mikrotik RouterOS 7.x / Patch_RouterOS (x86, stable) (push) Has been cancelled
Patch Mikrotik RouterOS 7.x / Patch_RouterOS (x86, testing) (push) Has been cancelled
Patch Mikrotik RouterOS 6.x / Patch_RouterOS (long-term) (push) Has been cancelled
Patch Mikrotik RouterOS 6.x / Patch_RouterOS (stable) (push) Has been cancelled
Some checks failed
Patch Mikrotik RouterOS 7.x / Set_BuildTime (push) Has been cancelled
Patch Mikrotik RouterOS 6.x / Set_BuildTime (push) Has been cancelled
Patch Mikrotik RouterOS 7.x / Patch_RouterOS (arm64, stable) (push) Has been cancelled
Patch Mikrotik RouterOS 7.x / Patch_RouterOS (arm64, testing) (push) Has been cancelled
Patch Mikrotik RouterOS 7.x / Patch_RouterOS (x86, stable) (push) Has been cancelled
Patch Mikrotik RouterOS 7.x / Patch_RouterOS (x86, testing) (push) Has been cancelled
Patch Mikrotik RouterOS 6.x / Patch_RouterOS (long-term) (push) Has been cancelled
Patch Mikrotik RouterOS 6.x / Patch_RouterOS (stable) (push) Has been cancelled
Use SystemRandom to ensure crossplatform compatibility
This commit is contained in:
commit
f6fea00c16
5
mikro.py
5
mikro.py
@ -1,8 +1,7 @@
|
||||
|
||||
import random
|
||||
import struct
|
||||
from sha256 import SHA256
|
||||
from toyecc import AffineCurvePoint, getcurvebyname, FieldElement,ECPrivateKey,ECPublicKey,Tools
|
||||
from toyecc.Random import secure_rand_int_between
|
||||
|
||||
|
||||
MIKRO_BASE64_CHARACTER_TABLE = b'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
||||
@ -167,7 +166,7 @@ def mikro_kcdsa_sign(data:bytes,private_key:bytes)->bytes:
|
||||
private_key:ECPrivateKey = ECPrivateKey(Tools.bytestoint_le(private_key), curve)
|
||||
public_key:ECPublicKey = private_key.pubkey
|
||||
while True:
|
||||
nonce_secret = secure_rand_int_between(1, curve.n - 1)
|
||||
nonce_secret = random.SystemRandom().randint(1, curve.n - 1)
|
||||
nonce_point = nonce_secret * curve.G
|
||||
nonce = int(nonce_point.x) % curve.n
|
||||
nonce_hash = mikro_sha256(Tools.inttobytes_le(nonce,32))
|
||||
|
Loading…
Reference in New Issue
Block a user