Upgrade to beecrypt-4.0.0.

CVS patchset: 7372
CVS date: 2004/08/02 00:45:38
This commit is contained in:
jbj 2004-08-02 00:45:38 +00:00
parent 8462a31960
commit 8931f04c4d
470 changed files with 36221 additions and 9353 deletions

View File

@ -1,42 +0,0 @@
.deps
.depend
.depend-done
.libs
Doxyfile
Makefile
Makefile.in
aclocal.m4
missing
mkinstalldirs
apidocs
autom4te*
beecrypt.gnu.h
beecrypt.spec
beecrypt-*.tar.gz
config.h
config.h.in
config.cache
config.guess
config.log
config.m4
config.status
config.sub
configure
depcomp
doxygen
libtool
listobjs
ltconfig
ltmain.sh
aesopt.c
blowfishopt.c
mpopt.c
sha1opt.c
*.la
*.lcd
*.lo
*.o
*.s
stamp-h
stamp-h1
stamp-h.in

View File

@ -1,51 +0,0 @@
-I. -I/usr/lib/gcc-lib/i386-redhat-linux/3.1/include -DHAVE_CONFIG_H -D_GNU_SOURCE -DHAVE_DEV_DSP -DHAVE_SYS_SOUNDCARD
#+partial
+forcehints
-warnposix
+unixlib
-unrecogcomments # XXX ignore doxygen markings
+strict # lclint level
# --- in progress
+likelybounds
-bufferoverflowhigh
-elseifcomplete
-whileempty
# --- not-yet at strict level
-exportconst # 3
-exportfcn # 308
-exporttype # 53
-exportvar # 14
-protoparamname # 826
-ansi-reserved-internal # goofy
-ptrarith # 212
-mustdefine # 64
-strictops # 23
-impcheckedstrictglobs
-impcheckedstrictstatics
-strictbranchstate
-forblock # 15
-ifblock # 455
-whileblock # 25
-sys-dir-errors # 1296
# --- not-yet at checks level
-predboolptr # 88
-ansi-reserved # goofy
# --- not-yet at standard level
+boolint # 329
+charint # 3
+matchanyintegral # 573

View File

@ -1,3 +1,11 @@
BeeCrypt Cryptograpy Library:
Bob Deblier <bob.deblier@pandora.be>
C++ Interface:
Bob Deblier <bob.deblier@pandora.be>
Python Interface:
Jeff Johson <jbj@redhat.com>

View File

@ -3,14 +3,18 @@ i.e. the amount of free memory, swapped memory, amount of cpu cache, etc.
I've tried to make them as accurate as possible, within limits.
Note: many of the testing systems were provided by HP's testdrive program;
many thanks to them for giving me access to their systems.
many thanks to them for giving me access to their systems. Also thanks to
SourceForge for their compile farm!
Note: to avoid religious wars, in the table below read GNU/Linux for
Linux - I'm just a little cramped for space...
BENCHmark Modular Exponentation (more is better):
BeeCrypt 4.0.0 | gcc-3.3.3 | Fedora Core 2 | Athlon 64 3000+| 1 GB: 24740
BeeCrypt 4.0.0 | gcc-3.2.2 | SuSE 8 EL | Opteron 1600 | 1 GB: 19460
BeeCrypt 3.0.0 | gcc-3.x | RedHat Linux | Opteron MP 1600 | : 17230
BeeCrypt 3.2.0 | gcc-2.96 | RedHat AS 2.1 | Itanium 2 1400 | 1 GB: 11453
BeeCrypt 3.0.0 | gcc-3.2.2 | Debian Linux 3.0 | Itanium 2 900 | 12 GB: 7317
BeeCrypt 3.0.0 | gcc-3.3 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 6920 [--with-arch=pentium4]
BeeCrypt 3.0.0 | gcc-2.95.4 | Debian Linux 3.0 | Alpha EV6.7 666 | 2 GB: 5742
@ -29,9 +33,11 @@ BeeCrypt 3.0.0 | gcc-2.95.4 | Debian Linux 3.0r1 | M68030 25
BENCHmark Hash Function (more is better):
MD5
BeeCrypt 4.0.0 | gcc-3.3.3 | Fedora Core 2 | Athlon 64 3000+| 1 GB: 186.6 MB/s
BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 137.0 MB/s [--with-arch=pentiumpro]
SHA-1
BeeCrypt 4.0.0 | gcc-3.3.3 | Fedora Core 2 | Athlon 64 3000+| 1 GB: 104.7 MB/s
BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 77.0 MB/s [--with-arch=pentiumpro]
SHA-256

View File

@ -2,13 +2,19 @@ Legend:
- = open bug
* = fixed bug
3.0.0pre:
- Intel icc can't cope with gcj headers; there's also a problem in
combination with aio.h. Solution should be to not test gcj when using
this compiler. As a workaround, you can specify --without-javaglue.
- GCC 3.3 produces faster output for Blowfish than the included assembler
source; try coding two Blowfish rounds (without swap) in C and compile
to assembler to see how GCC accomplishes this.
3.1.0:
* Error in final result computation of mpextgcd_w in certain circumstances.
* PowerPC 64-bit assembler symbols aren't defined according to LSB 1.3.
3.0.0:
- Can't seem to generate 64-bit shared libraries on AIX; use
--disable-shared on this platform for now.
- Intel icc can't cope with gcj headers. There's also a problem in
combination with aio.h; solution should be to not test gcj when using
this compiler. As a workaround, you can specify --without-javaglue.
- GCC 3.3 produces faster output for Blowfish on Pentium 4 than the
included assembler source; try coding two Blowfish rounds (without swap)
in C and compile to assembler to see how GCC accomplishes this.
2.3.0pre:
* bug in certain instances of computing modular inverse.

View File

@ -1,5 +1,6 @@
I would like to thank the following people (in alphabetical order):
- Seth Arnold, for contributing to the documentation.
- Jan-Rudolph Bührmann, for helping me get started on the 64-bit multi-
precision integer library.
- Luca Filipozzi, maintainer/packager of BeeCrypt for Debian GNU/Linux.

View File

@ -325,16 +325,12 @@ mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
necessary. Hereny it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Section

View File

@ -1 +0,0 @@
To generate the documentation, please use doxygen.

View File

@ -1,4 +1,4 @@
# Doxyfile 1.2.10
# Doxyfile 1.3.4
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
@ -11,7 +11,7 @@
# Values that contain spaces should be placed between quotes (" ")
#---------------------------------------------------------------------------
# General configuration options
# Project related configuration options
#---------------------------------------------------------------------------
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
@ -36,43 +36,22 @@ OUTPUT_DIRECTORY = @top_srcdir@/docs
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Brazilian, Chinese, Croatian, Czech, Danish, Dutch, Finnish, French,
# German, Hungarian, Italian, Japanese, Korean, Norwegian, Polish,
# Portuguese, Romanian, Russian, Slovak, Slovene, Spanish and Swedish.
# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch,
# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en
# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese,
# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
OUTPUT_LANGUAGE = English
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
# This tag can be used to specify the encoding used in the generated output.
# The encoding is not always determined by the language that is chosen,
# but also whether or not the output is meant for Windows or non-Windows users.
# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
# forces the Windows encoding (this is the default for the Windows binary),
# whereas setting the tag to NO uses a Unix-style encoding (the default for
# all platforms other than Windows).
EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = YES
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these class will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
USE_WINDOWS_ENCODING = NO
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
@ -94,106 +73,61 @@ REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
# members of a class in the documentation of that class as if those members were
# ordinary class members. Constructors, destructors and assignment operators of
# the base classes will not be shown.
INLINE_INHERITED_MEMB = NO
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
FULL_PATH_NAMES = NO
FULL_PATH_NAMES = YES
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user defined part of the path. Stripping is
# can be used to strip a user-defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. It is allowed to use relative paths in the argument list.
STRIP_FROM_PATH = @top_srcdir@/
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = YES
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a class diagram (in Html and LaTeX) for classes with base or
# super classes. Setting the tag to NO turns the diagrams off.
CLASS_DIAGRAMS = YES
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
SOURCE_BROWSER = YES
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
STRIP_CODE_COMMENTS = YES
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower case letters. If set to YES upper case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# users are adviced to set this option to NO.
CASE_SENSE_NAMES = YES
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful is your file systems
# doesn't support long names like on DOS, Mac, or CD-ROM.
SHORT_NAMES = NO
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
HIDE_SCOPE_NAMES = NO
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
VERBATIM_HEADERS = YES
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put list of the files that are included by a file in the documentation
# of that file.
SHOW_INCLUDE_FILES = YES
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
# comments will behave just like the Qt-style comments (thus requiring an
# comments will behave just like the Qt-style comments (thus requiring an
# explict @brief command for a brief description.
JAVADOC_AUTOBRIEF = YES
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
# treat a multi-line C++ special comment block (i.e. a block of //! or ///
# comments) as a brief description. This used to be the default behaviour.
# The new default is to treat a multi-line C++ comment block as a detailed
# description. Set this tag to YES if you prefer the old behaviour instead.
MULTILINE_CPP_IS_BRIEF = NO
# If the DETAILS_AT_TOP tag is set to YES then Doxygen
# will output the detailed description near the top, like JavaDoc.
# If set to NO, the detailed description appears after the member
# documentation.
DETAILS_AT_TOP = NO
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# reimplements.
INHERIT_DOCS = YES
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
@ -206,6 +140,132 @@ DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 4
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user-defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
ALIASES =
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C.
# For instance, some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = YES
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
# only. Doxygen will then generate output that is more tailored for Java.
# For instance, namespaces will be presented as packages, qualified scopes
# will look different, etc.
OPTIMIZE_OUTPUT_JAVA = NO
# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
# the same type (for instance a group of public functions) to be put as a
# subgroup of that type (e.g. under the Public Functions section). Set it to
# NO to prevent subgrouping. Alternatively, this can be done per class using
# the \nosubgrouping command.
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
# If set to NO only classes defined in header files are included.
EXTRACT_LOCAL_CLASSES = YES
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these classes will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
# friend (class|struct|union) declarations.
# If set to NO (the default) these declarations will be included in the
# documentation.
HIDE_FRIEND_COMPOUNDS = NO
# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
# documentation blocks found inside the body of a function.
# If set to NO (the default) these blocks will be appended to the
# function's detailed documentation block.
HIDE_IN_BODY_DOCS = NO
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = YES
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower-case letters. If set to YES upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# users are advised to set this option to NO.
CASE_SENSE_NAMES = YES
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
HIDE_SCOPE_NAMES = NO
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put a list of the files that are included by a file in the documentation
# of that file.
SHOW_INCLUDE_FILES = YES
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = YES
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
@ -224,14 +284,11 @@ GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
# 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 the documentation.
ALIASES =
GENERATE_DEPRECATEDLIST= YES
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
@ -239,7 +296,7 @@ ALIASES =
ENABLED_SECTIONS =
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consist of for it to appear in
# the initial value of a variable or define consists of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and defines in the
@ -248,13 +305,6 @@ ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C.
# For instance some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = YES
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
@ -282,6 +332,13 @@ WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as not documenting some
# parameters in a documented function, or documenting parameters that
# don't exist or using markup commands wrongly.
WARN_IF_DOC_ERROR = YES
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
@ -304,14 +361,27 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = \
@top_srcdir@/Doxyheader \
@top_srcdir@/
INPUT = @top_srcdir@/Doxyheader \
@top_srcdir@/ \
@top_srcdir@/c++ \
@top_srcdir@/c++/crypto \
@top_srcdir@/c++/crypto/interfaces \
@top_srcdir@/c++/crypto/spec \
@top_srcdir@/c++/io \
@top_srcdir@/c++/lang \
@top_srcdir@/c++/provider \
@top_srcdir@/c++/security \
@top_srcdir@/c++/security/cert \
@top_srcdir@/c++/security/interfaces \
@top_srcdir@/c++/security/spec \
@top_srcdir@/c++/util
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
# blank the following patterns are tested:
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
FILE_PATTERNS = *.h
@ -327,11 +397,16 @@ RECURSIVE = NO
EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
# that are symbolic links (a Unix filesystem feature) are excluded from the input.
EXCLUDE_SYMLINKS = NO
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories.
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = *config*.h
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
@ -346,6 +421,13 @@ EXAMPLE_PATH = @top_srcdir@/docs
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude
# commands irrespective of the value of the RECURSIVE tag.
# Possible values are YES and NO. If left blank NO is used.
EXAMPLE_RECURSIVE = NO
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
@ -363,10 +445,48 @@ INPUT_FILTER =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse.
# files to browse (i.e. when SOURCE_BROWSER is set to YES).
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
SOURCE_BROWSER = NO
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
STRIP_CODE_COMMENTS = YES
# If the REFERENCED_BY_RELATION tag is set to YES (the default)
# then for each documented function all documented
# functions referencing it will be listed.
REFERENCED_BY_RELATION = YES
# If the REFERENCES_RELATION tag is set to YES (the default)
# then for each documented function all documented entities
# called/used by that function will be listed.
REFERENCES_RELATION = YES
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
@ -403,7 +523,13 @@ GENERATE_HTML = YES
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
HTML_OUTPUT =
HTML_OUTPUT =
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
# doxygen will generate files with .html extension.
HTML_FILE_EXTENSION = .html
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
@ -417,7 +543,7 @@ HTML_HEADER =
HTML_FOOTER =
# The HTML_STYLESHEET tag can be used to specify a user defined cascading
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet
@ -437,6 +563,20 @@ HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
# be used to specify the file name of the resulting .chm file. You
# can add a path in front of the file if the result should not be
# written to the html output dir.
CHM_FILE =
# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
# be used to specify the location (absolute path including file name) of
# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
# the HTML help compiler on the generated index.hhp.
HHC_LOCATION =
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
@ -450,7 +590,7 @@ GENERATE_CHI = NO
BINARY_TOC = NO
# The TOC_EXPAND flag can be set to YES to add extra items for group members
# to the contents of the Html help documentation and to the tree view.
# to the contents of the HTML help documentation and to the tree view.
TOC_EXPAND = NO
@ -468,8 +608,9 @@ ENUM_VALUES_PER_LINE = 4
# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
# generated containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript and frames is required (for instance Netscape 4.0+
# or Internet explorer 4.0+).
# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
# probably better off using the HTML help feature.
GENERATE_TREEVIEW = NO
@ -492,7 +633,18 @@ GENERATE_LATEX = YES
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
LATEX_OUTPUT =
LATEX_OUTPUT =
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked. If left blank `latex' will be used as the default command name.
LATEX_CMD_NAME = latex
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
# generate index for LaTeX. If left blank `makeindex' will be used as the
# default command name.
MAKEINDEX_CMD_NAME = makeindex
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
@ -538,6 +690,12 @@ USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
# If LATEX_HIDE_INDICES is set to YES then doxygen will not
# include the index chapters (such as File Index, Compound Index, etc.)
# in the output.
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
@ -593,17 +751,17 @@ GENERATE_MAN = NO
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
MAN_OUTPUT =
MAN_OUTPUT =
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
MAN_EXTENSION =
# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
# then it will generate one additional man file for each entity
# documented in the real man page(s). These additional files
# only source the real man page, but without them the man command
# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
# then it will generate one additional man file for each entity
# documented in the real man page(s). These additional files
# only source the real man page, but without them the man command
# would be unable to find the correct page. The default is NO.
MAN_LINKS = NO
@ -620,6 +778,69 @@ MAN_LINKS = NO
GENERATE_XML = NO
# The XML_OUTPUT tag is used to specify where the XML pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `xml' will be used as the default path.
XML_OUTPUT = xml
# The XML_SCHEMA tag can be used to specify an XML schema,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_SCHEMA =
# The XML_DTD tag can be used to specify an XML DTD,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_DTD =
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
# generate an AutoGen Definitions (see autogen.sf.net) file
# that captures the structure of the code including all
# documentation. Note that this feature is still experimental
# and incomplete at the moment.
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
# If the GENERATE_PERLMOD tag is set to YES Doxygen will
# generate a Perl module file that captures the structure of
# the code including all documentation. Note that this
# feature is still experimental and incomplete at the
# moment.
GENERATE_PERLMOD = NO
# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
# the necessary Makefile rules, Perl scripts and LaTeX code to be able
# to generate PDF and DVI output from the Perl module output.
PERLMOD_LATEX = NO
# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
# nicely formatted so it can be parsed by a human reader. This is useful
# if you want to understand what is going on. On the other hand, if this
# tag is set to NO the size of the Perl module output will be much smaller
# and Perl will parse it just the same.
PERLMOD_PRETTY = YES
# The names of the make variables in the generated doxyrules.make file
# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
# This is useful so different doxyrules.make files included by the same
# Makefile don't overwrite each other's variables.
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
@ -635,7 +856,7 @@ ENABLE_PREPROCESSING = YES
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = YES
MACRO_EXPANSION = NO
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
@ -667,20 +888,41 @@ INCLUDE_FILE_PATTERNS =
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed.
PREDEFINED =
PREDEFINED = __cplusplus MP_WBITS=@MP_WBITS@
# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all function-like macros that are alone
# on a line, have an all uppercase name, and do not end with a semicolon. Such
# function macros are typically used for boiler-plate code, and will confuse the
# parser if not removed.
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
# The TAGFILES tag can be used to specify one or more tagfiles.
# The TAGFILES option can be used to specify one or more tagfiles.
# Optionally an initial location of the external documentation
# can be added for each tagfile. The format of a tag file without
# this location is as follows:
# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows:
# TAGFILES = file1=loc1 "file2 = loc2" ...
# where "loc1" and "loc2" can be relative or absolute paths or
# URLs. If a location is present for each tag, the installdox tool
# does not have to be run to correct the links.
# Note that each tag file must have a unique name
# (where the name does NOT include the path)
# If a tag file is not located in the directory in which doxygen
# is run, you must also specify the path to the tagfile here.
TAGFILES =
@ -695,6 +937,12 @@ GENERATE_TAGFILE =
ALLEXTERNALS = NO
# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
# in the modules index. If set to NO, only the current project's groups will
# be listed.
EXTERNAL_GROUPS = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
@ -704,12 +952,26 @@ PERL_PATH = /usr/bin/perl
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or
# super classes. Setting the tag to NO turns the diagrams off. Note that this
# option is superceded by the HAVE_DOT option below. This is only a fallback. It is
# recommended to install and use dot, since it yields more powerful graphs.
CLASS_DIAGRAMS = YES
# If set to YES, the inheritance and collaboration graphs will hide
# inheritance and usage relations if the target is undocumented
# or is not a class.
HIDE_UNDOC_RELATIONS = YES
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = NO
HAVE_DOT = YES
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
@ -725,6 +987,12 @@ CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
# collaboration diagrams in a style similiar to the OMG's Unified Modeling
# Language.
UML_LOOK = NO
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
@ -744,11 +1012,25 @@ INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
# generate a call dependency graph for every global function or class method.
# Note that enabling this option will significantly increase the time of a run.
# So in most cases it will be better to enable call graphs for selected
# functions only using the \callgraph command.
CALL_GRAPH = NO
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
GRAPHICAL_HIERARCHY = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. Possible values are png, jpg, or gif
# If left blank png will be used.
DOT_IMAGE_FORMAT = png
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found on the path.
@ -776,6 +1058,17 @@ MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
# graphs generated by dot. A depth value of 3 means that only nodes reachable
# from the root by following a path via at most 3 edges will be shown. Nodes that
# lay further from the root node will be omitted. Note that setting this option to
# 1 or 2 may greatly reduce the computation time needed for large code bases. Also
# note that a graph may be further truncated if the graph's image dimensions are
# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT).
# If 0 is used for the depth value (the default), the graph is not depth-constrained.
MAX_DOT_GRAPH_DEPTH = 0
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
@ -783,7 +1076,7 @@ MAX_DOT_GRAPH_HEIGHT = 1024
GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermedate dot files that are used to generate
# remove the intermediate dot files that are used to generate
# the various graphs.
DOT_CLEANUP = YES
@ -796,38 +1089,3 @@ DOT_CLEANUP = YES
# used. If set to NO the values of all tags below this one will be ignored.
SEARCHENGINE = NO
# The CGI_NAME tag should be the name of the CGI script that
# starts the search engine (doxysearch) with the correct parameters.
# A script with this name will be generated by doxygen.
CGI_NAME =
# The CGI_URL tag should be the absolute URL to the directory where the
# cgi binaries are located. See the documentation of your http daemon for
# details.
CGI_URL =
# The DOC_URL tag should be the absolute URL to the directory where the
# documentation is located. If left blank the absolute path to the
# documentation, with file:// prepended to it, will be used.
DOC_URL =
# The DOC_ABSPATH tag should be the absolute path to the directory where the
# documentation is located. If left blank the directory on the local machine
# will be used.
DOC_ABSPATH =
# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
# is installed.
BIN_ABSPATH = /usr/bin
# The EXT_DOC_PATHS tag can be used to specify one or more paths to
# documentation generated for other projects. This allows doxysearch to search
# the documentation for these projects as well.
EXT_DOC_PATHS =

View File

