summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/ipa_otptoken_import.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-08-12 15:23:56 +0200
committerJan Cholasta <jcholast@redhat.com>2015-09-01 11:42:01 +0200
commit5178e9a5975b17683a2529f6cf4c903766d234d9 (patch)
treed51ad5a191cf5129024d182b9e5a1d2518151284 /ipaserver/install/ipa_otptoken_import.py
parent9e917cae39e266fb3092e5ab212a99968de996c2 (diff)
downloadfreeipa-5178e9a5975b17683a2529f6cf4c903766d234d9.tar.gz
freeipa-5178e9a5975b17683a2529f6cf4c903766d234d9.tar.xz
freeipa-5178e9a5975b17683a2529f6cf4c903766d234d9.zip
Modernize use of range()
In Python 3, range() behaves like the old xrange(). The difference between range() and xrange() is usually not significant, especially if the whole result is iterated over. Convert xrange() usage to range() for small ranges. Use modern idioms in a few other uses of range(). Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipaserver/install/ipa_otptoken_import.py')
-rw-r--r--ipaserver/install/ipa_otptoken_import.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ipaserver/install/ipa_otptoken_import.py b/ipaserver/install/ipa_otptoken_import.py
index 4d901d08e..98de4799d 100644
--- a/ipaserver/install/ipa_otptoken_import.py
+++ b/ipaserver/install/ipa_otptoken_import.py
@@ -31,6 +31,7 @@ import dateutil.parser
import dateutil.tz
import nss.nss as nss
import gssapi
+from six.moves import xrange
from ipapython import admintool
from ipalib import api, errors
@@ -190,7 +191,7 @@ class PBKDF2KeyDerivation(XMLKeyDerivation):
# Loop through each block adding it to the derived key.
dk = []
- for i in xrange(1, blocks + 1):
+ for i in range(1, blocks + 1):
# Set initial values.
last = self.salt + struct.pack('>I', i)
hash = [0] * mac.digest_size
@@ -202,7 +203,7 @@ class PBKDF2KeyDerivation(XMLKeyDerivation):
last = tmp.digest()
# XOR the previous hash with the new hash.
- for k in xrange(mac.digest_size):
+ for k in range(mac.digest_size):
hash[k] ^= ord(last[k])
# Add block to derived key.