MCPcopy
hub / github.com/PyMySQL/PyMySQL / sha2_rsa_encrypt

Function sha2_rsa_encrypt

pymysql/_auth.py:138–157  ·  view source on GitHub ↗

Encrypt password with salt and public_key. Used for sha256_password and caching_sha2_password.

(password, salt, public_key)

Source from the content-addressed store, hash-verified

136
137
138def sha2_rsa_encrypt(password, salt, public_key):
139 """Encrypt password with salt and public_key.
140
141 Used for sha256_password and caching_sha2_password.
142 """
143 if not _have_cryptography:
144 raise RuntimeError(
145 "'cryptography' package is required for sha256_password or"
146 + " caching_sha2_password auth methods"
147 )
148 message = _xor_password(password + b"\0", salt)
149 rsa_key = serialization.load_pem_public_key(public_key, default_backend())
150 return rsa_key.encrypt(
151 message,
152 padding.OAEP(
153 mgf=padding.MGF1(algorithm=hashes.SHA1()),
154 algorithm=hashes.SHA1(),
155 label=None,
156 ),
157 )
158
159
160def sha256_password_auth(conn, pkt):

Callers 2

sha256_password_authFunction · 0.85

Calls 1

_xor_passwordFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…