ComputeMACBlock Method
Computes the MAC value of specified data.
Syntax
ANSI (Cross Platform) char* ComputeMACBlock(const char* lpInputBuffer, int lenInputBuffer, int bLastBlock, int *lpSize = NULL); Unicode (Windows) LPSTR ComputeMACBlock(LPCSTR lpInputBuffer, INT lenInputBuffer, BOOL bLastBlock, LPINT lpSize = NULL);
- (NSData*)computeMACBlock:(NSData*)inputBuffer :(BOOL)lastBlock;
#define MID_POLY1305_COMPUTEMACBLOCK 3 IPWORKSENCRYPT_EXTERNAL int IPWORKSENCRYPT_CALL IPWorksEncrypt_Poly1305_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);
Remarks
ComputeMACBlock allows input to the class to be specified in blocks. This method will return the MAC value only when the parameter LastBlock is True.
InputBuffer specifies the input data.
LastBlock specifies whether the block is the last block. If this is False the method will return an empty byte array.
To calculate the MAC value of data that is broken apart into multiple blocks make multiple calls to this method. For instance:
//Encode output in hex poly1305.EncodeMAC = true; //hex output //Pass any number of parts, of any size poly1305.ComputeMACBlock(part1,false); poly1305.ComputeMACBlock(part2,false); poly1305.ComputeMACBlock(part3,false); //Pass true for the last block poly1305.ComputeMACBlock(lastPart,true); //The MACValue property holds the MAC value Console.WriteLine(poly1305.MACValue);
Error Handling (C++)
This method returns a Binary String value (with length lpSize); after it returns, call the GetLastErrorCode() method to obtain its 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.