# ne7ssh_string Class Reference

`#include <ne7ssh_string.h>`

Inheritance diagram for ne7ssh_string:

[legend]

List of all members.

## Public Member Functions
| ne7ssh_string ()
| ne7ssh_string (Botan::SecureVector< Botan::byte > &var, uint32 position)
| ne7ssh_string (const char *var, uint32 position)
virtual | ~ne7ssh_string ()
void | clear ()
void | addString (const char *str)
bool | addFile (const char *filename)
void | addBytes (const Botan::byte *buff, uint32 len)
void | addVector (Botan::SecureVector< Botan::byte > &secvec)
void | addVectorField (const Botan::SecureVector< Botan::byte > &vector)
void | addChar (const char ch)
void | addInt (const uint32 var)
void | addBigInt (const Botan::BigInt &bn)
virtual Botan::SecureVector < Botan::byte > & | value ()
uint32 | length ()
bool | getString (Botan::SecureVector< Botan::byte > &result)
bool | getBigInt (Botan::BigInt &result)
uint32 | getInt ()
Botan::byte | getByte ()
void | split (const char token)
void | resetParts ()
char * | nextPart ()
void | chop (uint32 nBytes)
## Static Public Member Functions
static void | bn2vector (Botan::SecureVector< Botan::byte > &result, const Botan::BigInt &bi)
## Protected Attributes
Botan::SecureVector< Botan::byte > | buffer
## Private Attributes
Botan::byte ** | positions
uint32 | parts
uint32 | currentPart

## Detailed Description

Author:
  Andrew Useckas

## Constructor & Destructor Documentation

ne7ssh_string::ne7ssh_string | ( |  | ) |

ne7ssh_string class default consturctor.

Zeros out 'positions' and 'parts'.

ne7ssh_string::ne7ssh_string | ( | Botan::SecureVector< Botan::byte > & | var,
|  | uint32 | position |
| ) |  |  |

ne7ssh_string class consturctor.

Takes a vector as an argument and places the data into 'buffer'.

Parameters:

  | var | Reference to a vector containing a string.
  | position | Position in the vector to start reading from. If '0', the entire vector is dumped into 'buffer'.

ne7ssh_string::ne7ssh_string | ( | const char * | var,
|  | uint32 | position |
| ) |  |  |

Same as above costructor, but instead of vector it works with a string (const char*).

Parameters:

  | var | Pointer to a string terminated by '/0'.
  | position | Read from this position onwards.

ne7ssh_string::~ne7ssh_string | ( |  | ) | `[virtual]`

ne7ssh_string class destructor.

## Member Function Documentation

void ne7ssh_string::addBigInt | ( | const Botan::BigInt & | bn | ) |

Adds a BigInt variable to the buffer.

BigInt is first converted to a vector, then the integer, representing length of the vector is converted to the network format. Converted ingeger is added to the buffer, followed by the vector.

Parameters:

  | bn | Reference to BigInt variable.

References bn2vector().

Referenced by ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::getDSAKeys(), ne7ssh_keys::getRSAKeys(), and ne7ssh_kex::sendKexDHInit().

void ne7ssh_string::addBytes | ( | const Botan::byte * | buff,
|  | uint32 | len |
| ) |  |  |

Adds a byte stream to the buffer.

Parameters:

  | buff | Pointer to the byte stream.
  | len | Length of the byte stream.

Referenced by Ne7sshSftpPacket::addInt64(), ne7ssh_kex::constructLocalKex(), ne7ssh_kex::handleInit(), and ne7ssh_transport::sendPacket().

void ne7ssh_string::addChar | ( | const char | ch | ) |

Adds a single character to the buffer.

Parameters:

  | ch | a single character.

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), ne7ssh_crypt::compute_key(), ne7ssh_kex::constructLocalKex(), ne7ssh_channel::execCmd(), ne7ssh_channel::getShell(), ne7ssh_channel::handleData(), Ne7sshSftp::init(), ne7ssh_channel::open(), ne7ssh_connection::requestService(), ne7ssh_channel::sendAdjustWindow(), ne7ssh_channel::sendAll(), ne7ssh_channel::sendClose(), ne7ssh_channel::sendEof(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), ne7ssh_transport::sendPacket(), Ne7sshSftpPacket::value(), and Ne7sshSftpPacket::valueFragment().

bool ne7ssh_string::addFile | ( | const char * | filename | ) |

Reads content of an ASCII file and appends it to the buffer.

Parameters:

  | filename | Full path to ASCII file.

Returns:
  True is file is successfully read. Otherwise False is returned.

References ne7ssh::errors(), and Ne7sshError::push().

Referenced by ne7ssh_keys::getKeyPairFromFile().

void ne7ssh_string::addInt | ( | const uint32 | var | ) |

Adds a single integer to the buffer.

Integer is converted to network format as required by SSH protocol specifications.

Parameters:

  | var | a single integer.

