#NEWLINE# @ staticmethod #NEWLINE# def raw_encrypt( data , pubkey_x , pubkey_y , curve = 'sect283r1' , ephemcurve = None , ciphername = 'aes-256-cbc' ) : #NEWLINE# #INDENT# if ( ephemcurve is None ) : #NEWLINE# #INDENT# ephemcurve = curve #NEWLINE# #UNINDENT# ephem = ECC ( curve = ephemcurve ) #NEWLINE# key = sha512 ( ephem . raw_get_ecdh_key ( pubkey_x , pubkey_y ) ) . digest ( ) #NEWLINE# ( key_e , key_m ) = ( key [ : 32 ] , key [ 32 : ] ) #NEWLINE# pubkey = ephem . get_pubkey ( ) #NEWLINE# iv = OpenSSL . rand ( OpenSSL . get_cipher ( ciphername ) . get_blocksize ( ) ) #NEWLINE# ctx = Cipher ( key_e , iv , 1 , ciphername ) #NEWLINE# ciphertext = ctx . ciphering ( data ) #NEWLINE# mac = hmac_sha256 ( key_m , ciphertext ) #NEWLINE# return ( ( ( iv + pubkey ) + ciphertext ) + mac )