@ -3,7 +3,8 @@
BeeCrypt started its life when the need for a portable and fast cryptography
library arose at Virtual Unlimited in 1997. I'm still trying to make it
faster, easier to use and more portable, in addition to providing better
documentation.
documentation. The library is currently in full swing again, thanks to the
Beeyond Software Holding BV.
BeeCrypt is released under the following license:
@ -26,58 +27,82 @@ cryptography may be limited or forbidden by law. Before using this library,
make sure you are legally entitled to do so.
Included in the library are:
- entropy sources for initializing pseudo-random generators
- pseudo-random generators
- FIPS-186
- Mersenne Twister
- block ciphers
- AES
- Blowfish
- hash functions
- MD5
- SHA-1
- SHA-256
- keyed hash functions (a.k.a. message authentication codes)
- HMAC-MD5
- HMAC-SHA-1
- HMAC-SHA-256
- multi-precision integer library, with assembler-optimized routines
for a range of processors; optimized to perform well on both 32-bit
and 64-bit machines
- probabilistic primality testing, with optimized small prime trial
division
- discrete logarithm parameter generation over a prime field
- Diffie-Hellman key agreement
- DHAES encryption scheme
- DSA signature scheme
- ElGamal signature scheme (two variants)
- RSA keypair generation with chinese remainder theorem variables
- RSA public & private key operations
<ul>
<li>entropy sources for initializing pseudo-random generators
<li>pseudo-random generators
<ul>
<li>FIPS-186
</ul>
<li>block ciphers
<ul>
<li>AES
<li>Blowfish
</ul>
<li>hash functions
<ul>
<li>MD5
<li>SHA-1
<li>SHA-256
</ul>
<li>keyed hash functions (a.k.a. message authentication codes)
<ul>
<li>HMAC-MD5
<li>HMAC-SHA-1
<li>HMAC-SHA-256
</ul>
<li>multi-precision integer library, with assembler-optimized routines
for a range of processors; optimized to perform well on both 32-bit
and 64-bit machines; uses Barrett modular reduction instead of the
more common usual Montgomery algorithm; also implements sliding
windows.
<li>probabilistic primality testing, with optimized small prime trial
division
<li>discrete logarithm parameter generation over a prime field
<li>Diffie-Hellman key agreement
<li>DHAES encryption scheme
<li>DSA signature scheme
<li>ElGamal signature scheme (two variants)
<li>RSA keypair generation with chinese remainder theorem variables
<li>RSA public & private key operations
</ul>
Planned for the near future are:
- compliance with and compliance statements for IEEE P1363
- more blockciphers (Twofish, ... )
- more hash functions (RIPEMD-160, SHA-384, SHA-512, HAVAL, Tiger)
- RSA signatures as specified by RFC-2440.
- Elliptic Curves (ECDSA, ... )
- more blockcipher modes (OFB, ... )
A new feature in version 4.x is the C++ API, built to resemble Java's security
and cryptography API. At this moment the number of classes provided is just
enough to build CSPs. If there is enough interest, we may expand this library.
Planned for the future are:
<ul>
<li>compliance with and compliance statements for IEEE P1363
<li>more blockciphers (Twofish, ... )
<li>more blockcipher modes (CTR, OFB, ... )
<li>more hash functions (RIPEMD-160, SHA-384, SHA-512, HAVAL, Tiger)
<li>RSA signatures as specified by RFC-2440.
<li>Elliptic Curves (ECDSA, ... )
</ul>
The library has been tested on the following platforms:
- Linux glibc 2.x alpha
- Linux glibc 2.x arm
- Linux glibc 2.x ia64
- Linux glibc 2.x m68k
- Linux glibc 2.x ppc
- Linux glibc 2.x s390x
- Linux glibc 2.x sparc
- Linux glibc 2.x x86
- Solaris 2.[6789] sparc (with Forte or GNU compilers)
- Solaris 2.[78] x86 (with Forte or GNU compilers)
- Tru64 Unix alpha
- Win32 (Windows 95, 98, NT 4.0, 2000, XP)
- AIX (shared libraries don't seem to work in 64-bit mode)
- Darwin (javaglue doesn't compile yet)
- Cygwin (the DLL builds now, but needs to be tested)
<ul>
<li>Darwin
<li>Linux glibc 2.x alpha
<li>Linux glibc 2.x arm
<li>Linux glibc 2.x ia64
<li>Linux glibc 2.x m68k
<li>Linux glibc 2.x ppc
<li>Linux glibc 2.x s390x
<li>Linux glibc 2.x sparc
<li>Linux glibc 2.x x86
<li>Linux glibc 2.x x86_64
<li>Solaris 2.[6789] sparc (with Forte or GNU compilers)
<li>Solaris 2.[78] x86 (with Forte or GNU compilers)
<li>Tru64 Unix alpha
<li>Win32 (Windows 95, 98, NT 4.0, 2000, XP)
</ul>
The library is currently in the process of being ported to:
<ul>
<li>AIX (shared libraries don't seem to work in 64-bit mode)
<li>Cygwin (the DLL builds now, but needs to be tested)
</ul>
The structures in the library are geared towards exchange with Java
and its security and cryptography classes. This library can also be
@ -86,63 +111,91 @@ provider and the counterpart of this library.
*/
/*! \defgroup ES_m Entropy sources
/*!\defgroup ES_m Entropy sources
*/
/*! \defgroup ES_audio_m Entropy sources: /dev/audio
/*!\defgroup ES_audio_m Entropy sources: /dev/audio
*/
/*! \defgroup ES_dsp_m Entropy sources: /dev/dsp
/*!\defgroup ES_dsp_m Entropy sources: /dev/dsp
*/
/*! \defgroup ES_random_m Entropy sources: /dev/random
/*!\defgroup ES_random_m Entropy sources: /dev/random
*/
/*! \defgroup ES_urandom_m Entropy sources: /dev/urandom
/*!\defgroup ES_urandom_m Entropy sources: /dev/urandom
*/
/*! \defgroup ES_tty_m Entropy sources: /dev/tty
/*!\defgroup ES_tty_m Entropy sources: /dev/tty
*/
/*! \defgroup PRNG_m Pseudo-Random Number Generators
/*!\defgroup PRNG_m Pseudo-Random Number Generators
*/
/*! \defgroup PRNG_fips186_m Pseudo-Random Number Generators: FIPS-186
/*!\defgroup PRNG_fips186_m Pseudo-Random Number Generators: FIPS-186
*/
/*! \defgroup PRNG_mt_m Pseudo-Random Number Generators: Mersenne Twister
/*!\defgroup PRNG_mt_m Pseudo-Random Number Generators: Mersenne Twister
*/
/*! \defgroup HASH_m Hash Functions
/*!\defgroup HASH_m Hash Functions
*/
/*! \defgroup HASH_md5_m Hash Functions: MD5
/*!\defgroup HASH_md5_m Hash Functions: MD5
*/
/*! \defgroup HASH_sha1_m Hash Functions: SHA-1
/*!\defgroup HASH_sha1_m Hash Functions: SHA-1
*/
/*! \defgroup HASH_sha256_m Hash Functions: SHA-256
/*!\defgroup HASH_sha256_m Hash Functions: SHA-256
*/
/*! \defgroup HMAC_m Keyed Hash Functions, a.k.a. Message Authentication Codes
/*!\defgroup HMAC_m Keyed Hash Functions, a.k.a. Message Authentication Codes
*/
/*! \defgroup HMAC_md5_m Keyed Hash Functions: HMAC-MD5
/*!\defgroup HMAC_md5_m Keyed Hash Functions: HMAC-MD5
*/
/*! \defgroup HMAC_sha1_m Keyed Hash Functions: HMAC-SHA-1
/*!\defgroup HMAC_sha1_m Keyed Hash Functions: HMAC-SHA-1
*/
/*! \defgroup HMAC_sha256_m Keyed Hash Functions: HMAC-SHA-256
/*!\defgroup HMAC_sha256_m Keyed Hash Functions: HMAC-SHA-256
*/
/*! \defgroup BC_m Block ciphers
/*!\defgroup BC_m Block ciphers
*/
/*! \defgroup BC_aes_m Block ciphers: AES
/*!\defgroup BC_aes_m Block ciphers: AES
*/
/*! \defgroup BC_blowfish_m Block ciphers: Blowfish
/*!\defgroup BC_blowfish_m Block ciphers: Blowfish
*/
/*! \defgroup MP_m Multiple Precision Integer Arithmetic
/*!\defgroup MP_m Multiple Precision Integer Arithmetic
*/
/*! \defgroup DL_m Discrete Logarithm Primitives
/*!\defgroup DL_m Discrete Logarithm Primitives
*/
/*! \defgroup DL_dh_m Discrete Logarithm Primitives: Diffie-Hellman
/*!\defgroup DL_dh_m Discrete Logarithm Primitives: Diffie-Hellman
*/
/*! \defgroup DL_dsa_m Discrete Logarithm Primitives: DSA
/*!\defgroup DL_dsa_m Discrete Logarithm Primitives: DSA
*/
/*! \defgroup DL_elgamal_m Discrete Logarithm Primitives: ElGamal
/*!\defgroup DL_elgamal_m Discrete Logarithm Primitives: ElGamal
*/
/*! \defgroup IF_m Integer Factorization Primitives
/*!\defgroup IF_m Integer Factorization Primitives
*/
/*! \defgroup IF_rsa_m Integer Factorization Primitives: RSA
/*!\defgroup IF_rsa_m Integer Factorization Primitives: RSA
*/
/*! \defgroup JAVA_m Java API
/*!\defgroup PKCS1_m PKCS#1
*/
/*! \defgroup UNIT_m Unit tests
/*!\defgroup PKCS12_m PKCS#12
*/
/*! \defgroup BENCH_m Benchmark tests
/*!\defgroup CXX_m C++ API
*/
/*!\defgroup CXX_CRYPTO_m C++ classes mimicking javax.crypto
*/
/*!\defgroup CXX_CRYPTO_INTERFACES_m C++ classes mimicking javax.crypto.interfaces
*/
/*!\defgroup CXX_CRYPTO_SPEC_m C++ classes mimicking javax.crypto.spec
*/
/*!\defgroup CXX_IO_m C++ classes mimicking java.io
*/
/*!\defgroup CXX_LANG_m C++ classes mimicking java.lang
*/
/*!\defgroup CXX_PROV_m C++ Base Cryptographic Service Provider
*/
/*!\defgroup CXX_SECURITY_m C++ classes mimicking java.security
*/
/*!\defgroup CXX_SECURITY_CERT_m C++ classes mimicking java.security.cert
*/
/*!\defgroup CXX_SECURITY_INTERFACES_m C++ classes mimicking java.security.interfaces
*/
/*!\defgroup CXX_SECURITY_SPEC_m C++ classes mimicking java.security.spec
*/
/*!\defgroup CXX_UTIL_m C++ classes mimicking java.util
*/
/*!\defgroup JAVA_m Java API
*/
/*!\defgroup UNIT_m Unit tests
*/
/*!\defgroup BENCH_m Benchmark tests
*/

View File

@ -28,72 +28,39 @@
# 3. Interfaces removed (bad): Increment CURRENT, set AGE and REVISION to 0.
#
LIBBEECRYPT_LT_CURRENT = 6
LIBBEECRYPT_LT_AGE = 0
LIBBEECRYPT_LT_CURRENT = 8
LIBBEECRYPT_LT_AGE = 2
LIBBEECRYPT_LT_REVISION = 0
AUTOMAKE_OPTIONS = gnu check-news no-dependencies
LINT = splint
SUBDIRS = . docs gas masm tests $(MAYBE_OPT)
SUBDIRS = . $(MAYBE_SUB) tests docs gas masm
SUFFIXES = .s
INCLUDES = -I$(top_srcdir)/..
.s.lo:
$(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$<
BEECRYPT_OBJECTS = aes.lo aesopt.lo base64.lo beecrypt.lo blockmode.lo blockpad.lo blowfish.lo blowfishopt.lo dhaes.lo dldp.lo dlkp.lo dlpk.lo dlsvdp-dh.lo dsa.lo elgamal.lo endianness.lo entropy.lo fips186.lo hmac.lo hmacmd5.lo hmacsha1.lo hmacsha256.lo md5.lo memchunk.lo mp.lo mpbarrett.lo mpnumber.lo mpopt.lo mpprime.lo mtprng.lo rsa.lo rsakp.lo rsapk.lo sha1.lo sha1opt.lo sha256.lo timestamp.lo
BEECRYPT_OBJECTS = aes.lo aesopt.lo base64.lo beecrypt.lo blockmode.lo blockpad.lo blowfish.lo blowfishopt.lo dhaes.lo dldp.lo dlkp.lo dlpk.lo dlsvdp-dh.lo dsa.lo elgamal.lo endianness.lo entropy.lo fips186.lo hmac.lo hmacmd5.lo hmacsha1.lo hmacsha256.lo md5.lo memchunk.lo mp.lo mpopt.lo mpbarrett.lo mpnumber.lo mpprime.lo mtprng.lo pkcs1.lo pkcs12.lo rsa.lo rsakp.lo rsapk.lo sha1.lo sha1opt.lo sha256.lo timestamp.lo
libaltdir = $(libdir)@LIBALT@
libaltdir=$(prefix)/lib@LIBALT@
libalt_LTLIBRARIES = libbeecrypt.la
libbeecrypt_la_SOURCES = aes.c base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhaes.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha256.c md5.c memchunk.c mp.c mpbarrett.c mpnumber.c mpprime.c mtprng.c rsa.c rsakp.c rsapk.c sha1.c sha256.c timestamp.c
libbeecrypt_la_SOURCES = aes.c base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhaes.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha256.c md5.c memchunk.c mp.c mpbarrett.c mpnumber.c mpprime.c mtprng.c pkcs1.c pkcs12.c rsa.c rsakp.c rsapk.c sha1.c sha256.c timestamp.c cppglue.cxx
libbeecrypt_la_DEPENDENCIES = $(BEECRYPT_OBJECTS)
libbeecrypt_la_LIBADD = aesopt.lo blowfishopt.lo mpopt.lo sha1opt.lo
libbeecrypt_la_LDFLAGS = -no-undefined -version-info $(LIBBEECRYPT_LT_CURRENT):$(LIBBEECRYPT_LT_REVISION):$(LIBBEECRYPT_LT_AGE)
pkginclude_HEADERS = aes.h base64.h beecrypt.h beecrypt.api.h beecrypt.gnu.h blockmode.h blockpad.h blowfish.h dhaes.h dldp.h dlkp.h dlpk.h dlsvdp-dh.h dsa.h elgamal.h endianness.h entropy.h fips186.h hmac.h hmacmd5.h hmacsha1.h hmacsha256.h md5.h memchunk.h mp.h mpbarrett.h mpnumber.h mpprime.h mtprng.h rsa.h rsakp.h rsapk.h sha1.h sha256.h timestamp.h
pkginclude_HEADERS = aes.h aesopt.h api.h base64.h beecrypt.h blockmode.h blockpad.h blowfish.h blowfishopt.h dhaes.h dldp.h dlkp.h dlpk.h dlsvdp-dh.h dsa.h elgamal.h endianness.h entropy.h fips186.h gnu.h hmac.h hmacmd5.h hmacsha1.h hmacsha256.h md5.h memchunk.h mp.h mpbarrett.h mpnumber.h mpopt.h mpprime.h mtprng.h pkcs1.h pkcs12.h rsa.h rsakp.h rsapk.h sha1.h sha1opt.h sha256.h timestamp.h win.h
noinst_HEADERS = aes_be.h aes_le.h aesopt.h beecrypt.win.h \
blowfishopt.h debug.h mpopt.h sha1opt.h system.h
noinst_HEADERS = aes_be.h aes_le.h
EXTRA_DIST = BENCHMARKS BUGS CONTRIBUTORS Doxyfile.in Doxyheader README README.DLL README.WIN32 beecrypt.gnu.h.in beecrypt.rc beecrypt.spec autogen.sh Makefile.mak
EXTRA_DIST = BENCHMARKS BUGS CONTRIBUTORS README.DLL README.WIN32 Doxyheader beecrypt.rc autogen.sh Makefile.mak
DISTCLEANFILES = mpopt.s aesopt.s blowfishopt.s sha1opt.s
bench:
(cd tests && $(MAKE) $(AM_MAKEFLAGS) bench)
.PHONY: beetest
beetest: all
${MAKE} -C tests beetest
./tests/beetest
beecrypt.lcd: Makefile.am ${libbeecrypt_la_SOURCES} ${pkginclude_HEADERS} ${noinst_HEADERS}
lclint $(DEFS) $(INCLUDES) ${libbeecrypt_la_SOURCES} -dump $@
# XXX don't bite into gcj java dependencies (yet)
.PHONY: sources
sources:
@echo $(libbeecrypt_la_SOURCES:%=beecrypt/%) | sed -e 's,beecrypt/javaglue.c,,'
# XXX don't bite into javaglue.c (yet)
.PHONY: lint
lint:
$(LINT) $(DEFS) $(INCLUDES) $(libbeecrypt_la_SOURCES:javaglue.c=) tests/beetest.c
.PHONY: listobjs
listobjs:
@echo $(BEECRYPT_OBJECTS) > $@
DOXYGEN = /usr/bin/doxygen
.PHONY: doxygen
doxygen apidocs: Doxyfile Doxyheader
rm -rf $@
mkdir -p $@
- [ -x ${DOXYGEN} ] && ${DOXYGEN}

View File

@ -1,4 +1,23 @@
3.0.0pre:
4.0.0:
- Added a C++ API interface, modeled after Java's security & crypto API.
- Added the new GNU noexecstack feature.
- Added more x86_64 and s390x assembler routines.
- Modified i2osp, so that it only requires as many octets as there are
significant bytes in the multi-precision integers.
- Fixed a bug in the creation of rsa keypairs; code was not correctly
migrated to new calling sequence. The code now implements the method
described in IEEE P.1363.
- Fixed another bug in mpextgcd_w which sometimes returned incorrect
results.
- Fixed a bug in mprshiftlsz, which didn't work correctly when size = 1.
- Fixed a configuration problem on Tru64 Unix.
3.1.0:
- Added wiping of private key components of keypairs before freeing.
- Fixed bug in mpextgcd_w which sometimes returned incorrect result.
- Fixed error in PowerPC 64-bit assembler symbol definitions.
3.0.0:
- Cleaned up installed header files.
- Modified the API so that all keys can be passed as arrays of bytes.
- Modified the API so that all key sizes are given in bits.
@ -11,7 +30,10 @@
- Added multi-precision integer assembler routines for PowerPC 64-bit.
- Added multi-precision integer assembler routines for Alpha.
- Added multi-precision integer assembler routines for Opteron.
- Added multi-precision integer assembler routines for IBM zSeries 64-bit.
- Added multi-precision integer assembler routines for M68K.
- Added Jeff Johnson's python bindings.
- Added new unit tests.
- Added new benchmarking programs.
2.3.0pre:

View File

@ -109,6 +109,7 @@ Planned for the near future are:
The library has been tested on the following platforms:
- AIX 5.1 ppc
- AIX 5.1 ppc64
- Darwin 6.5 (a.k.a. MacOS X 10.2)
- FreeBSD 4.0 alpha
- FreeBSD 4.0, 4.2 x86
- Linux glibc 2.x alpha
@ -123,8 +124,6 @@ The library has been tested on the following platforms:
- Win32 (Windows 95, 98, NT 4.0, 2000, XP)
The library is currently in the process of being ported to:
- Darwin (apparently Apple has decided to change the PPC assembler format;
this will need a fix)
- Cygwin (Can't seem to get the DLL to build properly with the current
version of the autotools)
- HP/UX is a pain in the backside; I'll try getting it working, but the
@ -135,7 +134,7 @@ For more information, refer to the HTML documentation in the docs directory.
If you want to report bugs, make suggestions, contribute fixes or
enhancements, please see the beecrypt-specific website:
http://beecrypt.virtualunlimited.com/
http://sourceforge.net/projects/beecrypt
or contact me at mailto:bob.deblier@pandora.be

View File

@ -8,8 +8,143 @@ dnl
dnl LGPL
dnl BEECRYPT_WITH_CPU
AC_DEFUN([BEECRYPT_WITH_CPU],[
ac_with_cpu=yes
bc_target_cpu=$withval
case $target_cpu in
i[[3456]]86)
case $withval in
i[[3456]]86 | \
pentium | pentium-mmx | pentiumpro | pentium[[234]] | \
athlon | athlon-tbird | athlon-4 | athlon-xp | athlon-mp)
;;
*)
AC_MSG_WARN([invalid cpu type])
bc_target_cpu=$target_cpu
;;
esac
;;
powerpc | powerpc64)
case $withval in
403 | 505 | \
60[[1234]] | 60[[34]]e | 6[[23]]0 | \
7[[45]]0 | 74[[05]]0 | \
801 | 82[[13]] | 860 | \
power | power2 | powerpc | powerpc64)
;;
*)
AC_MSG_WARN([invalid cpu type])
bc_target_cpu=$target_cpu
;;
esac
;;
sparc | sparc64)
case $withval in
sparcv8 | sparcv8plus | sparcv8plus[[ab]] | sparcv9 | sparcv9[[ab]])
;;
*)
AC_MSG_WARN([invalid cpu type])
bc_target_cpu=$target_cpu
;;
esac
;;
x86) # QNX Neutrino doesn't list the exact cpu type
case $withval in
i[[3456]]86)
;;
*)
AC_MSG_WARN([unsupported or invalid cpu type])
bc_target_cpu=$target_cpu
;;
esac
;;
*)
AC_MSG_WARN([unsupported or invalid cpu type])
bc_target_cpu=$target_cpu
;;
esac
])
dnl BEECRYPT_WITHOUT_CPU
AC_DEFUN([BEECRYPT_WITHOUT_CPU],[
ac_with_cpu=no
bc_target_cpu=$target_cpu
])
dnl BEECRYPT_WITH_ARCH
AC_DEFUN([BEECRYPT_WITH_ARCH],[
ac_with_arch=yes
bc_target_arch=$withval
case $target_cpu in
i[[3456]]86)
case $withval in
i[[3456]]86 | \
pentium | pentium-mmx | pentiumpro | pentium[[234]] | \
athlon | athlon-tbird | athlon-4 | athlon-xp | athlon-mp)
if test "$ac_with_cpu" != yes; then
bc_target_cpu=$withval
fi
;;
esac
;;
powerpc*)
case $withval in
powerpc)
;;
powerpc64)
bc_target_arch=powerpc64
;;
*)
AC_MSG_WARN([unsupported on invalid arch type])
bc_target_arch=powerpc
;;
esac
;;
esac
])
dnl BEECRYPT_WITHOUT_ARCH
AC_DEFUN([BEECRYPT_WITHOUT_ARCH],[
ac_with_arch=no
case $target_cpu in
alpha*)
bc_target_arch=alpha
;;
arm*)
bc_target_arch=arm
;;
i[[3456]]86)
bc_target_arch=i386
;;
ia64)
bc_target_arch=ia64
;;
m68k)
bc_target_arch=m68k
;;
powerpc)
bc_target_arch=powerpc
;;
powerpc64)
bc_target_arch=powerpc64
;;
s390x)
bc_target_arch=s390x
;;
sparc*)
bc_target_arch=sparc
;;
x86_64)
bc_target_arch=x86_64
;;
esac
])
dnl BEECRYPT_INT_TYPES
AC_DEFUN(BEECRYPT_INT_TYPES,[
AC_DEFUN([BEECRYPT_INT_TYPES],[
AC_TYPE_SIZE_T
bc_typedef_size_t=
if test $ac_cv_type_size_t != yes; then
@ -112,7 +247,7 @@ AC_DEFUN(BEECRYPT_INT_TYPES,[
dnl BEECRYPT_CPU_BITS
AC_DEFUN(BEECRYPT_CPU_BITS,[
AC_DEFUN([BEECRYPT_CPU_BITS],[
AC_CHECK_SIZEOF([unsigned long])
if test $ac_cv_sizeof_unsigned_long -eq 8; then
AC_SUBST(MP_WBITS,64U)
@ -125,7 +260,7 @@ AC_DEFUN(BEECRYPT_CPU_BITS,[
dnl BEECRYPT_WORKING_AIO
AC_DEFUN(BEECRYPT_WORKING_AIO,[
AC_DEFUN([BEECRYPT_WORKING_AIO],[
AC_CHECK_HEADERS(aio.h)
if test "$ac_cv_header_aio_h" = yes; then
AC_SEARCH_LIBS([aio_read],[c rt aio posix4],[
@ -214,7 +349,7 @@ main()
case $target_os in
linux* | solaris*)
bc_cv_working_aio=yes ;;
*)
*)
bc_cv_working_aio=no ;;
esac
])
@ -228,7 +363,7 @@ main()
dnl BEECRYPT_CFLAGS_REM
AC_DEFUN(BEECRYPT_CFLAGS_REM,[
AC_DEFUN([BEECRYPT_CFLAGS_REM],[
if test "$CFLAGS" != ""; then
CFLAGS_save=""
for flag in $CFLAGS
@ -242,8 +377,23 @@ AC_DEFUN(BEECRYPT_CFLAGS_REM,[
])
dnl BEECRYPT_CXXFLAGS_REM
AC_DEFUN([BEECRYPT_CXXFLAGS_REM],[
if test "$CXXFLAGS" != ""; then
CXXFLAGS_save=""
for flag in $CXXFLAGS
do
if test "$flag" != "$1"; then
CXXFLAGS_save="$CXXFLAGS_save $flag"
fi
done
CXXFLAGS="$CXXFLAGS_save"
fi
])
dnl BEECRYPT_GNU_CC
AC_DEFUN(BEECRYPT_GNU_CC,[
AC_DEFUN([BEECRYPT_GNU_CC],[
AC_REQUIRE([AC_PROG_CC])
case $bc_target_arch in
ia64)
@ -263,7 +413,6 @@ AC_DEFUN(BEECRYPT_GNU_CC,[
case $target_os in
aix*)
CC="$CC -maix64"
LDFLAGS="$LDFLAGS -b64"
;;
esac
;;
@ -276,6 +425,10 @@ AC_DEFUN(BEECRYPT_GNU_CC,[
CPPFLAGS="$CPPFLAGS -pthread"
LDFLAGS="$LDFLAGS -pthread"
;;
osf*)
CFLAGS="$CFLAGS -pthread"
CPPFLAGS="$CPPFLAGS -pthread"
;;
esac
fi
if test "$ac_enable_debug" = yes; then
@ -286,56 +439,147 @@ AC_DEFUN(BEECRYPT_GNU_CC,[
BEECRYPT_CFLAGS_REM([-g])
BEECRYPT_CFLAGS_REM([-O2])
CFLAGS="$CFLAGS -O3 -fomit-frame-pointer"
case $bc_target_cpu in
athlon*)
CFLAGS="$CFLAGS -mcpu=pentiumpro";
;;
i586)
CFLAGS="$CFLAGS -mcpu=pentium"
;;
i686)
CFLAGS="$CFLAGS -mcpu=pentiumpro"
;;
ia64)
# no -mcpu=... option on ia64
;;
pentium*)
CFLAGS="$CFLAGS -mcpu=$bc_target_arch"
if test "$bc_cv_c_aggressive_opt" = yes; then
case $bc_target_cpu in
athlon*)
CFLAGS="$CFLAGS -mcpu=pentiumpro";
;;
i586)
CFLAGS="$CFLAGS -mcpu=pentium"
;;
i686)
CFLAGS="$CFLAGS -mcpu=pentiumpro"
;;
ia64)
# no -mcpu=... option on ia64
;;
pentium*)
CFLAGS="$CFLAGS -mcpu=$bc_target_arch"
;;
esac
# Architecture-specific optimizations
case $bc_target_arch in
athlon*)
CFLAGS="$CFLAGS -march=$bc_target_arch"
;;
i586)
CFLAGS="$CFLAGS -march=pentium"
;;
i686)
CFLAGS="$CFLAGS -march=pentiumpro"
;;
pentium*)
CFLAGS="$CFLAGS -march=$bc_target_arch"
;;
powerpc | powerpc64)
CFLAGS="$CFLAGS -mcpu=$bc_target_arch"
;;
sparcv8)
CFLAGS="$CFLAGS -mv8"
;;
sparcv8plus)
CFLAGS="$CFLAGS -mv8plus"
;;
esac
fi
fi
])
dnl BEECRYPT_GNU_CXX
AC_DEFUN([BEECRYPT_GNU_CXX],[
AC_REQUIRE([AC_PROG_CXX])
case $bc_target_arch in
ia64)
case $target_os in
# HP/UX on Itanium needs to be told that a long is 64-bit!
hpux*)
CXXFLAGS="$CXXFLAGS -mlp64"
;;
esac
# Architecture-specific optimizations
case $bc_target_arch in
athlon*)
CFLAGS="$CFLAGS -march=$bc_target_arch"
;;
i586)
CFLAGS="$CFLAGS -march=pentium"
;;
i686)
CFLAGS="$CFLAGS -march=pentiumpro"
;;
pentium*)
CFLAGS="$CFLAGS -march=$bc_target_arch"
;;
powerpc)
CFLAGS="$CFLAGS -mcpu=powerpc"
;;
powerpc64)
CFLAGS="$CFLAGS -mcpu=powerpc64"
;;
sparcv8)
CFLAGS="$CFLAGS -mv8"
;;
sparcv8plus)
CFLAGS="$CFLAGS -mv8plus"
;;
# PowerPC needs a signed char
powerpc)
CXXFLAGS="$CXXFLAGS -fsigned-char"
;;
powerpc64)
CXXFLAGS="$CXXFLAGS -fsigned-char"
case $target_os in
aix*)
CXX="$CXX -maix64"
;;
esac
;;
esac
# Certain platforms needs special flags for multi-threaded code
if test "$ac_enable_threads" = yes; then
case $target_os in
freebsd*)
CXXFLAGS="$CXXFLAGS -pthread"
CXXCPPFLAGS="$CXXCPPFLAGS -pthread"
LDFLAGS="$LDFLAGS -pthread"
;;
osf*)
CXXFLAGS="$CXXFLAGS -pthread"
CXXCPPFLAGS="$CXXCPPFLAGS -pthread"
;;
esac
fi
if test "$ac_enable_debug" = yes; then
BEECRYPT_CXXFLAGS_REM([-O2])
CXXFLAGS="$CXXFLAGS -Wall -pedantic"
else
# Generic optimizations, including cpu tuning
BEECRYPT_CXXFLAGS_REM([-g])
if test "$bc_cv_c_aggressive_opt" = yes; then
case $bc_target_cpu in
athlon*)
CXXFLAGS="$CXXFLAGS -mcpu=pentiumpro";
;;
i586)
CXXFLAGS="$CXXFLAGS -mcpu=pentium"
;;
i686)
CXXFLAGS="$CXXFLAGS -mcpu=pentiumpro"
;;
ia64)
# no -mcpu=... option on ia64
;;
pentium*)
CXXFLAGS="$CXXFLAGS -mcpu=$bc_target_arch"
;;
esac
# Architecture-specific optimizations
case $bc_target_arch in
athlon*)
CXXFLAGS="$CXXFLAGS -march=$bc_target_arch"
;;
i586)
CXXFLAGS="$CXXFLAGS -march=pentium"
;;
i686)
CXXFLAGS="$CXXFLAGS -march=pentiumpro"
;;
pentium*)
CXXFLAGS="$CXXFLAGS -march=$bc_target_arch"
;;
powerpc | powerpc64)
CXXFLAGS="$CXXFLAGS -mcpu=$bc_target_arch"
;;
sparcv8)
CXXFLAGS="$CXXFLAGS -mv8"
;;
sparcv8plus)
CXXFLAGS="$CXXFLAGS -mv8plus"
;;
esac
fi
fi
])
dnl BEECRYPT_COMPAQ_CC
AC_DEFUN(BEECRYPT_COMPAQ_CC,[
AC_DEFUN([BEECRYPT_COMPAQ_CC],[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CPP])
AC_CACHE_CHECK([whether we are using Compaq's C compiler],bc_cv_prog_COMPAQ_CC,[
@ -352,23 +596,37 @@ AC_DEFUN(BEECRYPT_COMPAQ_CC,[
fi
if test "$ac_enable_debug" != yes; then
BEECRYPT_CFLAGS_REM([-g])
if test "$bc_cv_c_aggressive_opt" = yes; then
CFLAGS="$CFLAGS -fast"
fi
fi
fi
])
dnl BEECRYPT_COMPAQ_CXX
AC_DEFUN([BEECRYPT_COMPAQ_CXX],[
])
dnl BEECRYPT_HPUX_CC
AC_DEFUN([BEECRYPT_HPUX_CC],[
if test "$ac_enable_debug" != yes; then
BEECRYPT_CFLAGS_REM([-g])
if test "$bc_cv_c_aggressive_opt" = yes; then
CFLAGS="$CFLAGS -fast"
fi
fi
])
dnl BEECRYPT_HPUX_CC
AC_DEFUN(BEECRYPT_HPUX_CC,[
if test "$ac_enable_debug" != yes; then
BEECRYPT_CFLAGS_REM([-g])
CFLAGS="$CFLAGS -fast"
fi
dnl BEECRYPT_HP_CXX
AC_DEFUN([BEECRYPT_HP_CXX],[
])
dnl BEECRYPT_IBM_CC
AC_DEFUN(BEECRYPT_IBM_CC,[
AC_DEFUN([BEECRYPT_IBM_CC],[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CPP])
AC_CACHE_CHECK([whether we are using IBM C],bc_cv_prog_IBM_CC,[
@ -389,10 +647,12 @@ AC_DEFUN(BEECRYPT_IBM_CC,[
esac
if test "$ac_enable_debug" != yes; then
BEECRYPT_CFLAGS_REM([-g])
if test "$ac_with_arch" = yes; then
CFLAGS="$CFLAGS -O5"
else
CFLAGS="$CFLAGS -O3"
if test "$bc_cv_c_aggressive_opt" = yes; then
if test "$ac_with_arch" = yes; then
CFLAGS="$CFLAGS -O5"
else
CFLAGS="$CFLAGS -O3"
fi
fi
fi
# Version 5.0 doesn't have this, but 6.0 does
@ -401,8 +661,13 @@ AC_DEFUN(BEECRYPT_IBM_CC,[
])
dnl BEECRYPT_IBM_CXX
AC_DEFUN([BEECRYPT_IBM_CXX],[
])
dnl BEECRYPT_INTEL_CC
AC_DEFUN(BEECRYPT_INTEL_CC,[
AC_DEFUN([BEECRYPT_INTEL_CC],[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CPP])
AC_CACHE_CHECK([whether we are using Intel C++],bc_cv_prog_INTEL_CC,[
@ -415,35 +680,36 @@ AC_DEFUN(BEECRYPT_INTEL_CC,[
if test "$bc_cv_prog_INTEL_CC" = yes; then
if test "$ac_enable_debug" != yes; then
BEECRYPT_CFLAGS_REM([-g])
CFLAGS="$CFLAGS -O3"
case $bc_target_cpu in
i586 | pentium | pentium-mmx)
CFLAGS="$CFLAGS -mcpu=pentium"
;;
i686 | pentiumpro | pentium[[23]])
CFLAGS="$CFLAGS -mcpu=pentiumpro"
;;
pentium4)
CFLAGS="$CFLAGS -mcpu=pentium4"
;;
esac
case $bc_target_arch in
i586 | pentium | pentium-mmx)
CFLAGS="$CFLAGS -tpp5"
;;
i686 | pentiumpro)
CFLAGS="$CFLAGS -tpp6 -march=pentiumpro"
;;
pentium2)
CFLAGS="$CFLAGS -tpp6 -march=pentiumii"
;;
pentium3)
CFLAGS="$CFLAGS -tpp6 -march=pentiumiii"
;;
pentium4)
CFLAGS="$CFLAGS -tpp7 -march=pentium4"
;;
esac
if test "$bc_cv_c_aggressive_opt" = yes; then
case $bc_target_cpu in
i586 | pentium | pentium-mmx)
CFLAGS="$CFLAGS -mcpu=pentium"
;;
i686 | pentiumpro | pentium[[23]])
CFLAGS="$CFLAGS -mcpu=pentiumpro"
;;
pentium4)
CFLAGS="$CFLAGS -mcpu=pentium4"
;;
esac
case $bc_target_arch in
i586 | pentium | pentium-mmx)
CFLAGS="$CFLAGS -tpp5"
;;
i686 | pentiumpro)
CFLAGS="$CFLAGS -tpp6 -march=pentiumpro"
;;
pentium2)
CFLAGS="$CFLAGS -tpp6 -march=pentiumii"
;;
pentium3)
CFLAGS="$CFLAGS -tpp6 -march=pentiumiii"
;;
pentium4)
CFLAGS="$CFLAGS -tpp7 -march=pentium4"
;;
esac
fi
fi
AC_CHECK_FUNC([_rotl])
AC_CHECK_FUNC([_rotr])
@ -451,8 +717,13 @@ AC_DEFUN(BEECRYPT_INTEL_CC,[
])
dnl BEECRYPT_INTEL_CXX
AC_DEFUN([BEECRYPT_INTEL_CXX],[
])
dnl BEECRYPT_SUN_FORTE_CC
AC_DEFUN(BEECRYPT_SUN_FORTE_CC,[
AC_DEFUN([BEECRYPT_SUN_FORTE_CC],[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CPP])
AC_CACHE_CHECK([whether we are using Sun Forte C],bc_cv_prog_SUN_FORTE_CC,[
@ -468,28 +739,236 @@ AC_DEFUN(BEECRYPT_SUN_FORTE_CC,[
fi
if test "$ac_enable_debug" != yes; then
BEECRYPT_CFLAGS_REM([-g])
CFLAGS="$CFLAGS -fast"
case $bc_target_arch in
sparc)
CFLAGS="$CFLAGS -xtarget=generic -xarch=generic"
;;
sparcv8)
CFLAGS="$CFLAGS -xtarget=generic -xarch=v8"
;;
sparcv8plus*)
CFLAGS="$CFLAGS -xtarget=generic -xarch=v8plus"
;;
sparcv9*)
CFLAGS="$CFLAGS -xtarget=generic64 -xarch=v9"
;;
esac
if test "$bc_cv_c_aggressive_opt" = yes; then
CFLAGS="$CFLAGS -fast"
case $bc_target_arch in
sparc)
CFLAGS="$CFLAGS -xtarget=generic -xarch=generic"
;;
sparcv8)
CFLAGS="$CFLAGS -xtarget=generic -xarch=v8"
;;
sparcv8plus*)
CFLAGS="$CFLAGS -xtarget=generic -xarch=v8plus"
;;
sparcv9*)
CFLAGS="$CFLAGS -xtarget=generic64 -xarch=v9"
;;
esac
fi
fi
fi
])
dnl BEECRYPT_SUN_FORTE_CXX
AC_DEFUN([BEECRYPT_SUN_FORTE_CXX],[
])
dnl BEECRYPT_CC
AC_DEFUN([BEECRYPT_CC],[
if test "$CFLAGS" = ""; then
bc_cv_c_aggressive_opt=yes
else
bc_cv_c_aggressive_opt=no
fi
# set flags for large file support
case $target_os in
linux* | solaris*)
CPPFLAGS="$CPPFLAGS `getconf LFS_CFLAGS`"
LDFLAGS="$LDFLAGS `getconf LFS_LDFLAGS`"
;;
esac
if test "$ac_cv_c_compiler_gnu" = yes; then
# Intel's icc can be mistakenly identified as gcc
case $target_os in
linux*)
BEECRYPT_INTEL_CC
;;
esac
if test "$bc_cv_prog_INTEL_CC" != yes; then
BEECRYPT_GNU_CC
fi
else
case $target_os in
aix*)
BEECRYPT_IBM_CC
;;
hpux*)
BEECRYPT_HPUX_CC
;;
linux*)
BEECRYPT_INTEL_CC
;;
solaris*)
BEECRYPT_SUN_FORTE_CC
;;
osf*)
BEECRYPT_COMPAQ_CC
;;
esac
fi
])
dnl BEECRYPT_CXX
AC_DEFUN([BEECRYPT_CXX],[
if test "$CXXFLAGS" = ""; then
bc_cv_cxx_aggressive_opt=yes
else
bc_cv_cxx_aggressive_opt=no
fi
if test "$ac_cv_cxx_compiler_gnu" = yes; then
# Intel's icc can be mistakenly identified as gcc
case $target_os in
linux*)
BEECRYPT_INTEL_CXX
;;
esac
if test "$bc_cv_prog_INTEL_CXX" != yes; then
BEECRYPT_GNU_CXX
fi
else
case $target_os in
aix*)
BEECRYPT_IBM_CXX
;;
hpux*)
BEECRYPT_HPUX_CXX
;;
linux*)
BEECRYPT_INTEL_CXX
;;
solaris*)
BEECRYPT_SUN_FORTE_CXX
;;
osf*)
BEECRYPT_COMPAQ_CXX
;;
esac
fi
])
dnl BEECRYPT_NOEXECSTACK
AC_DEFUN([BEECRYPT_NOEXECSTACK],[
AC_CACHE_CHECK([whether the assembler can use noexecstack],bc_cv_as_noexecstack,[
cat > conftest.c << EOF
void foo(void) { }
EOF
if AC_TRY_COMMAND([$CC -c -o conftest.o conftest.c]) then
bc_cv_as_noexecstack=yes
if test "$ac_cv_c_compiler_gnu" = yes; then
CFLAGS="$CFLAGS -Wa,--noexecstack"
fi
if test "$ac_cv_cxx_compiler_gnu" = yes; then
CXXFLAGS="$CXXFLAGS -Wa,--noexecstack"
fi
else
bc_cv_as_noexecstack=no
fi
])
AC_CACHE_CHECK([whether the linker can use noexecstack],bc_cv_ld_noexecstack,[
if AC_TRY_COMMAND([$LD -z noexecstack -o conftest conftest.o]) then
bc_cv_ld_noexecstack=yes
LDFLAGS="$LDFLAGS -z noexecstack"
else
bc_cv_ld_noexecstack=no
fi
])
])
dnl BEECRYPT_LIBTOOL
AC_DEFUN([BEECRYPT_LIBTOOL],[
case $target_os in
aix*)
case $bc_target_arch in
powerpc64)
AR="ar -X64"
NM="/usr/bin/nm -B -X64"
;;
esac
;;
solaris*)
case $bc_target_arch in
sparcv9*)
LD="/usr/ccs/bin/ld -64"
;;
esac
;;
esac
])
dnl BEECRYPT_OS_DEFS
AC_DEFUN([BEECRYPT_OS_DEFS],[
AH_TEMPLATE([AIX],[Define to 1 if you are using AIX])
AH_TEMPLATE([CYGWIN],[Define to 1 if you are using Cygwin])
AH_TEMPLATE([DARWIN],[Define to 1 if you are using Darwin/MacOS X])
AH_TEMPLATE([FREEBSD],[Define to 1 if you are using FreeBSD])
AH_TEMPLATE([HPUX],[Define to 1 if you are using HPUX])
AH_TEMPLATE([LINUX],[Define to 1 if you are using GNU/Linux])
AH_TEMPLATE([NETBSD],[Define to 1 if you are using NetBSD])
AH_TEMPLATE([OPENBSD],[Define to 1 if you are using OpenBSD])
AH_TEMPLATE([OSF],[Define to 1 if you are using OSF])
AH_TEMPLATE([QNX],[Define to 1 if you are using QNX])
AH_TEMPLATE([SCO_UNIX],[Define to 1 if you are using SCO Unix])
AH_TEMPLATE([SOLARIS],[Define to 1 if you are using Solaris])
AH_VERBATIM([WIN32],[
#ifndef WIN32
#undef WIN32
#endif
])
case $target_os in
aix*)
AC_DEFINE([AIX])
;;
cygwin*)
AC_DEFINE([CYGWIN])
AC_DEFINE([WIN32])
;;
darwin*)
AC_DEFINE([DARWIN])
;;
freebsd*)
AC_DEFINE([FREEBSD])
;;
hpux*)
AC_DEFINE([HPUX])
;;
linux*)
AC_DEFINE([LINUX])
;;
netbsd*)
AC_DEFINE([NETBSD])
;;
openbsd*)
AC_DEFINE([OPENBSD])
;;
osf*)
AC_DEFINE([OSF])
;;
*qnx)
AC_DEFINE([QNX])
;;
solaris*)
AC_DEFINE([SOLARIS])
;;
sysv*uv*)
AC_DEFINE([SCO_UNIX])
;;
*)
AC_MSG_WARN([Operating system type $target_os currently not supported and/or tested])
;;
esac
])
dnl BEECRYPT_ASM_DEFS
AC_DEFUN(BEECRYPT_ASM_DEFS,[
AC_DEFUN([BEECRYPT_ASM_DEFS],[
AC_SUBST(ASM_OS,$target_os)
AC_SUBST(ASM_CPU,$bc_target_cpu)
AC_SUBST(ASM_ARCH,$bc_target_arch)
@ -498,7 +977,7 @@ AC_DEFUN(BEECRYPT_ASM_DEFS,[
dnl BEECRYPT_ASM_TEXTSEG
AC_DEFUN(BEECRYPT_ASM_TEXTSEG,[
AC_DEFUN([BEECRYPT_ASM_TEXTSEG],[
AC_CACHE_CHECK([how to switch to text segment],
bc_cv_asm_textseg,[
case $target_os in
@ -520,7 +999,7 @@ AC_DEFUN(BEECRYPT_ASM_TEXTSEG,[
dnl BEECRYPT_ASM_GLOBL
AC_DEFUN(BEECRYPT_ASM_GLOBL,[
AC_DEFUN([BEECRYPT_ASM_GLOBL],[
AC_CACHE_CHECK([how to declare a global symbol],
bc_cv_asm_globl,[
case $target_os in
@ -533,7 +1012,7 @@ AC_DEFUN(BEECRYPT_ASM_GLOBL,[
dnl BEECRYPT_ASM_GSYM_PREFIX
AC_DEFUN(BEECRYPT_ASM_GSYM_PREFIX,[
AC_DEFUN([BEECRYPT_ASM_GSYM_PREFIX],[
AC_CACHE_CHECK([if global symbols need leading underscore],
bc_cv_asm_gsym_prefix,[
case $target_os in
@ -546,7 +1025,7 @@ AC_DEFUN(BEECRYPT_ASM_GSYM_PREFIX,[
dnl BEECRYPT_ASM_LSYM_PREFIX
AC_DEFUN(BEECRYPT_ASM_LSYM_PREFIX,[
AC_DEFUN([BEECRYPT_ASM_LSYM_PREFIX],[
AC_CACHE_CHECK([how to declare a local symbol],
bc_cv_asm_lsym_prefix,[
case $target_os in
@ -566,10 +1045,12 @@ AC_DEFUN(BEECRYPT_ASM_LSYM_PREFIX,[
dnl BEECRYPT_ASM_ALIGN
AC_DEFUN(BEECRYPT_ASM_ALIGN,[
AC_DEFUN([BEECRYPT_ASM_ALIGN],[
AC_CACHE_CHECK([how to align symbols],
bc_cv_asm_align,[
case $target_cpu in
alpha*)
bc_cv_asm_align=".align 5" ;;
i[[3456]]86 | athlon*)
bc_cv_asm_align=".align 4" ;;
ia64)
@ -580,6 +1061,8 @@ AC_DEFUN(BEECRYPT_ASM_ALIGN,[
bc_cv_asm_align=".align 4" ;;
sparc*)
bc_cv_asm_align=".align 4" ;;
x86_64)
bc_cv_asm_align=".align 16" ;;
esac
])
AC_SUBST(ASM_ALIGN,$bc_cv_asm_align)
@ -587,7 +1070,7 @@ AC_DEFUN(BEECRYPT_ASM_ALIGN,[
dnl BEECRYPT_ASM_SOURCES
AC_DEFUN(BEECRYPT_ASM_SOURCES,[
AC_DEFUN([BEECRYPT_ASM_SOURCES],[
echo > mpopt.s
echo > aesopt.s
echo > blowfishopt.s
@ -671,3 +1154,78 @@ AC_DEFUN(BEECRYPT_ASM_SOURCES,[
fi
fi
])
dnl BEECRYPT_DLFCN
AC_DEFUN([BEECRYPT_DLFCN],[
AH_TEMPLATE([HAVE_DLFCN_H],[.])
AC_CHECK_HEADERS([dlfcn.h])
if test "$ac_cv_header_dlfcn_h" = yes; then
AC_SEARCH_LIBS([dlopen],[dl dld],[
])
fi
])
dnl BEECRYPT_MULTITHREAD
AC_DEFUN([BEECRYPT_MULTITHREAD],[
AH_TEMPLATE([ENABLE_THREADS],[Define to 1 if you want to enable multithread support])
AH_TEMPLATE([HAVE_THREAD_H],[.])
AH_TEMPLATE([HAVE_PTHREAD_H],[.])
AH_TEMPLATE([HAVE_SYNCH_H],[.])
AH_TEMPLATE([HAVE_SEMAPHORE_H],[.])
if test "$ac_enable_threads" = yes; then
AC_CHECK_HEADERS([synch.h thread.h pthread.h semaphore.h])
fi
bc_include_synch_h=
bc_include_thread_h=
bc_include_pthread_h=
bc_typedef_bc_cond_t=
bc_typedef_bc_mutex_t=
bc_typedef_bc_thread_t=
if test "$ac_enable_threads" = yes; then
if test "$ac_cv_header_thread_h" = yes -a "$ac_cv_header_synch_h" = yes; then
bc_include_synch_h="#include <synch.h>"
bc_include_thread_h="#include <thread.h>"
bc_typedef_bc_cond_t="typedef cond_t bc_cond_t;"
bc_typedef_bc_mutex_t="typedef mutex_t bc_mutex_t;"
bc_typedef_bc_thread_t="typedef thread_t bc_thread_t;"
AC_SEARCH_LIBS([mutex_lock],[thread],[
AC_DEFINE([ENABLE_THREADS],1)
])
elif test "$ac_cv_header_pthread_h" = yes; then
bc_include_pthread_h="#include <pthread.h>"
bc_typedef_bc_cond_t="typedef pthread_cond_t bc_cond_t;"
bc_typedef_bc_mutex_t="typedef pthread_mutex_t bc_mutex_t;"
bc_typedef_bc_thread_t="typedef pthread_t bc_thread_t;"
# On most systems this tests will say 'none required', but that doesn't
# mean that the linked code will work correctly!
case $target_os in
linux* | solaris* )
AC_DEFINE([ENABLE_THREADS],1)
LIBS="-lpthread $LIBS"
;;
osf*)
AC_DEFINE([ENABLE_THREADS],1)
LIBS="-lpthread -lmach -lexc $LIBS"
;;
*)
AC_SEARCH_LIBS([pthread_mutex_lock],[pthread],[
AC_DEFINE([ENABLE_THREADS],1)
])
;;
esac
else
AC_MSG_WARN([Don't know which thread library to check for])
fi
fi
AC_SUBST(INCLUDE_SYNCH_H,$bc_include_synch_h)
AC_SUBST(INCLUDE_THREAD_H,$bc_include_thread_h)
AC_SUBST(INCLUDE_PTHREAD_H,$bc_include_pthread_h)
AC_SUBST(TYPEDEF_BC_COND_T,$bc_typedef_bc_cond_t)
AC_SUBST(TYPEDEF_BC_MUTEX_T,$bc_typedef_bc_mutex_t)
AC_SUBST(TYPEDEF_BC_THREAD_T,$bc_typedef_bc_thread_t)
])

View File

@ -1,4 +1,3 @@
/*@-bitwisesigned@*/
/*
* Copyright (c) 2002, 2003 Bob Deblier
*
@ -28,12 +27,13 @@
* \ingroup BC_aes_m BC_m
*/
#include "system.h"
#include "beecrypt.h"
#include "aesopt.h"
#include "aes.h"
#include "mp.h"
#include "debug.h"
#define BEECRYPT_DLL_EXPORT
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/aes.h"
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
# if (BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN)
@ -41,14 +41,10 @@
# endif
#endif
/*!\addtogroup BC_aes_m
* \{
*/
#if WORDS_BIGENDIAN
# include "aes_be.h"
# include "beecrypt/aes_be.h"
#else
# include "aes_le.h"
# include "beecrypt/aes_le.h"
#endif
#ifdef ASM_AESENCRYPTECB
@ -59,15 +55,13 @@ extern int aesEncryptECB(aesParam*, uint32_t*, const uint32_t*, unsigned int);
extern int aesDecryptECB(aesParam*, uint32_t*, const uint32_t*, unsigned int);
#endif
/*@-sizeoftype@*/
/*@-castfcnptr@*/
const blockCipher aes = {
"AES",
sizeof(aesParam),
16U,
128U,
256U,
64U,
16,
128,
256,
64,
(blockCipherSetup) aesSetup,
(blockCipherSetIV) aesSetIV,
/* raw */
@ -95,8 +89,6 @@ const blockCipher aes = {
},
(blockCipherFeedback) aesFeedback
};
/*@=castfcnptr@*/
/*@=sizeoftype@*/
int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
{
@ -127,16 +119,16 @@ int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
{
t = rk[3];
#if WORDS_BIGENDIAN
t = (_ae4[(t >> 16) & 0xff] & 0xff000000U) ^
(_ae4[(t >> 8) & 0xff] & 0x00ff0000U) ^
(_ae4[(t ) & 0xff] & 0x0000ff00U) ^
(_ae4[(t >> 24) ] & 0x000000ffU) ^
t = (_ae4[(t >> 16) & 0xff] & 0xff000000) ^
(_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^
(_ae4[(t ) & 0xff] & 0x0000ff00) ^
(_ae4[(t >> 24) ] & 0x000000ff) ^
_arc[i];
#else
t = (_ae4[(t >> 8) & 0xff] & 0x000000ffU) ^
(_ae4[(t >> 16) & 0xff] & 0x0000ff00U) ^
(_ae4[(t >> 24) ] & 0x00ff0000U) ^
(_ae4[(t ) & 0xff] & 0xff000000U) ^
t = (_ae4[(t >> 8) & 0xff] & 0x000000ff) ^
(_ae4[(t >> 16) & 0xff] & 0x0000ff00) ^
(_ae4[(t >> 24) ] & 0x00ff0000) ^
(_ae4[(t ) & 0xff] & 0xff000000) ^
_arc[i];
#endif
rk[4] = (t ^= rk[0]);
@ -154,16 +146,16 @@ int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
{
t = rk[5];
#if WORDS_BIGENDIAN
t = (_ae4[(t >> 16) & 0xff] & 0xff000000U) ^
(_ae4[(t >> 8) & 0xff] & 0x00ff0000U) ^
(_ae4[(t ) & 0xff] & 0x0000ff00U) ^
(_ae4[(t >> 24) ] & 0x000000ffU) ^
t = (_ae4[(t >> 16) & 0xff] & 0xff000000) ^
(_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^
(_ae4[(t ) & 0xff] & 0x0000ff00) ^
(_ae4[(t >> 24) ] & 0x000000ff) ^
_arc[i];
#else
t = (_ae4[(t >> 8) & 0xff] & 0x000000ffU) ^
(_ae4[(t >> 16) & 0xff] & 0x0000ff00U) ^
(_ae4[(t >> 24) ] & 0x00ff0000U) ^
(_ae4[(t ) & 0xff] & 0xff000000U) ^
t = (_ae4[(t >> 8) & 0xff] & 0x000000ff) ^
(_ae4[(t >> 16) & 0xff] & 0x0000ff00) ^
(_ae4[(t >> 24) ] & 0x00ff0000) ^
(_ae4[(t ) & 0xff] & 0xff000000) ^
_arc[i];
#endif
rk[6] = (t ^= rk[0]);
@ -183,16 +175,16 @@ int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
{
t = rk[7];
#if WORDS_BIGENDIAN
t = (_ae4[(t >> 16) & 0xff] & 0xff000000U) ^
(_ae4[(t >> 8) & 0xff] & 0x00ff0000U) ^
(_ae4[(t ) & 0xff] & 0x0000ff00U) ^
(_ae4[(t >> 24) ] & 0x000000ffU) ^
t = (_ae4[(t >> 16) & 0xff] & 0xff000000) ^
(_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^
(_ae4[(t ) & 0xff] & 0x0000ff00) ^
(_ae4[(t >> 24) ] & 0x000000ff) ^
_arc[i];
#else
t = (_ae4[(t >> 8) & 0xff] & 0x000000ffU) ^
(_ae4[(t >> 16) & 0xff] & 0x0000ff00U) ^
(_ae4[(t >> 24) ] & 0x00ff0000U) ^
(_ae4[(t ) & 0xff] & 0xff000000U) ^
t = (_ae4[(t >> 8) & 0xff] & 0x000000ff) ^
(_ae4[(t >> 16) & 0xff] & 0x0000ff00) ^
(_ae4[(t >> 24) ] & 0x00ff0000) ^
(_ae4[(t ) & 0xff] & 0xff000000) ^
_arc[i];
#endif
rk[8] = (t ^= rk[0]);
@ -202,15 +194,15 @@ int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
if (++i == 7)
break;
#if WORDS_BIGENDIAN
t = (_ae4[(t >> 24) ] & 0xff000000U) ^
(_ae4[(t >> 16) & 0xff] & 0x00ff0000U) ^
(_ae4[(t >> 8) & 0xff] & 0x0000ff00U) ^
(_ae4[(t ) & 0xff] & 0x000000ffU);
t = (_ae4[(t >> 24) ] & 0xff000000) ^
(_ae4[(t >> 16) & 0xff] & 0x00ff0000) ^
(_ae4[(t >> 8) & 0xff] & 0x0000ff00) ^
(_ae4[(t ) & 0xff] & 0x000000ff);
#else
t = (_ae4[(t ) & 0xff] & 0x000000ffU) ^
(_ae4[(t >> 8) & 0xff] & 0x0000ff00U) ^
(_ae4[(t >> 16) & 0xff] & 0x00ff0000U) ^
(_ae4[(t >> 24) ] & 0xff000000U);
t = (_ae4[(t ) & 0xff] & 0x000000ff) ^
(_ae4[(t >> 8) & 0xff] & 0x0000ff00) ^
(_ae4[(t >> 16) & 0xff] & 0x00ff0000) ^
(_ae4[(t >> 24) ] & 0xff000000);
#endif
rk[12] = (t ^= rk[4]);
rk[13] = (t ^= rk[5]);
@ -235,9 +227,9 @@ int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
{
rk += 4;
#if WORDS_BIGENDIAN
rk[0] =
_ad0[_ae4[(rk[0] >> 24) ] & 0xff] ^
_ad1[_ae4[(rk[0] >> 16) & 0xff] & 0xff] ^
rk[0] =
_ad0[_ae4[(rk[0] >> 24) ] & 0xff] ^
_ad1[_ae4[(rk[0] >> 16) & 0xff] & 0xff] ^
_ad2[_ae4[(rk[0] >> 8) & 0xff] & 0xff] ^
_ad3[_ae4[(rk[0] ) & 0xff] & 0xff];
rk[1] =
@ -252,9 +244,9 @@ int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
_ad3[_ae4[(rk[2] ) & 0xff] & 0xff];
rk[3] =
_ad0[_ae4[(rk[3] >> 24) ] & 0xff] ^
_ad1[_ae4[(rk[3] >> 16) & 0xff] & 0xff] ^
_ad2[_ae4[(rk[3] >> 8) & 0xff] & 0xff] ^
_ad3[_ae4[(rk[3] ) & 0xff] & 0xff];
_ad1[_ae4[(rk[3] >> 16) & 0xff] & 0xff] ^
_ad2[_ae4[(rk[3] >> 8) & 0xff] & 0xff] ^
_ad3[_ae4[(rk[3] ) & 0xff] & 0xff];
#else
rk[0] =
_ad0[_ae4[(rk[0] ) & 0xff] & 0xff] ^
@ -287,12 +279,10 @@ int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
#ifndef ASM_AESSETIV
int aesSetIV(aesParam* ap, const byte* iv)
{
/*@-mayaliasunique@*/
if (iv)
memcpy(ap->fdback, iv, 16);
else
memset(ap->fdback, 0, 16);
/*@=mayaliasunique@*/
return 0;
}
@ -394,6 +384,3 @@ uint32_t* aesFeedback(aesParam* ap)
{
return ap->fdback;
}
/*@=bitwisesigned@*/
/*!\}
*/

View File

@ -26,12 +26,25 @@
#ifndef _AES_H
#define _AES_H
/** \ingroup BC_aes_m
#include "beecrypt/beecrypt.h"
#include "beecrypt/aesopt.h"
/*!\brief Holds all the parameters necessary for the AES cipher.
* \ingroup BC_aes_m
*/
typedef struct
{
/*!\var k
* \brief Holds the key expansion.
*/
uint32_t k[64];
/*!\var nr
* \brief Number of rounds to be used in encryption/decryption.
*/
uint32_t nr;
/*!\var fdback
* \brief Buffer to be used by block chaining or feedback modes.
*/
uint32_t fdback[4];
} aesParam;
@ -39,83 +52,58 @@ typedef struct
extern "C" {
#endif
/** \ingroup BC_aes_m
/*!\var aes
* \brief Holds the full API description of the AES algorithm.
*/
/*@observer@*/ /*@unchecked@*/
extern const BEECRYPTAPI blockCipher aes;
/** \ingroup BC_aes_m
* The cipher's setup function.
*
* This function expands the key depending on whether the ENCRYPT or DECRYPT
* operation was selected.
*
* @param ap parameter block
* @param key key value
* @param keybits number of bits in the key (128, 192 or 256)
* @param op ENCRYPT or DECRYPT.
* @retval 0 on success, -1 on failure.
/*!\fn int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
* \brief This function performs the cipher's key expansion.
* \param ap The cipher's parameter block.
* \param key The key value.
* \param keybits The number of bits in the key; legal values are:
* 128, 192 and 256.
* \param op ENCRYPT or DECRYPT.
* \retval 0 on success.
* \retval -1 on failure.
*/
/*@-exportlocal@*/
BEECRYPTAPI
int aesSetup (aesParam* ap, const byte* key, size_t keybits, cipherOperation op)
/*@modifies ap @*/;
/*@=exportlocal@*/
int aesSetup (aesParam* ap, const byte* key, size_t keybits, cipherOperation op);
/** \ingroup BC_aes_m
* The Initialization Vector setup function.
*
* This function is only necessary in block chaining or feedback modes.
*
* @param ap parameter block
* @param iv initialization vector (or NULL)
* @retval 0 on success.
/*!\fn int aesSetIV(aesParam* ap, const byte* iv)
* \brief This function sets the Initialization Vector.
* \note This function is only useful in block chaining or feedback modes.
* \param ap The cipher's parameter block.
* \param iv The initialization vector; may be null.
* \retval 0 on success.
*/
/*@-exportlocal@*/
BEECRYPTAPI
int aesSetIV (aesParam* ap, /*@null@*/ const byte* iv)
/*@modifies ap @*/;
/*@=exportlocal@*/
int aesSetIV (aesParam* ap, const byte* iv);
/** \ingroup BC_aes_m
* The raw encryption function.
*
* This function encrypts one block of data; the size of a block is 128 bits.
*
* @param ap parameter block
* @param dst ciphertext (aligned on 32-bit boundary)
* @param src cleartext (aligned on 32-bit boundary)
* @retval 0 on success.
/*!\fn aesEncrypt(aesParam* ap, uint32_t* dst, const uint32_t* src)
* \brief This function performs the raw AES encryption; it encrypts one block
* of 128 bits.
* \param ap The cipher's parameter block.
* \param dst The ciphertext; should be aligned on 32-bit boundary.
* \param src The cleartext; should be aligned on 32-bit boundary.
* \retval 0 on success.
*/
/*@-exportlocal@*/
BEECRYPTAPI
int aesEncrypt(aesParam* ap, uint32_t* dst, const uint32_t* src)
/*@modifies dst @*/;
/*@=exportlocal@*/
int aesEncrypt (aesParam* ap, uint32_t* dst, const uint32_t* src);
/** \ingroup BC_aes_m
* The raw decryption function.
*
* This function decrypts one block of data; the size of a block is 128 bits.
*
* @param ap parameter block
* @param dst cleartext (aligned on 32-bit boundary)
* @param src ciphertext (aligned on 32-bit boundary)
* @retval 0 on success.
/*!\fn aesDecrypt(aesParam* ap, uint32_t* dst, const uint32_t* src)
* \brief This function performs the raw AES decryption; it decrypts one block
* of 128 bits.
* \param ap The cipher's parameter block.
* \param dst The cleartext; should be aligned on 32-bit boundary.
* \param src The ciphertext; should be aligned on 32-bit boundary.
* \retval 0 on success.
*/
/*@-exportlocal@*/
BEECRYPTAPI
int aesDecrypt(aesParam* ap, uint32_t* dst, const uint32_t* src)
/*@modifies dst @*/;
/*@=exportlocal@*/
int aesDecrypt (aesParam* ap, uint32_t* dst, const uint32_t* src);
/** \ingroup BC_aes_m
*/
/*@-exportlocal@*/
BEECRYPTAPI /*@observer@*/
uint32_t* aesFeedback(aesParam* ap)
/*@*/;
/*@=exportlocal@*/
BEECRYPTAPI
uint32_t* aesFeedback(aesParam* ap);
#ifdef __cplusplus
}

View File

@ -17,7 +17,6 @@
*
*/
/*@observer@*/ /*@unchecked@*/
const uint32_t _ae0[256] = {
0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d,
0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554,
@ -85,7 +84,6 @@ const uint32_t _ae0[256] = {
0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ae1[256] = {
0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b,
0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5,
@ -153,7 +151,6 @@ const uint32_t _ae1[256] = {
0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ae2[256] = {
0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b,
0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5,
@ -221,7 +218,6 @@ const uint32_t _ae2[256] = {
0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ae3[256] = {
0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6,
0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491,
@ -289,7 +285,6 @@ const uint32_t _ae3[256] = {
0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ae4[256] = {
0x63636363, 0x7c7c7c7c, 0x77777777, 0x7b7b7b7b,
0xf2f2f2f2, 0x6b6b6b6b, 0x6f6f6f6f, 0xc5c5c5c5,
@ -357,7 +352,6 @@ const uint32_t _ae4[256] = {
0xb0b0b0b0, 0x54545454, 0xbbbbbbbb, 0x16161616
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ad0[256] = {
0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96,
0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393,
@ -425,7 +419,6 @@ const uint32_t _ad0[256] = {
0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ad1[256] = {
0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e,
0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303,
@ -493,7 +486,6 @@ const uint32_t _ad1[256] = {
0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ad2[256] = {
0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27,
0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3,
@ -561,7 +553,6 @@ const uint32_t _ad2[256] = {
0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ad3[256] = {
0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a,
0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b,
@ -629,7 +620,6 @@ const uint32_t _ad3[256] = {
0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ad4[256] = {
0x52525252, 0x09090909, 0x6a6a6a6a, 0xd5d5d5d5,
0x30303030, 0x36363636, 0xa5a5a5a5, 0x38383838,
@ -697,7 +687,6 @@ const uint32_t _ad4[256] = {
0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d
};
/*@observer@*/ /*@unchecked@*/
static const uint32_t _arc[] = {
0x01000000, 0x02000000, 0x04000000, 0x08000000,
0x10000000, 0x20000000, 0x40000000, 0x80000000,

View File

@ -17,7 +17,6 @@
*
*/
/*@observer@*/ /*@unchecked@*/
#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686))
const uint64_t _ae0[256] = {
#else
@ -89,7 +88,6 @@ const uint32_t _ae0[256] = {
0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c
};
/*@observer@*/ /*@unchecked@*/
#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686))
const uint64_t _ae1[256] = {
#else
@ -161,7 +159,6 @@ const uint32_t _ae1[256] = {
0xb0b07bcb, 0x5454a8fc, 0xbbbb6dd6, 0x16162c3a
};
/*@observer@*/ /*@unchecked@*/
#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686))
const uint64_t _ae2[256] = {
#else
@ -233,7 +230,6 @@ const uint32_t _ae2[256] = {
0xb07bcbb0, 0x54a8fc54, 0xbb6dd6bb, 0x162c3a16
};
/*@observer@*/ /*@unchecked@*/
#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686))
const uint64_t _ae3[256] = {
#else
@ -305,7 +301,6 @@ const uint32_t _ae3[256] = {
0x7bcbb0b0, 0xa8fc5454, 0x6dd6bbbb, 0x2c3a1616
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ae4[256] = {
0x63636363, 0x7c7c7c7c, 0x77777777, 0x7b7b7b7b,
0xf2f2f2f2, 0x6b6b6b6b, 0x6f6f6f6f, 0xc5c5c5c5,
@ -373,7 +368,6 @@ const uint32_t _ae4[256] = {
0xb0b0b0b0, 0x54545454, 0xbbbbbbbb, 0x16161616
};
/*@observer@*/ /*@unchecked@*/
#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686))
const uint64_t _ad0[256] = {
#else
@ -445,7 +439,6 @@ const uint32_t _ad0[256] = {
0x6184cb7b, 0x70b632d5, 0x745c6c48, 0x4257b8d0
};
/*@observer@*/ /*@unchecked@*/
#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686))
const uint64_t _ad1[256] = {
#else
@ -517,7 +510,6 @@ const uint32_t _ad1[256] = {
0x84cb7b61, 0xb632d570, 0x5c6c4874, 0x57b8d042
};
/*@observer@*/ /*@unchecked@*/
#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686))
const uint64_t _ad2[256] = {
#else
@ -589,7 +581,6 @@ const uint32_t _ad2[256] = {
0xcb7b6184, 0x32d570b6, 0x6c48745c, 0xb8d04257
};
/*@observer@*/ /*@unchecked@*/
#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686))
const uint64_t _ad3[256] = {
#else
@ -661,7 +652,6 @@ const uint32_t _ad3[256] = {
0x7b6184cb, 0xd570b632, 0x48745c6c, 0xd04257b8
};
/*@observer@*/ /*@unchecked@*/
const uint32_t _ad4[256] = {
0x52525252, 0x09090909, 0x6a6a6a6a, 0xd5d5d5d5,
0x30303030, 0x36363636, 0xa5a5a5a5, 0x38383838,
@ -729,7 +719,6 @@ const uint32_t _ad4[256] = {
0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d
};
/*@observer@*/ /*@unchecked@*/
static const uint32_t _arc[] = {
0x00000001, 0x00000002, 0x00000004, 0x00000008,
0x00000010, 0x00000020, 0x00000040, 0x00000080,

View File

@ -26,6 +26,9 @@
#ifndef _AESOPT_H
#define _AESOPT_H
#include "beecrypt/beecrypt.h"
#include "beecrypt/aes.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -50,11 +53,13 @@ extern "C" {
#if defined(__INTEL_COMPILER)
# if defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)
# if defined(OPTIMIZE_MMX)
# define ASM_AESENCRYPT
# define ASM_AESENCRYPTECB
# define ASM_AESDECRYPT
# define ASM_AESDECRYPTECB
# endif
# endif
#endif
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)

View File

@ -17,7 +17,7 @@
*
*/
/*!\file beecrypt.api.h
/*!\file api.h
* \brief BeeCrypt API, portability headers.
* \author Bob Deblier <bob.deblier@pandora.be>
*/
@ -30,15 +30,23 @@
#endif
#if WIN32 && !__CYGWIN32__
# include "beecrypt.win.h"
# include "beecrypt/win.h"
# ifdef BEECRYPT_DLL_EXPORT
# define BEECRYPTAPI __declspec(dllexport)
# else
# define BEECRYPTAPI __declspec(dllimport)
# endif
# ifdef BEECRYPT_CXX_DLL_EXPORT
# define BEECRYPTCXXAPI __declspec(dllexport)
# define BEECRYPTCXXTEMPLATE
# else
# define BEECRYPTCXXAPI __declspec(dllimport)
# define BEECRYPTCXXTEMPLATE extern
# endif
#else
# include "beecrypt.gnu.h"
# include "beecrypt/gnu.h"
# define BEECRYPTAPI
# define BEECRYPTCXXAPI
#endif
#ifndef ROTL32
@ -50,16 +58,12 @@
typedef uint8_t byte;
/*@-typeuse@*/
typedef int8_t javabyte;
typedef int16_t javashort;
typedef int32_t javaint;
/*@=typeuse@*/
typedef int64_t javalong;
/*@-typeuse@*/
typedef uint16_t javachar;
/*@=typeuse@*/
#if (MP_WBITS == 64)
typedef uint64_t mpw;
@ -70,9 +74,7 @@ typedef uint32_t mphw;
typedef uint64_t mpdw;
# endif
typedef uint32_t mpw;
/*@-typeuse@*/
typedef uint16_t mphw;
/*@=typeuse@*/
#else
# error
#endif

View File

@ -1,44 +1,8 @@
#!/bin/sh
#! /bin/sh
export CFLAGS
export LDFLAGS
LTV="libtoolize (GNU libtool) 1.5.6"
ACV="autoconf (GNU Autoconf) 2.59"
AMV="automake (GNU automake) 1.9"
USAGE="
This script documents the versions of the tools I'm using to build rpm:
libtool-1.5.6
autoconf-2.59
automake-1.9
Simply edit this script to change the libtool/autoconf/automake versions
checked if you need to, as rpm should build (and has built) with all
recent versions of libtool/autoconf/automake.
"
[ "`libtoolize --version | head -1`" != "$LTV" ] && echo "$USAGE" && exit 1
[ "`autoconf --version | head -1`" != "$ACV" ] && echo "$USAGE" && exit 1
[ "`automake --version | head -1 | sed -e 's/1\.4[a-z]/1.4/'`" != "$AMV" ] && echo "$USAGE" && exit 1
libtoolize --copy --force
libtoolize --force --copy
aclocal
autoheader
automake -a -c
autoconf
if [ "$1" = "--noconfigure" ]; then
exit 0;
fi
if [ X"$@" = X -a "X`uname -s`" = "XLinux" ]; then
if [ -d /usr/share/man ]; then
mandir=/usr/share/man
infodir=/usr/share/info
else
mandir=/usr/man
infodir=/usr/info
fi
CPPFLAGS="-Wall -g" ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --infodir=${infodir} --mandir=${mandir} --enable-static --with-python "$@"
else
./configure "$@"
fi
autoheader

View File

@ -1,4 +1,3 @@
/*@-type@*/
/*
* Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V.
*
@ -23,15 +22,19 @@
* \author Bob Deblier <bob.deblier@pandora.be>
*/
#include "system.h"
#include "base64.h"
#include "endianness.h"
#include "debug.h"
#define BEECRYPT_DLL_EXPORT
/*@unchecked@*/
static int _debug = 0;
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/base64.h"
#include "beecrypt/endianness.h"
#if HAVE_CTYPE_H
# include <ctype.h>
#endif
/*@unchecked@*/ /*@observer@*/
static const char* to_b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/* encode 64 characters per line */
@ -55,10 +58,10 @@ char* b64enc(const memchunk* chunk)
while (div > 0)
{
buf[0] = to_b64[ ((unsigned)data[0] >> 2) & 0x3f];
buf[1] = to_b64[(((unsigned)data[0] << 4) & 0x30) | (((unsigned)data[1] >> 4) & 0xf)];
buf[2] = to_b64[(((unsigned)data[1] << 2) & 0x3c) | (((unsigned)data[2] >> 6) & 0x3)];
buf[3] = to_b64[ (unsigned)data[2] & 0x3f];
buf[0] = to_b64[ (data[0] >> 2) & 0x3f];
buf[1] = to_b64[((data[0] << 4) & 0x30) | ((data[1] >> 4) & 0xf)];
buf[2] = to_b64[((data[1] << 2) & 0x3c) | ((data[2] >> 6) & 0x3)];
buf[3] = to_b64[ data[2] & 0x3f];
data += 3;
buf += 4;
div--;
@ -73,16 +76,16 @@ char* b64enc(const memchunk* chunk)
switch (rem)
{
case 2:
buf[0] = to_b64[ ((unsigned)data[0] >> 2) & 0x3f];
buf[1] = to_b64[(((unsigned)data[0] << 4) & 0x30) + (((unsigned)data[1] >> 4) & 0xf)];
buf[2] = to_b64[ ((unsigned)data[1] << 2) & 0x3c];
buf[0] = to_b64[ (data[0] >> 2) & 0x3f];
buf[1] = to_b64[((data[0] << 4) & 0x30) + ((data[1] >> 4) & 0xf)];
buf[2] = to_b64[ (data[1] << 2) & 0x3c];
buf[3] = '=';
buf += 4;
chars += 4;
break;
case 1:
buf[0] = to_b64[ ((unsigned)data[0] >> 2) & 0x3f];
buf[1] = to_b64[ ((unsigned)data[0] << 4) & 0x30];
buf[0] = to_b64[ (data[0] >> 2) & 0x3f];
buf[1] = to_b64[ (data[0] << 4) & 0x30];
buf[2] = '=';
buf[3] = '=';
buf += 4;
@ -94,9 +97,7 @@ char* b64enc(const memchunk* chunk)
*buf = '\0';
}
/*@-dependenttrans@*/ /* FIX: buf = string makes string dependent */
return string;
/*@=dependenttrans@*/
}
memchunk* b64dec(const char* string)
@ -128,7 +129,7 @@ memchunk* b64dec(const char* string)
for (i = 0; i < vrfy; i++)
{
if (isspace(tmp[i]))
/*@innercontinue@*/ continue;
continue;
if (tmp[i] == '=')
{
@ -140,7 +141,7 @@ memchunk* b64dec(const char* string)
return 0;
/* end-of-message recognized */
/*@innerbreak@*/ break;
break;
}
else
{
@ -172,12 +173,11 @@ memchunk* b64dec(const char* string)
for (i = 0; i < length; i++)
{
register char ch = string[i];
register byte bits;
register byte bits = 0;
if (isspace(ch))
continue;
bits = 0;
if ((ch >= 'A') && (ch <= 'Z'))
{
bits = (byte) (ch - 'A');
@ -205,18 +205,18 @@ memchunk* b64dec(const char* string)
{
case 0:
data[tw+0] = (bits << 2) & 0xfc;
/*@switchbreak@*/ break;
break;
case 1:
data[tw+0] |= (bits >> 4) & 0x03;
data[tw+1] = (bits << 4) & 0xf0;
/*@switchbreak@*/ break;
break;
case 2:
data[tw+1] |= (bits >> 2) & 0x0f;
data[tw+2] = (bits << 6) & 0xc0;
/*@switchbreak@*/ break;
break;
case 3:
data[tw+2] |= bits & 0x3f;
/*@switchbreak@*/ break;
break;
}
if (qw == 4)
@ -237,11 +237,9 @@ int b64encode_chars_per_line = B64ENCODE_CHARS_PER_LINE;
const char * b64encode_eolstr = B64ENCODE_EOLSTR;
/*@-internalglobs -modfilesys @*/
char * b64encode (const void * data, size_t ns)
char* b64encode(const void* data, size_t ns)
{
static char b64enc[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static char b64enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const char *e;
const unsigned char *s = data;
unsigned char *t, *te;
@ -256,198 +254,187 @@ char * b64encode (const void * data, size_t ns)
nt = ((ns + 2) / 3) * 4;
/* Add additional bytes necessary for eol string(s). */
if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) {
lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line;
if (((nt + b64encode_chars_per_line - 1) % b64encode_chars_per_line) != 0)
++lc;
nt += lc * strlen(b64encode_eolstr);
if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL)
{
lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line;
if (((nt + b64encode_chars_per_line - 1) % b64encode_chars_per_line) != 0)
++lc;
nt += lc * strlen(b64encode_eolstr);
}
t = te = malloc(nt + 1);
lc = 0;
if (te)
while (ns > 0) {
while (ns > 0)
{
c = *s++;
*te++ = b64enc[ (c >> 2) ], lc++;
*te++ = b64enc[ ((c & 0x3) << 4) | (*s >> 4) ], lc++;
if (--ns == 0)
{
*te++ = '=';
*te++ = '=';
continue;
}
c = *s++;
*te++ = b64enc[ ((c & 0xf) << 2) | (*s >> 6) ], lc++;
if (--ns == 0)
{
*te++ = '=';
continue;
}
*te++ = b64enc[ (int)(*s & 0x3f) ], lc++;
if (_debug)
fprintf(stderr, "%7u %02x %02x %02x -> %02x %02x %02x %02x\n",
(unsigned)ns, (unsigned)s[0], (unsigned)s[1], (unsigned)s[2],
(unsigned)(s[0] >> 2),
(unsigned)((s[0] & 0x3) << 4) | (s[1] >> 4),
(unsigned)((s[1] & 0xf) << 2) | (s[2] >> 6),
(unsigned)(s[2]& 0x3f));
c = *s++;
*te++ = b64enc[ (c >> 2) ], lc++;
*te++ = b64enc[ ((c & 0x3) << 4) | (*s >> 4) ], lc++;
if (--ns == 0) {
*te++ = '=';
*te++ = '=';
continue;
/* Append eol string if desired. */
if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL)
{
if (lc >= b64encode_chars_per_line)
{
for (e = b64encode_eolstr; *e != '\0'; e++)
*te++ = *e;
lc = 0;
}
}
s++;
--ns;
}
c = *s++;
*te++ = b64enc[ ((c & 0xf) << 2) | (*s >> 6) ], lc++;
if (--ns == 0) {
*te++ = '=';
continue;
}
*te++ = b64enc[ (int)(*s & 0x3f) ], lc++;
/* Append eol string if desired. */
if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) {
if (lc >= b64encode_chars_per_line) {
for (e = b64encode_eolstr; *e != '\0'; e++)
*te++ = *e;
lc = 0;
}
}
s++;
--ns;
if (te)
{
/* Append eol string if desired. */
if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL)
{
if (lc != 0)
{
for (e = b64encode_eolstr; *e != '\0'; e++)
*te++ = *e;
}
}
*te = '\0';
}
if (te) {
/* Append eol string if desired. */
if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) {
if (lc != 0) {
for (e = b64encode_eolstr; *e != '\0'; e++)
*te++ = *e;
}
}
*te = '\0';
}
/*@-mustfree -compdef @*/
return (char *) t;
/*@=mustfree =compdef @*/
return (char*) t;
}
/*@=globs =internalglobs =modfilesys @*/
/*@-internalglobs -modfilesys @*/
#define CRC24_INIT 0xb704ceL
#define CRC24_POLY 0x1864cfbL
char * b64crc (const unsigned char * data, size_t ns)
char* b64crc (const unsigned char* data, size_t ns)
{
const unsigned char *s = data;
uint32_t crc = CRC24_INIT;
while (ns-- > 0) {
int i;
crc ^= (*s++) << 16;
for (i = 0; i < 8; i++) {
crc <<= 1;
if (crc & 0x1000000)
crc ^= CRC24_POLY;
}
while (ns-- > 0)
{
int i;
crc ^= (*s++) << 16;
for (i = 0; i < 8; i++)
{
crc <<= 1;
if (crc & 0x1000000)
crc ^= CRC24_POLY;
}
}
crc &= 0xffffff;
/*@-unrecog@*/ /* FIX: include endianness.h? */
#if !WORDS_BIGENDIAN
crc = swapu32(crc);
#endif
/*@=unrecog@*/
data = (byte *)&crc;
data++;
ns = 3;
return b64encode(data, ns);
return b64encode(data, ns);
}
/*@=internalglobs =modfilesys @*/
const char * b64decode_whitespace = B64DECODE_WHITESPACE;
const char* b64decode_whitespace = B64DECODE_WHITESPACE;
/*@-internalglobs -modfilesys @*/
int b64decode (const char * s, void ** datap, size_t *lenp)
int b64decode(const char* s, void** datap, size_t* lenp)
{
unsigned char b64dec[256];
const unsigned char *t;
unsigned char *te;
int ns, nt;
unsigned a, b, c, d;
unsigned char b64dec[256];
const unsigned char *t;
unsigned char *te;
int ns, nt;
unsigned a, b, c, d;
if (s == NULL) return 1;
/* Setup character lookup tables. */
memset(b64dec, 0x80, sizeof(b64dec));
for (c = 'A'; c <= 'Z'; c++)
b64dec[ c ] = 0 + (c - 'A');
b64dec[ c ] = 0 + (c - 'A');
for (c = 'a'; c <= 'z'; c++)
b64dec[ c ] = 26 + (c - 'a');
b64dec[ c ] = 26 + (c - 'a');
for (c = '0'; c <= '9'; c++)
b64dec[ c ] = 52 + (c - '0');
b64dec[(unsigned)'+'] = 62;
b64dec[(unsigned)'/'] = 63;
b64dec[(unsigned)'='] = 0;
b64dec[ c ] = 52 + (c - '0');
b64dec[(unsigned)'+'] = 62;
b64dec[(unsigned)'/'] = 63;
b64dec[(unsigned)'='] = 0;
/* Mark whitespace characters. */
if (b64decode_whitespace) {
const char *e;
for (e = b64decode_whitespace; *e != '\0'; e++) {
if (b64dec[ (unsigned)*e ] == 0x80)
b64dec[ (unsigned)*e ] = 0x81;
}
if (b64decode_whitespace)
{
const char *e;
for (e = b64decode_whitespace; *e != '\0'; e++)
{
if (b64dec[ (unsigned)*e ] == 0x80)
b64dec[ (unsigned)*e ] = 0x81;
}
}
/* Validate input buffer */
ns = 0;
for (t = (unsigned char *) s; *t != '\0'; t++) {
switch (b64dec[(unsigned)*t]) {
case 0x80: /* invalid chararcter */
if (_debug)
fprintf(stderr, "--- b64decode %c(%02x) %02x\n", *t, (unsigned)(*t & 0xff), (unsigned)b64dec[ (unsigned)*t ]);
return 3;
/*@notreached@*/ /*@switchbreak@*/ break;
case 0x81: /* white space */
/*@switchbreak@*/ break;
default:
ns++;
/*@switchbreak@*/ break;
}
for (t = (unsigned char*) s; *t != '\0'; t++)
{
switch (b64dec[(unsigned) *t])
{
case 0x80: /* invalid chararcter */
return 3;
case 0x81: /* white space */
break;
default:
ns++;
break;
}
}
if (((unsigned)ns) & 0x3) return 2;
if (((unsigned) ns) & 0x3) return 2;
nt = (ns / 4) * 3;
t = te = malloc(nt + 1);
while (ns > 0) {
while (ns > 0)
{
/* Get next 4 characters, ignoring whitespace. */
while ((a = b64dec[ (unsigned)*s++ ]) == 0x81)
;
while ((b = b64dec[ (unsigned)*s++ ]) == 0x81)
;
while ((c = b64dec[ (unsigned)*s++ ]) == 0x81)
;
while ((d = b64dec[ (unsigned)*s++ ]) == 0x81)
;
/* Get next 4 characters, ignoring whitespace. */
while ((a = b64dec[ (unsigned)*s++ ]) == 0x81)
{};
while ((b = b64dec[ (unsigned)*s++ ]) == 0x81)
{};
while ((c = b64dec[ (unsigned)*s++ ]) == 0x81)
{};
while ((d = b64dec[ (unsigned)*s++ ]) == 0x81)
{};
if (_debug)
fprintf(stderr, "%7u %02x %02x %02x %02x -> %02x %02x %02x\n",
(unsigned)ns, a, b, c, d,
(((a << 2) | (b >> 4)) & 0xff),
(((b << 4) | (c >> 2)) & 0xff),
(((c << 6) | d) & 0xff));
ns -= 4;
*te++ = (a << 2) | (b >> 4);
if (s[-2] == '=') break;
*te++ = (b << 4) | (c >> 2);
if (s[-1] == '=') break;
*te++ = (c << 6) | d;
ns -= 4;
*te++ = (a << 2) | (b >> 4);
if (s[-2] == '=') break;
*te++ = (b << 4) | (c >> 2);
if (s[-1] == '=') break;
*te++ = (c << 6) | d;
}
if (ns != 0) { /* XXX can't happen, just in case */
if (t) free((void *)t);
return 1;
if (ns != 0)
{ /* XXX can't happen, just in case */
if (t) free((void *)t);
return 1;
}
if (lenp)
*lenp = (te - t);
*lenp = (te - t);
if (datap)
*datap = (void *)t;
*datap = (void *)t;
else
if (t) free((void *)t);
if (t) free((void *)t);
return 0;
}
/*@=globs =internalglobs =modfilesys @*/
/*@=type@*/

View File

@ -19,84 +19,72 @@
/*!\file base64.h
* \brief Base64 encoding and decoding, headers.
* \author Bob Deblier <bob@virtualunlimited.com>
* \author Bob Deblier <bob.deblier@pandora.be>
*/
#ifndef _BASE64_H
#define _BASE64_H
#include "beecrypt.h"
#include "beecrypt/beecrypt.h"
/**
/*!\
* Decode white space character set (default).
*/
/*@-exportlocal@*/
/*@unchecked@*/ /*@observer@*/ /*@null@*/
extern const char * b64decode_whitespace;
/*@=exportlocal@*/
extern const char* b64decode_whitespace;
#define B64DECODE_WHITESPACE " \f\n\r\t\v"
/**
/*!\
* Encode 72 characters per line (default).
*/
/*@-exportlocal@*/
/*@unchecked@*/
extern int b64encode_chars_per_line;
/*@=exportlocal@*/
#define B64ENCODE_CHARS_PER_LINE 72
/**
/*!\
* Encode end-of-line string (default).
*/
/*@-exportlocal@*/
/*@unchecked@*/ /*@observer@*/ /*@null@*/
extern const char * b64encode_eolstr;
/*@=exportlocal@*/
extern const char* b64encode_eolstr;
#define B64ENCODE_EOLSTR "\n"
#ifdef __cplusplus
extern "C" {
#endif
/**
/*!
* Encode chunks of 3 bytes of binary input into 4 bytes of base64 output.
* @param data binary data
* @param ns no. bytes of data (0 uses strlen(data))
* @return (malloc'd) base64 string
* \param data binary data
* \param ns no. bytes of data (0 uses strlen(data))
* \return (malloc'd) base64 string
*/
BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
char * b64encode (const void * data, size_t ns)
/*@*/;
BEECRYPTAPI
char* b64encode(const void* data, size_t ns);
/**
/*!
* Encode crc of binary input data into 5 bytes of base64 output.
* @param data binary data
* @param ns no. bytes of binary data
* @return (malloc'd) base64 string
* \param data binary data
* \param ns no. bytes of binary data
* \return (malloc'd) base64 string
*/
BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
char * b64crc (const unsigned char * data, size_t ns)
/*@*/;
BEECRYPTAPI
char* b64crc(const unsigned char* data, size_t ns);
/**
/*!
* Decode chunks of 4 bytes of base64 input into 3 bytes of binary output.
* @param s base64 string
* @retval datap address of (malloc'd) binary data
* @retval lenp address of no. bytes of binary data
* @return 0 on success, 1: s == NULL, 2: bad length, 3: bad char
* \param s base64 string
* \retval datap address of (malloc'd) binary data
* \retval lenp address of no. bytes of binary data
* \return 0 on success, 1: s == NULL, 2: bad length, 3: bad char
*/
BEECRYPTAPI /*@unused@*/
int b64decode (const char * s, /*@out@*/ void ** datap, /*@out@*/ size_t *lenp)
/*@modifies *datap, *lenp @*/;
BEECRYPTAPI
int b64decode(const char* s, void** datap, size_t* lenp);
/**
/*!
*/
BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
BEECRYPTAPI
char* b64enc(const memchunk*);
/**
/*!
*/
BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
BEECRYPTAPI
memchunk* b64dec(const char*);
#ifdef __cplusplus

View File

@ -1,4 +1,3 @@
/*@-compdef -sizeoftype@*/
/*
* Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
*
@ -23,27 +22,31 @@
* \ingroup ES_m PRNG_m HASH_m HMAC_m BC_m
*/
#include "system.h"
#include "beecrypt.h"
#define BEECRYPT_DLL_EXPORT
#include "entropy.h"
#include "fips186.h"
#include "hmacmd5.h"
#include "hmacsha1.h"
#include "hmacsha256.h"
#include "md5.h"
#include "mp.h"
#include "mtprng.h"
#include "sha1.h"
#include "sha256.h"
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "aes.h"
#include "blowfish.h"
#include "blockmode.h"
#include "beecrypt/beecrypt.h"
#include "debug.h"
#include "beecrypt/entropy.h"
#include "beecrypt/fips186.h"
#include "beecrypt/mtprng.h"
#include "beecrypt/md5.h"
#include "beecrypt/sha1.h"
#include "beecrypt/sha256.h"
#include "beecrypt/hmacmd5.h"
#include "beecrypt/hmacsha1.h"
#include "beecrypt/hmacsha256.h"
#include "beecrypt/aes.h"
#include "beecrypt/blowfish.h"
#include "beecrypt/blockmode.h"
/*@observer@*/ /*@unchecked@*/
static entropySource entropySourceList[] =
{
#if WIN32
@ -108,10 +111,7 @@ const entropySource* entropySourceDefault()
{
return entropySourceList+0;
}
else
{
return (const entropySource*) 0;
}
return (const entropySource*) 0;
}
int entropyGatherNext(byte* data, size_t size)
@ -138,7 +138,6 @@ int entropyGatherNext(byte* data, size_t size)
return -1;
}
/*@observer@*/ /*@unchecked@*/
static const randomGenerator* randomGeneratorList[] =
{
&fips186prng,
@ -157,9 +156,7 @@ const randomGenerator* randomGeneratorGet(int index)
if ((index < 0) || (index >= RANDOMGENERATORS))
return (const randomGenerator*) 0;
/*@-compmempass@*/
return randomGeneratorList[index];
/*@=compmempass@*/
}
const randomGenerator* randomGeneratorFind(const char* name)
@ -169,9 +166,7 @@ const randomGenerator* randomGeneratorFind(const char* name)
for (index = 0; index < RANDOMGENERATORS; index++)
{
if (strcmp(name, randomGeneratorList[index]->name) == 0)
/*@-compmempass@*/
return randomGeneratorList[index];
/*@=compmempass@*/
}
return (const randomGenerator*) 0;
}
@ -183,9 +178,7 @@ const randomGenerator* randomGeneratorDefault()
if (selection)
return randomGeneratorFind(selection);
else
/*@-compmempass @*/
return &fips186prng;
/*@=compmempass @*/
}
int randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerator* rng)
@ -197,40 +190,42 @@ int randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerat
return -1;
ctxt->rng = rng;
ctxt->param = (randomGeneratorParam*) calloc(rng->paramsize, 1);
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
if (ctxt->param == (randomGeneratorParam*) 0)
return -1;
if (rng->paramsize)
{
ctxt->param = (randomGeneratorParam*) calloc(rng->paramsize, 1);
if (ctxt->param == (randomGeneratorParam*) 0)
return -1;
}
else
ctxt->param = (randomGeneratorParam*) 0;
return ctxt->rng->setup(ctxt->param);
/*@=nullstate@*/
}
int randomGeneratorContextFree(randomGeneratorContext* ctxt)
{
register int rc;
register int rc = 0;
/*@-mustfree@*/
if (ctxt == (randomGeneratorContext*) 0)
return -1;
if (ctxt->rng == (randomGenerator*) 0)
return -1;
if (ctxt->param == (randomGeneratorParam*) 0)
return -1;
/*@=mustfree@*/
if (ctxt->rng->paramsize)
{
if (ctxt->param == (randomGeneratorParam*) 0)
return -1;
rc = ctxt->rng->cleanup(ctxt->param);
rc = ctxt->rng->cleanup(ctxt->param);
free(ctxt->param);
free(ctxt->param);
ctxt->param = (randomGeneratorParam*) 0;
}
ctxt->param = (randomGeneratorParam*) 0;
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
return rc;
/*@=nullstate@*/
}
int randomGeneratorContextNext(randomGeneratorContext* ctxt, byte* data, size_t size)
@ -238,7 +233,11 @@ int randomGeneratorContextNext(randomGeneratorContext* ctxt, byte* data, size_t
return ctxt->rng->next(ctxt->param, data, size);
}
/*@observer@*/ /*@unchecked@*/
int randomGeneratorContextSeed(randomGeneratorContext* ctxt, const byte* data, size_t size)
{
return ctxt->rng->seed(ctxt->param, data, size);
}
static const hashFunction* hashFunctionList[] =
{
&md5,
@ -260,9 +259,7 @@ const hashFunction* hashFunctionDefault()
if (selection)
return hashFunctionFind(selection);
else
/*@-compmempass @*/
return &sha1;
/*@=compmempass @*/
}
const hashFunction* hashFunctionGet(int index)
@ -270,9 +267,7 @@ const hashFunction* hashFunctionGet(int index)
if ((index < 0) || (index >= HASHFUNCTIONS))
return (const hashFunction*) 0;
/*@-compmempass@*/
return hashFunctionList[index];
/*@=compmempass@*/
}
const hashFunction* hashFunctionFind(const char* name)
@ -282,9 +277,7 @@ const hashFunction* hashFunctionFind(const char* name)
for (index = 0; index < HASHFUNCTIONS; index++)
{
if (strcmp(name, hashFunctionList[index]->name) == 0)
/*@-compmempass@*/
return hashFunctionList[index];
/*@=compmempass@*/
}
return (const hashFunction*) 0;
}
@ -300,31 +293,25 @@ int hashFunctionContextInit(hashFunctionContext* ctxt, const hashFunction* hash)
ctxt->algo = hash;
ctxt->param = (hashFunctionParam*) calloc(hash->paramsize, 1);
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
if (ctxt->param == (hashFunctionParam*) 0)
return -1;
return ctxt->algo->reset(ctxt->param);
/*@=nullstate@*/
}
int hashFunctionContextFree(hashFunctionContext* ctxt)
{
/*@-mustfree@*/
if (ctxt == (hashFunctionContext*) 0)
return -1;
if (ctxt->param == (hashFunctionParam*) 0)
return -1;
/*@=mustfree@*/
free(ctxt->param);
ctxt->param = (hashFunctionParam*) 0;
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
return 0;
/*@=nullstate@*/
}
int hashFunctionContextReset(hashFunctionContext* ctxt)
@ -389,22 +376,25 @@ int hashFunctionContextUpdateMP(hashFunctionContext* ctxt, const mpnumber* n)
if (n != (mpnumber*) 0)
{
int rc;
byte* tmp = (byte*) malloc(MP_WORDS_TO_BYTES(n->size) + 1);
/* get the number of significant bits in the number */
size_t sig = mpbits(n->size, n->data);
/* calculate how many bytes we need for a java-style encoding;
* if the most significant bit of the most significant byte
* is set, then we need to prefix a zero byte.
*/
size_t req = ((sig+7) >> 3) + (((sig&7) == 0) ? 1 : 0);
byte* tmp = (byte*) malloc(req);
if (tmp == (byte*) 0)
return -1;
if (mpmsbset(n->size, n->data))
{
tmp[0] = 0;
(void) i2osp(tmp+1, MP_WORDS_TO_BYTES(n->size), n->data, n->size);
rc = ctxt->algo->update(ctxt->param, tmp, MP_WORDS_TO_BYTES(n->size) + 1);
}
else
{
(void) i2osp(tmp, MP_WORDS_TO_BYTES(n->size), n->data, n->size);
rc = ctxt->algo->update(ctxt->param, tmp, MP_WORDS_TO_BYTES(n->size));
}
i2osp(tmp, req, n->data, n->size);
rc = ctxt->algo->update(ctxt->param, tmp, req);
free(tmp);
return rc;
@ -477,12 +467,9 @@ int hashFunctionContextDigestMatch(hashFunctionContext* ctxt, const mpnumber* d)
mpnfree(&match);
/*@-mustfree@*/ /* dig.data is OK */
return rc;
/*@=mustfree@*/
}
/*@observer@*/ /*@unchecked@*/
static const keyedHashFunction* keyedHashFunctionList[] =
{
&hmacmd5,
@ -504,9 +491,7 @@ const keyedHashFunction* keyedHashFunctionDefault()
if (selection)
return keyedHashFunctionFind(selection);
else
/*@-compmempass @*/
return &hmacsha1;
/*@=compmempass @*/
}
const keyedHashFunction* keyedHashFunctionGet(int index)
@ -514,9 +499,7 @@ const keyedHashFunction* keyedHashFunctionGet(int index)
if ((index < 0) || (index >= KEYEDHASHFUNCTIONS))
return (const keyedHashFunction*) 0;
/*@-compmempass@*/
return keyedHashFunctionList[index];
/*@=compmempass@*/
}
const keyedHashFunction* keyedHashFunctionFind(const char* name)
@ -526,9 +509,7 @@ const keyedHashFunction* keyedHashFunctionFind(const char* name)
for (index = 0; index < KEYEDHASHFUNCTIONS; index++)
{
if (strcmp(name, keyedHashFunctionList[index]->name) == 0)
/*@-compmempass@*/
return keyedHashFunctionList[index];
/*@=compmempass@*/
}
return (const keyedHashFunction*) 0;
}
@ -544,17 +525,14 @@ int keyedHashFunctionContextInit(keyedHashFunctionContext* ctxt, const keyedHash
ctxt->algo = mac;
ctxt->param = (keyedHashFunctionParam*) calloc(mac->paramsize, 1);
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
if (ctxt->param == (keyedHashFunctionParam*) 0)
return -1;
return ctxt->algo->reset(ctxt->param);
/*@=nullstate@*/
}
int keyedHashFunctionContextFree(keyedHashFunctionContext* ctxt)
{
/*@-mustfree@*/
if (ctxt == (keyedHashFunctionContext*) 0)
return -1;
@ -563,15 +541,12 @@ int keyedHashFunctionContextFree(keyedHashFunctionContext* ctxt)
if (ctxt->param == (keyedHashFunctionParam*) 0)
return -1;
/*@=mustfree@*/
free(ctxt->param);
ctxt->param = (keyedHashFunctionParam*) 0;
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
return 0;
/*@=nullstate@*/
}
int keyedHashFunctionContextSetup(keyedHashFunctionContext* ctxt, const byte* key, size_t keybits)
@ -652,23 +627,27 @@ int keyedHashFunctionContextUpdateMP(keyedHashFunctionContext* ctxt, const mpnum
if (n != (mpnumber*) 0)
{
register int rc;
register byte* temp = (byte*) malloc(MP_WORDS_TO_BYTES(n->size)+1);
if (temp == (byte*) 0)
int rc;
/* get the number of significant bits in the number */
size_t sig = mpbits(n->size, n->data);
/* calculate how many bytes we need a java-style encoding; if the
* most significant bit of the most significant byte is set, then
* we need to prefix a zero byte.
*/
size_t req = ((sig+7) >> 3) + (((sig&7) == 0) ? 1 : 0);
byte* tmp = (byte*) malloc(req);
if (tmp == (byte*) 0)
return -1;
if (mpmsbset(n->size, n->data))
{
temp[0] = 0;
(void) i2osp(temp+1, MP_WORDS_TO_BYTES(n->size), n->data, n->size);
rc = ctxt->algo->update(ctxt->param, temp, MP_WORDS_TO_BYTES(n->size)+1);
}
else
{
(void) i2osp(temp, MP_WORDS_TO_BYTES(n->size), n->data, n->size);
rc = ctxt->algo->update(ctxt->param, temp, MP_WORDS_TO_BYTES(n->size));
}
free(temp);
i2osp(tmp, req, n->data, n->size);
rc = ctxt->algo->update(ctxt->param, tmp, req);
free(tmp);
return rc;
}
@ -692,7 +671,7 @@ int keyedHashFunctionContextDigest(keyedHashFunctionContext* ctxt, byte* digest)
return ctxt->algo->digest(ctxt->param, digest);
}
int keyedHashFunctionContextDigestMP(keyedHashFunctionContext* ctxt, const mpnumber* d)
int keyedHashFunctionContextDigestMP(keyedHashFunctionContext* ctxt, mpnumber* d)
{
if (ctxt == (keyedHashFunctionContext*) 0)
return -1;
@ -740,12 +719,9 @@ int keyedHashFunctionContextDigestMatch(keyedHashFunctionContext* ctxt, const mp
mpnfree(&match);
/*@-mustfree@*/ /* dig.data is OK */
return rc;
/*@=mustfree@*/
}
/*@observer@*/ /*@unchecked@*/
static const blockCipher* blockCipherList[] =
{
&aes,
@ -766,9 +742,7 @@ const blockCipher* blockCipherDefault()
if (selection)
return blockCipherFind(selection);
else
/*@-compmempass @*/
return &aes;
/*@=compmempass @*/
}
const blockCipher* blockCipherGet(int index)
@ -776,9 +750,7 @@ const blockCipher* blockCipherGet(int index)
if ((index < 0) || (index >= BLOCKCIPHERS))
return (const blockCipher*) 0;
/*@-compmempass@*/
return blockCipherList[index];
/*@=compmempass@*/
}
const blockCipher* blockCipherFind(const char* name)
@ -788,9 +760,7 @@ const blockCipher* blockCipherFind(const char* name)
for (index = 0; index < BLOCKCIPHERS; index++)
{
if (strcmp(name, blockCipherList[index]->name) == 0)
/*@-compmempass@*/
return blockCipherList[index];
/*@=compmempass@*/
}
return (const blockCipher*) 0;
@ -808,12 +778,10 @@ int blockCipherContextInit(blockCipherContext* ctxt, const blockCipher* ciph)
ctxt->param = (blockCipherParam*) calloc(ciph->paramsize, 1);
ctxt->op = NOCRYPT;
/*@-nullstate@*/ /* FIX: ctxt->param may be NULL */
if (ctxt->param == (blockCipherParam*) 0)
return -1;
return 0;
/*@=nullstate@*/
}
int blockCipherContextSetup(blockCipherContext* ctxt, const byte* key, size_t keybits, cipherOperation op)
@ -853,78 +821,62 @@ int blockCipherContextSetIV(blockCipherContext* ctxt, const byte* iv)
int blockCipherContextFree(blockCipherContext* ctxt)
{
/*@-mustfree@*/
if (ctxt == (blockCipherContext*) 0)
return -1;
if (ctxt->param == (blockCipherParam*) 0)
return -1;
/*@=mustfree@*/
free(ctxt->param);
ctxt->param = (blockCipherParam*) 0;
/*@-nullstate@*/ /* FIX: ctxt->param is NULL */
return 0;
/*@=nullstate@*/
}
int blockCipherContextECB(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, size_t nblocks)
int blockCipherContextECB(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, int nblocks)
{
switch (ctxt->op)
{
case NOCRYPT:
/*@-mayaliasunique@*/
memcpy(dst, src, nblocks * ctxt->algo->blocksize);
/*@=mayaliasunique@*/
return 0;
/*@notreached@*/ break;
case ENCRYPT:
return (ctxt->algo->ecb.encrypt) ?
ctxt->algo->ecb.encrypt(ctxt->param, dst, src, nblocks) :
blockEncryptECB(ctxt->algo, ctxt->param, dst, src, nblocks);
/*@notreached@*/ break;
case DECRYPT:
return (ctxt->algo->ecb.decrypt) ?
ctxt->algo->ecb.decrypt(ctxt->param, dst, src, nblocks) :
blockDecryptECB(ctxt->algo, ctxt->param, dst, src, nblocks);
/*@notreached@*/ break;
}
/*@notreached@*/
return -1;
}
int blockCipherContextCBC(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, size_t nblocks)
int blockCipherContextCBC(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, int nblocks)
{
switch (ctxt->op)
{
case NOCRYPT:
/*@-mayaliasunique@*/
memcpy(dst, src, nblocks * ctxt->algo->blocksize);
/*@=mayaliasunique@*/
return 0;
/*@notreached@*/ break;
case ENCRYPT:
return (ctxt->algo->cbc.encrypt) ?
ctxt->algo->cbc.encrypt(ctxt->param, dst, src, nblocks) :
blockEncryptCBC(ctxt->algo, ctxt->param, dst, src, nblocks);
/*@notreached@*/ break;
case DECRYPT:
return (ctxt->algo->cbc.decrypt) ?
ctxt->algo->cbc.decrypt(ctxt->param, dst, src, nblocks) :
blockDecryptCBC(ctxt->algo, ctxt->param, dst, src, nblocks);
/*@notreached@*/ break;
}
/*@notreached@*/
return -1;
}
#if WIN32
__declspec(dllexport)
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD wDataSeg, LPVOID lpReserved)
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID lpReserved)
{
switch (wDataSeg)
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
entropy_provider_setup(hInst);
@ -933,7 +885,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD wDataSeg, LPVOID lpReserved)
entropy_provider_cleanup();
break;
}
return TRUE;
return TRUE;
}
#endif
/*@=compdef =sizeoftype@*/

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,8 +1,8 @@
#include <winver.h>
1 VERSIONINFO
FILEVERSION 3,0,0,0
PRODUCTVERSION 3,0,0,0
FILEVERSION 3,1,0,0
PRODUCTVERSION 3,1,0,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0x0L
FILEOS VOS__WINDOWS32
@ -15,13 +15,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Virtual Unlimited B.V.\0"
VALUE "FileDescription", "BeeCrypt Cryptography Library\0"
VALUE "FileVersion", "3.0.0\0"
VALUE "FileVersion", "3.1.0\0"
VALUE "InternalName", "beecrypt\0"
VALUE "LegalCopyright", "Copyright (c) 1997-2003 Virtual Unlimited B.V.\0"
VALUE "LegalTradeMarks", "BeeCrypt is a trademark of Virtual Unlimited B.V.\0"
VALUE "OriginalFileName", "BEECRYPT.DLL\0"
VALUE "ProductName", "BeeCrypt\0"
VALUE "ProductVersion", "3.0.0\0"
VALUE "ProductVersion", "3.1.0\0"
END
END
BLOCK "VarFileInfo"

View File

@ -1,63 +0,0 @@
Summary: The BeeCrypt Cryptography Library
Name: beecrypt
Version: 2.2.0
Release: 1
Copyright: LGPL
Group: Development/Libraries
Source0: http://beecrypt.virtualunlimited.com/download/beecrypt-%{version}.tar.gz
URL: http://beecrypt.virtualunlimited.com/
Buildroot: %{_tmppath}/%{name}-root
%description
The BeeCrypt Cryptography Library.
%package devel
Summary: The BeeCrypt Cryptography Library headers
Group: Development/Libraries
Requires: beecrypt = %{version}
%description devel
The BeeCrypt Cryptography Library headers.
%prep
%setup -q
%build
%configure --enable-static
make
make apidocs
%install
rm -rf ${RPM_BUILD_ROOT}
make DESTDIR="${RPM_BUILD_ROOT}" install
%clean
rm -rf ${RPM_BUILD_ROOT}
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root)
%doc BENCHMARKS NEWS README*
%{_libdir}/libbeecrypt.so.@VERSION@
%files devel
%defattr(-,root,root)
%doc BUGS ChangeLog apidocs/*
%{_libdir}/libbeecrypt.so.2
%{_libdir}/libbeecrypt.so
%{_libdir}/libbeecrypt.la
%{_libdir}/libbeecrypt.a
%{_includedir}/beecrypt
%changelog
* Mon Oct 8 2001 Jeff Johnson <jbj@redhat.com>
- upgrade to 2.2.0pre.
* Mon Sep 24 2001 Jeff Johnsopn <jbj@redhat.com>
- add static libraries.
* Tue Sep 18 2001 Jeff Johnson <jbj@redhat.com>
- repackage.

View File

@ -23,14 +23,13 @@
* \ingroup BC_m
*/
#include "system.h"
#include "blockmode.h"
#include "mp.h"
#include "debug.h"
#define BEECRYPT_DLL_EXPORT
/*!\addtogroup BC_m
* \{
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/blockmode.h"
int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
{
@ -38,9 +37,7 @@ int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
while (nblocks > 0)
{
/*@-noeffectuncon@*/
(void) bc->raw.encrypt(bp, dst, src);
/*@=noeffectuncon@*/
bc->raw.encrypt(bp, dst, src);
dst += blockwords;
src += blockwords;
@ -57,9 +54,7 @@ int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
while (nblocks > 0)
{
/*@-noeffectuncon@*/
(void) bc->raw.decrypt(bp, dst, src);
/*@=noeffectuncon@*/
bc->raw.decrypt(bp, dst, src);
dst += blockwords;
src += blockwords;
@ -82,24 +77,20 @@ int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
for (i = 0; i < blockwords; i++)
dst[i] = src[i] ^ fdback[i];
/*@-noeffectuncon@*/
(void) bc->raw.encrypt(bp, dst, dst);
/*@=noeffectuncon@*/
bc->raw.encrypt(bp, dst, dst);
src += blockwords;
nblocks--;
/*@-usedef@*/ /* LCL: dst is initialized. */
while (nblocks > 0)
{
for (i = 0; i < blockwords; i++)
dst[i+blockwords] = src[i] ^ dst[i];
dst += blockwords;
/*@-noeffectuncon@*/
(void) bc->raw.encrypt(bp, dst, dst);
/*@=noeffectuncon@*/
bc->raw.encrypt(bp, dst, dst);
src += blockwords;
@ -110,7 +101,6 @@ int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
for (i = 0; i < blockwords; i++)
fdback[i] = dst[i];
/*@=usedef@*/
}
return 0;
@ -120,7 +110,7 @@ int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
{
register const unsigned int blockwords = bc->blocksize >> 2;
register uint32_t* fdback = bc->getfb(bp);
register uint32_t* buf = (uint32_t*) malloc(blockwords * sizeof(*buf));
register uint32_t* buf = (uint32_t*) malloc(blockwords * sizeof(uint32_t));
if (buf)
{
@ -129,16 +119,12 @@ int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
register uint32_t tmp;
register unsigned int i;
/*@-noeffectuncon@*/
(void) bc->raw.decrypt(bp, buf, src);
/*@=noeffectuncon@*/
bc->raw.decrypt(bp, buf, src);
for (i = 0; i < blockwords; i++)
{
tmp = src[i];
/*@-usedef@*/ /* LCL: buf is initialized. */
dst[i] = buf[i] ^ fdback[i];
/*@-usedef@*/
fdback[i] = tmp;
}
@ -153,6 +139,3 @@ int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst,
return -1;
}
/*!\}
*/

View File

@ -27,63 +27,63 @@
#ifndef _BLOCKMODE_H
#define _BLOCKMODE_H
#include "beecrypt.h"
#include "beecrypt/beecrypt.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Encrypts multiple blocks in Electronic Code Book (ECB) mode.
* @param bc blockcipher context
* @param bp blockcipher parameters
* @retval dst ciphertext data (aligned on a 32-bit boundary).
* @param src cleartext data (aligned on a 32-bit boundary).
* @param nblocks number of blocks to be encrypted.
* @retval 0 on success.
/*!\fn int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
* \brief This function encrypts a number of data blocks in Electronic Code
* Book mode.
* \param bc The blockcipher.
* \param bp The cipher's parameter block.
* \param dst The ciphertext data; should be aligned on a 32-bit boundary.
* \param src The cleartext data; should be aligned on a 32-bit boundary.
* \param nblocks The number of blocks to be encrypted.
* \retval 0 on success.
*/
BEECRYPTAPI
int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, /*@out@*/ uint32_t* dst, const uint32_t* src, unsigned int nblocks)
/*@modifies bp, dst @*/;
int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks);
/**
* Decrypts multiple blocks in Electronic Code Book (ECB) mode.
* @param bc blockcipher context
* @param bp blockcipher parameters
* @retval dst ciphertext data (aligned on a 32-bit boundary).
* @param src cleartext data (aligned on a 32-bit boundary).
* @param nblocks number of blocks to be encrypted.
* @retval 0 on success.
/*!\fn int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
* \brief This function decrypts a number of data blocks in Electronic Code
* Book mode.
* \param bc The blockcipher.
* \param bp The cipher's parameter block.
* \param dst The cleartext data; should be aligned on a 32-bit boundary.
* \param src The ciphertext data; should be aligned on a 32-bit boundary.
* \param nblocks The number of blocks to be decrypted.
* \retval 0 on success.
*/
BEECRYPTAPI
int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, /*@out@*/ uint32_t* dst, const uint32_t* src, unsigned int nblocks)
/*@modifies bp, dst @*/;
int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks);
/**
* Encrypts multiple blocks in Cipher Block Chaining (CBC) mode.
* @param bc blockcipher context
* @param bp blockcipher parameters
* @retval dst ciphertext data (aligned on a 32-bit boundary).
* @param src cleartext data (aligned on a 32-bit boundary).
* @param nblocks number of blocks to be encrypted.
* @retval 0 on success.
/*!\fn int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
* \brief This function encrypts a number of data blocks in Cipher Block
* Chaining mode.
* \param bc The blockcipher.
* \param bp The cipher's parameter block.
* \param dst The ciphertext data; should be aligned on a 32-bit boundary.
* \param src The cleartext data; should be aligned on a 32-bit boundary.
* \param nblocks The number of blocks to be encrypted.
* \retval 0 on success.
*/
BEECRYPTAPI
int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, /*@out@*/ uint32_t* dst, const uint32_t* src, unsigned int nblocks)
/*@modifies bp, dst @*/;
int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks);
/**
* Decrypts multiple blocks in Cipher Block Chaining (CBC) mode.
* @param bc blockcipher context
* @param bp blockcipher parameters
* @retval dst ciphertext data (aligned on a 32-bit boundary).
* @param src cleartext data (aligned on a 32-bit boundary).
* @param nblocks number of blocks to be encrypted.
* @retval 0 on success.
/*!\fn int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
* \brief This function decrypts a number of data blocks in Cipher Block
* Chaining mode.
* \param bc The blockcipher.
* \param bp The cipher's parameter block.
* \param dst The cleartext data; should be aligned on a 32-bit boundary.
* \param src The ciphertext data; should be aligned on a 32-bit boundary.
* \param nblocks The number of blocks to be decrypted.
* \retval 0 on success.
*/
BEECRYPTAPI
int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, /*@out@*/ uint32_t* dst, const uint32_t* src, unsigned int nblocks)
/*@modifies bp, dst @*/;
int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks);
#ifdef __cplusplus
}

View File

@ -23,9 +23,13 @@
* \ingroup BC_m
*/
#include "system.h"
#include "blockpad.h"
#include "debug.h"
#define BEECRYPT_DLL_EXPORT
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/blockpad.h"
memchunk* pkcs5Pad(size_t blockbytes, memchunk* tmp)
{
@ -46,14 +50,10 @@ memchunk* pkcs5Unpad(size_t blockbytes, memchunk* tmp)
{
if (tmp)
{
byte padvalue;
byte padvalue = tmp->data[tmp->size - 1];
unsigned int i;
/*@-usedef@*/ /* LCL: tmp->{data,size} not initialized? */
if (tmp->data == (byte*) 0)
return (memchunk*) 0;
padvalue = tmp->data[tmp->size - 1];
/*@=usedef@*/
if (padvalue > blockbytes)
return (memchunk*) 0;
@ -64,12 +64,10 @@ memchunk* pkcs5Unpad(size_t blockbytes, memchunk* tmp)
}
tmp->size -= padvalue;
/* tmp->data = (byte*) realloc(tmp->data, tmp->size; */
/* tmp->data = (byte*) realloc(tmp->data, tmp->size); */
}
/*@-temptrans -compdef @*/
return tmp;
/*@=temptrans =compdef @*/
}
memchunk* pkcs5PadCopy(size_t blockbytes, const memchunk* src)
@ -91,7 +89,7 @@ memchunk* pkcs5PadCopy(size_t blockbytes, const memchunk* src)
return tmp;
}
memchunk* pkcs5UnpadCopy(/*@unused@*/ size_t blockbytes, const memchunk* src)
memchunk* pkcs5UnpadCopy(size_t blockbytes, const memchunk* src)
{
memchunk* tmp;
byte padvalue;
@ -99,8 +97,6 @@ memchunk* pkcs5UnpadCopy(/*@unused@*/ size_t blockbytes, const memchunk* src)
if (src == (memchunk*) 0)
return (memchunk*) 0;
if (src->data == (byte*) 0)
return (memchunk*) 0;
padvalue = src->data[src->size - 1];

View File

@ -26,52 +26,21 @@
#ifndef _BLOCKPAD_H
#define _BLOCKPAD_H
#include "beecrypt.h"
#include "beecrypt/beecrypt.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Enlarge buffer to boundary.
* @param blockbytes desired block alignment/pad boundary
* @param tmp buffer to pad
* @return buffer with pad added
*/
BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
memchunk* pkcs5Pad (size_t blockbytes, /*@only@*/ /*@null@*/ memchunk* tmp)
/*@*/;
BEECRYPTAPI
memchunk* pkcs5Pad (size_t, memchunk*);
BEECRYPTAPI
memchunk* pkcs5Unpad(size_t, memchunk*);
/**
* Shrink buffer to boundary.
* @param blockbytes desired block alignment/pad boundary
* @param tmp buffer to unpad
* @return buffer with pad removed
*/
BEECRYPTAPI /*@only@*/ /*@null@*/
memchunk* pkcs5Unpad(size_t blockbytes,
/*@returned@*/ /*@null@*/ /*@out@*/ memchunk* tmp)
/*@modifies tmp @*/;
/**
* Copy/enlarge buffer to boundary.
* @param blockbytes desired block alignment/pad boundary
* @param src buffer to pad
* @return copy of buffer with pad added
*/
BEECRYPTAPI /*@only@*/ /*@null@*/
memchunk* pkcs5PadCopy (size_t blockbytes, const memchunk* src)
/*@*/;
/**
* Copy/shrink buffer to boundary.
* @param blockbytes desired block alignment/pad boundary
* @param src buffer to unpad
* @return copy of buffer with pad removed
*/
BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
memchunk* pkcs5UnpadCopy(size_t blockbytes, const memchunk* src)
/*@*/;
BEECRYPTAPI
memchunk* pkcs5PadCopy (size_t, const memchunk*);
BEECRYPTAPI
memchunk* pkcs5UnpadCopy(size_t, const memchunk*);
#ifdef __cplusplus
}

View File

@ -23,12 +23,14 @@
* \ingroup BC_m BC_blowfish_m
*/
#include "system.h"
#include "beecrypt.h"
#include "blowfishopt.h"
#include "blowfish.h"
#include "endianness.h"
#include "debug.h"
#define BEECRYPT_DLL_EXPORT
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/blowfish.h"
#include "beecrypt/endianness.h"
#ifdef ASM_BLOWFISHENCRYPTECB
extern int blowfishEncryptECB(blowfishparam*, uint32_t*, const uint32_t*, unsigned int);
@ -38,13 +40,6 @@ extern int blowfishEncryptECB(blowfishparam*, uint32_t*, const uint32_t*, unsign
extern int blowfishDecryptECB(blowfishparam*, uint32_t*, const uint32_t*, unsigned int);
#endif
/*!\addtogroup BC_blowfish_m
* \{
*/
/**
*/
/*@observer@*/ /*@unchecked@*/
static uint32_t _bf_p[BLOWFISHPSIZE] = {
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
@ -53,9 +48,6 @@ static uint32_t _bf_p[BLOWFISHPSIZE] = {
0x9216d5d9, 0x8979fb1b
};
/**
*/
/*@observer@*/ /*@unchecked@*/
static uint32_t _bf_s[1024] = {
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
@ -318,15 +310,13 @@ static uint32_t _bf_s[1024] = {
#define EROUND(l,r) l ^= *(p++); r ^= ((s[((l>>24)&0xff)+0x000]+s[((l>>16)&0xff)+0x100])^s[((l>>8)&0xff)+0x200])+s[((l>>0)&0xff)+0x300]
#define DROUND(l,r) l ^= *(p--); r ^= ((s[((l>>24)&0xff)+0x000]+s[((l>>16)&0xff)+0x100])^s[((l>>8)&0xff)+0x200])+s[((l>>0)&0xff)+0x300]
/*@-sizeoftype@*/
/*@-castfcnptr@*/
const blockCipher blowfish = {
"Blowfish",
sizeof(blowfishParam),
8U,
64U,
448U,
32U,
8,
64,
448,
32,
(blockCipherSetup) blowfishSetup,
(blockCipherSetIV) blowfishSetIV,
/* raw */
@ -354,8 +344,6 @@ const blockCipher blowfish = {
},
(blockCipherFeedback) blowfishFeedback
};
/*@=castfcnptr@*/
/*@=sizeoftype@*/
int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOperation op)
{
@ -370,7 +358,7 @@ int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOper
uint32_t tmp, work[2];
memcpy(s, _bf_s, 1024 * sizeof(*s));
memcpy(s, _bf_s, 1024 * sizeof(uint32_t));
for (i = 0, k = 0; i < BLOWFISHPSIZE; i++)
{
@ -389,7 +377,7 @@ int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOper
for (i = 0; i < BLOWFISHPSIZE; i += 2, p += 2)
{
(void) blowfishEncrypt(bp, work, work);
blowfishEncrypt(bp, work, work);
#if WORDS_BIGENDIAN
p[0] = work[0];
p[1] = work[1];
@ -401,7 +389,7 @@ int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOper
for (i = 0; i < 1024; i += 2, s += 2)
{
(void) blowfishEncrypt(bp, work, work);
blowfishEncrypt(bp, work, work);
#if WORDS_BIGENDIAN
s[0] = work[0];
s[1] = work[1];
@ -423,21 +411,16 @@ int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOper
#ifndef ASM_BLOWFISHSETIV
int blowfishSetIV(blowfishParam* bp, const byte* iv)
{
/*@-mayaliasunique@*/
if (iv)
memcpy(bp->fdback, iv, sizeof(bp->fdback));
memcpy(bp->fdback, iv, 8);
else
memset(bp->fdback, 0, sizeof(bp->fdback));
/*@=mayaliasunique@*/
memset(bp->fdback, 0, 8);
return 0;
}
#endif
/*@-exportheader@*/
/*@unused@*/
int blowfishBlowit(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
/*@modifies *dst @*/
{
register uint32_t xl = src[0], xr = src[1];
register uint32_t* p = bp->p;
@ -450,7 +433,6 @@ int blowfishBlowit(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
return 0;
}
/*@=exportheader@*/
#ifndef ASM_BLOWFISHENCRYPT
int blowfishEncrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
@ -520,6 +502,3 @@ uint32_t* blowfishFeedback(blowfishParam* bp)
{
return bp->fdback;
}
/*!\}
*/

View File

@ -34,18 +34,28 @@
#ifndef _BLOWFISH_H
#define _BLOWFISH_H
#include "beecrypt.h"
#include "blowfishopt.h"
#include "beecrypt/beecrypt.h"
#include "beecrypt/blowfishopt.h"
#define BLOWFISHROUNDS 16
#define BLOWFISHPSIZE (BLOWFISHROUNDS+2)
/** \ingroup BC_blowfish_m
/*!\brief Holds all the parameters necessary for the Blowfish cipher.
* \ingroup BC_blowfish_m
*/
typedef struct
{
/*!\var p
* \brief Holds the key expansion.
*/
uint32_t p[BLOWFISHPSIZE];
/*!\var s
* \brief Holds the s-boxes.
*/
uint32_t s[1024];
/*!\var fdback
* \brief Buffer to be used by block chaining or feedback modes.
*/
uint32_t fdback[2];
} blowfishParam;
@ -53,50 +63,59 @@ typedef struct
extern "C" {
#endif
/** \ingroup BC_blowfish_m
/*!\var blowfish
* \brief Holds the full API description of the Blowfish algorithm.
*/
/*@observer@*/ /*@checked@*/
extern const BEECRYPTAPI blockCipher blowfish;
/** \ingroup BC_blowfish_m
/*!\fn int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOperation
op)
* \brief The function performs the cipher's key expansion.
* \param bp The cipher's parameter block.
* \param key The key value.
* \param keybits The number of bits in the key; legal values are: 32 to 448,
* in multiples of 8.
* \param op ENCRYPT or DECRYPT.
* \retval 0 on success.
* \retval -1 on failure.
*/
/*@-exportlocal@*/
BEECRYPTAPI
int blowfishSetup (blowfishParam* bp, const byte* key, size_t keybits, cipherOperation op)
/*@modifies bp @*/;
/*@=exportlocal@*/
int blowfishSetup (blowfishParam*, const byte*, size_t, cipherOperation);
/** \ingroup BC_blowfish_m
/*!\fn int blowfishSetIV(blowfishParam* bp, const byte* iv)
* \brief This function sets the Initialization Vector.
* \note This function is only useful in block chaining or feedback modes.
* \param bp The cipher's parameter block.
* \param iv The initialization vector; may be null.
* \retval 0 on success.
*/
/*@-exportlocal@*/
BEECRYPTAPI
int blowfishSetIV (blowfishParam* bp, const byte* iv)
/*@modifies bp @*/;
/*@=exportlocal@*/
int blowfishSetIV (blowfishParam*, const byte*);
/** \ingroup BC_blowfish_m
/*!\fn blowfishEncrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
* \brief This function performs the Blowfish encryption; it encrypts one block
* of 64 bits.
* \param bp The cipher's parameter block.
* \param dst The ciphertext; should be aligned on 32-bit boundary.
* \param src The cleartext; should be aligned on 32-bit boundary.
* \retval 0 on success.
*/
/*@-exportlocal@*/
BEECRYPTAPI
int blowfishEncrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
/*@modifies bp, dst @*/;
/*@=exportlocal@*/
int blowfishEncrypt (blowfishParam*, uint32_t*, const uint32_t*);
/** \ingroup BC_blowfish_m
/*!\fn blowfishDecrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
* \brief This function performs the Blowfish decryption; it Rderypts one block
* of 64 bits.
* \param bp The cipher's parameter block.
* \param dst The cleartext; should be aligned on 32-bit boundary.
* \param src The ciphertext; should be aligned on 32-bit boundary.
* \retval 0 on success.
*/
/*@-exportlocal@*/
BEECRYPTAPI
int blowfishDecrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
/*@modifies bp, dst @*/;
/*@=exportlocal@*/
int blowfishDecrypt (blowfishParam*, uint32_t*, const uint32_t*);
/** \ingroup BC_blowfish_m
*/
/*@-exportlocal@*/
BEECRYPTAPI /*@observer@*/
uint32_t* blowfishFeedback(blowfishParam* bp)
/*@*/;
/*@=exportlocal@*/
BEECRYPTAPI
uint32_t* blowfishFeedback(blowfishParam*);
#ifdef __cplusplus
}

View File

@ -19,13 +19,16 @@
/*!\file blowfishopt.h
* \brief Blowfish block cipher, assembler-optimized routines, headers.
* \author Bob Deblier <bob@virtualunlimited.com>
* \author Bob Deblier <bob.deblier@pandora.be>
* \ingroup BC_blowfish_m
*/
#ifndef _BLOWFISHOPT_H
#define _BLOWFISHOPT_H
#include "beecrypt/beecrypt.h"
#include "beecrypt/blowfish.h"
#ifdef __cplusplus
extern "C" {
#endif

44
beecrypt/c++/Makefile.am Normal file
View File

@ -0,0 +1,44 @@
LIBBEECRYPT_CXX_LT_CURRENT = 8
LIBBEECRYPT_CXX_LT_AGE = 2
LIBBEECRYPT_CXX_LT_REVISION = 0
INCLUDES = -I$(top_srcdir)/..
AUTOMAKE_OPTIONS = gnu no-dependencies
SUBDIRS = lang io util security crypto beeyond . provider
libaltdir=$(prefix)/lib@LIBALT@
cxxdir=$(pkgincludedir)/c++
libalt_LTLIBRARIES = libbeecrypt_cxx.la
libbeecrypt_cxx_la_SOURCES = \
adapter.cxx \
bstream.cxx \
resource.cxx
libbeecrypt_cxx_la_LIBADD = ../libbeecrypt.la beeyond/libcxxbeeyond.la crypto/libcxxcrypto.la io/libcxxio.la lang/libcxxlang.la util/libcxxutil.la security/libcxxsecurity.la -licuuc -licuio
libbeecrypt_cxx_la_LDFLAGS = -no-undefined -version-info $(LIBBEECRYPT_CXX_LT_CURRENT):$(LIBBEECRYPT_CXX_LT_REVISION):$(LIBBEECRYPT_CXX_LT_AGE)
cxx_HEADERS = \
array.h \
bstream.h \
mutex.h
noinst_HEADERS = \
adapter.h \
resource.h
TESTS = testdsa testrsa testks
check_PROGRAMS = testdsa testrsa testks
testdsa_SOURCES = testdsa.cxx
testdsa_LDADD = libbeecrypt_cxx.la
testrsa_SOURCES = testrsa.cxx
testrsa_LDADD = libbeecrypt_cxx.la
testks_SOURCES = testks.cxx
testks_LDADD = libbeecrypt_cxx.la

734
beecrypt/c++/Makefile.in Normal file
View File

@ -0,0 +1,734 @@
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SOURCES = $(libbeecrypt_cxx_la_SOURCES) $(testdsa_SOURCES) $(testks_SOURCES) $(testrsa_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
check_PROGRAMS = testdsa$(EXEEXT) testrsa$(EXEEXT) testks$(EXEEXT)
subdir = c++
DIST_COMMON = $(cxx_HEADERS) $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(libaltdir)" "$(DESTDIR)$(cxxdir)"
libaltLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(libalt_LTLIBRARIES)
libbeecrypt_cxx_la_DEPENDENCIES = ../libbeecrypt.la \
beeyond/libcxxbeeyond.la crypto/libcxxcrypto.la io/libcxxio.la \
lang/libcxxlang.la util/libcxxutil.la \
security/libcxxsecurity.la
am_libbeecrypt_cxx_la_OBJECTS = adapter.lo bstream.lo resource.lo
libbeecrypt_cxx_la_OBJECTS = $(am_libbeecrypt_cxx_la_OBJECTS)
am_testdsa_OBJECTS = testdsa.$(OBJEXT)
testdsa_OBJECTS = $(am_testdsa_OBJECTS)
testdsa_DEPENDENCIES = libbeecrypt_cxx.la
am_testks_OBJECTS = testks.$(OBJEXT)
testks_OBJECTS = $(am_testks_OBJECTS)
testks_DEPENDENCIES = libbeecrypt_cxx.la
am_testrsa_OBJECTS = testrsa.$(OBJEXT)
testrsa_OBJECTS = $(am_testrsa_OBJECTS)
testrsa_DEPENDENCIES = libbeecrypt_cxx.la
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp =
am__depfiles_maybe =
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libbeecrypt_cxx_la_SOURCES) $(testdsa_SOURCES) \
$(testks_SOURCES) $(testrsa_SOURCES)
DIST_SOURCES = $(libbeecrypt_cxx_la_SOURCES) $(testdsa_SOURCES) \
$(testks_SOURCES) $(testrsa_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
cxxHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(cxx_HEADERS) $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
ASM_ALIGN = @ASM_ALIGN@
ASM_ARCH = @ASM_ARCH@
ASM_BIGENDIAN = @ASM_BIGENDIAN@
ASM_CPU = @ASM_CPU@
ASM_GLOBL = @ASM_GLOBL@
ASM_GSYM_PREFIX = @ASM_GSYM_PREFIX@
ASM_LSYM_PREFIX = @ASM_LSYM_PREFIX@
ASM_OS = @ASM_OS@
ASM_TEXTSEG = @ASM_TEXTSEG@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
INCLUDE_DLFCN_H = @INCLUDE_DLFCN_H@
INCLUDE_INTTYPES_H = @INCLUDE_INTTYPES_H@
INCLUDE_MALLOC_H = @INCLUDE_MALLOC_H@
INCLUDE_PTHREAD_H = @INCLUDE_PTHREAD_H@
INCLUDE_STDINT_H = @INCLUDE_STDINT_H@
INCLUDE_STDIO_H = @INCLUDE_STDIO_H@
INCLUDE_STDLIB_H = @INCLUDE_STDLIB_H@
INCLUDE_STRING_H = @INCLUDE_STRING_H@
INCLUDE_SYNCH_H = @INCLUDE_SYNCH_H@
INCLUDE_THREAD_H = @INCLUDE_THREAD_H@
INCLUDE_UNISTD_H = @INCLUDE_UNISTD_H@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
JAVAINC = @JAVAINC@
LDFLAGS = @LDFLAGS@
LIBALT = @LIBALT@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MAYBE_LTLIB = @MAYBE_LTLIB@
MAYBE_SUB = @MAYBE_SUB@
MP_WBITS = @MP_WBITS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PYTHONINC = @PYTHONINC@
PYTHONLIB = @PYTHONLIB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TYPEDEF_BC_COND_T = @TYPEDEF_BC_COND_T@
TYPEDEF_BC_MUTEX_T = @TYPEDEF_BC_MUTEX_T@
TYPEDEF_BC_THREAD_T = @TYPEDEF_BC_THREAD_T@
TYPEDEF_INT16_T = @TYPEDEF_INT16_T@
TYPEDEF_INT32_T = @TYPEDEF_INT32_T@
TYPEDEF_INT64_T = @TYPEDEF_INT64_T@
TYPEDEF_INT8_T = @TYPEDEF_INT8_T@
TYPEDEF_SIZE_T = @TYPEDEF_SIZE_T@
TYPEDEF_UINT16_T = @TYPEDEF_UINT16_T@
TYPEDEF_UINT32_T = @TYPEDEF_UINT32_T@
TYPEDEF_UINT64_T = @TYPEDEF_UINT64_T@
TYPEDEF_UINT8_T = @TYPEDEF_UINT8_T@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
ac_ct_F77 = @ac_ct_F77@
ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
ac_cv_have_gcj = @ac_cv_have_gcj@
ac_cv_have_java = @ac_cv_have_java@
ac_cv_have_javac = @ac_cv_have_javac@
ac_cv_have_python = @ac_cv_have_python@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
LIBBEECRYPT_CXX_LT_CURRENT = 8
LIBBEECRYPT_CXX_LT_AGE = 2
LIBBEECRYPT_CXX_LT_REVISION = 0
INCLUDES = -I$(top_srcdir)/..
AUTOMAKE_OPTIONS = gnu no-dependencies
SUBDIRS = lang io util security crypto beeyond . provider
libaltdir = $(prefix)/lib@LIBALT@
cxxdir = $(pkgincludedir)/c++
libalt_LTLIBRARIES = libbeecrypt_cxx.la
libbeecrypt_cxx_la_SOURCES = \
adapter.cxx \
bstream.cxx \
resource.cxx
libbeecrypt_cxx_la_LIBADD = ../libbeecrypt.la beeyond/libcxxbeeyond.la crypto/libcxxcrypto.la io/libcxxio.la lang/libcxxlang.la util/libcxxutil.la security/libcxxsecurity.la -licuuc -licuio
libbeecrypt_cxx_la_LDFLAGS = -no-undefined -version-info $(LIBBEECRYPT_CXX_LT_CURRENT):$(LIBBEECRYPT_CXX_LT_REVISION):$(LIBBEECRYPT_CXX_LT_AGE)
cxx_HEADERS = \
array.h \
bstream.h \
mutex.h
noinst_HEADERS = \
adapter.h \
resource.h
TESTS = testdsa testrsa testks
testdsa_SOURCES = testdsa.cxx
testdsa_LDADD = libbeecrypt_cxx.la
testrsa_SOURCES = testrsa.cxx
testrsa_LDADD = libbeecrypt_cxx.la
testks_SOURCES = testks.cxx
testks_LDADD = libbeecrypt_cxx.la
all: all-recursive
.SUFFIXES:
.SUFFIXES: .cxx .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu c++/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu c++/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-libaltLTLIBRARIES: $(libalt_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libaltdir)" || $(mkdir_p) "$(DESTDIR)$(libaltdir)"
@list='$(libalt_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(LIBTOOL) --mode=install $(libaltLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libaltdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libaltLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libaltdir)/$$f"; \
else :; fi; \
done
uninstall-libaltLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(libalt_LTLIBRARIES)'; for p in $$list; do \
p="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libaltdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libaltdir)/$$p"; \
done
clean-libaltLTLIBRARIES:
-test -z "$(libalt_LTLIBRARIES)" || rm -f $(libalt_LTLIBRARIES)
@list='$(libalt_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" = "$$p" && dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libbeecrypt_cxx.la: $(libbeecrypt_cxx_la_OBJECTS) $(libbeecrypt_cxx_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libaltdir) $(libbeecrypt_cxx_la_LDFLAGS) $(libbeecrypt_cxx_la_OBJECTS) $(libbeecrypt_cxx_la_LIBADD) $(LIBS)
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
testdsa$(EXEEXT): $(testdsa_OBJECTS) $(testdsa_DEPENDENCIES)
@rm -f testdsa$(EXEEXT)
$(CXXLINK) $(testdsa_LDFLAGS) $(testdsa_OBJECTS) $(testdsa_LDADD) $(LIBS)
testks$(EXEEXT): $(testks_OBJECTS) $(testks_DEPENDENCIES)
@rm -f testks$(EXEEXT)
$(CXXLINK) $(testks_LDFLAGS) $(testks_OBJECTS) $(testks_LDADD) $(LIBS)
testrsa$(EXEEXT): $(testrsa_OBJECTS) $(testrsa_DEPENDENCIES)
@rm -f testrsa$(EXEEXT)
$(CXXLINK) $(testrsa_LDFLAGS) $(testrsa_OBJECTS) $(testrsa_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.cxx.o:
$(CXXCOMPILE) -c -o $@ $<
.cxx.obj:
$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cxx.lo:
$(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-cxxHEADERS: $(cxx_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(cxxdir)" || $(mkdir_p) "$(DESTDIR)$(cxxdir)"
@list='$(cxx_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(cxxHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(cxxdir)/$$f'"; \
$(cxxHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(cxxdir)/$$f"; \
done
uninstall-cxxHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(cxx_HEADERS)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f '$(DESTDIR)$(cxxdir)/$$f'"; \
rm -f "$(DESTDIR)$(cxxdir)/$$f"; \
done
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if (etags --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
else \
include_option=--include; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; skip=0; \
srcdir=$(srcdir); export srcdir; \
list='$(TESTS)'; \
if test -n "$$list"; then \
for tst in $$list; do \
if test -f ./$$tst; then dir=./; \
elif test -f $$tst; then dir=; \
else dir="$(srcdir)/"; fi; \
if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xpass=`expr $$xpass + 1`; \
failed=`expr $$failed + 1`; \
echo "XPASS: $$tst"; \
;; \
*) \
echo "PASS: $$tst"; \
;; \
esac; \
elif test $$? -ne 77; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xfail=`expr $$xfail + 1`; \
echo "XFAIL: $$tst"; \
;; \
*) \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
;; \
esac; \
else \
skip=`expr $$skip + 1`; \
echo "SKIP: $$tst"; \
fi; \
done; \
if test "$$failed" -eq 0; then \
if test "$$xfail" -eq 0; then \
banner="All $$all tests passed"; \
else \
banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
fi; \
else \
if test "$$xpass" -eq 0; then \
banner="$$failed of $$all tests failed"; \
else \
banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
fi; \
fi; \
dashes="$$banner"; \
skipped=""; \
if test "$$skip" -ne 0; then \
skipped="($$skip tests were not run)"; \
test `echo "$$skipped" | wc -c` -gt `echo "$$banner" | wc -c` && \
dashes="$$skipped"; \
fi; \
report=""; \
if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
report="Please report to $(PACKAGE_BUGREPORT)"; \
test `echo "$$report" | wc -c` -gt `echo "$$banner" | wc -c` && \
dashes="$$report"; \
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
test -n "$$skipped" && echo "$$skipped"; \
test -n "$$report" && echo "$$report"; \
echo "$$dashes"; \
test "$$failed" -eq 0; \
else :; fi
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-recursive
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(libaltdir)" "$(DESTDIR)$(cxxdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-checkPROGRAMS clean-generic clean-libaltLTLIBRARIES \
clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am: install-cxxHEADERS install-libaltLTLIBRARIES
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-cxxHEADERS uninstall-info-am \
uninstall-libaltLTLIBRARIES
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-TESTS \
check-am clean clean-checkPROGRAMS clean-generic \
clean-libaltLTLIBRARIES clean-libtool clean-recursive ctags \
ctags-recursive distclean distclean-compile distclean-generic \
distclean-libtool distclean-recursive distclean-tags distdir \
dvi dvi-am html html-am info info-am install install-am \
install-cxxHEADERS install-data install-data-am install-exec \
install-exec-am install-info install-info-am \
install-libaltLTLIBRARIES install-man install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic \
maintainer-clean-recursive mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \
pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
uninstall-cxxHEADERS uninstall-info-am \
uninstall-libaltLTLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

65
beecrypt/c++/adapter.cxx Normal file
View File

@ -0,0 +1,65 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/adapter.h"
using namespace beecrypt;
int sraSetup(SecureRandom* random)
{
return 0;
}
int sraSeed(SecureRandom* random, const byte* data, size_t size)
{
random->setSeed(data, size);
return 0;
}
int sraNext(SecureRandom* random, byte* data, size_t size)
{
random->nextBytes(data, size);
return 0;
}
int sraCleanup(SecureRandom* random)
{
return 0;
}
const randomGenerator sraprng = {
"SecureRandom Adapter",
0,
(randomGeneratorSetup) sraSetup,
(randomGeneratorSeed) sraSeed,
(randomGeneratorNext) sraNext,
(randomGeneratorCleanup) sraCleanup
};
randomGeneratorContextAdapter::randomGeneratorContextAdapter(SecureRandom* random) : randomGeneratorContext(&sraprng)
{
param = (randomGeneratorParam*) random;
}
// SecureRandom systemsr;

45
beecrypt/c++/adapter.h Normal file
View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file adapter.h
* \brief In-between layer for BeeCrypt C and C++ code.
* \author Bob Deblier <bob.deblier@telenet.be>
*/
#ifndef _BEECRYPT_ADAPTER_H
#define _BEECRYPT_ADAPTER_H
#include "beecrypt/beecrypt.h"
#ifdef __cplusplus
#include "beecrypt/c++/security/SecureRandom.h"
using beecrypt::security::SecureRandom;
namespace beecrypt {
/*!\brief Class which transforms a SecureRandom generator into a randomGeneratorContext.
*/
struct BEECRYPTCXXAPI randomGeneratorContextAdapter : randomGeneratorContext
{
randomGeneratorContextAdapter(SecureRandom*);
};
}
#endif
#endif

188
beecrypt/c++/array.h Normal file
View File

@ -0,0 +1,188 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file array.h
* \brief Array template class.
* \author Bob Deblier <bob.deblier@telenet.be>
* \ingroup CXX_m
*/
#ifndef _TEMPLATE_ARRAY_H
#define _TEMPLATE_ARRAY_H
#include "beecrypt/api.h"
#ifdef __cplusplus
#include <new>
namespace beecrypt {
template <typename T>
class array
{
private:
T* _data;
size_t _size;
public:
array() throw ()
{
_data = 0;
_size = 0;
}
array(size_t size) throw (std::bad_alloc)
{
if (size)
{
_data = (T*) malloc(size * sizeof(T));
if (_data == 0)
throw std::bad_alloc();
}
else
_data = 0;
_size = size;
}
array(const T* data, size_t size) throw (std::bad_alloc)
{
_data = (T*) malloc(size * sizeof(T));
if (_data == 0)
throw std::bad_alloc();
_size = size;
memcpy(_data, data, _size * sizeof(T));
}
array(const array& _copy) throw (std::bad_alloc)
{
_data = (T*) malloc(_copy._size * sizeof(T));
if (_data == 0)
throw std::bad_alloc();
_size = _copy._size;
memcpy(_data, _copy._data, _size * sizeof(T));
}
~array() throw ()
{
if (_data)
free(_data);
}
const array& operator=(const array& _set) throw (std::bad_alloc)
{
resize(_set._size);
if (_size)
memcpy(_data, _set._data, _size * sizeof(T));
return *this;
}
bool operator==(const array& _cmp) const throw ()
{
if (_size != _cmp.size)
return false;
if (_size == 0 && _cmp._size == 0)
return true;
return !memcmp(_data, _cmp._data, _size * sizeof(T));
}
bool operator!=(const array& _cmp) const throw ()
{
if (_size != _cmp._size)
return true;
if (_size == 0 && _cmp._size == 0)
return false;
return memcmp(_data, _cmp._data, _size * sizeof(T));
}
T* data() throw ()
{
return _data;
}
const T* data() const throw ()
{
return _data;
}
size_t size() const throw ()
{
return _size;
}
void resize(size_t _newsize) throw (std::bad_alloc)
{
if (_newsize)
{
_data = (T*) (_data ? realloc(_data, _newsize * sizeof(T)) : malloc(_newsize * sizeof(T)));
if (_data == 0)
throw std::bad_alloc();
}
else
{
if (_data)
{
free(_data);
_data = 0;
}
}
_size = _newsize;
}
T& operator[](size_t _n) throw ()
{
return _data[_n];
}
const T operator[](size_t _n) const throw ()
{
return _data[_n];
}
const array<T>& operator+=(const array<T>& _rhs) throw ()
{
if (_rhs._size)
{
size_t _curr = _size;
resize(_size+_rhs._size);
memcpy(_data+_curr, _rhs._data, _rhs._size * sizeof(T));
}
return *this;
}
};
template<typename T>
array<T> operator+(const array<T>& _lhs, const array<T>& _rhs)
{
array<T> _con(_lhs);
return _con += _rhs;
};
typedef array<byte> bytearray;
typedef array<javachar> javachararray;
}
#endif
#endif

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#include "beecrypt/c++/beeyond/AnyEncodedKeySpec.h"
using namespace beecrypt::beeyond;
AnyEncodedKeySpec::AnyEncodedKeySpec(const String& format, const byte* data, size_t size) : EncodedKeySpec(data, size), _format(format)
{
}
AnyEncodedKeySpec::AnyEncodedKeySpec(const String& format, const bytearray& copy) : EncodedKeySpec(copy), _format(format)
{
}
AnyEncodedKeySpec::~AnyEncodedKeySpec()
{
}
const String& AnyEncodedKeySpec::getFormat() const throw ()
{
return _format;
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file AnyEncodedKeySpec.h
* \ingroup CXX_BEEYOND_m
*/
#ifndef _CLASS_ANYENCODEDKEYSPEC_H
#define _CLASS_ANYENCODEDKEYSPEC_H
#ifdef __cplusplus
#include "beecrypt/c++/lang/String.h"
using beecrypt::lang::String;
#include "beecrypt/c++/security/spec/EncodedKeySpec.h"
using beecrypt::security::spec::EncodedKeySpec;
namespace beecrypt {
namespace beeyond {
class BEECRYPTCXXAPI AnyEncodedKeySpec : public EncodedKeySpec
{
private:
String _format;
public:
AnyEncodedKeySpec(const String& format, const byte*, size_t);
AnyEncodedKeySpec(const String& format, const bytearray&);
virtual ~AnyEncodedKeySpec();
virtual const String& getFormat() const throw ();
};
}
}
#endif
#endif

View File

@ -0,0 +1,619 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/beeyond/BeeCertificate.h"
#include "beecrypt/c++/beeyond/AnyEncodedKeySpec.h"
#include "beecrypt/c++/io/ByteArrayInputStream.h"
using beecrypt::io::ByteArrayInputStream;
#include "beecrypt/c++/io/ByteArrayOutputStream.h"
using beecrypt::io::ByteArrayOutputStream;
#include "beecrypt/c++/lang/NullPointerException.h"
using beecrypt::lang::NullPointerException;
#include "beecrypt/c++/security/KeyFactory.h"
using beecrypt::security::KeyFactory;
#include "beecrypt/c++/security/Signature.h"
using beecrypt::security::Signature;
#include "beecrypt/c++/security/cert/CertificateFactory.h"
using beecrypt::security::cert::CertificateFactory;
using namespace beecrypt::beeyond;
BeeCertificate::Field::~Field()
{
}
BeeCertificate::UnknownField::UnknownField()
{
}
BeeCertificate::UnknownField::UnknownField(const UnknownField& copy) : encoding(copy.encoding)
{
type = copy.type;
}
BeeCertificate::UnknownField::~UnknownField()
{
}
BeeCertificate::Field* BeeCertificate::UnknownField::clone() const
{
return new BeeCertificate::UnknownField(*this);
}
void BeeCertificate::UnknownField::decode(DataInputStream& in) throw (IOException)
{
encoding.resize(in.available());
in.readFully(encoding);
}
void BeeCertificate::UnknownField::encode(DataOutputStream& out) const throw (IOException)
{
out.write(encoding);
}
const javaint BeeCertificate::PublicKeyField::FIELD_TYPE = 0x5055424b; // 'PUBK'
BeeCertificate::PublicKeyField::PublicKeyField()
{
type = BeeCertificate::PublicKeyField::FIELD_TYPE;
pub = 0;
}
BeeCertificate::PublicKeyField::PublicKeyField(const PublicKey& key)
{
type = BeeCertificate::PublicKeyField::FIELD_TYPE;
pub = key.clone();
}
BeeCertificate::PublicKeyField::~PublicKeyField()
{
delete pub;
}
BeeCertificate::Field* BeeCertificate::PublicKeyField::clone() const
{
return new BeeCertificate::PublicKeyField(*pub);
}
void BeeCertificate::PublicKeyField::decode(DataInputStream& in) throw (IOException)
{
String format;
in.readUTF(format);
// no need for a try-catch around this; calling function is expecting a thrown NoSuchAlgorithmException
KeyFactory* kf = KeyFactory::getInstance(format);
try
{
javaint encsize = in.readInt();
if (encsize <= 0)
throw IOException("Invalid key encoding size");
bytearray enc(encsize);
in.readFully(enc);
AnyEncodedKeySpec spec(format, enc);
pub = kf->generatePublic(spec);
delete kf;
}
catch (...)
{
delete kf;
throw;
}
}
void BeeCertificate::PublicKeyField::encode(DataOutputStream& out) const throw (IOException)
{
out.writeUTF(*pub->getFormat());
const bytearray* pubenc = pub->getEncoded();
if (!pubenc)
throw NullPointerException("PublicKey has no encoding");
out.writeInt(pubenc->size());
out.write(*pubenc);
}
const javaint BeeCertificate::ParentCertificateField::FIELD_TYPE = 0x43455254; // 'CERT'
BeeCertificate::ParentCertificateField::ParentCertificateField()
{
type = BeeCertificate::ParentCertificateField::FIELD_TYPE;
parent = 0;
}
BeeCertificate::ParentCertificateField::ParentCertificateField(const Certificate& cert)
{
type = BeeCertificate::ParentCertificateField::FIELD_TYPE;
parent = cert.clone();
}
BeeCertificate::ParentCertificateField::~ParentCertificateField()
{
delete parent;
}
BeeCertificate::Field* BeeCertificate::ParentCertificateField::clone() const
{
return new BeeCertificate::ParentCertificateField(*parent);
}
void BeeCertificate::ParentCertificateField::decode(DataInputStream& in) throw (IOException)
{
String type;
in.readUTF(type);
CertificateFactory* cf = CertificateFactory::getInstance(type);
try
{
javaint encsize = in.readInt();
if (encsize <= 0)
throw IOException("Invalid certificate encoding size");
bytearray enc(encsize);
in.readFully(enc);
ByteArrayInputStream bin(enc);
parent = cf->generateCertificate(bin);
throw RuntimeException();
delete cf;
}
catch (...)
{
delete cf;
throw;
}
}
void BeeCertificate::ParentCertificateField::encode(DataOutputStream& out) const throw (IOException)
{
out.writeUTF(parent->getType());
const bytearray& parentenc = parent->getEncoded();
out.writeInt(parentenc.size());
out.write(parentenc);
}
BeeCertificate::Field* BeeCertificate::instantiateField(javaint type)
{
switch (type)
{
case PublicKeyField::FIELD_TYPE:
return new PublicKeyField();
case ParentCertificateField::FIELD_TYPE:
return new ParentCertificateField();
default:
return new UnknownField();
}
}
const Date BeeCertificate::FOREVER((javalong) -1L);
BeeCertificate::BeeCertificate() : Certificate("BEE")
{
enc = 0;
}
BeeCertificate::BeeCertificate(InputStream& in) throw (IOException) : Certificate("BEE")
{
enc = 0;
DataInputStream dis(in);
dis.readUTF(issuer);
dis.readUTF(subject);
created.setTime(dis.readLong());
expires.setTime(dis.readLong());
javaint fieldcount = dis.readInt();
if (fieldcount < 0)
throw IOException("field count < 0");
for (javaint i = 0; i < fieldcount; i++)
{
bytearray fenc;
javaint type = dis.readInt();
javaint size = dis.readInt();
fenc.resize(size);
dis.readFully(fenc);
ByteArrayInputStream bis(fenc);
DataInputStream fis(bis);
Field* f = instantiateField(type);
try
{
f->decode(fis);
fields.push_back(f);
}
catch (...)
{
delete f;
throw;
}
}
dis.readUTF(signature_algorithm);
javaint siglength = dis.readInt();
if (siglength < 0)
throw IOException("signature length < 0");
if (siglength > 0)
{
signature.resize(siglength);
dis.readFully(signature);
}
}
BeeCertificate::BeeCertificate(const BeeCertificate& copy) : Certificate("BEE")
{
issuer = copy.issuer;
subject = copy.subject;
created = copy.created;
expires = copy.expires;
for (fields_const_iterator it = copy.fields.begin(); it != copy.fields.end(); it++)
fields.push_back((*it)->clone());
signature_algorithm = copy.signature_algorithm;
signature = copy.signature;
enc = 0;
}
BeeCertificate::~BeeCertificate()
{
if (enc)
delete enc;
}
BeeCertificate* BeeCertificate::clone() const
{
return new BeeCertificate(*this);
}
const bytearray& BeeCertificate::getEncoded() const
{
if (!enc)
{
// The following sequence shouldn't throw an exception
ByteArrayOutputStream bos;
DataOutputStream dos(bos);
dos.writeUTF(issuer);
dos.writeUTF(subject);
dos.writeLong(created.getTime());
dos.writeLong(expires.getTime());
dos.writeInt(fields.size());
for (fields_vector::const_iterator it = fields.begin(); it != fields.end(); it++)
{
ByteArrayOutputStream bout;
DataOutputStream dout(bout);
Field* f = (*it);
f->encode(dout);
dout.close();
bytearray* fenc = bout.toByteArray();
dos.writeInt(f->type);
dos.writeInt(fenc->size());
dos.write(*fenc);
delete fenc;
}
dos.writeUTF(signature_algorithm);
dos.writeInt(signature.size());
dos.write(signature);
dos.close();
bos.close();
enc = bos.toByteArray();
}
return *enc;
}
const PublicKey& BeeCertificate::getPublicKey() const
{
for (fields_const_iterator it = fields.begin(); it != fields.end(); it++)
{
if ((*it)->type == PublicKeyField::FIELD_TYPE)
{
const PublicKeyField* f = dynamic_cast<const PublicKeyField*>(*it);
if (f)
return *f->pub;
else
throw GeneralSecurityException("Somebody's trying to cheat with a new Field subclass");
}
}
throw CertificateException("BeeCertificate doesn't contain a PublicKey");
}
const Certificate& BeeCertificate::getParentCertificate() const
{
for (fields_const_iterator it = fields.begin(); it != fields.end(); it++)
{
if ((*it)->type == ParentCertificateField::FIELD_TYPE)
{
const ParentCertificateField* f = dynamic_cast<const ParentCertificateField*>(*it);
if (f)
return *f->parent;
else
throw GeneralSecurityException("Somebody's trying to cheat with a new Field subclass");
}
}
throw CertificateException("BeeCertificate doesn't contain a parent Certificate");
}
void BeeCertificate::verify(const PublicKey& pub) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException)
{
Signature* sig = Signature::getInstance(signature_algorithm);
try
{
sig->initVerify(pub);
bytearray* tmp = encodeTBS();
try
{
sig->update(*tmp);
delete tmp;
}
catch (...)
{
delete tmp;
throw;
}
if (!sig->verify(signature))
throw CertificateException("signature doesn't match");
delete sig;
}
catch (...)
{
delete sig;
throw;
}
}
void BeeCertificate::verify(const PublicKey& pub, const String& sigProvider) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException)
{
Signature* sig = Signature::getInstance(signature_algorithm, sigProvider);
try
{
sig->initVerify(pub);
bytearray* tmp = encodeTBS();
try
{
sig->update(*tmp);
delete tmp;
}
catch (...)
{
delete tmp;
throw;
}
if (!sig->verify(signature))
throw CertificateException("signature doesn't match");
delete sig;
}
catch (...)
{
delete sig;
throw;
}
}
const String& BeeCertificate::toString() const throw ()
{
if (!str)
str = new String();
return *str;
}
void BeeCertificate::checkValidity() const throw (CertificateExpiredException, CertificateNotYetValidException)
{
Date now;
checkValidity(now);
}
void BeeCertificate::checkValidity(const Date& at) const throw (CertificateExpiredException, CertificateNotYetValidException)
{
if (at.before(created))
throw CertificateNotYetValidException();
if (expires != FOREVER)
if (at.after(expires))
throw CertificateExpiredException();
}
const Date& BeeCertificate::getNotAfter() const throw ()
{
return expires;
}
const Date& BeeCertificate::getNotBefore() const throw ()
{
return created;
}
const bytearray& BeeCertificate::getSignature() const throw ()
{
return signature;
}
const String& BeeCertificate::getSigAlgName() const throw ()
{
return signature_algorithm;
}
bool BeeCertificate::hasPublicKey() const
{
for (fields_vector::const_iterator it = fields.begin(); it != fields.end(); it++)
{
switch ((*it)->type)
{
case PublicKeyField::FIELD_TYPE:
// do an extra check with dynamic_cast
if (dynamic_cast<PublicKeyField*>(*it))
return true;
else
throw GeneralSecurityException("Somebody's trying to cheat with a new Field subclass");
}
}
return false;
}
bool BeeCertificate::hasParentCertificate() const
{
for (fields_vector::const_iterator it = fields.begin(); it != fields.end(); it++)
{
switch ((*it)->type)
{
case ParentCertificateField::FIELD_TYPE:
// do an extra check with dynamic_cast
if (dynamic_cast<ParentCertificateField*>(*it))
return true;
else
throw GeneralSecurityException("Somebody's trying to cheat with a new Field subclass");
}
}
return false;
}
bytearray* BeeCertificate::encodeTBS() const
{
ByteArrayOutputStream bos;
DataOutputStream dos(bos);
dos.writeUTF(issuer);
dos.writeUTF(subject);
dos.writeLong(created.getTime());
dos.writeLong(expires.getTime());
dos.writeInt(fields.size());
for (fields_vector::const_iterator it = fields.begin(); it != fields.end(); it++)
{
Field* f = (*it);
dos.writeInt(f->type);
f->encode(dos);
}
dos.close();
bos.close();
return bos.toByteArray();
}
BeeCertificate* BeeCertificate::self(const PublicKey& pub, const PrivateKey& pri, const String& signatureAlgorithm) throw (InvalidKeyException, NoSuchAlgorithmException)
{
// if the public key doesn't have an encoding, it's not worth going through the effort
if (!pub.getEncoded())
throw InvalidKeyException("PublicKey doesn't have an encoding");
Signature* sig = Signature::getInstance(signatureAlgorithm);
try
{
sig->initSign(pri);
BeeCertificate* cert = new BeeCertificate();
try
{
// issuer is kept blank
cert->subject = "PublicKey Certificate";
cert->expires = FOREVER;
cert->signature_algorithm = signatureAlgorithm;
cert->fields.push_back(new PublicKeyField(pub));
bytearray* tmp = cert->encodeTBS();
try
{
sig->update(*tmp);
delete tmp;
}
catch (...)
{
delete tmp;
throw;
}
sig->sign(cert->signature);
}
catch (...)
{
delete cert;
throw;
}
delete sig;
return cert;
}
catch (...)
{
delete sig;
throw;
}
}

View File

@ -0,0 +1,186 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file BeeCertificate.h
* \ingroup CXX_BEEYOND_m
*/
#ifndef _CLASS_BEECERTIFICATE_H
#define _CLASS_BEECERTIFICATE_H
#ifdef __cplusplus
#include "beecrypt/c++/array.h"
using beecrypt::array;
#include "beecrypt/c++/io/DataInputStream.h"
using beecrypt::io::DataInputStream;
#include "beecrypt/c++/io/DataOutputStream.h"
using beecrypt::io::DataOutputStream;
#include "beecrypt/c++/provider/BeeCertificateFactory.h"
using beecrypt::provider::BeeCertificateFactory;
#include "beecrypt/c++/security/PublicKey.h"
using beecrypt::security::PublicKey;
#include "beecrypt/c++/security/PrivateKey.h"
using beecrypt::security::PrivateKey;
#include "beecrypt/c++/security/cert/Certificate.h"
using beecrypt::security::cert::Certificate;
#include "beecrypt/c++/security/cert/CertificateExpiredException.h"
using beecrypt::security::cert::CertificateExpiredException;
#include "beecrypt/c++/security/cert/CertificateNotYetValidException.h"
using beecrypt::security::cert::CertificateNotYetValidException;
#include "beecrypt/c++/util/Date.h"
using beecrypt::util::Date;
#include <vector>
using std::vector;
namespace beecrypt {
namespace beeyond {
/* We use short certificate chains, embedded in the certificate as parent certificates
* Issuer is informational
* Subject is used to identify the type of certificate
*/
class BEECRYPTCXXAPI BeeCertificate : public Certificate
{
friend class BeeCertificateFactory;
public:
static const Date FOREVER;
protected:
struct Field
{
javaint type;
virtual ~Field();
virtual Field* clone() const = 0;
virtual void decode(DataInputStream&) throw (IOException) = 0;
virtual void encode(DataOutputStream&) const throw (IOException) = 0;
};
struct UnknownField : public Field
{
bytearray encoding;
UnknownField();
UnknownField(const UnknownField&);
virtual ~UnknownField();
virtual Field* clone() const;
virtual void decode(DataInputStream&) throw (IOException);
virtual void encode(DataOutputStream&) const throw (IOException);
};
struct PublicKeyField : public Field
{
static const javaint FIELD_TYPE;
PublicKey* pub;
PublicKeyField();
PublicKeyField(const PublicKey& key);
virtual ~PublicKeyField();
virtual Field* clone() const;
virtual void decode(DataInputStream&) throw (IOException);
virtual void encode(DataOutputStream&) const throw (IOException);
};
struct ParentCertificateField : public Field
{
static const javaint FIELD_TYPE;
Certificate* parent;
ParentCertificateField();
ParentCertificateField(const Certificate&);
virtual ~ParentCertificateField();
virtual Field* clone() const;
virtual void decode(DataInputStream&) throw (IOException);
virtual void encode(DataOutputStream&) const throw (IOException);
};
virtual Field* instantiateField(javaint type);
public:
typedef vector<Field*> fields_vector;
typedef vector<Field*>::iterator fields_iterator;
typedef vector<Field*>::const_iterator fields_const_iterator;
protected:
String issuer;
String subject;
Date created;
Date expires;
fields_vector fields;
String signature_algorithm;
bytearray signature;
mutable bytearray* enc;
mutable String* str;
BeeCertificate();
BeeCertificate(InputStream& in) throw (IOException);
bytearray* encodeTBS() const;
public:
BeeCertificate(const BeeCertificate&);
virtual ~BeeCertificate();
virtual BeeCertificate* clone() const;
virtual const bytearray& getEncoded() const;
virtual const PublicKey& getPublicKey() const;
virtual void verify(const PublicKey&) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException);
virtual void verify(const PublicKey&, const String&) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException);
virtual const String& toString() const throw ();
void checkValidity() const throw (CertificateExpiredException, CertificateNotYetValidException);
void checkValidity(const Date&) const throw (CertificateExpiredException, CertificateNotYetValidException);
const String& getIssuer() const throw ();
const String& getSubject() const throw ();
const Date& getNotAfter() const throw ();
const Date& getNotBefore() const throw ();
const bytearray& getSignature() const throw ();
const String& getSigAlgName() const throw ();
bool hasPublicKey() const;
bool hasParentCertificate() const;
const Certificate& getParentCertificate() const;
public:
static BeeCertificate* self(const PublicKey&, const PrivateKey&, const String& sigAlgName) throw (InvalidKeyException, NoSuchAlgorithmException);
};
}
}
#endif
#endif

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#include "beecrypt/c++/beeyond/BeeEncodedKeySpec.h"
using namespace beecrypt::beeyond;
BeeEncodedKeySpec::BeeEncodedKeySpec(const byte* data, size_t size) : EncodedKeySpec(data, size)
{
}
BeeEncodedKeySpec::BeeEncodedKeySpec(const bytearray& copy) : EncodedKeySpec(copy)
{
}
BeeEncodedKeySpec::~BeeEncodedKeySpec()
{
}
const String& BeeEncodedKeySpec::getFormat() const throw ()
{
static const String* format = 0;
if (!format)
format = new String("BEE");
return *format;
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file BeeEncodedKeySpec.h
* \ingroup CXX_BEEYOND_m
*/
#ifndef _CLASS_BEEENCODEDKEYSPEC_H
#define _CLASS_BEEENCODEDKEYSPEC_H
#ifdef __cplusplus
#include "beecrypt/c++/security/spec/EncodedKeySpec.h"
using beecrypt::security::spec::EncodedKeySpec;
namespace beecrypt {
namespace beeyond {
class BEECRYPTCXXAPI BeeEncodedKeySpec : public EncodedKeySpec
{
public:
BeeEncodedKeySpec(const byte*, size_t);
BeeEncodedKeySpec(const bytearray&);
virtual ~BeeEncodedKeySpec();
virtual const String& getFormat() const throw ();
};
}
}
#endif
#endif

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/beeyond/BeeInputStream.h"
using namespace beecrypt::beeyond;
BeeInputStream::BeeInputStream(InputStream& in) : DataInputStream(in)
{
}
BeeInputStream::~BeeInputStream()
{
}
void BeeInputStream::read(mpnumber& n) throw (IOException)
{
int size = readInt();
byte* data = new byte[size];
try
{
readFully(data, 0, size);
mpnsetbin(&n, data, size);
delete[] data;
}
catch (IOException)
{
// free buffer
delete[] data;
// re-throw exception
throw;
}
}
void BeeInputStream::read(mpbarrett& b) throw (IOException)
{
int size = readInt();
byte* data = new byte[size];
try
{
readFully(data, 0, size);
mpbsetbin(&b, data, size);
delete[] data;
}
catch (IOException)
{
// free buffer
delete[] data;
// re-throw exception
throw;
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file BeeInputStream.h
* \ingroup CXX_BEEYOND_m
*/
#ifndef _CLASS_BEEINPUTSTREAM_H
#define _CLASS_BEEINPUTSTREAM_H
#include "beecrypt/mpbarrett.h"
#ifdef __cplusplus
#include "beecrypt/c++/io/DataInputStream.h"
using beecrypt::io::DataInputStream;
namespace beecrypt {
namespace beeyond {
class BEECRYPTCXXAPI BeeInputStream : public DataInputStream
{
public:
BeeInputStream(InputStream& in);
virtual ~BeeInputStream();
void read(mpnumber&) throw (IOException);
void read(mpbarrett&) throw (IOException);
};
}
}
#endif
#endif

View File

@ -0,0 +1,81 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/beeyond/BeeOutputStream.h"
using namespace beecrypt::beeyond;
BeeOutputStream::BeeOutputStream(OutputStream& out) : DataOutputStream(out)
{
}
BeeOutputStream::~BeeOutputStream()
{
}
void BeeOutputStream::write(const mpnumber& n) throw (IOException)
{
size_t bits = n.bitlength();
size_t length = ((bits + 7) >> 3) + (((bits & 7) == 0) ? 1 : 0);
byte* buffer = new byte[length];
try
{
i2osp(buffer, length, n.data, n.size);
DataOutputStream::writeInt(length);
DataOutputStream::write(buffer, 0, length);
delete[] buffer;
}
catch (IOException)
{
delete[] buffer;
throw;
}
}
void BeeOutputStream::write(const mpbarrett& b) throw (IOException)
{
size_t bits = b.bitlength();
size_t length = ((bits + 7) >> 3) + (((bits & 7) == 0) ? 1 : 0);
byte* buffer = new byte[length];
try
{
i2osp(buffer, length, b.modl, b.size);
DataOutputStream::writeInt(length);
DataOutputStream::write(buffer, 0, length);
delete[] buffer;
}
catch (IOException)
{
delete[] buffer;
throw;
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file BeeOutputStream.h
* \ingroup CXX_BEEYOND_m
*/
#ifndef _CLASS_BEEOUTPUTSTREAM_H
#define _CLASS_BEEOUTPUTSTREAM_H
#include "beecrypt/mpbarrett.h"
#ifdef __cplusplus
#include "beecrypt/c++/io/DataOutputStream.h"
using beecrypt::io::DataOutputStream;
namespace beecrypt {
namespace beeyond {
class BEECRYPTCXXAPI BeeOutputStream : public DataOutputStream
{
public:
BeeOutputStream(OutputStream& out);
virtual ~BeeOutputStream();
void write(const mpnumber&) throw (IOException);
void write(const mpbarrett&) throw (IOException);
};
}
}
#endif
#endif

View File

@ -0,0 +1,30 @@
INCLUDES = -I$(top_srcdir)/..
LIBS = -licuuc -licuio
AUTOMAKE_OPTIONS = gnu no-dependencies
noinst_LTLIBRARIES = libcxxbeeyond.la
libcxxbeeyond_la_SOURCES = \
AnyEncodedKeySpec.cxx \
BeeCertificate.cxx \
BeeEncodedKeySpec.cxx \
BeeInputStream.cxx \
BeeOutputStream.cxx \
PKCS12PBEKey.cxx
noinst_HEADERS = \
AnyEncodedKeySpec.h \
BeeCertificate.h \
BeeEncodedKeySpec.h \
BeeInputStream.h \
BeeOutputStream.h \
PKCS12PBEKey.h
TESTS = testcert
check_PROGRAMS = testcert
testcert_SOURCES = testcert.cxx
testcert_LDADD = ../libbeecrypt_cxx.la

View File

@ -0,0 +1,569 @@
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SOURCES = $(libcxxbeeyond_la_SOURCES) $(testcert_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
check_PROGRAMS = testcert$(EXEEXT)
subdir = c++/beeyond
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libcxxbeeyond_la_LIBADD =
am_libcxxbeeyond_la_OBJECTS = AnyEncodedKeySpec.lo BeeCertificate.lo \
BeeEncodedKeySpec.lo BeeInputStream.lo BeeOutputStream.lo \
PKCS12PBEKey.lo
libcxxbeeyond_la_OBJECTS = $(am_libcxxbeeyond_la_OBJECTS)
am_testcert_OBJECTS = testcert.$(OBJEXT)
testcert_OBJECTS = $(am_testcert_OBJECTS)
testcert_DEPENDENCIES = ../libbeecrypt_cxx.la
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp =
am__depfiles_maybe =
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libcxxbeeyond_la_SOURCES) $(testcert_SOURCES)
DIST_SOURCES = $(libcxxbeeyond_la_SOURCES) $(testcert_SOURCES)
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
ASM_ALIGN = @ASM_ALIGN@
ASM_ARCH = @ASM_ARCH@
ASM_BIGENDIAN = @ASM_BIGENDIAN@
ASM_CPU = @ASM_CPU@
ASM_GLOBL = @ASM_GLOBL@
ASM_GSYM_PREFIX = @ASM_GSYM_PREFIX@
ASM_LSYM_PREFIX = @ASM_LSYM_PREFIX@
ASM_OS = @ASM_OS@
ASM_TEXTSEG = @ASM_TEXTSEG@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
INCLUDE_DLFCN_H = @INCLUDE_DLFCN_H@
INCLUDE_INTTYPES_H = @INCLUDE_INTTYPES_H@
INCLUDE_MALLOC_H = @INCLUDE_MALLOC_H@
INCLUDE_PTHREAD_H = @INCLUDE_PTHREAD_H@
INCLUDE_STDINT_H = @INCLUDE_STDINT_H@
INCLUDE_STDIO_H = @INCLUDE_STDIO_H@
INCLUDE_STDLIB_H = @INCLUDE_STDLIB_H@
INCLUDE_STRING_H = @INCLUDE_STRING_H@
INCLUDE_SYNCH_H = @INCLUDE_SYNCH_H@
INCLUDE_THREAD_H = @INCLUDE_THREAD_H@
INCLUDE_UNISTD_H = @INCLUDE_UNISTD_H@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
JAVAINC = @JAVAINC@
LDFLAGS = @LDFLAGS@
LIBALT = @LIBALT@
LIBOBJS = @LIBOBJS@
LIBS = -licuuc -licuio
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MAYBE_LTLIB = @MAYBE_LTLIB@
MAYBE_SUB = @MAYBE_SUB@
MP_WBITS = @MP_WBITS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PYTHONINC = @PYTHONINC@
PYTHONLIB = @PYTHONLIB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TYPEDEF_BC_COND_T = @TYPEDEF_BC_COND_T@
TYPEDEF_BC_MUTEX_T = @TYPEDEF_BC_MUTEX_T@
TYPEDEF_BC_THREAD_T = @TYPEDEF_BC_THREAD_T@
TYPEDEF_INT16_T = @TYPEDEF_INT16_T@
TYPEDEF_INT32_T = @TYPEDEF_INT32_T@
TYPEDEF_INT64_T = @TYPEDEF_INT64_T@
TYPEDEF_INT8_T = @TYPEDEF_INT8_T@
TYPEDEF_SIZE_T = @TYPEDEF_SIZE_T@
TYPEDEF_UINT16_T = @TYPEDEF_UINT16_T@
TYPEDEF_UINT32_T = @TYPEDEF_UINT32_T@
TYPEDEF_UINT64_T = @TYPEDEF_UINT64_T@
TYPEDEF_UINT8_T = @TYPEDEF_UINT8_T@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
ac_ct_F77 = @ac_ct_F77@
ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
ac_cv_have_gcj = @ac_cv_have_gcj@
ac_cv_have_java = @ac_cv_have_java@
ac_cv_have_javac = @ac_cv_have_javac@
ac_cv_have_python = @ac_cv_have_python@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
INCLUDES = -I$(top_srcdir)/..
AUTOMAKE_OPTIONS = gnu no-dependencies
noinst_LTLIBRARIES = libcxxbeeyond.la
libcxxbeeyond_la_SOURCES = \
AnyEncodedKeySpec.cxx \
BeeCertificate.cxx \
BeeEncodedKeySpec.cxx \
BeeInputStream.cxx \
BeeOutputStream.cxx \
PKCS12PBEKey.cxx
noinst_HEADERS = \
AnyEncodedKeySpec.h \
BeeCertificate.h \
BeeEncodedKeySpec.h \
BeeInputStream.h \
BeeOutputStream.h \
PKCS12PBEKey.h
TESTS = testcert
testcert_SOURCES = testcert.cxx
testcert_LDADD = ../libbeecrypt_cxx.la
all: all-am
.SUFFIXES:
.SUFFIXES: .cxx .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu c++/beeyond/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu c++/beeyond/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" = "$$p" && dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libcxxbeeyond.la: $(libcxxbeeyond_la_OBJECTS) $(libcxxbeeyond_la_DEPENDENCIES)
$(CXXLINK) $(libcxxbeeyond_la_LDFLAGS) $(libcxxbeeyond_la_OBJECTS) $(libcxxbeeyond_la_LIBADD) $(LIBS)
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
testcert$(EXEEXT): $(testcert_OBJECTS) $(testcert_DEPENDENCIES)
@rm -f testcert$(EXEEXT)
$(CXXLINK) $(testcert_LDFLAGS) $(testcert_OBJECTS) $(testcert_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.cxx.o:
$(CXXCOMPILE) -c -o $@ $<
.cxx.obj:
$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cxx.lo:
$(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; skip=0; \
srcdir=$(srcdir); export srcdir; \
list='$(TESTS)'; \
if test -n "$$list"; then \
for tst in $$list; do \
if test -f ./$$tst; then dir=./; \
elif test -f $$tst; then dir=; \
else dir="$(srcdir)/"; fi; \
if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xpass=`expr $$xpass + 1`; \
failed=`expr $$failed + 1`; \
echo "XPASS: $$tst"; \
;; \
*) \
echo "PASS: $$tst"; \
;; \
esac; \
elif test $$? -ne 77; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xfail=`expr $$xfail + 1`; \
echo "XFAIL: $$tst"; \
;; \
*) \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
;; \
esac; \
else \
skip=`expr $$skip + 1`; \
echo "SKIP: $$tst"; \
fi; \
done; \
if test "$$failed" -eq 0; then \
if test "$$xfail" -eq 0; then \
banner="All $$all tests passed"; \
else \
banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
fi; \
else \
if test "$$xpass" -eq 0; then \
banner="$$failed of $$all tests failed"; \
else \
banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
fi; \
fi; \
dashes="$$banner"; \
skipped=""; \
if test "$$skip" -ne 0; then \
skipped="($$skip tests were not run)"; \
test `echo "$$skipped" | wc -c` -gt `echo "$$banner" | wc -c` && \
dashes="$$skipped"; \
fi; \
report=""; \
if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
report="Please report to $(PACKAGE_BUGREPORT)"; \
test `echo "$$report" | wc -c` -gt `echo "$$banner" | wc -c` && \
dashes="$$report"; \
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
test -n "$$skipped" && echo "$$skipped"; \
test -n "$$report" && echo "$$report"; \
echo "$$dashes"; \
test "$$failed" -eq 0; \
else :; fi
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
clean-noinstLTLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
clean-checkPROGRAMS clean-generic clean-libtool \
clean-noinstLTLIBRARIES ctags distclean distclean-compile \
distclean-generic distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-exec install-exec-am \
install-info install-info-am install-man install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,86 @@
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/beeyond/PKCS12PBEKey.h"
#include <iostream>
using std::cout;
using std::endl;
using namespace beecrypt::beeyond;
PKCS12PBEKey::PKCS12PBEKey(const array<javachar>& password, const bytearray* salt, size_t iterationCount) : _pswd(password)
{
if (salt)
_salt = new bytearray(*salt);
else
_salt = 0;
_iter = iterationCount;
_enc = 0;
}
PKCS12PBEKey::~PKCS12PBEKey()
{
if (_salt)
delete _salt;
}
PKCS12PBEKey* PKCS12PBEKey::clone() const
{
return new PKCS12PBEKey(_pswd, _salt, _iter);
}
bytearray* PKCS12PBEKey::encode(const array<javachar>& password, const bytearray* salt, size_t iterationCount)
{
size_t i;
bytearray* result = new bytearray((password.size() + 1) * 2);
for (i = 0; i < password.size(); i++)
{
(*result)[2*i ] = (password[i] >> 8) & 0xff;
(*result)[2*i+1] = (password[i] ) & 0xff;
}
(*result)[2*i ] = 0;
(*result)[2*i+1] = 0;
return result;
}
size_t PKCS12PBEKey::getIterationCount() const throw ()
{
return _iter;
}
const array<javachar>& PKCS12PBEKey::getPassword() const throw ()
{
return _pswd;
}
const bytearray* PKCS12PBEKey::getSalt() const throw ()
{
return _salt;
}
const bytearray* PKCS12PBEKey::getEncoded() const
{
if (!_enc)
_enc = encode(_pswd, _salt, _iter);
return _enc;
}
const String& PKCS12PBEKey::getAlgorithm() const throw ()
{
static const String ALGORITHM = UNICODE_STRING_SIMPLE("PKCS#12/PBE");
return ALGORITHM;
}
const String* PKCS12PBEKey::getFormat() const throw ()
{
static const String FORMAT = UNICODE_STRING_SIMPLE("RAW");
return &FORMAT;
}

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file PKCS12PBEKey.h
* \ingroup CXX_BEEYOND_m
*/
#ifndef _CLASS_PKCS12PBEKEY_H
#define _CLASS_PKCS12PBEKEY_H
#ifdef __cplusplus
#include "beecrypt/c++/array.h"
using beecrypt::array;
using beecrypt::bytearray;
#include "beecrypt/c++/crypto/interfaces/PBEKey.h"
using beecrypt::crypto::interfaces::PBEKey;
namespace beecrypt {
namespace beeyond {
class BEECRYPTCXXAPI PKCS12PBEKey : public PBEKey
{
private:
array<javachar> _pswd;
bytearray* _salt;
size_t _iter;
mutable bytearray* _enc;
public:
static bytearray* encode(const array<javachar>&, const bytearray*, size_t);
public:
PKCS12PBEKey(const array<javachar>&, const bytearray*, size_t);
virtual ~PKCS12PBEKey();
virtual PKCS12PBEKey* clone() const;
virtual size_t getIterationCount() const throw ();
virtual const array<javachar>& getPassword() const throw ();
virtual const bytearray* getSalt() const throw ();
virtual const bytearray* getEncoded() const;
virtual const String& getAlgorithm() const throw();
virtual const String* getFormat() const throw ();
};
}
}
#endif
#endif

View File

@ -0,0 +1,105 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "c++/bstream.h"
#include "c++/beeyond/BeeCertificate.h"
using beecrypt::beeyond::BeeCertificate;
#include "c++/io/ByteArrayInputStream.h"
using beecrypt::io::ByteArrayInputStream;
#include "c++/security/AlgorithmParameterGenerator.h"
using beecrypt::security::AlgorithmParameterGenerator;
#include "c++/security/AlgorithmParameters.h"
using beecrypt::security::AlgorithmParameters;
#include "c++/security/KeyFactory.h"
using beecrypt::security::KeyFactory;
#include "c++/security/KeyPairGenerator.h"
using beecrypt::security::KeyPairGenerator;
#include "c++/security/Signature.h"
using beecrypt::security::Signature;
#include "c++/security/cert/CertificateFactory.h"
using beecrypt::security::cert::CertificateFactory;
#include "c++/security/spec/EncodedKeySpec.h"
using beecrypt::security::spec::EncodedKeySpec;
#include <iostream>
using namespace std;
#include <unicode/ustream.h>
int main(int argc, char* argv[])
{
int failures = 0;
try
{
KeyPairGenerator* kpg = KeyPairGenerator::getInstance("DSA");
kpg->initialize(1024);
KeyPair* pair = kpg->generateKeyPair();
cout << "keypair generated" << endl << flush;
BeeCertificate* self = BeeCertificate::self(pair->getPublic(), pair->getPrivate(), "SHA1withDSA");
cout << "self generated" << endl << flush;
ByteArrayInputStream bis(self->getEncoded());
CertificateFactory* cf = CertificateFactory::getInstance("BEE");
cout << "got cf" << endl << flush;
Certificate* cert = cf->generateCertificate(bis);
cout << "verifying" << endl << flush;
cert->verify(pair->getPublic());
cout << "verified" << endl << flush;
if (!(*cert == *self))
{
cerr << "certificates differ" << endl;
failures++;
}
else
cout << "certificates equal" << endl << flush;
delete cert;
delete cf;
delete self;
delete pair;
delete kpg;
}
catch (Exception& ex)
{
std::cerr << "exception: " << ex.getMessage();
std::cerr << " type " << typeid(ex).name() << std::endl;
failures++;
}
catch (...)
{
std::cerr << "exception" << std::endl;
failures++;
}
return failures;
}

63
beecrypt/c++/bstream.cxx Normal file
View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#include "beecrypt/c++/bstream.h"
#include "beecrypt/c++/crypto/interfaces/DHPublicKey.h"
using beecrypt::crypto::interfaces::DHPublicKey;
#include "beecrypt/c++/security/interfaces/DSAPublicKey.h"
using beecrypt::security::interfaces::DSAPublicKey;
#include "beecrypt/c++/security/interfaces/RSAPublicKey.h"
using beecrypt::security::interfaces::RSAPublicKey;
#include <unicode/ustream.h>
using namespace beecrypt;
ostream& operator<<(ostream& stream, const PublicKey& pub)
{
stream << pub.getAlgorithm() << " public key" << endl;
const DHPublicKey* dh = dynamic_cast<const DHPublicKey*>(&pub);
if (dh)
{
return stream << "P = " << dh->getParams().getP() << endl <<
"G = " << dh->getParams().getG() << endl <<
"Y = " << dh->getY() << endl;
}
const DSAPublicKey* dsa = dynamic_cast<const DSAPublicKey*>(&pub);
if (dsa)
{
return stream << "P = " << dsa->getParams().getP() << endl <<
"Q = " << dsa->getParams().getQ() << endl <<
"G = " << dsa->getParams().getG() << endl <<
"Y = " << dsa->getY() << endl;
}
const RSAPublicKey* rsa = dynamic_cast<const RSAPublicKey*>(&pub);
if (rsa)
{
return stream << "N = " << rsa->getModulus() << endl <<
"E = " << rsa->getPublicExponent() << endl;
}
return stream;
}

46
beecrypt/c++/bstream.h Normal file
View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file bstream.h
* \brief C++ Object-to-stream output.
* \author Bob Deblier <bob.deblier@telenet.be>
*/
#ifndef _BEECRYPT_STREAM_H
#define _BEECRYPT_STREAM_H
#include "beecrypt/api.h"
#ifdef __cplusplus
#include <iostream>
using std::cout;
using std::ostream;
using std::endl;
#include "beecrypt/c++/security/PublicKey.h"
using beecrypt::security::PublicKey;
namespace beecrypt {
BEECRYPTCXXAPI
ostream& operator<<(ostream& stream, const PublicKey&);
}
#endif
#endif

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/crypto/BadPaddingException.h"
using namespace beecrypt::crypto;
BadPaddingException::BadPaddingException() throw ()
{
}
BadPaddingException::BadPaddingException(const String& message) throw () : GeneralSecurityException(message)
{
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file BadPaddingException.h
* \ingroup CXX_CRYPTO_m
*/
#ifndef _CLASS_BADPADDINGEXCEPTION_H
#define _CLASS_BADPADDINGEXCEPTION_H
#ifdef __cplusplus
#include "beecrypt/c++/security/GeneralSecurityException.h"
using beecrypt::security::GeneralSecurityException;
namespace beecrypt {
namespace crypto {
class BEECRYPTCXXAPI BadPaddingException : public GeneralSecurityException
{
public:
BadPaddingException() throw ();
BadPaddingException(const String&) throw ();
};
}
}
#endif
#endif

180
beecrypt/c++/crypto/Mac.cxx Normal file
View File

@ -0,0 +1,180 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/crypto/Mac.h"
#include "beecrypt/c++/lang/IllegalArgumentException.h"
using beecrypt::lang::IllegalArgumentException;
#include "beecrypt/c++/security/Security.h"
using beecrypt::security::Security;
using namespace beecrypt::crypto;
Mac::Mac(MacSpi* spi, const String& algorithm, const Provider& provider)
{
_mspi = spi;
_algo = algorithm;
_prov = &provider;
_init = false;
}
Mac::~Mac()
{
delete _mspi;
}
Mac* Mac::getInstance(const String& algorithm) throw (NoSuchAlgorithmException)
{
Security::spi* tmp = Security::getSpi(algorithm, "Mac");
Mac* result = new Mac((MacSpi*) tmp->cspi, tmp->name, tmp->prov);
delete tmp;
return result;
}
Mac* Mac::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException)
{
Security::spi* tmp = Security::getSpi(algorithm, "Mac", provider);
Mac* result = new Mac((MacSpi*) tmp->cspi, tmp->name, tmp->prov);
delete tmp;
return result;
}
Mac* Mac::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException)
{
Security::spi* tmp = Security::getSpi(algorithm, "Mac", provider);
Mac* result = new Mac((MacSpi*) tmp->cspi, tmp->name, tmp->prov);
delete tmp;
return result;
}
Mac* Mac::clone() const
{
MacSpi* _mspc = _mspi->clone();
if (_mspc)
{
// don't forget to also clone the _init state!
Mac* result = new Mac(_mspc, _algo, *_prov);
result->_init = _init;
return result;
}
else
return 0;
}
const bytearray& Mac::doFinal() throw (IllegalStateException)
{
if (!_init)
throw IllegalStateException();
return _mspi->engineDoFinal();
}
const bytearray& Mac::doFinal(const bytearray& b) throw (IllegalStateException)
{
if (!_init)
throw IllegalStateException();
_mspi->engineUpdate(b.data(), 0, b.size());
return _mspi->engineDoFinal();
}
size_t Mac::doFinal(byte* data, size_t offset, size_t length) throw (IllegalStateException, ShortBufferException)
{
if (!_init)
throw IllegalStateException();
return _mspi->engineDoFinal(data, offset, length);
}
size_t Mac::getMacLength()
{
return _mspi->engineGetMacLength();
}
void Mac::init(const Key& key) throw (InvalidKeyException)
{
try
{
_mspi->engineInit(key, 0);
}
catch (InvalidAlgorithmParameterException)
{
throw IllegalArgumentException("Mac apparently requires an AlgorithmParameterSpec");
}
_init = true;
}
void Mac::init(const Key& key, const AlgorithmParameterSpec* spec) throw (InvalidKeyException, InvalidAlgorithmParameterException)
{
_mspi->engineInit(key, spec);
_init = true;
}
void Mac::reset()
{
_mspi->engineReset();
}
void Mac::update(byte b) throw (IllegalStateException)
{
if (!_init)
throw IllegalStateException();
_mspi->engineUpdate(b);
}
void Mac::update(const bytearray& b) throw (IllegalStateException)
{
if (!_init)
throw IllegalStateException();
_mspi->engineUpdate(b.data(), 0, b.size());
}
void Mac::update(const byte* data, size_t offset, size_t length) throw (IllegalStateException)
{
if (!_init)
throw IllegalStateException();
_mspi->engineUpdate(data, offset, length);
}
const String& Mac::getAlgorithm() const throw ()
{
return _algo;
}
const Provider& Mac::getProvider() const throw ()
{
return *_prov;
}

81
beecrypt/c++/crypto/Mac.h Normal file
View File

@ -0,0 +1,81 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file Mac.h
* \ingroup CXX_CRYPTO_m
*/
#ifndef _CLASS_MAC_H
#define _CLASS_MAC_H
// #include "beecrypt/beecrypt.api.h"
#ifdef __cplusplus
#include "beecrypt/c++/crypto/MacSpi.h"
using beecrypt::crypto::MacSpi;
#include "beecrypt/c++/security/Provider.h"
using beecrypt::security::Provider;
#include "beecrypt/c++/security/NoSuchAlgorithmException.h"
using beecrypt::security::NoSuchAlgorithmException;
#include "beecrypt/c++/security/NoSuchProviderException.h"
using beecrypt::security::NoSuchProviderException;
namespace beecrypt {
namespace crypto {
class BEECRYPTCXXAPI Mac
{
public:
static Mac* getInstance(const String&) throw (NoSuchAlgorithmException);
static Mac* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException);
static Mac* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException);
private:
MacSpi* _mspi;
String _algo;
const Provider* _prov;
bool _init;
protected:
Mac(MacSpi*, const String&, const Provider&);
public:
~Mac();
Mac* clone() const;
const bytearray& doFinal() throw (IllegalStateException);
const bytearray& doFinal(const bytearray&) throw (IllegalStateException);
size_t doFinal(byte* data, size_t offset, size_t length) throw (ShortBufferException, IllegalStateException);
size_t getMacLength();
void init(const Key&) throw (InvalidKeyException);
void init(const Key&, const AlgorithmParameterSpec*) throw (InvalidKeyException, InvalidAlgorithmParameterException);
void reset();
void update(byte) throw (IllegalStateException);
void update(const byte* data, size_t offset, size_t length) throw (IllegalStateException);
void update(const bytearray&) throw (IllegalStateException);
const String& getAlgorithm() const throw ();
const Provider& getProvider() const throw ();
};
}
}
#endif
#endif

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/crypto/MacInputStream.h"
#include "beecrypt/c++/lang/NullPointerException.h"
using beecrypt::lang::NullPointerException;
using namespace beecrypt::crypto;
MacInputStream::MacInputStream(InputStream& in, Mac& m) : FilterInputStream(in), mac(m)
{
_on = true;
}
MacInputStream::~MacInputStream()
{
}
int MacInputStream::read() throw (IOException)
{
int rc = in.read();
if (rc >= 0 && _on)
mac.update((byte) rc);
return rc;
}
int MacInputStream::read(byte *data, size_t offset, size_t length) throw (IOException)
{
if (!data)
throw NullPointerException();
int rc = in.read(data, offset, length);
if (rc >= 0 && _on)
mac.update(data, offset, rc);
return rc;
}
void MacInputStream::on(bool on)
{
_on = on;
}
Mac& MacInputStream::getMac()
{
return mac;
}
void MacInputStream::setMac(Mac& m)
{
mac = m;
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file MacInputStream.h
* \ingroup CXX_CRYPTO_m
*/
#ifndef _CLASS_MACINPUTSTREAM_H
#define _CLASS_MACINPUTSTREAM_H
#ifdef __cplusplus
#include "beecrypt/c++/crypto/Mac.h"
using beecrypt::crypto::Mac;
#include "beecrypt/c++/io/FilterInputStream.h"
using beecrypt::io::FilterInputStream;
namespace beecrypt {
namespace crypto {
class BEECRYPTCXXAPI MacInputStream : public FilterInputStream
{
private:
bool _on;
protected:
Mac& mac;
public:
MacInputStream(InputStream&, Mac&);
virtual ~MacInputStream();
virtual int read() throw (IOException);
virtual int read(byte* data, size_t offset, size_t length) throw (IOException);
void on(bool);
Mac& getMac();
void setMac(Mac&);
};
}
}
#endif
#endif

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/crypto/MacOutputStream.h"
#include "beecrypt/c++/lang/NullPointerException.h"
using beecrypt::lang::NullPointerException;
using namespace beecrypt::crypto;
MacOutputStream::MacOutputStream(OutputStream& out, Mac& m) : FilterOutputStream(out), mac(m)
{
_on = true;
}
MacOutputStream::~MacOutputStream()
{
}
void MacOutputStream::write(byte b) throw (IOException)
{
out.write(b);
if (_on)
mac.update(b);
}
void MacOutputStream::write(const byte *data, size_t offset, size_t length) throw (IOException)
{
if (!data)
throw NullPointerException();
out.write(data, offset, length);
if (_on)
mac.update(data, offset, length);
}
void MacOutputStream::on(bool on)
{
_on = on;
}
Mac& MacOutputStream::getMac()
{
return mac;
}
void MacOutputStream::setMac(Mac& m)
{
mac = m;
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file MacOutputStream.h
* \ingroup CXX_CRYPTO_m
*/
#ifndef _CLASS_MACOUTPUTSTREAM_H
#define _CLASS_MACOUTPUTSTREAM_H
#ifdef __cplusplus
#include "beecrypt/c++/crypto/Mac.h"
using beecrypt::crypto::Mac;
#include "beecrypt/c++/io/FilterOutputStream.h"
using beecrypt::io::FilterOutputStream;
namespace beecrypt {
namespace crypto {
class BEECRYPTCXXAPI MacOutputStream : public FilterOutputStream
{
private:
bool _on;
protected:
Mac& mac;
public:
MacOutputStream(OutputStream&, Mac&);
virtual ~MacOutputStream();
virtual void write(byte) throw (IOException);
virtual void write(const byte* data, size_t offset, size_t length) throw (IOException);
void on(bool);
Mac& getMac();
void setMac(Mac&);
};
}
}
#endif
#endif

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file MacSpi.h
* \ingroup CXX_CRYPTO_m
*/
#ifndef _CLASS_MACSPI_H
#define _CLASS_MACSPI_H
#include "beecrypt/api.h"
#ifdef __cplusplus
#include "beecrypt/c++/array.h"
using beecrypt::array;
#include "beecrypt/c++/lang/IllegalStateException.h"
using beecrypt::lang::IllegalStateException;
#include "beecrypt/c++/security/InvalidAlgorithmParameterException.h"
using beecrypt::security::InvalidAlgorithmParameterException;
#include "beecrypt/c++/security/InvalidKeyException.h"
using beecrypt::security::InvalidKeyException;
#include "beecrypt/c++/security/Key.h"
using beecrypt::security::Key;
#include "beecrypt/c++/security/ShortBufferException.h"
using beecrypt::security::ShortBufferException;
#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h"
using beecrypt::security::spec::AlgorithmParameterSpec;
namespace beecrypt {
namespace crypto {
class BEECRYPTCXXAPI MacSpi
{
friend class Mac;
protected:
virtual const bytearray& engineDoFinal() = 0;
virtual size_t engineDoFinal(byte*, size_t, size_t) throw (ShortBufferException) = 0;
virtual size_t engineGetMacLength() = 0;
virtual void engineInit(const Key&, const AlgorithmParameterSpec*) throw (InvalidKeyException, InvalidAlgorithmParameterException) = 0;
virtual void engineReset() = 0;
virtual void engineUpdate(byte) = 0;
virtual void engineUpdate(const byte*, size_t, size_t) = 0;
public:
virtual ~MacSpi() {};
virtual MacSpi* clone() const = 0;
};
}
}
#endif
#endif

View File

@ -0,0 +1,27 @@
INCLUDES = -I$(top_srcdir)/..
AUTOMAKE_OPTIONS = gnu no-dependencies
SUBDIRS = interfaces spec
noinst_LTLIBRARIES = libcxxcrypto.la
cxxcryptodir=$(pkgincludedir)/c++/crypto
libcxxcrypto_la_SOURCES = \
BadPaddingException.cxx \
Mac.cxx \
MacInputStream.cxx \
MacOutputStream.cxx \
SecretKeyFactory.cxx
libcxxcrypto_la_LIBADD = spec/libcxxcryptospec.la
cxxcrypto_HEADERS = \
BadPaddingException.h \
Mac.h \
MacInputStream.h \
MacOutputStream.h \
MacSpi.h \
SecretKey.h \
SecretKeyFactory.h \
SecretKeyFactorySpi.h

View File

@ -0,0 +1,599 @@
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SOURCES = $(libcxxcrypto_la_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = c++/crypto
DIST_COMMON = $(cxxcrypto_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libcxxcrypto_la_DEPENDENCIES = spec/libcxxcryptospec.la
am_libcxxcrypto_la_OBJECTS = BadPaddingException.lo Mac.lo \
MacInputStream.lo MacOutputStream.lo SecretKeyFactory.lo
libcxxcrypto_la_OBJECTS = $(am_libcxxcrypto_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp =
am__depfiles_maybe =
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libcxxcrypto_la_SOURCES)
DIST_SOURCES = $(libcxxcrypto_la_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
am__installdirs = "$(DESTDIR)$(cxxcryptodir)"
cxxcryptoHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(cxxcrypto_HEADERS)
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
ASM_ALIGN = @ASM_ALIGN@
ASM_ARCH = @ASM_ARCH@
ASM_BIGENDIAN = @ASM_BIGENDIAN@
ASM_CPU = @ASM_CPU@
ASM_GLOBL = @ASM_GLOBL@
ASM_GSYM_PREFIX = @ASM_GSYM_PREFIX@
ASM_LSYM_PREFIX = @ASM_LSYM_PREFIX@
ASM_OS = @ASM_OS@
ASM_TEXTSEG = @ASM_TEXTSEG@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
INCLUDE_DLFCN_H = @INCLUDE_DLFCN_H@
INCLUDE_INTTYPES_H = @INCLUDE_INTTYPES_H@
INCLUDE_MALLOC_H = @INCLUDE_MALLOC_H@
INCLUDE_PTHREAD_H = @INCLUDE_PTHREAD_H@
INCLUDE_STDINT_H = @INCLUDE_STDINT_H@
INCLUDE_STDIO_H = @INCLUDE_STDIO_H@
INCLUDE_STDLIB_H = @INCLUDE_STDLIB_H@
INCLUDE_STRING_H = @INCLUDE_STRING_H@
INCLUDE_SYNCH_H = @INCLUDE_SYNCH_H@
INCLUDE_THREAD_H = @INCLUDE_THREAD_H@
INCLUDE_UNISTD_H = @INCLUDE_UNISTD_H@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
JAVAINC = @JAVAINC@
LDFLAGS = @LDFLAGS@
LIBALT = @LIBALT@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MAYBE_LTLIB = @MAYBE_LTLIB@
MAYBE_SUB = @MAYBE_SUB@
MP_WBITS = @MP_WBITS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PYTHONINC = @PYTHONINC@
PYTHONLIB = @PYTHONLIB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TYPEDEF_BC_COND_T = @TYPEDEF_BC_COND_T@
TYPEDEF_BC_MUTEX_T = @TYPEDEF_BC_MUTEX_T@
TYPEDEF_BC_THREAD_T = @TYPEDEF_BC_THREAD_T@
TYPEDEF_INT16_T = @TYPEDEF_INT16_T@
TYPEDEF_INT32_T = @TYPEDEF_INT32_T@
TYPEDEF_INT64_T = @TYPEDEF_INT64_T@
TYPEDEF_INT8_T = @TYPEDEF_INT8_T@
TYPEDEF_SIZE_T = @TYPEDEF_SIZE_T@
TYPEDEF_UINT16_T = @TYPEDEF_UINT16_T@
TYPEDEF_UINT32_T = @TYPEDEF_UINT32_T@
TYPEDEF_UINT64_T = @TYPEDEF_UINT64_T@
TYPEDEF_UINT8_T = @TYPEDEF_UINT8_T@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
ac_ct_F77 = @ac_ct_F77@
ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
ac_cv_have_gcj = @ac_cv_have_gcj@
ac_cv_have_java = @ac_cv_have_java@
ac_cv_have_javac = @ac_cv_have_javac@
ac_cv_have_python = @ac_cv_have_python@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
INCLUDES = -I$(top_srcdir)/..
AUTOMAKE_OPTIONS = gnu no-dependencies
SUBDIRS = interfaces spec
noinst_LTLIBRARIES = libcxxcrypto.la
cxxcryptodir = $(pkgincludedir)/c++/crypto
libcxxcrypto_la_SOURCES = \
BadPaddingException.cxx \
Mac.cxx \
MacInputStream.cxx \
MacOutputStream.cxx \
SecretKeyFactory.cxx
libcxxcrypto_la_LIBADD = spec/libcxxcryptospec.la
cxxcrypto_HEADERS = \
BadPaddingException.h \
Mac.h \
MacInputStream.h \
MacOutputStream.h \
MacSpi.h \
SecretKey.h \
SecretKeyFactory.h \
SecretKeyFactorySpi.h
all: all-recursive
.SUFFIXES:
.SUFFIXES: .cxx .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu c++/crypto/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu c++/crypto/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" = "$$p" && dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libcxxcrypto.la: $(libcxxcrypto_la_OBJECTS) $(libcxxcrypto_la_DEPENDENCIES)
$(CXXLINK) $(libcxxcrypto_la_LDFLAGS) $(libcxxcrypto_la_OBJECTS) $(libcxxcrypto_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.cxx.o:
$(CXXCOMPILE) -c -o $@ $<
.cxx.obj:
$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cxx.lo:
$(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-cxxcryptoHEADERS: $(cxxcrypto_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(cxxcryptodir)" || $(mkdir_p) "$(DESTDIR)$(cxxcryptodir)"
@list='$(cxxcrypto_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(cxxcryptoHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(cxxcryptodir)/$$f'"; \
$(cxxcryptoHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(cxxcryptodir)/$$f"; \
done
uninstall-cxxcryptoHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(cxxcrypto_HEADERS)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f '$(DESTDIR)$(cxxcryptodir)/$$f'"; \
rm -f "$(DESTDIR)$(cxxcryptodir)/$$f"; \
done
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if (etags --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
else \
include_option=--include; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(cxxcryptodir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am: install-cxxcryptoHEADERS
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-cxxcryptoHEADERS uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-libtool clean-noinstLTLIBRARIES \
clean-recursive ctags ctags-recursive distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-recursive distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am \
install-cxxcryptoHEADERS install-data install-data-am \
install-exec install-exec-am install-info install-info-am \
install-man install-strip installcheck installcheck-am \
installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \
tags tags-recursive uninstall uninstall-am \
uninstall-cxxcryptoHEADERS uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file SecretKey.h
* \ingroup CXX_CRYPTO_m
*/
#ifndef _INTERFACE_SECRETKEY_H
#define _INTERFACE_SECRETKEY_H
#ifdef __cplusplus
#include "beecrypt/c++/security/Key.h"
using beecrypt::security::Key;
namespace beecrypt {
namespace crypto {
/*!\brief SecretKey interface
* \ingroup CXX_CRYPTO_m
*/
class BEECRYPTCXXAPI SecretKey : public Key
{
public:
virtual SecretKey* clone() const = 0;
};
}
}
#endif
#endif

View File

@ -0,0 +1,99 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/crypto/SecretKeyFactory.h"
#include "beecrypt/c++/security/Security.h"
using beecrypt::security::Security;
using namespace beecrypt::crypto;
SecretKeyFactory::SecretKeyFactory(SecretKeyFactorySpi* spi, const String& algorithm, const Provider& provider)
{
_kspi = spi;
_algo = algorithm;
_prov = &provider;
}
SecretKeyFactory::~SecretKeyFactory()
{
delete _kspi;
}
SecretKeyFactory* SecretKeyFactory::getInstance(const String& algorithm) throw (NoSuchAlgorithmException)
{
Security::spi* tmp = Security::getSpi(algorithm, "SecretKeyFactory");
SecretKeyFactory* result = new SecretKeyFactory((SecretKeyFactorySpi*) tmp->cspi, tmp->name, tmp->prov);
delete tmp;
return result;
}
SecretKeyFactory* SecretKeyFactory::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException)
{
Security::spi* tmp = Security::getSpi(algorithm, "SecretKeyFactory", provider);
SecretKeyFactory* result = new SecretKeyFactory((SecretKeyFactorySpi*) tmp->cspi, tmp->name, tmp->prov);
delete tmp;
return result;
}
SecretKeyFactory* SecretKeyFactory::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException)
{
Security::spi* tmp = Security::getSpi(algorithm, "SecretKeyFactory", provider);
SecretKeyFactory* result = new SecretKeyFactory((SecretKeyFactorySpi*) tmp->cspi, tmp->name, tmp->prov);
delete tmp;
return result;
}
SecretKey* SecretKeyFactory::generateSecret(const KeySpec& spec) throw (InvalidKeySpecException)
{
return _kspi->engineGenerateSecret(spec);
}
KeySpec* SecretKeyFactory::getKeySpec(const SecretKey& key, const type_info& info) throw (InvalidKeySpecException)
{
return _kspi->engineGetKeySpec(key, info);
}
SecretKey* SecretKeyFactory::translateKey(const SecretKey& key) throw (InvalidKeyException)
{
return _kspi->engineTranslateKey(key);
}
const String& SecretKeyFactory::getAlgorithm() const throw ()
{
return _algo;
}
const Provider& SecretKeyFactory::getProvider() const throw ()
{
return *_prov;
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file SecretKeyFactory.h
* \ingroup CXX_CRYPTO_m
*/
#ifndef _CLASS_SECRETKEYFACTORY_H
#define _CLASS_SECRETKEYFACTORY_H
// #include "beecrypt/beecrypt.api.h"
#ifdef __cplusplus
#include "beecrypt/c++/crypto/SecretKeyFactorySpi.h"
using beecrypt::crypto::SecretKeyFactorySpi;
#include "beecrypt/c++/security/Provider.h"
using beecrypt::security::Provider;
#include "beecrypt/c++/security/NoSuchAlgorithmException.h"
using beecrypt::security::NoSuchAlgorithmException;
#include "beecrypt/c++/security/NoSuchProviderException.h"
using beecrypt::security::NoSuchProviderException;
#include <typeinfo>
using std::type_info;
namespace beecrypt {
namespace crypto {
class BEECRYPTCXXAPI SecretKeyFactory
{
public:
static SecretKeyFactory* getInstance(const String&) throw (NoSuchAlgorithmException);
static SecretKeyFactory* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException);
static SecretKeyFactory* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException);
private:
SecretKeyFactorySpi* _kspi;
String _algo;
const Provider* _prov;
protected:
SecretKeyFactory(SecretKeyFactorySpi*, const String&, const Provider&);
public:
~SecretKeyFactory();
SecretKey* generateSecret(const KeySpec&) throw (InvalidKeySpecException);
KeySpec* getKeySpec(const SecretKey& key, const type_info&) throw (InvalidKeySpecException);
SecretKey* translateKey(const SecretKey&) throw (InvalidKeyException);
const String& getAlgorithm() const throw ();
const Provider& getProvider() const throw ();
};
}
}
#endif
#endif

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file SecretKeyFactorySpi.h
* \ingroup CXX_CRYPTO_m
*/
#ifndef _CLASS_SECRETKEYFACTORYSPI_H
#define _CLASS_SECRETKEYFACTORYSPI_H
#include "beecrypt/api.h"
#ifdef __cplusplus
#include "beecrypt/c++/crypto/SecretKey.h"
using beecrypt::crypto::SecretKey;
#include "beecrypt/c++/security/InvalidKeyException.h"
using beecrypt::security::InvalidKeyException;
#include "beecrypt/c++/security/spec/KeySpec.h"
using beecrypt::security::spec::KeySpec;
#include "beecrypt/c++/security/spec/InvalidKeySpecException.h"
using beecrypt::security::spec::InvalidKeySpecException;
#include <typeinfo>
using std::type_info;
namespace beecrypt {
namespace crypto {
class BEECRYPTCXXAPI SecretKeyFactorySpi
{
friend class SecretKeyFactory;
protected:
virtual SecretKey* engineGenerateSecret(const KeySpec&) throw (InvalidKeySpecException) = 0;
virtual KeySpec* engineGetKeySpec(const SecretKey&, const type_info&) throw (InvalidKeySpecException) = 0;
virtual SecretKey* engineTranslateKey(const SecretKey&) throw (InvalidKeyException) = 0;
public:
virtual ~SecretKeyFactorySpi() {};
};
}
}
#endif
#endif

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DHKey.h
* \ingroup CXX_CRYPTO_INTERFACES_m
*/
#ifndef _INTERFACE_DHKEY_H
#define _INTERFACE_DHKEY_H
#ifdef __cplusplus
#include "beecrypt/c++/crypto/interfaces/DHParams.h"
using beecrypt::crypto::interfaces::DHParams;
namespace beecrypt {
namespace crypto {
namespace interfaces {
/*!\brief Diffie-Hellman key interface.
* \ingroup CXX_IF_m
*/
class DHKey
{
public:
virtual const DHParams& getParams() const throw () = 0;
};
}
}
}
#endif
#endif

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DHParams.h
* \ingroup CXX_CRYPTO_INTERFACES_m
*/
#ifndef _INTERFACE_DHPARAMS_H
#define _INTERFACE_DHPARAMS_H
#include "beecrypt/api.h"
#include "beecrypt/mpbarrett.h"
#ifdef __cplusplus
namespace beecrypt {
namespace crypto {
namespace interfaces {
class DHParams
{
public:
virtual const mpbarrett& getP() const throw () = 0;
virtual const mpnumber& getG() const throw () = 0;
virtual size_t getL() const throw () = 0;
};
}
}
}
#endif
#endif

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DHPrivateKey.h
* \ingroup CXX_CRYPTO_INTERFACES_m
*/
#ifndef _INTERFACE_DHPRIVATEKEY_H
#define _INTERFACE_DHPRIVATEKEY_H
#include "beecrypt/api.h"
#include "beecrypt/dldp.h"
#ifdef __cplusplus
#include "beecrypt/c++/security/PrivateKey.h"
using beecrypt::security::PrivateKey;
#include "beecrypt/c++/crypto/interfaces/DHKey.h"
using beecrypt::crypto::interfaces::DHKey;
namespace beecrypt {
namespace crypto {
namespace interfaces {
/*!\brief Diffie-Hellman PrivateKey interface
* \ingroup CXX_IF_m
*/
class DHPrivateKey : public PrivateKey, public DHKey
{
public:
virtual const mpnumber& getX() const throw () = 0;
};
}
}
}
#endif
#endif

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DHPublicKey.h
* \ingroup CXX_CRYPTO_INTERFACES_m
*/
#ifndef _INTERFACE_DHPUBLICKEY_H
#define _INTERFACE_DHPUBLICKEY_H
#include "beecrypt/api.h"
#include "beecrypt/mpnumber.h"
#ifdef __cplusplus
#include "beecrypt/c++/security/PublicKey.h"
using beecrypt::security::PublicKey;
#include "beecrypt/c++/crypto/interfaces/DHKey.h"
using beecrypt::crypto::interfaces::DHKey;
namespace beecrypt {
namespace crypto {
namespace interfaces {
/*!\brief Diffie-Hellman PublicKey interface
* \ingroup CXX_IF_m
*/
class DHPublicKey : public PublicKey, public DHKey
{
public:
virtual const mpnumber& getY() const throw () = 0;
};
}
}
}
#endif
#endif

View File

@ -0,0 +1,12 @@
INCLUDES = -I$(top_srcdir)/..
AUTOMAKE_OPTIONS = gnu no-dependencies
cxxcryptointerfacesdir=$(pkgincludedir)/c++/crypto/interfaces
cxxcryptointerfaces_HEADERS =\
DHKey.h \
DHParams.h \
DHPrivateKey.h \
DHPublicKey.h \
PBEKey.h

View File

@ -0,0 +1,444 @@
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = c++/crypto/interfaces
DIST_COMMON = $(cxxcryptointerfaces_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
depcomp =
am__depfiles_maybe =
SOURCES =
DIST_SOURCES =
am__installdirs = "$(DESTDIR)$(cxxcryptointerfacesdir)"
cxxcryptointerfacesHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(cxxcryptointerfaces_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
ASM_ALIGN = @ASM_ALIGN@
ASM_ARCH = @ASM_ARCH@
ASM_BIGENDIAN = @ASM_BIGENDIAN@
ASM_CPU = @ASM_CPU@
ASM_GLOBL = @ASM_GLOBL@
ASM_GSYM_PREFIX = @ASM_GSYM_PREFIX@
ASM_LSYM_PREFIX = @ASM_LSYM_PREFIX@
ASM_OS = @ASM_OS@
ASM_TEXTSEG = @ASM_TEXTSEG@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
INCLUDE_DLFCN_H = @INCLUDE_DLFCN_H@
INCLUDE_INTTYPES_H = @INCLUDE_INTTYPES_H@
INCLUDE_MALLOC_H = @INCLUDE_MALLOC_H@
INCLUDE_PTHREAD_H = @INCLUDE_PTHREAD_H@
INCLUDE_STDINT_H = @INCLUDE_STDINT_H@
INCLUDE_STDIO_H = @INCLUDE_STDIO_H@
INCLUDE_STDLIB_H = @INCLUDE_STDLIB_H@
INCLUDE_STRING_H = @INCLUDE_STRING_H@
INCLUDE_SYNCH_H = @INCLUDE_SYNCH_H@
INCLUDE_THREAD_H = @INCLUDE_THREAD_H@
INCLUDE_UNISTD_H = @INCLUDE_UNISTD_H@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
JAVAINC = @JAVAINC@
LDFLAGS = @LDFLAGS@
LIBALT = @LIBALT@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MAYBE_LTLIB = @MAYBE_LTLIB@
MAYBE_SUB = @MAYBE_SUB@
MP_WBITS = @MP_WBITS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PYTHONINC = @PYTHONINC@
PYTHONLIB = @PYTHONLIB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TYPEDEF_BC_COND_T = @TYPEDEF_BC_COND_T@
TYPEDEF_BC_MUTEX_T = @TYPEDEF_BC_MUTEX_T@
TYPEDEF_BC_THREAD_T = @TYPEDEF_BC_THREAD_T@
TYPEDEF_INT16_T = @TYPEDEF_INT16_T@
TYPEDEF_INT32_T = @TYPEDEF_INT32_T@
TYPEDEF_INT64_T = @TYPEDEF_INT64_T@
TYPEDEF_INT8_T = @TYPEDEF_INT8_T@
TYPEDEF_SIZE_T = @TYPEDEF_SIZE_T@
TYPEDEF_UINT16_T = @TYPEDEF_UINT16_T@
TYPEDEF_UINT32_T = @TYPEDEF_UINT32_T@
TYPEDEF_UINT64_T = @TYPEDEF_UINT64_T@
TYPEDEF_UINT8_T = @TYPEDEF_UINT8_T@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
ac_ct_F77 = @ac_ct_F77@
ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
ac_cv_have_gcj = @ac_cv_have_gcj@
ac_cv_have_java = @ac_cv_have_java@
ac_cv_have_javac = @ac_cv_have_javac@
ac_cv_have_python = @ac_cv_have_python@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
INCLUDES = -I$(top_srcdir)/..
AUTOMAKE_OPTIONS = gnu no-dependencies
cxxcryptointerfacesdir = $(pkgincludedir)/c++/crypto/interfaces
cxxcryptointerfaces_HEADERS = \
DHKey.h \
DHParams.h \
DHPrivateKey.h \
DHPublicKey.h \
PBEKey.h
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu c++/crypto/interfaces/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu c++/crypto/interfaces/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-cxxcryptointerfacesHEADERS: $(cxxcryptointerfaces_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(cxxcryptointerfacesdir)" || $(mkdir_p) "$(DESTDIR)$(cxxcryptointerfacesdir)"
@list='$(cxxcryptointerfaces_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(cxxcryptointerfacesHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(cxxcryptointerfacesdir)/$$f'"; \
$(cxxcryptointerfacesHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(cxxcryptointerfacesdir)/$$f"; \
done
uninstall-cxxcryptointerfacesHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(cxxcryptointerfaces_HEADERS)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f '$(DESTDIR)$(cxxcryptointerfacesdir)/$$f'"; \
rm -f "$(DESTDIR)$(cxxcryptointerfacesdir)/$$f"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(cxxcryptointerfacesdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-cxxcryptointerfacesHEADERS
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-cxxcryptointerfacesHEADERS uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool ctags distclean distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am \
install-cxxcryptointerfacesHEADERS install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-cxxcryptointerfacesHEADERS \
uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file PBEKey.h
* \ingroup CXX_CRYPTO_INTERFACES_m
*/
#ifndef _INTERFACE_PBEKEY_H
#define _INTERFACE_PBEKEY_H
#ifdef __cplusplus
#include "beecrypt/c++/crypto/SecretKey.h"
using beecrypt::crypto::SecretKey;
namespace beecrypt {
namespace crypto {
namespace interfaces {
/*!\brief PBEKey interface
* \ingroup CXX_CRYPTO_m
*/
class BEECRYPTCXXAPI PBEKey : public SecretKey
{
public:
virtual size_t getIterationCount() const throw () = 0;
virtual const array<javachar>& getPassword() const throw () = 0;
virtual const bytearray* getSalt() const throw () = 0;
virtual PBEKey* clone() const = 0;
};
}
}
}
#endif
#endif

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#include "beecrypt/c++/crypto/spec/DHParameterSpec.h"
using namespace beecrypt::crypto::spec;
DHParameterSpec::DHParameterSpec(const DHParams& copy)
{
_p = copy.getP();
_g = copy.getG();
_l = copy.getL();
}
DHParameterSpec::DHParameterSpec(const mpbarrett& p, const mpnumber& g)
{
_p = p;
_g = g;
_l = 0;
}
DHParameterSpec::DHParameterSpec(const mpbarrett& p, const mpnumber& g, size_t l)
{
_p = p;
_g = g;
_l = l;
}
DHParameterSpec::~DHParameterSpec()
{
}
const mpbarrett& DHParameterSpec::getP() const throw ()
{
return _p;
}
const mpnumber& DHParameterSpec::getG() const throw ()
{
return _g;
}
size_t DHParameterSpec::getL() const throw ()
{
return _l;
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DHParameterSpec.h
* \ingroup CXX_CRYPTO_SPEC_m
*/
#ifndef _CLASS_DHPARAMETERSPEC_H
#define _CLASS_DHPARAMETERSPEC_H
#include "beecrypt/api.h"
#include "beecrypt/mpbarrett.h"
#include "beecrypt/dlsvdp-dh.h"
#ifdef __cplusplus
#include "beecrypt/c++/crypto/interfaces/DHParams.h"
using beecrypt::crypto::interfaces::DHParams;
#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h"
using beecrypt::security::spec::AlgorithmParameterSpec;
namespace beecrypt {
namespace crypto {
namespace spec {
class BEECRYPTCXXAPI DHParameterSpec : public AlgorithmParameterSpec, public DHParams
{
private:
mpbarrett _p;
mpnumber _g;
size_t _l;
public:
DHParameterSpec(const DHParams&);
DHParameterSpec(const mpbarrett& p, const mpnumber& g);
DHParameterSpec(const mpbarrett& p, const mpnumber& g, size_t l);
virtual ~DHParameterSpec();
const mpbarrett& getP() const throw ();
const mpnumber& getG() const throw ();
size_t getL() const throw ();
};
}
}
}
#endif
#endif

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#include "beecrypt/c++/crypto/spec/DHPrivateKeySpec.h"
using namespace beecrypt::crypto::spec;
DHPrivateKeySpec::DHPrivateKeySpec(const mpbarrett& p, const mpnumber& g, const mpnumber& x)
{
_p = p;
_g = g;
_x = x;
}
DHPrivateKeySpec::~DHPrivateKeySpec()
{
_x.wipe();
}
const mpbarrett& DHPrivateKeySpec::getP() const throw ()
{
return _p;
}
const mpnumber& DHPrivateKeySpec::getG() const throw ()
{
return _g;
}
const mpnumber& DHPrivateKeySpec::getX() const throw ()
{
return _x;
}

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DHPrivateKeySpec.h
* \ingroup CXX_CRYPTO_SPEC_m
*/
#ifndef _CLASS_DHPRIVATEKEYSPEC_H
#define _CLASS_DHPRIVATEKEYSPEC_H
#include "beecrypt/api.h"
#include "beecrypt/mpbarrett.h"
#ifdef __cplusplus
#include "beecrypt/c++/security/spec/KeySpec.h"
using beecrypt::security::spec::KeySpec;
namespace beecrypt {
namespace crypto {
namespace spec {
class BEECRYPTCXXAPI DHPrivateKeySpec : public KeySpec
{
private:
mpbarrett _p;
mpnumber _g;
mpnumber _x;
public:
DHPrivateKeySpec(const mpbarrett& p, const mpnumber& g, const mpnumber& x);
virtual ~DHPrivateKeySpec();
const mpbarrett& getP() const throw ();
const mpnumber& getG() const throw ();
const mpnumber& getX() const throw ();
};
}
}
}
#endif
#endif

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#include "beecrypt/c++/crypto/spec/DHPublicKeySpec.h"
using namespace beecrypt::crypto::spec;
DHPublicKeySpec::DHPublicKeySpec(const mpbarrett& p, const mpnumber& g, const mpnumber& y)
{
_p = p;
_g = g;
_y = y;
}
DHPublicKeySpec::~DHPublicKeySpec()
{
}
const mpbarrett& DHPublicKeySpec::getP() const throw ()
{
return _p;
}
const mpnumber& DHPublicKeySpec::getG() const throw ()
{
return _g;
}
const mpnumber& DHPublicKeySpec::getY() const throw ()
{
return _y;
}

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DHPublicKeySpec.h
* \ingroup CXX_CRYPTO_SPEC_m
*/
#ifndef _CLASS_DHPUBLICKEYSPEC_H
#define _CLASS_DHPUBLICKEYSPEC_H
#include "beecrypt/api.h"
#include "beecrypt/mpbarrett.h"
#ifdef __cplusplus
#include "beecrypt/c++/security/spec/KeySpec.h"
using beecrypt::security::spec::KeySpec;
namespace beecrypt {
namespace crypto {
namespace spec {
class BEECRYPTCXXAPI DHPublicKeySpec : public KeySpec
{
private:
mpbarrett _p;
mpnumber _g;
mpnumber _y;
public:
DHPublicKeySpec(const mpbarrett& p, const mpnumber& g, const mpnumber& y);
virtual ~DHPublicKeySpec();
const mpbarrett& getP() const throw ();
const mpnumber& getG() const throw ();
const mpnumber& getY() const throw ();
};
}
}
}
#endif
#endif

View File

@ -0,0 +1,19 @@
INCLUDES = -I$(top_srcdir)/..
AUTOMAKE_OPTIONS = gnu no-dependencies
noinst_LTLIBRARIES = libcxxcryptospec.la
cxxcryptospecdir=$(pkgincludedir)/c++/crypto/spec
libcxxcryptospec_la_SOURCES =\
DHParameterSpec.cxx \
DHPrivateKeySpec.cxx \
DHPublicKeySpec.cxx \
PBEKeySpec.cxx
cxxcryptospec_HEADERS =\
DHParameterSpec.h \
DHPrivateKeySpec.h \
DHPublicKeySpec.h \
PBEKeySpec.h

View File

@ -0,0 +1,496 @@
# Makefile.in generated by automake 1.8.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SOURCES = $(libcxxcryptospec_la_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = c++/crypto/spec
DIST_COMMON = $(cxxcryptospec_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libcxxcryptospec_la_LIBADD =
am_libcxxcryptospec_la_OBJECTS = DHParameterSpec.lo \
DHPrivateKeySpec.lo DHPublicKeySpec.lo PBEKeySpec.lo
libcxxcryptospec_la_OBJECTS = $(am_libcxxcryptospec_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp =
am__depfiles_maybe =
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libcxxcryptospec_la_SOURCES)
DIST_SOURCES = $(libcxxcryptospec_la_SOURCES)
am__installdirs = "$(DESTDIR)$(cxxcryptospecdir)"
cxxcryptospecHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(cxxcryptospec_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
ASM_ALIGN = @ASM_ALIGN@
ASM_ARCH = @ASM_ARCH@
ASM_BIGENDIAN = @ASM_BIGENDIAN@
ASM_CPU = @ASM_CPU@
ASM_GLOBL = @ASM_GLOBL@
ASM_GSYM_PREFIX = @ASM_GSYM_PREFIX@
ASM_LSYM_PREFIX = @ASM_LSYM_PREFIX@
ASM_OS = @ASM_OS@
ASM_TEXTSEG = @ASM_TEXTSEG@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
INCLUDE_DLFCN_H = @INCLUDE_DLFCN_H@
INCLUDE_INTTYPES_H = @INCLUDE_INTTYPES_H@
INCLUDE_MALLOC_H = @INCLUDE_MALLOC_H@
INCLUDE_PTHREAD_H = @INCLUDE_PTHREAD_H@
INCLUDE_STDINT_H = @INCLUDE_STDINT_H@
INCLUDE_STDIO_H = @INCLUDE_STDIO_H@
INCLUDE_STDLIB_H = @INCLUDE_STDLIB_H@
INCLUDE_STRING_H = @INCLUDE_STRING_H@
INCLUDE_SYNCH_H = @INCLUDE_SYNCH_H@
INCLUDE_THREAD_H = @INCLUDE_THREAD_H@
INCLUDE_UNISTD_H = @INCLUDE_UNISTD_H@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
JAVAINC = @JAVAINC@
LDFLAGS = @LDFLAGS@
LIBALT = @LIBALT@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MAYBE_LTLIB = @MAYBE_LTLIB@
MAYBE_SUB = @MAYBE_SUB@
MP_WBITS = @MP_WBITS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PYTHONINC = @PYTHONINC@
PYTHONLIB = @PYTHONLIB@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TYPEDEF_BC_COND_T = @TYPEDEF_BC_COND_T@
TYPEDEF_BC_MUTEX_T = @TYPEDEF_BC_MUTEX_T@
TYPEDEF_BC_THREAD_T = @TYPEDEF_BC_THREAD_T@
TYPEDEF_INT16_T = @TYPEDEF_INT16_T@
TYPEDEF_INT32_T = @TYPEDEF_INT32_T@
TYPEDEF_INT64_T = @TYPEDEF_INT64_T@
TYPEDEF_INT8_T = @TYPEDEF_INT8_T@
TYPEDEF_SIZE_T = @TYPEDEF_SIZE_T@
TYPEDEF_UINT16_T = @TYPEDEF_UINT16_T@
TYPEDEF_UINT32_T = @TYPEDEF_UINT32_T@
TYPEDEF_UINT64_T = @TYPEDEF_UINT64_T@
TYPEDEF_UINT8_T = @TYPEDEF_UINT8_T@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
ac_ct_F77 = @ac_ct_F77@
ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
ac_cv_have_gcj = @ac_cv_have_gcj@
ac_cv_have_java = @ac_cv_have_java@
ac_cv_have_javac = @ac_cv_have_javac@
ac_cv_have_python = @ac_cv_have_python@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
INCLUDES = -I$(top_srcdir)/..
AUTOMAKE_OPTIONS = gnu no-dependencies
noinst_LTLIBRARIES = libcxxcryptospec.la
cxxcryptospecdir = $(pkgincludedir)/c++/crypto/spec
libcxxcryptospec_la_SOURCES = \
DHParameterSpec.cxx \
DHPrivateKeySpec.cxx \
DHPublicKeySpec.cxx \
PBEKeySpec.cxx
cxxcryptospec_HEADERS = \
DHParameterSpec.h \
DHPrivateKeySpec.h \
DHPublicKeySpec.h \
PBEKeySpec.h
all: all-am
.SUFFIXES:
.SUFFIXES: .cxx .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu c++/crypto/spec/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu c++/crypto/spec/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" = "$$p" && dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libcxxcryptospec.la: $(libcxxcryptospec_la_OBJECTS) $(libcxxcryptospec_la_DEPENDENCIES)
$(CXXLINK) $(libcxxcryptospec_la_LDFLAGS) $(libcxxcryptospec_la_OBJECTS) $(libcxxcryptospec_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.cxx.o:
$(CXXCOMPILE) -c -o $@ $<
.cxx.obj:
$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cxx.lo:
$(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-cxxcryptospecHEADERS: $(cxxcryptospec_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(cxxcryptospecdir)" || $(mkdir_p) "$(DESTDIR)$(cxxcryptospecdir)"
@list='$(cxxcryptospec_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(cxxcryptospecHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(cxxcryptospecdir)/$$f'"; \
$(cxxcryptospecHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(cxxcryptospecdir)/$$f"; \
done
uninstall-cxxcryptospecHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(cxxcryptospec_HEADERS)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f '$(DESTDIR)$(cxxcryptospecdir)/$$f'"; \
rm -f "$(DESTDIR)$(cxxcryptospecdir)/$$f"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(cxxcryptospecdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-cxxcryptospecHEADERS
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-cxxcryptospecHEADERS uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-cxxcryptospecHEADERS install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-cxxcryptospecHEADERS \
uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/crypto/spec/PBEKeySpec.h"
using namespace beecrypt::crypto::spec;
PBEKeySpec::PBEKeySpec(const array<javachar>* password) : _password(password ? *password : 0)
{
_salt = 0;
_iteration_count = 0;
_key_length = 0;
}
PBEKeySpec::PBEKeySpec(const array<javachar>* password, const bytearray* salt, size_t iterationCount, size_t keyLength) : _password(password ? *password : 0)
{
if (salt)
_salt = new bytearray(*salt);
_iteration_count = iterationCount;
_key_length = keyLength;
}
PBEKeySpec::~PBEKeySpec()
{
}
const array<javachar>& PBEKeySpec::getPassword() const throw ()
{
return _password;
}
const bytearray* PBEKeySpec::getSalt() const throw ()
{
return _salt;
}
size_t PBEKeySpec::getIterationCount() const throw ()
{
return _iteration_count;
}
size_t PBEKeySpec::getKeyLength() const throw ()
{
return _key_length;
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file PBEKeySpec.h
* \ingroup CXX_CRYPTO_SPEC_m
*/
#ifndef _CLASS_PBEKEYSPEC_H
#define _CLASS_PBEKEYSPEC_H
#ifdef __cplusplus
#include "beecrypt/c++/array.h"
using beecrypt::array;
using beecrypt::bytearray;
#include "beecrypt/c++/security/spec/KeySpec.h"
using beecrypt::security::spec::KeySpec;
namespace beecrypt {
namespace crypto {
namespace spec {
class BEECRYPTCXXAPI PBEKeySpec : public KeySpec
{
private:
array<javachar> _password;
bytearray* _salt;
size_t _iteration_count;
size_t _key_length;
public:
PBEKeySpec(const array<javachar>* password);
PBEKeySpec(const array<javachar>* password, const bytearray* salt, size_t iterationCount, size_t keyLength);
virtual ~PBEKeySpec();
const array<javachar>& getPassword() const throw ();
const bytearray* getSalt() const throw ();
size_t getIterationCount() const throw ();
size_t getKeyLength() const throw ();
};
}
}
}
#endif
#endif

View File

@ -0,0 +1,129 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/io/ByteArrayInputStream.h"
#include "beecrypt/c++/lang/NullPointerException.h"
using beecrypt::lang::NullPointerException;
using namespace beecrypt::io;
ByteArrayInputStream::ByteArrayInputStream(const bytearray& b) : _buf(b)
{
_lock.init();
_count = _buf.size();
_mark = 0;
_pos = 0;
}
ByteArrayInputStream::ByteArrayInputStream(const byte* data, size_t offset, size_t length) : _buf(data+offset, length)
{
_lock.init();
_count = _buf.size();
_mark = 0;
_pos = 0;
}
ByteArrayInputStream::~ByteArrayInputStream()
{
_lock.destroy();
}
off_t ByteArrayInputStream::available() throw (IOException)
{
return (off_t)(_count - _pos);
}
void ByteArrayInputStream::close() throw (IOException)
{
}
void ByteArrayInputStream::mark(off_t readlimit) throw ()
{
_mark = _pos;
}
bool ByteArrayInputStream::markSupported() throw ()
{
return true;
}
int ByteArrayInputStream::read() throw (IOException)
{
register int rc;
_lock.lock();
rc = (_pos < _count) ? _buf[_pos++] : -1;
_lock.unlock();
return rc;
}
int ByteArrayInputStream::read(byte* data, size_t offset, size_t length) throw (IOException)
{
if (!data)
throw NullPointerException();
_lock.lock();
if (_pos >= _count)
{
_lock.unlock();
return -1;
}
if (_pos + length > _count)
length = _count - _pos;
if (length == 0)
{
_lock.unlock();
return 0;
}
memcpy(data+offset, _buf.data()+_pos, length);
_pos += length;
_lock.unlock();
return length;
}
int ByteArrayInputStream::read(bytearray& b) throw (IOException)
{
return read(b.data(), 0, b.size());
}
void ByteArrayInputStream::reset() throw (IOException)
{
_lock.lock();
_pos = _mark;
_lock.unlock();
}
off_t ByteArrayInputStream::skip(off_t n) throw (IOException)
{
_lock.lock();
if (_pos + n > _count)
n = _count - _pos;
_pos += n;
_lock.unlock();
return n;
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file ByteArrayInputStream.h
* \ingroup CXX_IO_m
*/
#ifndef _CLASS_BYTEARRAYINPUTSTREAM_H
#define _CLASS_BYTEARRAYINPUTSTREAM_H
#ifdef __cplusplus
#include "beecrypt/c++/array.h"
using beecrypt::bytearray;
#include "beecrypt/c++/mutex.h"
using beecrypt::mutex;
#include "beecrypt/c++/io/InputStream.h"
using beecrypt::io::InputStream;
namespace beecrypt {
namespace io {
class BEECRYPTCXXAPI ByteArrayInputStream : public InputStream
{
private:
mutex _lock;
protected:
bytearray _buf;
size_t _count;
size_t _mark;
size_t _pos;
public:
ByteArrayInputStream(const byte* data, size_t offset, size_t length);
ByteArrayInputStream(const bytearray& b);
virtual ~ByteArrayInputStream();
virtual off_t available() throw (IOException);
virtual void close() throw (IOException);
virtual void mark(off_t readlimit) throw ();
virtual bool markSupported() throw ();
virtual int read() throw (IOException);
virtual int read(byte* data, size_t offset, size_t length) throw (IOException);
virtual int read(bytearray&) throw (IOException);
virtual void reset() throw (IOException);
virtual off_t skip(off_t n) throw (IOException);
};
}
}
#endif
#endif

View File

@ -0,0 +1,127 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/io/ByteArrayOutputStream.h"
#include "beecrypt/c++/lang/NullPointerException.h"
using beecrypt::lang::NullPointerException;
using namespace beecrypt::io;
ByteArrayOutputStream::ByteArrayOutputStream() : _buf(32)
{
_lock.init();
_count = 0;
}
ByteArrayOutputStream::ByteArrayOutputStream(size_t size) : _buf(size)
{
_lock.init();
_count = 0;
}
ByteArrayOutputStream::~ByteArrayOutputStream()
{
_lock.destroy();
}
void ByteArrayOutputStream::reset() throw ()
{
_count = 0;
}
size_t ByteArrayOutputStream::size() throw ()
{
return _count;
}
bytearray* ByteArrayOutputStream::toByteArray()
{
bytearray* result = new bytearray();
toByteArray(*result);
return result;
}
void ByteArrayOutputStream::toByteArray(bytearray& b)
{
_lock.lock();
b.resize(_count);
memcpy(b.data(), _buf.data(), _count);
_lock.unlock();
}
void ByteArrayOutputStream::close() throw (IOException)
{
}
void ByteArrayOutputStream::flush() throw (IOException)
{
}
void ByteArrayOutputStream::write(byte b) throw (IOException)
{
_lock.lock();
size_t newcount = _count+1;
size_t actualsz = _buf.size();
if (actualsz < newcount)
{
if (actualsz == 0)
_buf.resize(32);
else
_buf.resize(actualsz << 1);
}
_buf[_count++] = b;
_lock.unlock();
}
void ByteArrayOutputStream::write(const byte* data, size_t offset, size_t length) throw (IOException)
{
if (!data)
throw NullPointerException();
_lock.lock();
size_t newcount = _count + length;
size_t actualsz = _buf.size();
if (newcount > actualsz)
{
_buf.resize(newcount > (actualsz << 1) ? newcount : (actualsz << 1));
}
memcpy(_buf.data()+_count, data, length);
_count += length;
_lock.unlock();
}
void ByteArrayOutputStream::write(const bytearray& b) throw (IOException)
{
write(b.data(), 0, b.size());
}

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file ByteArrayOutputStream.h
* \ingroup CXX_IO_m
*/
#ifndef _CLASS_BYTEARRAYOUTPUTSTREAM_H
#define _CLASS_BYTEARRAYOUTPUTSTREAM_H
#ifdef __cplusplus
#include "beecrypt/c++/mutex.h"
using beecrypt::mutex;
#include "beecrypt/c++/io/OutputStream.h"
using beecrypt::io::OutputStream;
namespace beecrypt {
namespace io {
class BEECRYPTCXXAPI ByteArrayOutputStream : public OutputStream
{
private:
mutex _lock;
protected:
bytearray _buf;
size_t _count;
public:
ByteArrayOutputStream();
ByteArrayOutputStream(size_t);
virtual ~ByteArrayOutputStream();
void reset() throw ();
size_t size() throw ();
bytearray* toByteArray();
void toByteArray(bytearray&);
void writeTo(OutputStream& out) throw (IOException);
virtual void close() throw (IOException);
virtual void flush() throw (IOException);
virtual void write(byte b) throw (IOException);
virtual void write(const byte* data, size_t offset, size_t length) throw (IOException);
virtual void write(const bytearray& b) throw (IOException);
};
}
}
#endif
#endif

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DataInput.h
* \ingroup CXX_IO_m
*/
#ifndef _INTERFACE_DATAINPUT_H
#define _INTERFACE_DATAINPUT_H
#ifdef __cplusplus
#include "beecrypt/c++/array.h"
using beecrypt::bytearray;
#include "beecrypt/c++/io/IOException.h"
using beecrypt::io::IOException;
namespace beecrypt {
namespace io {
class DataInput
{
public:
virtual bool readBoolean() throw (IOException) = 0;
virtual javabyte readByte() throw (IOException) = 0;
virtual javachar readChar() throw (IOException) = 0;
virtual void readFully(byte*, size_t, size_t) = 0;
virtual void readFully(bytearray&) = 0;
virtual javaint readInt() throw (IOException) = 0;
virtual String* readLine() throw (IOException) = 0;
virtual void readLine(String&) throw (IOException) = 0;
virtual javalong readLong() throw (IOException) = 0;
virtual javashort readShort() throw (IOException) = 0;
virtual int readUnsignedByte() throw (IOException) = 0;
virtual int readUnsignedShort() throw (IOException) = 0;
virtual String* readUTF() throw (IOException) = 0;
virtual void readUTF(String&) throw (IOException) = 0;
virtual off_t skipBytes(off_t n) throw (IOException) = 0;
};
}
}
#endif
#endif

View File

@ -0,0 +1,370 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/io/DataInputStream.h"
#include "beecrypt/c++/io/EOFException.h"
#include "beecrypt/c++/io/PushbackInputStream.h"
#include "beecrypt/c++/lang/NullPointerException.h"
using beecrypt::lang::NullPointerException;
#define MAX_BYTES_PER_CHARACTER 8
using namespace beecrypt::io;
DataInputStream::DataInputStream(InputStream& in) : FilterInputStream(in)
{
_pin = &in;
_del = false;
_utf = 0;
_loc = 0;
}
DataInputStream::~DataInputStream()
{
if (_utf)
{
ucnv_close(_utf);
_utf = 0;
}
if (_loc)
{
ucnv_close(_loc);
_loc = 0;
}
if (_del)
{
delete _pin;
_pin = 0;
}
}
bool DataInputStream::readBoolean() throw (IOException)
{
register int b = _pin->read();
if (b < 0)
throw EOFException();
return (b != 0);
}
javabyte DataInputStream::readByte() throw (IOException)
{
register int b = _pin->read();
if (b < 0)
throw EOFException();
return static_cast<javabyte>(b);
}
int DataInputStream::readUnsignedByte() throw (IOException)
{
register int b = _pin->read();
if (b < 0)
throw EOFException();
return b;
}
javashort DataInputStream::readShort() throw (IOException)
{
register javashort tmp = 0;
register int rc;
for (register unsigned i = 0; i < 2; i++)
{
if ((rc = _pin->read()) < 0)
throw EOFException();
tmp = (tmp << 8) + rc;
}
return tmp;
}
int DataInputStream::readUnsignedShort() throw (IOException)
{
register int tmp = 0, rc;
for (register unsigned i = 0; i < 2; i++)
{
if ((rc = _pin->read()) < 0)
throw EOFException();
tmp = (tmp << 8) + rc;
}
return tmp;
}
javachar DataInputStream::readChar() throw (IOException)
{
register javachar tmp = 0;
register int rc;
for (register unsigned i = 0; i < 2; i++)
{
if ((rc = _pin->read()) < 0)
throw EOFException();
tmp = (tmp << 8) + rc;
}
return tmp;
}
javaint DataInputStream::readInt() throw (IOException)
{
register javaint tmp = 0;
register int rc;
for (register unsigned i = 0; i < 4; i++)
{
if ((rc = _pin->read()) < 0)
throw EOFException();
tmp = (tmp << 8) + rc;
}
return tmp;
}
javalong DataInputStream::readLong() throw (IOException)
{
register javalong tmp = 0;
register int rc;
for (register unsigned i = 0; i < 8; i++)
{
if ((rc = _pin->read()) < 0)
throw EOFException();
tmp = (tmp << 8) + rc;
}
return tmp;
}
void DataInputStream::readUTF(String& str) throw (IOException)
{
UErrorCode status = U_ZERO_ERROR;
if (!_utf)
{
// UTF-8 converter lazy initialization
_utf = ucnv_open("UTF-8", &status);
if (U_FAILURE(status))
throw IOException("unable to open ICU UTF-8 converter");
}
int utflen = readUnsignedShort();
if (utflen > 0)
{
byte* data = new byte[utflen];
readFully(data, 0, utflen);
status = U_ZERO_ERROR;
size_t ulen = ucnv_toUChars(_utf, 0, 0, (const char*) data, (size_t) utflen, &status);
if (status != U_BUFFER_OVERFLOW_ERROR)
{
delete[] data;
throw "error in ucnv_toUChars";
}
UChar* buffer = str.getBuffer(ulen+1);
if (buffer)
{
status = U_ZERO_ERROR;
ucnv_toUChars(_utf, buffer, ulen+1, (const char*) data, (size_t) utflen, &status);
delete[] data;
if (status != U_ZERO_ERROR)
throw "error in ucnv_toUChars";
str.releaseBuffer(ulen);
}
else
{
delete[] data;
throw "error in String::getBuffer(size_t)";
}
}
}
String* DataInputStream::readUTF() throw (IOException)
{
String* str = new String();
try
{
readUTF(*str);
}
catch (IOException ex)
{
/* cleanup str */
delete str;
/* re-throw exception */
throw ex;
}
return str;
}
String* DataInputStream::readLine() throw (IOException)
{
String* result = new String();
readLine(*result);
return result;
}
void DataInputStream::readLine(String& line) throw (IOException)
{
UErrorCode status = U_ZERO_ERROR;
if (!_loc)
{
// default locale converter lazy initialization
_loc = ucnv_open(0, &status);
if (U_FAILURE(status))
throw IOException("unable to open ICU default locale converter");
}
UChar target_buffer[1];
UChar* target = target_buffer;
const UChar* target_limit = target_buffer+1;
char source_buffer[MAX_BYTES_PER_CHARACTER];
const char* source = source_buffer;
char* source_limit = source_buffer;
bool cr = false;
int ch;
// clear the line
line.remove();
do
{
ch = _pin->read();
if (ch >= 0)
{
if ((source_limit-source_buffer) == MAX_BYTES_PER_CHARACTER)
throw IOException("fubar in readLine");
*(source_limit++) = (byte) ch;
}
status = U_ZERO_ERROR;
// use the default locale converter; flush if ch == -1
ucnv_toUnicode(_loc, &target, target_limit, &source, source_limit, NULL, (UBool) (ch == -1), &status);
if (U_FAILURE(status))
throw IOException("error in ucnv_toUnicode");
if (target == target_limit)
{
// we got a whole character from the converter
if (cr)
{
// last character read was ASCII <CR>; is this one a <LF>?
if (target_buffer[0] != 0x0A)
{
// unread the right number of bytes
PushbackInputStream* p = dynamic_cast<PushbackInputStream*>(_pin);
if (p)
p->unread((const byte*) source_buffer, 0, source-source_buffer);
else
throw IOException("fubar in dynamic_cast");
}
// we're now officially at the end of the line
break;
}
// did we get an ASCII <LF>?
if (target_buffer[0] == 0x0A)
break;
// did we get an ASCII <CR>?
if (target_buffer[0] == 0x0D)
{
cr = true;
// the next character may be a <LF> but if not we'll have to 'unread' it
if (!_del)
{
// lazy push
_pin = new PushbackInputStream(in, MAX_BYTES_PER_CHARACTER);
_del = true;
}
}
else
{
// append character to string and reset pointers
source = source_limit = source_buffer;
line.append(*(target = target_buffer));
}
}
} while (ch >= 0);
}
void DataInputStream::readFully(byte* data, size_t offset, size_t length) throw (IOException)
{
if (!data)
throw NullPointerException();
size_t total = 0;
while (total < length)
{
int rc = _pin->read(data, offset+total, length-total);
if (rc < 0)
throw EOFException();
total += rc;
}
}
void DataInputStream::readFully(bytearray& b) throw (IOException)
{
readFully(b.data(), 0, b.size());
}
off_t DataInputStream::skipBytes(off_t n) throw (IOException)
{
off_t total = 0, rc;
while ((total < n) && ((rc = _pin->skip(n - total)) > 0))
total += rc;
return total;
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DataInputStream.h
* \ingroup CXX_IO_m
*/
#ifndef _CLASS_DATAINPUTSTREAM_H
#define _CLASS_DATAINPUTSTREAM_H
#ifdef __cplusplus
#include "beecrypt/c++/io/DataInput.h"
using beecrypt::io::DataInput;
#include "beecrypt/c++/io/FilterInputStream.h"
using beecrypt::io::FilterInputStream;
#include <unicode/ucnv.h>
namespace beecrypt {
namespace io {
class BEECRYPTCXXAPI DataInputStream : public FilterInputStream, public DataInput
{
private:
bool _del;
InputStream* _pin;
UConverter* _utf;
UConverter* _loc;
public:
DataInputStream(InputStream& in);
virtual ~DataInputStream();
virtual bool readBoolean() throw (IOException);
virtual javabyte readByte() throw (IOException);
virtual javachar readChar() throw (IOException);
virtual void readFully(byte* data, size_t offset, size_t length) throw (IOException);
virtual void readFully(bytearray& b) throw (IOException);
virtual javaint readInt() throw (IOException);
virtual String* readLine() throw (IOException);
virtual void readLine(String&) throw (IOException);
virtual javalong readLong() throw (IOException);
virtual javashort readShort() throw (IOException);
virtual int readUnsignedByte() throw (IOException);
virtual int readUnsignedShort() throw (IOException);
virtual String* readUTF() throw (IOException);
virtual void readUTF(String&) throw (IOException);
virtual off_t skipBytes(off_t n) throw (IOException);
};
}
}
#endif
#endif

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DataOutput.h
* \ingroup CXX_IO_m
*/
#ifndef _INTERFACE_DATAOUTPUT_H
#define _INTERFACE_DATAOUTPUT_H
#ifdef __cplusplus
#include "beecrypt/c++/array.h"
using beecrypt::bytearray;
#include "beecrypt/c++/io/IOException.h"
using beecrypt::io::IOException;
namespace beecrypt {
namespace io {
class DataOutput
{
public:
virtual void write(const bytearray&) throw (IOException) = 0;
virtual void write(const byte*, size_t, size_t) throw (IOException) = 0;
virtual void write(byte) throw (IOException) = 0;
virtual void writeBoolean(bool) throw (IOException) = 0;
virtual void writeByte(byte) throw (IOException) = 0;
virtual void writeChars(const String&) throw (IOException) = 0;
virtual void writeInt(javaint) throw (IOException) = 0;
virtual void writeLong(javalong) throw (IOException) = 0;
virtual void writeShort(javashort) throw (IOException) = 0;
virtual void writeUTF(const String&) throw (IOException) = 0;
};
}
}
#endif
#endif

View File

@ -0,0 +1,186 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/io/DataOutputStream.h"
using namespace beecrypt::io;
DataOutputStream::DataOutputStream(OutputStream& out) : FilterOutputStream(out)
{
_lock.init();
_utf = 0;
written = 0;
}
DataOutputStream::~DataOutputStream()
{
_lock.destroy();
if (_utf)
ucnv_close(_utf);
}
size_t DataOutputStream::size() const throw ()
{
return written;
}
void DataOutputStream::write(byte b) throw (IOException)
{
_lock.lock();
out.write(b);
written++;
_lock.unlock();
}
void DataOutputStream::write(const byte* data, size_t offset, size_t len) throw (IOException)
{
_lock.lock();
out.write(data, offset, len);
written += len;
_lock.unlock();
}
void DataOutputStream::write(const bytearray& b) throw (IOException)
{
write(b.data(), 0, b.size());
}
void DataOutputStream::writeBoolean(bool b) throw (IOException)
{
_lock.lock();
out.write(b ? 1 : 0);
written++;
_lock.unlock();
}
void DataOutputStream::writeByte(byte b) throw (IOException)
{
_lock.lock();
out.write(b);
written++;
_lock.unlock();
}
void DataOutputStream::writeShort(javashort s) throw (IOException)
{
_lock.lock();
out.write((s >> 8) );
out.write((s ) & 0xff);
written += 2;
_lock.unlock();
}
void DataOutputStream::writeInt(javaint i) throw (IOException)
{
_lock.lock();
out.write((i >> 24) );
out.write((i >> 16) & 0xff);
out.write((i >> 8) & 0xff);
out.write((i ) & 0xff);
written += 4;
_lock.unlock();
}
void DataOutputStream::writeLong(javalong l) throw (IOException)
{
_lock.lock();
out.write((l >> 56) );
out.write((l >> 48) & 0xff);
out.write((l >> 40) & 0xff);
out.write((l >> 32) & 0xff);
out.write((l >> 24) & 0xff);
out.write((l >> 16) & 0xff);
out.write((l >> 8) & 0xff);
out.write((l ) & 0xff);
written += 8;
_lock.unlock();
}
void DataOutputStream::writeChars(const String& str) throw (IOException)
{
const UChar* buffer = str.getBuffer();
size_t len = str.length();
_lock.lock();
for (size_t i = 0; i < len; i++)
{
out.write((buffer[i] >> 8) & 0xff);
out.write((buffer[i] ) & 0xff);
}
written += (len << 1);
_lock.unlock();
}
void DataOutputStream::writeUTF(const String& str) throw (IOException)
{
UErrorCode status = U_ZERO_ERROR;
if (!_utf)
{
// UTF-8 converter lazy initialization
_utf = ucnv_open("UTF-8", &status);
if (U_FAILURE(status))
throw IOException("unable to open ICU UTF-8 converter");
}
// the expected status code here is U_BUFFER_OVERFLOW_ERROR
size_t need = ucnv_fromUChars(_utf, 0, 0, str.getBuffer(), str.length(), &status);
if (U_FAILURE(status))
if (status != U_BUFFER_OVERFLOW_ERROR)
throw IOException("unexpected error in ucnv_fromUChars");
if (need > 0xffff)
throw IOException("String length >= 64K");
byte* buffer = new byte[need];
status = U_ZERO_ERROR;
// the expected status code here is U_STRING_NOT_TERMINATED_WARNING
ucnv_fromUChars(_utf, (char*) buffer, need, str.getBuffer(), str.length(), &status);
if (status != U_STRING_NOT_TERMINATED_WARNING)
{
delete[] buffer;
throw IOException("error in ucnv_fromUChars");
}
// everything ready for the critical section
_lock.lock();
try
{
out.write((need >> 8) & 0xff);
out.write((need ) & 0xff);
out.write(buffer, 0, need);
written += 2 + need;
_lock.unlock();
delete[] buffer;
}
catch (IOException)
{
_lock.unlock();
delete[] buffer;
throw;
}
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*!\file DataOutputStream.h
* \ingroup CXX_IO_m
*/
#ifndef _CLASS_DATAOUTPUTSTREAM_H
#define _CLASS_DATAOUTPUTSTREAM_H
#ifdef __cplusplus
#include "beecrypt/c++/mutex.h"
using beecrypt::mutex;
#include "beecrypt/c++/io/DataOutput.h"
using beecrypt::io::DataOutput;
#include "beecrypt/c++/io/FilterOutputStream.h"
using beecrypt::io::FilterOutputStream;
#include <unicode/ucnv.h>
namespace beecrypt {
namespace io {
class BEECRYPTCXXAPI DataOutputStream : public FilterOutputStream, public DataOutput
{
private:
mutex _lock;
UConverter* _utf;
protected:
size_t written;
public:
DataOutputStream(OutputStream& out);
virtual ~DataOutputStream();
size_t size() const throw ();
virtual void write(byte) throw (IOException);
virtual void write(const byte* data, size_t offset, size_t length) throw (IOException);
virtual void write(const bytearray&) throw (IOException);
virtual void writeBoolean(bool) throw (IOException);
virtual void writeByte(byte) throw (IOException);
virtual void writeChars(const String&) throw (IOException);
virtual void writeInt(javaint) throw (IOException);
virtual void writeLong(javalong) throw (IOException);
virtual void writeShort(javashort) throw (IOException);
virtual void writeUTF(const String&) throw (IOException);
};
}
}
#endif
#endif

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2004 Beeyond Software Holding BV
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/io/EOFException.h"
using namespace beecrypt::io;
EOFException::EOFException() throw ()
{
}
EOFException::EOFException(const String& message) throw () : IOException(message)
{
}

Some files were not shown because too many files have changed in this diff Show More