Referenced by ne7ssh_kex::constructLocalKex(), ne7ssh_channel::execCmd(), ne7ssh_channel::getShell(), Ne7sshSftp::handleNames(), Ne7sshSftp::init(), ne7ssh_channel::open(), ne7ssh_channel::sendAdjustWindow(), ne7ssh_channel::sendAll(), ne7ssh_channel::sendClose(), ne7ssh_channel::sendEof(), ne7ssh_transport::sendPacket(), Ne7sshSftpPacket::value(), and Ne7sshSftpPacket::valueFragment().

void ne7ssh_string::addString | ( | const char * | str | ) |

Adds a string to the buffer.

Adds an integer representing the length of the string, converted to the network format, before the actual string data. Required by SSH protocol specifications.

Parameters:

  | str | pointer to a string.

References value().

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), ne7ssh_kex::constructLocalKex(), ne7ssh_channel::execCmd(), ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::generateRSASignature(), ne7ssh_keys::getDSAKeys(), ne7ssh_keys::getRSAKeys(), ne7ssh_channel::getShell(), Ne7sshSftp::init(), ne7ssh_channel::open(), and ne7ssh_connection::requestService().

void ne7ssh_string::addVector | ( | Botan::SecureVector< Botan::byte > & | secvec | ) |

Adds a vector to the buffer.

Parameters:

  | secvec | Reference to the vector.

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_crypt::compute_key(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSASignature(), ne7ssh_crypt::getDSAKey(), ne7ssh_crypt::getRSAKey(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), ne7ssh_kex::handleKexDHReply(), ne7ssh_channel::handleReceived(), Ne7sshSftp::ls(), ne7ssh_kex::sendKexDHInit(), ne7ssh_transport::sendPacket(), Ne7sshSftpPacket::valueFragment(), and ne7ssh_channel::write().

void ne7ssh_string::addVectorField | ( | const Botan::SecureVector< Botan::byte > & | vector | ) |

Adds a vector to the buffer.

Adds an integer representing the length of the vector, converted to the network format, before the actual data. Required by SSH protocol specifications.

Parameters:

  | vector | Reference to a vector.

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_crypt::compute_key(), ne7ssh_kex::constructLocalKex(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSASignature(), Ne7sshSftp::handleNames(), ne7ssh_kex::makeH(), ne7ssh_channel::sendAll(), Ne7sshSftpPacket::value(), and Ne7sshSftpPacket::valueFragment().

void ne7ssh_string::bn2vector | ( | Botan::SecureVector< Botan::byte > & | result,
|  | const Botan::BigInt & | bi |
| ) |  |  | `[static]`

Converts BigInt into vector

For internal use only

Parameters:

  | result | Reference to vector where the converted result will be dumped.
  | bi | Reference to BigInt to convert.

Referenced by addBigInt(), ne7ssh_kex::handleKexDHReply(), ne7ssh_crypt::makeKexSecret(), and ne7ssh_kex::sendKexDHInit().

void ne7ssh_string::chop | ( | uint32 | nBytes | ) |

Chops bytes off of the end of the buffer.

Parameters:

  | nBytes | How many bytes to chop off the end of the buffer.

Referenced by ne7ssh_channel::handleData().

void ne7ssh_string::clear | ( |  | ) | `[inline]`

Zeros out the buffer

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), ne7ssh_crypt::compute_key(), ne7ssh_kex::constructLocalKex(), ne7ssh_channel::execCmd(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::getDSAKeys(), ne7ssh_keys::getRSAKeys(), ne7ssh_channel::getShell(), Ne7sshSftp::handleData(), ne7ssh_kex::handleInit(), ne7ssh_kex::handleKexDHReply(), Ne7sshSftp::handleSftpData(), Ne7sshSftp::init(), Ne7sshSftp::ls(), Ne7sshSftp::receiveUntil(), Ne7sshSftp::receiveWhile(), ne7ssh_channel::sendAll(), ne7ssh_kex::sendKexDHInit(), and ne7ssh_channel::write().

bool ne7ssh_string::getBigInt | ( | Botan::BigInt & | result | ) |

Extracts a single BigInt variable from the payload field of SSH packet.

Parameters:

  | result | Reference to a BigInt variable where the result will be stored.

Returns:
  True if BigInt field was found and successfully parsed, otherwise false is returned.

Referenced by ne7ssh_crypt::getDSAKey(), ne7ssh_crypt::getRSAKey(), and ne7ssh_kex::handleKexDHReply().

Botan::byte ne7ssh_string::getByte | ( |  | ) |

Extracts a single byte from tje payload field of SSH packet.

Returns:
  A byte extracted from thenext byte of the payload.

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), Ne7sshSftp::handleData(), ne7ssh_channel::handleReceived(), and ne7ssh_channel::handleRequest().

uint32 ne7ssh_string::getInt | ( |  | ) |

Extracts a single unsigned integer (uint32) from the payload field of SSH packet.

Returns:
  The integer extracted from the next 4 bytes of the payload.

Referenced by Ne7sshSftp::addOpenHandle(), ne7ssh_channel::adjustWindow(), ne7ssh_channel::handleChannelConfirm(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), ne7ssh_channel::handleExtendedData(), Ne7sshSftp::handleNames(), ne7ssh_channel::handleRequest(), Ne7sshSftp::handleSftpData(), Ne7sshSftp::handleStatus(), Ne7sshSftp::handleVersion(), and Ne7sshSftp::processAttrs().

bool ne7ssh_string::getString | ( | Botan::SecureVector< Botan::byte > & | result | ) |

Extracts a single string from the payload field of SSH packet.

Parameters:

  | result | Reference to a buffer where the result will be stored.

Returns:
  True if string field was found and successfully parsed, otherwise false is returned.

Referenced by Ne7sshSftp::addOpenHandle(), ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), ne7ssh_crypt::getDSAKey(), ne7ssh_crypt::getRSAKey(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), ne7ssh_channel::handleDisconnect(), ne7ssh_channel::handleExtendedData(), ne7ssh_kex::handleInit(), ne7ssh_kex::handleKexDHReply(), Ne7sshSftp::handleNames(), ne7ssh_channel::handleRequest(), Ne7sshSftp::handleSftpData(), Ne7sshSftp::handleStatus(), and ne7ssh_crypt::verifySig().

uint32 ne7ssh_string::length | ( |  | ) | `[inline]`

Returns current length of the buffer.

Returns:
  Length of the buffer.

Referenced by Ne7sshSftp::cd(), Ne7sshSftp::chmod(), Ne7sshSftp::chown(), ne7ssh_channel::data2Send(), Ne7sshSftp::getFileAttrs(), Ne7sshSftp::getFileStats(), ne7ssh_keys::getKeyPairFromFile(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), Ne7sshSftp::isType(), Ne7sshSftp::mkdir(), Ne7sshSftp::mv(), Ne7sshSftp::openDir(), Ne7sshSftp::openFile(), Ne7sshSftp::receiveUntil(), Ne7sshSftp::receiveWhile(), Ne7sshSftp::rm(), Ne7sshSftp::rmdir(), ne7ssh_channel::sendAll(), and ne7ssh_channel::write().

char * ne7ssh_string::nextPart | ( |  | ) |

Returns the next part.

Returns:
  NULL terminated string, or 0 if this is the last part.

Referenced by ne7ssh_crypt::agree(), and ne7ssh_kex::constructLocalKex().

void ne7ssh_string::resetParts | ( |  | ) | `[inline]`

Returns to the first part.

Referenced by ne7ssh_crypt::agree(), and ne7ssh_kex::constructLocalKex().

void ne7ssh_string::split | ( | const char | token | ) |

Splits the buffer into strings separated by null character.

Parameters:

  | token | Searches for this character in the buffer, replaces it with null and creates a part index.

Referenced by ne7ssh_crypt::agree(), and ne7ssh_kex::constructLocalKex().

virtual Botan::SecureVector<Botan::byte>& ne7ssh_string::value | ( |  | ) | `[inline, virtual]`

Returns the buffer as a vector.

Returns:
  Reference to the 'buffer' vector.

Reimplemented in Ne7sshSftpPacket.

Referenced by addString(), ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), Ne7sshSftp::cd(), Ne7sshSftp::chmod(), Ne7sshSftp::chown(), ne7ssh_crypt::compute_key(), ne7ssh_kex::constructLocalKex(), ne7ssh_channel::execCmd(), ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::generateRSASignature(), Ne7sshSftp::getFileAttrs(), Ne7sshSftp::getFileStats(), ne7ssh_keys::getKeyPairFromFile(), ne7ssh_keys::getPublicKeyBlob(), ne7ssh_channel::getReceived(), ne7ssh_channel::getShell(), Ne7sshSftp::handleData(), ne7ssh_kex::handleKexDHReply(), Ne7sshSftp::handleNames(), ne7ssh_channel::handleReceived(), Ne7sshSftp::init(), Ne7sshSftp::isType(), Ne7sshSftp::ls(), ne7ssh_kex::makeH(), Ne7sshSftp::mkdir(), Ne7sshSftp::mv(), ne7ssh_channel::open(), Ne7sshSftp::openDir(), Ne7sshSftp::openFile(), ne7ssh_connection::requestService(), Ne7sshSftp::rm(), Ne7sshSftp::rmdir(), ne7ssh_channel::sendAdjustWindow(), ne7ssh_channel::sendAll(), ne7ssh_channel::sendClose(), ne7ssh_channel::sendEof(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), ne7ssh_transport::sendPacket(), Ne7sshSftpPacket::value(), Ne7sshSftpPacket::valueFragment(), and ne7ssh_channel::write().

The documentation for this class was generated from the following files:

- ne7ssh_string.h
- ne7ssh_string.cpp