Moved hashing to native python3 hashlib
This commit is contained in:
parent
379e56b2ce
commit
715a84c6f2
@ -26,7 +26,6 @@ import time
|
|||||||
import RNS
|
import RNS
|
||||||
|
|
||||||
from cryptography.fernet import Fernet
|
from cryptography.fernet import Fernet
|
||||||
from cryptography.hazmat.primitives import hashes
|
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
|
|
||||||
class Callbacks:
|
class Callbacks:
|
||||||
@ -97,10 +96,7 @@ class Destination:
|
|||||||
name = Destination.full_name(app_name, *aspects)
|
name = Destination.full_name(app_name, *aspects)
|
||||||
|
|
||||||
# Create a digest for the destination
|
# Create a digest for the destination
|
||||||
digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
|
return RNS.Identity.full_hash(name.encode("utf-8"))[:RNS.Reticulum.TRUNCATED_HASHLENGTH//8]
|
||||||
digest.update(name.encode("UTF-8"))
|
|
||||||
|
|
||||||
return digest.finalize()[:10]
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def app_and_aspects_from_name(full_name):
|
def app_and_aspects_from_name(full_name):
|
||||||
|
@ -27,9 +27,10 @@ import RNS
|
|||||||
import time
|
import time
|
||||||
import atexit
|
import atexit
|
||||||
import base64
|
import base64
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from .vendor import umsgpack as umsgpack
|
from .vendor import umsgpack as umsgpack
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives import hashes
|
|
||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
|
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
|
||||||
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
|
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
|
||||||
@ -158,10 +159,10 @@ class Identity:
|
|||||||
:param data: Data to be hashed as *bytes*.
|
:param data: Data to be hashed as *bytes*.
|
||||||
:returns: SHA-256 hash as *bytes*
|
:returns: SHA-256 hash as *bytes*
|
||||||
"""
|
"""
|
||||||
digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
|
digest = hashlib.sha256()
|
||||||
digest.update(data)
|
digest.update(data)
|
||||||
|
|
||||||
return digest.finalize()
|
return digest.digest()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def truncated_hash(data):
|
def truncated_hash(data):
|
||||||
|
Loading…
Reference in New Issue
Block a user