Skip to content

Commit

Permalink
Cleared issues 11,12,13 (Clang integrated assembler), 58 (RC rollup),…
Browse files Browse the repository at this point in the history
… 66 (Coverity rollup)
  • Loading branch information
noloader committed Nov 18, 2015
1 parent d2fda9b commit 6ac1e46
Show file tree
Hide file tree
Showing 136 changed files with 3,461 additions and 1,546 deletions.
2 changes: 2 additions & 0 deletions 3way.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

NAMESPACE_BEGIN(CryptoPP)

#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void ThreeWay_TestInstantiations()
{
ThreeWay::Encryption x1;
ThreeWay::Decryption x2;
}
#endif

static const word32 START_E = 0x0b0b; // round constant of first encryption round
static const word32 START_D = 0xb1b1; // round constant of first decryption round
Expand Down
2 changes: 1 addition & 1 deletion 3way.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//! \file
//! \headerfile 3way.h
//! \brief Class files for the 3way cipher
//! \brief Class file for the 3way cipher

#ifndef CRYPTOPP_THREEWAY_H
#define CRYPTOPP_THREEWAY_H
Expand Down
7 changes: 6 additions & 1 deletion adler32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,19 @@ void Adler32::TruncatedFinal(byte *hash, size_t size)
{
default:
hash[3] = byte(m_s1);
// fall through
case 3:
hash[2] = byte(m_s1 >> 8);
// fall through
case 2:
hash[1] = byte(m_s2);
// fall through
case 1:
hash[0] = byte(m_s2 >> 8);
// fall through
case 0:
;
;;
// fall through
}

Reset();
Expand Down
3 changes: 2 additions & 1 deletion adler32.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// adler32.h - written and placed in the public domain by Wei Dai

//! \file
//! \brief Class files for ADLER-32 checksum calculations
//! \headerfile adler32.h
//! \brief Class file for ADLER-32 checksum calculations

