Encrypt password with salt and public_key. Used for sha256_password and caching_sha2_password.
(password, salt, public_key)
| 136 | |
| 137 | |
| 138 | def 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 | |
| 160 | def sha256_password_auth(conn, pkt): |
no test coverage detected
searching dependent graphs…