def __init__(self, encrypt): """ Initialization method for the object encrypt -- boolean to see if the package uses encryption """ KeyPack.__init__(self, encrypt) # HOTP requires AlgorithmParameters self.algparamreq = True
def __init__(self, encrypt): """ Initialization method for the object encrypt -- boolean to see if the package uses encryption """ # SecurID requires AlgorithmParameters self.algparamreq = True # SecurID requires Key policy self.keypolicyreq = True KeyPack.__init__(self, encrypt)
def parse(self, element): """ Extends the default parser """ KeyPack.parse(self, element) try: # Encoding and Lenght both need to be set if 'Encoding' not in self.algattr or 'Length' not in self.algattr: raise PskcError # Time and TimeInterval elements need to be present in the key data if 'Time' not in self.keydata or 'TimeInterval' not in self.keydata: raise PskcError # Encoding needs to be DECIMAL if self.algattr['Encoding'] != 'DECIMAL': raise PskcError return 0 except PskcError: print ('Error! Key ' + self.keyinfo['Id'] + ' is not a valid ' 'TOTP key.') return 1
def parse(self, element): """ Extends the default parser """ KeyPack.parse(self, element) try: if self.devinfo['Manufacturer'] != 'oath.UB': raise PskcError if self.devinfo['StartDate'] is None: raise PskcError # cryptoid marks ports on the Yubikey token - 1 or 2 if self.cryptoid != '1' and self.cryptoid != '2': raise PskcError if (self.algattr['Encoding'] != 'ALPHANUMERIC' or 'Length' not in self.algattr): raise PskcError return 0 except (PskcError, KeyError): print ('Error! Key ' + self.keyinfo['Id'] + ' is not a valid' ' Yubico key.') return 1
def parse(self, element): """ Extends the default parser """ KeyPack.parse(self, element) try: # Start date and expiry date both need to be set if ('StartDate' not in self.policyinfo or 'ExpiryDate' not in self.policyinfo): raise PskcError # Encoding needs to be DECIMAL if self.algattr['Encoding'] != 'DECIMAL': raise PskcError # Length needs to be at least 6 if int(self.algattr['Length']) < 6: raise PskcError return 0 except PskcError: print ('Error! Key ' + self.keyinfo['Id'] + ' is not a valid ' 'TOTP key.') return 1