(self, data, algorithm=OAEP_SHA1)
| 407 | raise InvalidKeyError("Unsupported key algorithm") |
| 408 | |
| 409 | def encrypt(self, data, algorithm=OAEP_SHA1): |
| 410 | _padding = self.parse_padding_for_encryption(algorithm) |
| 411 | _hash = self.parse_hash(algorithm) |
| 412 | self._enforce_fips(algorithm) |
| 413 | if type(data) == "bytes": |
| 414 | bdata = data |
| 415 | else: |
| 416 | bdata = salt.utils.stringutils.to_bytes(data) |
| 417 | try: |
| 418 | return self.key.encrypt( |
| 419 | bdata, |
| 420 | _padding( |
| 421 | mgf=padding.MGF1(algorithm=_hash()), |
| 422 | algorithm=_hash(), |
| 423 | label=None, |
| 424 | ), |
| 425 | ) |
| 426 | except cryptography.exceptions.UnsupportedAlgorithm: |
| 427 | raise UnsupportedAlgorithm(f"Unsupported algorithm: {algorithm}") |
| 428 | |
| 429 | def verify(self, data, signature, algorithm=PKCS1v15_SHA1): |
| 430 | _padding = self.parse_padding_for_signing(algorithm) |
no test coverage detected