(data, pubkey_x, pubkey_y, curve='sect283r1',
ephemcurve=None, ciphername='aes-256-cbc')
| 447 | |
| 448 | @staticmethod |
| 449 | def raw_encrypt(data, pubkey_x, pubkey_y, curve='sect283r1', |
| 450 | ephemcurve=None, ciphername='aes-256-cbc'): |
| 451 | if ephemcurve is None: |
| 452 | ephemcurve = curve |
| 453 | ephem = ECC(curve=ephemcurve) |
| 454 | key = sha512(ephem.raw_get_ecdh_key(pubkey_x, pubkey_y)).digest() |
| 455 | key_e, key_m = key[:32], key[32:] |
| 456 | pubkey = ephem.get_pubkey() |
| 457 | iv = OpenSSL.rand(OpenSSL.get_cipher(ciphername).get_blocksize()) |
| 458 | ctx = Cipher(key_e, iv, 1, ciphername) |
| 459 | ciphertext = iv + pubkey + ctx.ciphering(data) |
| 460 | mac = hmac_sha256(key_m, ciphertext) |
| 461 | return ciphertext + mac |
| 462 | |
| 463 | def decrypt(self, data, ciphername='aes-256-cbc'): |
| 464 | """ |
no test coverage detected