AES192_Update 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 abData As Byte, ByVal nDataLen As Long) As Long
nRet = AES192_Update(hContext, abData(0), nDataLen)
Long handle to the AES context set up by an earlier call to
AES192_Init or AES192_InitHex.Byte array containing the input
to be processed by the AES function and to receive the output.Long containing length of the data in bytes.
long _stdcall AES192_Update(long ctx_handle, unsigned char *data, long dataLen);
Long: If successful, the return value is 0;
otherwise it returns a non-zero error code.
Aes192.Update Method (Byte[])
The input array abData 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