-
Notifications
You must be signed in to change notification settings - Fork 3
Secret Key Cryptography _AEAD_AES256GCM
It's extremely important that you read the detailed documentation from libsodium.. If security is not a concern to you, you can ignore this warning I give to you.
Even though the code works but I don't recommend anyone to use the pre computation of hardware accelerated AES256 GCM.
There're lots of code that seem to be extra and I think I will be spending some free time to rework and erase.. the code
Initial Functions
public static Boolean IsAES256GCMAvailable()
Example Code
Boolean IsHAAES256GCMAvailable = SodiumSecretAeadAES256GCM.IsAES256GCMAvailable();
if(IsHAAES256GCMAvailable)
{
//Do something..
}
Kindly ensures that your machine or current machine supports HA-AES256GCM else all the wrapper functions couldn't be called by you as a developer.
Initial Functions
public static Byte[] GenerateKey()
public static Byte[] GeneratePublicNonce()
Example Code
Byte[] Key = SodiumSecretAeadAES256GCM.GenerateKey();
Byte[] NoncePublic = SodiumSecretAeadAES256GCM.GeneratePublicNonce();
This section of the documentation describes about using HA-AES256GCM without involving pre-computation.
Initial Functions
public static Byte[] Encrypt(Byte[] Message, Byte[] NoncePublic, Byte[] Key, Byte[] AdditionalData = null, Byte[] NonceSecurity = null,Boolean ClearKey=false)
public static Byte[] Decrypt(Byte[] CipherText, Byte[] NoncePublic, Byte[] Key, Byte[] AdditionalData = null, Byte[] NonceSecurity = null,Boolean ClearKey=false)
Example Code
Byte[] Key = SodiumSecretAeadAES256GCM.GenerateKey();
Byte[] NoncePublic = SodiumSecretAeadAES256GCM.GeneratePublicNonce();
Byte[] Message = SodiumRNG.GetRandomBytes(32);
Byte[] CipherText = SodiumSecretAeadAES256GCM.Encrypt(Message,NoncePublic,Key,null,null,false);
Byte[] PlainText = SodiumSecretAeadAES256GCM.Decrypt(CipherText,NoncePublic,Key,null,null,false);
Initial Functions
public static AES256GCMDetachedBox CreateDetachedBox(Byte[] Message, Byte[] NoncePublic, Byte[] Key, Byte[] NonceSecurity = null, Byte[] AdditionalData = null,Boolean ClearKey=false)
public static Byte[] OpenDetachedBox(AES256GCMDetachedBox MyDetachedBox, Byte[] NoncePublic, Byte[] Key, Byte[] AdditionalData = null, Byte[] NonceSecurity = null,Boolean ClearKey=false)
public static Byte[] OpenDetachedBox(Byte[] CipherText, Byte[] MAC, Byte[] NoncePublic, Byte[] Key, Byte[] AdditionalData = null, Byte[] NonceSecurity = null,Boolean ClearKey=false)
Example Code
Byte[] Key = SodiumSecretAeadAES256GCM.GenerateKey();
Byte[] NoncePublic = SodiumSecretAeadAES256GCM.GeneratePublicNonce();
Byte[] Message = SodiumRNG.GetRandomBytes(32);
Byte[] CipherText = new Byte[] {};
Byte[] PlainText = new Byte[] {};
AES256GCMDetachedBox MyDetachedBox = SodiumSecretAeadAES256GCM.CreateDetachedBox(Message,NoncePublic,Key,null,null,false);
PlainText = SodiumSecretAeadAES256GCM.OpenDetachedBox(MyDetachedBox,NoncePublic,Key,null,null,false);
Initial functions
public static Byte[] InitializeState(Byte[] Key,Boolean ClearKey=false)
public static Byte[] Encrypt(Byte[] Message, Byte[] NoncePublic, Byte[] StateBytes, Byte[] AdditionalData = null, Byte[] NonceSecurity = null,Boolean ClearKey=false)
public static Byte[] Decrypt(Byte[] CipherText, Byte[] NoncePublic, Byte[] StateBytes, Byte[] AdditionalData = null, Byte[] NonceSecurity = null,Boolean ClearKey=false)
Example code
Byte[] Key = SodiumSecretAeadAES256GCM.GenerateKey();
Byte[] StateBytes = SodiumSecretAeadAES256GCMPC.InitializeState(Key);
Byte[] NoncePublic = SodiumSecretAeadAES256GCM.GeneratePublicNonce();
Byte[] Message = SodiumRNG.GetRandomBytes(32);
Byte[] CipherText = SodiumSecretAeadAES256GCMPC.Encrypt(Message,NoncePublic,StateBytes,null,null,false);
Byte[] PlainText = SodiumSecretAeadAES256GCMPC.Decrypt(CipherText,NoncePublic,StateBytes,null,null,false);
Initial functions
public static AES256GCMDetachedBox CreateDetachedBox(Byte[] Message, Byte[] NoncePublic, Byte[] StateBytes, Byte[] NonceSecurity = null, Byte[] AdditionalData = null,Boolean ClearKey=false)
public static Byte[] OpenDetachedBox(AES256GCMDetachedBox MyDetachedBox, Byte[] NoncePublic, Byte[] StateBytes, Byte[] AdditionalData = null, Byte[] NonceSecurity = null,Boolean ClearKey=false)
public static Byte[] OpenDetachedBox(Byte[] CipherText, Byte[] MAC, Byte[] NoncePublic, Byte[] StateBytes, Byte[] AdditionalData = null, Byte[] NonceSecurity = null,Boolean ClearKey=false)
Example Code
Byte[] Key = SodiumSecretAeadAES256GCM.GenerateKey();
Byte[] StateBytes = SodiumSecretAeadAES256GCMPC.InitializeState(Key);
Byte[] NoncePublic = SodiumSecretAeadAES256GCM.GeneratePublicNonce();
Byte[] Message = SodiumRNG.GetRandomBytes(32);
AES256GCMDetachedBox MyDetachedBox = SodiumSecretAeadAES256GCMPC.CreateDetachedBox(Message,NoncePublic,StateBytes);
Byte[] PlainText = SodiumSecretAeadAES256GCMPC.OpenDetachedBox(MyDetachedBox,NoncePublic,StateBytes);