Carries out the AES transformation function on a byte array
according to the direction
and mode set up by an earlier call to AES192_Init() or AES192_InitHex().
Public Declare Function AES192_Update Lib "diCryptoSys.dll"
(ByVal hContext As Long, ByRef lpData As Byte, ByVal nDataLen As Long) As Long
nRet = AES192_Update(hContext, abData(0), nDataLen)
long __stdcall AES192_Update(long hContext, unsigned char *lpData, long nDataLen);
AES192_Init() or AES192_InitHex().If successful, the return value is 0; otherwise it returns a non-zero error code.
Aes192.Update Method (Byte[])
The input array lpData must be a multiple of the block size of 16 bytes long. If not, an error code will be returned. Note that the output overwrites the input.
This example carries out the third (I=2) Monte Carlo MOVS test in CBC encrypt mode. (Ref: AES Candidate Algorithm Submissions, update 17 Feb 1998, file cbc_e_m.txt [RIJNVALS]).
Dim nRet As Long
Dim hContext As Long
Dim abBlock() As Byte
Dim abKey() As Byte
Dim abCorrect() As Byte
Dim j As Integer
' File: ecb_d_m.txt
' KEYSIZE=192 I=2
' KEY=EF334C87288C43DE84E276D5CCD586228C8EA3A264D2DB0E
' CT=CC01684BE9B29ED01EA7923E7D2380AA
' PT=8726B4E66D6B8FBAA22D42981A5A40CC
' Convert to Byte format
abKey = cnvBytesFromHexStr("EF334C87288C43DE84E276D5CCD586228C8EA3A264D2DB0E")
abBlock = cnvBytesFromHexStr("CC01684BE9B29ED01EA7923E7D2380AA")
abCorrect = cnvBytesFromHexStr("8726B4E66D6B8FBAA22D42981A5A40CC")
Debug.Print "AES Monte Carlo ECB Mode Decrypt:"
Debug.Print "KY=" & cnvHexStrFromBytes(abKey)
Debug.Print "CT=" & cnvHexStrFromBytes(abBlock)
hContext = AES192_Init(abKey(0), DECRYPT, "ECB", 0)
If hContext = 0 Then
MsgBox "Failed to set context", vbCritical
Exit Function
End If
' Do 10,000 times
For j = 0 To 9999
nRet = AES192_Update(hContext, abBlock(0), 16)
Next
Debug.Print "PT=" & cnvHexStrFromBytes(abBlock)
Debug.Print "OK=" & cnvHexStrFromBytes(abCorrect)
nRet = AES192_Final(hContext)
Debug.Assert (StrConv(abCorrect, vbUnicode) = StrConv(abBlock, vbUnicode))
This should result in output as follows:
AES Monte Carlo ECB Mode Decrypt: KY=EF334C87288C43DE84E276D5CCD586228C8EA3A264D2DB0E CT=CC01684BE9B29ED01EA7923E7D2380AA PT=8726B4E66D6B8FBAA22D42981A5A40CC OK=8726B4E66D6B8FBAA22D42981A5A40CC
AES192_Init
AES192_InitHex
AES192_UpdateHex
AES192_Final