MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / raw_encrypt

Method raw_encrypt

src/pyelliptic/ecc.py:449–461  ·  view source on GitHub ↗
(data, pubkey_x, pubkey_y, curve='sect283r1',
                    ephemcurve=None, ciphername='aes-256-cbc')

Source from the content-addressed store, hash-verified

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 """

Callers 1

encryptMethod · 0.80

Calls 9

raw_get_ecdh_keyMethod · 0.95
get_pubkeyMethod · 0.95
cipheringMethod · 0.95
CipherClass · 0.90
hmac_sha256Function · 0.90
ECCClass · 0.85
randMethod · 0.80
get_cipherMethod · 0.80
get_blocksizeMethod · 0.45

Tested by

no test coverage detected