def fromQuery(cls, query): """ @param query: The associate request's query parameters @type query: {str:str} @returntype: L{DiffieHellmanServerSession} @raises ProtocolError: When parameters required to establish the session are missing. """ dh_modulus = query.get('openid.dh_modulus') dh_gen = query.get('openid.dh_gen') if (dh_modulus is None and dh_gen is not None or dh_gen is None and dh_modulus is not None): if dh_modulus is None: missing = 'modulus' else: missing = 'generator' raise ProtocolError('If non-default modulus or generator is ' 'supplied, both must be supplied. Missing %s' % (missing, )) if dh_modulus or dh_gen: dh_modulus = cryptutil.base64ToLong(dh_modulus) dh_gen = cryptutil.base64ToLong(dh_gen) dh = DiffieHellman(dh_modulus, dh_gen) else: dh = DiffieHellman.fromDefaults() consumer_pubkey = query.get('openid.dh_consumer_public') if consumer_pubkey is None: raise ProtocolError("Public key for DH-SHA1 session " "not found in query %s" % (query, )) consumer_pubkey = cryptutil.base64ToLong(consumer_pubkey) return cls(dh, consumer_pubkey)
def createNonstandardConsumerDH(): nonstandard_dh = DiffieHellman('FBHb', DEFAULT_DH_GENERATOR) return DiffieHellmanSHA1ConsumerSession(nonstandard_dh)
def createNonstandardConsumerDH(): nonstandard_dh = DiffieHellman(1315291, 2) return DiffieHellmanSHA1ConsumerSession(nonstandard_dh)
def test_init_int(self): dh = DiffieHellman(base64ToLong(DEFAULT_DH_MODULUS), base64ToLong(DEFAULT_DH_GENERATOR)) self.assertTrue(dh.usingDefaultValues())
def test_init(self): dh = DiffieHellman(DEFAULT_DH_MODULUS, DEFAULT_DH_GENERATOR) self.assertTrue(dh.usingDefaultValues())