mirror of
https://github.com/morgan9e/noiseprotocol
synced 2026-04-14 00:14:05 +09:00
* Created NoiseBackend class serving as a base for backends
* Refactored NoiseProtocol name parsing
* Refactored existing spec-defined functions into abstract classes.
Implementing classes are connecting crypto primitives to expected
interfaces.
* Refactored existing usage of Cryptography as source of crypto into
"default" backend (along with in-house implementation of X448).
* Provisioned "experimental" backend, it will contain e.g. non-default
crypto algorithms
* Backend can be chosen while creating NoiseConnection, though by
default, the Cryptography backend ("default") is used
Closes #7
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from noise.backends.default.ciphers import ChaCha20Cipher, AESGCMCipher
|
|
from noise.backends.default.diffie_hellmans import ED25519, ED448
|
|
from noise.backends.default.hashes import hmac_hash, BLAKE2sHash, BLAKE2bHash, SHA256Hash, SHA512Hash
|
|
from noise.backends.default.keypairs import KeyPair25519, KeyPair448
|
|
from noise.backends.noise_backend import NoiseBackend
|
|
|
|
|
|
class DefaultNoiseBackend(NoiseBackend):
|
|
"""
|
|
Contains all the crypto methods endorsed by Noise Protocol specification, using Cryptography as backend
|
|
"""
|
|
|
|
def __init__(self):
|
|
super(DefaultNoiseBackend, self).__init__()
|
|
|
|
self.diffie_hellmans = {
|
|
'25519': ED25519,
|
|
'448': ED448
|
|
}
|
|
|
|
self.ciphers = {
|
|
'AESGCM': AESGCMCipher,
|
|
'ChaChaPoly': ChaCha20Cipher
|
|
}
|
|
|
|
self.hashes = {
|
|
'BLAKE2s': BLAKE2sHash,
|
|
'BLAKE2b': BLAKE2bHash,
|
|
'SHA256': SHA256Hash,
|
|
'SHA512': SHA512Hash
|
|
}
|
|
|
|
self.keypairs = {
|
|
'25519': KeyPair25519,
|
|
'448': KeyPair448
|
|
}
|
|
|
|
self.hmac = hmac_hash
|