I wrote a class in Java for encrypting and decrypting data using AES/GCM/NoPadding
. I'm using an IV with a length of 12 bytes. I would like to write the remote site (which should run on another system) in C#. Unfortunately I can not find an implementation of the AES/GCM/NoPadding
algorithm in C # with .NET 4.7.2. Is there any way to solve my problem with the .NET Framework version 4.7.2?
Asked
Active
Viewed 2,505 times
1

Lukas Nothhelfer
- 261
- 1
- 5
- 14
-
1An IV of length 12 bytes makes no sense. The IV should always be the length of a block, and in AES, the block size is fixed at 128 bits (16 bytes). Rijndael, on which AES was based, offered more choice over block sizes but they were larger, not smaller. – Damien_The_Unbeliever Jan 07 '19 at 11:31
-
3@Damien_The_Unbeliever In Galois Counter Mode (GCM) you typically have 12 Bytes for the IV and 4 Bytes for the counter. I don't understand how your post can help me with my question? – Lukas Nothhelfer Jan 07 '19 at 11:50
-
Read Wiki : https://en.wikipedia.org/wiki/Galois/Counter_Mode. See msdn : https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.aes?view=netframework-4.7.2. You should be able to change parameters to get what you need. – jdweng Jan 07 '19 at 11:56
-
@jdweng No, that's just the point, the GCM mode is not supported. That's why I'm asking if anyone has already managed to implement this in C # with the mentioned .NET Framework release – Lukas Nothhelfer Jan 07 '19 at 12:00
-
@Damien_The_Unbeliever For IV size of AES GCM see NIST 800-38D or see [this](https://crypto.stackexchange.com/questions/41601/aes-gcm-recommended-iv-size-why-12-bytes) and [this](https://crypto.stackexchange.com/questions/59396/generate-j-0-for-gcm-cipher-when-operatornameleniv-neq-96-bits?noredirect=1&lq=1) – kelalaka Jan 07 '19 at 12:01
-
It is still AES. It is just that every block you must call the constructor to create a new IV. – jdweng Jan 07 '19 at 12:09
-
@Damien_The_Unbeliever: You're right, it's not really an IV but more accurately called a nonce. – President James K. Polk Jan 07 '19 at 14:29
-
This question is essentially a duplicate of [this](https://stackoverflow.com/q/46067811/238704), and I believe the situation is still the same. That questions has no answers, but the comments contain useful info. – President James K. Polk Jan 07 '19 at 14:41
-
@JamesKPolk you're right. This question is duplicate to the one in your link. Thanks for sharing it. I don't know how I could miss that. – Lukas Nothhelfer Jan 08 '19 at 15:37