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.
EncodeMAC | Whether the MAC value is hex encoded. |
InputFile | The file to process. |
InputMessage | The message to process. |
Key | The 256 bit (32 byte) key to be used when computing a MAC (Message Authentication Code). |
MACValue | The 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.
ComputeMAC | Computes the MAC. |
ComputeMACBlock | Computes the MAC value of specified data. |
Config | Sets or retrieves a configuration setting. |
Reset | Resets the component. |
SetInputStream | Sets 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.
Error | Information about errors during data delivery. |
Progress | Fired 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.
CloseInputStreamAfterProcessing | Determines whether or not the input stream is closed after processing. |
BuildInfo | Information about the product's build. |
CodePage | The system code page used for Unicode to Multibyte translations. |
LicenseInfo | Information about the current license. |
UseInternalSecurityAPI | Tells the component whether or not to use the system security libraries or an internal implementation. |