#ifndef CRYPTOPP_ADLER32_H
#define CRYPTOPP_ADLER32_H
Expand Down
3 changes: 2 additions & 1 deletion algebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ template <class Element, class Iterator> Element GeneralCascadeMultiplication(co
struct WindowSlider
{
WindowSlider(const Integer &expIn, bool fastNegate, unsigned int windowSizeIn=0)
: exp(expIn), windowModulus(Integer::One()), windowSize(windowSizeIn), windowBegin(0), fastNegate(fastNegate), negateNext(false), firstTime(true), finished(false)
: exp(expIn), windowModulus(Integer::One()), windowSize(windowSizeIn), windowBegin(0), expWindow(0)
, fastNegate(fastNegate), negateNext(false), firstTime(true), finished(false)
{
if (windowSize == 0)
{
Expand Down
5 changes: 3 additions & 2 deletions algebra.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// algebra.h - written and placed in the public domain by Wei Dai

//! \file
//! \brief Classes and functions for performing mathematics over different fields
//! \headerfile algebra.h
//! \brief Classes for performing mathematics over different fields

#ifndef CRYPTOPP_ALGEBRA_H
#define CRYPTOPP_ALGEBRA_H

#include "config.h"
#include "integer.h"
#include "misc.h"
#include "integer.h"

NAMESPACE_BEGIN(CryptoPP)

Expand Down
55 changes: 41 additions & 14 deletions algparam.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// algparam.h - written and placed in the public domain by Wei Dai

//! \file
//! \brief Classes and functions for working with NameValuePairs
//! \headerfile algparam.h
//! \brief Classes for working with NameValuePairs


#ifndef CRYPTOPP_ALGPARAM_H
Expand Down Expand Up @@ -30,21 +31,26 @@ class ConstByteArrayParameter
{
public:
ConstByteArrayParameter(const char *data = NULL, bool deepCopy = false)
: m_deepCopy(false), m_data(NULL), m_size(0)
{
Assign((const byte *)data, data ? strlen(data) : 0, deepCopy);
}
ConstByteArrayParameter(const byte *data, size_t size, bool deepCopy = false)
: m_deepCopy(false), m_data(NULL), m_size(0)
{
Assign(data, size, deepCopy);
}
template <class T> ConstByteArrayParameter(const T &string, bool deepCopy = false)
: m_deepCopy(false), m_data(NULL), m_size(0)
{
CRYPTOPP_COMPILE_ASSERT(sizeof(CPP_TYPENAME T::value_type) == 1);
CRYPTOPP_COMPILE_ASSERT(sizeof(CPP_TYPENAME T::value_type) == 1);
Assign((const byte *)string.data(), string.size(), deepCopy);
}

void Assign(const byte *data, size_t size, bool deepCopy)
{
// This fires, which means: no data with a size, or data with no size.
// assert((data && size) || !(data || size));
if (deepCopy)
m_block.Assign(data, size);
else
Expand Down Expand Up @@ -400,6 +406,19 @@ CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<bool>;
CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<int>;
CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmParametersTemplate<ConstByteArrayParameter>;

//! \class AlgorithmParameters
//! \brief An object that implements NameValuePairs
//! \tparam T the class or type
//! \param name the name of the object or value to retrieve
//! \param value reference to a variable that receives the value
//! \param throwIfNotUsed if true, the object will throw an exception if the value is not accessed
//! \note throwIfNotUsed is ignored if using a compiler that does not support std::uncaught_exception(),
//! such as MSVC 7.0 and earlier.
//! \note A NameValuePairs object containing an arbitrary number of name value pairs may be constructed by
//! repeatedly using operator() on the object returned by MakeParameters, for example:
//! <pre>
//! AlgorithmParameters parameters = MakeParameters(name1, value1)(name2, value2)(name3, value3);
//! </pre>
class CRYPTOPP_DLL AlgorithmParameters : public NameValuePairs
{
public:
Expand All @@ -418,6 +437,10 @@ class CRYPTOPP_DLL AlgorithmParameters : public NameValuePairs

AlgorithmParameters & operator=(const AlgorithmParameters &x);

//! \tparam T the class or type
//! \param name the name of the object or value to retrieve
//! \param value reference to a variable that receives the value
//! \param throwIfNotUsed if true, the object will throw an exception if the value is not accessed
template <class T>
AlgorithmParameters & operator()(const char *name, const T &value, bool throwIfNotUsed)
{
Expand All @@ -428,6 +451,10 @@ class CRYPTOPP_DLL AlgorithmParameters : public NameValuePairs
return *this;
}

//! \brief Appends a NameValuePair to a collection of NameValuePairs
//! \tparam T the class or type
//! \param name the name of the object or value to retrieve
//! \param value reference to a variable that receives the value
template <class T>
AlgorithmParameters & operator()(const char *name, const T &value)
{
Expand All @@ -441,23 +468,23 @@ class CRYPTOPP_DLL AlgorithmParameters : public NameValuePairs
bool m_defaultThrowIfNotUsed;
};

//! Create an object that implements NameValuePairs for passing parameters
/*! \param throwIfNotUsed if true, the object will throw an exception if the value is not accessed
\note throwIfNotUsed is ignored if using a compiler that does not support std::uncaught_exception(),
such as MSVC 7.0 and earlier.
\note A NameValuePairs object containing an arbitrary number of name value pairs may be constructed by
repeatedly using operator() on the object returned by MakeParameters, for example:
AlgorithmParameters parameters = MakeParameters(name1, value1)(name2, value2)(name3, value3);
*/
//! \brief Create an object that implements NameValuePairs
//! \tparam T the class or type
//! \param name the name of the object or value to retrieve
//! \param value reference to a variable that receives the value
//! \param throwIfNotUsed if true, the object will throw an exception if the value is not accessed
//! \note throwIfNotUsed is ignored if using a compiler that does not support std::uncaught_exception(),
//! such as MSVC 7.0 and earlier.
//! \note A NameValuePairs object containing an arbitrary number of name value pairs may be constructed by
//! repeatedly using \p operator() on the object returned by \p MakeParameters, for example:
//! <pre>
//! AlgorithmParameters parameters = MakeParameters(name1, value1)(name2, value2)(name3, value3);
//! </pre>
#ifdef __BORLANDC__
typedef AlgorithmParameters MakeParameters;
#else
template <class T>
#if __APPLE__
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed = false)
#else
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed = true)
#endif
{
return AlgorithmParameters()(name, value, throwIfNotUsed);
}
Expand Down
2 changes: 2 additions & 0 deletions arc4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
NAMESPACE_BEGIN(CryptoPP)
namespace Weak1 {

#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void ARC4_TestInstantiations()
{
ARC4 x;
}
#endif

ARC4_Base::~ARC4_Base()
{
Expand Down
12 changes: 8 additions & 4 deletions arc4.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// arc4.h - written and placed in the public domain by Wei Dai

//! \file
//! \brief Implementation of ARC4
//! \headerfile arc4.h
//! \brief Classes for ARC4 cipher

#ifndef CRYPTOPP_ARC4_H
#define CRYPTOPP_ARC4_H
Expand All @@ -16,7 +17,8 @@ NAMESPACE_BEGIN(CryptoPP)
namespace Weak1 {

//! \class ARC4_Base
//! \brief Allegedly RC4
//! \brief Class specific methods used to operate the cipher.
//! \details Implementations and overrides in \p Base apply to both \p ENCRYPTION and \p DECRYPTION directions
class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, public RandomNumberGenerator, public SymmetricCipher, public SymmetricCipherDocumentation
{
public:
Expand Down Expand Up @@ -47,7 +49,10 @@ class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, publi
//! <a href="http:https://www.weidai.com/scan-mirror/cs.html#RC4">Alleged RC4</a>
DOCUMENTED_TYPEDEF(SymmetricCipherFinal<ARC4_Base>, ARC4)

//! _
//! \class MARC4_Base
//! \brief Class specific methods used to operate the cipher.
//! \details Implementations and overrides in \p Base apply to both \p ENCRYPTION and \p DECRYPTION directions
//! \details MARC4 discards the first 256 bytes of keystream, which may be weaker than the rest
class CRYPTOPP_NO_VTABLE MARC4_Base : public ARC4_Base
{
public:
Expand All @@ -60,7 +65,6 @@ class CRYPTOPP_NO_VTABLE MARC4_Base : public ARC4_Base
unsigned int GetDefaultDiscardBytes() const {return 256;}
};

//! Modified ARC4: it discards the first 256 bytes of keystream which may be weaker than the rest
DOCUMENTED_TYPEDEF(SymmetricCipherFinal<MARC4_Base>, MARC4)

}
Expand Down
10 changes: 5 additions & 5 deletions argnames.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// argnames.h - written and placed in the public domain by Wei Dai

//! \file
//! \brief Standard names for retrieving values when working with \p NameValuePairs
//! \file argnames.h
//! \brief Standard names for retrieving values by name when working with \p NameValuePairs

#ifndef CRYPTOPP_ARGNAMES_H
#define CRYPTOPP_ARGNAMES_H
Expand Down Expand Up @@ -78,9 +78,9 @@ CRYPTOPP_DEFINE_NAME_STRING(MaxLineLength) //< int
CRYPTOPP_DEFINE_NAME_STRING(DigestSize) //!< int, in bytes
CRYPTOPP_DEFINE_NAME_STRING(L1KeyLength) //!< int, in bytes
CRYPTOPP_DEFINE_NAME_STRING(TableSize) //!< int, in bytes
CRYPTOPP_DEFINE_NAME_STRING(DerivedKey) //< ByteArrayParameter, key derivation, derived key
CRYPTOPP_DEFINE_NAME_STRING(DerivedLength) //< int, key derivation, derived key length in bytes

CRYPTOPP_DEFINE_NAME_STRING(Blinding) //!< bool
CRYPTOPP_DEFINE_NAME_STRING(DerivedKey) //!< ByteArrayParameter, key derivation, derived key
CRYPTOPP_DEFINE_NAME_STRING(DerivedLength) //!< int, key derivation, derived key length in bytes
DOCUMENTED_NAMESPACE_END

NAMESPACE_END
Expand Down
5 changes: 4 additions & 1 deletion asn.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// asn.h - written and placed in the public domain by Wei Dai

//! \file
//! \headerfile asn.h
//! \brief Classes and functions for working with ANS.1 objects

#ifndef CRYPTOPP_ASN_H
Expand Down Expand Up @@ -348,7 +349,9 @@ void BERDecodeUnsigned(BufferedTransformation &in, T &w, byte asnTag = INTEGER,
BERDecodeError();

size_t bc;
BERLengthDecode(in, bc);
bool definite = BERLengthDecode(in, bc);
if (!definite)
BERDecodeError();

SecByteBlock buf(bc);

Expand Down
4 changes: 3 additions & 1 deletion authenc.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// authenc.h - written and placed in the public domain by Wei Dai

//! \file
//! \headerfile authenc.h
//! \brief Base classes for working with authenticated encryption modes of encryption

#ifndef CRYPTOPP_AUTHENC_H
Expand All @@ -16,7 +17,8 @@ NAMESPACE_BEGIN(CryptoPP)
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AuthenticatedSymmetricCipherBase : public AuthenticatedSymmetricCipher
{
public:
AuthenticatedSymmetricCipherBase() : m_state(State_Start) {}
AuthenticatedSymmetricCipherBase() : m_state(State_Start), m_bufferedDataLength(0),
m_totalHeaderLength(0), m_totalMessageLength(0), m_totalFooterLength(0) {}

bool IsRandomAccess() const {return false;}
bool IsSelfInverting() const {return true;}
Expand Down
2 changes: 1 addition & 1 deletion base32.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// base32.h - written and placed in the public domain by Wei Dai

//! \file
//! \brief Class files for the Base32 encoder and decoder
//! \brief Classes for Base32 encoder and decoder

#ifndef CRYPTOPP_BASE32_H
#define CRYPTOPP_BASE32_H
Expand Down
2 changes: 1 addition & 1 deletion base64.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// .h - written and placed in the public domain by Wei Dai

//! \file
//! \brief Class files for the Base64Encoder, Base64Decoder, Base64URLEncoder and Base64URLDecoder
//! \brief Classes for the Base64Encoder, Base64Decoder, Base64URLEncoder and Base64URLDecoder

#ifndef CRYPTOPP_BASE64_H
#define CRYPTOPP_BASE64_H
Expand Down
17 changes: 13 additions & 4 deletions basecode.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// basecode.h - written and placed in the public domain by Wei Dai

//! \file
//! \brief Base class files for working with encoders and decoders.
//! \brief Base classes for working with encoders and decoders.

#ifndef CRYPTOPP_BASECODE_H
#define CRYPTOPP_BASECODE_H
Expand All @@ -19,9 +19,13 @@ class CRYPTOPP_DLL BaseN_Encoder : public Unflushable<Filter>
{
public:
BaseN_Encoder(BufferedTransformation *attachment=NULL)
{Detach(attachment);}
: m_alphabet(NULL), m_padding(0), m_bitsPerChar(0)
, m_outputBlockSize(0), m_bytePos(0), m_bitPos(0)
{Detach(attachment);}

BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1)
: m_alphabet(NULL), m_padding(0), m_bitsPerChar(0)
, m_outputBlockSize(0), m_bytePos(0), m_bitPos(0)
{
Detach(attachment);
IsolatedInitialize(MakeParameters(Name::EncodingLookupArray(), alphabet)
Expand All @@ -46,9 +50,13 @@ class CRYPTOPP_DLL BaseN_Decoder : public Unflushable<Filter>
{
public:
BaseN_Decoder(BufferedTransformation *attachment=NULL)
{Detach(attachment);}
: m_lookup(0), m_padding(0), m_bitsPerChar(0)
, m_outputBlockSize(0), m_bytePos(0), m_bitPos(0)
{Detach(attachment);}

BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL)
: m_lookup(0), m_padding(0), m_bitsPerChar(0)
, m_outputBlockSize(0), m_bytePos(0), m_bitPos(0)
{
Detach(attachment);
IsolatedInitialize(MakeParameters(Name::DecodingLookupArray(), lookup)(Name::Log2Base(), log2base));
Expand All @@ -71,9 +79,10 @@ class CRYPTOPP_DLL Grouper : public Bufferless<Filter>
{
public:
Grouper(BufferedTransformation *attachment=NULL)
{Detach(attachment);}
: m_groupSize(0), m_counter(0) {Detach(attachment);}

Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULL)
: m_groupSize(0), m_counter(0)
{
Detach(attachment);
IsolatedInitialize(MakeParameters(Name::GroupSize(), groupSize)
Expand Down
Loading

0 comments on commit 6ac1e46

Please sign in to comment.