#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def _do_shared_secret_registration( self , username , password , mac ) : #NEWLINE# #INDENT# if ( not got_mac . hs . config . registration_shared_secret ) : #NEWLINE# #INDENT# raise SynapseError ( 400 , 'Shared secret registration is not enabled' ) #NEWLINE# #UNINDENT# user = username . encode ( 'utf-8' ) #NEWLINE# got_mac = str ( mac ) #NEWLINE# want_mac = hmac . new ( key = self . hs . config . registration_shared_secret , msg = user , digestmod = sha1 ) . hexdigest ( ) #NEWLINE# if ( not compare_digest ( want_mac , got_mac ) ) : #NEWLINE# #INDENT# raise SynapseError ( 403 , 'HMAC incorrect' ) #NEWLINE# #UNINDENT# ( user_id , token ) = ( yield self . registration_handler . register ( localpart = username , password = password ) ) #NEWLINE# defer . returnValue ( ( yield self . _create_registration_details ( user_id , token ) ) )