aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/bigint
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-03-30 18:27:18 +0000
committerlloyd <[email protected]>2009-03-30 18:27:18 +0000
commit96d6eb6f29c55e16a37cf11899547886f735b065 (patch)
tree9f13901e9b44c98d58b2589c9b09c6a7443eb7cd /src/math/bigint
parent3cc3dd72c5f87b76852a55c1f2d1821dba967d8c (diff)
Thomas Moschny passed along a request from the Fedora packagers which came
up during the Fedora submission review, that each source file include some text about the license. One handy Perl script later and each file now has the line Distributed under the terms of the Botan license after the copyright notices. While I was in there modifying every file anyway, I also stripped out the remainder of the block comments (lots of astericks before and after the text); this is stylistic thing I picked up when I was first learning C++ but in retrospect it is not a good style as the structure makes it harder to modify comments (with the result that comments become fewer, shorter and are less likely to be updated, which are not good things).
Diffstat (limited to 'src/math/bigint')
-rw-r--r--src/math/bigint/big_code.cpp40
-rw-r--r--src/math/bigint/big_io.cpp22
-rw-r--r--src/math/bigint/big_ops2.cpp58
-rw-r--r--src/math/bigint/big_ops3.cpp58
-rw-r--r--src/math/bigint/big_rand.cpp28
-rw-r--r--src/math/bigint/bigint.cpp178
-rw-r--r--src/math/bigint/bigint.h36
-rw-r--r--src/math/bigint/divide.cpp22
-rw-r--r--src/math/bigint/divide.h10
-rw-r--r--src/math/bigint/monty_generic/mp_monty.cpp18
-rw-r--r--src/math/bigint/mp_amd64/mp_asm.h30
-rw-r--r--src/math/bigint/mp_amd64/mp_asmi.h84
-rw-r--r--src/math/bigint/mp_asm.cpp60
-rw-r--r--src/math/bigint/mp_asm64/mp_asm.h22
-rw-r--r--src/math/bigint/mp_comba.cpp58
-rw-r--r--src/math/bigint/mp_core.h64
-rw-r--r--src/math/bigint/mp_generic/mp_asm.h24
-rw-r--r--src/math/bigint/mp_generic/mp_asmi.h78
-rw-r--r--src/math/bigint/mp_ia32/mp_asm.h30
-rw-r--r--src/math/bigint/mp_ia32/mp_asmi.h84
-rw-r--r--src/math/bigint/mp_ia32_msvc/mp_asmi.h78
-rw-r--r--src/math/bigint/mp_karat.cpp46
-rw-r--r--src/math/bigint/mp_misc.cpp34
-rw-r--r--src/math/bigint/mp_shift.cpp34
-rw-r--r--src/math/bigint/mp_types.h10
-rw-r--r--src/math/bigint/mulop_amd64/mp_mulop.cpp20
-rw-r--r--src/math/bigint/mulop_generic/mp_mulop.cpp20
27 files changed, 650 insertions, 596 deletions
diff --git a/src/math/bigint/big_code.cpp b/src/math/bigint/big_code.cpp
index e7a5e4946..74701e532 100644
--- a/src/math/bigint/big_code.cpp
+++ b/src/math/bigint/big_code.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* BigInt Encoding/Decoding Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* BigInt Encoding/Decoding
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/bigint.h>
#include <botan/divide.h>
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* Encode a BigInt *
-*************************************************/
+/*
+* Encode a BigInt
+*/
void BigInt::encode(byte output[], const BigInt& n, Base base)
{
if(base == Binary)
@@ -53,9 +55,9 @@ void BigInt::encode(byte output[], const BigInt& n, Base base)
throw Invalid_Argument("Unknown BigInt encoding method");
}
-/*************************************************
-* Encode a BigInt *
-*************************************************/
+/*
+* Encode a BigInt
+*/
SecureVector<byte> BigInt::encode(const BigInt& n, Base base)
{
SecureVector<byte> output(n.encoded_size(base));
@@ -67,9 +69,9 @@ SecureVector<byte> BigInt::encode(const BigInt& n, Base base)
return output;
}
-/*************************************************
-* Encode a BigInt, with leading 0s if needed *
-*************************************************/
+/*
+* Encode a BigInt, with leading 0s if needed
+*/
SecureVector<byte> BigInt::encode_1363(const BigInt& n, u32bit bytes)
{
const u32bit n_bytes = n.bytes();
@@ -83,17 +85,17 @@ SecureVector<byte> BigInt::encode_1363(const BigInt& n, u32bit bytes)
return output;
}
-/*************************************************
-* Decode a BigInt *
-*************************************************/
+/*
+* Decode a BigInt
+*/
BigInt BigInt::decode(const MemoryRegion<byte>& buf, Base base)
{
return BigInt::decode(buf, buf.size(), base);
}
-/*************************************************
-* Decode a BigInt *
-*************************************************/
+/*
+* Decode a BigInt
+*/
BigInt BigInt::decode(const byte buf[], u32bit length, Base base)
{
BigInt r;
diff --git a/src/math/bigint/big_io.cpp b/src/math/bigint/big_io.cpp
index 3c201e8b2..b50fcceff 100644
--- a/src/math/bigint/big_io.cpp
+++ b/src/math/bigint/big_io.cpp
@@ -1,16 +1,18 @@
-/*************************************************
-* BigInt Input/Output Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* BigInt Input/Output
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/bigint.h>
#include <iostream>
namespace Botan {
-/*************************************************
-* Write the BigInt into a stream *
-*************************************************/
+/*
+* Write the BigInt into a stream
+*/
std::ostream& operator<<(std::ostream& stream, const BigInt& n)
{
BigInt::Base base = BigInt::Decimal;
@@ -37,9 +39,9 @@ std::ostream& operator<<(std::ostream& stream, const BigInt& n)
return stream;
}
-/*************************************************
-* Read the BigInt from a stream *
-*************************************************/
+/*
+* Read the BigInt from a stream
+*/
std::istream& operator>>(std::istream& stream, BigInt& n)
{
std::string str;
diff --git a/src/math/bigint/big_ops2.cpp b/src/math/bigint/big_ops2.cpp
index ef083f394..488eca909 100644
--- a/src/math/bigint/big_ops2.cpp
+++ b/src/math/bigint/big_ops2.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* BigInt Assignment Operators Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* BigInt Assignment Operators
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/bigint.h>
#include <botan/mp_core.h>
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* Addition Operator *
-*************************************************/
+/*
+* Addition Operator
+*/
BigInt& BigInt::operator+=(const BigInt& y)
{
const u32bit x_sw = sig_words(), y_sw = y.sig_words();
@@ -45,9 +47,9 @@ BigInt& BigInt::operator+=(const BigInt& y)
return (*this);
}
-/*************************************************
-* Subtraction Operator *
-*************************************************/
+/*
+* Subtraction Operator
+*/
BigInt& BigInt::operator-=(const BigInt& y)
{
const u32bit x_sw = sig_words(), y_sw = y.sig_words();
@@ -91,9 +93,9 @@ BigInt& BigInt::operator-=(const BigInt& y)
return (*this);
}
-/*************************************************
-* Multiplication Operator *
-*************************************************/
+/*
+* Multiplication Operator
+*/
BigInt& BigInt::operator*=(const BigInt& y)
{
const u32bit x_sw = sig_words(), y_sw = y.sig_words();
@@ -129,9 +131,9 @@ BigInt& BigInt::operator*=(const BigInt& y)
return (*this);
}
-/*************************************************
-* Division Operator *
-*************************************************/
+/*
+* Division Operator
+*/
BigInt& BigInt::operator/=(const BigInt& y)
{
if(y.sig_words() == 1 && power_of_2(y.word_at(0)))
@@ -141,17 +143,17 @@ BigInt& BigInt::operator/=(const BigInt& y)
return (*this);
}
-/*************************************************
-* Modulo Operator *
-*************************************************/
+/*
+* Modulo Operator
+*/
BigInt& BigInt::operator%=(const BigInt& mod)
{
return (*this = (*this) % mod);
}
-/*************************************************
-* Modulo Operator *
-*************************************************/
+/*
+* Modulo Operator
+*/
word BigInt::operator%=(word mod)
{
if(mod == 0)
@@ -182,9 +184,9 @@ word BigInt::operator%=(word mod)
return word_at(0);
}
-/*************************************************
-* Left Shift Operator *
-*************************************************/
+/*
+* Left Shift Operator
+*/
BigInt& BigInt::operator<<=(u32bit shift)
{
if(shift)
@@ -200,9 +202,9 @@ BigInt& BigInt::operator<<=(u32bit shift)
return (*this);
}
-/*************************************************
-* Right Shift Operator *
-*************************************************/
+/*
+* Right Shift Operator
+*/
BigInt& BigInt::operator>>=(u32bit shift)
{
if(shift)
diff --git a/src/math/bigint/big_ops3.cpp b/src/math/bigint/big_ops3.cpp
index ff24eab1c..ad8b7bbd0 100644
--- a/src/math/bigint/big_ops3.cpp
+++ b/src/math/bigint/big_ops3.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* BigInt Binary Operators Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* BigInt Binary Operators
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/bigint.h>
#include <botan/divide.h>
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* Addition Operator *
-*************************************************/
+/*
+* Addition Operator
+*/
BigInt operator+(const BigInt& x, const BigInt& y)
{
const u32bit x_sw = x.sig_words(), y_sw = y.sig_words();
@@ -40,9 +42,9 @@ BigInt operator+(const BigInt& x, const BigInt& y)
return z;
}
-/*************************************************
-* Subtraction Operator *
-*************************************************/
+/*
+* Subtraction Operator
+*/
BigInt operator-(const BigInt& x, const BigInt& y)
{
const u32bit x_sw = x.sig_words(), y_sw = y.sig_words();
@@ -75,9 +77,9 @@ BigInt operator-(const BigInt& x, const BigInt& y)
return z;
}
-/*************************************************
-* Multiplication Operator *
-*************************************************/
+/*
+* Multiplication Operator
+*/
BigInt operator*(const BigInt& x, const BigInt& y)
{
const u32bit x_sw = x.sig_words(), y_sw = y.sig_words();
@@ -101,9 +103,9 @@ BigInt operator*(const BigInt& x, const BigInt& y)
return z;
}
-/*************************************************
-* Division Operator *
-*************************************************/
+/*
+* Division Operator
+*/
BigInt operator/(const BigInt& x, const BigInt& y)
{
BigInt q, r;
@@ -111,9 +113,9 @@ BigInt operator/(const BigInt& x, const BigInt& y)
return q;
}
-/*************************************************
-* Modulo Operator *
-*************************************************/
+/*
+* Modulo Operator
+*/
BigInt operator%(const BigInt& n, const BigInt& mod)
{
if(mod.is_zero())
@@ -128,9 +130,9 @@ BigInt operator%(const BigInt& n, const BigInt& mod)
return r;
}
-/*************************************************
-* Modulo Operator *
-*************************************************/
+/*
+* Modulo Operator
+*/
word operator%(const BigInt& n, word mod)
{
if(mod == 0)
@@ -148,9 +150,9 @@ word operator%(const BigInt& n, word mod)
return remainder;
}
-/*************************************************
-* Left Shift Operator *
-*************************************************/
+/*
+* Left Shift Operator
+*/
BigInt operator<<(const BigInt& x, u32bit shift)
{
if(shift == 0)
@@ -166,9 +168,9 @@ BigInt operator<<(const BigInt& x, u32bit shift)
return y;
}
-/*************************************************
-* Right Shift Operator *
-*************************************************/
+/*
+* Right Shift Operator
+*/
BigInt operator>>(const BigInt& x, u32bit shift)
{
if(shift == 0)
diff --git a/src/math/bigint/big_rand.cpp b/src/math/bigint/big_rand.cpp
index 055873642..b641baee2 100644
--- a/src/math/bigint/big_rand.cpp
+++ b/src/math/bigint/big_rand.cpp
@@ -1,16 +1,18 @@
-/*************************************************
-* BigInt Random Generation Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* BigInt Random Generation
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/bigint.h>
#include <botan/parsing.h>
namespace Botan {
-/*************************************************
-* Construct a BigInt of a specific form *
-*************************************************/
+/*
+* Construct a BigInt of a specific form
+*/
BigInt::BigInt(NumberType type, u32bit bits)
{
set_sign(Positive);
@@ -21,9 +23,9 @@ BigInt::BigInt(NumberType type, u32bit bits)
throw Invalid_Argument("BigInt(NumberType): Unknown type");
}
-/*************************************************
-* Randomize this number *
-*************************************************/
+/*
+* Randomize this number
+*/
void BigInt::randomize(RandomNumberGenerator& rng,
u32bit bitsize)
{
@@ -42,9 +44,9 @@ void BigInt::randomize(RandomNumberGenerator& rng,
}
}
-/*************************************************
-* Generate a random integer within given range *
-*************************************************/
+/*
+* Generate a random integer within given range
+*/
BigInt BigInt::random_integer(RandomNumberGenerator& rng,
const BigInt& min, const BigInt& max)
{
diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp
index e3c7931e6..926bedc02 100644
--- a/src/math/bigint/bigint.cpp
+++ b/src/math/bigint/bigint.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* BigInt Base Source File *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/*
+* BigInt Base
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/bigint.h>
#include <botan/mp_core.h>
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* Construct a BigInt from a regular number *
-*************************************************/
+/*
+* Construct a BigInt from a regular number
+*/
BigInt::BigInt(u64bit n)
{
set_sign(Positive);
@@ -28,18 +30,18 @@ BigInt::BigInt(u64bit n)
reg[j] = ((n >> (j*MP_WORD_BITS)) & MP_WORD_MASK);
}
-/*************************************************
-* Construct a BigInt of the specified size *
-*************************************************/
+/*
+* Construct a BigInt of the specified size
+*/
BigInt::BigInt(Sign s, u32bit size)
{
reg.create(round_up(size, 8));
signedness = s;
}
-/*************************************************
-* Construct a BigInt from a "raw" BigInt *
-*************************************************/
+/*
+* Construct a BigInt from a "raw" BigInt
+*/
BigInt::BigInt(const BigInt& b)
{
const u32bit b_words = b.sig_words();
@@ -57,9 +59,9 @@ BigInt::BigInt(const BigInt& b)
}
}
-/*************************************************
-* Construct a BigInt from a string *
-*************************************************/
+/*
+* Construct a BigInt from a string
+*/
BigInt::BigInt(const std::string& str)
{
Base base = Decimal;
@@ -80,53 +82,53 @@ BigInt::BigInt(const std::string& str)
else set_sign(Positive);
}
-/*************************************************
-* Construct a BigInt from an encoded BigInt *
-*************************************************/
+/*
+* Construct a BigInt from an encoded BigInt
+*/
BigInt::BigInt(const byte input[], u32bit length, Base base)
{
set_sign(Positive);
*this = decode(input, length, base);
}
-/*************************************************
-* Construct a BigInt from an encoded BigInt *
-*************************************************/
+/*
+* Construct a BigInt from an encoded BigInt
+*/
BigInt::BigInt(RandomNumberGenerator& rng, u32bit bits)
{
set_sign(Positive);
randomize(rng, bits);
}
-/*************************************************
-* Swap this BigInt with another *
-*************************************************/
+/*
+* Swap this BigInt with another
+*/
void BigInt::swap(BigInt& other)
{
reg.swap(other.reg);
std::swap(signedness, other.signedness);
}
-/*************************************************
-* Grow the internal storage *
-*************************************************/
+/*
+* Grow the internal storage
+*/
void BigInt::grow_reg(u32bit n)
{
reg.grow_to(round_up(size() + n, 8));
}
-/*************************************************
-* Grow the internal storage *
-*************************************************/
+/*
+* Grow the internal storage
+*/
void BigInt::grow_to(u32bit n)
{
if(n > size())
reg.grow_to(round_up(n, 8));
}
-/*************************************************
-* Comparison Function *
-*************************************************/
+/*
+* Comparison Function
+*/
s32bit BigInt::cmp(const BigInt& n, bool check_signs) const
{
if(check_signs)
@@ -139,9 +141,9 @@ s32bit BigInt::cmp(const BigInt& n, bool check_signs) const
return bigint_cmp(data(), sig_words(), n.data(), n.sig_words());
}
-/*************************************************
-* Convert this number to a u32bit, if possible *
-*************************************************/
+/*
+* Convert this number to a u32bit, if possible
+*/
u32bit BigInt::to_u32bit() const
{
if(is_negative())
@@ -155,9 +157,9 @@ u32bit BigInt::to_u32bit() const
return out;
}
-/*************************************************
-* Return byte n of this number *
-*************************************************/
+/*
+* Return byte n of this number
+*/
byte BigInt::byte_at(u32bit n) const
{
const u32bit WORD_BYTES = sizeof(word);
@@ -168,17 +170,17 @@ byte BigInt::byte_at(u32bit n) const
return get_byte(WORD_BYTES - byte_num - 1, reg[word_num]);
}
-/*************************************************
-* Return bit n of this number *
-*************************************************/
+/*
+* Return bit n of this number
+*/
bool BigInt::get_bit(u32bit n) const
{
return ((word_at(n / MP_WORD_BITS) >> (n % MP_WORD_BITS)) & 1);
}
-/*************************************************
-* Return bits {offset...offset+length} *
-*************************************************/
+/*
+* Return bits {offset...offset+length}
+*/
u32bit BigInt::get_substring(u32bit offset, u32bit length) const
{
if(length > 32)
@@ -194,9 +196,9 @@ u32bit BigInt::get_substring(u32bit offset, u32bit length) const
return static_cast<u32bit>((piece >> shift) & mask);
}
-/*************************************************
-* Set bit number n *
-*************************************************/
+/*
+* Set bit number n
+*/
void BigInt::set_bit(u32bit n)
{
const u32bit which = n / MP_WORD_BITS;
@@ -205,9 +207,9 @@ void BigInt::set_bit(u32bit n)
reg[which] |= mask;
}
-/*************************************************
-* Clear bit number n *
-*************************************************/
+/*
+* Clear bit number n
+*/
void BigInt::clear_bit(u32bit n)
{
const u32bit which = n / MP_WORD_BITS;
@@ -216,9 +218,9 @@ void BigInt::clear_bit(u32bit n)
reg[which] &= ~mask;
}
-/*************************************************
-* Clear all but the lowest n bits *
-*************************************************/
+/*
+* Clear all but the lowest n bits
+*/
void BigInt::mask_bits(u32bit n)
{
if(n == 0) { clear(); return; }
@@ -234,17 +236,17 @@ void BigInt::mask_bits(u32bit n)
reg[top_word] &= mask;
}
-/*************************************************
-* Count how many bytes are being used *
-*************************************************/
+/*
+* Count how many bytes are being used
+*/
u32bit BigInt::bytes() const
{
return (bits() + 7) / 8;
}
-/*************************************************
-* Count how many bits are being used *
-*************************************************/
+/*
+* Count how many bits are being used
+*/
u32bit BigInt::bits() const
{
if(sig_words() == 0)
@@ -259,9 +261,9 @@ u32bit BigInt::bits() const
return (full_words * MP_WORD_BITS + top_bits);
}
-/*************************************************
-* Calcluate the size in a certain base *
-*************************************************/
+/*
+* Calcluate the size in a certain base
+*/
u32bit BigInt::encoded_size(Base base) const
{
static const double LOG_2_BASE_10 = 0.30102999566;
@@ -278,9 +280,9 @@ u32bit BigInt::encoded_size(Base base) const
throw Invalid_Argument("Unknown base for BigInt encoding");
}
-/*************************************************
-* Set the sign *
-*************************************************/
+/*
+* Set the sign
+*/
void BigInt::set_sign(Sign s)
{
if(is_zero())
@@ -289,17 +291,17 @@ void BigInt::set_sign(Sign s)
signedness = s;
}
-/*************************************************
-* Reverse the value of the sign flag *
-*************************************************/
+/*
+* Reverse the value of the sign flag
+*/
void BigInt::flip_sign()
{
set_sign(reverse_sign());
}
-/*************************************************
-* Return the opposite value of the current sign *
-*************************************************/
+/*
+* Return the opposite value of the current sign
+*/
BigInt::Sign BigInt::reverse_sign() const
{
if(sign() == Positive)
@@ -307,9 +309,9 @@ BigInt::Sign BigInt::reverse_sign() const
return Positive;
}
-/*************************************************
-* Return the negation of this number *
-*************************************************/
+/*
+* Return the negation of this number
+*/
BigInt BigInt::operator-() const
{
BigInt x = (*this);
@@ -317,9 +319,9 @@ BigInt BigInt::operator-() const
return x;
}
-/*************************************************
-* Return the absolute value of this number *
-*************************************************/
+/*
+* Return the absolute value of this number
+*/
BigInt BigInt::abs() const
{
BigInt x = (*this);
@@ -327,9 +329,9 @@ BigInt BigInt::abs() const
return x;
}
-/*************************************************
-* Encode this number into bytes *
-*************************************************/
+/*
+* Encode this number into bytes
+*/
void BigInt::binary_encode(byte output[]) const
{
const u32bit sig_bytes = bytes();
@@ -337,9 +339,9 @@ void BigInt::binary_encode(byte output[]) const
output[sig_bytes-j-1] = byte_at(j);
}
-/*************************************************
-* Set this number to the value in buf *
-*************************************************/
+/*
+* Set this number to the value in buf
+*/
void BigInt::binary_decode(const byte buf[], u32bit length)
{
const u32bit WORD_BYTES = sizeof(word);
@@ -356,9 +358,9 @@ void BigInt::binary_decode(const byte buf[], u32bit length)
reg[length / WORD_BYTES] = (reg[length / WORD_BYTES] << 8) | buf[j];
}
-/*************************************************
-* Set this number to the value in buf *
-*************************************************/
+/*
+* Set this number to the value in buf
+*/
void BigInt::binary_decode(const MemoryRegion<byte>& buf)
{
binary_decode(buf, buf.size());
diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h
index 4a29e5365..16a1bba96 100644
--- a/src/math/bigint/bigint.h
+++ b/src/math/bigint/bigint.h
@@ -1,8 +1,10 @@
-/*************************************************
-* BigInt Header File *
-* (C) 1999-2008 Jack Lloyd *
-* 2007 FlexSecure *
-*************************************************/
+/*
+* BigInt
+* (C) 1999-2008 Jack Lloyd
+* 2007 FlexSecure
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_BIGINT_H__
#define BOTAN_BIGINT_H__
@@ -18,7 +20,7 @@ namespace Botan {
* Big Integer representation. This class defines an integer type,
* that can be very big. Additionally some helper functions are
* defined to work more comfortably.
- *
+
*/
class BOTAN_DLL BigInt
{
@@ -45,7 +47,7 @@ class BOTAN_DLL BigInt
{ DivideByZero() : Exception("BigInt divide by zero") {} };
/*************
- * operators *
+ * operators
*************/
/**
@@ -142,7 +144,7 @@ class BOTAN_DLL BigInt
void clear() { get_reg().clear(); }
/*************
- * functions *
+ * functions
************/
/**
@@ -487,9 +489,9 @@ class BOTAN_DLL BigInt
Sign signedness;
};
-/*************************************************
-* Arithmetic Operators *
-*************************************************/
+/*
+* Arithmetic Operators
+*/
BigInt BOTAN_DLL operator+(const BigInt&, const BigInt&);
BigInt BOTAN_DLL operator-(const BigInt&, const BigInt&);
BigInt BOTAN_DLL operator*(const BigInt&, const BigInt&);
@@ -499,9 +501,9 @@ word BOTAN_DLL operator%(const BigInt&, word);
BigInt BOTAN_DLL operator<<(const BigInt&, u32bit);
BigInt BOTAN_DLL operator>>(const BigInt&, u32bit);
-/*************************************************
-* Comparison Operators *
-*************************************************/
+/*
+* Comparison Operators
+*/
inline bool operator==(const BigInt& a, const BigInt& b)
{ return (a.cmp(b) == 0); }
inline bool operator!=(const BigInt& a, const BigInt& b)
@@ -515,9 +517,9 @@ inline bool operator<(const BigInt& a, const BigInt& b)
inline bool operator>(const BigInt& a, const BigInt& b)
{ return (a.cmp(b) > 0); }
-/*************************************************
-* I/O Operators *
-*************************************************/
+/*
+* I/O Operators
+*/
BOTAN_DLL std::ostream& operator<<(std::ostream&, const BigInt&);
BOTAN_DLL std::istream& operator>>(std::istream&, BigInt&);
diff --git a/src/math/bigint/divide.cpp b/src/math/bigint/divide.cpp
index ba088ced4..6afaa0fee 100644
--- a/src/math/bigint/divide.cpp
+++ b/src/math/bigint/divide.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Division Algorithm Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Division Algorithm
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/divide.h>
#include <botan/mp_core.h>
@@ -10,9 +12,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Handle signed operands, if necessary *
-*************************************************/
+/*
+* Handle signed operands, if necessary
+*/
void sign_fixup(const BigInt& x, const BigInt& y, BigInt& q, BigInt& r)
{
if(x.sign() == BigInt::Negative)
@@ -26,9 +28,9 @@ void sign_fixup(const BigInt& x, const BigInt& y, BigInt& q, BigInt& r)
}
-/*************************************************
-* Solve x = q * y + r *
-*************************************************/
+/*
+* Solve x = q * y + r
+*/
void divide(const BigInt& x, const BigInt& y_arg, BigInt& q, BigInt& r)
{
if(y_arg.is_zero())
diff --git a/src/math/bigint/divide.h b/src/math/bigint/divide.h
index a50cbfb47..9445b137b 100644
--- a/src/math/bigint/divide.h
+++ b/src/math/bigint/divide.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Division Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Division
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_DIVISON_ALGORITHM_H__
#define BOTAN_DIVISON_ALGORITHM_H__
diff --git a/src/math/bigint/monty_generic/mp_monty.cpp b/src/math/bigint/monty_generic/mp_monty.cpp
index c162bfd4f..5409e2569 100644
--- a/src/math/bigint/monty_generic/mp_monty.cpp
+++ b/src/math/bigint/monty_generic/mp_monty.cpp
@@ -1,8 +1,10 @@
-/*************************************************
-* Montgomery Reduction Source File *
-* (C) 1999-2008 Jack Lloyd *
-* 2006 Luca Piccarreta *
-*************************************************/
+/*
+* Montgomery Reduction
+* (C) 1999-2008 Jack Lloyd
+* 2006 Luca Piccarreta
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/mp_core.h>
#include <botan/mp_asm.h>
@@ -12,9 +14,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Montgomery Reduction Algorithm *
-*************************************************/
+/*
+* Montgomery Reduction Algorithm
+*/
void bigint_monty_redc(word z[], u32bit z_size,
const word x[], u32bit x_size, word u)
{
diff --git a/src/math/bigint/mp_amd64/mp_asm.h b/src/math/bigint/mp_amd64/mp_asm.h
index eca7bae6c..fa66d04f3 100644
--- a/src/math/bigint/mp_amd64/mp_asm.h
+++ b/src/math/bigint/mp_amd64/mp_asm.h
@@ -1,8 +1,10 @@
-/*************************************************
-* Lowest Level MPI Algorithms Header File *
-* (C) 1999-2008 Jack Lloyd *
-* 2006 Luca Piccarreta *
-*************************************************/
+/*
+* Lowest Level MPI Algorithms
+* (C) 1999-2008 Jack Lloyd
+* 2006 Luca Piccarreta
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MP_ASM_H__
#define BOTAN_MP_ASM_H__
@@ -17,14 +19,14 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Helper Macros for amd64 Assembly *
-*************************************************/
+/*
+* Helper Macros for amd64 Assembly
+*/
#define ASM(x) x "\n\t"
-/*************************************************
-* Word Multiply *
-*************************************************/
+/*
+* Word Multiply
+*/
inline word word_madd2(word a, word b, word* c)
{
asm(
@@ -38,9 +40,9 @@ inline word word_madd2(word a, word b, word* c)
return a;
}
-/*************************************************
-* Word Multiply/Add *
-*************************************************/
+/*
+* Word Multiply/Add
+*/
inline word word_madd3(word a, word b, word c, word* d)
{
asm(
diff --git a/src/math/bigint/mp_amd64/mp_asmi.h b/src/math/bigint/mp_amd64/mp_asmi.h
index bf3469526..8bccbaaf4 100644
--- a/src/math/bigint/mp_amd64/mp_asmi.h
+++ b/src/math/bigint/mp_amd64/mp_asmi.h
@@ -1,8 +1,10 @@
-/*************************************************
-* Lowest Level MPI Algorithms Header File *
-* (C) 1999-2007 Jack Lloyd *
-* 2006 Luca Piccarreta *
-*************************************************/
+/*
+* Lowest Level MPI Algorithms
+* (C) 1999-2007 Jack Lloyd
+* 2006 Luca Piccarreta
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MP_ASM_INTERNAL_H__
#define BOTAN_MP_ASM_INTERNAL_H__
@@ -13,9 +15,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Helper Macros for amd64 Assembly *
-*************************************************/
+/*
+* Helper Macros for amd64 Assembly
+*/
#ifndef ASM
#define ASM(x) x "\n\t"
#endif
@@ -63,9 +65,9 @@ extern "C" {
ASM("sbbq %[carry],%[carry]") \
ASM("negq %[carry]")
-/*************************************************
-* Word Addition *
-*************************************************/
+/*
+* Word Addition
+*/
inline word word_add(word x, word y, word* carry)
{
#if 0
@@ -84,9 +86,9 @@ inline word word_add(word x, word y, word* carry)
#endif
}
-/*************************************************
-* Eight Word Block Addition, Two Argument *
-*************************************************/
+/*
+* Eight Word Block Addition, Two Argument
+*/
inline word word8_add2(word x[8], const word y[8], word carry)
{
asm(
@@ -97,9 +99,9 @@ inline word word8_add2(word x[8], const word y[8], word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Addition, Three Argument *
-*************************************************/
+/*
+* Eight Word Block Addition, Three Argument
+*/
inline word word8_add3(word z[8], const word x[8], const word y[8], word carry)
{
asm(
@@ -110,9 +112,9 @@ inline word word8_add3(word z[8], const word x[8], const word y[8], word carry)
return carry;
}
-/*************************************************
-* Word Subtraction *
-*************************************************/
+/*
+* Word Subtraction
+*/
inline word word_sub(word x, word y, word* carry)
{
asm(
@@ -123,9 +125,9 @@ inline word word_sub(word x, word y, word* carry)
return x;
}
-/*************************************************
-* Eight Word Block Subtraction, Two Argument *
-*************************************************/
+/*
+* Eight Word Block Subtraction, Two Argument
+*/
inline word word8_sub2(word x[8], const word y[8], word carry)
{
asm(
@@ -136,9 +138,9 @@ inline word word8_sub2(word x[8], const word y[8], word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Subtraction, Three Argument *
-*************************************************/
+/*
+* Eight Word Block Subtraction, Three Argument
+*/
inline word word8_sub3(word z[8], const word x[8], const word y[8], word carry)
{
asm(
@@ -149,9 +151,9 @@ inline word word8_sub3(word z[8], const word x[8], const word y[8], word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Linear Multiplication *
-*************************************************/
+/*
+* Eight Word Block Linear Multiplication
+*/
inline word word8_linmul2(word x[8], word y, word carry)
{
asm(
@@ -162,9 +164,9 @@ inline word word8_linmul2(word x[8], word y, word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Linear Multiplication *
-*************************************************/
+/*
+* Eight Word Block Linear Multiplication
+*/
inline word word8_linmul3(word z[8], const word x[8], word y, word carry)
{
asm(
@@ -175,9 +177,9 @@ inline word word8_linmul3(word z[8], const word x[8], word y, word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Multiply/Add *
-*************************************************/
+/*
+* Eight Word Block Multiply/Add
+*/
inline word word8_madd3(word z[8], const word x[8], word y, word carry)
{
asm(
@@ -188,9 +190,9 @@ inline word word8_madd3(word z[8], const word x[8], word y, word carry)
return carry;
}
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
+/*
+* Multiply-Add Accumulator
+*/
inline void word3_muladd(word* w2, word* w1, word* w0, word x, word y)
{
asm(
@@ -205,9 +207,9 @@ inline void word3_muladd(word* w2, word* w1, word* w0, word x, word y)
: "cc");
}
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
+/*
+* Multiply-Add Accumulator
+*/
inline void word3_muladd_2(word* w2, word* w1, word* w0, word x, word y)
{
asm(
diff --git a/src/math/bigint/mp_asm.cpp b/src/math/bigint/mp_asm.cpp
index e5d1fe0d6..ea9738d30 100644
--- a/src/math/bigint/mp_asm.cpp
+++ b/src/math/bigint/mp_asm.cpp
@@ -1,8 +1,10 @@
-/*************************************************
-* Lowest Level MPI Algorithms Source File *
-* (C) 1999-2008 Jack Lloyd *
-* 2006 Luca Piccarreta *
-*************************************************/
+/*
+* Lowest Level MPI Algorithms
+* (C) 1999-2008 Jack Lloyd
+* 2006 Luca Piccarreta
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/mp_asm.h>
#include <botan/mp_asmi.h>
@@ -13,9 +15,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Two Operand Addition, No Carry *
-*************************************************/
+/*
+* Two Operand Addition, No Carry
+*/
word bigint_add2_nc(word x[], u32bit x_size, const word y[], u32bit y_size)
{
word carry = 0;
@@ -38,9 +40,9 @@ word bigint_add2_nc(word x[], u32bit x_size, const word y[], u32bit y_size)
return 1;
}
-/*************************************************
-* Three Operand Addition, No Carry *
-*************************************************/
+/*
+* Three Operand Addition, No Carry
+*/
word bigint_add3_nc(word z[], const word x[], u32bit x_size,
const word y[], u32bit y_size)
{
@@ -68,18 +70,18 @@ word bigint_add3_nc(word z[], const word x[], u32bit x_size,
return carry;
}
-/*************************************************
-* Two Operand Addition *
-*************************************************/
+/*
+* Two Operand Addition
+*/
void bigint_add2(word x[], u32bit x_size, const word y[], u32bit y_size)
{
if(bigint_add2_nc(x, x_size, y, y_size))
++x[x_size];
}
-/*************************************************
-* Three Operand Addition *
-*************************************************/
+/*
+* Three Operand Addition
+*/
void bigint_add3(word z[], const word x[], u32bit x_size,
const word y[], u32bit y_size)
{
@@ -87,9 +89,9 @@ void bigint_add3(word z[], const word x[], u32bit x_size,
++z[(x_size > y_size ? x_size : y_size)];
}
-/*************************************************
-* Two Operand Subtraction *
-*************************************************/
+/*
+* Two Operand Subtraction
+*/
void bigint_sub2(word x[], u32bit x_size, const word y[], u32bit y_size)
{
word carry = 0;
@@ -111,9 +113,9 @@ void bigint_sub2(word x[], u32bit x_size, const word y[], u32bit y_size)
}
}
-/*************************************************
-* Three Operand Subtraction *
-*************************************************/
+/*
+* Three Operand Subtraction
+*/
void bigint_sub3(word z[], const word x[], u32bit x_size,
const word y[], u32bit y_size)
{
@@ -136,9 +138,9 @@ void bigint_sub3(word z[], const word x[], u32bit x_size,
}
}
-/*************************************************
-* Two Operand Linear Multiply *
-*************************************************/
+/*
+* Two Operand Linear Multiply
+*/
void bigint_linmul2(word x[], u32bit x_size, word y)
{
const u32bit blocks = x_size - (x_size % 8);
@@ -154,9 +156,9 @@ void bigint_linmul2(word x[], u32bit x_size, word y)
x[x_size] = carry;
}
-/*************************************************
-* Three Operand Linear Multiply *
-*************************************************/
+/*
+* Three Operand Linear Multiply
+*/
void bigint_linmul3(word z[], const word x[], u32bit x_size, word y)
{
const u32bit blocks = x_size - (x_size % 8);
diff --git a/src/math/bigint/mp_asm64/mp_asm.h b/src/math/bigint/mp_asm64/mp_asm.h
index f751a50f8..d1583e236 100644
--- a/src/math/bigint/mp_asm64/mp_asm.h
+++ b/src/math/bigint/mp_asm64/mp_asm.h
@@ -1,7 +1,9 @@
-/*************************************************
-* MPI Multiply-Add Core Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* MPI Multiply-Add Core
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MP_MADD_H__
#define BOTAN_MP_MADD_H__
@@ -81,9 +83,9 @@ inline void bigint_2word_mul(word a, word b, word* z1, word* z0)
#endif
-/*************************************************
-* Word Multiply/Add *
-*************************************************/
+/*
+* Word Multiply/Add
+*/
inline word word_madd2(word a, word b, word* c)
{
word z0 = 0, z1 = 0;
@@ -96,9 +98,9 @@ inline word word_madd2(word a, word b, word* c)
return z1;
}
-/*************************************************
-* Word Multiply/Add *
-*************************************************/
+/*
+* Word Multiply/Add
+*/
inline word word_madd3(word a, word b, word c, word* d)
{
word z0 = 0, z1 = 0;
diff --git a/src/math/bigint/mp_comba.cpp b/src/math/bigint/mp_comba.cpp
index c7a9c964c..218038d8a 100644
--- a/src/math/bigint/mp_comba.cpp
+++ b/src/math/bigint/mp_comba.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Comba Multiplication and Squaring Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Comba Multiplication and Squaring
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/mp_core.h>
#include <botan/mp_asmi.h>
@@ -10,9 +12,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Comba 4x4 Squaring *
-*************************************************/
+/*
+* Comba 4x4 Squaring
+*/
void bigint_comba_sqr4(word z[8], const word x[4])
{
word w2 = 0, w1 = 0, w0 = 0;
@@ -43,9 +45,9 @@ void bigint_comba_sqr4(word z[8], const word x[4])
z[7] = w1;
}
-/*************************************************
-* Comba 4x4 Multiplication *
-*************************************************/
+/*
+* Comba 4x4 Multiplication
+*/
void bigint_comba_mul4(word z[8], const word x[4], const word y[4])
{
word w2 = 0, w1 = 0, w0 = 0;
@@ -82,9 +84,9 @@ void bigint_comba_mul4(word z[8], const word x[4], const word y[4])
z[7] = w1;
}
-/*************************************************
-* Comba 6x6 Squaring *
-*************************************************/
+/*
+* Comba 6x6 Squaring
+*/
void bigint_comba_sqr6(word z[12], const word x[6])
{
word w2 = 0, w1 = 0, w0 = 0;
@@ -134,9 +136,9 @@ void bigint_comba_sqr6(word z[12], const word x[6])
z[11] = w1;
}
-/*************************************************
-* Comba 6x6 Multiplication *
-*************************************************/
+/*
+* Comba 6x6 Multiplication
+*/
void bigint_comba_mul6(word z[12], const word x[6], const word y[6])
{
word w2 = 0, w1 = 0, w0 = 0;
@@ -201,9 +203,9 @@ void bigint_comba_mul6(word z[12], const word x[6], const word y[6])
z[11] = w1;
}
-/*************************************************
-* Comba 8x8 Squaring *
-*************************************************/
+/*
+* Comba 8x8 Squaring
+*/
void bigint_comba_sqr8(word z[16], const word x[8])
{
word w2 = 0, w1 = 0, w0 = 0;
@@ -276,9 +278,9 @@ void bigint_comba_sqr8(word z[16], const word x[8])
z[15] = w1;
}
-/*************************************************
-* Comba 8x8 Multiplication *
-*************************************************/
+/*
+* Comba 8x8 Multiplication
+*/
void bigint_comba_mul8(word z[16], const word x[8], const word y[8])
{
word w2 = 0, w1 = 0, w0 = 0;
@@ -379,9 +381,9 @@ void bigint_comba_mul8(word z[16], const word x[8], const word y[8])
z[15] = w1;
}
-/*************************************************
-* Comba 16x16 Squaring *
-*************************************************/
+/*
+* Comba 16x16 Squaring
+*/
void bigint_comba_sqr16(word z[32], const word x[16])
{
word w2 = 0, w1 = 0, w0 = 0;
@@ -586,9 +588,9 @@ void bigint_comba_sqr16(word z[32], const word x[16])
z[31] = w1;
}
-/*************************************************
-* Comba 16x16 Multiplication *
-*************************************************/
+/*
+* Comba 16x16 Multiplication
+*/
void bigint_comba_mul16(word z[32], const word x[16], const word y[16])
{
word w2 = 0, w1 = 0, w0 = 0;
diff --git a/src/math/bigint/mp_core.h b/src/math/bigint/mp_core.h
index 92949cd83..ea27a77a7 100644
--- a/src/math/bigint/mp_core.h
+++ b/src/math/bigint/mp_core.h
@@ -1,7 +1,9 @@
-/*************************************************
-* MPI Algorithms Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* MPI Algorithms
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MP_CORE_H__
#define BOTAN_MP_CORE_H__
@@ -10,16 +12,16 @@
namespace Botan {
-/*************************************************
-* The size of the word type, in bits *
-*************************************************/
+/*
+* The size of the word type, in bits
+*/
const u32bit MP_WORD_BITS = BOTAN_MP_WORD_BITS;
extern "C" {
-/*************************************************
-* Addition/Subtraction Operations *
-*************************************************/
+/*
+* Addition/Subtraction Operations
+*/
void bigint_add2(word[], u32bit, const word[], u32bit);
void bigint_add3(word[], const word[], u32bit, const word[], u32bit);
@@ -29,45 +31,45 @@ word bigint_add3_nc(word[], const word[], u32bit, const word[], u32bit);
void bigint_sub2(word[], u32bit, const word[], u32bit);
void bigint_sub3(word[], const word[], u32bit, const word[], u32bit);
-/*************************************************
-* Shift Operations *
-*************************************************/
+/*
+* Shift Operations
+*/
void bigint_shl1(word[], u32bit, u32bit, u32bit);
void bigint_shl2(word[], const word[], u32bit, u32bit, u32bit);
void bigint_shr1(word[], u32bit, u32bit, u32bit);
void bigint_shr2(word[], const word[], u32bit, u32bit, u32bit);
-/*************************************************
-* Simple O(N^2) Multiplication and Squaring *
-*************************************************/
+/*
+* Simple O(N^2) Multiplication and Squaring
+*/
void bigint_simple_mul(word z[], const word x[], u32bit x_size,
const word y[], u32bit y_size);
void bigint_simple_sqr(word z[], const word x[], u32bit x_size);
-/*************************************************
-* Linear Multiply *
-*************************************************/
+/*
+* Linear Multiply
+*/
void bigint_linmul2(word[], u32bit, word);
void bigint_linmul3(word[], const word[], u32bit, word);
void bigint_linmul_add(word[], u32bit, const word[], u32bit, word);
-/*************************************************
-* Montgomery Reduction *
-*************************************************/
+/*
+* Montgomery Reduction
+*/
void bigint_monty_redc(word[], u32bit, const word[], u32bit, word);
-/*************************************************
-* Misc Utility Operations *
-*************************************************/
+/*
+* Misc Utility Operations
+*/
u32bit bigint_divcore(word, word, word, word, word, word);
s32bit bigint_cmp(const word[], u32bit, const word[], u32bit);
word bigint_divop(word, word, word);
word bigint_modop(word, word, word);
void bigint_wordmul(word, word, word*, word*);
-/*************************************************
-* Comba Multiplication / Squaring *
-*************************************************/
+/*
+* Comba Multiplication / Squaring
+*/
void bigint_comba_mul4(word[8], const word[4], const word[4]);
void bigint_comba_mul6(word[12], const word[6], const word[6]);
void bigint_comba_mul8(word[16], const word[8], const word[8]);
@@ -81,9 +83,9 @@ void bigint_comba_sqr16(word[64], const word[32]);
}
-/*************************************************
-* High Level Multiplication/Squaring Interfaces *
-*************************************************/
+/*
+* High Level Multiplication/Squaring Interfaces
+*/
void bigint_mul(word[], u32bit, word[],
const word[], u32bit, u32bit,
const word[], u32bit, u32bit);
diff --git a/src/math/bigint/mp_generic/mp_asm.h b/src/math/bigint/mp_generic/mp_asm.h
index e62a57110..7c18343ef 100644
--- a/src/math/bigint/mp_generic/mp_asm.h
+++ b/src/math/bigint/mp_generic/mp_asm.h
@@ -1,8 +1,10 @@
-/*************************************************
-* Lowest Level MPI Algorithms Header File *
-* (C) 1999-2008 Jack Lloyd *
-* 2006 Luca Piccarreta *
-*************************************************/
+/*
+* Lowest Level MPI Algorithms
+* (C) 1999-2008 Jack Lloyd
+* 2006 Luca Piccarreta
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MP_ASM_H__
#define BOTAN_MP_ASM_H__
@@ -25,9 +27,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Word Multiply/Add *
-*************************************************/
+/*
+* Word Multiply/Add
+*/
inline word word_madd2(word a, word b, word* c)
{
dword z = (dword)a * b + *c;
@@ -35,9 +37,9 @@ inline word word_madd2(word a, word b, word* c)
return (word)z;
}
-/*************************************************
-* Word Multiply/Add *
-*************************************************/
+/*
+* Word Multiply/Add
+*/
inline word word_madd3(word a, word b, word c, word* d)
{
dword z = (dword)a * b + c + *d;
diff --git a/src/math/bigint/mp_generic/mp_asmi.h b/src/math/bigint/mp_generic/mp_asmi.h
index d15295154..21c4db248 100644
--- a/src/math/bigint/mp_generic/mp_asmi.h
+++ b/src/math/bigint/mp_generic/mp_asmi.h
@@ -1,8 +1,10 @@
-/*************************************************
-* Lowest Level MPI Algorithms Header File *
-* (C) 1999-2008 Jack Lloyd *
-* 2006 Luca Piccarreta *
-*************************************************/
+/*
+* Lowest Level MPI Algorithms
+* (C) 1999-2008 Jack Lloyd
+* 2006 Luca Piccarreta
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MP_ASM_INTERNAL_H__
#define BOTAN_MP_ASM_INTERNAL_H__
@@ -13,9 +15,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Word Addition *
-*************************************************/
+/*
+* Word Addition
+*/
inline word word_add(word x, word y, word* carry)
{
word z = x + y;
@@ -25,9 +27,9 @@ inline word word_add(word x, word y, word* carry)
return z;
}
-/*************************************************
-* Eight Word Block Addition, Two Argument *
-*************************************************/
+/*
+* Eight Word Block Addition, Two Argument
+*/
inline word word8_add2(word x[8], const word y[8], word carry)
{
x[0] = word_add(x[0], y[0], &carry);
@@ -41,9 +43,9 @@ inline word word8_add2(word x[8], const word y[8], word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Addition, Three Argument *
-*************************************************/
+/*
+* Eight Word Block Addition, Three Argument
+*/
inline word word8_add3(word z[8], const word x[8],
const word y[8], word carry)
{
@@ -58,9 +60,9 @@ inline word word8_add3(word z[8], const word x[8],
return carry;
}
-/*************************************************
-* Word Subtraction *
-*************************************************/
+/*
+* Word Subtraction
+*/
inline word word_sub(word x, word y, word* carry)
{
word t0 = x - y;
@@ -70,9 +72,9 @@ inline word word_sub(word x, word y, word* carry)
return z;
}
-/*************************************************
-* Eight Word Block Subtraction, Two Argument *
-*************************************************/
+/*
+* Eight Word Block Subtraction, Two Argument
+*/
inline word word8_sub2(word x[4], const word y[4], word carry)
{
x[0] = word_sub(x[0], y[0], &carry);
@@ -86,9 +88,9 @@ inline word word8_sub2(word x[4], const word y[4], word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Subtraction, Three Argument *
-*************************************************/
+/*
+* Eight Word Block Subtraction, Three Argument
+*/
inline word word8_sub3(word z[8], const word x[8],
const word y[8], word carry)
{
@@ -103,9 +105,9 @@ inline word word8_sub3(word z[8], const word x[8],
return carry;
}
-/*************************************************
-* Eight Word Block Linear Multiplication *
-*************************************************/
+/*
+* Eight Word Block Linear Multiplication
+*/
inline word word8_linmul2(word x[4], word y, word carry)
{
x[0] = word_madd2(x[0], y, &carry);
@@ -119,9 +121,9 @@ inline word word8_linmul2(word x[4], word y, word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Linear Multiplication *
-*************************************************/
+/*
+* Eight Word Block Linear Multiplication
+*/
inline word word8_linmul3(word z[8], const word x[8], word y, word carry)
{
z[0] = word_madd2(x[0], y, &carry);
@@ -135,9 +137,9 @@ inline word word8_linmul3(word z[8], const word x[8], word y, word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Multiply/Add *
-*************************************************/
+/*
+* Eight Word Block Multiply/Add
+*/
inline word word8_madd3(word z[8], const word x[8], word y, word carry)
{
z[0] = word_madd3(x[0], y, z[0], &carry);
@@ -151,9 +153,9 @@ inline word word8_madd3(word z[8], const word x[8], word y, word carry)
return carry;
}
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
+/*
+* Multiply-Add Accumulator
+*/
inline void word3_muladd(word* w2, word* w1, word* w0, word a, word b)
{
word carry = *w0;
@@ -162,9 +164,9 @@ inline void word3_muladd(word* w2, word* w1, word* w0, word a, word b)
*w2 += (*w1 < carry) ? 1 : 0;
}
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
+/*
+* Multiply-Add Accumulator
+*/
inline void word3_muladd_2(word* w2, word* w1, word* w0, word a, word b)
{
word carry = 0;
diff --git a/src/math/bigint/mp_ia32/mp_asm.h b/src/math/bigint/mp_ia32/mp_asm.h
index b45140321..4d3afc992 100644
--- a/src/math/bigint/mp_ia32/mp_asm.h
+++ b/src/math/bigint/mp_ia32/mp_asm.h
@@ -1,8 +1,10 @@
-/*************************************************
-* Lowest Level MPI Algorithms Header File *
-* (C) 1999-2008 Jack Lloyd *
-* 2006 Luca Piccarreta *
-*************************************************/
+/*
+* Lowest Level MPI Algorithms
+* (C) 1999-2008 Jack Lloyd
+* 2006 Luca Piccarreta
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MP_ASM_H__
#define BOTAN_MP_ASM_H__
@@ -17,14 +19,14 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Helper Macros for x86 Assembly *
-*************************************************/
+/*
+* Helper Macros for x86 Assembly
+*/
#define ASM(x) x "\n\t"
-/*************************************************
-* Word Multiply *
-*************************************************/
+/*
+* Word Multiply
+*/
inline word word_madd2(word a, word b, word* c)
{
asm(
@@ -38,9 +40,9 @@ inline word word_madd2(word a, word b, word* c)
return a;
}
-/*************************************************
-* Word Multiply/Add *
-*************************************************/
+/*
+* Word Multiply/Add
+*/
inline word word_madd3(word a, word b, word c, word* d)
{
asm(
diff --git a/src/math/bigint/mp_ia32/mp_asmi.h b/src/math/bigint/mp_ia32/mp_asmi.h
index 20079974e..28b99abcc 100644
--- a/src/math/bigint/mp_ia32/mp_asmi.h
+++ b/src/math/bigint/mp_ia32/mp_asmi.h
@@ -1,8 +1,10 @@
-/*************************************************
-* Lowest Level MPI Algorithms Header File *
-* (C) 1999-2007 Jack Lloyd *
-* 2006 Luca Piccarreta *
-*************************************************/
+/*
+* Lowest Level MPI Algorithms
+* (C) 1999-2007 Jack Lloyd
+* 2006 Luca Piccarreta
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MP_ASM_INTERNAL_H__
#define BOTAN_MP_ASM_INTERNAL_H__
@@ -13,9 +15,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Helper Macros for x86 Assembly *
-*************************************************/
+/*
+* Helper Macros for x86 Assembly
+*/
#ifndef ASM
#define ASM(x) x "\n\t"
#endif
@@ -63,9 +65,9 @@ extern "C" {
ASM("sbbl %[carry],%[carry]") \
ASM("negl %[carry]")
-/*************************************************
-* Word Addition *
-*************************************************/
+/*
+* Word Addition
+*/
inline word word_add(word x, word y, word* carry)
{
#if 0
@@ -84,9 +86,9 @@ inline word word_add(word x, word y, word* carry)
#endif
}
-/*************************************************
-* Eight Word Block Addition, Two Argument *
-*************************************************/
+/*
+* Eight Word Block Addition, Two Argument
+*/
inline word word8_add2(word x[8], const word y[8], word carry)
{
asm(
@@ -97,9 +99,9 @@ inline word word8_add2(word x[8], const word y[8], word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Addition, Three Argument *
-*************************************************/
+/*
+* Eight Word Block Addition, Three Argument
+*/
inline word word8_add3(word z[8], const word x[8], const word y[8], word carry)
{
asm(
@@ -110,9 +112,9 @@ inline word word8_add3(word z[8], const word x[8], const word y[8], word carry)
return carry;
}
-/*************************************************
-* Word Subtraction *
-*************************************************/
+/*
+* Word Subtraction
+*/
inline word word_sub(word x, word y, word* carry)
{
asm(
@@ -123,9 +125,9 @@ inline word word_sub(word x, word y, word* carry)
return x;
}
-/*************************************************
-* Eight Word Block Subtraction, Two Argument *
-*************************************************/
+/*
+* Eight Word Block Subtraction, Two Argument
+*/
inline word word8_sub2(word x[8], const word y[8], word carry)
{
asm(
@@ -136,9 +138,9 @@ inline word word8_sub2(word x[8], const word y[8], word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Subtraction, Three Argument *
-*************************************************/
+/*
+* Eight Word Block Subtraction, Three Argument
+*/
inline word word8_sub3(word z[8], const word x[8], const word y[8], word carry)
{
asm(
@@ -149,9 +151,9 @@ inline word word8_sub3(word z[8], const word x[8], const word y[8], word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Linear Multiplication *
-*************************************************/
+/*
+* Eight Word Block Linear Multiplication
+*/
inline word word8_linmul2(word x[8], word y, word carry)
{
asm(
@@ -162,9 +164,9 @@ inline word word8_linmul2(word x[8], word y, word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Linear Multiplication *
-*************************************************/
+/*
+* Eight Word Block Linear Multiplication
+*/
inline word word8_linmul3(word z[8], const word x[8], word y, word carry)
{
asm(
@@ -175,9 +177,9 @@ inline word word8_linmul3(word z[8], const word x[8], word y, word carry)
return carry;
}
-/*************************************************
-* Eight Word Block Multiply/Add *
-*************************************************/
+/*
+* Eight Word Block Multiply/Add
+*/
inline word word8_madd3(word z[8], const word x[8], word y, word carry)
{
asm(
@@ -188,9 +190,9 @@ inline word word8_madd3(word z[8], const word x[8], word y, word carry)
return carry;
}
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
+/*
+* Multiply-Add Accumulator
+*/
inline void word3_muladd(word* w2, word* w1, word* w0, word x, word y)
{
asm(
@@ -205,9 +207,9 @@ inline void word3_muladd(word* w2, word* w1, word* w0, word x, word y)
: "cc");
}
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
+/*
+* Multiply-Add Accumulator
+*/
inline void word3_muladd_2(word* w2, word* w1, word* w0, word x, word y)
{
asm(
diff --git a/src/math/bigint/mp_ia32_msvc/mp_asmi.h b/src/math/bigint/mp_ia32_msvc/mp_asmi.h
index 1aaea6ce0..33ce6eb3d 100644
--- a/src/math/bigint/mp_ia32_msvc/mp_asmi.h
+++ b/src/math/bigint/mp_ia32_msvc/mp_asmi.h
@@ -1,8 +1,10 @@
-/*************************************************
-* Lowest Level MPI Algorithms Header File *
-* (C) 1999-2006 Jack Lloyd *
-* 2006 Luca Piccarreta *
-*************************************************/
+/*
+* Lowest Level MPI Algorithms
+* (C) 1999-2006 Jack Lloyd
+* 2006 Luca Piccarreta
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MP_ASM_INTERNAL_H__
#define BOTAN_MP_ASM_INTERNAL_H__
@@ -13,9 +15,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Word Addition *
-*************************************************/
+/*
+* Word Addition
+*/
inline word word_add(word x, word y, word* carry)
{
word z = x + y;
@@ -25,9 +27,9 @@ inline word word_add(word x, word y, word* carry)
return z;
}
-/*************************************************
-* Eight Word Block Addition, Two Argument *
-*************************************************/
+/*
+* Eight Word Block Addition, Two Argument
+*/
inline word word8_add2(word x[8], const word y[8], word carry)
{
__asm {
@@ -56,9 +58,9 @@ inline word word8_add2(word x[8], const word y[8], word carry)
}
}
-/*************************************************
-* Eight Word Block Addition, Three Argument *
-*************************************************/
+/*
+* Eight Word Block Addition, Three Argument
+*/
inline word word8_add3(word z[8], const word x[8], const word y[8], word carry)
{
__asm {
@@ -104,9 +106,9 @@ inline word word8_add3(word z[8], const word x[8], const word y[8], word carry)
}
}
-/*************************************************
-* Word Subtraction *
-*************************************************/
+/*
+* Word Subtraction
+*/
inline word word_sub(word x, word y, word* carry)
{
word t0 = x - y;
@@ -116,9 +118,9 @@ inline word word_sub(word x, word y, word* carry)
return z;
}
-/*************************************************
-* Eight Word Block Subtraction, Two Argument *
-*************************************************/
+/*
+* Eight Word Block Subtraction, Two Argument
+*/
inline word word8_sub2(word x[8], const word y[8], word carry)
{
_asm {
@@ -155,9 +157,9 @@ inline word word8_sub2(word x[8], const word y[8], word carry)
}
}
-/*************************************************
-* Eight Word Block Subtraction, Three Argument *
-*************************************************/
+/*
+* Eight Word Block Subtraction, Three Argument
+*/
inline word word8_sub3(word z[8], const word x[8],
const word y[8], word carry)
{
@@ -196,9 +198,9 @@ inline word word8_sub3(word z[8], const word x[8],
}
}
-/*************************************************
-* Eight Word Block Linear Multiplication *
-*************************************************/
+/*
+* Eight Word Block Linear Multiplication
+*/
inline word word8_linmul2(word x[8], word y, word carry)
{
__asm
@@ -263,9 +265,9 @@ inline word word8_linmul2(word x[8], word y, word carry)
}
}
-/*************************************************
-* Eight Word Block Linear Multiplication *
-*************************************************/
+/*
+* Eight Word Block Linear Multiplication
+*/
inline word word8_muladd(word z[8], const word x[8],
word y, word carry)
{
@@ -472,9 +474,9 @@ inline word word8_linmul3(word z[4], const word x[4], word y, word carry)
}
}
-/*************************************************
-* Eight Word Block Multiply/Add *
-*************************************************/
+/*
+* Eight Word Block Multiply/Add
+*/
inline word word8_madd3(word z[8], const word x[8], word y, word carry)
{
z[0] = word_madd3(x[0], y, z[0], &carry);
@@ -488,9 +490,9 @@ inline word word8_madd3(word z[8], const word x[8], word y, word carry)
return carry;
}
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
+/*
+* Multiply-Add Accumulator
+*/
inline void word3_muladd(word* w2, word* w1, word* w0, word a, word b)
{
word carry = *w0;
@@ -499,9 +501,9 @@ inline void word3_muladd(word* w2, word* w1, word* w0, word a, word b)
*w2 += (*w1 < carry) ? 1 : 0;
}
-/*************************************************
-* Multiply-Add Accumulator *
-*************************************************/
+/*
+* Multiply-Add Accumulator
+*/
inline void word3_muladd_2(word* w2, word* w1, word* w0, word a, word b)
{
word carry = 0;
diff --git a/src/math/bigint/mp_karat.cpp b/src/math/bigint/mp_karat.cpp
index 15b0551fd..f30d418cc 100644
--- a/src/math/bigint/mp_karat.cpp
+++ b/src/math/bigint/mp_karat.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Karatsuba Multiplication/Squaring Source File *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/*
+* Karatsuba Multiplication/Squaring
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/mp_core.h>
#include <botan/mem_ops.h>
@@ -11,9 +13,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Karatsuba Multiplication Operation *
-*************************************************/
+/*
+* Karatsuba Multiplication Operation
+*/
void karatsuba_mul(word z[], const word x[], const word y[], u32bit N,
word workspace[])
{
@@ -91,9 +93,9 @@ void karatsuba_mul(word z[], const word x[], const word y[], u32bit N,
}
}
-/*************************************************
-* Karatsuba Squaring Operation *
-*************************************************/
+/*
+* Karatsuba Squaring Operation
+*/
void karatsuba_sqr(word z[], const word x[], u32bit N, word workspace[])
{
if(N == 6)
@@ -162,9 +164,9 @@ void karatsuba_sqr(word z[], const word x[], u32bit N, word workspace[])
}
}
-/*************************************************
-* Pick a good size for the Karatsuba multiply *
-*************************************************/
+/*
+* Pick a good size for the Karatsuba multiply
+*/
u32bit karatsuba_size(u32bit z_size,
u32bit x_size, u32bit x_sw,
u32bit y_size, u32bit y_sw)
@@ -206,9 +208,9 @@ u32bit karatsuba_size(u32bit z_size,
return 0;
}
-/*************************************************
-* Pick a good size for the Karatsuba squaring *
-*************************************************/
+/*
+* Pick a good size for the Karatsuba squaring
+*/
u32bit karatsuba_size(u32bit z_size, u32bit x_size, u32bit x_sw)
{
if(x_sw == x_size)
@@ -236,9 +238,9 @@ u32bit karatsuba_size(u32bit z_size, u32bit x_size, u32bit x_sw)
}
-/*************************************************
-* Multiplication Algorithm Dispatcher *
-*************************************************/
+/*
+* Multiplication Algorithm Dispatcher
+*/
void bigint_mul(word z[], u32bit z_size, word workspace[],
const word x[], u32bit x_size, u32bit x_sw,
const word y[], u32bit y_size, u32bit y_sw)
@@ -287,9 +289,9 @@ void bigint_mul(word z[], u32bit z_size, word workspace[],
}
}
-/*************************************************
-* Squaring Algorithm Dispatcher *
-*************************************************/
+/*
+* Squaring Algorithm Dispatcher
+*/
void bigint_sqr(word z[], u32bit z_size, word workspace[],
const word x[], u32bit x_size, u32bit x_sw)
{
diff --git a/src/math/bigint/mp_misc.cpp b/src/math/bigint/mp_misc.cpp
index db9c8cda0..6b7fc651b 100644
--- a/src/math/bigint/mp_misc.cpp
+++ b/src/math/bigint/mp_misc.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* MP Misc Functions Source File *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/*
+* MP Misc Functions
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/mp_core.h>
#include <botan/mp_asm.h>
@@ -10,9 +12,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Core Division Operation *
-*************************************************/
+/*
+* Core Division Operation
+*/
u32bit bigint_divcore(word q, word y1, word y2,
word x1, word x2, word x3)
{
@@ -29,9 +31,9 @@ u32bit bigint_divcore(word q, word y1, word y2,
return 0;
}
-/*************************************************
-* Compare two MP integers *
-*************************************************/
+/*
+* Compare two MP integers
+*/
s32bit bigint_cmp(const word x[], u32bit x_size,
const word y[], u32bit y_size)
{
@@ -51,9 +53,9 @@ s32bit bigint_cmp(const word x[], u32bit x_size,
return 0;
}
-/*************************************************
-* Do a 2-word/1-word Division *
-*************************************************/
+/*
+* Do a 2-word/1-word Division
+*/
word bigint_divop(word n1, word n0, word d)
{
word high = n1 % d, quotient = 0;
@@ -76,9 +78,9 @@ word bigint_divop(word n1, word n0, word d)
return quotient;
}
-/*************************************************
-* Do a 2-word/1-word Modulo *
-*************************************************/
+/*
+* Do a 2-word/1-word Modulo
+*/
word bigint_modop(word n1, word n0, word d)
{
word z = bigint_divop(n1, n0, d);
diff --git a/src/math/bigint/mp_shift.cpp b/src/math/bigint/mp_shift.cpp
index 033774e46..a7de79c77 100644
--- a/src/math/bigint/mp_shift.cpp
+++ b/src/math/bigint/mp_shift.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* MP Shift Algorithms Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* MP Shift Algorithms
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/mp_core.h>
#include <botan/mem_ops.h>
@@ -10,9 +12,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Single Operand Left Shift *
-*************************************************/
+/*
+* Single Operand Left Shift
+*/
void bigint_shl1(word x[], u32bit x_size, u32bit word_shift, u32bit bit_shift)
{
if(word_shift)
@@ -34,9 +36,9 @@ void bigint_shl1(word x[], u32bit x_size, u32bit word_shift, u32bit bit_shift)
}
}
-/*************************************************
-* Single Operand Right Shift *
-*************************************************/
+/*
+* Single Operand Right Shift
+*/
void bigint_shr1(word x[], u32bit x_size, u32bit word_shift, u32bit bit_shift)
{
if(x_size < word_shift)
@@ -89,9 +91,9 @@ void bigint_shr1(word x[], u32bit x_size, u32bit word_shift, u32bit bit_shift)
}
}
-/*************************************************
-* Two Operand Left Shift *
-*************************************************/
+/*
+* Two Operand Left Shift
+*/
void bigint_shl2(word y[], const word x[], u32bit x_size,
u32bit word_shift, u32bit bit_shift)
{
@@ -109,9 +111,9 @@ void bigint_shl2(word y[], const word x[], u32bit x_size,
}
}
-/*************************************************
-* Two Operand Right Shift *
-*************************************************/
+/*
+* Two Operand Right Shift
+*/
void bigint_shr2(word y[], const word x[], u32bit x_size,
u32bit word_shift, u32bit bit_shift)
{
diff --git a/src/math/bigint/mp_types.h b/src/math/bigint/mp_types.h
index 81b6d7395..1648713ed 100644
--- a/src/math/bigint/mp_types.h
+++ b/src/math/bigint/mp_types.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Low Level MPI Types Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Low Level MPI Types
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MPI_TYPES_H__
#define BOTAN_MPI_TYPES_H__
diff --git a/src/math/bigint/mulop_amd64/mp_mulop.cpp b/src/math/bigint/mulop_amd64/mp_mulop.cpp
index d1aa51489..cbd723e28 100644
--- a/src/math/bigint/mulop_amd64/mp_mulop.cpp
+++ b/src/math/bigint/mulop_amd64/mp_mulop.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Simple O(N^2) Multiplication and Squaring *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/*
+* Simple O(N^2) Multiplication and Squaring
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/mp_asm.h>
#include <botan/mp_asmi.h>
@@ -12,9 +14,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Simple O(N^2) Multiplication *
-*************************************************/
+/*
+* Simple O(N^2) Multiplication
+*/
void bigint_simple_mul(word z[], const word x[], u32bit x_size,
const word y[], u32bit y_size)
{
@@ -38,14 +40,14 @@ void bigint_simple_mul(word z[], const word x[], u32bit x_size,
inline word word_sqr(word x,
-/*************************************************
+/*
* Simple O(N^2) Squaring
This is exactly the same algorithm as bigint_simple_mul,
however because C/C++ compilers suck at alias analysis it
is good to have the version where the compiler knows
that x == y
-*************************************************/
+*/
void bigint_simple_sqr(word z[], const word x[], u32bit x_size)
{
clear_mem(z, 2*x_size);
diff --git a/src/math/bigint/mulop_generic/mp_mulop.cpp b/src/math/bigint/mulop_generic/mp_mulop.cpp
index daa394fe6..4647d00d5 100644
--- a/src/math/bigint/mulop_generic/mp_mulop.cpp
+++ b/src/math/bigint/mulop_generic/mp_mulop.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Simple O(N^2) Multiplication and Squaring *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/*
+* Simple O(N^2) Multiplication and Squaring
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/mp_asm.h>
#include <botan/mp_asmi.h>
@@ -12,9 +14,9 @@ namespace Botan {
extern "C" {
-/*************************************************
-* Simple O(N^2) Multiplication *
-*************************************************/
+/*
+* Simple O(N^2) Multiplication
+*/
void bigint_simple_mul(word z[], const word x[], u32bit x_size,
const word y[], u32bit y_size)
{
@@ -38,7 +40,7 @@ void bigint_simple_mul(word z[], const word x[], u32bit x_size,
}
}
-/*************************************************
+/*
* Simple O(N^2) Squaring
This is exactly the same algorithm as bigint_simple_mul,
@@ -48,7 +50,7 @@ that x == y
There is an O(n^1.5) squaring algorithm specified in Handbook of
Applied Cryptography, chapter 14
-*************************************************/
+*/
void bigint_simple_sqr(word z[], const word x[], u32bit x_size)
{
const u32bit x_size_8 = x_size - (x_size % 8);