CryptoSys API Library Manual

TDEA_UpdateHex

Carries out the TDEA transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to TDEA_Init() or TDEA_InitHex().

VBA/VB6 Syntax

Public Declare Function TDEA_UpdateHex Lib "diCryptoSys.dll" (ByVal hContext As Long, ByVal strHexString As String) As Long

nRet = TDEA_UpdateHex(hContext, strHexString)

C/C++ Syntax

long __stdcall TDEA_UpdateHex(long hContext, char *szHexData);

Parameters

hContext
[in] handle to the TDEA context set up by an earlier call to TDEA_Init() or TDEA_InitHex().
szHexData
[in,out] containing input in hexadecimal format to be processed by the TDEA function and to receive the output.

Returns (VBA/C)

If successful, the return value is 0; otherwise it returns a non-zero error code.

.NET Equivalent

Tdea.Update Method (String)

Remarks

szHexString must be a multiple of 16 hex characters long (i.e. representing a multiple of 8 bytes). If not, an error code will be returned. Valid hexadecimal characters are [0-9A-Fa-f]. Note that the output overwrites the input. szHexString must be a variable that can receive the output, not a constant.

Example

    Dim nRet As Long
    Dim hContext As Long
    Dim sBlock As String
    Dim strKey As String
    Dim strIV As String
    Dim sNext As String
    Dim sLast As String
    Dim sCorrect As String
    Dim j As Integer

    sBlock = "4e6f772069732074"
    strKey = "0123456789abcdef" & _
            "23456789abcdef01" & _
            "456789abcdef0123"
    strIV = "1234567890abcdef"
    sCorrect = "cb191f85d1ed8439"

    Debug.Print "TDEA Monte Carlo TCBC Mode Encrypt:"
    Debug.Print "KY=" & strKey
    Debug.Print "IV=" & strIV
    Debug.Print "PT=" & sBlock

    hContext = TDEA_InitHex(strKey, True, "CBC", strIV)
    If hContext = 0 Then
        Exit Function
    End If
    ' Do 10,000 times
    sNext = sBlock
    For j = 0 To 9999
        sBlock = sNext
        nRet = TDEA_UpdateHex(hContext, sBlock)
        If j = 0 Then
            sNext = strIV
        Else
            sNext = sLast
        End If
        sLast = sBlock
    Next
    Debug.Print "CT=" & sBlock
    Debug.Print "OK=" & sCorrect
    nRet = TDEA_Final(hContext)

This should result in output as follows:

TDEA Monte Carlo TCBC Mode Encrypt:
KY=0123456789abcdef23456789abcdef01456789abcdef0123
IV=1234567890abcdef
PT=4e6f772069732074
CT=CB191F85D1ED8439
OK=cb191f85d1ed8439

See Also

TDEA_Init TDEA_InitHex TDEA_Update TDEA_Final

[Contents] [Index]

[PREV: TDEA_Update...]   [Contents]   [Index]   
   [NEXT: WIPE_Data...]

Copyright © 2001-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-01-07T07:42:00Z.