C# Class dlech.SshAgentLib.Util

PageantSharp utility class.
Show file Open project: dlech/SshAgentLib

Public Methods

Method Description
ClearByteList ( List list ) : void

writes over all values in list with 0 then call list.Clear()

FromBase64 ( byte base64Data ) : byte[]
FromBase64 ( string base64String ) : byte[]
FromHex ( string base16String ) : byte[]

converts string of hexadecimal characters to a byte[] two characters are converted into one byte

FromHex ( string base16String, string delimeter ) : byte[]

converts string of hexadecimal characters to a byte[] two characters are converted into one byte

GetDataType ( this aConstraint ) : Type

Gets the Type of the Data object for a given Agent.KeyConstraintType

ModMinusOne ( PinnedArray a, PinnedArray b ) : PinnedArray

Computes a % (b -1) of 2 large numbers

ToBase64 ( this binaryData ) : byte[]
ToBytes ( this aInt ) : byte[]

Convert 32 bit integer to four bytes in BigEndian order

ToHexString ( this bytes ) : string

Converts array of bytes to a string of hexadecimal digits delimited by':'. Alpha digits will be lower case.

ToHexString ( this bytes, string delimeter ) : string

Converts array of bytes to a string of hexadecimal digits. Alpha digits will be lower case.

ToInt ( this aBytes ) : UInt32

Converts 4 bytes in BigEndian order to 32 bit integer

ToInt ( this aBytes, int aOffset ) : UInt32

Converts 4 bytes in BigEndian order to 32 bit integer

TrimLeadingZero ( PinnedArray array ) : void

removes leading element from array if the value of that element is 0

UnicodeToAnsi ( this unicodeChar ) : byte

Unicode char to to ANSI char.

Based on http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit1252.txt

WriteBlob ( this aStream, BlobBuilder aBuilder ) : void

Writes aBuiler data to aStream at current position of aStream

addConfirmConstraint ( this aKeyCollection ) : void

Adds Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_CONFIRM constraint to key

addLifetimeConstraint ( this aKeyCollection, uint aLifetime ) : void

Adds Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_LIFETIME constraint to key

Private Methods

Method Description
CompareBigInt ( byte a, byte b, int bShift ) : int

Compares to BigInts

GenericTransform ( ICryptoTransform transform, byte data ) : byte[]
SubtractBigInt ( byte a, byte b, int bShift ) : byte[]

Compute a - b, assumes that a > b<<bShift

Method Details

ClearByteList() public static method

writes over all values in list with 0 then call list.Clear()
public static ClearByteList ( List list ) : void
list List list to be cleared
return void

FromBase64() public static method

public static FromBase64 ( byte base64Data ) : byte[]
base64Data byte
return byte[]

FromBase64() public static method

public static FromBase64 ( string base64String ) : byte[]
base64String string
return byte[]

FromHex() public static method

converts string of hexadecimal characters to a byte[] two characters are converted into one byte
thrown if base16String is null or empty thrown if base16String does not contain an even number of characters /// or if the characters are not hexadecimal digits (0-9 and A-F or a-f)
public static FromHex ( string base16String ) : byte[]
base16String string the string to convert
return byte[]

FromHex() public static method

converts string of hexadecimal characters to a byte[] two characters are converted into one byte
thrown if base16String is null or empty thrown if base16String does not contain an even number of characters /// or if the characters are not hexadecimal digits (0-9 and A-F or a-f)
public static FromHex ( string base16String, string delimeter ) : byte[]
base16String string the string to convert
delimeter string the delimiter that is present between each pair of digits
return byte[]

GetDataType() public static method

Gets the Type of the Data object for a given Agent.KeyConstraintType
public static GetDataType ( this aConstraint ) : Type
aConstraint this
return System.Type

ModMinusOne() public static method

Computes a % (b -1) of 2 large numbers
public static ModMinusOne ( PinnedArray a, PinnedArray b ) : PinnedArray
a PinnedArray variable a
b PinnedArray variable b
return PinnedArray

ToBase64() public static method

public static ToBase64 ( this binaryData ) : byte[]
binaryData this
return byte[]

ToBytes() public static method

Convert 32 bit integer to four bytes in BigEndian order
public static ToBytes ( this aInt ) : byte[]
aInt this integer to convert
return byte[]

ToHexString() public static method

Converts array of bytes to a string of hexadecimal digits delimited by':'. Alpha digits will be lower case.
public static ToHexString ( this bytes ) : string
bytes this the byte[] to convert
return string

ToHexString() public static method

Converts array of bytes to a string of hexadecimal digits. Alpha digits will be lower case.
public static ToHexString ( this bytes, string delimeter ) : string
bytes this the byte[] to convert
delimeter string a delimiter to insert in-between each pair of digits
return string

ToInt() public static method

Converts 4 bytes in BigEndian order to 32 bit integer
public static ToInt ( this aBytes ) : UInt32
aBytes this array of bytes
return System.UInt32

ToInt() public static method

Converts 4 bytes in BigEndian order to 32 bit integer
public static ToInt ( this aBytes, int aOffset ) : UInt32
aBytes this array of bytes
aOffset int the offset where to start reading the bytes
return System.UInt32

TrimLeadingZero() public static method

removes leading element from array if the value of that element is 0
public static TrimLeadingZero ( PinnedArray array ) : void
array PinnedArray
return void

UnicodeToAnsi() public static method

Unicode char to to ANSI char.
Based on http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit1252.txt
public static UnicodeToAnsi ( this unicodeChar ) : byte
unicodeChar this /// Unicode char. ///
return byte

WriteBlob() public static method

Writes aBuiler data to aStream at current position of aStream
public static WriteBlob ( this aStream, BlobBuilder aBuilder ) : void
aStream this Stream to write to
aBuilder BlobBuilder BlobBuilder to use
return void

addConfirmConstraint() public static method

Adds Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_CONFIRM constraint to key
public static addConfirmConstraint ( this aKeyCollection ) : void
aKeyCollection this
return void

addLifetimeConstraint() public static method

Adds Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_LIFETIME constraint to key
public static addLifetimeConstraint ( this aKeyCollection, uint aLifetime ) : void
aKeyCollection this
aLifetime uint
return void