mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
p11helper: Port to Python 3
- Use binascii.hexlify instead of encode('hex') - Keep the library name as a text string instead of encoding to bytes https://fedorahosted.org/freeipa/ticket/5638 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
parent
c3529355a6
commit
5b6a1ce8a8
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
import ctypes.util
|
import ctypes.util
|
||||||
|
import binascii
|
||||||
|
|
||||||
import six
|
import six
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
@ -551,13 +552,13 @@ def char_array_to_unicode(array, l):
|
|||||||
|
|
||||||
def int_to_bytes(value):
|
def int_to_bytes(value):
|
||||||
try:
|
try:
|
||||||
return '{0:x}'.format(value).decode('hex')
|
return binascii.unhexlify('{0:x}'.format(value))
|
||||||
except TypeError:
|
except (TypeError, binascii.Error):
|
||||||
return '0{0:x}'.format(value).decode('hex')
|
return binascii.unhexlify('0{0:x}'.format(value))
|
||||||
|
|
||||||
|
|
||||||
def bytes_to_int(value):
|
def bytes_to_int(value):
|
||||||
return int(value.encode('hex'), 16)
|
return int(binascii.hexlify(value), 16)
|
||||||
|
|
||||||
|
|
||||||
def check_return_value(rv, message):
|
def check_return_value(rv, message):
|
||||||
@ -807,8 +808,6 @@ class P11_Helper(object):
|
|||||||
# Parse method args
|
# Parse method args
|
||||||
if isinstance(user_pin, unicode):
|
if isinstance(user_pin, unicode):
|
||||||
user_pin = user_pin.encode()
|
user_pin = user_pin.encode()
|
||||||
if isinstance(library_path, unicode):
|
|
||||||
library_path = library_path.encode()
|
|
||||||
self.slot = slot
|
self.slot = slot
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user