Symmetric Encryption + HMAC

45 views
Skip to first unread message

Melodies Sim

unread,
May 27, 2020, 2:37:47 AM5/27/20
to python-gnupg
Hi all, 

I've been working on a use case recently that requires symmetric encryption (and HMAC to verify integrity of the encrypted content). 

While there seems to be an alternative flag on `encrypt` function to toggle between symmetric and asymmetric uses, I couldn't seem to find a function for HMAC. Can someone advise on this? 

For example:
gpg.encrypt(message, recipients=None, symmetric='AE256', passphrase=passphrase, armor=True)


On a side note, have anyone tried testing whether the speed/size of files that `encrypt` and `decrypt` function could handle is similar for both symmetric and asymmetric? 

Many Thanks,
Mel

Melodies Sim

unread,
May 27, 2020, 2:37:47 AM5/27/20
to python-gnupg
Hi all, 

I'm have a use case that requires symmetric encryption (and using hmac to verify the integrity). I notice that while we could use encrypt for both symmetric and asymmetric use cases as shown: 

gpg.encrypt(message, recipients=None, symmetric='AE256', passphrase=passphrase, armor=True)

there doesn't seem to be an equivalent HMAC function (please correct me if I'm wrong). 

Is there another way, we could ensure the integrity of encrypted data with python gnupg (I'm aware that digital signatures require both private and public keys to work which doesn't work for the symmetric case)? 

On a side note, have anyone tested the speed (and also how large of a file can encrypt work on) of the symmetric vs asymmetric encrypt functions? 


Many thanks, 
Mel

Vinay Sajip

unread,
May 27, 2020, 8:11:38 AM5/27/20
to python-gnupg
I thought HMAC always uses symmetric encryption? There is IIUC a single key which is used to derive inner and outer keys.

Regards,

Vinay Sajip

Melodies Sim

unread,
May 27, 2020, 8:58:57 AM5/27/20
to python-gnupg
Yeap, hmm I was wondering if the library has any support for HMAC generation (for instance it supports digital signature).

Also, is there support for generating keys for symmetric encryption?

Many thanks,
Mel

Reply all
Reply to author
Forward
0 new messages