aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/read_ssh.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-12-21 13:51:05 +0000
committerlloyd <[email protected]>2009-12-21 13:51:05 +0000
commit75f32d61c6a78e4e63cfadd084730f20b5896493 (patch)
tree4a52d3009f012ec5761f1c1218e18efbe07eef0b /doc/examples/read_ssh.cpp
parentf3f36611db8c3f6c67c818d454973a0165b0fcf2 (diff)
Un-internal loadstor.h (and its header deps, rotate.h and
bswap.h); too many external apps rely on loadstor.h existing. Define 64-bit generic bswap in terms of 32-bit bswap, since it's not much slower if 32-bit is also generic, and much faster if it's not. This may be quite helpful on 32-bit x86 in particular. Change formulation of generic 32-bit bswap. It may be faster or slower depending on the CPU, especially the latency and throuput of rotate instructions, but should be faster on an ideally superscalar processor with rotate instructions (ie, what I expect future CPUs to look more like).
Diffstat (limited to 'doc/examples/read_ssh.cpp')
-rw-r--r--doc/examples/read_ssh.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/doc/examples/read_ssh.cpp b/doc/examples/read_ssh.cpp
index 4d9050a31..a88306caa 100644
--- a/doc/examples/read_ssh.cpp
+++ b/doc/examples/read_ssh.cpp
@@ -5,24 +5,17 @@
#include <fstream>
#include <botan/x509_key.h>
#include <botan/filters.h>
+#include <botan/loadstor.h>
#include <botan/rsa.h>
#include <botan/dsa.h>
using namespace Botan;
-inline u32bit make_u32bit(byte i0, byte i1, byte i2, byte i3)
- {
- return ((static_cast<u32bit>(i0) << 24) |
- (static_cast<u32bit>(i1) << 16) |
- (static_cast<u32bit>(i2) << 8) |
- (static_cast<u32bit>(i3)));
- }
-
u32bit read_u32bit(Pipe& pipe)
{
- byte sz[4] = { 0 };
- pipe.read(sz, 4);
- u32bit len = make_u32bit(sz[0], sz[1], sz[2], sz[3]);
+ byte out[4] = { 0 };
+ pipe.read(out, 4);
+ u32bit len = load_be<u32bit>(out, 0);
if(len > 10000)
throw Decoding_Error("Huge size in read_u32bit, something went wrong");
return len;