-
Hello, I'm upgrading a project from .NET 6 to .NET 8. And now there is this: I should add a tag size parameter to my Are there any recommendations? The documentation and related issues are pretty silent here. Or should I leave it as is and disable that obsoletion warning because the class knows best itself what to do here? I'm confused. I'm told that I should change, but not how. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The same goes for this one: I'm using a now obsolete constructor of the |
Beta Was this translation helpful? Give feedback.
-
if you're doing the encryption, what size buffer are you passing as the So, if what you have already is AesGcm gcm = new AesGcm(key);
...
byte[] tag = new byte[16];
gcm.Encrypt(nonce, plaintext, ciphertext, tag); You'd float that AesGcm gcm = new AesGcm(key, 16);
...
byte[] tag = new byte[16];
gcm.Encrypt(nonce, plaintext, ciphertext, tag); If you're only decrypting, then if you are decrypting data from a standard then you should put whatever tag size the standard says into the constructor, and then it will detect for you at decryption time to make sure everything was copacetic. For example, in the COSE Specification all three supported GCM algorithm choices specify a 128-bit (16-byte) tag. So if you were decrypting CBOR data you'd do
The constructors that don't accept a hash algorithm use SHA-1. If you need to reproduce an existing value you need to specify the same hash algorithm as it previously had, so you'd pass in |
Beta Was this translation helpful? Give feedback.
if you're doing the encryption, what size buffer are you passing as the
tag
destination parameter? Assuming it's the same size every time, that's what you pass in the constructor. Then the Encrypt and Decrypt methods just double check that they were supplied values that correspond with your previously registered intent.So, if what you have already is
You'd float that
16
into the constructor:A…