def xorSecret(self, composite, secret, hash_func): warnings.warn("Method 'xorSecret' is deprecated, use 'xor_secret' instead.", DeprecationWarning) dh_shared = self._get_shared_secret(cryptutil.longToBase64(composite)) # The DH secret must be `btwoc` compatible. # See http://openid.net/specs/openid-authentication-2_0.html#rfc.section.8.2.3 for details. dh_shared = cryptutil.fix_btwoc(dh_shared) hashed_dh_shared = hash_func(dh_shared) return strxor(secret, hashed_dh_shared)
def xorSecret(self, composite, secret, hash_func): warnings.warn( "Method 'xorSecret' is deprecated, use 'xor_secret' instead.", DeprecationWarning) dh_shared = self._get_shared_secret(cryptutil.longToBase64(composite)) # The DH secret must be `btwoc` compatible. # See http://openid.net/specs/openid-authentication-2_0.html#rfc.section.8.2.3 for details. dh_shared = cryptutil.fix_btwoc(dh_shared) hashed_dh_shared = hash_func(dh_shared) return strxor(secret, hashed_dh_shared)
def xor_secret(self, public_key, secret, algorithm): """Return a base64 encoded XOR of a secret key and hash of a DH exchanged secret. @param public_key: Base64 encoded public key of the other party. @type public_key: six.text_type @param secret: Base64 encoded secret @type secret: six.text_type @type algorithm: hashes.HashAlgorithm @rtype: six.text_type """ dh_shared = self._get_shared_secret(public_key) # The DH secret must be `btwoc` compatible. # See http://openid.net/specs/openid-authentication-2_0.html#rfc.section.8.2.3 for details. dh_shared = cryptutil.fix_btwoc(dh_shared) digest = hashes.Hash(algorithm, backend=default_backend()) digest.update(dh_shared) hashed_dh_shared = digest.finalize() return toBase64(strxor(base64.b64decode(secret), hashed_dh_shared))
def xor_secret(self, public_key, secret, algorithm): """Return a base64 encoded XOR of a secret key and hash of a DH exchanged secret. @param public_key: Base64 encoded public key of the other party. @type public_key: six.text_type @param secret: Base64 encoded secret @type secret: six.text_type @type algorithm: hashes.HashAlgorithm @rtype: six.text_type """ dh_shared = self._get_shared_secret(public_key) # The DH secret must be `btwoc` compatible. # See http://openid.net/specs/openid-authentication-2_0.html#rfc.section.8.2.3 for details. dh_shared = cryptutil.fix_btwoc(dh_shared) digest = hashes.Hash(algorithm, backend=default_backend()) digest.update(dh_shared) hashed_dh_shared = digest.finalize() return toBase64(strxor(base64.b64decode(secret), hashed_dh_shared))
def test_bytearray(self): for value, output in self.cases: self.assertEqual(cryptutil.fix_btwoc(bytearray(value)), output)
def test_bytearray(self): for value, output in self.cases: self.assertEqual(cryptutil.fix_btwoc(bytearray(value)), output)