C# Class Gurux.DLMS.Secure.GXDLMSChipperingStream

Implements GMAC. This class is based to this doc: http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf
Mostra file Open project: Gurux/Gurux.DLMS.Net Class Usage Examples

Public Methods

Method Description
FlushFinalBlock ( ) : byte[]

Process encrypting/decrypting.

GXDLMSChipperingStream ( Gurux security, bool encrypt, byte blockCipherKey, byte aad, byte iv, byte tag ) : System

Constructor.

GXDLMSChipperingStream ( bool encrypt, byte kek ) : System

Constructor.

GetTag ( ) : byte[]

Get tag from crypted data.

Write ( byte input ) : void

Write bytes to decrypt/encrypt.

Private Methods

Method Description
BEToUInt32 ( byte buff, int offset ) : uint

Convert Big Endian byte array to Little Endian UInt 32.

DecryptAes ( byte input ) : byte[]

Decrypt data using AES RFC3394.

DecryptBlock ( uint key ) : void
EncryptAes ( byte data ) : byte[]

Encrypt data using AES RFC3394.

EncryptBlock ( uint key ) : void

Encrypt data block.

GenerateKey ( bool encrypt, byte key ) : ].uint[

Generate AES keys.

GetGHash ( byte b ) : byte[]

The GF(2128) field used is defined by the polynomial x^{128}+x^7+x^2+x+1. The authentication tag is constructed by feeding blocks of data into the GHASH function, and encrypting the result.

GetUInt32 ( uint value, byte data, int offset ) : void

Get bytes from UIn32.

GetUint128 ( byte buff ) : uint[]

Get Uint 128 as array of UInt32.

ImixCol ( uint x ) : uint
Init ( byte H ) : void
MultiplyH ( byte value ) : void
MultiplyP ( uint x ) : void
MultiplyP8 ( uint x ) : void
PackBlock ( byte bytes, int offset ) : void
ProcessBlock ( byte input, int inOffset, byte output, int outOffset ) : int
Reset ( ) : void

Reset

SetPackLength ( ulong length, byte buff, int offset ) : void

Set packet length to byte array.

Shift ( UInt32 value, int shift ) : UInt32

Shift value.

ShiftRight ( uint block, int count ) : void

Shift block to right.

StarX ( uint value ) : uint

Initialise the key schedule from the user supplied key.

SubWord ( uint value ) : UInt32
TagsEquals ( byte tag1, byte tag2 ) : bool

Are tags equals.

ToUInt32 ( byte value, int offset ) : UInt32

Convert byte array to Little Endian.

UInt32_To_BE ( uint value, byte buff, int offset ) : void

Convert uint32 to Big Endian byte array.

UnPackBlock ( byte bytes, int offset ) : void
Xor ( byte block, byte value ) : void

Make Xor for 128 bits.

Xor ( uint block, uint value ) : void

Make Xor for 128 bits.

gCTRBlock ( byte buf, int bufCount ) : void

Method Details

FlushFinalBlock() public method

Process encrypting/decrypting.
public FlushFinalBlock ( ) : byte[]
return byte[]

GXDLMSChipperingStream() public method

Constructor.
public GXDLMSChipperingStream ( Gurux security, bool encrypt, byte blockCipherKey, byte aad, byte iv, byte tag ) : System
security Gurux Used security level.
encrypt bool
blockCipherKey byte
aad byte
iv byte
tag byte
return System

GXDLMSChipperingStream() public method

Constructor.
public GXDLMSChipperingStream ( bool encrypt, byte kek ) : System
encrypt bool
kek byte Key Encrypting Key, also known as Master key.
return System

GetTag() public method

Get tag from crypted data.
public GetTag ( ) : byte[]
return byte[]

Write() public method

Write bytes to decrypt/encrypt.
public Write ( byte input ) : void
input byte
return void