{"action":"opened","issue":{"url":"https://api.github.com/repos/idaviddesmet/NaCl.Core/issues/7","repository_url":"https://api.github.com/repos/idaviddesmet/NaCl.Core","labels_url":"https://api.github.com/repos/idaviddesmet/NaCl.Core/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/idaviddesmet/NaCl.Core/issues/7/comments","events_url":"https://api.github.com/repos/idaviddesmet/NaCl.Core/issues/7/events","html_url":"https://github.com/idaviddesmet/NaCl.Core/issues/7","id":387981025,"node_id":"MDU6SXNzdWUzODc5ODEwMjU=","number":7,"title":"Will you add support for AES-GCM and AES-CCM ciphers?","user":{"login":"idaviddesmet","id":2607383,"node_id":"MDQ6VXNlcjI2MDczODM=","avatar_url":"https://avatars0.githubusercontent.com/u/2607383?v=4","gravatar_id":"","url":"https://api.github.com/users/idaviddesmet","html_url":"https://github.com/idaviddesmet","followers_url":"https://api.github.com/users/idaviddesmet/followers","following_url":"https://api.github.com/users/idaviddesmet/following{/other_user}","gists_url":"https://api.github.com/users/idaviddesmet/gists{/gist_id}","starred_url":"https://api.github.com/users/idaviddesmet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idaviddesmet/subscriptions","organizations_url":"https://api.github.com/users/idaviddesmet/orgs","repos_url":"https://api.github.com/users/idaviddesmet/repos","events_url":"https://api.github.com/users/idaviddesmet/events{/privacy}","received_events_url":"https://api.github.com/users/idaviddesmet/received_events","type":"User","site_admin":false},"labels":[{"id":951611698,"node_id":"MDU6TGFiZWw5NTE2MTE2OTg=","url":"https://api.github.com/repos/idaviddesmet/NaCl.Core/labels/wontfix","name":"wontfix","color":"ffffff","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-05T22:51:28Z","updated_at":"2018-12-05T22:51:28Z","closed_at":null,"author_association":"OWNER","body":"Microsoft have added support for AES-GCM and AES-CCM ciphers, implemented via `System.Security.Cryptography.AesGcm` and `System.Security.Cryptography.AesCcm`. These algorithms are the first Authenticated Encryption (AE) algorithms added to **.NET Core 3.0** (starting from Preview 1). Since it will be supported out-of-the-box, I don't see the benefit of adding support for those.\r\n\r\nThe following code demonstrates using AesGcm cipher to encrypt and decrypt random data. The code for AesCcm would look almost identical (only the class variable names would be different):\r\n\r\n```csharp\r\n// key should be: pre-known, derived, or transported via another channel, such as RSA encryption\r\nbyte[] key = new byte[16];\r\nRandomNumberGenerator.Fill(key);\r\n\r\nbyte[] nonce = new byte[12];\r\nRandomNumberGenerator.Fill(nonce);\r\n\r\n// normally this would be your data\r\nbyte[] dataToEncrypt = new byte[1234];\r\nbyte[] associatedData = new byte[333];\r\nRandomNumberGenerator.Fill(dataToEncrypt);\r\nRandomNumberGenerator.Fill(associatedData);\r\n\r\n// these will be filled during the encryption\r\nbyte[] tag = new byte[16];\r\nbyte[] ciphertext = new byte[dataToEncrypt.Length];\r\n\r\nusing (AesGcm aesGcm = new AesGcm(key))\r\n{\r\n    aesGcm.Encrypt(nonce, dataToEncrypt, ciphertext, tag, associatedData);\r\n}\r\n\r\n// tag, nonce, ciphertext, associatedData should be sent to the other part\r\n\r\nbyte[] decryptedData = new byte[ciphertext.Length];\r\n\r\nusing (AesGcm aesGcm = new AesGcm(key))\r\n{\r\n    aesGcm.Decrypt(nonce, ciphertext, tag, decryptedData, associatedData);\r\n}\r\n\r\n// do something with the data\r\n// this should always print that data is the same\r\nConsole.WriteLine($\"AES-GCM: Decrypted data is{(dataToEncrypt.SequenceEqual(decryptedData) ? \"the same as\" : \"different than\")} original data.\");\r\n```\r\n\r\n"}}
{"actor":{"display_login":"idaviddesmet"}}