[VB6 equivalent: GCM_Encrypt]
Dim abKey() As Byte Dim abPlain() As Byte Dim abAAD() As Byte Dim abIV() As Byte Dim abTag() As Byte Dim abCipher() As Byte Dim abCheck() As Byte ' Test Case 4: ' Convert test vectors from hex to byte array format abKey = Cnv.FromHex("feffe9928665731c6d6a8f9467308308") abPlain = Cnv.FromHex("d9313225f88406e5a55909c5aff5269a" & _ "86a7a9531534f7da2e4c303d8a318a72" & _ "1c3c0c95956809532fcf0e2449a6b525" & _ "b16aedf5aa0de657ba637b39") abAAD = Cnv.FromHex("feedfacedeadbeeffeedfacedeadbeef" & _ "abaddad2") abIV = Cnv.FromHex("cafebabefacedbaddecaf888") ' and compute lengths ' Dimension output arrays abTag = New Byte(15) {} ' Do the business abCipher = Gcm.Encrypt(abTag, abPlain, abKey, abIV, abAAD) Console.WriteLine("GCM_Encrypt:") Console.WriteLine("CT =" & Cnv.ToHex(abCipher)) Console.WriteLine("TAG=" & Cnv.ToHex(abTag)) ' Check we can decrypt abCheck = Gcm.Decrypt(abCipher, abKey, abIV, abAAD, abTag) Console.WriteLine("GCM_Decrypt:") Console.WriteLine("PT'=" & Cnv.ToHex(abCheck)) Console.WriteLine("PT =" & Cnv.ToHex(abPlain))
See Also:
Gcm.Encrypt Method - @superseded