diff options
author | lloyd <[email protected]> | 2008-09-30 22:41:49 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-30 22:41:49 +0000 |
commit | 13d08cbe978c4cd0de01aa0120c39470508cbbcb (patch) | |
tree | ff93739131cbca0dbdf23a31cd4b7611faf5aa6e /src/bigint/big_io.cpp | |
parent | 8854fe339f2e1f81091ba65c042824e8cc62cbbc (diff) |
Rearrange BigInt directories:
math/bigint - BigInt implementation
math/numbertheory - Math stuff built on top of BigInt
Coming soon: math/gfp (parts of pk/ecdsa)
Update deps in the pk files
Diffstat (limited to 'src/bigint/big_io.cpp')
-rw-r--r-- | src/bigint/big_io.cpp | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/bigint/big_io.cpp b/src/bigint/big_io.cpp deleted file mode 100644 index 3c201e8b2..000000000 --- a/src/bigint/big_io.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/************************************************* -* BigInt Input/Output Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#include <botan/bigint.h> -#include <iostream> - -namespace Botan { - -/************************************************* -* Write the BigInt into a stream * -*************************************************/ -std::ostream& operator<<(std::ostream& stream, const BigInt& n) - { - BigInt::Base base = BigInt::Decimal; - if(stream.flags() & std::ios::hex) - base = BigInt::Hexadecimal; - else if(stream.flags() & std::ios::oct) - base = BigInt::Octal; - - if(n == 0) - stream.write("0", 1); - else - { - if(n < 0) - stream.write("-", 1); - SecureVector<byte> buffer = BigInt::encode(n, base); - u32bit skip = 0; - while(buffer[skip] == '0' && skip < buffer.size()) - ++skip; - stream.write(reinterpret_cast<const char*>(buffer.begin()) + skip, - buffer.size() - skip); - } - if(!stream.good()) - throw Stream_IO_Error("BigInt output operator has failed"); - return stream; - } - -/************************************************* -* Read the BigInt from a stream * -*************************************************/ -std::istream& operator>>(std::istream& stream, BigInt& n) - { - std::string str; - std::getline(stream, str); - if(stream.bad() || (stream.fail() && !stream.eof())) - throw Stream_IO_Error("BigInt input operator has failed"); - n = BigInt(str); - return stream; - } - -} |