aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/gnump
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/engine/gnump
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/engine/gnump')
-rw-r--r--src/engine/gnump/eng_gmp.h16
-rw-r--r--src/engine/gnump/gmp_dh.cpp28
-rw-r--r--src/engine/gnump/gmp_dsa.cpp34
-rw-r--r--src/engine/gnump/gmp_elg.cpp34
-rw-r--r--src/engine/gnump/gmp_if.cpp34
-rw-r--r--src/engine/gnump/gmp_mem.cpp46
-rw-r--r--src/engine/gnump/gmp_nr.cpp34
-rw-r--r--src/engine/gnump/gmp_powm.cpp28
-rw-r--r--src/engine/gnump/gmp_wrap.cpp58
-rw-r--r--src/engine/gnump/gmp_wrap.h16
10 files changed, 174 insertions, 154 deletions
diff --git a/src/engine/gnump/eng_gmp.h b/src/engine/gnump/eng_gmp.h
index 8edaae374..6a52b7e51 100644
--- a/src/engine/gnump/eng_gmp.h
+++ b/src/engine/gnump/eng_gmp.h
@@ -1,7 +1,9 @@
-/*************************************************
-* GMP Engine Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GMP Engine
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_ENGINE_GMP_H__
#define BOTAN_ENGINE_GMP_H__
@@ -10,9 +12,9 @@
namespace Botan {
-/*************************************************
-* GMP Engine *
-*************************************************/
+/*
+* GMP Engine
+*/
class BOTAN_DLL GMP_Engine : public Engine
{
public:
diff --git a/src/engine/gnump/gmp_dh.cpp b/src/engine/gnump/gmp_dh.cpp
index ef2732626..b33240268 100644
--- a/src/engine/gnump/gmp_dh.cpp
+++ b/src/engine/gnump/gmp_dh.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* GMP Engine Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GMP Engine
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/eng_gmp.h>
#include <botan/gmp_wrap.h>
@@ -12,9 +14,9 @@ namespace Botan {
#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
namespace {
-/*************************************************
-* GMP DH Operation *
-*************************************************/
+/*
+* GMP DH Operation
+*/
class GMP_DH_Op : public DH_Operation
{
public:
@@ -27,9 +29,9 @@ class GMP_DH_Op : public DH_Operation
GMP_MPZ x, p;
};
-/*************************************************
-* GMP DH Key Agreement Operation *
-*************************************************/
+/*
+* GMP DH Key Agreement Operation
+*/
BigInt GMP_DH_Op::agree(const BigInt& i_bn) const
{
GMP_MPZ i(i_bn);
@@ -39,9 +41,9 @@ BigInt GMP_DH_Op::agree(const BigInt& i_bn) const
}
-/*************************************************
-* Acquire a DH op *
-*************************************************/
+/*
+* Acquire a DH op
+*/
DH_Operation* GMP_Engine::dh_op(const DL_Group& group, const BigInt& x) const
{
return new GMP_DH_Op(group, x);
diff --git a/src/engine/gnump/gmp_dsa.cpp b/src/engine/gnump/gmp_dsa.cpp
index 209c6e0a6..69a9c3e9c 100644
--- a/src/engine/gnump/gmp_dsa.cpp
+++ b/src/engine/gnump/gmp_dsa.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* GMP DSA Engine Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GMP DSA Engine
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/eng_gmp.h>
#include <botan/gmp_wrap.h>
@@ -13,9 +15,9 @@ namespace Botan {
namespace {
-/*************************************************
-* GMP DSA Operation *
-*************************************************/
+/*
+* GMP DSA Operation
+*/
class GMP_DSA_Op : public DSA_Operation
{
public:
@@ -30,9 +32,9 @@ class GMP_DSA_Op : public DSA_Operation
const GMP_MPZ x, y, p, q, g;
};
-/*************************************************
-* GMP DSA Verify Operation *
-*************************************************/
+/*
+* GMP DSA Verify Operation
+*/
bool GMP_DSA_Op::verify(const byte msg[], u32bit msg_len,
const byte sig[], u32bit sig_len) const
{
@@ -72,9 +74,9 @@ bool GMP_DSA_Op::verify(const byte msg[], u32bit msg_len,
return false;
}
-/*************************************************
-* GMP DSA Sign Operation *
-*************************************************/
+/*
+* GMP DSA Sign Operation
+*/
SecureVector<byte> GMP_DSA_Op::sign(const byte in[], u32bit length,
const BigInt& k_bn) const
{
@@ -109,9 +111,9 @@ SecureVector<byte> GMP_DSA_Op::sign(const byte in[], u32bit length,
}
-/*************************************************
-* Acquire a DSA op *
-*************************************************/
+/*
+* Acquire a DSA op
+*/
DSA_Operation* GMP_Engine::dsa_op(const DL_Group& group, const BigInt& y,
const BigInt& x) const
{
diff --git a/src/engine/gnump/gmp_elg.cpp b/src/engine/gnump/gmp_elg.cpp
index 63e9440ff..ee109f1d6 100644
--- a/src/engine/gnump/gmp_elg.cpp
+++ b/src/engine/gnump/gmp_elg.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* GMP ElGamal Engine Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GMP ElGamal Engine
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/eng_gmp.h>
#include <botan/gmp_wrap.h>
@@ -13,9 +15,9 @@ namespace Botan {
namespace {
-/*************************************************
-* GMP ElGamal Operation *
-*************************************************/
+/*
+* GMP ElGamal Operation
+*/
class GMP_ELG_Op : public ELG_Operation
{
public:
@@ -30,9 +32,9 @@ class GMP_ELG_Op : public ELG_Operation
GMP_MPZ x, y, g, p;
};
-/*************************************************
-* GMP ElGamal Encrypt Operation *
-*************************************************/
+/*
+* GMP ElGamal Encrypt Operation
+*/
SecureVector<byte> GMP_ELG_Op::encrypt(const byte in[], u32bit length,
const BigInt& k_bn) const
{
@@ -55,9 +57,9 @@ SecureVector<byte> GMP_ELG_Op::encrypt(const byte in[], u32bit length,
return output;
}
-/*************************************************
-* GMP ElGamal Decrypt Operation *
-*************************************************/
+/*
+* GMP ElGamal Decrypt Operation
+*/
BigInt GMP_ELG_Op::decrypt(const BigInt& a_bn, const BigInt& b_bn) const
{
if(mpz_cmp_ui(x.value, 0) == 0)
@@ -77,9 +79,9 @@ BigInt GMP_ELG_Op::decrypt(const BigInt& a_bn, const BigInt& b_bn) const
}
-/*************************************************
-* Acquire an ElGamal op *
-*************************************************/
+/*
+* Acquire an ElGamal op
+*/
ELG_Operation* GMP_Engine::elg_op(const DL_Group& group, const BigInt& y,
const BigInt& x) const
{
diff --git a/src/engine/gnump/gmp_if.cpp b/src/engine/gnump/gmp_if.cpp
index a4a4d0476..b96f2ddac 100644
--- a/src/engine/gnump/gmp_if.cpp
+++ b/src/engine/gnump/gmp_if.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* GMP IF Engine Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GMP IF Engine
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/eng_gmp.h>
#include <botan/gmp_wrap.h>
@@ -13,9 +15,9 @@ namespace Botan {
namespace {
-/*************************************************
-* GMP IF Operation *
-*************************************************/
+/*
+* GMP IF Operation
+*/
class GMP_IF_Op : public IF_Operation
{
public:
@@ -32,9 +34,9 @@ class GMP_IF_Op : public IF_Operation
const GMP_MPZ e, n, p, q, d1, d2, c;
};
-/*************************************************
-* GMP IF Public Operation *
-*************************************************/
+/*
+* GMP IF Public Operation
+*/
BigInt GMP_IF_Op::public_op(const BigInt& i_bn) const
{
GMP_MPZ i(i_bn);
@@ -42,9 +44,9 @@ BigInt GMP_IF_Op::public_op(const BigInt& i_bn) const
return i.to_bigint();
}
-/*************************************************
-* GMP IF Private Operation *
-*************************************************/
+/*
+* GMP IF Private Operation
+*/
BigInt GMP_IF_Op::private_op(const BigInt& i_bn) const
{
if(mpz_cmp_ui(p.value, 0) == 0)
@@ -64,9 +66,9 @@ BigInt GMP_IF_Op::private_op(const BigInt& i_bn) const
}
-/*************************************************
-* Acquire an IF op *
-*************************************************/
+/*
+* Acquire an IF op
+*/
IF_Operation* GMP_Engine::if_op(const BigInt& e, const BigInt& n,
const BigInt& d, const BigInt& p,
const BigInt& q, const BigInt& d1,
diff --git a/src/engine/gnump/gmp_mem.cpp b/src/engine/gnump/gmp_mem.cpp
index 91ba94dd7..89a1ed2d4 100644
--- a/src/engine/gnump/gmp_mem.cpp
+++ b/src/engine/gnump/gmp_mem.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* GNU MP Memory Handlers Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GNU MP Memory Handlers
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/eng_gmp.h>
#include <cstring>
@@ -11,22 +13,22 @@ namespace Botan {
namespace {
-/*************************************************
-* Allocator used by GNU MP *
-*************************************************/
+/*
+* Allocator used by GNU MP
+*/
Allocator* gmp_alloc = 0;
-/*************************************************
-* Allocation Function for GNU MP *
-*************************************************/
+/*
+* Allocation Function for GNU MP
+*/
void* gmp_malloc(size_t n)
{
return gmp_alloc->allocate(n);
}
-/*************************************************
-* Reallocation Function for GNU MP *
-*************************************************/
+/*
+* Reallocation Function for GNU MP
+*/
void* gmp_realloc(void* ptr, size_t old_n, size_t new_n)
{
void* new_buf = gmp_alloc->allocate(new_n);
@@ -35,9 +37,9 @@ void* gmp_realloc(void* ptr, size_t old_n, size_t new_n)
return new_buf;
}
-/*************************************************
-* Deallocation Function for GNU MP *
-*************************************************/
+/*
+* Deallocation Function for GNU MP
+*/
void gmp_free(void* ptr, size_t n)
{
gmp_alloc->deallocate(ptr, n);
@@ -45,9 +47,9 @@ void gmp_free(void* ptr, size_t n)
}
-/*************************************************
-* Set the GNU MP memory functions *
-*************************************************/
+/*
+* Set the GNU MP memory functions
+*/
void GMP_Engine::set_memory_hooks()
{
if(gmp_alloc == 0)
@@ -57,9 +59,9 @@ void GMP_Engine::set_memory_hooks()
}
}
-/*************************************************
-* GMP_Engine Constructor *
-*************************************************/
+/*
+* GMP_Engine Constructor
+*/
GMP_Engine::GMP_Engine()
{
set_memory_hooks();
diff --git a/src/engine/gnump/gmp_nr.cpp b/src/engine/gnump/gmp_nr.cpp
index 97b7e5554..4aeb09fe2 100644
--- a/src/engine/gnump/gmp_nr.cpp
+++ b/src/engine/gnump/gmp_nr.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* GMP NR Engine Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GMP NR Engine
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/eng_gmp.h>
#include <botan/gmp_wrap.h>
@@ -13,9 +15,9 @@ namespace Botan {
namespace {
-/*************************************************
-* GMP NR Operation *
-*************************************************/
+/*
+* GMP NR Operation
+*/
class GMP_NR_Op : public NR_Operation
{
public:
@@ -30,9 +32,9 @@ class GMP_NR_Op : public NR_Operation
const GMP_MPZ x, y, p, q, g;
};
-/*************************************************
-* GMP NR Verify Operation *
-*************************************************/
+/*
+* GMP NR Verify Operation
+*/
SecureVector<byte> GMP_NR_Op::verify(const byte sig[], u32bit sig_len) const
{
const u32bit q_bytes = q.bytes();
@@ -57,9 +59,9 @@ SecureVector<byte> GMP_NR_Op::verify(const byte sig[], u32bit sig_len) const
return BigInt::encode(i1.to_bigint());
}
-/*************************************************
-* GMP NR Sign Operation *
-*************************************************/
+/*
+* GMP NR Sign Operation
+*/
SecureVector<byte> GMP_NR_Op::sign(const byte in[], u32bit length,
const BigInt& k_bn) const
{
@@ -92,9 +94,9 @@ SecureVector<byte> GMP_NR_Op::sign(const byte in[], u32bit length,
}
-/*************************************************
-* Acquire a NR op *
-*************************************************/
+/*
+* Acquire a NR op
+*/
NR_Operation* GMP_Engine::nr_op(const DL_Group& group, const BigInt& y,
const BigInt& x) const
{
diff --git a/src/engine/gnump/gmp_powm.cpp b/src/engine/gnump/gmp_powm.cpp
index a5e3d1c0d..687aed88a 100644
--- a/src/engine/gnump/gmp_powm.cpp
+++ b/src/engine/gnump/gmp_powm.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* GMP Modular Exponentiation Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GMP Modular Exponentiation
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/eng_gmp.h>
#include <botan/gmp_wrap.h>
@@ -10,9 +12,9 @@ namespace Botan {
namespace {
-/*************************************************
-* GMP Modular Exponentiator *
-*************************************************/
+/*
+* GMP Modular Exponentiator
+*/
class GMP_Modular_Exponentiator : public Modular_Exponentiator
{
public:
@@ -27,9 +29,9 @@ class GMP_Modular_Exponentiator : public Modular_Exponentiator
GMP_MPZ base, exp, mod;
};
-/*************************************************
-* Compute the result *
-*************************************************/
+/*
+* Compute the result
+*/
BigInt GMP_Modular_Exponentiator::execute() const
{
GMP_MPZ r;
@@ -39,9 +41,9 @@ BigInt GMP_Modular_Exponentiator::execute() const
}
-/*************************************************
-* Return the GMP-based modular exponentiator *
-*************************************************/
+/*
+* Return the GMP-based modular exponentiator
+*/
Modular_Exponentiator* GMP_Engine::mod_exp(const BigInt& n,
Power_Mod::Usage_Hints) const
{
diff --git a/src/engine/gnump/gmp_wrap.cpp b/src/engine/gnump/gmp_wrap.cpp
index 4c73c2562..735fc7070 100644
--- a/src/engine/gnump/gmp_wrap.cpp
+++ b/src/engine/gnump/gmp_wrap.cpp
@@ -1,7 +1,9 @@
-/*************************************************
-* GMP Wrapper Source File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GMP Wrapper
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#include <botan/gmp_wrap.h>
@@ -17,9 +19,9 @@
namespace Botan {
-/*************************************************
-* GMP_MPZ Constructor *
-*************************************************/
+/*
+* GMP_MPZ Constructor
+*/
GMP_MPZ::GMP_MPZ(const BigInt& in)
{
mpz_init(value);
@@ -27,60 +29,60 @@ GMP_MPZ::GMP_MPZ(const BigInt& in)
mpz_import(value, in.sig_words(), -1, sizeof(word), 0, 0, in.data());
}
-/*************************************************
-* GMP_MPZ Constructor *
-*************************************************/
+/*
+* GMP_MPZ Constructor
+*/
GMP_MPZ::GMP_MPZ(const byte in[], u32bit length)
{
mpz_init(value);
mpz_import(value, length, 1, 1, 0, 0, in);
}
-/*************************************************
-* GMP_MPZ Copy Constructor *
-*************************************************/
+/*
+* GMP_MPZ Copy Constructor
+*/
GMP_MPZ::GMP_MPZ(const GMP_MPZ& other)
{
mpz_init_set(value, other.value);
}
-/*************************************************
-* GMP_MPZ Destructor *
-*************************************************/
+/*
+* GMP_MPZ Destructor
+*/
GMP_MPZ::~GMP_MPZ()
{
mpz_clear(value);
}
-/*************************************************
-* GMP_MPZ Assignment Operator *
-*************************************************/
+/*
+* GMP_MPZ Assignment Operator
+*/
GMP_MPZ& GMP_MPZ::operator=(const GMP_MPZ& other)
{
mpz_set(value, other.value);
return (*this);
}
-/*************************************************
-* Export the mpz_t as a bytestring *
-*************************************************/
+/*
+* Export the mpz_t as a bytestring
+*/
void GMP_MPZ::encode(byte out[], u32bit length) const
{
size_t dummy = 0;
mpz_export(out + (length - bytes()), &dummy, 1, 1, 0, 0, value);
}
-/*************************************************
-* Return the number of significant bytes *
-*************************************************/
+/*
+* Return the number of significant bytes
+*/
u32bit GMP_MPZ::bytes() const
{
return ((mpz_sizeinbase(value, 2) + 7) / 8);
}
-/*************************************************
-* GMP to BigInt Conversions *
-*************************************************/
+/*
+* GMP to BigInt Conversions
+*/
BigInt GMP_MPZ::to_bigint() const
{
BigInt out(BigInt::Positive, (bytes() + sizeof(word) - 1) / sizeof(word));
diff --git a/src/engine/gnump/gmp_wrap.h b/src/engine/gnump/gmp_wrap.h
index e2a420e6b..11a51c87d 100644
--- a/src/engine/gnump/gmp_wrap.h
+++ b/src/engine/gnump/gmp_wrap.h
@@ -1,7 +1,9 @@
-/*************************************************
-* GMP MPZ Wrapper Header File *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
+/*
+* GMP MPZ Wrapper
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
#ifndef BOTAN_GMP_MPZ_WRAP_H__
#define BOTAN_GMP_MPZ_WRAP_H__
@@ -11,9 +13,9 @@
namespace Botan {
-/*************************************************
-* Lightweight GMP mpz_t Wrapper *
-*************************************************/
+/*
+* Lightweight GMP mpz_t Wrapper
+*/
class BOTAN_DLL GMP_MPZ
{
public: