#include <ne7ssh_keys.h>
Public Types | |
enum | keyAlgos { DSA, RSA } |
Public Member Functions | |
ne7ssh_keys () | |
~ne7ssh_keys () | |
bool | generateDSAKeys (const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048) |
bool | generateRSAKeys (const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048) |
bool | getKeyPairFromFile (const char *privKeyFileName) |
Botan::SecureVector < Botan::byte > & | generateSignature (Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData) |
Botan::SecureVector< Botan::byte > | generateDSASignature (Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData) |
Botan::SecureVector< Botan::byte > | generateRSASignature (Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData) |
Botan::SecureVector < Botan::byte > & | getPublicKeyBlob () |
uint8 | getKeyAlgo () |
Private Member Functions | |
bool | getDSAKeys (char *buffer, uint32 size) |
bool | getRSAKeys (char *buffer, uint32 size) |
Private Attributes | |
Botan::DSA_PrivateKey * | dsaPrivateKey |
Botan::RSA_PrivateKey * | rsaPrivateKey |
ne7ssh_string | publicKeyBlob |
Botan::SecureVector< Botan::byte > | signature |
uint8 | keyAlgo |
ne7ssh_keys::ne7ssh_keys | ( | ) |
ne7ssh_keys constructor.
ne7ssh_keys::~ne7ssh_keys | ( | ) |
ne7ssh_keys destructor.
bool ne7ssh_keys::generateDSAKeys | ( | const char * | fqdn, | |
const char * | privKeyFileName, | |||
const char * | pubKeyFileName, | |||
uint16 | keySize = 2048 | |||
) |
Generates DSA Key pair and saves keys in specified files.
fqdn | User id. Usually an Email. For example "test@netsieben.com" | |
privKeyFileName | Full path to a file where generated private key should be written. | |
pubKeyFileName | Full path to a file where generated public key should be written. | |
keySize | Desired key size in bits. If not specified will default to 2048. |
References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().
Referenced by ne7ssh::generateKeyPair().
SecureVector< Botan::byte > ne7ssh_keys::generateDSASignature | ( | Botan::SecureVector< Botan::byte > & | sessionID, | |
Botan::SecureVector< Botan::byte > & | signingData | |||
) |
Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before.
sessionID | SSH2 SessionID. | |
signingData | Packet data to sign. |
References ne7ssh_string::addString(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh_string::clear(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().
Referenced by generateSignature().
bool ne7ssh_keys::generateRSAKeys | ( | const char * | fqdn, | |
const char * | privKeyFileName, | |||
const char * | pubKeyFileName, | |||
uint16 | keySize = 2048 | |||
) |
Generates RSA Key pair and saves keys in specified files.
fqdn | User id. Usually an Email. For example "test@netsieben.com" | |
privKeyFileName | Full path to a file where generated private key should be written. | |
pubKeyFileName | Full path to a file where generated public key should be written. | |
keySize | Desired key size in bits. If not specified will default to 2048. |
References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().
Referenced by ne7ssh::generateKeyPair().
SecureVector< Botan::byte > ne7ssh_keys::generateRSASignature | ( | Botan::SecureVector< Botan::byte > & | sessionID, | |
Botan::SecureVector< Botan::byte > & | signingData | |||
) |
Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before.
sessionID | SSH2 SessionID. | |
signingData | Packet data to sign. |
References ne7ssh_string::addString(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().
Referenced by generateSignature().
SecureVector< Botan::byte > & ne7ssh_keys::generateSignature | ( | Botan::SecureVector< Botan::byte > & | sessionID, | |
Botan::SecureVector< Botan::byte > & | signingData | |||
) |
Generates a SHA-1 signature from sessionID and packet data provided.
Determines key type and passed the processing either to generateDSASignature() or generateRSAKeys() functions.
sessionID | SSH2 SessionID. | |
signingData | Packet data to sign. |
References generateDSASignature(), and generateRSASignature().
Referenced by ne7ssh_connection::authWithKey().
bool ne7ssh_keys::getDSAKeys | ( | char * | buffer, | |
uint32 | size | |||
) | [private] |
Extracts DSA key pair from a PEM encoded stream.
buffer | PEM encoded string. | |
size | Length of the stream. |
References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), and Ne7sshError::push().
Referenced by getKeyPairFromFile().
uint8 ne7ssh_keys::getKeyAlgo | ( | ) | [inline] |
Returns type of initialized keys.
Referenced by ne7ssh_connection::authWithKey().
bool ne7ssh_keys::getKeyPairFromFile | ( | const char * | privKeyFileName | ) |
Extracts key pair from a PEM encoded file.
Reads the file and determines the type of key, then passes processing to either getDsaKeys() or getRSAKeys(*) functions.
privKeyFileName | Full path to PEM encoded file. |
References ne7ssh_string::addFile(), ne7ssh::errors(), getDSAKeys(), getRSAKeys(), ne7ssh_string::length(), Ne7sshError::push(), and ne7ssh_string::value().
Referenced by ne7ssh_connection::authWithKey().
SecureVector< Botan::byte > & ne7ssh_keys::getPublicKeyBlob | ( | ) |
After key pair has been initialized, this function returns public key blob, as specified by SSH2 specs.
References ne7ssh_string::value().
Referenced by ne7ssh_connection::authWithKey().
bool ne7ssh_keys::getRSAKeys | ( | char * | buffer, | |
uint32 | size | |||
) | [private] |
Extracts RSA key pair from a PEM encoded stream.
buffer | PEM encoded string. | |
size | Length of the stream. |
References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), and Ne7sshError::push().
Referenced by getKeyPairFromFile().