IPWorks Encrypt 2020 C++ Edition

Questions / Feedback?

ComputeMAC Method

Computes the MAC.

Syntax

ANSI (Cross Platform)
int ComputeMAC();

Unicode (Windows)
INT ComputeMAC();
- (void)computeMAC;
#define MID_POLY1305_COMPUTEMAC 2

IPWORKSENCRYPT_EXTERNAL int IPWORKSENCRYPT_CALL IPWorksEncrypt_Poly1305_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

Remarks

ComputeMAC computes the MAC (Message Authentication Code) from the input data.

Before calling this method set Key to a 256 bit (32 byte) key. If EncodeMAC is set to True (default) the output data will be hex encoded.

Input Notes

The class will determine the source of the input based on which properties are set.

The order in which the input properties are checked are as follows:

When a valid source is found the search stops.

After calling this method MACValue will be populated with the computed 128 bit (16 byte) value.

ComputeMAC Example


Poly1305 poly1305 = new Poly1305();
poly1305.KeyB = new byte[] { 0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a, 0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0, 0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09, 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0 };
poly1305.InputMessage = "Hello Polly";
poly1305.EncodeMAC = true; //hex output
poly1305.ComputeMAC();

//This outputs "113019A3ACF5ED2FBB7A45AC1FD67DA1"
Console.WriteLine(poly1305.MACValue);

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Encrypt 2020 C++ Edition - Version 20.0 [Build 8155]