#NEWLINE# def __init__( self , key , length , algorithm , backend ) : #NEWLINE# #INDENT# if ( not isinstance ( backend , HMACBackend ) ) : #NEWLINE# #INDENT# raise UnsupportedAlgorithm ( 'Backend object does not implement HMACBackend.' , _Reasons . BACKEND_MISSING_INTERFACE ) #NEWLINE# #UNINDENT# if ( len ( key ) < 16 ) : #NEWLINE# #INDENT# raise ValueError ( 'Key length has to be at least 128 bits.' ) #NEWLINE# #UNINDENT# if ( not isinstance ( length , six . integer_types ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Length parameter must be an integer type.' ) #NEWLINE# #UNINDENT# if ( ( length < 6 ) or ( length > 8 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Length of HOTP has to be between 6 to 8.' ) #NEWLINE# #UNINDENT# if ( not isinstance ( algorithm , ( SHA1 , SHA256 , SHA512 ) ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Algorithm must be SHA1, SHA256 or SHA512.' ) #NEWLINE# #UNINDENT# self . _key = key #NEWLINE# self . _length = length #NEWLINE# self . _algorithm = algorithm #NEWLINE# self . _backend = backend