def __init__(self, key=None, keylen=20, algo=None, digits=6, offset=0, jitter=0, timestep=60): ''' no key given - create one ''' if key is None: self.key = binascii.hexlify(geturandom(keylen)) else: self.key = key.decode('hex') keylen = len(self.key) if algo is None: if keylen == 20: algo = sha1 elif keylen == 32: algo = sha256 elif keylen == 64: algo = sha512 else: algo = algo self.offset = offset self.jitter = jitter self.timestep = timestep self.digits = digits self.hmacOtp = HmacOtp(self.key, digits=self.digits, hashfunc=algo) return
def generate_otpkey(key_size=20): ''' generates the HMAC key of keysize. Should be 20 or 32 THe key is returned as a hexlified string ''' log.debug("generating key of size %s" % key_size) return binascii.hexlify(geturandom(key_size))
def __init__(self, key=None, keylen=20, algo=None, digits=6, offset=0, jitter=0, timestep=60): ''' no key given - create one ''' if key is None: self.key = binascii.hexlify(geturandom(keylen)) else: self.key = key.decode('hex') keylen = len(self.key) if algo is None: if keylen == 20: algo = sha1 elif keylen == 32: algo = sha256 elif keylen == 64: algo = sha512 else: algo = algo self.offset = offset self.jitter = jitter self.timestep = timestep self.digits = digits self.hmacOtp = HmacOtp(self.key, digits=self.digits, hashfunc=algo) return
def generate_otpkey(key_size=20): ''' generates the HMAC key of keysize. Should be 20 or 32 THe key is returned as a hexlified string ''' log.debug("generating key of size %s" % key_size) return binascii.hexlify(geturandom(key_size))
def setHashedPin(self, pin): seed = geturandom(16) self.LinOtpSeed = unicode(binascii.hexlify(seed)) self.LinOtpPinHash = unicode(binascii.hexlify(hash_digest(pin, seed))) return self.LinOtpPinHash
def setHashedPin(self, pin): seed = geturandom(16) self.LinOtpSeed = unicode(binascii.hexlify(seed)) self.LinOtpPinHash = unicode(binascii.hexlify(hash_digest(pin, seed))) return self.LinOtpPinHash