diff --git a/.gitignore b/.gitignore
index 440f91ed..0539a4a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -82,6 +82,7 @@ x64/
build/
[Bb]in/
[Oo]bj/
+[Ll]ibs/
# MSTest test Results
[Tt]est[Rr]esult*/
@@ -92,6 +93,7 @@ build/
*.ilk
*.meta
*.obj
+*.o
*.pch
*.pdb
*.pgc
@@ -110,6 +112,8 @@ build/
*.pidb
*.log
*.scc
+*.exe
+*.a
# Visual C++ cache files
ipch/
@@ -249,3 +253,4 @@ pip-log.txt
#Mr Developer
.mr.developer.cfg
+
diff --git a/3way.h b/3way.h
index 72f9984d..16affa6c 100644
--- a/3way.h
+++ b/3way.h
@@ -13,16 +13,15 @@
NAMESPACE_BEGIN(CryptoPP)
//! \class ThreeWay_Info
-//! \brief The cipher's key, iv, block size and name information.
+//! \brief ThreeWay block cipher information
struct ThreeWay_Info : public FixedBlockSize<12>, public FixedKeyLength<12>, public VariableRounds<11>
{
static const char *StaticAlgorithmName() {return "3-Way";}
};
-// 3-Way
-
//! \class ThreeWay
-//! \brief Provides 3-Way encryption and decryption
+//! \brief ThreeWay block cipher
+//! \sa 3-Way
class ThreeWay : public ThreeWay_Info, public BlockCipherDocumentation
{
//! \class Base
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..5458525e
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,185 @@
+cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
+project(cryptopp VERSION 5.6.3)
+
+include(GNUInstallDirs)
+include(TestBigEndian)
+include(CheckCXXSymbolExists)
+
+#============================================================================
+# Settable options
+#============================================================================
+
+option(BUILD_TESTING "Build library tests" ON)
+option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
+
+option(DISABLE_ASM "Disable ASM" OFF)
+option(DISABLE_SSSE3 "Disable SSSE3" OFF)
+option(DISABLE_AESNI "Disable AES-NI" OFF)
+
+#============================================================================
+# Internal compiler options
+#============================================================================
+
+set(LIB_VER ${cryptopp_VERSION_MAJOR}${cryptopp_VERSION_MINOR}${cryptopp_VERSION_PATCH})
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
+ add_definitions(-wd68 -wd186 -wd279 -wd327 -wd161 -wd3180)
+endif()
+
+# Endianess
+TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
+if(IS_BIG_ENDIAN)
+ add_definitions(-DIS_BIG_ENDIAN)
+endif()
+
+if(DISABLE_ASM)
+ add_definitions(-DCRYPTOPP_DISABLE_ASM)
+endif()
+if(DISABLE_SSSE3)
+ add_definitions(-DCRYPTOPP_DISABLE_SSSE3)
+endif()
+if(DISABLE_AESNI)
+ add_definitions(-DCRYPTOPP_DISABLE_AESNI)
+endif()
+
+#============================================================================
+# Sources & headers
+#============================================================================
+
+# Library headers
+file(GLOB cryptopp_HEADERS *.h)
+
+# Test sources
+file(GLOB cryptopp_SOURCES_TEST bench.cpp bench2.cpp test.cpp validat1.cpp validat2.cpp validat3.cpp adhoc.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp fipstest.cpp)
+
+# Library sources
+file(GLOB cryptopp_SOURCES *.cpp)
+list(REMOVE_ITEM cryptopp_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/cryptlib.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/cpu.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/simple.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/winpipes.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/cryptlib_bds.cpp
+ ${cryptopp_SOURCES_TEST}
+ )
+set(cryptopp_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/cryptlib.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/cpu.cpp
+ ${cryptopp_SOURCES}
+ )
+
+if(MINGW)
+ list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/winpipes.cpp)
+endif()
+
+#============================================================================
+# Compile targets
+#============================================================================
+add_library(cryptopp-object OBJECT ${cryptopp_SOURCES})
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ # Enables -fPIC on all 64-bit platforms
+ set_target_properties(cryptopp-object PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
+endif()
+
+add_library(cryptopp-static STATIC $)
+add_library(cryptopp-shared SHARED $)
+
+target_include_directories(cryptopp-shared PUBLIC $ $)
+target_include_directories(cryptopp-static PUBLIC $ $)
+
+if(NOT MSVC)
+ set(COMPAT_VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR})
+
+ set_target_properties(cryptopp-static
+ PROPERTIES
+ OUTPUT_NAME cryptopp)
+ set_target_properties(cryptopp-shared
+ PROPERTIES
+ SOVERSION ${COMPAT_VERSION}
+ OUTPUT_NAME cryptopp)
+endif()
+
+#============================================================================
+# Third-party libraries
+#============================================================================
+if(WIN32)
+ target_link_libraries(cryptopp-static ws2_32)
+ target_link_libraries(cryptopp-shared ws2_32)
+endif()
+
+find_package(Threads)
+target_link_libraries(cryptopp-static ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(cryptopp-shared ${CMAKE_THREAD_LIBS_INIT})
+
+#============================================================================
+# Tests
+#============================================================================
+enable_testing()
+if(BUILD_TESTING)
+ add_library(cryptest-object OBJECT ${cryptopp_SOURCES_TEST})
+
+ add_executable(cryptest $)
+ target_link_libraries(cryptest cryptopp-static)
+
+ file(COPY ${CMAKE_SOURCE_DIR}/TestData DESTINATION ${PROJECT_BINARY_DIR})
+ file(COPY ${CMAKE_SOURCE_DIR}/TestVectors DESTINATION ${PROJECT_BINARY_DIR})
+
+ add_test(NAME cryptest COMMAND $ v)
+endif()
+
+#============================================================================
+# Doxygen documentation
+#============================================================================
+if(BUILD_DOCUMENTATION)
+ find_package(Doxygen REQUIRED)
+
+ set(in_source_DOCS_DIR "${CMAKE_SOURCE_DIR}/html-docs")
+ set(out_source_DOCS_DIR "${PROJECT_BINARY_DIR}/html-docs")
+
+ add_custom_target(docs ALL
+ COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ SOURCES ${CMAKE_SOURCE_DIR}/Doxyfile
+ )
+
+ if(NOT ${in_source_DOCS_DIR} STREQUAL ${out_source_DOCS_DIR})
+ add_custom_command(
+ TARGET docs POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_directory "${in_source_DOCS_DIR}" "${out_source_DOCS_DIR}"
+ COMMAND ${CMAKE_COMMAND} -E remove_directory "${in_source_DOCS_DIR}"
+ )
+ endif()
+endif()
+
+#============================================================================
+# Install
+#============================================================================
+set(export_name "cryptopp-targets")
+
+# Runtime package
+install(TARGETS cryptopp-shared EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+# Development package
+install(TARGETS cryptopp-static EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp)
+
+# CMake Package
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file("${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake" COMPATIBILITY SameMajorVersion)
+install(FILES cryptopp-config.cmake ${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake DESTINATION "lib/cmake/cryptopp")
+install(EXPORT ${export_name} DESTINATION "lib/cmake/cryptopp")
+
+# Tests
+if(BUILD_TESTING)
+ install(TARGETS cryptest DESTINATION ${CMAKE_INSTALL_BINDIR})
+ install(DIRECTORY ${CMAKE_SOURCE_DIR}/TestData DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp)
+ install(DIRECTORY ${CMAKE_SOURCE_DIR}/TestVectors DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp)
+endif()
+
+
+# Documentation
+if(BUILD_DOCUMENTATION)
+ install(DIRECTORY "${out_source_DOCS_DIR}" DESTINATION ${CMAKE_INSTALL_DOCDIR})
+endif()
\ No newline at end of file
diff --git a/Doxyfile b/Doxyfile
index da7bbf4c..64289a91 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -614,7 +614,7 @@ GENERATE_TESTLIST = YES
# list. This list is created by putting \bug commands in the documentation.
# The default value is: YES.
-GENERATE_BUGLIST = YES
+GENERATE_BUGLIST = NO
# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
# the deprecated list. This list is created by putting \deprecated commands in
@@ -765,7 +765,9 @@ WARN_LOGFILE =
INPUT = . \
GNUmakefile \
- rdrand.asm
+ GNUmakefile-cross \
+ rdrand.asm \
+ rdrand.S
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -934,13 +936,13 @@ STRIP_CODE_COMMENTS = NO
# function all documented functions referencing it will be listed.
# The default value is: NO.
-REFERENCED_BY_RELATION = YES
+REFERENCED_BY_RELATION = NO
# If the REFERENCES_RELATION tag is set to YES then for each documented function
# all documented entities called/used by that function will be listed.
# The default value is: NO.
-REFERENCES_RELATION = YES
+REFERENCES_RELATION = NO
# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
# to YES then the hyperlinks from functions in REFERENCES_RELATION and
@@ -1192,7 +1194,7 @@ DOCSET_FEEDNAME = "Doxygen generated docs"
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_DOCSET is set to YES.
-DOCSET_BUNDLE_ID = org.doxygen.Project
+DOCSET_BUNDLE_ID = com.cryptopp.Project
# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
# the documentation publisher. This should be a reverse domain-name style
@@ -1200,13 +1202,13 @@ DOCSET_BUNDLE_ID = org.doxygen.Project
# The default value is: org.doxygen.Publisher.
# This tag requires that the tag GENERATE_DOCSET is set to YES.
-DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+DOCSET_PUBLISHER_ID = com.cryptopp.Publisher
# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
# The default value is: Publisher.
# This tag requires that the tag GENERATE_DOCSET is set to YES.
-DOCSET_PUBLISHER_NAME = Publisher
+DOCSET_PUBLISHER_NAME = Crypto++
# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
diff --git a/Filelist.txt b/Filelist.txt
index fd503de5..e55b1041 100644
--- a/Filelist.txt
+++ b/Filelist.txt
@@ -303,6 +303,8 @@ License.txt
Readme.txt
Install.txt
Filelist.txt
+CMakeLists.txt
+cryptopp-config.cmake
TestData/3desval.dat
TestData/3wayval.dat
TestData/camellia.dat
diff --git a/GNUmakefile-cross b/GNUmakefile-cross
index 83aebf66..468892eb 100755
--- a/GNUmakefile-cross
+++ b/GNUmakefile-cross
@@ -4,7 +4,7 @@ CXXFLAGS ?= -DNDEBUG -g2 -Os -fPIC -pipe
# CXXFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += -Wl,--gc-sections
-ARFLAGS = -cr # ar needs the dash on OpenBSD
+ARFLAGS = cr
RANLIB ?= ranlib
CP = cp
MKDIR = mkdir
@@ -13,11 +13,9 @@ CHMOD = chmod
CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
-IS_X86=0
-IS_LINUX=0
-IS_MINGW=0
-IS_DARWIN=0
-UNAME=CrossCompile
+IS_IOS ?= 0
+IS_ANDROID ?= 0
+IS_ARM_EMBEDDED ?= 0
# Default prefix for make install
ifeq ($(PREFIX),)
@@ -28,62 +26,69 @@ endif
# Its a shame because GCC has so much to offer by the way of analysis.
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
ifneq ($(CLANG_COMPILER),0)
-CXXFLAGS += -Wall
+CXXFLAGS += -Wall -Wno-delete-non-virtual-dtor
endif
-# iOS cross-compile configuration. Works in conjunction with IS_CROSS_COMPILE.
+# iOS cross-compile configuration.
# See http://www.cryptopp.com/wiki/iOS_(Command_Line).
ifeq ($(IS_IOS),1)
CXX = clang++
- CXXFLAGS += -DCRYPTOPP_DISABLE_ASM $(IOS_FLAGS)
- CXXFLAGS += -arch $(IOS_ARCH) -isysroot $(IOS_SYSROOT)
- CXXFLAGS += -stdlib=libc++
+ CXXFLAGS += $(IOS_FLAGS) -arch $(IOS_ARCH)
+ CXXFLAGS += -isysroot $(IOS_SYSROOT) -stdlib=libc++
AR = libtool
ARFLAGS = -static -o
+ RANLIB = ranlib
endif
-# Android cross-compile configuration. Works in conjunction with IS_CROSS_COMPILE.
+# Android cross-compile configuration.
# See http://www.cryptopp.com/wiki/Android_(Command_Line).
ifeq ($(IS_ANDROID),1)
# CPP, CXX, AR, RANLIB, LD, etc are set in 'setenv-android.sh'
- CXXFLAGS += -DCRYPTOPP_DISABLE_ASM $(ANDROID_FLAGS)
- CXXFLAGS += --sysroot=$(ANDROID_SYSROOT) -I$(ANDROID_STL_INC)
- LDLIBS += $(ANDROID_STL_LIB)
+ CXXFLAGS += $(AOSP_FLAGS) -DANDROID --sysroot=$(AOSP_SYSROOT)
+ CXXFLAGS += -Wa,--noexecstack -I$(AOSP_STL_INC)
+
+ # c++config.h shows up in odd places at times.
+ ifneq ($(AOSP_BITS_INC),)
+ CXXFLAGS += -I$(AOSP_BITS_INC)
+ endif
+
+ LDLIBS += $(AOSP_STL_LIB)
endif
-# ARM embedded cross-compile configuration. Works in conjunction with IS_CROSS_COMPILE.
+# ARM embedded cross-compile configuration.
# See http://www.cryptopp.com/wiki/ARM_Embedded_(Command_Line)
# and http://www.cryptopp.com/wiki/ARM_Embedded_(Bare Metal).
ifeq ($(IS_ARM_EMBEDDED),1)
# CPP, CXX, AR, RANLIB, LD, etc are set in 'setenv-embedded.sh'
- CXXFLAGS += -DCRYPTOPP_DISABLE_ASM $(ARM_EMBEDDED_FLAGS)
- CXXFLAGS += --sysroot=$(ARM_EMBEDDED_SYSROOT)
+ CXXFLAGS += $(ARM_EMBEDDED_FLAGS) --sysroot=$(ARM_EMBEDDED_SYSROOT)
endif
-# List cryptlib.cpp first in an attempt to tame C++ static initialization problems
+# List cryptlib.cpp first and cpu.cpp second in an attempt to tame C++ static initialization problems.
+# The issue spills into POD data types of cpu.cpp due to the storage class of the bools, so cpu.cpp
+# is the second candidate for explicit initialization order.
SRCS := cryptlib.cpp cpu.cpp $(filter-out cryptlib.cpp cpu.cpp pch.cpp simple.cpp winpipes.cpp cryptlib_bds.cpp,$(wildcard *.cpp))
-
-# List of objects with crytlib.o at the first index position
OBJS := $(SRCS:.cpp=.o)
# test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
-TESTOBJS := bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
+TESTSRCS := bench.cpp bench2.cpp test.cpp validat1.cpp validat2.cpp validat3.cpp adhoc.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp
+TESTOBJS := $(TESTSRCS:.cpp=.o)
LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
-# List cryptlib.cpp first in an attempt to tame C++ static initialization problems
-DLLSRCS := cryptlib.cpp cpu.cpp algebra.cpp algparam.cpp asn.cpp basecode.cpp cbcmac.cpp channels.cpp des.cpp dessp.cpp dh.cpp dll.cpp dsa.cpp ec2n.cpp eccrypto.cpp ecp.cpp eprecomp.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gf2n.cpp gfpcrypt.cpp hex.cpp hmac.cpp integer.cpp iterhash.cpp misc.cpp modes.cpp modexppc.cpp mqueue.cpp nbtheory.cpp oaep.cpp osrng.cpp pch.cpp pkcspad.cpp pubkey.cpp queue.cpp randpool.cpp rdtables.cpp rijndael.cpp rng.cpp rsa.cpp sha.cpp simple.cpp skipjack.cpp strciphr.cpp trdlocal.cpp
-DLLOBJS := $(DLLSRCS:.cpp=.export.o)
+# For Shared Objects, Diff, Dist/Zip rules
+LIB_VER := $(shell $(EGREP) "define CRYPTOPP_VERSION" config.h | cut -d" " -f 3)
+LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
+LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
+LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
-# Import lib testing
-LIBIMPORTOBJS := $(LIBOBJS:.o=.import.o)
-TESTIMPORTOBJS := $(TESTOBJS:.o=.import.o)
-DLLTESTOBJS := dlltest.dllonly.o
+ifeq ($(strip $(LIB_PATCH)),)
+LIB_PATCH := 0
+endif
all: cryptest.exe
-ifneq ($(IS_DARWIN),0)
+ifneq ($(IS_IOS),0)
static: libcryptopp.a
shared dynamic dylib: libcryptopp.dylib
else
@@ -96,27 +101,30 @@ test: cryptest.exe
.PHONY: clean
clean:
- -$(RM) cryptest.exe dlltest.exe libcryptopp.a libcryptopp.so libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe ct
- -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(LIBOBJS) $(TESTOBJS) $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
+ -$(RM) cryptest.exe libcryptopp.a libcryptopp.so libcryptopp.dylib
+ -$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(LIBOBJS) $(TESTOBJS)
ifneq ($(wildcard *.dSYM),)
- -$(RM) -r cryptest.exe.dSYM dlltest.exe.dSYM
+ -$(RM) -r cryptest.exe.dSYM
endif
.PHONY: distclean
distclean: clean
- -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps cryptopp$(LIB_VER).diff cryptopp$(LIB_VER).zip *.o *.ii *.s
+ -$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps *.o *.ii *.s
.PHONY: install
install:
- $(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin
+ $(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib
-$(CP) *.h $(PREFIX)/include/cryptopp
-$(CHMOD) 755 $(PREFIX)/include/cryptopp
-$(CHMOD) 644 $(PREFIX)/include/cryptopp/*.h
-$(CP) libcryptopp.a $(PREFIX)/lib
-$(CHMOD) 644 $(PREFIX)/lib/libcryptopp.a
+ifeq ($(wildcard cryptest.exe),cryptest.exe)
+ $(MKDIR) -p $(PREFIX)/bin
-$(CP) cryptest.exe $(PREFIX)/bin
-$(CHMOD) 755 $(PREFIX)/bin/cryptest.exe
-ifneq ($(IS_DARWIN),0)
+endif
+ifneq ($(IS_IOS),0)
-$(CP) libcryptopp.dylib $(PREFIX)/lib
-$(CHMOD) 755 $(PREFIX)/lib/libcryptopp.dylib
else
@@ -129,22 +137,32 @@ remove uninstall:
-$(RM) -r $(PREFIX)/include/cryptopp
-$(RM) $(PREFIX)/lib/libcryptopp.a
-$(RM) $(PREFIX)/bin/cryptest.exe
-ifneq ($(IS_DARWIN),0)
+ifneq ($(IS_IOS),0)
-$(RM) $(PREFIX)/lib/libcryptopp.dylib
else
-$(RM) $(PREFIX)/lib/libcryptopp.so
endif
-libcryptopp.a: public_service | $(LIBOBJS)
+libcryptopp.a: $(LIBOBJS)
$(AR) $(ARFLAGS) $@ $(LIBOBJS)
$(RANLIB) $@
-libcryptopp.so: public_service | $(LIBOBJS)
- $(CXX) $(CXXFLAGS) -shared -o $@ $(LIBOBJS) $(LDFLAGS) $(LDLIBS)
+libcryptopp.so: $(LIBOBJS)
+ $(CXX) -shared -o $@ $(CXXFLAGS) -Wl,--exclude-libs,ALL $(LIBOBJS) $(LDLIBS)
-cryptest.exe: public_service | libcryptopp.a $(TESTOBJS)
+libcryptopp.dylib: $(LIBOBJS)
+ $(CXX) -dynamiclib -o $@ $(CXXFLAGS) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" $(LIBOBJS)
+
+cryptest.exe: libcryptopp.a $(TESTOBJS)
$(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS)
+# Used to generate list of source files for Autotools, CMakeList and Android.mk
+.PHONY: sources
+sources:
+ $(info Library sources: $(filter-out fipstest.cpp $(TESTSRCS),$(SRCS)))
+ $(info )
+ $(info Test sources: $(TESTSRCS))
+
adhoc.cpp: adhoc.cpp.proto
ifeq ($(wildcard adhoc.cpp),)
cp adhoc.cpp.proto adhoc.cpp
@@ -162,25 +180,3 @@ endif # Dependencies
GNUmakefile.deps:
$(CXX) $(CXXFLAGS) -MM *.cpp > GNUmakefile.deps
-
-# Warn of potential configurations issues. This will go away after 5.6.3
-UNALIGNED_ACCESS := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_NO_UNALIGNED_DATA_ACCESS" config.h)
-NO_INIT_PRIORITY := $(shell $(EGREP) -c "^[[:space:]]*//[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_INIT_PRIORITY" config.h)
-COMPATIBILITY_562 := $(shell $(EGREP) -c "^[[:space:]]*\#[[:space:]]*define[[:space:]]*CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562" config.h)
-.PHONY: public_service
-public_service:
-ifneq ($(UNALIGNED_ACCESS),0)
- $(info WARNING: CRYPTOPP_NO_UNALIGNED_DATA_ACCESS is not defined in config.h.)
-endif
-ifneq ($(NO_INIT_PRIORITY),0)
- $(info WARNING: CRYPTOPP_INIT_PRIORITY is not defined in config.h.)
-endif
-ifneq ($(COMPATIBILITY_562),0)
- $(info WARNING: CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 is defined in config.h.)
-endif
-ifneq (x$(UNALIGNED_ACCESS)$(NO_INIT_PRIORITY)$(COMPATIBILITY_562),x000)
- $(info WARNING: You should make these changes in config.h, and not CXXFLAGS.)
- $(info WARNING: You can 'mv config.recommend config.h', but it breaks versioning.)
- $(info WARNING: See http://cryptopp.com/wiki/config.h for more details.)
- $(info )
-endif
diff --git a/aes.h b/aes.h
index 5588531b..217738bd 100644
--- a/aes.h
+++ b/aes.h
@@ -10,7 +10,9 @@
NAMESPACE_BEGIN(CryptoPP)
-//! AES winner, announced on 10/2/2000
+//! \class AES
+//! \brief AES block cipher (Rijndael)
+//! \sa AES winner, announced on 10/2/2000
DOCUMENTED_TYPEDEF(Rijndael, AES);
typedef RijndaelEncryption AESEncryption;
diff --git a/algparam.h b/algparam.h
index 3f5b25c5..236d5b21 100644
--- a/algparam.h
+++ b/algparam.h
@@ -8,8 +8,8 @@
#ifndef CRYPTOPP_ALGPARAM_H
#define CRYPTOPP_ALGPARAM_H
-#include "cryptlib.h"
#include "config.h"
+#include "cryptlib.h"
// TODO: fix 6011 when the API/ABI can change
#if (CRYPTOPP_MSC_VERSION >= 1400)
@@ -24,22 +24,40 @@
NAMESPACE_BEGIN(CryptoPP)
-//! used to pass byte array input as part of a NameValuePairs object
-/*! the deepCopy option is used when the NameValuePairs object can't
- keep a copy of the data available */
+//! \class ConstByteArrayParameter
+//! \brief Used to pass byte array input as part of a NameValuePairs object
class ConstByteArrayParameter
{
public:
+ //! \brief Construct a ConstByteArrayParameter
+ //! \param data a C-String
+ //! \param deepCopy flag indicating whether the data should be copied
+ //! \details The deepCopy option is used when the NameValuePairs object can't
+ //! keep a copy of the data available
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);
}
+
+ //! \brief Construct a ConstByteArrayParameter
+ //! \param data a memory buffer
+ //! \param size the length of the memory buffer
+ //! \param deepCopy flag indicating whether the data should be copied
+ //! \details The deepCopy option is used when the NameValuePairs object can't
+ //! keep a copy of the data available
ConstByteArrayParameter(const byte *data, size_t size, bool deepCopy = false)
: m_deepCopy(false), m_data(NULL), m_size(0)
{
Assign(data, size, deepCopy);
}
+
+ //! \brief Construct a ConstByteArrayParameter
+ //! \tparam T a std::basic_string class
+ //! \param string a std::basic_string class
+ //! \param deepCopy flag indicating whether the data should be copied
+ //! \details The deepCopy option is used when the NameValuePairs object can't
+ //! keep a copy of the data available
template ConstByteArrayParameter(const T &string, bool deepCopy = false)
: m_deepCopy(false), m_data(NULL), m_size(0)
{
@@ -47,6 +65,12 @@ public:
Assign((const byte *)string.data(), string.size(), deepCopy);
}
+ //! \brief Assign contents from a memory buffer
+ //! \param data a memory buffer
+ //! \param size the length of the memory buffer
+ //! \param deepCopy flag indicating whether the data should be copied
+ //! \details The deepCopy option is used when the NameValuePairs object can't
+ //! keep a copy of the data available
void Assign(const byte *data, size_t size, bool deepCopy)
{
// This fires, which means: no data with a size, or data with no size.
@@ -61,8 +85,11 @@ public:
m_deepCopy = deepCopy;
}
+ //! \brief Pointer to the first byte in the memory block
const byte *begin() const {return m_deepCopy ? m_block.begin() : m_data;}
+ //! \brief Pointer beyond the last byte in the memory block
const byte *end() const {return m_deepCopy ? m_block.end() : m_data + m_size;}
+ //! \brief Length of the memory block
size_t size() const {return m_deepCopy ? m_block.size() : m_size;}
private:
@@ -72,16 +99,27 @@ private:
SecByteBlock m_block;
};
+//! \class ByteArrayParameter
+//! \brief Used to pass byte array input as part of a NameValuePairs object
class ByteArrayParameter
{
public:
+ //! \brief Construct a ByteArrayParameter
+ //! \param data a memory buffer
+ //! \param size the length of the memory buffer
ByteArrayParameter(byte *data = NULL, unsigned int size = 0)
: m_data(data), m_size(size) {}
+
+ //! \brief Construct a ByteArrayParameter
+ //! \param block a SecByteBlock
ByteArrayParameter(SecByteBlock &block)
: m_data(block.begin()), m_size(block.size()) {}
+ //! \brief Pointer to the first byte in the memory block
byte *begin() const {return m_data;}
+ //! \brief Pointer beyond the last byte in the memory block
byte *end() const {return m_data + m_size;}
+ //! \brief Length of the memory block
size_t size() const {return m_size;}
private:
@@ -89,9 +127,17 @@ private:
size_t m_size;
};
+//! \class CombinedNameValuePairs
+//! \brief Combines two sets of NameValuePairs
+//! \details CombinedNameValuePairs allows you to provide two sets of of NameValuePairs.
+//! If a name is not found in the first set, then the second set is searched for the
+//! name and value pair. The second set of NameValuePairs often provides default values.
class CRYPTOPP_DLL CombinedNameValuePairs : public NameValuePairs
{
public:
+ //! \brief Construct a CombinedNameValuePairs
+ //! \param pairs1 reference to the first set of NameValuePairs
+ //! \param pairs2 reference to the second set of NameValuePairs
CombinedNameValuePairs(const NameValuePairs &pairs1, const NameValuePairs &pairs2)
: m_pairs1(pairs1), m_pairs2(pairs2) {}
@@ -101,6 +147,7 @@ private:
const NameValuePairs &m_pairs1, &m_pairs2;
};
+#ifndef CRYPTOPP_DOXYGEN_PROCESSING
template
class GetValueHelperClass
{
@@ -312,6 +359,8 @@ AssignFromHelperClass AssignFromHelper(T *pObject, const NameValuePairs &s
return AssignFromHelperClass(pObject, source);
}
+#endif // CRYPTOPP_DOXYGEN_PROCESSING
+
// ********************************************************
// to allow the linker to discard Integer code if not needed.
@@ -320,9 +369,13 @@ CRYPTOPP_DLL extern PAssignIntToInteger g_pAssignIntToInteger;
CRYPTOPP_DLL const std::type_info & CRYPTOPP_API IntegerTypeId();
+//! \class AlgorithmParametersBase
+//! \brief Base class for AlgorithmParameters
class CRYPTOPP_DLL AlgorithmParametersBase
{
public:
+ //! \class ParameterNotUsed
+ //! \brief Exception thrown when an AlgorithmParameter is unused
class ParameterNotUsed : public Exception
{
public:
@@ -337,6 +390,11 @@ public:
x.m_used = true;
}
+ //! \brief Construct a AlgorithmParametersBase
+ //! \param name the parameter name
+ //! \param throwIfNotUsed flags indicating whether an exception should be thrown
+ //! \details If throwIfNotUsed is true, then a ParameterNotUsed exception
+ //! will be thrown in the destructor if the parameter is not not retrieved.
AlgorithmParametersBase(const char *name, bool throwIfNotUsed)
: m_name(name), m_throwIfNotUsed(throwIfNotUsed), m_used(false) {}
@@ -373,10 +431,19 @@ protected:
member_ptr m_next;
};
+//! \class AlgorithmParametersTemplate
+//! \brief Template base class for AlgorithmParameters
+//! \tparam T the class or type
template
class AlgorithmParametersTemplate : public AlgorithmParametersBase
{
public:
+ //! \brief Construct an AlgorithmParametersTemplate
+ //! \param name the name of the value
+ //! \param value a reference to the value
+ //! \param throwIfNotUsed flags indicating whether an exception should be thrown
+ //! \details If throwIfNotUsed is true, then a ParameterNotUsed exception
+ //! will be thrown in the destructor if the parameter is not not retrieved.
AlgorithmParametersTemplate(const char *name, const T &value, bool throwIfNotUsed)
: AlgorithmParametersBase(name, throwIfNotUsed), m_value(value)
{
diff --git a/blowfish.h b/blowfish.h
index 98336b45..41497a66 100644
--- a/blowfish.h
+++ b/blowfish.h
@@ -12,7 +12,7 @@
NAMESPACE_BEGIN(CryptoPP)
//! \class Blowfish_Info
-//! \brief The cipher's key, iv, block size and name information.
+//! \brief Blowfish block cipher information
struct Blowfish_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 4, 56>, public FixedRounds<16>
{
static const char *StaticAlgorithmName() {return "Blowfish";}
@@ -20,8 +20,8 @@ struct Blowfish_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 4,
// Blowfish
-//! \class Blowfish
-//! \brief Provides Blowfish encryption and decryption
+//! \class Blowfish_Info
+//! \brief Blowfish block cipher
class Blowfish : public Blowfish_Info, public BlockCipherDocumentation
{
//! \class Base
diff --git a/camellia.h b/camellia.h
index 91e765e5..832bceac 100644
--- a/camellia.h
+++ b/camellia.h
@@ -12,13 +12,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class Camellia_Info
+//! \brief Camellia block cipher information
struct Camellia_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
{
static const char *StaticAlgorithmName() {return "Camellia";}
};
-/// Camellia
+//! \class Camellia
+//! \brief Camellia block cipher
+//! \sa Camellia
class Camellia : public Camellia_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/cast.h b/cast.h
index d464bbf7..05c0c50c 100644
--- a/cast.h
+++ b/cast.h
@@ -17,13 +17,16 @@ protected:
static const word32 S[8][256];
};
-//! algorithm info
+//! \class CAST128_Info
+//! \brief CAST128 block cipher information
struct CAST128_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 5, 16>
{
static const char *StaticAlgorithmName() {return "CAST-128";}
};
-/// CAST-128
+//! \class CAST128
+//! \brief CAST128 block cipher
+//! \sa CAST-128
class CAST128 : public CAST128_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl
@@ -53,13 +56,16 @@ public:
typedef BlockCipherFinal Decryption;
};
-//! algorithm info
+//! \class CAST256_Info
+//! \brief CAST256 block cipher information
struct CAST256_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32>
{
static const char *StaticAlgorithmName() {return "CAST-256";}
};
-//! CAST-256
+//! \class CAST256
+//! \brief CAST256 block cipher
+//! \sa CAST-256
class CAST256 : public CAST256_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl
diff --git a/config.h b/config.h
index 638bc3ce..dad4e619 100644
--- a/config.h
+++ b/config.h
@@ -368,7 +368,7 @@ NAMESPACE_END
# pragma GCC diagnostic ignored "-Wunused-function"
#endif
-#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
+#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || (defined(_STLPORT_VERSION) && ((_STLPORT_VERSION < 0x450) || defined(_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)))
#define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
#endif
@@ -414,7 +414,7 @@ NAMESPACE_END
#define CRYPTOPP_X64_ASM_AVAILABLE
#endif
-#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
+#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__)) && !defined(_M_ARM)
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
#else
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
@@ -468,8 +468,9 @@ NAMESPACE_END
#endif
// Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set.
-// Detect via __ILP32__ (http://wiki.debian.org/X32Port). Both GCC and Clang provide the preprocessor macro.
-#if ((__ILP32__ >= 1) || (_ILP32 >= 1))
+// Detect via __ILP32__ (http://wiki.debian.org/X32Port). However, __ILP32__ shows up in more places than
+// the System V ABI specs calls out, like on just about any 32-bit system with Clang.
+#if ((__ILP32__ >= 1) || (_ILP32 >= 1)) && defined(__x86_64__)
#define CRYPTOPP_BOOL_X32 1
#else
#define CRYPTOPP_BOOL_X32 0
diff --git a/config.recommend b/config.recommend
index eb7dbb58..6901e0fb 100644
--- a/config.recommend
+++ b/config.recommend
@@ -368,7 +368,7 @@ NAMESPACE_END
# pragma GCC diagnostic ignored "-Wunused-function"
#endif
-#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || defined(_STLPORT_VERSION)
+#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__MWERKS__) || (defined(_STLPORT_VERSION) && ((_STLPORT_VERSION < 0x450) || defined(_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)))
#define CRYPTOPP_DISABLE_UNCAUGHT_EXCEPTION
#endif
@@ -414,7 +414,7 @@ NAMESPACE_END
#define CRYPTOPP_X64_ASM_AVAILABLE
#endif
-#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
+#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__)) && !defined(_M_ARM)
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
#else
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
@@ -466,10 +466,11 @@ NAMESPACE_END
#else
# define CRYPTOPP_CONSTANT(x) static const int x;
#endif
-
+
// Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set.
-// Detect via __ILP32__ (http://wiki.debian.org/X32Port). Both GCC and Clang provide the preprocessor macro.
-#if ((__ILP32__ >= 1) || (_ILP32 >= 1))
+// Detect via __ILP32__ (http://wiki.debian.org/X32Port). However, __ILP32__ shows up in more places than
+// the System V ABI specs calls out, like on just about any 32-bit system with Clang.
+#if ((__ILP32__ >= 1) || (_ILP32 >= 1)) && defined(__x86_64__)
#define CRYPTOPP_BOOL_X32 1
#else
#define CRYPTOPP_BOOL_X32 0
diff --git a/cpu.h b/cpu.h
index c0b0122e..36d26dd2 100644
--- a/cpu.h
+++ b/cpu.h
@@ -278,6 +278,21 @@ inline int GetCacheLineSize()
#define IF0(y)
#define IF1(y) y
+// Should be confined to GCC, but its used to help manage Clang 3.4 compiler error.
+// Also see LLVM Bug 24232, http://llvm.org/bugs/show_bug.cgi?id=24232 .
+#ifndef INTEL_PREFIX
+ #define INTEL_PREFIX
+#endif
+#ifndef INTEL_NOPREFIX
+ #define INTEL_NOPREFIX
+#endif
+#ifndef ATT_PREFIX
+ #define ATT_PREFIX
+#endif
+#ifndef ATT_NOPREFIX
+ #define ATT_NOPREFIX
+#endif
+
#ifdef CRYPTOPP_GENERATE_X64_MASM
#define ASM_MOD(x, y) ((x) MOD (y))
#define XMMWORD_PTR XMMWORD PTR
diff --git a/cryptest.sh b/cryptest.sh
index 4d61d6c9..e07a5b43 100755
--- a/cryptest.sh
+++ b/cryptest.sh
@@ -14,7 +14,7 @@
# Set to suite your taste
TEST_RESULTS=cryptest-result.txt
BENCHMARK_RESULTS=cryptest-bench.txt
-WARN_TEST_RESULTS=cryptest-warn-result.txt
+WARN_RESULTS=cryptest-warn.txt
# Respect user's preferred flags, but filter the stuff we expliclty test
#if [ ! -z "CXXFLAGS" ]; then
@@ -33,6 +33,8 @@ IS_LINUX=$(uname -s | grep -i -c linux)
IS_CYGWIN=$(uname -s | grep -i -c cygwin)
IS_MINGW=$(uname -s | grep -i -c mingw)
IS_OPENBSD=$(uname -s | grep -i -c openbsd)
+IS_INTEL=$(uname -m | egrep -i -c "(i386|i586|i686|amd64|x86_64)")
+IS_PPC=$(uname -m | egrep -i -c "(Power|PPC)")
# We need to use the C++ compiler to determine if c++11 is available. Otherwise
# a mis-detection occurs on Mac OS X 10.9 and above. Below, we use the same
@@ -105,12 +107,30 @@ if [ "$IS_CYGWIN" -ne "0" ] || [ "$IS_MINGW" -ne "0" ]; then
HAVE_ASAN=0
fi
-#Final fixups for compilers liek GCC on ARM64
+# Final fixups for compilers like GCC on ARM64
if [ "$HAVE_UBSAN" -eq "0" ] || [ "$HAVE_ASAN" -eq "0" ]; then
HAVE_UBAN=0
HAVE_ASAN=0
fi
+# Set to 0 if you don't have Intel multiarch
+HAVE_INTEL_MULTIARCH=0
+if [ "$IS_DARWIN" -ne "0" ] && [ "$IS_INTEL" -ne "0" ]; then
+$CXX -x c++ -arch i386 -arch x86_64 -c adhoc.cpp.proto -o $TMP/adhoc > /dev/null 2>&1
+if [ "$?" -eq "0" ]; then
+ HAVE_INTEL_MULTIARCH=1
+fi
+fi
+
+# Set to 0 if you don't have PPC multiarch
+HAVE_PPC_MULTIARCH=0
+if [ "$IS_DARWIN" -ne "0" ] && [ "$IS_PPC" -ne "0" ]; then
+$CXX -x c++ -arch ppc -arch ppc64 -c adhoc.cpp.proto -o $TMP/adhoc > /dev/null 2>&1
+if [ "$?" -eq "0" ]; then
+ HAVE_PPC_MULTIARCH=1
+fi
+fi
+
# Set to 0 if you don't have Valgrind. Valgrind tests take a long time...
HAVE_VALGRIND=$(which valgrind 2>&1 | grep -v "no valgrind" | grep -i -c valgrind)
@@ -128,6 +148,12 @@ if [ "$IS_DARWIN" -ne "0" ]; then
echo "IS_DARWIN: $IS_DARWIN"
unset MallocScribble MallocPreScribble MallocGuardEdges
fi
+if [ "$HAVE_INTEL_MULTIARCH" -ne "0" ]; then
+ echo "HAVE_INTEL_MULTIARCH: $HAVE_INTEL_MULTIARCH"
+fi
+if [ "$HAVE_PPC_MULTIARCH" -ne "0" ]; then
+ echo "HAVE_PPC_MULTIARCH: $HAVE_PPC_MULTIARCH"
+fi
if [ "$IS_LINUX" -ne "0" ]; then
echo "IS_LINUX: $IS_LINUX"
fi
@@ -142,11 +168,6 @@ echo "User CXXFLAGS: $CXXFLAGS"
echo "Retained CXXFLAGS: $ADD_CXXFLAGS"
echo "Compiler:" $($CXX --version | head -1)
-TEST_BEGIN=$(date)
-echo
-echo "Start time: $TEST_BEGIN"
-
-############################################
############################################
# Remove previous test results
@@ -159,6 +180,13 @@ touch "$BENCHMARK_RESULTS"
rm -f "$WARN_RESULTS" > /dev/null 2>&1
touch "$WARN_RESULTS"
+############################################
+############################################
+
+TEST_BEGIN=$(date)
+echo
+echo "Start time: $TEST_BEGIN"
+
############################################
# Basic debug build
echo
@@ -611,6 +639,69 @@ if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_CXX11" -ne "0" ]; then
./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
fi
+############################################
+# Darwin, Intel multiarch, c++03
+if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_INTEL_MULTIARCH" -ne "0" ] && [ "$HAVE_CXX03" -ne "0" ]; then
+ echo
+ echo "************************************" | tee -a "$TEST_RESULTS"
+ echo "Testing: Darwin, Intel multiarch, c++03" | tee -a "$TEST_RESULTS"
+ echo
+
+ unset CXXFLAGS
+ "$MAKE" clean > /dev/null 2>&1
+ export CXXFLAGS="-DNDEBUG -g2 -O2 -arch i386 -arch x86_64 -std=c++03 $ADD_CXXFLAGS"
+ "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
+
+ echo "Running i386 version..."
+ arch -i386 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
+ arch -i386 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
+ echo "Running x86_64 version..."
+ arch -x86_64 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
+ arch -x86_64 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
+fi
+
+############################################
+# Darwin, Intel multiarch, c++11
+if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_INTEL_MULTIARCH" -ne "0" ] && [ "$HAVE_CXX11" -ne "0" ]; then
+ echo
+ echo "************************************" | tee -a "$TEST_RESULTS"
+ echo "Testing: Darwin, Intel multiarch, c++11" | tee -a "$TEST_RESULTS"
+ echo
+
+ unset CXXFLAGS
+ "$MAKE" clean > /dev/null 2>&1
+ export CXXFLAGS="-DNDEBUG -g2 -O2 -arch i386 -arch x86_64 -std=c++11 $ADD_CXXFLAGS"
+ "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
+
+ echo "Running i386 version..."
+ arch -i386 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
+ arch -i386 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
+ echo "Running x86_64 version..."
+ arch -x86_64 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
+ arch -x86_64 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
+fi
+
+############################################
+# Darwin, PowerPC multiarch
+if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_PPC_MULTIARCH" -ne "0" ]; then
+ echo
+ echo "************************************" | tee -a "$TEST_RESULTS"
+ echo "Testing: Darwin, PowerPC multiarch" | tee -a "$TEST_RESULTS"
+ echo
+
+ unset CXXFLAGS
+ "$MAKE" clean > /dev/null 2>&1
+ export CXXFLAGS="-DNDEBUG -g2 -O2 -arch ppc -arch ppc64 $ADD_CXXFLAGS"
+ "$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
+
+ echo "Running PPC version..."
+ arch -ppc ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
+ arch -ppc ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
+ echo "Running PPC64 version..."
+ arch -ppc64 ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
+ arch -ppc64 ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
+fi
+
############################################
# Darwin, c++03, Malloc Guards
if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_CXX03" -ne "0" ]; then
@@ -653,12 +744,15 @@ if [ "$IS_DARWIN" -ne "0" ] && [ "$HAVE_CXX11" -ne "0" ]; then
unset MallocScribble MallocPreScribble MallocGuardEdges
fi
-# Try to locate a Xcode compiler for testing under Darwin
-XCODE_COMPILER=$(find /Applications/Xcode*.app/Contents/Developer -name clang++ | head -1)
-
############################################
# Xcode compiler
-if [ "$IS_DARWIN" -ne "0" ] && [ -z "$XCODE_COMPILER" ]; then
+if [ "$IS_DARWIN" -ne "0" ]; then
+ XCODE_COMPILER=$(find /Applications/Xcode*.app/Contents/Developer -name clang++ 2>/dev/null | head -1)
+ if [ -z "$XCODE_COMPILER" ]; then
+ XCODE_COMPILER=$(find /Developer/Applications/Xcode.app -name clang++ 2>/dev/null | head -1)
+ fi
+
+ if [ ! -z "$XCODE_COMPILER" ]; then
echo
echo "************************************" | tee -a "$TEST_RESULTS"
echo "Testing: Xcode Clang compiler" | tee -a "$TEST_RESULTS"
@@ -666,11 +760,12 @@ if [ "$IS_DARWIN" -ne "0" ] && [ -z "$XCODE_COMPILER" ]; then
unset CXXFLAGS
"$MAKE" clean > /dev/null 2>&1
- expot CXX="$XCODE_COMPILER"
- export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 $ADD_CXXFLAGS"
+ export CXX="$XCODE_COMPILER"
+ export CXXFLAGS="-DNDEBUG -g2 -O2 $ADD_CXXFLAGS"
"$MAKE" static cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
+ fi
fi
############################################
@@ -778,26 +873,52 @@ if [ "$CXX" == "g++" ] && [ "$HAVE_CXX11" -ne "0" ]; then
############################################
# Basic debug build
echo
- echo "************************************" | tee -a "$WARN_TEST_RESULTS"
- echo "Testing: debug, c++11, elevated warnings" | tee -a "$WARN_TEST_RESULTS"
+ echo "************************************" | tee -a "$WARN_RESULTS"
+ echo "Testing: debug, c++11, elevated warnings" | tee -a "$WARN_RESULTS"
echo
unset CXXFLAGS
"$MAKE" clean > /dev/null 2>&1
export CXXFLAGS="-DDEBUG -g2 -O2 -std=c++11 -DCRYPTOPP_NO_BACKWARDS_COMPATIBILITY_562 -Wall -Wextra -Wno-unknown-pragmas -Wstrict-aliasing=3 -Wstrict-overflow -Waggressive-loop-optimizations"
- "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$WARN_TEST_RESULTS"
+ "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$WARN_RESULTS"
############################################
# Basic release build
echo
- echo "************************************" | tee -a "$WARN_TEST_RESULTS"
- echo "Testing: release, c++11, elevated warnings" | tee -a "$WARN_TEST_RESULTS"
+ echo "************************************" | tee -a "$WARN_RESULTS"
+ echo "Testing: release, c++11, elevated warnings" | tee -a "$WARN_RESULTS"
echo
unset CXXFLAGS
"$MAKE" clean > /dev/null 2>&1
export CXXFLAGS="-DNDEBUG -g2 -O2 -std=c++11 -DCRYPTOPP_NO_BACKWARDS_COMPATIBILITY_562 -Wall -Wextra -Wno-unknown-pragmas -Wstrict-aliasing=3 -Wstrict-overflow -Waggressive-loop-optimizations"
- "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$WARN_TEST_RESULTS"
+ "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$WARN_RESULTS"
+fi
+
+############################################
+############################################
+
+# If using GCC (likely Linux), then perform a quick check with Clang.
+# This check was added after testing on Ubuntu 14.04 with Clang 3.4.
+if [ "$CXX" == "g++" ]; then
+
+ $(which clang++ | head -1) -x c++ -c adhoc.cpp.proto -o $TMP/adhoc > /dev/null 2>&1
+ if [ "$?" -eq "0" ]; then
+
+ ############################################
+ # Basic Clang build
+ echo
+ echo "************************************" | tee -a "$TEST_RESULTS"
+ echo "Testing: Clang" | tee -a "$TEST_RESULTS"
+ echo
+
+ unset CXX
+ unset CXXFLAGS
+ export CXX="clang++"
+
+ "$MAKE" clean > /dev/null 2>&1
+ "$MAKE" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
+ fi
fi
############################################
@@ -837,3 +958,10 @@ echo | tee -a "$TEST_RESULTS"
echo "************************************************" | tee -a "$TEST_RESULTS"
echo "************************************************" | tee -a "$TEST_RESULTS"
+
+# http://tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF
+if [ "$COUNT" -eq "0" ]; then
+ exit 0
+else
+ exit 1
+fi
diff --git a/cryptlib.h b/cryptlib.h
index 555b0401..ac6e8814 100644
--- a/cryptlib.h
+++ b/cryptlib.h
@@ -114,17 +114,21 @@ struct EnumToType
//! \brief Provides the byte ordering
enum ByteOrder {LITTLE_ENDIAN_ORDER = 0, BIG_ENDIAN_ORDER = 1};
-//! \typedef Provides a constant for LittleEndian
+//! \brief Provides a constant for LittleEndian
typedef EnumToType LittleEndian;
-//! \typedef Provides a constant for BigEndian
+//! \brief Provides a constant for BigEndian
typedef EnumToType BigEndian;
//! \class Exception
-//! \brief Base class for all exceptions thrown by Crypto++
+//! \brief Base class for all exceptions thrown by the library
+//! \details All library exceptions directly or indirectly inherit from the Exception class.
+//! The Exception class itself inherits from std::exception. The library does not use
+//! std::runtime_error derived classes.
class CRYPTOPP_DLL Exception : public std::exception
{
public:
- //! error types
+ //! \enum ErrorType
+ //! \brief Error types or categories
enum ErrorType {
//! \brief A method was called which was not implemented
NOT_IMPLEMENTED,
@@ -138,7 +142,7 @@ public:
INVALID_DATA_FORMAT,
//! \brief Error reading from input device or writing to output device
IO_ERROR,
- //! \brief Some other error occurred not belong to any of the above categories
+ //! \brief Some other error occurred not belonging to other categories
OTHER_ERROR
};
@@ -493,7 +497,8 @@ public:
};
//! \class SimpleKeyingInterface
-//! Interface for algorithms that take byte strings as keys
+//! \brief Interface for algorithms that take byte strings as keys
+//! \sa FixedKeyLength(), VariableKeyLength(), SameKeyLengthAs(), SimpleKeyingInterfaceImpl()
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE SimpleKeyingInterface
{
public:
@@ -507,11 +512,14 @@ public:
virtual size_t DefaultKeyLength() const =0;
//! \brief
+ //! \param n the desired keylength
//! \returns the smallest valid key length in bytes that is greater than or equal to min(n, GetMaxKeyLength())
virtual size_t GetValidKeyLength(size_t n) const =0;
//! \brief Returns whether keylength is a valid key length
- //! \details Internally the function calls GetValidKeyLength()
+ //! \param keylength the requested keylength
+ //! \returns true if keylength is valid, false otherwise
+ //! \details Internally the function calls GetValidKeyLength()
virtual bool IsValidKeyLength(size_t keylength) const
{return keylength == GetValidKeyLength(keylength);}
@@ -527,8 +535,8 @@ public:
//! \param length the size of the key, in bytes
//! \param rounds the number of rounds to apply the transformation function,
//! if applicable
- //! \details SetKeyWithRounds calls SetKey with an NameValuePairs
- //! object that just specifies rounds. rounds is an integer parameter,
+ //! \details SetKeyWithRounds() calls SetKey() with a NameValuePairs
+ //! object that only specifies rounds. rounds is an integer parameter,
//! and -1 means use the default number of rounds.
void SetKeyWithRounds(const byte *key, size_t length, int rounds);
@@ -537,27 +545,32 @@ public:
//! \param length the size of the key, in bytes
//! \param iv the intiialization vector to use when keying the object
//! \param ivLength the size of the iv, in bytes
- //! \details SetKeyWithIV calls SetKey with an NameValuePairs object
- //! that just specifies iv. iv is a byte buffer with size ivLength.
+ //! \details SetKeyWithIV() calls SetKey() with a NameValuePairs
+ //! that only specifies IV. The IV is a byte buffer with size ivLength.
+ //! ivLength is an integer parameter, and -1 means use IVSize().
void SetKeyWithIV(const byte *key, size_t length, const byte *iv, size_t ivLength);
//! \brief Sets or reset the key of this object
//! \param key the key to use when keying the object
//! \param length the size of the key, in bytes
//! \param iv the intiialization vector to use when keying the object
- //! \details SetKeyWithIV calls SetKey with an NameValuePairs object
- //! that just specifies iv. iv is a byte buffer, and it must have
- //! a size IVSize.
+ //! \details SetKeyWithIV() calls SetKey() with a NameValuePairs() object
+ //! that only specifies iv. iv is a byte buffer, and it must have
+ //! a size IVSize().
void SetKeyWithIV(const byte *key, size_t length, const byte *iv)
{SetKeyWithIV(key, length, iv, IVSize());}
- //! \brief Provides IV requirements as an enumerated value.
+ //! \brief Secure IVs requirements as enumerated values.
+ //! \details Provides secure IV requirements as a monotomically increasing enumerated values. Requirements can be
+ //! compared using less than (<) and greater than (>). For example, UNIQUE_IV < RANDOM_IV
+ //! and UNPREDICTABLE_RANDOM_IV > RANDOM_IV.
+ //! \sa IsResynchronizable(), CanUseRandomIVs(), CanUsePredictableIVs(), CanUseStructuredIVs()
enum IV_Requirement {
//! \brief The IV must be unique
UNIQUE_IV = 0,
- //! \brief The IV must be random
+ //! \brief The IV must be random and possibly predictable
RANDOM_IV,
- //! \brief The IV must be unpredictable
+ //! \brief The IV must be random and unpredictable
UNPREDICTABLE_RANDOM_IV,
//! \brief The IV is set by the object
INTERNALLY_GENERATED_IV,
@@ -565,42 +578,69 @@ public:
NOT_RESYNCHRONIZABLE
};
- //! returns the minimal requirement for secure IVs
+ //! \brief Minimal requirement for secure IVs
+ //! \returns the secure IV requirement of the algorithm
virtual IV_Requirement IVRequirement() const =0;
- //! returns whether the object can be resynchronized (i.e. supports initialization vectors)
- /*! If this function returns true, and no IV is passed to SetKey() and CanUseStructuredIVs()==true, an IV of all 0's will be assumed. */
+ //! \brief Determines if the object can be resynchronized
+ //! \returns true if the object can be resynchronized (i.e. supports initialization vectors), false otherwise
+ //! \note If this function returns true, and no IV is passed to SetKey() and CanUseStructuredIVs()==true,
+ //! an IV of all 0's will be assumed.
bool IsResynchronizable() const {return IVRequirement() < NOT_RESYNCHRONIZABLE;}
- //! returns whether the object can use random IVs (in addition to ones returned by GetNextIV)
+
+ //! \brief Determines if the object can use random IVs
+ //! \returns true if the object can use random IVs (in addition to ones returned by GetNextIV), false otherwise
bool CanUseRandomIVs() const {return IVRequirement() <= UNPREDICTABLE_RANDOM_IV;}
- //! returns whether the object can use random but possibly predictable IVs (in addition to ones returned by GetNextIV)
+
+ //! \brief Determines if the object can use random but possibly predictable IVs
+ //! \returns true if the object can use random but possibly predictable IVs (in addition to ones returned by
+ //! GetNextIV), false otherwise
bool CanUsePredictableIVs() const {return IVRequirement() <= RANDOM_IV;}
- //! returns whether the object can use structured IVs, for example a counter (in addition to ones returned by GetNextIV)
+
+ //! \brief Determines if the object can use structured IVs
+ //! returns whether the object can use structured IVs, for example a counter (in addition to ones returned by
+ //! GetNextIV), false otherwise
bool CanUseStructuredIVs() const {return IVRequirement() <= UNIQUE_IV;}
//! \brief Returns length of the IV accepted by this object
+ //! \returns the size of an IV, in bytes
+ //! \throws NotImplemented() if the object does not support resynchronization
//! \details The default implementation throws NotImplemented
virtual unsigned int IVSize() const
{throw NotImplemented(GetAlgorithm().AlgorithmName() + ": this object doesn't support resynchronization");}
- //! returns default length of IVs accepted by this object
+
+ //! \brief Provides the default size of an IV
+ //! \returns default length of IVs accepted by this object, in bytes
unsigned int DefaultIVLength() const {return IVSize();}
- //! returns minimal length of IVs accepted by this object
+
+ //! \brief Provides the minimum size of an IV
+ //! \returns minimal length of IVs accepted by this object, in bytes
+ //! \throws NotImplemented() if the object does not support resynchronization
virtual unsigned int MinIVLength() const {return IVSize();}
- //! returns maximal length of IVs accepted by this object
+
+ //! \brief Provides the maximum size of an IV
+ //! \returns maximal length of IVs accepted by this object, in bytes
+ //! \throws NotImplemented() if the object does not support resynchronization
virtual unsigned int MaxIVLength() const {return IVSize();}
- //! resynchronize with an IV. ivLength=-1 means use IVSize()
+
+ //! \brief Resynchronize with an IV
+ //! \param iv the initialization vector
+ //! \param ivLength the size of the initialization vector, in bytes
+ //! \details Resynchronize() resynchronizes with an IV provided by the caller. ivLength=-1 means use IVSize().
+ //! \throws NotImplemented() if the object does not support resynchronization
virtual void Resynchronize(const byte *iv, int ivLength=-1) {
CRYPTOPP_UNUSED(iv); CRYPTOPP_UNUSED(ivLength);
throw NotImplemented(GetAlgorithm().AlgorithmName() + ": this object doesn't support resynchronization");
}
- //! \brief Gets a secure IV for the next message
+ //! \brief Retrieves a secure IV for the next message
//! \param rng a RandomNumberGenerator to produce keying material
//! \param iv a block of bytes to receive the IV
+ //! \details The IV must be at least IVSize() in length.
//! \details This method should be called after you finish encrypting one message and are ready
- //! to start the next one. After calling it, you must call SetKey() or Resynchronize()
- //! before using this object again.
- //! \details key must be at least IVSize() in length.
+ //! to start the next one. After calling it, you must call SetKey() or Resynchronize().
+ //! before using this object again.
+ //! \details Internally, the base class implementation calls RandomNumberGenerator's GenerateBlock()
//! \note This method is not implemented on decryption objects.
virtual void GetNextIV(RandomNumberGenerator &rng, byte *iv);
@@ -638,7 +678,7 @@ protected:
void ThrowIfInvalidIV(const byte *iv);
//! \brief Validates the IV length
- //! \param length the size of the IV, in bytes
+ //! \param length the size of an IV, in bytes
//! \throws InvalidArgument if the number of rounds are invalid
size_t ThrowIfInvalidIVLength(int length);
@@ -689,7 +729,7 @@ public:
//! \param inoutBlock the input message before processing
//! \details ProcessBlock encrypts or decrypts inoutBlock in-place.
//! \details The size of the block is determined by the block cipher and its documentation.
- //! Use BLOCKSIZE at compile time, or BlockSize() at runtime.
+ //! Use BLOCKSIZE at compile time, or BlockSize() at runtime.
//! \sa FixedBlockSize, BlockCipherFinal from seckey.h and BlockSize()
void ProcessBlock(byte *inoutBlock) const
{ProcessAndXorBlock(inoutBlock, NULL, inoutBlock);}
@@ -763,7 +803,7 @@ public:
//! \brief Provides the input block size most efficient for this cipher.
//! \returns The input block size that is most efficient for the cipher
- //! \details The base class implemnetation returns MandatoryBlockSize().
+ //! \details The base class implementation returns MandatoryBlockSize().
//! \note Optimal input length is
//! n * OptimalBlockSize() - GetOptimalBlockSizeUsed() for any n \> 0.
virtual unsigned int OptimalBlockSize() const {return MandatoryBlockSize();}
@@ -908,7 +948,7 @@ public:
//! \brief Provides the input block size most efficient for this hash.
//! \returns The input block size that is most efficient for the cipher
- //! \details The base class implemnetation returns MandatoryBlockSize().
+ //! \details The base class implementation returns MandatoryBlockSize().
//! \note Optimal input length is
//! n * OptimalBlockSize() - GetOptimalBlockSizeUsed() for any n \> 0.
virtual unsigned int OptimalBlockSize() const {return 1;}
@@ -956,7 +996,7 @@ public:
//! \param digest a pointer to the buffer to receive the hash
//! \param digestSize the size of the truncated digest, in bytes
//! \details TruncatedFinal() call Final() and then copies digestSize bytes to digest
- //! \details TruncatedFinal() restarts the hash for the next nmessage.
+ //! \details TruncatedFinal() restarts the hash for the next message.
virtual void TruncatedFinal(byte *digest, size_t digestSize) =0;
//! \brief Updates the hash with additional input and computes the hash of the current message
@@ -1002,7 +1042,10 @@ public:
#endif
protected:
- //! \brief Exception thrown when the truncated digest size is greater than DigestSize()
+ //! \brief Validates a truncated digest size
+ //! \param size the requested digest size
+ //! \throws InvalidArgument if the algorithm's digest size cannot be truncated to the requested size
+ //! \details Throws an exception when the truncated digest size is greater than DigestSize()
void ThrowIfInvalidTruncatedSize(size_t size) const;
};
@@ -1182,7 +1225,7 @@ public:
//! \details NullRNG() returns a reference that can be passed to functions that require a
//! RandomNumberGenerator but don't actually use it. The NullRNG() throws NotImplemented
//! when a generation function is called.
-//! \sa ClassNullRNG
+//! \sa ClassNullRNG, IsProbabilistic()
CRYPTOPP_DLL RandomNumberGenerator & CRYPTOPP_API NullRNG();
//! \class WaitObjectContainer
@@ -1332,6 +1375,7 @@ public:
//! \param length the size of the string, in bytes
//! \param propagation the number of attached transformations the MessageEnd() signal should be passed
//! \param blocking specifies whether the object should block when processing input
+ //! \returns the number of bytes that remain in the block (i.e., bytes not processed)
//! \details Internally, PutMessageEnd() calls Put2() with a modified propagation to
//! ensure all attached transformations finish processing the message.
//! \details propagation count includes this object. Setting propagation to 1 means this
@@ -1356,7 +1400,9 @@ public:
virtual size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking)
{return Put2(inString, length, messageEnd, blocking);}
- //! \brief thrown by objects that have not implemented nonblocking input processing
+ //! \class BlockingInputOnly
+ //! \brief Exception thrown by objects that have \a not implemented nonblocking input processing
+ //! \details BlockingInputOnly inherits from NotImplemented
struct BlockingInputOnly : public NotImplemented
{BlockingInputOnly(const std::string &s) : NotImplemented(s + ": Nonblocking input is not implemented by this object.") {}};
//@}
@@ -1381,14 +1427,13 @@ public:
//@{
//! \brief Initialize or reinitialize this object, without signal propagation
- //! \param parameters a set of NameValuePairs used to initialize this object
+ //! \param parameters a set of NameValuePairs to initialize this object
//! \throws NotImplemented
//! \details IsolatedInitialize() is used to initialize or reinitialize an object using a variable
//! number of arbitrarily typed arguments. The function avoids the need for multiple constuctors providing
//! all possible combintations of configurable parameters.
//! \details IsolatedInitialize() does not call Initialize() on attached transformations. If initialization
//! should be propagated, then use the Initialize() function.
- //! \details Setting propagation to -1 means unlimited propagation.
//! \details If a derived class does not override IsolatedInitialize(), then the base class throws
//! NotImplemented.
virtual void IsolatedInitialize(const NameValuePairs ¶meters) {
@@ -1409,8 +1454,7 @@ public:
{CRYPTOPP_UNUSED(blocking); return false;}
//! \brief Initialize or reinitialize this object, with signal propagation
- //! \param parameters a set of NameValuePairs used to initialize or reinitialize this object
- //! and attached transformations
+ //! \param parameters a set of NameValuePairs to initialize or reinitialize this object
//! \param propagation the number of attached transformations the Initialize() signal should be passed
//! \details Initialize() is used to initialize or reinitialize an object using a variable number of
//! arbitrarily typed arguments. The function avoids the need for multiple constuctors providing
@@ -1781,8 +1825,7 @@ public:
//! \param length the size of the string, in bytes
//! \param propagation the number of attached transformations the ChannelPutMessageEnd() signal should be passed
//! \param blocking specifies whether the object should block when processing input
- //! \returns 0 indicates all bytes were processed during the call. Non-0 indicates the
- //! number of bytes that were \a not processed.
+ //! \returns the number of bytes that remain in the block (i.e., bytes not processed)
//! \details propagation count includes this object. Setting propagation to 1 means this
//! object only. Setting propagation to -1 means unlimited propagation.
size_t ChannelPutMessageEnd(const std::string &channel, const byte *inString, size_t length, int propagation=-1, bool blocking=true)
@@ -1791,13 +1834,14 @@ public:
//! \brief Request space which can be written into by the caller
//! \param channel the channel to process the data
//! \param size the requested size of the buffer
+ //! \returns a pointer to a memroy block with length size
//! \details The purpose of this method is to help avoid extra memory allocations.
//! \details size is an \a IN and \a OUT parameter and used as a hint. When the call is made,
//! size is the requested size of the buffer. When the call returns, size is the size of
//! the array returned to the caller.
- //! \details The base class implementation sets size to 0 and returns NULL.
- //! \note Some objects, like ArraySink, cannot create a space because its fixed. In the case of
- //! an ArraySink, the pointer to the array is returned and the size is remaining size.
+ //! \details The base class implementation sets size to 0 and returns NULL.
+ //! \note Some objects, like ArraySink(), cannot create a space because its fixed. In the case of
+ //! an ArraySink(), the pointer to the array is returned and the size is remaining size.
virtual byte * ChannelCreatePutSpace(const std::string &channel, size_t &size);
//! \brief Input multiple bytes for processing on a channel.
@@ -1806,6 +1850,7 @@ public:
//! \param length the size of the string, in bytes.
//! \param messageEnd means how many filters to signal MessageEnd() to, including this one.
//! \param blocking specifies whether the object should block when processing input.
+ //! \returns the number of bytes that remain in the block (i.e., bytes not processed)
virtual size_t ChannelPut2(const std::string &channel, const byte *inString, size_t length, int messageEnd, bool blocking);
//! \brief Input multiple bytes that may be modified by callee on a channel
@@ -1814,6 +1859,7 @@ public:
//! \param length the size of the string, in bytes
//! \param messageEnd means how many filters to signal MessageEnd() to, including this one
//! \param blocking specifies whether the object should block when processing input
+ //! \returns the number of bytes that remain in the block (i.e., bytes not processed)
virtual size_t ChannelPutModifiable2(const std::string &channel, byte *inString, size_t length, int messageEnd, bool blocking);
//! \brief Flush buffered input and/or output on a channel
@@ -1821,6 +1867,7 @@ public:
//! \param hardFlush is used to indicate whether all data should be flushed
//! \param propagation the number of attached transformations the ChannelFlush() signal should be passed
//! \param blocking specifies whether the object should block when processing input
+ //! \returns true of the Flush was successful
//! \details propagation count includes this object. Setting propagation to 1 means this
//! object only. Setting propagation to -1 means unlimited propagation.
virtual bool ChannelFlush(const std::string &channel, bool hardFlush, int propagation=-1, bool blocking=true);
@@ -1856,11 +1903,15 @@ public:
virtual bool Attachable() {return false;}
//! \brief Returns the object immediately attached to this object
- //! \details AttachedTransformation returns NULL if there is no attachment
+ //! \returns the attached transformation
+ //! \details AttachedTransformation() returns NULL if there is no attachment. The non-const
+ //! version of AttachedTransformation() always returns NULL.
virtual BufferedTransformation *AttachedTransformation() {assert(!Attachable()); return 0;}
//! \brief Returns the object immediately attached to this object
- //! \details AttachedTransformation returns NULL if there is no attachment
+ //! \returns the attached transformation
+ //! \details AttachedTransformation() returns NULL if there is no attachment. The non-const
+ //! version of AttachedTransformation() always returns NULL.
virtual const BufferedTransformation *AttachedTransformation() const
{return const_cast(this)->AttachedTransformation();}
@@ -1877,7 +1928,6 @@ public:
//! \brief Add newAttachment to the end of attachment chain
//! \param newAttachment the attachment to add to the end of the chain
-
virtual void Attach(BufferedTransformation *newAttachment);
//@}
@@ -2035,37 +2085,41 @@ public:
};
//! \brief Interface for public keys
-
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PublicKey : virtual public CryptoMaterial
{
};
//! \brief Interface for private keys
-
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PrivateKey : public GeneratableCryptoMaterial
{
};
//! \brief Interface for crypto prameters
-
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CryptoParameters : public GeneratableCryptoMaterial
{
};
//! \brief Interface for asymmetric algorithms
-
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AsymmetricAlgorithm : public Algorithm
{
public:
- //! returns a reference to the crypto material used by this object
+ //! \brief Retrieves a reference to CryptoMaterial
+ //! \returns a reference to the crypto material used by this object
virtual CryptoMaterial & AccessMaterial() =0;
- //! returns a const reference to the crypto material used by this object
+
+ //! \brief Retrieves a reference to CryptoMaterial
+ //! \returns a const reference to the crypto material used by this object
virtual const CryptoMaterial & GetMaterial() const =0;
- //! for backwards compatibility, calls AccessMaterial().Load(bt)
+ //! \brief Loads this object from a BufferedTransformation
+ //! \param bt a BufferedTransformation object
+ //! \deprecated for backwards compatibility, calls AccessMaterial().Load(bt)
void BERDecode(BufferedTransformation &bt)
{AccessMaterial().Load(bt);}
- //! for backwards compatibility, calls GetMaterial().Save(bt)
+
+ //! \brief Saves this object to a BufferedTransformation
+ //! \param bt a BufferedTransformation object
+ //! \deprecated for backwards compatibility, calls GetMaterial().Save(bt)
void DEREncode(BufferedTransformation &bt) const
{GetMaterial().Save(bt);}
@@ -2075,16 +2129,18 @@ public:
};
//! \brief Interface for asymmetric algorithms using public keys
-
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PublicKeyAlgorithm : public AsymmetricAlgorithm
{
public:
// VC60 workaround: no co-variant return type
- CryptoMaterial & AccessMaterial() {return AccessPublicKey();}
- const CryptoMaterial & GetMaterial() const {return GetPublicKey();}
+ CryptoMaterial & AccessMaterial()
+ {return AccessPublicKey();}
+ const CryptoMaterial & GetMaterial() const
+ {return GetPublicKey();}
virtual PublicKey & AccessPublicKey() =0;
- virtual const PublicKey & GetPublicKey() const {return const_cast(this)->AccessPublicKey();}
+ virtual const PublicKey & GetPublicKey() const
+ {return const_cast(this)->AccessPublicKey();}
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~PublicKeyAlgorithm() {}
@@ -2092,7 +2148,6 @@ public:
};
//! \brief Interface for asymmetric algorithms using private keys
-
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PrivateKeyAlgorithm : public AsymmetricAlgorithm
{
public:
@@ -2108,7 +2163,6 @@ public:
};
//! \brief Interface for key agreement algorithms
-
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE KeyAgreementAlgorithm : public AsymmetricAlgorithm
{
public:
@@ -2124,33 +2178,41 @@ public:
};
//! \brief Interface for public-key encryptors and decryptors
-
-/*! This class provides an interface common to encryptors and decryptors
- for querying their plaintext and ciphertext lengths.
-*/
+//! \details This class provides an interface common to encryptors and decryptors
+//! for querying their plaintext and ciphertext lengths.
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_CryptoSystem
{
public:
virtual ~PK_CryptoSystem() {}
- //! maximum length of plaintext for a given ciphertext length
- /*! \note This function returns 0 if ciphertextLength is not valid (too long or too short). */
+ //! \brief Provides the maximum length of plaintext for a given ciphertext length
+ //! \returns the maximum size of the plaintext, in bytes
+ //! \details This function returns 0 if ciphertextLength is not valid (too long or too short).
virtual size_t MaxPlaintextLength(size_t ciphertextLength) const =0;
- //! calculate length of ciphertext given length of plaintext
- /*! \note This function returns 0 if plaintextLength is not valid (too long). */
+ //! \brief Calculate the length of ciphertext given length of plaintext
+ //! \returns the maximum size of the ciphertext, in bytes
+ //! \details This function returns 0 if plaintextLength is not valid (too long).
virtual size_t CiphertextLength(size_t plaintextLength) const =0;
- //! this object supports the use of the parameter with the given name
- /*! some possible parameter names: EncodingParameters, KeyDerivationParameters */
+ //! \brief Determines whether this object supports the use of a named parameter
+ //! \param name the name of the parameter
+ //! \returns true if the parameter name is supported, false otherwise
+ //! \details Some possible parameter names: EncodingParameters(), KeyDerivationParameters()
+ //! and others Parameters listed in argnames.h
virtual bool ParameterSupported(const char *name) const =0;
- //! return fixed ciphertext length, if one exists, otherwise return 0
- /*! \note "Fixed" here means length of ciphertext does not depend on length of plaintext.
- It usually does depend on the key length. */
+ //! \brief Provides the fixed ciphertext length, if one exists
+ //! \returns the fixed ciphertext length if one exists, otherwise 0
+ //! \details "Fixed" here means length of ciphertext does not depend on length of plaintext.
+ //! In this case, it usually does depend on the key length.
virtual size_t FixedCiphertextLength() const {return 0;}
- //! return maximum plaintext length given the fixed ciphertext length, if one exists, otherwise return 0
+ //! \brief Provides the maximum plaintext length given a fixed ciphertext length
+ //! \return maximum plaintext length given the fixed ciphertext length, if one exists,
+ //! otherwise return 0.
+ //! \details FixedMaxPlaintextLength(0 returns the maximum plaintext length given the fixed ciphertext
+ //! length, if one exists, otherwise return 0.
virtual size_t FixedMaxPlaintextLength() const {return 0;}
#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
@@ -2176,7 +2238,7 @@ public:
//! \param plaintext the plaintext byte buffer
//! \param plaintextLength the size of the plaintext byte buffer
//! \param ciphertext a byte buffer to hold the encrypted string
- //! \param parameters additional configuration options
+ //! \param parameters a set of NameValuePairs to initialize this object
//! \pre CiphertextLength(plaintextLength) != 0 ensures the plaintext isn't too large
//! \pre COUNTOF(ciphertext) == CiphertextLength(plaintextLength) ensures the output
//! byte buffer is large enough.
@@ -2186,9 +2248,12 @@ public:
byte *ciphertext, const NameValuePairs ¶meters = g_nullNameValuePairs) const =0;
//! \brief Create a new encryption filter
- //! \note The caller is responsible for deleting the returned pointer.
- //! \note Encoding parameters should be passed in the "EP" channel.
- virtual BufferedTransformation * CreateEncryptionFilter(RandomNumberGenerator &rng,
+ //! \param rng a RandomNumberGenerator derived class
+ //! \param attachment an attached transformation
+ //! \param parameters a set of NameValuePairs to initialize this object
+ //! \details \p attachment can be \p NULL. The caller is responsible for deleting the returned pointer.
+ //! Encoding parameters should be passed in the "EP" channel.
+ virtual BufferedTransformation * CreateEncryptionFilter(RandomNumberGenerator &rng,
BufferedTransformation *attachment=NULL, const NameValuePairs ¶meters = g_nullNameValuePairs) const;
};
@@ -2202,7 +2267,7 @@ public:
//! \param ciphertext the encrypted byte buffer
//! \param ciphertextLength the size of the encrypted byte buffer
//! \param plaintext a byte buffer to hold the decrypted string
- //! \param parameters additional configuration options
+ //! \param parameters a set of NameValuePairs to initialize this object
//! \returns the result of the decryption operation
//! \pre COUNTOF(plaintext) == MaxPlaintextLength(ciphertextLength) ensures the output
//! byte buffer is large enough
@@ -2236,22 +2301,26 @@ typedef PK_Encryptor PK_FixedLengthEncryptor;
typedef PK_Decryptor PK_FixedLengthDecryptor;
#endif
+//! \class PK_SignatureScheme
//! \brief Interface for public-key signers and verifiers
-
-/*! This class provides an interface common to signers and verifiers
- for querying scheme properties.
-*/
+//! \details This class provides an interface common to signers and verifiers for querying scheme properties
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_SignatureScheme
{
public:
- //! invalid key exception, may be thrown by any function in this class if the private or public key has a length that can't be used
+ //! \class InvalidKeyLength
+ //! \brief Exception throw when the private or public key has a length that can't be used
+ //! \details InvalidKeyLength() may be thrown by any function in this class if the private
+ //! or public key has a length that can't be used
class CRYPTOPP_DLL InvalidKeyLength : public Exception
{
public:
InvalidKeyLength(const std::string &message) : Exception(OTHER_ERROR, message) {}
};
- //! key too short exception, may be thrown by any function in this class if the private or public key is too short to sign or verify anything
+ //! \class KeyTooShort
+ //! \brief Exception throw when the private or public key is too short to sign or verify
+ //! \details KeyTooShort() may be thrown by any function in this class if the private or public
+ //! key is too short to sign or verify anything
class CRYPTOPP_DLL KeyTooShort : public InvalidKeyLength
{
public:
@@ -2260,37 +2329,60 @@ public:
virtual ~PK_SignatureScheme() {}
- //! signature length if it only depends on the key, otherwise 0
+ //! \brief Provides the signature length if it only depends on the key
+ //! \returns the signature length if it only depends on the key, in bytes
+ //! \details SignatureLength() returns the signature length if it only depends on the key, otherwise 0.
virtual size_t SignatureLength() const =0;
- //! maximum signature length produced for a given length of recoverable message part
+ //! \brief Provides the maximum signature length produced given the length of the recoverable message part
+ //! \param recoverablePartLength the length of the recoverable message part, in bytes
+ //! \returns the maximum signature length produced for a given length of recoverable message part, in bytes
+ //! \details MaxSignatureLength() returns the maximum signature length produced given the length of the
+ //! recoverable message part.
virtual size_t MaxSignatureLength(size_t recoverablePartLength = 0) const
{CRYPTOPP_UNUSED(recoverablePartLength); return SignatureLength();}
- //! length of longest message that can be recovered, or 0 if this signature scheme does not support message recovery
+ //! \brief Provides the length of longest message that can be recovered
+ //! \returns the length of longest message that can be recovered, in bytes
+ //! \details MaxRecoverableLength() returns the length of longest message that can be recovered, or 0 if
+ //! this signature scheme does not support message recovery.
virtual size_t MaxRecoverableLength() const =0;
- //! length of longest message that can be recovered from a signature of given length, or 0 if this signature scheme does not support message recovery
+ //! \brief Provides the length of longest message that can be recovered from a signature of given length
+ //! \param signatureLength the length of the signature, in bytes
+ //! \returns the length of longest message that can be recovered from a signature of given length, in bytes
+ //! \details MaxRecoverableLengthFromSignatureLength() returns the length of longest message that can be
+ //! recovered from a signature of given length, or 0 if this signature scheme does not support message
+ //! recovery.
virtual size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const =0;
- //! requires a random number generator to sign
- /*! if this returns false, NullRNG() can be passed to functions that take RandomNumberGenerator & */
+ //! \brief Determines whether a signature scheme requires a random number generator
+ //! \returns true if the signature scheme requires a RandomNumberGenerator() to sign
+ //! \details if IsProbabilistic() returns false, then NullRNG() can be passed to functions that take
+ //! RandomNumberGenerator().
virtual bool IsProbabilistic() const =0;
- //! whether or not a non-recoverable message part can be signed
+ //! \brief Determines whether the non-recoverable message part can be signed
+ //! \returns true if the non-recoverable message part can be signed
virtual bool AllowNonrecoverablePart() const =0;
- //! if this function returns true, during verification you must input the signature before the message, otherwise you can input it at anytime */
+ //! \brief Determines whether the signature must be input before the message
+ //! \returns true if the signature must be input before the message during verifcation
+ //! \details if SignatureUpfront() returns true, then you must input the signature before the message
+ //! during verification. Otherwise you can input the signature at anytime.
virtual bool SignatureUpfront() const {return false;}
- //! whether you must input the recoverable part before the non-recoverable part during signing
+ //! \brief Determines whether the recoverable part must be input before the non-recoverable part
+ //! \returns true if the recoverable part must be input before the non-recoverable part during signing
+ //! \details RecoverablePartFirst() determines whether you must input the recoverable part before the
+ //! non-recoverable part during signing
virtual bool RecoverablePartFirst() const =0;
};
+//! \class PK_MessageAccumulator
//! \brief Interface for accumulating messages to be signed or verified
-/*! Only Update() should be called
- on this class. No other functions inherited from HashTransformation should be called.
-*/
+//! \details Only Update() should be called from the PK_MessageAccumulator() class. No other functions
+//! inherited from HashTransformation, like DigestSize() and TruncatedFinal(), should be called.
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_MessageAccumulator : public HashTransformation
{
public:
@@ -2306,38 +2398,60 @@ public:
}
};
+//! \class PK_Signer
//! \brief Interface for public-key signers
-
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Signer : public PK_SignatureScheme, public PrivateKeyAlgorithm
{
public:
- //! create a new HashTransformation to accumulate the message to be signed
+ //! \brief Create a new HashTransformation to accumulate the message to be signed
+ //! \param rng a RandomNumberGenerator derived class
+ //! \returns a pointer to a PK_MessageAccumulator
+ //! \details NewSignatureAccumulator() can be used with all signing methods. Sign() will autimatically delete the
+ //! accumulator pointer. The caller is responsible for deletion if a methods is called that takes a reference.
virtual PK_MessageAccumulator * NewSignatureAccumulator(RandomNumberGenerator &rng) const =0;
+ //! \brief Input a recoverable message to an accumulator
+ //! \param messageAccumulator a reference to a PK_MessageAccumulator
+ //! \param recoverableMessage a pointer to the recoverable message part to be signed
+ //! \param recoverableMessageLength the size of the recoverable message part
virtual void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const =0;
- //! sign and delete messageAccumulator (even in case of exception thrown)
- /*! \pre size of signature == MaxSignatureLength()
- \returns actual signature length
- */
+ //! \brief Sign and delete the messageAccumulator
+ //! \param rng a RandomNumberGenerator derived class
+ //! \param messageAccumulator a pointer to a PK_MessageAccumulator derived class
+ //! \param signature a block of bytes for the signature
+ //! \returns actual signature length
+ //! \details Sign() deletes the messageAccumulator, even if an exception is thrown.
+ //! \pre size of signature == MaxSignatureLength()
virtual size_t Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const;
- //! sign and restart messageAccumulator
- /*! \pre size of signature == MaxSignatureLength()
- \returns actual signature length
- */
+ //! \brief Sign and restart messageAccumulator
+ //! \param rng a RandomNumberGenerator derived class
+ //! \param messageAccumulator a pointer to a PK_MessageAccumulator derived class
+ //! \param signature a block of bytes for the signature
+ //! \param restart flag indicating whether the messageAccumulator should be restarted
+ //! \returns actual signature length
+ //! \pre size of signature == MaxSignatureLength()
virtual size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart=true) const =0;
- //! sign a message
- /*! \pre size of signature == MaxSignatureLength()
- \returns actual signature length
- */
+ //! \brief Sign a message
+ //! \param rng a RandomNumberGenerator derived class
+ //! \param message a pointer to the message
+ //! \param messageLen the size of the message to be signed
+ //! \param signature a block of bytes for the signature
+ //! \returns actual signature length
+ //! \pre size of signature == MaxSignatureLength()
virtual size_t SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const;
- //! sign a recoverable message
- /*! \pre size of signature == MaxSignatureLength(recoverableMessageLength)
- \returns actual signature length
- */
+ //! \brief Sign a recoverable message
+ //! \param rng a RandomNumberGenerator derived class
+ //! \param recoverableMessage a pointer to the recoverable message part to be signed
+ //! \param recoverableMessageLength the size of the recoverable message part
+ //! \param nonrecoverableMessage a pointer to the non-recoverable message part to be signed
+ //! \param nonrecoverableMessageLength the size of the non-recoverable message part
+ //! \param signature a block of bytes for the signature
+ //! \pre size of signature == MaxSignatureLength(recoverableMessageLength)
+ //! \returns actual signature length
virtual size_t SignMessageWithRecovery(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength,
const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, byte *signature) const;
@@ -2346,13 +2460,13 @@ public:
#endif
};
+//! \class PK_Verifier
//! \brief Interface for public-key signature verifiers
-/*! The Recover* functions throw NotImplemented if the signature scheme does not support
- message recovery.
- The Verify* functions throw InvalidDataFormat if the scheme does support message
- recovery and the signature contains a non-empty recoverable message part. The
- Recovery* functions should be used in that case.
-*/
+//! \details The Recover* functions throw NotImplemented if the signature scheme does not support
+//! message recovery.
+//! \details The Verify* functions throw InvalidDataFormat if the scheme does support message
+//! recovery and the signature contains a non-empty recoverable message part. The
+//! Recovery* functions should be used in that case.
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Verifier : public PK_SignatureScheme, public PublicKeyAlgorithm
{
public:
@@ -2394,12 +2508,11 @@ public:
#endif
};
+//! \class SimpleKeyAgreementDomain
//! \brief Interface for domains of simple key agreement protocols
-
-/*! A key agreement domain is a set of parameters that must be shared
- by two parties in a key agreement protocol, along with the algorithms
- for generating key pairs and deriving agreed values.
-*/
+//! \details A key agreement domain is a set of parameters that must be shared
+//! by two parties in a key agreement protocol, along with the algorithms
+//! for generating key pairs and deriving agreed values.
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE SimpleKeyAgreementDomain : public KeyAgreementAlgorithm
{
public:
diff --git a/cryptopp-config.cmake b/cryptopp-config.cmake
new file mode 100644
index 00000000..b739501a
--- /dev/null
+++ b/cryptopp-config.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/cryptopp-targets.cmake")
diff --git a/des.h b/des.h
index 827b5e08..429d2e49 100644
--- a/des.h
+++ b/des.h
@@ -11,6 +11,8 @@
NAMESPACE_BEGIN(CryptoPP)
+//! \class RawDES
+//! \brief DES block cipher base class
class CRYPTOPP_DLL RawDES
{
public:
@@ -23,18 +25,20 @@ protected:
FixedSizeSecBlock k;
};
-//! _
+//! \class DES_Info
+//! \brief DES block cipher information
struct DES_Info : public FixedBlockSize<8>, public FixedKeyLength<8>
{
// disable DES in DLL version by not exporting this function
static const char * StaticAlgorithmName() {return "DES";}
};
-/// DES
-/*! The DES implementation in Crypto++ ignores the parity bits
- (the least significant bits of each byte) in the key. However
- you can use CheckKeyParityBits() and CorrectKeyParityBits() to
- check or correct the parity bits if you wish. */
+//! \class DES
+//! \brief DES block cipher
+//! \details The DES implementation in Crypto++ ignores the parity bits
+//! (the least significant bits of each byte) in the key. However you can use CheckKeyParityBits()
+//! and CorrectKeyParityBits() to check or correct the parity bits if you wish.
+//! \sa DES
class DES : public DES_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl, public RawDES
@@ -54,13 +58,16 @@ public:
typedef BlockCipherFinal Decryption;
};
-//! _
+//! \class DES_EDE2_Info
+//! \brief 2-key TripleDES block cipher information
struct DES_EDE2_Info : public FixedBlockSize<8>, public FixedKeyLength<16>
{
CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "DES-EDE2";}
};
-/// DES-EDE2
+//! \class DES_EDE2
+//! \brief 2-key TripleDES block cipher
+/// \sa DES-EDE2
class DES_EDE2 : public DES_EDE2_Info, public BlockCipherDocumentation
{
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
@@ -78,13 +85,16 @@ public:
typedef BlockCipherFinal Decryption;
};
-//! _
+//! \class DES_EDE3_Info
+//! \brief 3-key TripleDES block cipher information
struct DES_EDE3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
{
CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "DES-EDE3";}
};
-/// DES-EDE3
+//! \class DES_EDE3
+//! \brief 3-key TripleDES block cipher
+//! \sa DES-EDE3
class DES_EDE3 : public DES_EDE3_Info, public BlockCipherDocumentation
{
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
@@ -102,13 +112,16 @@ public:
typedef BlockCipherFinal Decryption;
};
-//! _
+//! \class DES_XEX3_Info
+//! \brief DESX block cipher information
struct DES_XEX3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
{
static const char *StaticAlgorithmName() {return "DES-XEX3";}
};
-/// DES-XEX3, AKA DESX
+//! \class DES_XEX3
+//! \brief DESX block cipher
+//! \sa DES-XEX3, AKA DESX
class DES_XEX3 : public DES_XEX3_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/dh.h b/dh.h
index fc23e9fb..64cb811b 100644
--- a/dh.h
+++ b/dh.h
@@ -9,6 +9,7 @@
#include "cryptlib.h"
#include "gfpcrypt.h"
+#include "algebra.h"
NAMESPACE_BEGIN(CryptoPP)
diff --git a/ec2n.h b/ec2n.h
index 826b2e43..f89fd7bd 100644
--- a/ec2n.h
+++ b/ec2n.h
@@ -11,6 +11,7 @@
#include "cryptlib.h"
#include "gf2n.h"
#include "integer.h"
+#include "algebra.h"
#include "eprecomp.h"
#include "smartptr.h"
#include "pubkey.h"
diff --git a/ecp.h b/ecp.h
index 6c3b44dc..29d40329 100644
--- a/ecp.h
+++ b/ecp.h
@@ -8,6 +8,7 @@
#include "cryptlib.h"
#include "integer.h"
+#include "algebra.h"
#include "modarith.h"
#include "eprecomp.h"
#include "smartptr.h"
diff --git a/eprecomp.cpp b/eprecomp.cpp
index ad6ea891..5161290a 100644
--- a/eprecomp.cpp
+++ b/eprecomp.cpp
@@ -6,6 +6,7 @@
#include "eprecomp.h"
#include "integer.h"
+#include "algebra.h"
#include "asn.h"
NAMESPACE_BEGIN(CryptoPP)
diff --git a/filters.h b/filters.h
index 7e5445d9..3f330aa1 100644
--- a/filters.h
+++ b/filters.h
@@ -1,14 +1,11 @@
// filters.h - written and placed in the public domain by Wei Dai
//! \file filters.h
-//! \brief Implementation of BufferedTransformation's attachment interface in cryptlib.h.
-//! \nosubgrouping
+//! \brief Implementation of BufferedTransformation's attachment interface.
#ifndef CRYPTOPP_FILTERS_H
#define CRYPTOPP_FILTERS_H
-//! \file
-
#include "cryptlib.h"
#if CRYPTOPP_MSC_VERSION
@@ -39,8 +36,12 @@ NAMESPACE_BEGIN(CryptoPP)
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Filter : public BufferedTransformation, public NotCopyable
{
public:
+
+ //! \name ATTACHMENT
+ //@{
+
//! \brief Construct a Filter
- //! \param attachment the filter's attached transformation
+ //! \param attachment an optional attached transformation
//! \details attachment can be \p NULL.
Filter(BufferedTransformation *attachment = NULL);
@@ -58,11 +59,13 @@ public:
const BufferedTransformation *AttachedTransformation() const;
//! \brief Replace an attached transformation
- //! \param newAttachment pointer to a new BufferedTransformation
- //! \details newAttachment cab ne a single filter, a chain of filters or \p NULL.
+ //! \param newAttachment an optional attached transformation
+ //! \details newAttachment can be a single filter, a chain of filters or \p NULL.
//! Pass \p NULL to remove an existing BufferedTransformation or chain of filters
void Detach(BufferedTransformation *newAttachment = NULL);
+ //@}
+
// See the documentation for BufferedTransformation in cryptlib.h
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true);
size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const;
@@ -92,8 +95,7 @@ protected:
//! \param messageEnd means how many filters to signal MessageEnd() to, including this one
//! \param blocking specifies whether the object should block when processing input
//! \param channel the channel to process the data
- //! \returns 0 indicates all bytes were processed during the call. Non-0 indicates the
- //! number of bytes that were \a not processed.
+ //! \returns the number of bytes that remain in the block (i.e., bytes not processed)
size_t Output(int outputSite, const byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel=DEFAULT_CHANNEL);
//! \brief Output multiple bytes that may be modified by callee.
@@ -103,8 +105,7 @@ protected:
//! \param messageEnd means how many filters to signal MessageEnd() to, including this one
//! \param blocking specifies whether the object should block when processing input
//! \param channel the channel to process the data
- //! \returns 0 indicates all bytes were processed during the call. Non-0 indicates the
- //! number of bytes that were \a not processed
+ //! \returns the number of bytes that remain in the block (i.e., bytes not processed)
size_t OutputModifiable(int outputSite, byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel=DEFAULT_CHANNEL);
//! \brief Signals the end of messages to the object
@@ -112,6 +113,7 @@ protected:
//! \param propagation the number of attached transformations the MessageEnd() signal should be passed
//! \param blocking specifies whether the object should block when processing input
//! \param channel the channel to process the data
+ //! \returns TODO
//! \details propagation count includes this object. Setting propagation to 1 means this
//! object only. Setting propagation to -1 means unlimited propagation.
bool OutputMessageEnd(int outputSite, int propagation, bool blocking, const std::string &channel=DEFAULT_CHANNEL);
@@ -122,6 +124,7 @@ protected:
//! \param propagation the number of attached transformations the Flush() signal should be passed
//! \param blocking specifies whether the object should block when processing input
//! \param channel the channel to process the data
+ //! \returns TODO
//! \details propagation count includes this object. Setting propagation to 1 means this
//! object only. Setting propagation to -1 means unlimited propagation.
//! \note Hard flushes must be used with care. It means try to process and output everything, even if
@@ -139,6 +142,7 @@ protected:
//! \param propagation the number of attached transformations the MessageSeriesEnd() signal should be passed
//! \param blocking specifies whether the object should block when processing input
//! \param channel the channel to process the data
+ //! \returns TODO
//! \details Each object that receives the signal will perform its processing, decrement
//! propagation, and then pass the signal on to attached transformations if the value is not 0.
//! \details propagation count includes this object. Setting propagation to 1 means this
@@ -154,11 +158,23 @@ protected:
int m_continueAt;
};
-//! \struct FilterPutSpaceHelper
-
+//! \class FilterPutSpaceHelper
+//! \brief Create a working space in a BufferedTransformation
struct CRYPTOPP_DLL FilterPutSpaceHelper
{
- // desiredSize is how much to ask target, bufferSize is how much to allocate in m_tempSpace
+ //! \brief Create a working space in a BufferedTransformation
+ //! \param target BufferedTransformation for the working space
+ //! \param channel channel for the working space
+ //! \param minSize minimum size of the allocation, in bytes
+ //! \param desiredSize preferred size of the allocation, in bytes
+ //! \param bufferSize actual size of the allocation, in bytes
+ //! \pre desiredSize >= minSize and bufferSize >= minSize.
+ //! \details \p bufferSize is an IN and OUT parameter. If HelpCreatePutSpace() returns a non-NULL value, then
+ //! bufferSize is valid and provides the size of the working space created for the caller.
+ //! \details Internally, HelpCreatePutSpace() calls \ref BufferedTransformation::ChannelCreatePutSpace
+ //! "ChannelCreatePutSpace()" using \p desiredSize. If the target returns \p desiredSize with a size less
+ //! than \p minSize (i.e., the request could not be fulfilled), then an internal SecByteBlock
+ //! called \p m_tempSpace is resized and used for the caller.
byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize)
{
assert(desiredSize >= minSize && bufferSize >= minSize);
@@ -176,25 +192,63 @@ struct CRYPTOPP_DLL FilterPutSpaceHelper
bufferSize = m_tempSpace.size();
return m_tempSpace.begin();
}
+
+ //! \brief Create a working space in a BufferedTransformation
+ //! \param target the BufferedTransformation for the working space
+ //! \param channel channel for the working space
+ //! \param minSize minimum size of the allocation, in bytes
+ //! \details Internally, the overload calls HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize) using \p minSize for missing arguments.
byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize)
{return HelpCreatePutSpace(target, channel, minSize, minSize, minSize);}
+
+ //! \brief Create a working space in a BufferedTransformation
+ //! \param target the BufferedTransformation for the working space
+ //! \param channel channel for the working space
+ //! \param minSize minimum size of the allocation, in bytes
+ //! \param bufferSize the actual size of the allocation, in bytes
+ //! \details Internally, the overload calls HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize) using \p minSize for missing arguments.
byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t bufferSize)
{return HelpCreatePutSpace(target, channel, minSize, minSize, bufferSize);}
+
+ //! \brief Temporay working space
SecByteBlock m_tempSpace;
};
-//! measure how many byte and messages pass through, also serves as valve
+//! \class MeterFilter
+//! \brief Measure how many bytes and messages pass through the filter
+//! \details measure how many bytes and messages pass through the filter. The filter also serves as valve by
+//! maintaining a list of ranges to skip during processing.
class CRYPTOPP_DLL MeterFilter : public Bufferless
{
public:
+ //! \brief Construct a MeterFilter
+ //! \param attachment an optional attached transformation
+ //! \param transparent flag indicating if the filter should function transparently
+ //! \details \p attachment can be \p NULL. The filter is transparent by default. If the filter is
+ //! transparent, then PutMaybeModifiable() does not process a request and always returns 0.
MeterFilter(BufferedTransformation *attachment=NULL, bool transparent=true)
: m_transparent(transparent), m_currentMessageBytes(0), m_totalBytes(0)
, m_currentSeriesMessages(0), m_totalMessages(0), m_totalMessageSeries(0)
, m_begin(NULL), m_length(0) {Detach(attachment); ResetMeter();}
+ //! \brief Set or change the transparent mode of this object
+ //! \param transparent the new transparent mode
void SetTransparent(bool transparent) {m_transparent = transparent;}
+
+ //! \brief Adds a range to skip during processing
+ //! \param message the message to apply the range
+ //! \param position the 0-based index in the current stream
+ //! \param size the length of the range
+ //! \param sortNow flag indicating whether the range should be sorted
+ //! \details Internally, MeterFilter maitains a deque of ranges to skip. As messages are processed,
+ //! ranges of bytes are skipped according to the list of ranges.
void AddRangeToSkip(unsigned int message, lword position, lword size, bool sortNow = true);
+
+ //! \brief Resets the meter
+ //! \details ResetMeter() reinitializes the meter by setting counters to 0 and removing previous
+ //! skip ranges.
void ResetMeter();
+
void IsolatedInitialize(const NameValuePairs ¶meters)
{CRYPTOPP_UNUSED(parameters); ResetMeter();}
@@ -230,25 +284,35 @@ private:
size_t m_length;
};
-//! _
+//! \class TransparentFilter
+//! \brief A transparent MeterFilter
+//! \sa MeterFilter, OpaqueFilter
class CRYPTOPP_DLL TransparentFilter : public MeterFilter
{
public:
+ //! \brief Construct a TransparentFilter
+ //! \param attachment an optional attached transformation
TransparentFilter(BufferedTransformation *attachment=NULL) : MeterFilter(attachment, true) {}
};
-//! _
+//! \class OpaqueFilter
+//! \brief A non-transparent MeterFilter
+//! \sa MeterFilter, TransparentFilter
class CRYPTOPP_DLL OpaqueFilter : public MeterFilter
{
public:
+ //! \brief Construct an OpaqueFilter
+ //! \param attachment an optional attached transformation
OpaqueFilter(BufferedTransformation *attachment=NULL) : MeterFilter(attachment, false) {}
};
-/*! FilterWithBufferedInput divides up the input stream into
- a first block, a number of middle blocks, and a last block.
- First and last blocks are optional, and middle blocks may
- be a stream instead (i.e. blockSize == 1).
-*/
+//! \class FilterWithBufferedInput
+//! \brief Divides an input stream into discrete blocks
+//! \details FilterWithBufferedInput divides the input stream into a first block, a number of
+//! middle blocks, and a last block. First and last blocks are optional, and middle blocks may
+//! be a stream instead (i.e. blockSize == 1).
+//! \sa AuthenticatedEncryptionFilter, AuthenticatedDecryptionFilter, HashVerificationFilter,
+//! SignatureVerificationFilter, StreamTransformationFilter
class CRYPTOPP_DLL FilterWithBufferedInput : public Filter
{
public:
@@ -258,9 +322,16 @@ public:
FilterWithBufferedInput();
#endif
- //! construct a FilterWithBufferedInput with an attached transformation
+ //! \brief Construct a FilterWithBufferedInput with an attached transformation
+ //! \param attachment an attached transformation
FilterWithBufferedInput(BufferedTransformation *attachment);
- //! firstSize and lastSize may be 0, blockSize must be at least 1
+
+ //! \brief Construct a FilterWithBufferedInput with an attached transformation
+ //! \param firstSize the size of the first block
+ //! \param blockSize the size of middle blocks
+ //! \param lastSize the size of the last block
+ //! \param attachment an attached transformation
+ //! \details \p firstSize and \p lastSize may be 0. \p blockSize must be at least 1.
FilterWithBufferedInput(size_t firstSize, size_t blockSize, size_t lastSize, BufferedTransformation *attachment);
void IsolatedInitialize(const NameValuePairs ¶meters);
@@ -341,10 +412,16 @@ protected:
BlockQueue m_queue;
};
-//! _
+//! \class FilterWithInputQueue
+//! \brief A filter that buffers input using a ByteQueue
+//! \details FilterWithInputQueue will buffer input using a ByteQueue. When the filter receives
+//! a \ref BufferedTransformation::MessageEnd() "MessageEnd()" signal it will pass the data
+//! on to its attached transformation.
class CRYPTOPP_DLL FilterWithInputQueue : public Filter
{
public:
+ //! \brief Construct a FilterWithInputQueue
+ //! \param attachment an optional attached transformation
FilterWithInputQueue(BufferedTransformation *attachment=NULL) : Filter(attachment) {}
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
@@ -370,11 +447,11 @@ protected:
};
//! \struct BlockPaddingSchemeDef
-//! \details Padding schemes used for block ciphers.
+//! \brief Padding schemes used for block ciphers
struct BlockPaddingSchemeDef
{
//! \enum BlockPaddingScheme
- //! \details Padding schemes used for block ciphers.
+ //! \brief Padding schemes used for block ciphers.
//! \details DEFAULT_PADDING means PKCS_PADDING if cipher.MandatoryBlockSize() > 1 &&
//! cipher.MinLastBlockSize() == 0, which holds for ECB or CBC mode. Otherwise,
//! NO_PADDING for modes like OFB, CFB, CTR, CBC-CTS.
@@ -389,15 +466,22 @@ struct BlockPaddingSchemeDef
PKCS_PADDING,
//! \brief 1 and 0's padding added to a block
ONE_AND_ZEROS_PADDING,
- //! \brief Default padding acheme
+ //! \brief Default padding scheme
DEFAULT_PADDING
};
};
-//! Filter Wrapper for StreamTransformation, optionally handling padding/unpadding when needed
+//! \class StreamTransformationFilter
+//! \brief Filter wrapper for StreamTransformation
+//! \details Filter wrapper for StreamTransformation. The filter will optionally handle padding/unpadding when needed
class CRYPTOPP_DLL StreamTransformationFilter : public FilterWithBufferedInput, public BlockPaddingSchemeDef, private FilterPutSpaceHelper
{
public:
+ //! \brief Construct a StreamTransformationFilter
+ //! \param c reference to a StreamTransformation
+ //! \param attachment an optional attached transformation
+ //! \param padding the \ref BlockPaddingSchemeDef "padding scheme"
+ //! \param allowAuthenticatedSymmetricCipher flag indicating whether the filter should allow authenticated encryption schemes
StreamTransformationFilter(StreamTransformation &c, BufferedTransformation *attachment = NULL, BlockPaddingScheme padding = DEFAULT_PADDING, bool allowAuthenticatedSymmetricCipher = false);
std::string AlgorithmName() const {return m_cipher.AlgorithmName();}
@@ -420,10 +504,18 @@ protected:
typedef StreamTransformationFilter StreamCipherFilter;
#endif
-//! Filter Wrapper for HashTransformation
+//! \class HashFilter
+//! \brief Filter wrapper for HashTransformation
class CRYPTOPP_DLL HashFilter : public Bufferless, private FilterPutSpaceHelper
{
public:
+ //! \brief Construct a HashFilter
+ //! \param hm reference to a HashTransformation
+ //! \param attachment an optional attached transformation
+ //! \param putMessage flag indicating whether the original message should be passed to an attached transformation
+ //! \param truncatedDigestSize the size of the digest
+ //! \param messagePutChannel the channel on which the message should be output
+ //! \param hashPutChannel the channel on which the digest should be output
HashFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, bool putMessage=false, int truncatedDigestSize=-1, const std::string &messagePutChannel=DEFAULT_CHANNEL, const std::string &hashPutChannel=DEFAULT_CHANNEL);
std::string AlgorithmName() const {return m_hashModule.AlgorithmName();}
@@ -439,10 +531,13 @@ private:
std::string m_messagePutChannel, m_hashPutChannel;
};
-//! Filter Wrapper for HashTransformation
+//! \class HashVerificationFilter
+//! \brief Filter wrapper for HashTransformation
class CRYPTOPP_DLL HashVerificationFilter : public FilterWithBufferedInput
{
public:
+ //! \class HashVerificationFailed
+ //! \brief Exception thrown when a data integrity check failure is encountered
class HashVerificationFailed : public Exception
{
public:
@@ -450,7 +545,32 @@ public:
: Exception(DATA_INTEGRITY_CHECK_FAILED, "HashVerificationFilter: message hash or MAC not valid") {}
};
- enum Flags {HASH_AT_END=0, HASH_AT_BEGIN=1, PUT_MESSAGE=2, PUT_HASH=4, PUT_RESULT=8, THROW_EXCEPTION=16, DEFAULT_FLAGS = HASH_AT_BEGIN | PUT_RESULT};
+ //! \enum Flags
+ //! \brief Flags controlling filter behavior.
+ //! \details The flags are a bitmask and can be OR'd together.
+ enum Flags {
+ //! \brief Indicates the hash is at the end of the message (i.e., concatenation of message+hash)
+ HASH_AT_END=0,
+ //! \brief Indicates the hash is at the beginning of the message (i.e., concatenation of hash+message)
+ HASH_AT_BEGIN=1,
+ //! \brief Indicates the message should be passed to an attached transformation
+ PUT_MESSAGE=2,
+ //! \brief Indicates the hash should be passed to an attached transformation
+ PUT_HASH=4,
+ //! \brief Indicates the result of the verification should be passed to an attached transformation
+ PUT_RESULT=8,
+ //! \brief Indicates the filter should throw a HashVerificationFailed if a failure is encountered
+ THROW_EXCEPTION=16,
+ //! \brief Default flags using \p HASH_AT_BEGIN and \p PUT_RESULT
+ DEFAULT_FLAGS = HASH_AT_BEGIN | PUT_RESULT
+ };
+
+ //! \brief Construct a HashVerificationFilter
+ //! \param hm reference to a HashTransformation
+ //! \param attachment an optional attached transformation
+ //! \param flags flags indicating behaviors for the filter
+ //! \param truncatedDigestSize the size of the digest
+ //! \details truncatedDigestSize = -1 indicates \ref HashTransformation::DigestSize() "DigestSize" should be used.
HashVerificationFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1);
std::string AlgorithmName() const {return m_hashModule.AlgorithmName();}
@@ -474,12 +594,20 @@ private:
typedef HashVerificationFilter HashVerifier; // for backwards compatibility
-//! Filter wrapper for encrypting with AuthenticatedSymmetricCipher, optionally handling padding/unpadding when needed
-/*! Additional authenticated data should be given in channel "AAD". If putAAD is true, AAD will be Put() to the attached BufferedTransformation in channel "AAD". */
+//! \class AuthenticatedEncryptionFilter
+//! \brief Filter wrapper for encrypting with AuthenticatedSymmetricCipher
+//! \details Filter wrapper for encrypting with AuthenticatedSymmetricCipher, optionally handling padding/unpadding when needed
class CRYPTOPP_DLL AuthenticatedEncryptionFilter : public StreamTransformationFilter
{
public:
- /*! See StreamTransformationFilter for documentation on BlockPaddingScheme */
+ //! \brief Construct a AuthenticatedEncryptionFilter
+ //! \param c reference to a AuthenticatedSymmetricCipher
+ //! \param attachment an optional attached transformation
+ //! \param putAAD flag indicating whether the AAD should be passed to an attached transformation
+ //! \param truncatedDigestSize the size of the digest
+ //! \param macChannel the channel on which the MAC should be output
+ //! \param padding the \ref BlockPaddingSchemeDef "padding scheme"
+ //! \details truncatedDigestSize = -1 indicates \ref HashTransformation::DigestSize() "DigestSize" should be used.
AuthenticatedEncryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULL, bool putAAD=false, int truncatedDigestSize=-1, const std::string &macChannel=DEFAULT_CHANNEL, BlockPaddingScheme padding = DEFAULT_PADDING);
void IsolatedInitialize(const NameValuePairs ¶meters);
@@ -491,14 +619,34 @@ protected:
HashFilter m_hf;
};
-//! Filter wrapper for decrypting with AuthenticatedSymmetricCipher, optionally handling padding/unpadding when needed
-/*! Additional authenticated data should be given in channel "AAD". */
+//! \class AuthenticatedDecryptionFilter
+//! \brief Filter wrapper for decrypting with AuthenticatedSymmetricCipher
+//! \details Filter wrapper wrapper for decrypting with AuthenticatedSymmetricCipher, optionally handling padding/unpadding when needed.
class CRYPTOPP_DLL AuthenticatedDecryptionFilter : public FilterWithBufferedInput, public BlockPaddingSchemeDef
{
public:
- enum Flags {MAC_AT_END=0, MAC_AT_BEGIN=1, THROW_EXCEPTION=16, DEFAULT_FLAGS = THROW_EXCEPTION};
+ //! \enum Flags
+ //! \brief Flags controlling filter behavior.
+ //! \details The flags are a bitmask and can be OR'd together.
+ enum Flags {
+ //! \brief Indicates the MAC is at the end of the message (i.e., concatenation of message+mac)
+ MAC_AT_END=0,
+ //! \brief Indicates the MAC is at the beginning of the message (i.e., concatenation of mac+message)
+ MAC_AT_BEGIN=1,
+ //! \brief Indicates the filter should throw a HashVerificationFailed if a failure is encountered
+ THROW_EXCEPTION=16,
+ //! \brief Default flags using \p THROW_EXCEPTION
+ DEFAULT_FLAGS = THROW_EXCEPTION
+ };
- /*! See StreamTransformationFilter for documentation on BlockPaddingScheme */
+ //! \brief Construct a AuthenticatedDecryptionFilter
+ //! \param c reference to a AuthenticatedSymmetricCipher
+ //! \param attachment an optional attached transformation
+ //! \param flags flags indicating behaviors for the filter
+ //! \param truncatedDigestSize the size of the digest
+ //! \param padding the \ref BlockPaddingSchemeDef "padding scheme"
+ //! \details Additional authenticated data should be given in channel "AAD".
+ //! \details truncatedDigestSize = -1 indicates \ref HashTransformation::DigestSize() "DigestSize" should be used.
AuthenticatedDecryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1, BlockPaddingScheme padding = DEFAULT_PADDING);
std::string AlgorithmName() const {return m_hashVerifier.AlgorithmName();}
@@ -516,10 +664,16 @@ protected:
StreamTransformationFilter m_streamFilter;
};
-//! Filter Wrapper for PK_Signer
+//! \class SignerFilter
+//! \brief Filter wrapper for PK_Signer
class CRYPTOPP_DLL SignerFilter : public Unflushable
{
public:
+ //! \brief Construct a SignerFilter
+ //! \param rng a RandomNumberGenerator derived class
+ //! \param signer a PK_Signer derived class
+ //! \param attachment an optional attached transformation
+ //! \param putMessage flag indicating whether the original message should be passed to an attached transformation
SignerFilter(RandomNumberGenerator &rng, const PK_Signer &signer, BufferedTransformation *attachment = NULL, bool putMessage=false)
: m_rng(rng), m_signer(signer), m_messageAccumulator(signer.NewSignatureAccumulator(rng)), m_putMessage(putMessage) {Detach(attachment);}
@@ -536,10 +690,12 @@ private:
SecByteBlock m_buf;
};
-//! Filter Wrapper for PK_Verifier
+//! \class SignatureVerificationFilter
+//! \brief Filter wrapper for PK_Verifier
class CRYPTOPP_DLL SignatureVerificationFilter : public FilterWithBufferedInput
{
public:
+ //! \brief Exception thrown when an invalid signature is encountered
class SignatureVerificationFailed : public Exception
{
public:
@@ -547,11 +703,36 @@ public:
: Exception(DATA_INTEGRITY_CHECK_FAILED, "VerifierFilter: digital signature not valid") {}
};
- enum Flags {SIGNATURE_AT_END=0, SIGNATURE_AT_BEGIN=1, PUT_MESSAGE=2, PUT_SIGNATURE=4, PUT_RESULT=8, THROW_EXCEPTION=16, DEFAULT_FLAGS = SIGNATURE_AT_BEGIN | PUT_RESULT};
+ //! \enum Flags
+ //! \brief Flags controlling filter behavior.
+ //! \details The flags are a bitmask and can be OR'd together.
+ enum Flags {
+ //! \brief Indicates the signature is at the end of the message (i.e., concatenation of message+signature)
+ SIGNATURE_AT_END=0,
+ //! \brief Indicates the signature is at the beginning of the message (i.e., concatenation of signature+message)
+ SIGNATURE_AT_BEGIN=1,
+ //! \brief Indicates the message should be passed to an attached transformation
+ PUT_MESSAGE=2,
+ //! \brief Indicates the signature should be passed to an attached transformation
+ PUT_SIGNATURE=4,
+ //! \brief Indicates the result of the verification should be passed to an attached transformation
+ PUT_RESULT=8,
+ //! \brief Indicates the filter should throw a HashVerificationFailed if a failure is encountered
+ THROW_EXCEPTION=16,
+ //! \brief Default flags using \p SIGNATURE_AT_BEGIN and \p PUT_RESULT
+ DEFAULT_FLAGS = SIGNATURE_AT_BEGIN | PUT_RESULT
+ };
+
+ //! \brief Construct a SignatureVerificationFilter
+ //! \param verifier a PK_Verifier derived class
+ //! \param attachment an optional attached transformation
+ //! \param flags flags indicating behaviors for the filter
SignatureVerificationFilter(const PK_Verifier &verifier, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS);
std::string AlgorithmName() const {return m_verifier.AlgorithmName();}
+ //! \brief Retrieves the result of the last verification
+ //! \returns true if the signature on the previosus message was valid, false otherwise
bool GetLastResult() const {return m_verified;}
protected:
@@ -570,10 +751,12 @@ private:
typedef SignatureVerificationFilter VerifierFilter; // for backwards compatibility
-//! Redirect input to another BufferedTransformation without owning it
+//! \class Redirector
+//! \brief Redirect input to another BufferedTransformation without owning it
class CRYPTOPP_DLL Redirector : public CustomSignalPropagation
{
public:
+ //! \enum Behavior
//! \brief Controls signal propagation behavior
enum Behavior
{
@@ -588,11 +771,19 @@ public:
PASS_EVERYTHING = PASS_SIGNALS | PASS_WAIT_OBJECTS
};
+ //! \brief Construct a Redirector
Redirector() : m_target(NULL), m_behavior(PASS_EVERYTHING) {}
+
+ //! \brief Construct a Redirector
+ //! \param target the destination BufferedTransformation
+ //! \param behavior \ref Behavior "flags" specifying signal propagation
Redirector(BufferedTransformation &target, Behavior behavior=PASS_EVERYTHING)
: m_target(&target), m_behavior(behavior) {}
+ //! \brief Redirect input to another BufferedTransformation
+ //! \param target the destination BufferedTransformation
void Redirect(BufferedTransformation &target) {m_target = ⌖}
+ //! \brief Stop redirecting input
void StopRedirection() {m_target = NULL;}
Behavior GetBehavior() {return (Behavior) m_behavior;}
@@ -674,14 +865,22 @@ private:
bool m_passSignal;
};
-//! Base class for Filter classes that are proxies for a chain of other filters.
+//! \class ProxyFilter
+//! \brief Base class for Filter classes that are proxies for a chain of other filters
class CRYPTOPP_DLL ProxyFilter : public FilterWithBufferedInput
{
public:
+ //! \brief Construct a ProxyFilter
+ //! \param filter an output filter
+ //! \param firstSize the first Put size
+ //! \param lastSize the last Put size
+ //! \param attachment an attached transformation
ProxyFilter(BufferedTransformation *filter, size_t firstSize, size_t lastSize, BufferedTransformation *attachment);
bool IsolatedFlush(bool hardFlush, bool blocking);
+ //! \brief Sets the OutputProxy filter
+ //! \param filter an OutputProxy filter
void SetFilter(Filter *filter);
void NextPutMultiple(const byte *s, size_t len);
void NextPutModifiable(byte *inString, size_t length);
@@ -690,36 +889,57 @@ protected:
member_ptr m_filter;
};
-//! simple proxy filter that doesn't modify the underlying filter's input or output
+//! \class SimpleProxyFilter
+//! \brief Proxy filter that doesn't modify the underlying filter's input or output
class CRYPTOPP_DLL SimpleProxyFilter : public ProxyFilter
{
public:
+ //! \brief Construct a SimpleProxyFilter
+ //! \param filter an output filter
+ //! \param attachment an attached transformation
SimpleProxyFilter(BufferedTransformation *filter, BufferedTransformation *attachment)
: ProxyFilter(filter, 0, 0, attachment) {}
- void FirstPut(const byte *) {}
- void LastPut(const byte *, size_t) {m_filter->MessageEnd();}
+ void FirstPut(const byte * inString)
+ {CRYPTOPP_UNUSED(inString);}
+ void LastPut(const byte *inString, size_t length)
+ {CRYPTOPP_UNUSED(inString), CRYPTOPP_UNUSED(length); m_filter->MessageEnd();}
};
-//! proxy for the filter created by PK_Encryptor::CreateEncryptionFilter
-/*! This class is here just to provide symmetry with VerifierFilter. */
+//! \class PK_EncryptorFilter
+//! \brief Filter wrapper for PK_Encryptor
+//! \details PK_DecryptorFilter is a proxy for the filter created by PK_Encryptor::CreateEncryptionFilter.
+//! This class provides symmetry with VerifierFilter.
class CRYPTOPP_DLL PK_EncryptorFilter : public SimpleProxyFilter
{
public:
+ //! \brief Construct a PK_EncryptorFilter
+ //! \param rng a RandomNumberGenerator derived class
+ //! \param encryptor a PK_Encryptor derived class
+ //! \param attachment an optional attached transformation
PK_EncryptorFilter(RandomNumberGenerator &rng, const PK_Encryptor &encryptor, BufferedTransformation *attachment = NULL)
: SimpleProxyFilter(encryptor.CreateEncryptionFilter(rng), attachment) {}
};
-//! proxy for the filter created by PK_Decryptor::CreateDecryptionFilter
-/*! This class is here just to provide symmetry with SignerFilter. */
+//! \class PK_DecryptorFilter
+//! \brief Filter wrapper for PK_Decryptor
+//! \details PK_DecryptorFilter is a proxy for the filter created by PK_Decryptor::CreateDecryptionFilter.
+//! This class provides symmetry with SignerFilter.
class CRYPTOPP_DLL PK_DecryptorFilter : public SimpleProxyFilter
{
public:
+ //! \brief Construct a PK_DecryptorFilter
+ //! \param rng a RandomNumberGenerator derived class
+ //! \param decryptor a PK_Decryptor derived class
+ //! \param attachment an optional attached transformation
PK_DecryptorFilter(RandomNumberGenerator &rng, const PK_Decryptor &decryptor, BufferedTransformation *attachment = NULL)
: SimpleProxyFilter(decryptor.CreateDecryptionFilter(rng), attachment) {}
};
-//! Append input to a string object
+//! \class StringSinkTemplate
+//! \brief Append input to a string object
+//! \tparam T std::basic_string type
+//! \details \ref StringSinkTemplate "StringSink" is a StringSinkTemplate typedef
template
class StringSinkTemplate : public Bufferless
{
@@ -727,6 +947,8 @@ public:
// VC60 workaround: no T::char_type
typedef typename T::traits_type::char_type char_type;
+ //! \brief Construct a StringSinkTemplate
+ //! \param output std::basic_string type
StringSinkTemplate(T &output)
: m_output(&output) {assert(sizeof(output[0])==1);}
@@ -741,7 +963,7 @@ public:
typename T::size_type size = m_output->size();
if (length < size && size + length > m_output->capacity())
m_output->reserve(2*size);
- m_output->append((const char_type *)inString, (const char_type *)inString+length);
+ m_output->append((const char_type *)inString, (const char_type *)inString+length);
}
return 0;
}
@@ -750,17 +972,20 @@ private:
T *m_output;
};
-//! Append input to an std::string
CRYPTOPP_DLL_TEMPLATE_CLASS StringSinkTemplate;
-typedef StringSinkTemplate StringSink;
+DOCUMENTED_TYPEDEF(StringSinkTemplate, StringSink);
-//! incorporates input into RNG as additional entropy
+//! \class RandomNumberSink
+//! \brief Incorporates input into RNG as additional entropy
class RandomNumberSink : public Bufferless
{
public:
+ //! \brief Construct a RandomNumberSink
RandomNumberSink()
: m_rng(NULL) {}
+ //! \brief Construct a RandomNumberSink
+ //! \param rng a RandomNumberGenerator derived class
RandomNumberSink(RandomNumberGenerator &rng)
: m_rng(&rng) {}
@@ -771,12 +996,20 @@ private:
RandomNumberGenerator *m_rng;
};
-//! Copy input to a memory buffer
+//! \class ArraySink
+//! \brief Copy input to a memory buffer
class CRYPTOPP_DLL ArraySink : public Bufferless
{
public:
+ //! \brief Construct an ArraySink
+ //! \param parameters a set of NameValuePairs to initialize this object
+ //! \details Name::OutputBuffer() is a mandatory parameter using this constructor.
ArraySink(const NameValuePairs ¶meters = g_nullNameValuePairs)
: m_buf(NULL), m_size(0), m_total(0) {IsolatedInitialize(parameters);}
+
+ //! \brief Construct an ArraySink
+ //! \param buf pointer to a memory buffer
+ //! \param size length of the memory buffer
ArraySink(byte *buf, size_t size)
: m_buf(buf), m_size(size), m_total(0) {}
@@ -793,10 +1026,14 @@ protected:
lword m_total;
};
-//! Xor input to a memory buffer
+//! \class ArrayXorSink
+//! \brief Xor input to a memory buffer
class CRYPTOPP_DLL ArrayXorSink : public ArraySink
{
public:
+ //! \brief Construct an ArrayXorSink
+ //! \param buf pointer to a memory buffer
+ //! \param size length of the memory buffer
ArrayXorSink(byte *buf, size_t size)
: ArraySink(buf, size) {}
@@ -804,14 +1041,25 @@ public:
byte * CreatePutSpace(size_t &size) {return BufferedTransformation::CreatePutSpace(size);}
};
-//! string-based implementation of Store interface
+//! \class StringStore
+//! \brief String-based implementation of Store interface
class StringStore : public Store
{
public:
+ //! \brief Construct a StringStore
+ //! \param string pointer to a C-String
StringStore(const char *string = NULL)
{StoreInitialize(MakeParameters("InputBuffer", ConstByteArrayParameter(string)));}
+
+ //! \brief Construct a StringStore
+ //! \param string pointer to a memory buffer
+ //! \param length size of the memory buffer
StringStore(const byte *string, size_t length)
{StoreInitialize(MakeParameters("InputBuffer", ConstByteArrayParameter(string, length)));}
+
+ //! \brief Construct a StringStore
+ //! \tparam T std::basic_string type
+ //! \param string reference to a std::basic_string type
template StringStore(const T &string)
{StoreInitialize(MakeParameters("InputBuffer", ConstByteArrayParameter(string)));}
@@ -880,21 +1128,57 @@ private:
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Source : public InputRejecting
{
public:
+ //! \brief Construct a Source
+ //! \param attachment an optional attached transformation
Source(BufferedTransformation *attachment = NULL)
{Source::Detach(attachment);}
//! \name PIPELINE
//@{
-
+
+ //! \brief Pump data to attached transformation
+ //! \param pumpMax the maximpum number of bytes to pump
+ //! \returns the number of bytes that remain in the block (i.e., bytes not processed)
+ //! \details Internally, Pump() calls Pump2().
+ //! \note pumpMax is a \p lword, which is a 64-bit value that typically uses \p LWORD_MAX. The default
+ //! argument is a \p size_t that uses \p SIZE_MAX, and it can be 32-bits or 64-bits.
lword Pump(lword pumpMax=size_t(SIZE_MAX))
{Pump2(pumpMax); return pumpMax;}
+
+ //! \brief Pump messages to attached transformation
+ //! \param count the maximpum number of messages to pump
+ //! \returns TODO
+ //! \details Internally, PumpMessages() calls PumpMessages2().
unsigned int PumpMessages(unsigned int count=UINT_MAX)
{PumpMessages2(count); return count;}
+
+ //! \brief Pump all data to attached transformation
+ //! \details Internally, PumpAll() calls PumpAll2().
void PumpAll()
{PumpAll2();}
+
+ //! \brief Pump data to attached transformation
+ //! \param byteCount the maximpum number of bytes to pump
+ //! \param blocking specifies whether the object should block when processing input
+ //! \returns the number of bytes that remain in the block (i.e., bytes not processed)
+ //! \details byteCount is an \a IN and \a OUT parameter. When the call is made, byteCount is the
+ //! requested size of the pump. When the call returns, byteCount is the number of bytes that
+ //! were pumped.
virtual size_t Pump2(lword &byteCount, bool blocking=true) =0;
+
+ //! \brief Pump messages to attached transformation
+ //! \param messageCount the maximpum number of messages to pump
+ //! \param blocking specifies whether the object should block when processing input
+ //! \details messageCount is an IN and OUT parameter.
virtual size_t PumpMessages2(unsigned int &messageCount, bool blocking=true) =0;
+
+ //! \brief Pump all data to attached transformation
+ //! \param blocking specifies whether the object should block when processing input
+ //! \returns the number of bytes that remain in the block (i.e., bytes not processed)
virtual size_t PumpAll2(bool blocking=true);
+
+ //! \brief Determines if the Source is exhausted
+ //! \returns true if the source has been exhausted
virtual bool SourceExhausted() const =0;
//@}
@@ -919,6 +1203,9 @@ template
class SourceTemplate : public Source
{
public:
+ //! \brief Construct a SourceTemplate
+ //! \tparam T the class or type
+ //! \param attachment an attached transformation
SourceTemplate(BufferedTransformation *attachment)
: Source(attachment) {}
void IsolatedInitialize(const NameValuePairs ¶meters)
@@ -945,9 +1232,15 @@ protected:
class CRYPTOPP_DLL StringSource : public SourceTemplate
{
public:
+ //! \brief Construct a StringSource
+ //! \param attachment an optional attached transformation
StringSource(BufferedTransformation *attachment = NULL)
: SourceTemplate(attachment) {}
- //! zero terminated string as source
+
+ //! \brief Construct a StringSource
+ //! \param string C-String
+ //! \param pumpAll C-String
+ //! \param attachment an optional attached transformation
StringSource(const char *string, bool pumpAll, BufferedTransformation *attachment = NULL)
: SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string)));}
//! binary byte array as source
@@ -958,8 +1251,8 @@ public:
: SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string)));}
};
-//! use the third constructor for an array source
-typedef StringSource ArraySource;
+// Use the third constructor for an array source
+DOCUMENTED_TYPEDEF(StringSource, ArraySource);
//! RNG-based implementation of Source interface
class CRYPTOPP_DLL RandomNumberSource : public SourceTemplate
diff --git a/gcm.cpp b/gcm.cpp
index 9f401c88..e74c7408 100644
--- a/gcm.cpp
+++ b/gcm.cpp
@@ -12,6 +12,17 @@
#ifndef CRYPTOPP_IMPORTS
#ifndef CRYPTOPP_GENERATE_X64_MASM
+// Clang 3.3 integrated assembler crash on Linux
+#if defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400)
+# undef CRYPTOPP_X86_ASM_AVAILABLE
+# undef CRYPTOPP_X32_ASM_AVAILABLE
+# undef CRYPTOPP_X64_ASM_AVAILABLE
+# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
+# undef CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE
+# define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
+# define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
+#endif
+
#include "gcm.h"
#include "cpu.h"
@@ -686,7 +697,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
AS2( psrldq xmm0, 15 )
#if (CRYPTOPP_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
AS2( movd edi, xmm0 )
-#elif defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)
+#elif (defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE)
AS2( mov WORD_REG(di), xmm0 )
#else // GNU Assembler
AS2( movd WORD_REG(di), xmm0 )
@@ -701,7 +712,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
AS2( psrldq xmm1, 15 )
#if (CRYPTOPP_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
AS2( movd edi, xmm1 )
-#elif defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)
+#elif (defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE)
AS2( mov WORD_REG(di), xmm1 )
#else
AS2( movd WORD_REG(di), xmm1 )
@@ -712,7 +723,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
AS2( psrldq xmm0, 15 )
#if (CRYPTOPP_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
AS2( movd edi, xmm0 )
-#elif defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)
+#elif (defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE)
AS2( mov WORD_REG(di), xmm0 )
#else
AS2( movd WORD_REG(di), xmm0 )
@@ -724,7 +735,9 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
AS2( add WORD_REG(cx), 16 )
AS2( sub WORD_REG(dx), 1 )
+ ATT_NOPREFIX
ASJ( jnz, 0, b )
+ INTEL_NOPREFIX
AS2( movdqa [WORD_REG(si)], xmm0 )
#if CRYPTOPP_BOOL_X32
@@ -807,10 +820,12 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
SSE2_MUL_32BITS(2)
SSE2_MUL_32BITS(3)
- AS2( add WORD_REG(cx), 16 )
- AS2( sub WORD_REG(dx), 1 )
- ASJ( jnz, 1, b )
- AS2( movdqa [WORD_REG(si)], xmm0 )
+ AS2( add WORD_REG(cx), 16 )
+ AS2( sub WORD_REG(dx), 1 )
+ ATT_NOPREFIX
+ ASJ( jnz, 1, b )
+ INTEL_NOPREFIX
+ AS2( movdqa [WORD_REG(si)], xmm0 )
#ifdef __GNUC__
ATT_PREFIX
diff --git a/gost.h b/gost.h
index 6ef844e4..12dbb344 100644
--- a/gost.h
+++ b/gost.h
@@ -11,13 +11,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class GOST_Info
+//! \brief GOST block cipher information
struct GOST_Info : public FixedBlockSize<8>, public FixedKeyLength<32>
{
static const char *StaticAlgorithmName() {return "GOST";}
};
-/// GOST
+//! \class GOST
+//! \brief GOST block cipher
+//! \sa GOST
class GOST : public GOST_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/hmac.h b/hmac.h
index d46626d4..f6c1499a 100644
--- a/hmac.h
+++ b/hmac.h
@@ -1,6 +1,6 @@
// hmac.h - written and placed in the public domain by Wei Dai
-//! \file
+//! \file hmac.h
//! \brief Classes for HMAC message authentication codes
#ifndef CRYPTOPP_HMAC_H
@@ -11,10 +11,13 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class HMAC_Base
+//! \brief HMAC information
+//! \details HMAC_Base derives from VariableKeyLength and MessageAuthenticationCode
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE HMAC_Base : public VariableKeyLength<16, 0, INT_MAX>, public MessageAuthenticationCode
{
public:
+ //! \brief Construct a HMAC_Base
HMAC_Base() : m_innerHashKeyed(false) {}
void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs ¶ms);
@@ -37,8 +40,12 @@ private:
bool m_innerHashKeyed;
};
-//! HMAC
-/*! HMAC(K, text) = H(K XOR opad, H(K XOR ipad, text)) */
+//! \class HMAC
+//! \brief HMAC
+//! \tparam T HashTransformation derived class
+//! \details HMAC derives from MessageAuthenticationCodeImpl. It calculates the HMAC using
+//! HMAC(K, text) = H(K XOR opad, H(K XOR ipad, text)).
+//! \sa HMAC
template
class HMAC : public MessageAuthenticationCodeImpl >
{
@@ -46,7 +53,11 @@ public:
CRYPTOPP_CONSTANT(DIGESTSIZE=T::DIGESTSIZE)
CRYPTOPP_CONSTANT(BLOCKSIZE=T::BLOCKSIZE)
+ //! \brief Construct a HMAC
HMAC() {}
+ //! \brief Construct a HMAC
+ //! \param key the HMAC key
+ //! \param length the size of the HMAC key
HMAC(const byte *key, size_t length=HMAC_Base::DEFAULT_KEYLENGTH)
{this->SetKey(key, length);}
diff --git a/idea.h b/idea.h
index 897de889..a2b50673 100644
--- a/idea.h
+++ b/idea.h
@@ -11,13 +11,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class IDEA_Info
+//! \brief IDEA block cipher information
struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8>
{
static const char *StaticAlgorithmName() {return "IDEA";}
};
-/// IDEA
+//! \class IDEA
+//! \brief IDEA block cipher
+//! \sa IDEA
class IDEA : public IDEA_Info, public BlockCipherDocumentation
{
public: // made public for internal purposes
diff --git a/integer.cpp b/integer.cpp
index e50f3714..229a1d37 100644
--- a/integer.cpp
+++ b/integer.cpp
@@ -32,7 +32,7 @@
#include
-#if _MSC_VER >= 1400
+#if (_MSC_VER >= 1400) && !defined(_M_ARM)
#include
#endif
@@ -186,7 +186,7 @@ static word AtomicInverseModPower2(word A)
#define GetBorrow(u) u##1
#else
#define Declare2Words(x) dword x;
- #if _MSC_VER >= 1400 && !defined(__INTEL_COMPILER)
+ #if _MSC_VER >= 1400 && !defined(__INTEL_COMPILER) && !defined(_M_ARM)
#define MultiplyWords(p, a, b) p = __emulu(a, b);
#else
#define MultiplyWords(p, a, b) p = (dword)a*b;
diff --git a/lubyrack.h b/lubyrack.h
index 1c9c62da..ad301bd6 100644
--- a/lubyrack.h
+++ b/lubyrack.h
@@ -16,14 +16,16 @@ template struct DigestSizeDoubleWorkaround // VC60 workaround
CRYPTOPP_CONSTANT(RESULT = 2*T::DIGESTSIZE)
};
-//! algorithm info
+//! \class LR_Info
+//! \brief Luby-Rackoff block cipher information
template
struct LR_Info : public VariableKeyLength<16, 0, 2*(INT_MAX/2), 2>, public FixedBlockSize::RESULT>
{
static std::string StaticAlgorithmName() {return std::string("LR/")+T::StaticAlgorithmName();}
};
-//! Luby-Rackoff
+//! \class LR
+//! \brief Luby-Rackoff block cipher
template
class LR : public LR_Info, public BlockCipherDocumentation
{
diff --git a/luc.h b/luc.h
index bfd37597..bd04dee5 100644
--- a/luc.h
+++ b/luc.h
@@ -7,6 +7,7 @@
#include "cryptlib.h"
#include "gfpcrypt.h"
#include "integer.h"
+#include "algebra.h"
#include "secblock.h"
#if CRYPTOPP_MSC_VERSION
diff --git a/mars.h b/mars.h
index c4c7fd93..3a59c1e8 100644
--- a/mars.h
+++ b/mars.h
@@ -11,13 +11,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class MARS_Info
+//! \brief MARS block cipher information
struct MARS_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 56, 4>
{
static const char *StaticAlgorithmName() {return "MARS";}
};
-/// MARS
+//! \class MARS
+//! \brief MARS block cipher
+//! \sa MARS
class MARS : public MARS_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/modexppc.h b/modexppc.h
index ebfcf6f0..a1a0a9c7 100644
--- a/modexppc.h
+++ b/modexppc.h
@@ -4,6 +4,7 @@
#include "cryptlib.h"
#include "modarith.h"
#include "integer.h"
+#include "algebra.h"
#include "eprecomp.h"
#include "smartptr.h"
#include "pubkey.h"
diff --git a/mqv.h b/mqv.h
index 5d30de24..aa5ba8f6 100644
--- a/mqv.h
+++ b/mqv.h
@@ -10,6 +10,7 @@
#include "gfpcrypt.h"
#include "modarith.h"
#include "integer.h"
+#include "algebra.h"
#include "misc.h"
NAMESPACE_BEGIN(CryptoPP)
diff --git a/panama.h b/panama.h
index 97531928..b7db323a 100644
--- a/panama.h
+++ b/panama.h
@@ -10,7 +10,8 @@
#include "iterhash.h"
#include "secblock.h"
-#if CRYPTOPP_BOOL_X32
+// Clang 3.3 integrated assembler crash on Linux. Clang 3.4 due to compiler error with .intel_syntax
+#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30500))
# define CRYPTOPP_DISABLE_PANAMA_ASM
#endif
diff --git a/pubkey.h b/pubkey.h
index 4b6f28a3..8cdabe56 100644
--- a/pubkey.h
+++ b/pubkey.h
@@ -43,6 +43,7 @@
#include "cryptlib.h"
#include "integer.h"
+#include "algebra.h"
#include "modarith.h"
#include "filters.h"
#include "eprecomp.h"
diff --git a/queue.h b/queue.h
index 570a26d9..88a3b8d4 100644
--- a/queue.h
+++ b/queue.h
@@ -12,15 +12,23 @@
NAMESPACE_BEGIN(CryptoPP)
-/** The queue is implemented as a linked list of byte arrays, but you don't need to
- know about that. So just ignore this next line. :) */
class ByteQueueNode;
-//! Byte Queue
+//! \class ByteQueue
+//! \brief Data structure used to store byte strings
+//! \details The queue is implemented as a linked list of byte arrays
class CRYPTOPP_DLL ByteQueue : public Bufferless
{
public:
+ //! \brief Construct a ByteQueue
+ //! \param nodeSize the initial node size
+ //! \details Internally, ByteQueue uses a ByteQueueNode to store bytes, and \p nodeSize determines the
+ //! size of the ByteQueueNode. A value of 0 indicates the ByteQueueNode should be automatically sized,
+ //! which means a value of 256 is used.
ByteQueue(size_t nodeSize=0);
+
+ //! \brief Copy construct a ByteQueue
+ //! \param copy the other ByteQueue
ByteQueue(const ByteQueue ©);
~ByteQueue();
@@ -66,9 +74,13 @@ public:
byte operator[](lword i) const;
void swap(ByteQueue &rhs);
+ //! \class Walker
+ //! \brief A ByteQueue iterator
class Walker : public InputRejecting
{
public:
+ //! \brief Construct a ByteQueue Walker
+ //! \param queue a ByteQueue
Walker(const ByteQueue &queue)
: m_queue(queue), m_node(NULL), m_position(0), m_offset(0), m_lazyString(NULL), m_lazyLength(0)
{Initialize();}
diff --git a/rc2.h b/rc2.h
index 96ed6d4d..b917abfb 100644
--- a/rc2.h
+++ b/rc2.h
@@ -13,7 +13,7 @@
NAMESPACE_BEGIN(CryptoPP)
//! \class RC2_Info
-//! \brief The RC2 cipher's key, iv, block size and name information.
+//! \brief RC2 block cipher information
struct RC2_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 128>
{
CRYPTOPP_CONSTANT(DEFAULT_EFFECTIVE_KEYLENGTH = 1024)
@@ -22,7 +22,7 @@ struct RC2_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 128>
};
//! \class RC2
-//! \brief The RC2 stream cipher
+//! \brief RC2 block cipher
//! \sa RC2 on the Crypto Lounge.
class RC2 : public RC2_Info, public BlockCipherDocumentation
{
diff --git a/rc5.h b/rc5.h
index 9f125dd0..b1012737 100644
--- a/rc5.h
+++ b/rc5.h
@@ -11,14 +11,17 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class RC5_Info
+//! \brief RC5 block cipher information
struct RC5_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 0, 255>, public VariableRounds<16>
{
static const char *StaticAlgorithmName() {return "RC5";}
typedef word32 RC5_WORD;
};
-/// RC5
+//! \class RC5
+//! \brief RC5 block cipher
+//! \sa RC5
class RC5 : public RC5_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/rc6.h b/rc6.h
index 37eba319..13b7bfa9 100644
--- a/rc6.h
+++ b/rc6.h
@@ -11,14 +11,17 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class RC6_Info
+//! \brief RC6 block cipher information
struct RC6_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 255>, public VariableRounds<20>
{
static const char *StaticAlgorithmName() {return "RC6";}
typedef word32 RC6_WORD;
};
-/// RC6
+//! \class RC6
+//! \brief RC6 block cipher
+//! \sa RC6
class RC6 : public RC6_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/rdrand.cpp b/rdrand.cpp
index 1fd6f94c..fbfb7eec 100644
--- a/rdrand.cpp
+++ b/rdrand.cpp
@@ -132,10 +132,8 @@
#if (ALL_RDRAND_INTRIN_AVAILABLE || ALL_RDSEED_INTRIN_AVAILABLE)
# include // rdrand, MSC, ICC, and GCC
-# if defined(__has_include)
-# if __has_include()
-# include // rdseed for some compilers, like GCC
-# endif
+# if defined(__GNUC__) && (CRYPTOPP_GCC_VERSION >= 40600)
+# include // rdseed for some compilers, like GCC
# endif
#endif
diff --git a/rijndael.cpp b/rijndael.cpp
index 934b6884..0b6d1581 100644
--- a/rijndael.cpp
+++ b/rijndael.cpp
@@ -651,7 +651,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( movdqa XMMWORD_PTR [L_SUBKEYS+WORD_REG(si)], xmm0)
AS2( add WORD_REG(si), 16)
AS2( cmp WORD_REG(si), 16*12)
+ ATT_NOPREFIX
ASJ( jl, 0, b)
+ INTEL_NOPREFIX
// read subkeys 0, 1 and last
AS2( movdqa xmm4, [WORD_REG(ax)+WORD_REG(si)]) // last subkey
@@ -673,11 +675,15 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( mov esi, [AS_REG_7+WORD_REG(ax)])
AS2( add WORD_REG(ax), WORD_REG(di))
AS2( cmp WORD_REG(ax), 2048)
+ ATT_NOPREFIX
ASJ( jl, 9, b)
+ INTEL_NOPREFIX
AS1( lfence)
AS2( test DWORD PTR [L_LENGTH], 1)
+ ATT_NOPREFIX
ASJ( jz, 8, f)
+ INTEL_NOPREFIX
// counter mode one-time setup
AS2( mov WORD_REG(si), [L_INBLOCKS])
@@ -751,8 +757,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( mov [L_SAVED_X+0*4], eax)
AS2( mov [L_SAVED_X+1*4], ebx)
AS2( mov [L_SAVED_X+2*4], edi)
+ ATT_NOPREFIX
ASJ( jmp, 5, f)
-
+ INTEL_NOPREFIX
ASL(3)
// non-counter mode per-block setup
AS2( MOVD MM(1), [L_KEY12+0*4]) // 0,1,2,3
@@ -802,8 +809,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( add L_REG, [L_KEYS_BEGIN])
AS2( add L_REG, 4*16)
+ ATT_NOPREFIX
ASJ( jmp, 2, f)
-
+ INTEL_NOPREFIX
ASL(1)
// counter-mode per-block setup
AS2( MOVD ecx, MM(2))
@@ -830,7 +838,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( add L_REG, [L_KEYS_BEGIN])
AS2( add L_REG, 3*16)
+ ATT_NOPREFIX
ASJ( jmp, 4, f)
+ INTEL_NOPREFIX
// in: eax(0,1,2,3), ebx(4,5,6,7), ecx(8,9,10,11), edx(12,13,14,15)
// out: eax, ebx, edi, mm0
@@ -877,7 +887,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( add L_REG, 32)
AS2( test L_REG, 255)
+ ATT_NOPREFIX
ASJ( jnz, 2, b)
+ INTEL_NOPREFIX
AS2( sub L_REG, 16*16)
#define LAST(a, b, c) \
@@ -923,16 +935,22 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( pxor xmm2, [L_LASTROUND])
AS2( movdqu [WORD_REG(bx)], xmm2)
+ ATT_NOPREFIX
ASJ( jle, 7, f)
+ INTEL_NOPREFIX
AS2( mov [L_LENGTH], WORD_REG(cx))
AS2( test WORD_REG(cx), 1)
+ ATT_NOPREFIX
ASJ( jnz, 1, b)
+ INTEL_NOPREFIX
#if CRYPTOPP_BOOL_X64
AS2( movdqa xmm0, [L_INCREMENTS])
AS2( paddq xmm0, [L_INBLOCKS])
AS2( movdqa [L_INBLOCKS], xmm0)
#endif
+ ATT_NOPREFIX
ASJ( jmp, 3, b)
+ INTEL_NOPREFIX
ASL(7)
// erase keys on stack
diff --git a/rijndael.h b/rijndael.h
index 417df76b..ed856d94 100644
--- a/rijndael.h
+++ b/rijndael.h
@@ -11,7 +11,8 @@
#include "seckey.h"
#include "secblock.h"
-#if CRYPTOPP_BOOL_X32
+// Clang 3.3 integrated assembler crash on Linux
+#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400))
# define CRYPTOPP_DISABLE_RIJNDAEL_ASM
#endif
diff --git a/rng.h b/rng.h
index ed1177c5..15e7ae33 100644
--- a/rng.h
+++ b/rng.h
@@ -84,6 +84,7 @@ private:
class MaurerRandomnessTest : public Bufferless
{
public:
+ //! \brief Contruct a MaurerRandomnessTest
MaurerRandomnessTest();
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking);
diff --git a/safer.h b/safer.h
index a828c629..3828d8e3 100644
--- a/safer.h
+++ b/safer.h
@@ -11,7 +11,8 @@
NAMESPACE_BEGIN(CryptoPP)
-/// base class, do not use directly
+//! \class SAFER
+//! \brief SAFER base class
class SAFER
{
public:
@@ -49,13 +50,16 @@ protected:
bool Strengthened() const {return STR;}
};
-//! _
+//! \class SAFER_K_Info
+//! \brief SAFER-K block cipher information
struct SAFER_K_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
{
static const char *StaticAlgorithmName() {return "SAFER-K";}
};
-/// SAFER-K
+//! \class SAFER_K
+//! \brief SAFER-K block cipher
+//! \sa SAFER-K
class SAFER_K : public SAFER_K_Info, public SAFER, public BlockCipherDocumentation
{
public:
@@ -63,13 +67,16 @@ public:
typedef BlockCipherFinal > Decryption;
};
-//! _
+//! \class SAFER_SK_Info
+//! \brief SAFER-SK block cipher information
struct SAFER_SK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
{
static const char *StaticAlgorithmName() {return "SAFER-SK";}
};
-/// SAFER-SK
+//! \class SAFER_SK
+//! \brief SAFER-SK block cipher
+//! \sa SAFER-SK
class SAFER_SK : public SAFER_SK_Info, public SAFER, public BlockCipherDocumentation
{
public:
diff --git a/secblock.h b/secblock.h
index 0e1d9a66..8b318108 100644
--- a/secblock.h
+++ b/secblock.h
@@ -453,7 +453,7 @@ public:
//! \throws std::bad_alloc
//! \details If ptr!=NULL and len!=0, then the block is initialized from the pointer ptr.
//! If ptr==NULL and len!=0, then the block is initialized to 0.
- //! Otherwise, the block is empty and uninitialized.
+ //! Otherwise, the block is empty and \a not initialized.
//! \note size is the count of elements, and not the number of bytes
SecBlock(const T *ptr, size_type len)
: m_size(len), m_ptr(m_alloc.allocate(len, NULL)) {
@@ -528,7 +528,7 @@ public:
//! \brief Set contents and size from an array
//! \param ptr a pointer to an array of T
//! \param len the number of elements in the memory block
- //! \details If the memory block is reduced in size, then the unused area is set to 0.
+ //! \details If the memory block is reduced in size, then the reclaimed memory is set to 0.
void Assign(const T *ptr, size_type len)
{
New(len);
@@ -539,7 +539,7 @@ public:
//! \brief Copy contents from another SecBlock
//! \param t the other SecBlock
//! \details Assign checks for self assignment.
- //! \details If the memory block is reduced in size, then the unused area is set to 0.
+ //! \details If the memory block is reduced in size, then the reclaimed memory is set to 0.
void Assign(const SecBlock &t)
{
if (this != &t)
@@ -553,7 +553,7 @@ public:
//! \brief Assign contents from another SecBlock
//! \param t the other SecBlock
//! \details Internally, operator=() calls Assign().
- //! \details If the memory block is reduced in size, then the unused area is set to 0.
+ //! \details If the memory block is reduced in size, then the reclaimed memory is set to 0.
SecBlock& operator=(const SecBlock &t)
{
// Assign guards for self-assignment
@@ -563,8 +563,7 @@ public:
//! \brief Append contents from another SecBlock
//! \param t the other SecBlock
- //! \details Internally, this SecBlock calls Grow and then copies the new content.
- //! \details If the memory block is reduced in size, then the unused area is set to 0.
+ //! \details Internally, this SecBlock calls Grow and then appends t.
SecBlock& operator+=(const SecBlock &t)
{
assert((!t.m_ptr && !t.m_size) || (t.m_ptr && t.m_ptr.m_size));
@@ -580,12 +579,10 @@ public:
return *this;
}
- //! \brief Concatenate contents from another SecBlock
+ //! \brief Construct a SecBlock from this and another SecBlock
//! \param t the other SecBlock
//! \returns a newly constructed SecBlock that is a conacentation of this and t
- //! \details Internally, a temporary SecBlock is created and the content from this
- //! SecBlock and the other SecBlock are concatenated. The temporary
- //! SecBlock is returned to the caller.
+ //! \details Internally, a new SecBlock is created from this and a concatenation of t.
SecBlock operator+(const SecBlock &t)
{
assert((!m_ptr && !m_size) || (m_ptr && m_size));
@@ -624,8 +621,8 @@ public:
//! \brief Change size without preserving contents
//! \param newSize the new size of the memory block
//! \details Old content is \a not preserved. If the memory block is reduced in size,
- //! then the unused content is set to 0. If the memory block grows in size, then
- //! all content is uninitialized.
+ //! then the reclaimed memory is set to 0. If the memory block grows in size, then
+ //! the new memory is \a not initialized.
//! \details Internally, this SecBlock calls reallocate().
//! \sa New(), CleanNew(), Grow(), CleanGrow(), resize()
void New(size_type newSize)
@@ -636,9 +633,10 @@ public:
//! \brief Change size without preserving contents
//! \param newSize the new size of the memory block
- //! \details Old content is not preserved. If the memory block is reduced in size,
- //! then the unused content is set to 0. Existing and new content is set to 0.
- //! \details Internally, this SecBlock calls reallocate().
+ //! \details Old content is \a not preserved. If the memory block is reduced in size,
+ //! then the reclaimed content is set to 0. If the memory block grows in size, then
+ //! the new memory is initialized to 0.
+ //! \details Internally, this SecBlock calls New().
//! \sa New(), CleanNew(), Grow(), CleanGrow(), resize()
void CleanNew(size_type newSize)
{
@@ -648,12 +646,10 @@ public:
//! \brief Change size and preserve contents
//! \param newSize the new size of the memory block
- //! \details Old content is preserved. If the memory block grows in size, then
- //! all content is uninitialized.
- //! \details Internally, this SecBlock calls reallocate().
- //! \note reallocate() is called if the size increases. If the size does not
- //! increase, then Grow does not take action. If the size must change,
- //! then use resize().
+ //! \details Old content is preserved. New content is not initialized.
+ //! \details Internally, this SecBlock calls reallocate() when size must increase. If the
+ //! size does not increase, then Grow() does not take action. If the size must
+ //! change, then use resize().
//! \sa New(), CleanNew(), Grow(), CleanGrow(), resize()
void Grow(size_type newSize)
{
@@ -666,13 +662,10 @@ public:
//! \brief Change size and preserve contents
//! \param newSize the new size of the memory block
- //! \details Old content is preserved. If the memory block is reduced in size,
- //! then the unused content is set to 0. If the memory block grows in size,
- //! then the new content is uninitialized.
- //! \details Internally, this SecBlock calls reallocate().
- //! \note reallocate() is called if the size increases. If the size does not
- //! increase, then Grow does not take action. If the size must change,
- //! then use resize().
+ //! \details Old content is preserved. New content is initialized to 0.
+ //! \details Internally, this SecBlock calls reallocate() when size must increase. If the
+ //! size does not increase, then CleanGrow() does not take action. If the size must
+ //! change, then use resize().
//! \sa New(), CleanNew(), Grow(), CleanGrow(), resize()
void CleanGrow(size_type newSize)
{
@@ -687,11 +680,8 @@ public:
//! \brief Change size and preserve contents
//! \param newSize the new size of the memory block
//! \details Old content is preserved. If the memory block grows in size, then
- //! all content is uninitialized.
+ //! new memory is \a not initialized.
//! \details Internally, this SecBlock calls reallocate().
- //! \note reallocate() is called if the size increases. If the size does not
- //! increase, then Grow does not take action. If the size must change,
- //! then use resize().
//! \sa New(), CleanNew(), Grow(), CleanGrow(), resize()
void resize(size_type newSize)
{
@@ -718,13 +708,13 @@ public:
#ifdef CRYPTOPP_DOXYGEN_PROCESSING
//! \class SecByteBlock
-//! \brief SecByteBlock is a SecBlock typedef.
+//! \brief \ref SecBlock "SecBlock" typedef.
class SecByteBlock : public SecBlock {};
//! \class SecWordBlock
-//! \brief SecWordBlock is a SecBlock typedef.
+//! \brief \ref SecBlock "SecBlock" typedef.
class SecWordBlock : public SecBlock {};
//! \class AlignedSecByteBlock
-//! \brief AlignedSecByteBlock is a SecBlock > typedef.
+//! \brief SecBlock using \ref AllocatorWithCleanup "AllocatorWithCleanup" typedef
class AlignedSecByteBlock SecBlock > {};
#else
typedef SecBlock SecByteBlock;
diff --git a/seckey.h b/seckey.h
index 90d7aa25..287d38a9 100644
--- a/seckey.h
+++ b/seckey.h
@@ -21,38 +21,38 @@ NAMESPACE_BEGIN(CryptoPP)
//! \brief Inverts the cipher's direction
//! \param dir the cipher's direction
-//! \returns DECRYPTION if dir is ENCRYPTION, DECRYPTION otherwise
+//! \returns DECRYPTION if \ref CipherDir "dir" is ENCRYPTION, DECRYPTION otherwise
inline CipherDir ReverseCipherDir(CipherDir dir)
{
return (dir == ENCRYPTION) ? DECRYPTION : ENCRYPTION;
}
//! \class FixedBlockSize
-//! \brief Inherited by block ciphers with fixed block size
-//! \tparam N the blocksize of the cipher
+//! \brief Inherited by algorithms with fixed block size
+//! \tparam N the blocksize of the algorithm
template
class FixedBlockSize
{
public:
- //! \brief The block size of the cipher provided as a constant.
+ //! \brief The block size of the algorithm provided as a constant.
CRYPTOPP_CONSTANT(BLOCKSIZE = N)
};
// ************** rounds ***************
//! \class FixedRounds
-//! \brief Inherited by ciphers with fixed number of rounds
-//! \tparam R the number of rounds used by the cipher
+//! \brief Inherited by algorithms with fixed number of rounds
+//! \tparam R the number of rounds used by the algorithm
template
class FixedRounds
{
public:
- //! \brief The number of rounds for the cipher provided as a constant.
+ //! \brief The number of rounds for the algorithm provided as a constant.
CRYPTOPP_CONSTANT(ROUNDS = R)
};
//! \class VariableRounds
-//! \brief Inherited by ciphers with variable number of rounds
+//! \brief Inherited by algorithms with variable number of rounds
//! \tparam D Default number of rounds
//! \tparam N Minimum number of rounds
//! \tparam D Maximum number of rounds
@@ -60,13 +60,13 @@ template // use INT_
class VariableRounds
{
public:
- //! \brief The default number of rounds for the cipher provided as a constant.
+ //! \brief The default number of rounds for the algorithm provided as a constant.
CRYPTOPP_CONSTANT(DEFAULT_ROUNDS = D)
- //! \brief The minimum number of rounds for the cipher provided as a constant.
+ //! \brief The minimum number of rounds for the algorithm provided as a constant.
CRYPTOPP_CONSTANT(MIN_ROUNDS = N)
- //! \brief The maximum number of rounds for the cipher provided as a constant.
+ //! \brief The maximum number of rounds for the algorithm provided as a constant.
CRYPTOPP_CONSTANT(MAX_ROUNDS = M)
- //! \brief The default number of rounds for the cipher based on key length
+ //! \brief The default number of rounds for the algorithm based on key length
//! provided by a static function.
//! \param keylength the size of the key, in bytes
//! \details keylength is unused in the default implementation.
@@ -74,7 +74,7 @@ public:
{CRYPTOPP_UNUSED(keylength); return DEFAULT_ROUNDS;}
protected:
- //! \brief Validates the number of rounds for a cipher.
+ //! \brief Validates the number of rounds for an algorithm.
//! \param rounds the canddiate number of rounds
//! \param alg an Algorithm object used if the number of rounds are invalid
//! \throws InvalidRounds if the number of rounds are invalid
@@ -89,10 +89,10 @@ protected:
#endif
}
- //! \brief Validates the number of rounds for a cipher
+ //! \brief Validates the number of rounds for an algorithm
//! \param param the canddiate number of rounds
//! \param alg an Algorithm object used if the number of rounds are invalid
- //! \returns the number of rounds for the cipher
+ //! \returns the number of rounds for the algorithm
//! \throws InvalidRounds if the number of rounds are invalid
inline unsigned int GetRoundsAndThrowIfInvalid(const NameValuePairs ¶m, const Algorithm *alg)
{
@@ -107,32 +107,33 @@ protected:
//! \class FixedKeyLength
//! \brief Inherited by keyed algorithms with fixed key length
//! \tparam N Default key length, in bytes
-//! \tparam IV_REQ The IV requirements. See IV_Requirement in cryptlib.h for allowed values
-//! \tparam IV_L Default IV length, in bytes
+//! \tparam IV_REQ the \ref SimpleKeyingInterface::IV_Requirement "IV requirements"
+//! \tparam IV_L default IV length, in bytes
+//! \sa SimpleKeyingInterface
template
class FixedKeyLength
{
public:
- //! \brief The default key length used by the cipher provided as a constant
+ //! \brief The default key length used by the algorithm provided as a constant
//! \details KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(KEYLENGTH=N)
- //! \brief The minimum key length used by the cipher provided as a constant
+ //! \brief The minimum key length used by the algorithm provided as a constant
//! \details MIN_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(MIN_KEYLENGTH=N)
- //! \brief The maximum key length used by the cipher provided as a constant
+ //! \brief The maximum key length used by the algorithm provided as a constant
//! \details MAX_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(MAX_KEYLENGTH=N)
- //! \brief The default key length used by the cipher provided as a constant
+ //! \brief The default key length used by the algorithm provided as a constant
//! \details DEFAULT_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH=N)
- //! \brief The default IV requirements for the cipher provided as a constant
+ //! \brief The default IV requirements for the algorithm provided as a constant
//! \details The default value is NOT_RESYNCHRONIZABLE. See IV_Requirement
//! in cryptlib.h for allowed values.
CRYPTOPP_CONSTANT(IV_REQUIREMENT = IV_REQ)
- //! \brief The default IV length used by the cipher provided as a constant
+ //! \brief The default IV length used by the algorithm provided as a constant
//! \details IV_LENGTH is provided in bytes, not bits. The default implementation uses 0.
CRYPTOPP_CONSTANT(IV_LENGTH = IV_L)
- //! \brief The default key length for the cipher provided by a static function.
+ //! \brief The default key length for the algorithm provided by a static function.
//! \param keylength the size of the key, in bytes
//! \details The default implementation returns KEYLENGTH. keylength is unused
//! in the default implementation.
@@ -146,8 +147,9 @@ public:
//! \tparam N Minimum key length, in bytes
//! \tparam M Maximum key length, in bytes
//! \tparam M Default key length multiple, in bytes. The default multiple is 1.
-//! \tparam IV_REQ The IV requirements. See IV_Requirement in cryptlib.h for allowed values
-//! \tparam IV_L Default IV length, in bytes. The default length is 0.
+//! \tparam IV_REQ the \ref SimpleKeyingInterface::IV_Requirement "IV requirements"
+//! \tparam IV_L default IV length, in bytes. The default length is 0.
+//! \sa SimpleKeyingInterface
template
class VariableKeyLength
{
@@ -160,26 +162,26 @@ class VariableKeyLength
CRYPTOPP_COMPILE_ASSERT(M >= D);
public:
- //! \brief The minimum key length used by the cipher provided as a constant
+ //! \brief The minimum key length used by the algorithm provided as a constant
//! \details MIN_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(MIN_KEYLENGTH=N)
- //! \brief The maximum key length used by the cipher provided as a constant
+ //! \brief The maximum key length used by the algorithm provided as a constant
//! \details MAX_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(MAX_KEYLENGTH=M)
- //! \brief The default key length used by the cipher provided as a constant
+ //! \brief The default key length used by the algorithm provided as a constant
//! \details DEFAULT_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH=D)
- //! \brief The key length multiple used by the cipher provided as a constant
+ //! \brief The key length multiple used by the algorithm provided as a constant
//! \details MAX_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(KEYLENGTH_MULTIPLE=Q)
- //! \brief The default IV requirements for the cipher provided as a constant
+ //! \brief The default IV requirements for the algorithm provided as a constant
//! \details The default value is NOT_RESYNCHRONIZABLE. See IV_Requirement
//! in cryptlib.h for allowed values.
CRYPTOPP_CONSTANT(IV_REQUIREMENT=IV_REQ)
- //! \brief The default initialization vector length for the cipher provided as a constant
+ //! \brief The default initialization vector length for the algorithm provided as a constant
//! \details IV_LENGTH is provided in bytes, not bits. The default implementation uses 0.
CRYPTOPP_CONSTANT(IV_LENGTH=IV_L)
- //! \brief Provides a valid key length for the cipher provided by a static function.
+ //! \brief Provides a valid key length for the algorithm provided by a static function.
//! \param keylength the size of the key, in bytes
//! \details If keylength is less than MIN_KEYLENGTH, then the function returns
//! MIN_KEYLENGTH. If keylength is greater than MAX_KEYLENGTH, then the function
@@ -207,29 +209,30 @@ public:
//! \class SameKeyLengthAs
//! \brief Provides key lengths based on another class's key length
//! \tparam T another FixedKeyLength or VariableKeyLength class
-//! \tparam IV_REQ The IV requirements. See IV_Requirement in cryptlib.h for allowed values
-//! \tparam IV_L Default IV length, in bytes
+//! \tparam IV_REQ the \ref SimpleKeyingInterface::IV_Requirement "IV requirements"
+//! \tparam IV_L default IV length, in bytes
+//! \sa SimpleKeyingInterface
template
class SameKeyLengthAs
{
public:
- //! \brief The minimum key length used by the cipher provided as a constant
+ //! \brief The minimum key length used by the algorithm provided as a constant
//! \details MIN_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(MIN_KEYLENGTH=T::MIN_KEYLENGTH)
- //! \brief The maximum key length used by the cipher provided as a constant
+ //! \brief The maximum key length used by the algorithm provided as a constant
//! \details MIN_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(MAX_KEYLENGTH=T::MAX_KEYLENGTH)
- //! \brief The default key length used by the cipher provided as a constant
+ //! \brief The default key length used by the algorithm provided as a constant
//! \details MIN_KEYLENGTH is provided in bytes, not bits
CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH=T::DEFAULT_KEYLENGTH)
- //! \brief The default IV requirements for the cipher provided as a constant
+ //! \brief The default IV requirements for the algorithm provided as a constant
//! \details The default value is NOT_RESYNCHRONIZABLE. See IV_Requirement
//! in cryptlib.h for allowed values.
CRYPTOPP_CONSTANT(IV_REQUIREMENT=IV_REQ)
- //! \brief The default initialization vector length for the cipher provided as a constant
+ //! \brief The default initialization vector length for the algorithm provided as a constant
//! \details IV_LENGTH is provided in bytes, not bits. The default implementation uses 0.
CRYPTOPP_CONSTANT(IV_LENGTH=IV_L)
- //! \brief Provides a valid key length for the cipher provided by a static function.
+ //! \brief Provides a valid key length for the algorithm provided by a static function.
//! \param keylength the size of the key, in bytes
//! \details If keylength is less than MIN_KEYLENGTH, then the function returns
//! MIN_KEYLENGTH. If keylength is greater than MAX_KEYLENGTH, then the function
@@ -241,30 +244,35 @@ public:
{return T::StaticGetValidKeyLength(keylength);}
};
-// ************** implementation helper for SimpleKeyed ***************
+// ************** implementation helper for SimpleKeyingInterface ***************
//! \class SimpleKeyingInterfaceImpl
-//! \brief Provides class member functions to access SimpleKeyingInterface constants
+//! \brief Provides a base implementation of SimpleKeyingInterface
//! \tparam BASE a SimpleKeyingInterface derived class
//! \tparam INFO a SimpleKeyingInterface derived class
+//! \sa SimpleKeyingInterface
template
class CRYPTOPP_NO_VTABLE SimpleKeyingInterfaceImpl : public BASE
{
public:
- //! \brief The minimum key length used by the cipher
+ //! \brief The minimum key length used by the algorithm
+ //! \returns minimum key length used by the algorithm, in bytes
size_t MinKeyLength() const
{return INFO::MIN_KEYLENGTH;}
- //! \brief The maximum key length used by the cipher
+ //! \brief The maximum key length used by the algorithm
+ //! \returns maximum key length used by the algorithm, in bytes
size_t MaxKeyLength() const
{return (size_t)INFO::MAX_KEYLENGTH;}
- //! \brief The default key length used by the cipher
+ //! \brief The default key length used by the algorithm
+ //! \returns default key length used by the algorithm, in bytes
size_t DefaultKeyLength() const
{return INFO::DEFAULT_KEYLENGTH;}
- //! \brief Provides a valid key length for the cipher
+ //! \brief Provides a valid key length for the algorithm
//! \param keylength the size of the key, in bytes
+ //! \returns the valid key lenght, in bytes
//! \details keylength is provided in bytes, not bits. If keylength is less than MIN_KEYLENGTH,
//! then the function returns MIN_KEYLENGTH. If keylength is greater than MAX_KEYLENGTH,
//! then the function returns MAX_KEYLENGTH. if If keylength is a multiple of KEYLENGTH_MULTIPLE,
@@ -272,28 +280,28 @@ public:
//! KEYLENGTH_MULTIPLE.
size_t GetValidKeyLength(size_t keylength) const {return INFO::StaticGetValidKeyLength(keylength);}
- //! \brief The default IV requirements for the cipher
+ //! \brief The default IV requirements for the algorithm
//! \details The default value is NOT_RESYNCHRONIZABLE. See IV_Requirement
//! in cryptlib.h for allowed values.
SimpleKeyingInterface::IV_Requirement IVRequirement() const
{return (SimpleKeyingInterface::IV_Requirement)INFO::IV_REQUIREMENT;}
- //! \brief The default initialization vector length for the cipher
+ //! \brief The default initialization vector length for the algorithm
//! \details IVSize is provided in bytes, not bits. The default implementation uses IV_LENGTH, which is 0.
unsigned int IVSize() const
{return INFO::IV_LENGTH;}
};
//! \class BlockCipherImpl
-//! \brief Provides class member functions to access BlockCipher constants
+//! \brief Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers
//! \tparam INFO a SimpleKeyingInterface derived class
//! \tparam BASE a SimpleKeyingInterface derived class
template
class CRYPTOPP_NO_VTABLE BlockCipherImpl : public AlgorithmImpl > >
{
public:
- //! Provides the block size of the cipher
- //! \returns the block size of the cipher, in bytes
+ //! Provides the block size of the algorithm
+ //! \returns the block size of the algorithm, in bytes
unsigned int BlockSize() const {return this->BLOCKSIZE;}
};
@@ -335,12 +343,12 @@ public:
//! \brief Provides the direction of the cipher
//! \returns true if DIR is ENCRYPTION, false otherwise
- //! \sa IsForwardTransformation(), IsPermutation(), GetCipherDirection()
+ //! \sa GetCipherDirection(), IsPermutation()
bool IsForwardTransformation() const {return DIR == ENCRYPTION;}
};
//! \class MessageAuthenticationCodeImpl
-//! \brief Provides class member functions to access MessageAuthenticationCode constants
+//! \brief Provides a base implementation of Algorithm and SimpleKeyingInterface for message authentication codes
//! \tparam INFO a SimpleKeyingInterface derived class
//! \tparam BASE a SimpleKeyingInterface derived class
template
@@ -360,13 +368,13 @@ public:
//! \details The message authentication code is not keyed.
MessageAuthenticationCodeFinal() {}
//! \brief Construct a BlockCipherFinal
- //! \param key a byte array used to key the cipher
+ //! \param key a byte array used to key the algorithm
//! \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls
//! SimpleKeyingInterface::SetKey.
MessageAuthenticationCodeFinal(const byte *key)
{this->SetKey(key, this->DEFAULT_KEYLENGTH);}
//! \brief Construct a BlockCipherFinal
- //! \param key a byte array used to key the cipher
+ //! \param key a byte array used to key the algorithm
//! \param length the length of the byte array
//! \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls
//! SimpleKeyingInterface::SetKey.
diff --git a/seed.h b/seed.h
index a7fba346..f62f6626 100644
--- a/seed.h
+++ b/seed.h
@@ -11,13 +11,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class SEED_Info
+//! \brief SEED block cipher information
struct SEED_Info : public FixedBlockSize<16>, public FixedKeyLength<16>, public FixedRounds<16>
{
static const char *StaticAlgorithmName() {return "SEED";}
};
-/// SEED
+//! \class SEED
+//! \brief SEED block cipher
+//! \sa SEED
class SEED : public SEED_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/serpent.h b/serpent.h
index 7c48cf76..64fd0e5c 100644
--- a/serpent.h
+++ b/serpent.h
@@ -11,13 +11,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class Serpent_Info
+//! \brief Serpent block cipher information
struct Serpent_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>, public FixedRounds<32>
{
static const char *StaticAlgorithmName() {return "Serpent";}
};
-/// Serpent
+//! \class Serpent
+//! \brief Serpent block cipher
+/// \sa Serpent
class Serpent : public Serpent_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/sha.cpp b/sha.cpp
index 8ac6368a..bdd87df7 100644
--- a/sha.cpp
+++ b/sha.cpp
@@ -102,7 +102,7 @@ void SHA256::InitState(HashWordType *state)
memcpy(state, s, sizeof(s));
}
-#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
+#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SHA_ASM)
CRYPTOPP_ALIGN_DATA(16) extern const word32 SHA256_K[64] CRYPTOPP_SECTION_ALIGN16 = {
#else
extern const word32 SHA256_K[64] = {
@@ -127,7 +127,7 @@ extern const word32 SHA256_K[64] = {
#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
-#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_GENERATE_X64_MASM)
+#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_GENERATE_X64_MASM)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32 *data, size_t len
#if defined(_MSC_VER) && (_MSC_VER == 1200)
@@ -371,7 +371,9 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32
ROUND(14, 1, eax, ecx, edi, edx)
ROUND(15, 1, ecx, eax, edx, edi)
AS2( cmp WORD_REG(si), K_END)
+ ATT_NOPREFIX
ASJ( jb, 1, b)
+ INTEL_NOPREFIX
AS2( mov WORD_REG(dx), DATA_SAVE)
AS2( add WORD_REG(dx), 64)
@@ -390,7 +392,9 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32
AS2( movdqa [AS_REG_7+1*16], xmm1)
AS2( movdqa [AS_REG_7+0*16], xmm0)
AS2( cmp WORD_REG(dx), DATA_END)
+ ATT_NOPREFIX
ASJ( jb, 0, b)
+ INTEL_NOPREFIX
#endif
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
@@ -461,7 +465,7 @@ void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32 *data,
}
#endif
-#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
+#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
size_t SHA256::HashMultipleBlocks(const word32 *input, size_t length)
{
@@ -503,7 +507,7 @@ size_t SHA224::HashMultipleBlocks(const word32 *input, size_t length)
void SHA256::Transform(word32 *state, const word32 *data)
{
word32 W[16];
-#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
+#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
// this byte reverse is a waste of time, but this function is only called by MDC
ByteReverse(W, data, BLOCKSIZE);
X86_SHA256_HashBlocks(state, W, BLOCKSIZE - !HasSSE2());
diff --git a/sha.h b/sha.h
index 90ff1ab0..544e8056 100644
--- a/sha.h
+++ b/sha.h
@@ -10,6 +10,11 @@
#include "config.h"
#include "iterhash.h"
+// Clang 3.3 integrated assembler crash on Linux
+#if defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400)
+# define CRYPTOPP_DISABLE_SHA_ASM
+#endif
+
NAMESPACE_BEGIN(CryptoPP)
/// SHA-1
@@ -27,7 +32,7 @@ typedef SHA1 SHA; // for backwards compatibility
class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform
{
public:
-#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
+#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
size_t HashMultipleBlocks(const word32 *input, size_t length);
#endif
static void CRYPTOPP_API InitState(HashWordType *state);
@@ -39,7 +44,7 @@ public:
class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform
{
public:
-#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
+#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
size_t HashMultipleBlocks(const word32 *input, size_t length);
#endif
static void CRYPTOPP_API InitState(HashWordType *state);
diff --git a/shacal2.h b/shacal2.h
index 70532102..6d6ffa33 100644
--- a/shacal2.h
+++ b/shacal2.h
@@ -1,6 +1,6 @@
// shacal.h - written and placed in the public domain by Wei Dai
-//! \file shacal.h
+//! \file shacal2.h
//! \brief Classes for the SHACAL-2 block cipher
#ifndef CRYPTOPP_SHACAL2_H
@@ -11,13 +11,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class SHACAL2_Info
+//! \brief SHACAL2 block cipher information
struct SHACAL2_Info : public FixedBlockSize<32>, public VariableKeyLength<16, 16, 64>
{
static const char *StaticAlgorithmName() {return "SHACAL-2";}
};
-/// SHACAL-2
+//! \class SHACAL2
+//! \brief SHACAL2 block cipher
+//! \sa SHACAL-2
class SHACAL2 : public SHACAL2_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/shark.h b/shark.h
index 41663fa1..8d1b6e71 100644
--- a/shark.h
+++ b/shark.h
@@ -12,12 +12,15 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class SHARK_Info
+//! \brief SHARK block cipher information
struct SHARK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 16>, public VariableRounds<6, 2>
{
static const char *StaticAlgorithmName() {return "SHARK-E";}
};
+//! \class SHARK
+//! \brief SHARK block cipher
/// SHARK-E
class SHARK : public SHARK_Info, public BlockCipherDocumentation
{
diff --git a/simple.h b/simple.h
index 347dabac..b195feb1 100644
--- a/simple.h
+++ b/simple.h
@@ -1,7 +1,7 @@
// simple.h - written and placed in the public domain by Wei Dai
//! \file simple.h
-//! \brief Classes providing simple keying interfaces.
+//! \brief Classes providing basic library services.
#ifndef CRYPTOPP_SIMPLE_H
#define CRYPTOPP_SIMPLE_H
@@ -228,6 +228,7 @@ private:
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Store : public AutoSignaling >
{
public:
+ //! \brief Construct a Store
Store() : m_messageEnd(false) {}
void IsolatedInitialize(const NameValuePairs ¶meters)
diff --git a/skipjack.h b/skipjack.h
index 2b2fbfe7..1e214c26 100644
--- a/skipjack.h
+++ b/skipjack.h
@@ -11,13 +11,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class SKIPJACK_Info
+//! \brief SKIPJACK block cipher information
struct SKIPJACK_Info : public FixedBlockSize<8>, public FixedKeyLength<10>
{
CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "SKIPJACK";}
};
-/// SKIPJACK
+//! \class SKIPJACK
+//! \brief SKIPJACK block cipher information
+//! \sa SKIPJACK
class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation
{
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/square.h b/square.h
index 2565f1cf..cf058a3d 100644
--- a/square.h
+++ b/square.h
@@ -11,13 +11,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class Square_Info
+//! \brief Square block cipher information
struct Square_Info : public FixedBlockSize<16>, public FixedKeyLength<16>, FixedRounds<8>
{
static const char *StaticAlgorithmName() {return "Square";}
};
-/// Square
+//! \class Square
+//! \brief Square block cipher
+//! \sa Square
class Square : public Square_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/tea.h b/tea.h
index 39923924..6c933b7e 100644
--- a/tea.h
+++ b/tea.h
@@ -12,13 +12,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class TEA_Info
+//! \brief TEA block cipher information
struct TEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
{
static const char *StaticAlgorithmName() {return "TEA";}
};
-/// TEA
+//! \class TEA
+//! \brief TEA block cipher
+//! \sa TEA
class TEA : public TEA_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
@@ -51,13 +54,16 @@ public:
typedef TEA::Encryption TEAEncryption;
typedef TEA::Decryption TEADecryption;
-//! _
+//! \class XTEA_Info
+//! \brief XTEA block cipher information
struct XTEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
{
static const char *StaticAlgorithmName() {return "XTEA";}
};
-/// XTEA
+//! \class XTEA
+//! \brief XTEA block cipher
+//! \sa XTEA
class XTEA : public XTEA_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
@@ -87,14 +93,17 @@ public:
typedef BlockCipherFinal Decryption;
};
-//! _
+//! \class BTEA_Info
+//! \brief BTEA block cipher information
struct BTEA_Info : public FixedKeyLength<16>
{
static const char *StaticAlgorithmName() {return "BTEA";}
};
-//! corrected Block TEA (as described in "xxtea").
-/*! This class hasn't been tested yet. */
+//! \class BTEA
+//! \brief BTEA block cipher
+//! \details Corrected Block TEA as described in "xxtea". This class hasn't been tested yet.
+//! \sa Corrected Block TEA.
class BTEA : public BTEA_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public AlgorithmImpl, BTEA_Info>, public BTEA_Info
diff --git a/twofish.h b/twofish.h
index f93395d7..5ebc2440 100644
--- a/twofish.h
+++ b/twofish.h
@@ -11,13 +11,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! _
+//! \class Twofish_Info
+//! \brief Twofish block cipher information
struct Twofish_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>, FixedRounds<16>
{
static const char *StaticAlgorithmName() {return "Twofish";}
};
-/// Twofish
+//! \class Twofish
+//! \brief Twofish block cipher
+//~ \sa Twofish
class Twofish : public Twofish_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl
diff --git a/validat1.cpp b/validat1.cpp
index 1d614636..144bdbf0 100644
--- a/validat1.cpp
+++ b/validat1.cpp
@@ -460,6 +460,7 @@ bool TestAutoSeeded()
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
bool TestRDRAND()
{
+ // Testing on 6th generation i7 shows RDRAND needs less than 8 retries for 10K bytes.
RDRAND rdrand;
bool entropy = true, compress = true, discard = true;
static const unsigned int SIZE = 10000;
@@ -532,7 +533,8 @@ bool TestRDRAND()
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
bool TestRDSEED()
{
- RDSEED rdseed;
+ // Testing on 6th generation i7 shows RDSEED needs about 128 retries for 10K bytes.
+ RDSEED rdseed(128);
bool entropy = true, compress = true, discard = true;
static const unsigned int SIZE = 10000;
diff --git a/vmac.cpp b/vmac.cpp
index 45c3d851..d4338712 100644
--- a/vmac.cpp
+++ b/vmac.cpp
@@ -19,7 +19,12 @@ NAMESPACE_BEGIN(CryptoPP)
#include
#endif
-#define VMAC_BOOL_WORD128 (defined(CRYPTOPP_WORD128_AVAILABLE) && !defined(CRYPTOPP_X64_ASM_AVAILABLE))
+#if defined(CRYPTOPP_WORD128_AVAILABLE) && !defined(CRYPTOPP_X64_ASM_AVAILABLE)
+# define VMAC_BOOL_WORD128 1
+#else
+# define VMAC_BOOL_WORD128 0
+#endif
+
#ifdef __BORLANDC__
#define const // Turbo C++ 2006 workaround
#endif
@@ -467,7 +472,7 @@ VMAC_Base::VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWord64,
#define AccumulateNH(a, b, c) a += word128(b)*(c)
#define Multiply128(r, i1, i2) r = word128(word64(i1)) * word64(i2)
#else
- #if _MSC_VER >= 1400 && !defined(__INTEL_COMPILER)
+ #if _MSC_VER >= 1400 && !defined(__INTEL_COMPILER) && !defined(_M_ARM)
#define MUL32(a, b) __emulu(word32(a), word32(b))
#else
#define MUL32(a, b) ((word64)((word32)(a)) * (word32)(b))
diff --git a/vmac.h b/vmac.h
index 996457f8..335afc30 100644
--- a/vmac.h
+++ b/vmac.h
@@ -1,3 +1,8 @@
+// vmac.h - written and placed in the public domain by Wei Dai
+
+//! \file vmac.h
+//! \brief Classes for the VMAC message authentication code
+
#ifndef CRYPTOPP_VMAC_H
#define CRYPTOPP_VMAC_H
@@ -12,7 +17,7 @@
NAMESPACE_BEGIN(CryptoPP)
//! \class VMAC_Base
-//! \brief Class specific methods used to operate the MAC.
+//! \brief VMAC message authentication code base class
class VMAC_Base : public IteratedHashBase
{
public:
@@ -45,10 +50,6 @@ protected:
void VHASH_Update_Template(const word64 *data, size_t blockRemainingInWord128);
void VHASH_Update(const word64 *data, size_t blocksRemainingInWord128);
-#if CRYPTOPP_DOXYGEN_PROCESSING
- private: // hide from documentation
-#endif
-
CRYPTOPP_BLOCK_1(polyState, word64, 4*(m_is128+1))
CRYPTOPP_BLOCK_2(nhKey, word64, m_L1KeyLength/sizeof(word64) + 2*m_is128)
CRYPTOPP_BLOCK_3(data, byte, m_L1KeyLength)
@@ -62,13 +63,15 @@ protected:
};
//! \class VMAC
-//! \brief The VMAC message authentication code
+//! \brief VMAC message authentication code
+//! \tparam T_BlockCipher block cipher
+//! \tparam T_DigestBitSize digest size, in bits
//! \details VMAC is a block cipher-based message authentication code algorithm
//! using a universal hash proposed by Ted Krovetz and Wei Dai in April 2007. The
//! algorithm was designed for high performance backed by a formal analysis.
-//! \tparam T_BlockCipher block cipher
-//! \tparam T_DigestBitSize digest size, in bits
-//! \sa VMAC at the Crypto Lounge.
+//! \details The implementation is based on Ted Krovetz's public domain vmac.c
+//! and draft-krovetz-vmac-01.txt.
+//! \sa VMAC.
template
class VMAC : public SimpleKeyingInterfaceImpl >
{
diff --git a/xtr.cpp b/xtr.cpp
index 459f8ffe..9819b81d 100644
--- a/xtr.cpp
+++ b/xtr.cpp
@@ -5,6 +5,7 @@
#include "xtr.h"
#include "nbtheory.h"
#include "integer.h"
+#include "algebra.h"
#include "modarith.h"
#include "algebra.cpp"
diff --git a/xtr.h b/xtr.h
index f520cf5e..d38bae95 100644
--- a/xtr.h
+++ b/xtr.h
@@ -1,17 +1,19 @@
#ifndef CRYPTOPP_XTR_H
#define CRYPTOPP_XTR_H
-/** \file
- "The XTR public key system" by Arjen K. Lenstra and Eric R. Verheul
-*/
+//! \file xtr.h
+//! \brief The XTR public key system
+//! \details The XTR public key system by Arjen K. Lenstra and Eric R. Verheul
#include "cryptlib.h"
#include "modarith.h"
#include "integer.h"
+#include "algebra.h"
NAMESPACE_BEGIN(CryptoPP)
-//! an element of GF(p^2)
+//! \class GFP2Element
+//! \brief an element of GF(p^2)
class GFP2Element
{
public:
@@ -40,7 +42,8 @@ public:
Integer c1, c2;
};
-//! GF(p^2), optimal normal basis
+//! \class GFP2_ONB
+//! \brief GF(p^2), optimal normal basis
template
class GFP2_ONB : public AbstractRing
{
@@ -208,6 +211,7 @@ protected:
mutable Integer t;
};
+//! \brief Creates primes p,q and generator g for XTR
void XTR_FindPrimesAndGenerator(RandomNumberGenerator &rng, Integer &p, Integer &q, GFP2Element &g, unsigned int pbits, unsigned int qbits);
GFP2Element XTR_Exponentiate(const GFP2Element &b, const Integer &e, const Integer &p);
diff --git a/zdeflate.cpp b/zdeflate.cpp
index fea6025c..9643d5d7 100644
--- a/zdeflate.cpp
+++ b/zdeflate.cpp
@@ -588,7 +588,7 @@ void Deflator::MatchFound(unsigned int distance, unsigned int length)
assert(m_matchBufferEnd < m_matchBuffer.size());
EncodedMatch &m = m_matchBuffer[m_matchBufferEnd++];
- assert(length >= 3 && length < COUNTOF(lengthCodes));
+ assert((length >= 3) && (length-3 < COUNTOF(lengthCodes)));
unsigned int lengthCode = lengthCodes[length-3];
m.literalCode = lengthCode;
m.literalExtra = length - lengthBases[lengthCode-257];