IPWorks Encrypt 2020 Delphi Edition

Questions / Feedback?

Poly1305 Component

Properties   Methods   Events   Configuration Settings   Errors  

The Poly1305 component may be used to produce a MAC (or Tag) value using the Poly1305 algorithm.

Syntax

TipcPoly1305

Remarks

The Poly1305 component implements the Poly1305 algorithm defined in RFC 7539. This may be used to compute a MAC (or Tag) value on data of any length.

The Key must be set to a 256 bit (32 byte) key before computing the MAC. The computed MAC is 128 bit (32 bytes) in size.

ComputeMAC Notes

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 component 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);

ComputeMACBlock Notes

ComputeMACBlock allows input to the component 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);

Property List


The following is the full list of the properties of the component with short descriptions. Click on the links for further details.

EncodeMACWhether the MAC value is hex encoded.
InputFileThe file to process.
InputMessageThe message to process.
KeyThe 256 bit (32 byte) key to be used when computing a MAC (Message Authentication Code).
MACValueThe computed MAC value.

Method List


The following is the full list of the methods of the component with short descriptions. Click on the links for further details.

ComputeMACComputes the MAC.
ComputeMACBlockComputes the MAC value of specified data.
ConfigSets or retrieves a configuration setting.
ResetResets the component.
SetInputStreamSets the stream from which the component will read data.

Event List


The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.

ErrorInformation about errors during data delivery.
ProgressFired as progress is made.

Configuration Settings


The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.

CloseInputStreamAfterProcessingDetermines whether or not the input stream is closed after processing.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
UseInternalSecurityAPITells the component whether or not to use the system security libraries or an internal implementation.

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