repad base32 if necessary in more places in onionrcrypto
This commit is contained in:
parent
2ca762b3b6
commit
61eb4a53e6
@ -101,6 +101,7 @@ The following applies to Ubuntu Bionic. Other distros may have different package
|
|||||||
* Run Onionr normally: `$ ./onionr.sh start`
|
* Run Onionr normally: `$ ./onionr.sh start`
|
||||||
* Run Onionr in background as daemon: `$ ./start-daemon.sh`
|
* Run Onionr in background as daemon: `$ ./start-daemon.sh`
|
||||||
* Open Onionr web interface `$ ./onionr.sh openhome`
|
* Open Onionr web interface `$ ./onionr.sh openhome`
|
||||||
|
* Gracefully stop Onionr from CLI `$ ./onionr.sh stop`
|
||||||
|
|
||||||
# Help out
|
# Help out
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ def pub_key_encrypt(data, pubkey, encodedData=False):
|
|||||||
|
|
||||||
def pub_key_decrypt(data, pubkey='', privkey='', encodedData=False):
|
def pub_key_decrypt(data, pubkey='', privkey='', encodedData=False):
|
||||||
'''pubkey decrypt (Curve25519, taken from Ed25519 pubkey)'''
|
'''pubkey decrypt (Curve25519, taken from Ed25519 pubkey)'''
|
||||||
|
if pubkey != '':
|
||||||
|
pubkey = unpaddedbase32.repad(bytesconverter.str_to_bytes(pubkey))
|
||||||
decrypted = False
|
decrypted = False
|
||||||
if encodedData:
|
if encodedData:
|
||||||
encoding = nacl.encoding.Base64Encoder
|
encoding = nacl.encoding.Base64Encoder
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
import base64, binascii
|
import base64, binascii
|
||||||
|
|
||||||
|
import unpaddedbase32
|
||||||
import nacl.encoding, nacl.signing, nacl.exceptions
|
import nacl.encoding, nacl.signing, nacl.exceptions
|
||||||
|
|
||||||
|
from onionrutils import bytesconverter
|
||||||
import logger
|
import logger
|
||||||
def ed_sign(data, key, encodeResult=False):
|
def ed_sign(data, key, encodeResult=False):
|
||||||
'''Ed25519 sign data'''
|
'''Ed25519 sign data'''
|
||||||
|
key = unpaddedbase32.repad(bytesconverter.str_to_bytes(key))
|
||||||
try:
|
try:
|
||||||
data = data.encode()
|
data = data.encode()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -17,6 +22,7 @@ def ed_sign(data, key, encodeResult=False):
|
|||||||
|
|
||||||
def ed_verify(data, key, sig, encodedData=True):
|
def ed_verify(data, key, sig, encodedData=True):
|
||||||
'''Verify signed data (combined in nacl) to an ed25519 key'''
|
'''Verify signed data (combined in nacl) to an ed25519 key'''
|
||||||
|
key = unpaddedbase32.repad(bytesconverter.str_to_bytes(key))
|
||||||
try:
|
try:
|
||||||
key = nacl.signing.VerifyKey(key=key, encoder=nacl.encoding.Base32Encoder)
|
key = nacl.signing.VerifyKey(key=key, encoder=nacl.encoding.Base32Encoder)
|
||||||
except nacl.exceptions.ValueError:
|
except nacl.exceptions.ValueError:
|
||||||
|
Loading…
Reference in New Issue
Block a user