Repository navigation
[WIP] GCM support - #176
Conversation
There was a problem hiding this comment.
I guess GCM isn't available with other ciphers?
There was a problem hiding this comment.
Not in OpenSSL.
—
Sent from Mailbox for iPhone
On Thu, Oct 24, 2013 at 11:40 AM, Alex Gaynor [email protected]
wrote:
@@ -153,6 +153,11 @@ def _register_default_ciphers(self):
mode_cls,
GetCipherByName("des-ede3-{mode.name}")
)
self.register_cipher_adapter(AES,GCM,GetCipherByName("{cipher.name}-{cipher.key_size}-{mode.name}"))I guess GCM isn't available with other ciphers?
Reply to this email directly or view it on GitHub:
https://github.com/pyca/cryptography/pull/176/files#r7193332
|
This comment is outdated. This PR has now been rebased and reworked to fit in the new model we use for _CipherContexts in the backend. Outstanding items to discuss:
|
There was a problem hiding this comment.
This method duplicates a ton of logic from the superclass, and never calls the parent's implementation.
|
Can we split the vector loading and tests for that into a seperate patch? |
|
Yeah we certainly can. This patch is still very much WIP overall, but I'll break the vector loader + tests out and submit them as a finalized PR tomorrow (assuming I actually think they're done). |
|
Great! On Thu, Oct 24, 2013 at 9:18 PM, Paul Kehrer [email protected]:
"I disapprove of what you say, but I will defend to the death your right to |
There was a problem hiding this comment.
When does it get? When does it set?
There was a problem hiding this comment.
This is one of the ugly parts of the PR right now (and the comment is inaccurate). At the moment if you want to decrypt you must set the tag in the GCM object. When encrypting, however, after calling finalize() it will set the tag on the context.
One possible solution would be to remove tag from the GCM object entirely and require users to get/set tag on the AEADContext. This would keep the tag location consistent and allow users to use their BlockCipher object as a factory for both encryption and decryption contexts. The GCM object itself would be reduced to only holding the IV though.
aes = ciphers.AES(b"0" * 16)
gcm = modes.GCM(b"0" * 12)
bc = BlockCipher(aes, gcm)
enc = bc.encryptor()
enc.add_data(b"test")
enc.finalize()
tag = enc.tag
dec = bc.decryptor()
dec.tag = tag
dec.add_data(b"test")
dec.finalize()There was a problem hiding this comment.
Oh, abstractproperty, nevermind.
|
I think this is now ready to be rebased on master, all the dependent patches are in? |
|
Coverage remained the same when pulling 323f5f34467166166cad571fd0feb138dc923b07 on reaperhulk:gcm-support into 838ad7d on pyca:master. |
There was a problem hiding this comment.
This doesn't look right. If we just malloc block_size // 8, there's not enough bytes for this. Probably no slicing is needed at all? just buffer(...)[:]?
|
Coverage remained the same when pulling ed51a9ee673e508086b109eb8f7e4698c2548a58 on reaperhulk:gcm-support into 838ad7d on pyca:master. |
There was a problem hiding this comment.
The _tag properly shouldn't exist on _CipherContext IMO.
|
Coverage remained the same when pulling 893b4bde18fc8f5251a86ff46d11f4cedc5c3081 on reaperhulk:gcm-support into 838ad7d on pyca:master. |
|
Coverage remained the same when pulling 358cc37a585bf7b79bae388cfb3d54b6602e73cd on reaperhulk:gcm-support into 8cf523e on pyca:master. |
|
Coverage remained the same when pulling c89d78561fd41c82792c4aaadd1ecee1460f7211 on reaperhulk:gcm-support into 9050172 on pyca:master. |
* To support this the _AEADCipherContext in base.py now needs to be aware of whether it is encrypting/decrypting
* Might make more sense to split it into _CipherContext and _AEADCipherContext like we do in base.py, but there would be quite a bit of duplicate code.
There was a problem hiding this comment.
I don't think you need this interface. Or the concrete implementation of it. Something either provides AEADCipherContext or AEADCipherContext & AEADEncryptionContext (maybe there is a better name for that which will relieve us of the apparent need for symmetry here?)
decryption will return AEADCipherContext and encryption returns AEADEncryptionContext
There was a problem hiding this comment.
AEADDecryptionContext is no more?
There was a problem hiding this comment.
Referenced recommendations should be provide links.
Clarify that 96-bit IV is only recommended in performance critical situations...otherwise feel free to use something longer.
Rebased and rewritten. I'm not happy with this API so let's discuss how to make it better! Here's what encryption/decryption looks like with the current model:
When calling
encryptor()ordecryptor()you will get anAEADCipherContextobject that has the methods fromCipherContextbut also addsadd_dataandtag.Note that you must obtain the tag from the AEADCipherContext object and build a new GCM object (this time passing the tag) if you want to do an encrypt/decrypt cycle.