From 80726182fb8ea0ba39be3d145a183972a004e31d Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 20 Nov 2009 15:36:10 +0000 Subject: Add an example of reading SSH2 public keys --- doc/examples/read_ssh.cpp | 119 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 doc/examples/read_ssh.cpp (limited to 'doc') diff --git a/doc/examples/read_ssh.cpp b/doc/examples/read_ssh.cpp new file mode 100644 index 000000000..a88306caa --- /dev/null +++ b/doc/examples/read_ssh.cpp @@ -0,0 +1,119 @@ +/* +* Example of reading SSH2 format public keys (see RFC 4716) +*/ + +#include +#include +#include +#include +#include +#include + +using namespace Botan; + +u32bit read_u32bit(Pipe& pipe) + { + byte out[4] = { 0 }; + pipe.read(out, 4); + u32bit len = load_be(out, 0); + if(len > 10000) + throw Decoding_Error("Huge size in read_u32bit, something went wrong"); + return len; + } + +std::string read_string(Pipe& pipe) + { + u32bit len = read_u32bit(pipe); + + std::string out(len, 'X'); + pipe.read(reinterpret_cast(&out[0]), len); + return out; + } + +BigInt read_bigint(Pipe& pipe) + { + u32bit len = read_u32bit(pipe); + + SecureVector buf(len); + pipe.read(&buf[0], len); + return BigInt::decode(buf); + } + +Public_Key* read_ssh_pubkey(const std::string& file) + { + std::ifstream in(file.c_str()); + + const std::string ssh_header = "---- BEGIN SSH2 PUBLIC KEY ----"; + const std::string ssh_trailer = "---- END SSH2 PUBLIC KEY ----"; + + std::string hex_bits; + + std::string line; + std::getline(in, line); + + if(line != ssh_header) + return 0; + + while(in.good()) + { + std::getline(in, line); + + if(line.find("Comment: ") == 0) + { + while(line[line.size()-1] == '\\') + std::getline(in, line); + std::getline(in, line); + } + + if(line == ssh_trailer) + break; + + hex_bits += line; + } + + Pipe pipe(new Base64_Decoder); + pipe.process_msg(hex_bits); + + std::string key_type = read_string(pipe); + + if(key_type != "ssh-rsa" && key_type != "ssh-dss") + return 0; + + if(key_type == "ssh-rsa") + { + BigInt e = read_bigint(pipe); + BigInt n = read_bigint(pipe); + return new RSA_PublicKey(n, e); + } + else if(key_type == "ssh-dss") + { + BigInt p = read_bigint(pipe); + BigInt q = read_bigint(pipe); + BigInt g = read_bigint(pipe); + BigInt y = read_bigint(pipe); + + return new DSA_PublicKey(DL_Group(p, q, g), y); + } + + return 0; + } + +#include +#include + +int main() + { + LibraryInitializer init; + + Public_Key* key = read_ssh_pubkey("dsa.ssh"); + + if(key == 0) + { + std::cout << "Failed\n"; + return 1; + } + + std::cout << X509::PEM_encode(*key); + + return 0; + } -- cgit v1.2.3 From a6959f2f276c4e6c679a0db810588b054caa15c2 Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 23 Nov 2009 15:04:06 +0000 Subject: Update version # to 1.9.4-dev --- configure.py | 6 +++--- doc/log.txt | 2 ++ readme.txt | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/configure.py b/configure.py index cd03bdf8b..7cb083adf 100755 --- a/configure.py +++ b/configure.py @@ -37,9 +37,9 @@ class BuildConfigurationInformation(object): """ version_major = 1 version_minor = 9 - version_patch = 3 - version_so_patch = 3 - version_suffix = '' + version_patch = 4 + version_so_patch = 4 + version_suffix = '-dev' version_string = '%d.%d.%d%s' % ( version_major, version_minor, version_patch, version_suffix) diff --git a/doc/log.txt b/doc/log.txt index 57c1a22a1..bd70c55ae 100644 --- a/doc/log.txt +++ b/doc/log.txt @@ -1,4 +1,6 @@ +* 1.9.4-dev, ????-??-?? + * 1.9.3, 2009-11-19 - Add new AES implementation using Intel's AES instruction intrinsics - Add an implementation of format preserving encryption diff --git a/readme.txt b/readme.txt index 4d13f7f1a..5f729b436 100644 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,4 @@ -Botan 1.9.3, 2009-11-19 +Botan 1.9.4-dev, ????-??-?? Botan is a C++ class library for performing a wide variety of cryptographic operations. -- cgit v1.2.3 From ec7a71f47d30f4c5b1a8ca29300ea3edb5e164cd Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 24 Nov 2009 00:40:52 +0000 Subject: Mention the Win32 build and installer improvements --- doc/log.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'doc') diff --git a/doc/log.txt b/doc/log.txt index bd70c55ae..c0c87028c 100644 --- a/doc/log.txt +++ b/doc/log.txt @@ -1,5 +1,7 @@ * 1.9.4-dev, ????-??-?? + - Greatly improve the Win32 installer + - Several fixes for Visual C++ debug builds * 1.9.3, 2009-11-19 - Add new AES implementation using Intel's AES instruction intrinsics -- cgit v1.2.3