aboutsummaryrefslogtreecommitdiffstats
path: root/src/math
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
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')
-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
-rw-r--r--src/math/gfpmath/curve_gfp.cpp16
-rw-r--r--src/math/gfpmath/curve_gfp.h22
-rw-r--r--src/math/gfpmath/gfp_element.cpp22
-rw-r--r--src/math/gfpmath/gfp_element.h22
-rw-r--r--src/math/gfpmath/gfp_modulus.h24
-rw-r--r--src/math/gfpmath/point_gfp.cpp20
-rw-r--r--src/math/gfpmath/point_gfp.h18
-rw-r--r--src/math/numbertheory/blinding.cpp28
-rw-r--r--src/math/numbertheory/blinding.h16
-rw-r--r--src/math/numbertheory/def_powm.h22
-rw-r--r--src/math/numbertheory/dsa_gen.cpp28
-rw-r--r--src/math/numbertheory/jacobi.cpp16
-rw-r--r--src/math/numbertheory/make_prm.cpp22
-rw-r--r--src/math/numbertheory/mp_numth.cpp28
-rw-r--r--src/math/numbertheory/numthry.cpp94
-rw-r--r--src/math/numbertheory/numthry.h66
-rw-r--r--src/math/numbertheory/pow_mod.cpp82
-rw-r--r--src/math/numbertheory/pow_mod.h34
-rw-r--r--src/math/numbertheory/powm_fw.cpp40
-rw-r--r--src/math/numbertheory/powm_mnt.cpp46
-rw-r--r--src/math/numbertheory/primes.cpp10
-rw-r--r--src/math/numbertheory/reducer.cpp34
-rw-r--r--src/math/numbertheory/reducer.h16
-rw-r--r--src/math/numbertheory/ressol.cpp18
51 files changed, 1044 insertions, 946 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);
diff --git a/src/math/gfpmath/curve_gfp.cpp b/src/math/gfpmath/curve_gfp.cpp
index 4b32e7095..37555ea06 100644
--- a/src/math/gfpmath/curve_gfp.cpp
+++ b/src/math/gfpmath/curve_gfp.cpp
@@ -1,11 +1,11 @@
-/******************************************************
-* Elliptic curves over GF(p) *
-* *
-* (C) 2007 Martin Doering *
-* Christoph Ludwig *
-* Falko Strenzke *
-* 2008 Jack Lloyd *
-******************************************************/
+/******
+* Elliptic curves over GF(p)
+*
+* (C) 2007 Martin Doering
+* Christoph Ludwig
+* Falko Strenzke
+* 2008 Jack Lloyd
+******/
#include <botan/curve_gfp.h>
#include <botan/bigint.h>
diff --git a/src/math/gfpmath/curve_gfp.h b/src/math/gfpmath/curve_gfp.h
index 4d8f9e1b8..90d64b45d 100644
--- a/src/math/gfpmath/curve_gfp.h
+++ b/src/math/gfpmath/curve_gfp.h
@@ -1,13 +1,13 @@
-/******************************************************
- * Elliptic curves over GF(p) (header file) *
- * *
- * (C) 2007 Martin Doering *
- * Christoph Ludwig *
- * Falko Strenzke *
- ******************************************************/
+/******
+ * Elliptic curves over GF(p) (header file)
+ *
+ * (C) 2007 Martin Doering
+ * Christoph Ludwig
+ * Falko Strenzke
+ ******/
#ifndef BOTAN_GFP_CURVE_H__
#define BOTAN_GFP_CURVE_H__
@@ -20,6 +20,8 @@ namespace Botan {
/**
* This class represents an elliptic curve over GF(p)
+*
+* Distributed under the terms of the Botan license
*/
class BOTAN_DLL CurveGFp
{
diff --git a/src/math/gfpmath/gfp_element.cpp b/src/math/gfpmath/gfp_element.cpp
index f5ef28a00..183d7d4ab 100644
--- a/src/math/gfpmath/gfp_element.cpp
+++ b/src/math/gfpmath/gfp_element.cpp
@@ -1,13 +1,13 @@
-/******************************************************
- * Arithmetic for prime fields GF(p) (source file) *
- * *
- * (C) 2007 Martin Doering *
- * Christoph Ludwig *
- * Falko Strenzke *
- ******************************************************/
+/******
+ * Arithmetic for prime fields GF(p) (source file)
+ *
+ * (C) 2007 Martin Doering
+ * Christoph Ludwig
+ * Falko Strenzke
+ ******/
#include <botan/gfp_element.h>
#include <botan/numthry.h>
@@ -127,6 +127,8 @@ void montg_mult(BigInt& result, BigInt& a_bar, BigInt& b_bar, const BigInt& m, c
/**
*calculates R=b^n (here b=2) with R>m (and R beeing as small as possible) for an odd modulus m.
* no check for oddity is performed!
+*
+* Distributed under the terms of the Botan license
*/
BigInt montgm_calc_r_oddmod(const BigInt& prime)
{
diff --git a/src/math/gfpmath/gfp_element.h b/src/math/gfpmath/gfp_element.h
index 6535d7e3e..0a1b4910c 100644
--- a/src/math/gfpmath/gfp_element.h
+++ b/src/math/gfpmath/gfp_element.h
@@ -1,13 +1,13 @@
-/******************************************************
- * Arithmetic for prime fields GF(p) (header file) *
- * *
- * (C) 2007 Martin Doering *
- * Christoph Ludwig *
- * Falko Strenzke *
- ******************************************************/
+/******
+ * Arithmetic for prime fields GF(p) (header file)
+ *
+ * (C) 2007 Martin Doering
+ * Christoph Ludwig
+ * Falko Strenzke
+ ******/
#ifndef BOTAN_GFP_ELEMENT_H__
#define BOTAN_GFP_ELEMENT_H__
@@ -92,7 +92,7 @@ class BOTAN_DLL GFpElement
* Assignment operator.
* makes *this a totally independent object
* (gives *this independent modulus specific values).
- *
+
* @param other The element to assign to our object
*/
const GFpElement& operator=(const GFpElement& other);
diff --git a/src/math/gfpmath/gfp_modulus.h b/src/math/gfpmath/gfp_modulus.h
index 55e0ff424..b5c085775 100644
--- a/src/math/gfpmath/gfp_modulus.h
+++ b/src/math/gfpmath/gfp_modulus.h
@@ -1,14 +1,14 @@
-/******************************************************
- * Modulus and related data for a specific *
- * implementation of GF(p) (header file) *
- * *
- * (C) 2008 Martin Döring *
- * Christoph Ludwig *
- * Falko Strenzke *
- ******************************************************/
+/******
+ * Modulus and related data for a specific
+ * implementation of GF(p) (header file)
+ *
+ * (C) 2008 Martin Döring
+ * Christoph Ludwig
+ * Falko Strenzke
+ ******/
#ifndef BOTAN_GFP_MODULUS_H__
#define BOTAN_GFP_MODULUS_H__
@@ -22,6 +22,8 @@ class BOTAN_DLL GFpElement;
/**
* This class represents a GFpElement modulus including the modulus related
* values necessary for the montgomery multiplication.
+*
+* Distributed under the terms of the Botan license
*/
class BOTAN_DLL GFpModulus
{
diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp
index 5312eeaee..9139c3ef9 100644
--- a/src/math/gfpmath/point_gfp.cpp
+++ b/src/math/gfpmath/point_gfp.cpp
@@ -1,12 +1,12 @@
-/******************************************************
-* Arithmetic for point groups of elliptic curves *
-* over GF(p) (source file) *
-* *
-* (C) 2007 Martin Doering *
-* Christoph Ludwig *
-* Falko Strenzke *
-* 2008 Jack Lloyd *
-******************************************************/
+/******
+* Arithmetic for point groups of elliptic curves
+* over GF(p) (source file)
+*
+* (C) 2007 Martin Doering
+* Christoph Ludwig
+* Falko Strenzke
+* 2008 Jack Lloyd
+******/
#include <botan/point_gfp.h>
#include <botan/numthry.h>
@@ -688,6 +688,8 @@ void PointGFp::turn_on_sp_red_mul() const
* returns a point equivalent to *this but were
* Z has value one, i.e. x and y correspond to
* their values in affine coordinates
+*
+* Distributed under the terms of the Botan license
*/
PointGFp const PointGFp::get_z_to_one() const
{
diff --git a/src/math/gfpmath/point_gfp.h b/src/math/gfpmath/point_gfp.h
index 687777075..771605efc 100644
--- a/src/math/gfpmath/point_gfp.h
+++ b/src/math/gfpmath/point_gfp.h
@@ -1,11 +1,13 @@
-/*************************************************
-* Arithmetic over GF(p) *
-* *
-* (C) 2007 Martin Doering *
-* Christoph Ludwig *
-* Falko Strenzke *
-* (C) 2008 Jack Lloyd *
-*************************************************/
+/*
+* Arithmetic over GF(p)
+*
+* (C) 2007 Martin Doering
+* Christoph Ludwig
+* Falko Strenzke
+* (C) 2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_POINT_GFP_H__
#define BOTAN_POINT_GFP_H__
diff --git a/src/math/numbertheory/blinding.cpp b/src/math/numbertheory/blinding.cpp
index 740904d10..c6a3fd1bd 100644
--- a/src/math/numbertheory/blinding.cpp
+++ b/src/math/numbertheory/blinding.cpp
@@ -1,16 +1,18 @@
-/*************************************************
-* Blinder Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Blinder
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/blinding.h>
#include <botan/numthry.h>
namespace Botan {
-/*************************************************
-* Blinder Constructor *
-*************************************************/
+/*
+* Blinder Constructor
+*/
Blinder::Blinder(const BigInt& e, const BigInt& d, const BigInt& n)
{
if(e < 1 || d < 1 || n < 1)
@@ -21,9 +23,9 @@ Blinder::Blinder(const BigInt& e, const BigInt& d, const BigInt& n)
this->d = d;
}
-/*************************************************
-* Blind a number *
-*************************************************/
+/*
+* Blind a number
+*/
BigInt Blinder::blind(const BigInt& i) const
{
if(!reducer.initialized())
@@ -34,9 +36,9 @@ BigInt Blinder::blind(const BigInt& i) const
return reducer.multiply(i, e);
}
-/*************************************************
-* Unblind a number *
-*************************************************/
+/*
+* Unblind a number
+*/
BigInt Blinder::unblind(const BigInt& i) const
{
if(!reducer.initialized())
diff --git a/src/math/numbertheory/blinding.h b/src/math/numbertheory/blinding.h
index 958686fb1..5f7f9e6b7 100644
--- a/src/math/numbertheory/blinding.h
+++ b/src/math/numbertheory/blinding.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Blinder Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Blinder
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_BLINDER_H__
#define BOTAN_BLINDER_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* Blinding Function Object *
-*************************************************/
+/*
+* Blinding Function Object
+*/
class BOTAN_DLL Blinder
{
public:
diff --git a/src/math/numbertheory/def_powm.h b/src/math/numbertheory/def_powm.h
index c91ff002c..472c865c3 100644
--- a/src/math/numbertheory/def_powm.h
+++ b/src/math/numbertheory/def_powm.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Modular Exponentiation Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Modular Exponentiation
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_DEFAULT_MODEXP_H__
#define BOTAN_DEFAULT_MODEXP_H__
@@ -12,9 +14,9 @@
namespace Botan {
-/*************************************************
-* Fixed Window Exponentiator *
-*************************************************/
+/*
+* Fixed Window Exponentiator
+*/
class BOTAN_DLL Fixed_Window_Exponentiator : public Modular_Exponentiator
{
public:
@@ -34,9 +36,9 @@ class BOTAN_DLL Fixed_Window_Exponentiator : public Modular_Exponentiator
Power_Mod::Usage_Hints hints;
};
-/*************************************************
-* Montgomery Exponentiator *
-*************************************************/
+/*
+* Montgomery Exponentiator
+*/
class BOTAN_DLL Montgomery_Exponentiator : public Modular_Exponentiator
{
public:
diff --git a/src/math/numbertheory/dsa_gen.cpp b/src/math/numbertheory/dsa_gen.cpp
index 1e44b7148..83646e50e 100644
--- a/src/math/numbertheory/dsa_gen.cpp
+++ b/src/math/numbertheory/dsa_gen.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* DSA Parameter Generation Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* DSA Parameter Generation
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/numthry.h>
#include <botan/algo_factory.h>
@@ -14,9 +16,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Check if this size is allowed by FIPS 186-3 *
-*************************************************/
+/*
+* Check if this size is allowed by FIPS 186-3
+*/
bool fips186_3_valid_size(u32bit pbits, u32bit qbits)
{
if(qbits == 160)
@@ -33,9 +35,9 @@ bool fips186_3_valid_size(u32bit pbits, u32bit qbits)
}
-/*************************************************
-* Attempt DSA prime generation with given seed *
-*************************************************/
+/*
+* Attempt DSA prime generation with given seed
+*/
bool generate_dsa_primes(RandomNumberGenerator& rng,
Algorithm_Factory& af,
BigInt& p, BigInt& q,
@@ -111,9 +113,9 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
return false;
}
-/*************************************************
-* Generate DSA Primes *
-*************************************************/
+/*
+* Generate DSA Primes
+*/
SecureVector<byte> generate_dsa_primes(RandomNumberGenerator& rng,
Algorithm_Factory& af,
BigInt& p, BigInt& q,
diff --git a/src/math/numbertheory/jacobi.cpp b/src/math/numbertheory/jacobi.cpp
index 57c78508a..2ad05ff71 100644
--- a/src/math/numbertheory/jacobi.cpp
+++ b/src/math/numbertheory/jacobi.cpp
@@ -1,15 +1,17 @@
-/*************************************************
-* Jacobi Function Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Jacobi Function
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/numthry.h>
namespace Botan {
-/*************************************************
-* Calculate the Jacobi symbol *
-*************************************************/
+/*
+* Calculate the Jacobi symbol
+*/
s32bit jacobi(const BigInt& a, const BigInt& n)
{
if(a.is_negative())
diff --git a/src/math/numbertheory/make_prm.cpp b/src/math/numbertheory/make_prm.cpp
index 30ac9a623..226f0c38f 100644
--- a/src/math/numbertheory/make_prm.cpp
+++ b/src/math/numbertheory/make_prm.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Prime Generation Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Prime Generation
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/numthry.h>
#include <botan/parsing.h>
@@ -9,9 +11,9 @@
namespace Botan {
-/*************************************************
-* Generate a random prime *
-*************************************************/
+/*
+* Generate a random prime
+*/
BigInt random_prime(RandomNumberGenerator& rng,
u32bit bits, const BigInt& coprime,
u32bit equiv, u32bit modulo)
@@ -76,9 +78,9 @@ BigInt random_prime(RandomNumberGenerator& rng,
}
}
-/*************************************************
-* Generate a random safe prime *
-*************************************************/
+/*
+* Generate a random safe prime
+*/
BigInt random_safe_prime(RandomNumberGenerator& rng, u32bit bits)
{
if(bits <= 64)
diff --git a/src/math/numbertheory/mp_numth.cpp b/src/math/numbertheory/mp_numth.cpp
index b024d2e2d..45a398440 100644
--- a/src/math/numbertheory/mp_numth.cpp
+++ b/src/math/numbertheory/mp_numth.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Fused and Important MP Algorithms Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Fused and Important MP Algorithms
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/numthry.h>
#include <botan/mp_core.h>
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* Square a BigInt *
-*************************************************/
+/*
+* Square a BigInt
+*/
BigInt square(const BigInt& x)
{
const u32bit x_sw = x.sig_words();
@@ -25,9 +27,9 @@ BigInt square(const BigInt& x)
return z;
}
-/*************************************************
-* Multiply-Add Operation *
-*************************************************/
+/*
+* Multiply-Add Operation
+*/
BigInt mul_add(const BigInt& a, const BigInt& b, const BigInt& c)
{
if(c.is_negative() || c.is_zero())
@@ -52,9 +54,9 @@ BigInt mul_add(const BigInt& a, const BigInt& b, const BigInt& c)
return r;
}
-/*************************************************
-* Subtract-Multiply Operation *
-*************************************************/
+/*
+* Subtract-Multiply Operation
+*/
BigInt sub_mul(const BigInt& a, const BigInt& b, const BigInt& c)
{
if(a.is_negative() || b.is_negative())
diff --git a/src/math/numbertheory/numthry.cpp b/src/math/numbertheory/numthry.cpp
index ffd523e82..d634ca88c 100644
--- a/src/math/numbertheory/numthry.cpp
+++ b/src/math/numbertheory/numthry.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Number Theory Source File *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/*
+* Number Theory
+* (C) 1999-2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/numthry.h>
#include <botan/bit_ops.h>
@@ -11,9 +13,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Miller-Rabin Iterations *
-*************************************************/
+/*
+* Miller-Rabin Iterations
+*/
u32bit miller_rabin_test_iterations(u32bit bits, bool verify)
{
struct mapping { u32bit bits; u32bit verify_iter; u32bit check_iter; };
@@ -69,9 +71,9 @@ u32bit miller_rabin_test_iterations(u32bit bits, bool verify)
}
-/*************************************************
-* Return the number of 0 bits at the end of n *
-*************************************************/
+/*
+* Return the number of 0 bits at the end of n
+*/
u32bit low_zero_bits(const BigInt& n)
{
if(n.is_negative() || n.is_zero()) return 0;
@@ -97,9 +99,9 @@ u32bit low_zero_bits(const BigInt& n)
return low_zero;
}
-/*************************************************
-* Calculate the GCD *
-*************************************************/
+/*
+* Calculate the GCD
+*/
BigInt gcd(const BigInt& a, const BigInt& b)
{
if(a.is_zero() || b.is_zero()) return 0;
@@ -124,17 +126,17 @@ BigInt gcd(const BigInt& a, const BigInt& b)
return (y << shift);
}
-/*************************************************
-* Calculate the LCM *
-*************************************************/
+/*
+* Calculate the LCM
+*/
BigInt lcm(const BigInt& a, const BigInt& b)
{
return ((a * b) / gcd(a, b));
}
-/*************************************************
-* Find the Modular Inverse *
-*************************************************/
+/*
+* Find the Modular Inverse
+*/
BigInt inverse_mod(const BigInt& n, const BigInt& mod)
{
if(mod.is_zero())
@@ -181,9 +183,9 @@ BigInt inverse_mod(const BigInt& n, const BigInt& mod)
return D;
}
-/*************************************************
-* Modular Exponentiation *
-*************************************************/
+/*
+* Modular Exponentiation
+*/
BigInt power_mod(const BigInt& base, const BigInt& exp, const BigInt& mod)
{
Power_Mod pow_mod(mod);
@@ -192,9 +194,9 @@ BigInt power_mod(const BigInt& base, const BigInt& exp, const BigInt& mod)
return pow_mod.execute();
}
-/*************************************************
-* Do simple tests of primality *
-*************************************************/
+/*
+* Do simple tests of primality
+*/
s32bit simple_primality_tests(const BigInt& n)
{
const s32bit NOT_PRIME = -1, UNKNOWN = 0, PRIME = 1;
@@ -223,33 +225,33 @@ s32bit simple_primality_tests(const BigInt& n)
return UNKNOWN;
}
-/*************************************************
-* Fast check of primality *
-*************************************************/
+/*
+* Fast check of primality
+*/
bool check_prime(const BigInt& n, RandomNumberGenerator& rng)
{
return run_primality_tests(rng, n, 0);
}
-/*************************************************
-* Test for primality *
-*************************************************/
+/*
+* Test for primality
+*/
bool is_prime(const BigInt& n, RandomNumberGenerator& rng)
{
return run_primality_tests(rng, n, 1);
}
-/*************************************************
-* Verify primality *
-*************************************************/
+/*
+* Verify primality
+*/
bool verify_prime(const BigInt& n, RandomNumberGenerator& rng)
{
return run_primality_tests(rng, n, 2);
}
-/*************************************************
-* Verify primality *
-*************************************************/
+/*
+* Verify primality
+*/
bool run_primality_tests(RandomNumberGenerator& rng,
const BigInt& n, u32bit level)
{
@@ -258,9 +260,9 @@ bool run_primality_tests(RandomNumberGenerator& rng,
return passes_mr_tests(rng, n, level);
}
-/*************************************************
-* Test for primaility using Miller-Rabin *
-*************************************************/
+/*
+* Test for primaility using Miller-Rabin
+*/
bool passes_mr_tests(RandomNumberGenerator& rng,
const BigInt& n, u32bit level)
{
@@ -295,9 +297,9 @@ bool passes_mr_tests(RandomNumberGenerator& rng,
return true;
}
-/*************************************************
-* Miller-Rabin Test *
-*************************************************/
+/*
+* Miller-Rabin Test
+*/
bool MillerRabin_Test::passes_test(const BigInt& a)
{
if(a < 2 || a >= n_minus_1)
@@ -319,9 +321,9 @@ bool MillerRabin_Test::passes_test(const BigInt& a)
return false;
}
-/*************************************************
-* Miller-Rabin Constructor *
-*************************************************/
+/*
+* Miller-Rabin Constructor
+*/
MillerRabin_Test::MillerRabin_Test(const BigInt& num)
{
if(num.is_even() || num < 3)
diff --git a/src/math/numbertheory/numthry.h b/src/math/numbertheory/numthry.h
index 78910d063..e4c043799 100644
--- a/src/math/numbertheory/numthry.h
+++ b/src/math/numbertheory/numthry.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Number Theory Functions Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Number Theory Functions
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_NUMBER_THEORY_H__
#define BOTAN_NUMBER_THEORY_H__
@@ -13,15 +15,15 @@
namespace Botan {
-/*************************************************
-* Fused Arithmetic Operations *
-*************************************************/
+/*
+* Fused Arithmetic Operations
+*/
BigInt BOTAN_DLL mul_add(const BigInt&, const BigInt&, const BigInt&);
BigInt BOTAN_DLL sub_mul(const BigInt&, const BigInt&, const BigInt&);
-/*************************************************
-* Number Theory Functions *
-*************************************************/
+/*
+* Number Theory Functions
+*/
inline BigInt abs(const BigInt& n) { return n.abs(); }
void BOTAN_DLL divide(const BigInt&, const BigInt&, BigInt&, BigInt&);
@@ -35,20 +37,20 @@ s32bit BOTAN_DLL jacobi(const BigInt&, const BigInt&);
BigInt BOTAN_DLL power_mod(const BigInt&, const BigInt&, const BigInt&);
-/*************************************************
-* Compute the square root of x modulo a prime *
-* using the Shanks-Tonnelli algorithm *
-*************************************************/
+/*
+* Compute the square root of x modulo a prime
+* using the Shanks-Tonnelli algorithm
+*/
BigInt ressol(const BigInt& x, const BigInt& p);
-/*************************************************
-* Utility Functions *
-*************************************************/
+/*
+* Utility Functions
+*/
u32bit BOTAN_DLL low_zero_bits(const BigInt&);
-/*************************************************
-* Primality Testing *
-*************************************************/
+/*
+* Primality Testing
+*/
bool BOTAN_DLL check_prime(const BigInt&, RandomNumberGenerator&);
bool BOTAN_DLL is_prime(const BigInt&, RandomNumberGenerator&);
bool BOTAN_DLL verify_prime(const BigInt&, RandomNumberGenerator&);
@@ -61,9 +63,9 @@ bool BOTAN_DLL passes_mr_tests(RandomNumberGenerator&,
bool BOTAN_DLL run_primality_tests(RandomNumberGenerator&,
const BigInt&, u32bit = 1);
-/*************************************************
-* Random Number Generation *
-*************************************************/
+/*
+* Random Number Generation
+*/
BigInt BOTAN_DLL random_prime(RandomNumberGenerator&,
u32bit bits, const BigInt& coprime = 1,
u32bit equiv = 1, u32bit equiv_mod = 2);
@@ -71,9 +73,9 @@ BigInt BOTAN_DLL random_prime(RandomNumberGenerator&,
BigInt BOTAN_DLL random_safe_prime(RandomNumberGenerator&,
u32bit);
-/*************************************************
-* DSA Parameter Generation *
-*************************************************/
+/*
+* DSA Parameter Generation
+*/
class Algorithm_Factory;
SecureVector<byte> BOTAN_DLL
@@ -89,18 +91,18 @@ generate_dsa_primes(RandomNumberGenerator& rng,
u32bit p_bits, u32bit q_bits,
const MemoryRegion<byte>& seed);
-/*************************************************
-* Prime Numbers *
-*************************************************/
+/*
+* Prime Numbers
+*/
const u32bit PRIME_TABLE_SIZE = 6541;
const u32bit PRIME_PRODUCTS_TABLE_SIZE = 256;
extern const u16bit BOTAN_DLL PRIMES[];
extern const u64bit PRIME_PRODUCTS[];
-/*************************************************
-* Miller-Rabin Primality Tester *
-*************************************************/
+/*
+* Miller-Rabin Primality Tester
+*/
class BOTAN_DLL MillerRabin_Test
{
public:
diff --git a/src/math/numbertheory/pow_mod.cpp b/src/math/numbertheory/pow_mod.cpp
index 17ca7b796..4801a945c 100644
--- a/src/math/numbertheory/pow_mod.cpp
+++ b/src/math/numbertheory/pow_mod.cpp
@@ -1,25 +1,27 @@
-/*************************************************
-* Modular Exponentiation Proxy Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Modular Exponentiation Proxy
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/pow_mod.h>
#include <botan/engine.h>
namespace Botan {
-/*************************************************
-* Power_Mod Constructor *
-*************************************************/
+/*
+* Power_Mod Constructor
+*/
Power_Mod::Power_Mod(const BigInt& n, Usage_Hints hints)
{
core = 0;
set_modulus(n, hints);
}
-/*************************************************
-* Power_Mod Copy Constructor *
-*************************************************/
+/*
+* Power_Mod Copy Constructor
+*/
Power_Mod::Power_Mod(const Power_Mod& other)
{
core = 0;
@@ -27,9 +29,9 @@ Power_Mod::Power_Mod(const Power_Mod& other)
core = other.core->copy();
}
-/*************************************************
-* Power_Mod Assignment Operator *
-*************************************************/
+/*
+* Power_Mod Assignment Operator
+*/
Power_Mod& Power_Mod::operator=(const Power_Mod& other)
{
delete core;
@@ -39,26 +41,26 @@ Power_Mod& Power_Mod::operator=(const Power_Mod& other)
return (*this);
}
-/*************************************************
-* Power_Mod Destructor *
-*************************************************/
+/*
+* Power_Mod Destructor
+*/
Power_Mod::~Power_Mod()
{
delete core;
}
-/*************************************************
-* Set the modulus *
-*************************************************/
+/*
+* Set the modulus
+*/
void Power_Mod::set_modulus(const BigInt& n, Usage_Hints hints) const
{
delete core;
core = ((n == 0) ? 0 : Engine_Core::mod_exp(n, hints));
}
-/*************************************************
-* Set the base *
-*************************************************/
+/*
+* Set the base
+*/
void Power_Mod::set_base(const BigInt& b) const
{
if(b.is_zero() || b.is_negative())
@@ -69,9 +71,9 @@ void Power_Mod::set_base(const BigInt& b) const
core->set_base(b);
}
-/*************************************************
-* Set the exponent *
-*************************************************/
+/*
+* Set the exponent
+*/
void Power_Mod::set_exponent(const BigInt& e) const
{
if(e.is_negative())
@@ -82,9 +84,9 @@ void Power_Mod::set_exponent(const BigInt& e) const
core->set_exponent(e);
}
-/*************************************************
-* Compute the result *
-*************************************************/
+/*
+* Compute the result
+*/
BigInt Power_Mod::execute() const
{
if(!core)
@@ -94,9 +96,9 @@ BigInt Power_Mod::execute() const
namespace {
-/*************************************************
-* Choose potentially useful hints *
-*************************************************/
+/*
+* Choose potentially useful hints
+*/
Power_Mod::Usage_Hints choose_base_hints(const BigInt& b, const BigInt& n)
{
if(b == 2)
@@ -114,9 +116,9 @@ Power_Mod::Usage_Hints choose_base_hints(const BigInt& b, const BigInt& n)
return Power_Mod::NO_HINTS;
}
-/*************************************************
-* Choose potentially useful hints *
-*************************************************/
+/*
+* Choose potentially useful hints
+*/
Power_Mod::Usage_Hints choose_exp_hints(const BigInt& e, const BigInt& n)
{
const u32bit e_bits = e.bits();
@@ -131,9 +133,9 @@ Power_Mod::Usage_Hints choose_exp_hints(const BigInt& e, const BigInt& n)
}
-/*************************************************
-* Fixed_Exponent_Power_Mod Constructor *
-*************************************************/
+/*
+* Fixed_Exponent_Power_Mod Constructor
+*/
Fixed_Exponent_Power_Mod::Fixed_Exponent_Power_Mod(const BigInt& e,
const BigInt& n,
Usage_Hints hints) :
@@ -142,9 +144,9 @@ Fixed_Exponent_Power_Mod::Fixed_Exponent_Power_Mod(const BigInt& e,
set_exponent(e);
}
-/*************************************************
-* Fixed_Base_Power_Mod Constructor *
-*************************************************/
+/*
+* Fixed_Base_Power_Mod Constructor
+*/
Fixed_Base_Power_Mod::Fixed_Base_Power_Mod(const BigInt& b, const BigInt& n,
Usage_Hints hints) :
Power_Mod(n, Usage_Hints(hints | BASE_IS_FIXED | choose_base_hints(b, n)))
diff --git a/src/math/numbertheory/pow_mod.h b/src/math/numbertheory/pow_mod.h
index 37e0871da..6952dcd1b 100644
--- a/src/math/numbertheory/pow_mod.h
+++ b/src/math/numbertheory/pow_mod.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Modular Exponentiator Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Modular Exponentiator
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_POWER_MOD_H__
#define BOTAN_POWER_MOD_H__
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* Modular Exponentiator Interface *
-*************************************************/
+/*
+* Modular Exponentiator Interface
+*/
class BOTAN_DLL Modular_Exponentiator
{
public:
@@ -23,9 +25,9 @@ class BOTAN_DLL Modular_Exponentiator
virtual ~Modular_Exponentiator() {}
};
-/*************************************************
-* Modular Exponentiator Proxy *
-*************************************************/
+/*
+* Modular Exponentiator Proxy
+*/
class BOTAN_DLL Power_Mod
{
public:
@@ -58,9 +60,9 @@ class BOTAN_DLL Power_Mod
Usage_Hints hints;
};
-/*************************************************
-* Fixed Exponent Modular Exponentiator Proxy *
-*************************************************/
+/*
+* Fixed Exponent Modular Exponentiator Proxy
+*/
class BOTAN_DLL Fixed_Exponent_Power_Mod : public Power_Mod
{
public:
@@ -72,9 +74,9 @@ class BOTAN_DLL Fixed_Exponent_Power_Mod : public Power_Mod
Usage_Hints = NO_HINTS);
};
-/*************************************************
-* Fixed Base Modular Exponentiator Proxy *
-*************************************************/
+/*
+* Fixed Base Modular Exponentiator Proxy
+*/
class BOTAN_DLL Fixed_Base_Power_Mod : public Power_Mod
{
public:
diff --git a/src/math/numbertheory/powm_fw.cpp b/src/math/numbertheory/powm_fw.cpp
index c29b9f311..b764ee7aa 100644
--- a/src/math/numbertheory/powm_fw.cpp
+++ b/src/math/numbertheory/powm_fw.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Fixed Window Exponentiation Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Fixed Window Exponentiation
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/def_powm.h>
#include <botan/numthry.h>
@@ -11,9 +13,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Try to choose a good window size *
-*************************************************/
+/*
+* Try to choose a good window size
+*/
u32bit choose_window_bits(u32bit exp_bits, u32bit,
Power_Mod::Usage_Hints hints)
{
@@ -47,17 +49,17 @@ u32bit choose_window_bits(u32bit exp_bits, u32bit,
}
-/*************************************************
-* Set the exponent *
-*************************************************/
+/*
+* Set the exponent
+*/
void Fixed_Window_Exponentiator::set_exponent(const BigInt& e)
{
exp = e;
}
-/*************************************************
-* Set the base *
-*************************************************/
+/*
+* Set the base
+*/
void Fixed_Window_Exponentiator::set_base(const BigInt& base)
{
window_bits = choose_window_bits(exp.bits(), base.bits(), hints);
@@ -68,9 +70,9 @@ void Fixed_Window_Exponentiator::set_base(const BigInt& base)
g[j] = reducer.multiply(g[j-1], g[0]);
}
-/*************************************************
-* Compute the result *
-*************************************************/
+/*
+* Compute the result
+*/
BigInt Fixed_Window_Exponentiator::execute() const
{
const u32bit exp_nibbles = (exp.bits() + window_bits - 1) / window_bits;
@@ -88,9 +90,9 @@ BigInt Fixed_Window_Exponentiator::execute() const
return x;
}
-/*************************************************
-* Fixed_Window_Exponentiator Constructor *
-*************************************************/
+/*
+* Fixed_Window_Exponentiator Constructor
+*/
Fixed_Window_Exponentiator::Fixed_Window_Exponentiator(const BigInt& n,
Power_Mod::Usage_Hints hints)
{
diff --git a/src/math/numbertheory/powm_mnt.cpp b/src/math/numbertheory/powm_mnt.cpp
index 6091d467a..e6d8cc3f0 100644
--- a/src/math/numbertheory/powm_mnt.cpp
+++ b/src/math/numbertheory/powm_mnt.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Montgomery Exponentiation Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Montgomery Exponentiation
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/def_powm.h>
#include <botan/numthry.h>
@@ -11,9 +13,9 @@ namespace Botan {
namespace {
-/*************************************************
-* Try to choose a good window size *
-*************************************************/
+/*
+* Try to choose a good window size
+*/
u32bit choose_window_bits(u32bit exp_bits, u32bit,
Power_Mod::Usage_Hints hints)
{
@@ -43,9 +45,9 @@ u32bit choose_window_bits(u32bit exp_bits, u32bit,
return window_bits;
}
-/*************************************************
-* Montgomery Reduction *
-*************************************************/
+/*
+* Montgomery Reduction
+*/
inline void montgomery_reduce(BigInt& out, MemoryRegion<word>& z_buf,
const BigInt& x_bn, u32bit x_size, word u)
{
@@ -60,18 +62,18 @@ inline void montgomery_reduce(BigInt& out, MemoryRegion<word>& z_buf,
}
-/*************************************************
-* Set the exponent *
-*************************************************/
+/*
+* Set the exponent
+*/
void Montgomery_Exponentiator::set_exponent(const BigInt& exp)
{
this->exp = exp;
exp_bits = exp.bits();
}
-/*************************************************
-* Set the base *
-*************************************************/
+/*
+* Set the base
+*/
void Montgomery_Exponentiator::set_base(const BigInt& base)
{
window_bits = choose_window_bits(exp.bits(), base.bits(), hints);
@@ -105,9 +107,9 @@ void Montgomery_Exponentiator::set_base(const BigInt& base)
}
}
-/*************************************************
-* Compute the result *
-*************************************************/
+/*
+* Compute the result
+*/
BigInt Montgomery_Exponentiator::execute() const
{
const u32bit exp_nibbles = (exp_bits + window_bits - 1) / window_bits;
@@ -148,9 +150,9 @@ BigInt Montgomery_Exponentiator::execute() const
return x;
}
-/*************************************************
-* Montgomery_Exponentiator Constructor *
-*************************************************/
+/*
+* Montgomery_Exponentiator Constructor
+*/
Montgomery_Exponentiator::Montgomery_Exponentiator(const BigInt& mod,
Power_Mod::Usage_Hints hints)
{
diff --git a/src/math/numbertheory/primes.cpp b/src/math/numbertheory/primes.cpp
index d005167e5..26ff098a5 100644
--- a/src/math/numbertheory/primes.cpp
+++ b/src/math/numbertheory/primes.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Small Primes Table *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Small Primes Table
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/numthry.h>
diff --git a/src/math/numbertheory/reducer.cpp b/src/math/numbertheory/reducer.cpp
index 47c5c20fc..fbd675ea6 100644
--- a/src/math/numbertheory/reducer.cpp
+++ b/src/math/numbertheory/reducer.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* Modular Reducer Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Modular Reducer
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/reducer.h>
#include <botan/numthry.h>
@@ -9,9 +11,9 @@
namespace Botan {
-/*************************************************
-* Modular_Reducer Constructor *
-*************************************************/
+/*
+* Modular_Reducer Constructor
+*/
Modular_Reducer::Modular_Reducer(const BigInt& mod)
{
if(mod <= 0)
@@ -27,9 +29,9 @@ Modular_Reducer::Modular_Reducer(const BigInt& mod)
mu_words = mu.sig_words();
}
-/*************************************************
-* Barrett Reduction *
-*************************************************/
+/*
+* Barrett Reduction
+*/
BigInt Modular_Reducer::reduce(const BigInt& x) const
{
if(mod_words == 0)
@@ -76,17 +78,17 @@ BigInt Modular_Reducer::reduce(const BigInt& x) const
return t1;
}
-/*************************************************
-* Multiply, followed by a reduction *
-*************************************************/
+/*
+* Multiply, followed by a reduction
+*/
BigInt Modular_Reducer::multiply(const BigInt& x, const BigInt& y) const
{
return reduce(x * y);
}
-/*************************************************
-* Square, followed by a reduction *
-*************************************************/
+/*
+* Square, followed by a reduction
+*/
BigInt Modular_Reducer::square(const BigInt& x) const
{
return reduce(Botan::square(x));
diff --git a/src/math/numbertheory/reducer.h b/src/math/numbertheory/reducer.h
index 48008e73b..d234e0735 100644
--- a/src/math/numbertheory/reducer.h
+++ b/src/math/numbertheory/reducer.h
@@ -1,7 +1,9 @@
-/*************************************************
-* Modular Reducer Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* Modular Reducer
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_MODARITH_H__
#define BOTAN_MODARITH_H__
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* Modular Reducer *
-*************************************************/
+/*
+* Modular Reducer
+*/
class BOTAN_DLL Modular_Reducer
{
public:
diff --git a/src/math/numbertheory/ressol.cpp b/src/math/numbertheory/ressol.cpp
index 0cd2b988a..6a078726d 100644
--- a/src/math/numbertheory/ressol.cpp
+++ b/src/math/numbertheory/ressol.cpp
@@ -1,8 +1,10 @@
-/*************************************************
-* Shanks-Tonnelli (RESSOL) Source File *
-* (C) 2007-2008 Falko Strenzke, FlexSecure GmbH *
-* (C) 2008 Jack Lloyd *
-*************************************************/
+/*
+* Shanks-Tonnelli (RESSOL)
+* (C) 2007-2008 Falko Strenzke, FlexSecure GmbH
+* (C) 2008 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/numthry.h>
#include <botan/reducer.h>
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* Shanks-Tonnelli algorithm *
-*************************************************/
+/*
+* Shanks-Tonnelli algorithm
+*/
BigInt ressol(const BigInt& a, const BigInt& p)
{
if(a < 0)