Commit 09035649 authored by unknown's avatar unknown Committed by unknown

Merge from mysql-5.0.96-release

parents f5e730ed 08b6f6c2
...@@ -5,7 +5,7 @@ For the avoidance of doubt, this particular copy of the software ...@@ -5,7 +5,7 @@ For the avoidance of doubt, this particular copy of the software
is released under the version 2 of the GNU General Public License. is released under the version 2 of the GNU General Public License.
MySQL is brought to you by Oracle. MySQL is brought to you by Oracle.
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
License information can be found in the COPYING file. License information can be found in the COPYING file.
......
File mode changed from 100755 to 100644
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software Installation Instructions
Foundation, Inc. *************************
This file is free documentation; the Free Software Foundation gives Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006 Free Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it. unlimited permission to copy, distribute and modify it.
Basic Installation Basic Installation
================== ==================
These are generic installation instructions. Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package.
The `configure' shell script attempts to guess correct values for The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses various system-dependent variables used during compilation. It uses
...@@ -20,9 +26,9 @@ debugging `configure'). ...@@ -20,9 +26,9 @@ debugging `configure').
It can also use an optional file (typically called `config.cache' It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale disabled by default to prevent problems with accidental use of stale
cache files.) cache files.
If you need to do unusual things to compile the package, please try If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail to figure out how `configure' could check whether to do them, and mail
...@@ -32,20 +38,17 @@ some point `config.cache' contains results you don't want to keep, you ...@@ -32,20 +38,17 @@ some point `config.cache' contains results you don't want to keep, you
may remove or edit it. may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need `configure' by a program called `autoconf'. You need `configure.ac' if
`configure.ac' if you want to change it or regenerate `configure' using you want to change it or regenerate `configure' using a newer version
a newer version of `autoconf'. of `autoconf'.
The simplest way to compile this package is: The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type 1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're `./configure' to configure the package for your system.
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some Running `configure' might take a while. While running, it prints
messages telling which features it is checking for. some messages telling which features it is checking for.
2. Type `make' to compile the package. 2. Type `make' to compile the package.
...@@ -67,51 +70,49 @@ The simplest way to compile this package is: ...@@ -67,51 +70,49 @@ The simplest way to compile this package is:
Compilers and Options Compilers and Options
===================== =====================
Some systems require unusual options for compilation or linking that Some systems require unusual options for compilation or linking that the
the `configure' script does not know about. Run `./configure --help' `configure' script does not know about. Run `./configure --help' for
for details on some of the pertinent environment variables. details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here by setting variables in the command line or in the environment. Here
is an example: is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details. *Note Defining Variables::, for more details.
Compiling For Multiple Architectures Compiling For Multiple Architectures
==================================== ====================================
You can compile the package for more than one kind of computer at the You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that own directory. To do this, you can use GNU `make'. `cd' to the
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH' With a non-GNU `make', it is safer to compile the package for one
variable, you have to compile the package for one architecture at a architecture at a time in the source code directory. After you have
time in the source code directory. After you have installed the installed the package for one architecture, use `make distclean' before
package for one architecture, use `make distclean' before reconfiguring reconfiguring for another architecture.
for another architecture.
Installation Names Installation Names
================== ==================
By default, `make install' will install the package's files in By default, `make install' installs the package's commands under
`/usr/local/bin', `/usr/local/man', etc. You can specify an `/usr/local/bin', include files under `/usr/local/include', etc. You
installation prefix other than `/usr/local' by giving `configure' the can specify an installation prefix other than `/usr/local' by giving
option `--prefix=PATH'. `configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PATH as the prefix for installing programs and libraries. PREFIX as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix. Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. you can set and what kinds of files go in them.
...@@ -122,7 +123,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. ...@@ -122,7 +123,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features Optional Features
================= =================
Some packages pay attention to `--enable-FEATURE' options to Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package. `configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The is something like `gnu-as' or `x' (for the X Window System). The
...@@ -137,11 +138,11 @@ you can use the `configure' options `--x-includes=DIR' and ...@@ -137,11 +138,11 @@ you can use the `configure' options `--x-includes=DIR' and
Specifying the System Type Specifying the System Type
========================== ==========================
There may be some features `configure' cannot figure out There may be some features `configure' cannot figure out automatically,
automatically, but needs to determine by the type of machine the package but needs to determine by the type of machine the package will run on.
will run on. Usually, assuming the package is built to be run on the Usually, assuming the package is built to be run on the _same_
_same_ architectures, `configure' can figure that out, but if it prints architectures, `configure' can figure that out, but if it prints a
a message saying it cannot guess the machine type, give it the message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system `--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form: type, such as `sun4', or a canonical name which has the form:
...@@ -156,7 +157,7 @@ where SYSTEM can have one of these forms: ...@@ -156,7 +157,7 @@ where SYSTEM can have one of these forms:
need to know the machine type. need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will use the option `--target=TYPE' to select the type of system they will
produce code for. produce code for.
If you want to _use_ a cross compiler, that generates code for a If you want to _use_ a cross compiler, that generates code for a
...@@ -167,9 +168,9 @@ eventually be run) with `--host=TYPE'. ...@@ -167,9 +168,9 @@ eventually be run) with `--host=TYPE'.
Sharing Defaults Sharing Defaults
================ ================
If you want to set default values for `configure' scripts to share, If you want to set default values for `configure' scripts to share, you
you can create a site shell script called `config.site' that gives can create a site shell script called `config.site' that gives default
default values for variables like `CC', `cache_file', and `prefix'. values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then `configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the `PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script. `CONFIG_SITE' environment variable to the location of the site script.
...@@ -178,7 +179,7 @@ A warning: not all `configure' scripts look for a site script. ...@@ -178,7 +179,7 @@ A warning: not all `configure' scripts look for a site script.
Defining Variables Defining Variables
================== ==================
Variables not defined in a site shell script can be set in the Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set variables may be lost. In order to avoid this problem, you should set
...@@ -186,14 +187,18 @@ them in the `configure' command line, using `VAR=value'. For example: ...@@ -186,14 +187,18 @@ them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc ./configure CC=/usr/local2/bin/gcc
will cause the specified gcc to be used as the C compiler (unless it is causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script). overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation `configure' Invocation
====================== ======================
`configure' recognizes the following options to control how it `configure' recognizes the following options to control how it operates.
operates.
`--help' `--help'
`-h' `-h'
......
*** Note, Please read ***
yaSSL takes a different approach to certificate verification than OpenSSL does.
The default policy for the client is to verify the server, this means that if
you don't load CAs to verify the server you'll get a connect error, unable to
verify. It you want to mimic OpenSSL behavior of not verifying the server and
reducing security you can do this by calling:
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
before calling SSL_new();
*** end Note ***
yaSSL Release notes, version 2.1.2 (9/2/2011)
This release of yaSSL contains bug fixes, better non-blocking support with
SSL_write, and OpenSSL RSA public key format support.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 2.0.0 (7/6/2010)
This release of yaSSL contains bug fixes, new testing certs,
and a security patch for a potential heap overflow on forged application
data processing. Vulnerability discovered by Matthieu Bonetti from VUPEN
Security http://www.vupen.com.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.9.9 (1/26/2010)
This release of yaSSL contains bug fixes, the removal of assert() s and
a security patch for a buffer overflow possibility in certificate name
processing.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.9.8 (10/14/09)
This release of yaSSL contains bug fixes and adds new stream ciphers
Rabbit and HC-128
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.9.6 (11/13/08)
This release of yaSSL contains bug fixes, adds autconf shared library
support and has better server suite detection based on certficate and
private key.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.9.2 (9/24/08)
This release of yaSSL contains bug fixes and improved certificate verify
callback support.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.8.8 (5/7/08)
This release of yaSSL contains bug fixes, and better socket handling.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.8.6 (1/31/08)
This release of yaSSL contains bug fixes, and fixes security problems
associated with using SSL 2.0 client hellos and improper input handling.
Please upgrade to this version if you are using a previous one.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.7.5 (10/15/07)
This release of yaSSL contains bug fixes, adds MSVC 2005 project support,
GCC 4.2 support, IPV6 support and test, and new test certificates.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.7.2 (8/20/07)
This release of yaSSL contains bug fixes and adds initial OpenVPN support.
Just configure at this point and beginning of build.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.6.8 (4/16/07)
This release of yaSSL contains bug fixes and adds SHA-256, SHA-512, SHA-224,
and SHA-384.
See normal build instructions below under 1.0.6.
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
*****************yaSSL Release notes, version 1.6.0 (2/22/07) *****************yaSSL Release notes, version 1.6.0 (2/22/07)
This release of yaSSL contains bug fixes, portability enhancements, and This release of yaSSL contains bug fixes, portability enhancements, and
...@@ -13,7 +130,7 @@ See libcurl build instructions below under 1.3.0 and note in 1.5.8. ...@@ -13,7 +130,7 @@ See libcurl build instructions below under 1.3.0 and note in 1.5.8.
Since yaSSL now supports zlib, as does libcur, the libcurl build test can Since yaSSL now supports zlib, as does libcurl, the libcurl build test can
fail if yaSSL is built with zlib support since the zlib library isn't fail if yaSSL is built with zlib support since the zlib library isn't
passed. You can do two things to fix this: passed. You can do two things to fix this:
...@@ -518,7 +635,7 @@ in the source and include files. ...@@ -518,7 +635,7 @@ in the source and include files.
********************* *********************
Contact: please send comments or questions to Todd A Ouska at todd@yassl.com Contact: please send comments or questions to Todd A Ouska at todd@yassl.com
and/or Larry Stefonic at larry@yassl.com or 425-741-6858. and/or Larry Stefonic at larry@yassl.com.
Certificate: Certificate:
Data: Data:
Version: 3 (0x2) Version: 3 (0x2)
Serial Number: 0 (0x0) Serial Number:
8a:37:22:65:73:f5:aa:e8
Signature Algorithm: md5WithRSAEncryption Signature Algorithm: md5WithRSAEncryption
Issuer: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com Issuer: C=US, ST=Montana, L=Bozeman, O=sawtooth, OU=consulting, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com
Validity Validity
Not Before: Mar 7 03:10:11 2005 GMT Not Before: Jun 30 18:47:10 2010 GMT
Not After : Apr 1 03:10:11 2046 GMT Not After : Mar 26 18:47:10 2013 GMT
Subject: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com Subject: C=US, ST=Montana, L=Bozeman, O=sawtooth, OU=consulting, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com
Subject Public Key Info: Subject Public Key Info:
Public Key Algorithm: rsaEncryption Public Key Algorithm: rsaEncryption
RSA Public Key: (512 bit) RSA Public Key: (512 bit)
Modulus (512 bit): Modulus (512 bit):
00:ef:c1:e3:9a:3c:6e:6e:cb:26:6f:05:be:e0:cb: 00:97:30:b9:1a:92:ef:25:4f:ca:4c:11:31:95:1a:
57:a0:4b:68:e6:1b:f9:95:db:01:92:aa:6e:a6:b5: e1:c0:10:19:0a:20:b9:37:80:1a:57:38:02:4e:1b:
2d:b1:2b:50:fd:db:13:f2:c5:d8:b8:4f:75:28:53: c5:0f:28:4f:da:e3:c9:16:aa:50:bd:4a:fb:b7:71:
72:e8:e5:11:9d:bb:c3:4f:4f:09:fd:4c:e7:46:d5: c7:35:cc:63:81:c1:dd:9d:33:f9:38:16:88:32:a0:
1d:bb:35:02:af aa:56:23:03:a3
Exponent: 65537 (0x10001) Exponent: 65537 (0x10001)
X509v3 extensions: X509v3 extensions:
X509v3 Subject Key Identifier: X509v3 Subject Key Identifier:
1D:EF:A1:B8:81:78:12:47:E8:57:06:08:74:18:F7:D3:AA:D8:F7:BD 3B:66:FD:A0:40:C6:F4:E2:70:CF:21:1A:0C:4F:67:FE:B7:4B:42:09
X509v3 Authority Key Identifier: X509v3 Authority Key Identifier:
keyid:1D:EF:A1:B8:81:78:12:47:E8:57:06:08:74:18:F7:D3:AA:D8:F7:BD keyid:3B:66:FD:A0:40:C6:F4:E2:70:CF:21:1A:0C:4F:67:FE:B7:4B:42:09
DirName:/C=US/ST=Oregon/L=Portland/O=sawtooth/CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com DirName:/C=US/ST=Montana/L=Bozeman/O=sawtooth/OU=consulting/CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com
serial:00 serial:8A:37:22:65:73:F5:AA:E8
X509v3 Basic Constraints: X509v3 Basic Constraints:
CA:TRUE CA:TRUE
Signature Algorithm: md5WithRSAEncryption Signature Algorithm: md5WithRSAEncryption
d9:77:e3:07:d9:2e:ec:2f:9b:8e:9e:ca:b4:00:0b:ef:c7:74: 32:65:a2:b1:dc:6d:e0:8d:8b:c8:58:29:8e:b8:18:4b:62:88:
cb:f4:f6:44:2f:02:75:17:a5:74:3e:26:b2:26:fd:1f:ab:3a: 13:67:f8:6c:75:46:75:8f:8a:19:a6:a3:d5:3c:fc:57:4e:7a:
df:d5:e3:05:14:08:d0:8c:1d:c9:3e:e1:59:6f:b3:38:5d:af: 68:a9:fc:93:dc:ae:29:7d:bb:4e:ec:ea:55:fa:a4:e3:00:61:
78:60:e3:c5:6a:69:96:80:7d:00 f4:b0:34:6d:d1:d5:a4:64:24:f8
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIC7zCCApmgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBiTELMAkGA1UEBhMCVVMx MIIDQDCCAuqgAwIBAgIJAIo3ImVz9aroMA0GCSqGSIb3DQEBBAUAMIGeMQswCQYD
DzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxhbmQxETAPBgNVBAoTCHNh VQQGEwJVUzEQMA4GA1UECBMHTW9udGFuYTEQMA4GA1UEBxMHQm96ZW1hbjERMA8G
d3Rvb3RoMSQwIgYDVQQDExt3d3cuc2F3dG9vdGgtY29uc3VsdGluZy5jb20xHTAb A1UEChMIc2F3dG9vdGgxEzARBgNVBAsTCmNvbnN1bHRpbmcxJDAiBgNVBAMTG3d3
BgkqhkiG9w0BCQEWDmluZm9AeWFzc2wuY29tMB4XDTA1MDMwNzAzMTAxMVoXDTQ2 dy5zYXd0b290aC1jb25zdWx0aW5nLmNvbTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5
MDQwMTAzMTAxMVowgYkxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIEwZPcmVnb24xETAP YXNzbC5jb20wHhcNMTAwNjMwMTg0NzEwWhcNMTMwMzI2MTg0NzEwWjCBnjELMAkG
BgNVBAcTCFBvcnRsYW5kMREwDwYDVQQKEwhzYXd0b290aDEkMCIGA1UEAxMbd3d3 A1UEBhMCVVMxEDAOBgNVBAgTB01vbnRhbmExEDAOBgNVBAcTB0JvemVtYW4xETAP
LnNhd3Rvb3RoLWNvbnN1bHRpbmcuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlh BgNVBAoTCHNhd3Rvb3RoMRMwEQYDVQQLEwpjb25zdWx0aW5nMSQwIgYDVQQDExt3
c3NsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDvweOaPG5uyyZvBb7gy1eg d3cuc2F3dG9vdGgtY29uc3VsdGluZy5jb20xHTAbBgkqhkiG9w0BCQEWDmluZm9A
S2jmG/mV2wGSqm6mtS2xK1D92xPyxdi4T3UoU3Lo5RGdu8NPTwn9TOdG1R27NQKv eWFzc2wuY29tMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJcwuRqS7yVPykwRMZUa
AgMBAAGjgekwgeYwHQYDVR0OBBYEFB3vobiBeBJH6FcGCHQY99Oq2Pe9MIG2BgNV 4cAQGQoguTeAGlc4Ak4bxQ8oT9rjyRaqUL1K+7dxxzXMY4HB3Z0z+TgWiDKgqlYj
HSMEga4wgauAFB3vobiBeBJH6FcGCHQY99Oq2Pe9oYGPpIGMMIGJMQswCQYDVQQG A6MCAwEAAaOCAQcwggEDMB0GA1UdDgQWBBQ7Zv2gQMb04nDPIRoMT2f+t0tCCTCB
EwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDERMA8GA1UE 0wYDVR0jBIHLMIHIgBQ7Zv2gQMb04nDPIRoMT2f+t0tCCaGBpKSBoTCBnjELMAkG
ChMIc2F3dG9vdGgxJDAiBgNVBAMTG3d3dy5zYXd0b290aC1jb25zdWx0aW5nLmNv A1UEBhMCVVMxEDAOBgNVBAgTB01vbnRhbmExEDAOBgNVBAcTB0JvemVtYW4xETAP
bTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb22CAQAwDAYDVR0TBAUwAwEB BgNVBAoTCHNhd3Rvb3RoMRMwEQYDVQQLEwpjb25zdWx0aW5nMSQwIgYDVQQDExt3
/zANBgkqhkiG9w0BAQQFAANBANl34wfZLuwvm46eyrQAC+/HdMv09kQvAnUXpXQ+ d3cuc2F3dG9vdGgtY29uc3VsdGluZy5jb20xHTAbBgkqhkiG9w0BCQEWDmluZm9A
JrIm/R+rOt/V4wUUCNCMHck+4Vlvszhdr3hg48VqaZaAfQA= eWFzc2wuY29tggkAijciZXP1qugwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQF
AANBADJlorHcbeCNi8hYKY64GEtiiBNn+Gx1RnWPihmmo9U8/FdOemip/JPcril9
u07s6lX6pOMAYfSwNG3R1aRkJPg=
-----END CERTIFICATE----- -----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
MIIBOQIBAAJBAJcwuRqS7yVPykwRMZUa4cAQGQoguTeAGlc4Ak4bxQ8oT9rjyRaq
UL1K+7dxxzXMY4HB3Z0z+TgWiDKgqlYjA6MCAwEAAQJAEQ9TY7c+uuQU/J5YDO4a
mRR37tegbq3Kyxqrz+p8QuhqLDtVh13GaF7rVU70vyNHm+cgihUyzho/PViAkPBo
qQIhAMU8/RDhDLgL5BxID4sxKIVBtg+imFSbyKVyg7oQLUcXAiEAxDu94O45Cf4a
np9R0thumY/QqWpCkycWAB7fFEuaf1UCIEH+bg4/vqm2ENUFp23DPPOZUPlaRe3J
UhFJh5mx3/RxAiBq++8vfHFYg1Lb/BxOCXVy/zdRxf753ytdcXdJx1Y56QIgVgpN
FNfYJofQfWaP96sjlc0usrT28uceHx0QmHqolVc=
-----END RSA PRIVATE KEY-----
Certificate: Certificate:
Data: Data:
Version: 3 (0x2) Version: 3 (0x2)
Serial Number: 0 (0x0) Serial Number:
c5:d7:6c:11:36:f0:35:e1
Signature Algorithm: md5WithRSAEncryption Signature Algorithm: md5WithRSAEncryption
Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL, CN=www.yassl.com/emailAddress=info@yassl.com Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=programming, CN=www.yassl.com/emailAddress=info@yassl.com
Validity Validity
Not Before: Mar 7 03:00:31 2005 GMT Not Before: Jun 30 18:39:39 2010 GMT
Not After : Apr 1 03:00:31 2046 GMT Not After : Mar 26 18:39:40 2013 GMT
Subject: C=US, ST=Oregon, L=Portland, O=yaSSL, CN=www.yassl.com/emailAddress=info@yassl.com Subject: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=programming, CN=www.yassl.com/emailAddress=info@yassl.com
Subject Public Key Info: Subject Public Key Info:
Public Key Algorithm: rsaEncryption Public Key Algorithm: rsaEncryption
RSA Public Key: (512 bit) RSA Public Key: (512 bit)
Modulus (512 bit): Modulus (512 bit):
00:cd:1f:78:47:f8:b8:d6:08:bf:bd:7c:23:61:86: 00:bd:51:4a:14:fd:6a:19:84:0c:33:38:fc:27:32:
36:28:ac:ee:3c:a8:9a:94:e6:d5:26:e8:71:50:b2: 9c:97:0b:fc:a4:18:60:69:4e:d9:d8:78:50:0b:e9:
26:8b:1c:1e:3f:75:b2:d3:b3:67:95:0c:fd:76:28: 20:5d:d6:1d:70:1c:0c:24:9f:23:82:cc:3a:01:d5:
65:d5:ce:12:82:9e:06:00:a2:09:dd:ce:3a:26:dd: 97:17:b2:73:6c:86:cf:b5:f1:e5:ce:68:0c:d9:a2:
46:2a:a0:45:71 12:39:7c:f2:53
Exponent: 65537 (0x10001) Exponent: 65537 (0x10001)
X509v3 extensions: X509v3 extensions:
X509v3 Subject Key Identifier: X509v3 Subject Key Identifier:
AE:25:5E:FA:4D:A3:5B:2B:87:DE:F1:2A:F5:42:C0:FF:CE:B5:B4:AD 5C:F7:29:21:69:7A:09:78:9E:7B:CD:53:42:02:EC:CE:29:0D:11:DF
X509v3 Authority Key Identifier: X509v3 Authority Key Identifier:
keyid:AE:25:5E:FA:4D:A3:5B:2B:87:DE:F1:2A:F5:42:C0:FF:CE:B5:B4:AD keyid:5C:F7:29:21:69:7A:09:78:9E:7B:CD:53:42:02:EC:CE:29:0D:11:DF
DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL/CN=www.yassl.com/emailAddress=info@yassl.com DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL/OU=programming/CN=www.yassl.com/emailAddress=info@yassl.com
serial:00 serial:C5:D7:6C:11:36:F0:35:E1
X509v3 Basic Constraints: X509v3 Basic Constraints:
CA:TRUE CA:TRUE
Signature Algorithm: md5WithRSAEncryption Signature Algorithm: md5WithRSAEncryption
59:19:ae:1b:4e:65:9e:ca:f1:b8:3d:ff:c7:5e:15:86:10:97: b4:a5:f1:71:26:4d:b9:ff:54:f3:09:1f:ac:e1:19:59:e5:ec:
8c:3e:22:32:ab:4e:75:a7:70:83:f2:fb:2f:af:fe:26:28:e9: 57:e3:f1:0b:b2:8f:f3:29:eb:6b:c6:fa:27:33:3e:91:d0:77:
4f:d4:c9:49:7c:6f:51:7e:2a:ff:a0:5b:25:45:2e:66:d9:0d: 43:c9:ce:1e:0f:71:07:a9:f7:26:e0:7e:ff:30:7d:52:0a:e1:
92:94:e5:b8:60:c6:67:1a:f3:03 80:48:46:bb:99:e9:d9:77:ce:75
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIICtzCCAmGgAwIBAgIBADANBgkqhkiG9w0BAQQFADB4MQswCQYDVQQGEwJVUzEP MIIDDjCCArigAwIBAgIJAMXXbBE28DXhMA0GCSqGSIb3DQEBBAUAMIGOMQswCQYD
MA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDEOMAwGA1UEChMFeWFT VQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDEOMAwG
U0wxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkqhkiG9w0BCQEWDmluZm9A A1UEChMFeWFTU0wxFDASBgNVBAsTC3Byb2dyYW1taW5nMRYwFAYDVQQDEw13d3cu
eWFzc2wuY29tMB4XDTA1MDMwNzAzMDAzMVoXDTQ2MDQwMTAzMDAzMVoweDELMAkG eWFzc2wuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbTAeFw0xMDA2
A1UEBhMCVVMxDzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxhbmQxDjAM MzAxODM5MzlaFw0xMzAzMjYxODM5NDBaMIGOMQswCQYDVQQGEwJVUzEPMA0GA1UE
BgNVBAoTBXlhU1NMMRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJKoZIhvcN CBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDEOMAwGA1UEChMFeWFTU0wxFDAS
AQkBFg5pbmZvQHlhc3NsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDNH3hH BgNVBAsTC3Byb2dyYW1taW5nMRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJ
+LjWCL+9fCNhhjYorO48qJqU5tUm6HFQsiaLHB4/dbLTs2eVDP12KGXVzhKCngYA KoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgC
ogndzjom3UYqoEVxAgMBAAGjgdUwgdIwHQYDVR0OBBYEFK4lXvpNo1srh97xKvVC QQC9UUoU/WoZhAwzOPwnMpyXC/ykGGBpTtnYeFAL6SBd1h1wHAwknyOCzDoB1ZcX
wP/OtbStMIGiBgNVHSMEgZowgZeAFK4lXvpNo1srh97xKvVCwP/OtbStoXykejB4 snNshs+18eXOaAzZohI5fPJTAgMBAAGjgfYwgfMwHQYDVR0OBBYEFFz3KSFpegl4
MQswCQYDVQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFu nnvNU0IC7M4pDRHfMIHDBgNVHSMEgbswgbiAFFz3KSFpegl4nnvNU0IC7M4pDRHf
ZDEOMAwGA1UEChMFeWFTU0wxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkq oYGUpIGRMIGOMQswCQYDVQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQH
hkiG9w0BCQEWDmluZm9AeWFzc2wuY29tggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZI EwhQb3J0bGFuZDEOMAwGA1UEChMFeWFTU0wxFDASBgNVBAsTC3Byb2dyYW1taW5n
hvcNAQEEBQADQQBZGa4bTmWeyvG4Pf/HXhWGEJeMPiIyq051p3CD8vsvr/4mKOlP MRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlh
1MlJfG9Rfir/oFslRS5m2Q2SlOW4YMZnGvMD c3NsLmNvbYIJAMXXbBE28DXhMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQAD
QQC0pfFxJk25/1TzCR+s4RlZ5exX4/ELso/zKetrxvonMz6R0HdDyc4eD3EHqfcm
4H7/MH1SCuGASEa7menZd851
-----END CERTIFICATE----- -----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBAM0feEf4uNYIv718I2GGNiis7jyompTm1SbocVCyJoscHj91stOz MIIBPAIBAAJBAL1RShT9ahmEDDM4/CcynJcL/KQYYGlO2dh4UAvpIF3WHXAcDCSf
Z5UM/XYoZdXOEoKeBgCiCd3OOibdRiqgRXECAwEAAQJAXwa6OVVvg7Bv63+MAI0l I4LMOgHVlxeyc2yGz7Xx5c5oDNmiEjl88lMCAwEAAQJAVGHWLlLhpqvXsEEXCvWh
n/hlMfLGEj9R9gFvJXwywPSEQhijOZmedpHALufFPNHtwba9dmbqMkBAw9JDaAgg HCYono+K8YVGzhiaPSTU212fCoQryIxsXQKGBjhFdZm96DZWp+Vd/t/u+B4ZeaqY
QQIhAO+mBaSmoG5AYVKYQZiASe/2wMZjaQSN+zFLyF97OX8ZAiEA2x5iRmXUkbOT +QIhAOBEfbFtdZqk5OmbbRsRVPI7+YYmubgY1TVIPqmxHQ4NAiEA2BrTQkjOb3ul
8Td/vx8R9mq9W5CJu+cN+SWGwTYhPBkCIGZFM6NQeKaUUvQshdHO7b66Twpa4jZP A/SZO04fJUZsm7Ng92FWHDJsRancSd8CIQCmGbQqZBK1TamJZ6dAY+7RViAx/p6Q
YSNoc9pLe/4BAiB+jIvBkKo2A/rbg2waG32qTXdTXKTPiuA9Fnk/OV30cQIhANuA vjuzMeXPUrFdRQIhAMkfBhg9bCqjFyt8PBPOm/vz8+ZgZlE0/JAXeV7IPCVfAiEA
uMdo+T+rYcNGJ1hCYKDe9JWBpNfSQ+H/A7sWuW8L gZwCFm1ghGxmaoB424YC4DHeDeN/g9xwJHT7EuM9Mvc=
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-CBC,B9D8FB94E38635AB
e7bVyzL1RF6p7hl8GDaOrRTcgB4ip+pWWUcnNf6y2tsuAQx/c/Bd5c9ZDc3L5AXC
oOAzWYB+ay1vWkmAQB4ivFS5QzGDf8870d4FbOejwmgPhiHdZNw5xNwscAN6ps0v
dFaUrR9nzWmbycsQCjXZGIZtGFCtXkA8Gdl5OMO4o+rzM0muNPS5fb++x7oNl1YG
gjReu2sQ85dPfMlnoHhr8Pz9LBcxVyOmcqtmT0SOSuPcoj6aDtcZ+EY9MQf6SR9E
ysmrJKMtp+ABgXglAj5hbT0dMpoJ2KpJYk62JAh/A6DDyv5YYUI0W57xY5+QzaV+
YXnIvqwLjJ3cXEV4YH7ozLHAESgnAAUoQsin42rrRKt7GxjSdBoFhWjH69V2nl65
LYRNjE1O5BBEX+rz0S+fe2ZZgT17kUr7eLZCq15J+L5xWQ7R4ERc0w==
-----END RSA PRIVATE KEY-----
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,BDE979D13CCC0ABD
N7yz2JV13EmQ7MZPL5wamid5+G1V1gp8FKqMemAC5JDxonS/W9oViMLUcxbfPTDx
FznKdYSVTIQ7vv3ofmDG4MEyV/2C568N2kdtAw+jTfrZFN+IU9CI+W+In/nacirF
02sAcvDMofustnooKNOO7/iyb5+3vRvEt5vSSRQn5WuSQ9sUKjuzoLs/lbf7fyAt
4NeqfI3rYBZXxiUOLITOGXzGNRuFoY+o2uDCfelLAJ8uhiVG6ME3LeJEo1dT5lZ8
CSJOLPasKg0iG4V7olM4j9FvAfZr48RRsSfUen756Jo2HpI4bad8LKhFYIdNs2Au
WwKLmjpo6QB9hBmRshR04rEXPdrgTqLBExCE08PyaGYnWU8ggWritCeBzDQFj/n4
sI+NO0Mymuvg98e5RpO52lg3Xnqv9RIK3guLFOmI6aEHC0PS4WwOEQ==
-----END RSA PRIVATE KEY-----
Certificate: Certificate:
Data: Data:
Version: 3 (0x2) Version: 3 (0x2)
Serial Number: 0 (0x0) Serial Number:
ce:df:23:31:64:b4:13:da
Signature Algorithm: dsaWithSHA1 Signature Algorithm: dsaWithSHA1
Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL DSA, CN=yaSSL DSA/emailAddress=info@yassl.com Issuer: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=testing, CN=www.yassl.com/emailAddress=info@yassl.com
Validity Validity
Not Before: Mar 7 03:22:00 2005 GMT Not Before: Jun 30 18:56:38 2010 GMT
Not After : Apr 1 03:22:00 2046 GMT Not After : Mar 26 18:56:39 2013 GMT
Subject: C=US, ST=Oregon, L=Portland, O=yaSSL DSA, CN=yaSSL DSA/emailAddress=info@yassl.com Subject: C=US, ST=Oregon, L=Portland, O=yaSSL, OU=testing, CN=www.yassl.com/emailAddress=info@yassl.com
Subject Public Key Info: Subject Public Key Info:
Public Key Algorithm: dsaEncryption Public Key Algorithm: dsaEncryption
DSA Public Key: DSA Public Key:
...@@ -37,32 +38,33 @@ Certificate: ...@@ -37,32 +38,33 @@ Certificate:
BE:F9:8C:5D:D6:1C:B4:EE:81:DD:36:56:0A:21:E4:61:44:73:E9:E2 BE:F9:8C:5D:D6:1C:B4:EE:81:DD:36:56:0A:21:E4:61:44:73:E9:E2
X509v3 Authority Key Identifier: X509v3 Authority Key Identifier:
keyid:BE:F9:8C:5D:D6:1C:B4:EE:81:DD:36:56:0A:21:E4:61:44:73:E9:E2 keyid:BE:F9:8C:5D:D6:1C:B4:EE:81:DD:36:56:0A:21:E4:61:44:73:E9:E2
DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL DSA/CN=yaSSL DSA/emailAddress=info@yassl.com DirName:/C=US/ST=Oregon/L=Portland/O=yaSSL/OU=testing/CN=www.yassl.com/emailAddress=info@yassl.com
serial:00 serial:CE:DF:23:31:64:B4:13:DA
X509v3 Basic Constraints: X509v3 Basic Constraints:
CA:TRUE CA:TRUE
Signature Algorithm: dsaWithSHA1 Signature Algorithm: dsaWithSHA1
30:2c:02:14:7e:5e:94:fc:7f:ca:81:ab:b3:32:f7:21:83:48: 30:2d:02:14:00:a3:21:20:34:6a:2c:f9:fb:76:d7:20:c9:c0:
48:5f:0a:f1:13:ca:02:14:73:54:32:14:51:22:bf:0b:ec:d7: 35:1b:64:9a:c2:83:02:15:00:a4:59:ac:6d:da:85:48:ff:f5:
6a:6a:fa:a7:1d:46:b4:c2:a3:b5 0d:49:72:c8:cd:91:fc:ec:2f:5c:63
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIDMjCCAvKgAwIBAgIBADAJBgcqhkjOOAQDMHgxCzAJBgNVBAYTAlVTMQ8wDQYD MIIDfjCCAz2gAwIBAgIJAM7fIzFktBPaMAkGByqGSM44BAMwgYoxCzAJBgNVBAYT
VQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRsYW5kMRIwEAYDVQQKEwl5YVNTTCBE AlVTMQ8wDQYDVQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRsYW5kMQ4wDAYDVQQK
U0ExEjAQBgNVBAMTCXlhU1NMIERTQTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNz EwV5YVNTTDEQMA4GA1UECxMHdGVzdGluZzEWMBQGA1UEAxMNd3d3Lnlhc3NsLmNv
bC5jb20wHhcNMDUwMzA3MDMyMjAwWhcNNDYwNDAxMDMyMjAwWjB4MQswCQYDVQQG bTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb20wHhcNMTAwNjMwMTg1NjM4
EwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQHEwhQb3J0bGFuZDESMBAGA1UE WhcNMTMwMzI2MTg1NjM5WjCBijELMAkGA1UEBhMCVVMxDzANBgNVBAgTBk9yZWdv
ChMJeWFTU0wgRFNBMRIwEAYDVQQDEwl5YVNTTCBEU0ExHTAbBgkqhkiG9w0BCQEW bjERMA8GA1UEBxMIUG9ydGxhbmQxDjAMBgNVBAoTBXlhU1NMMRAwDgYDVQQLEwd0
DmluZm9AeWFzc2wuY29tMIHwMIGoBgcqhkjOOAQBMIGcAkEAmSlpgMk8mGhFqYL+ ZXN0aW5nMRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJKoZIhvcNAQkBFg5p
Z+uViMW0DNYmRZUZLKAgW37faencww/zYQolm/IhAWrNqow358pm21b0D3160Ri5 bmZvQHlhc3NsLmNvbTCB8DCBqAYHKoZIzjgEATCBnAJBAJkpaYDJPJhoRamC/mfr
Qv0bEQIVAK0lKasKnwkcwa0DIHZ/prfdTQMJAkASiJna59ALk5vm7jwhf5yztI2l lYjFtAzWJkWVGSygIFt+32np3MMP82EKJZvyIQFqzaqMN+fKZttW9A99etEYuUL9
jOI3gD8X0YFPvfBxtjIIVN2/AeKzdwZkdYoE1nk5sQIDA8YGdOWQBQoQRhkxA0MA GxECFQCtJSmrCp8JHMGtAyB2f6a33U0DCQJAEoiZ2ufQC5Ob5u48IX+cs7SNpYzi
AkAEhKAmMXIM6E9dUxdisYDKwBZfwx7qxdmYOPm+VlNHaM4IIlccuw13kc9bNu3z N4A/F9GBT73wcbYyCFTdvwHis3cGZHWKBNZ5ObECAwPGBnTlkAUKEEYZMQNDAAJA
JIKQis2QfNt3+Rctc3Pvu7mCo4HVMIHSMB0GA1UdDgQWBBS++Yxd1hy07oHdNlYK BISgJjFyDOhPXVMXYrGAysAWX8Me6sXZmDj5vlZTR2jOCCJXHLsNd5HPWzbt8ySC
IeRhRHPp4jCBogYDVR0jBIGaMIGXgBS++Yxd1hy07oHdNlYKIeRhRHPp4qF8pHow kIrNkHzbd/kXLXNz77u5gqOB8jCB7zAdBgNVHQ4EFgQUvvmMXdYctO6B3TZWCiHk
eDELMAkGA1UEBhMCVVMxDzANBgNVBAgTBk9yZWdvbjERMA8GA1UEBxMIUG9ydGxh YURz6eIwgb8GA1UdIwSBtzCBtIAUvvmMXdYctO6B3TZWCiHkYURz6eKhgZCkgY0w
bmQxEjAQBgNVBAoTCXlhU1NMIERTQTESMBAGA1UEAxMJeWFTU0wgRFNBMR0wGwYJ gYoxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRs
KoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbYIBADAMBgNVHRMEBTADAQH/MAkGByqG YW5kMQ4wDAYDVQQKEwV5YVNTTDEQMA4GA1UECxMHdGVzdGluZzEWMBQGA1UEAxMN
SM44BAMDLwAwLAIUfl6U/H/KgauzMvchg0hIXwrxE8oCFHNUMhRRIr8L7Ndqavqn d3d3Lnlhc3NsLmNvbTEdMBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb22CCQDO
HUa0wqO1 3yMxZLQT2jAMBgNVHRMEBTADAQH/MAkGByqGSM44BAMDMAAwLQIUAKMhIDRqLPn7
dtcgycA1G2SawoMCFQCkWaxt2oVI//UNSXLIzZH87C9cYw==
-----END CERTIFICATE----- -----END CERTIFICATE-----
...@@ -3,36 +3,37 @@ Certificate: ...@@ -3,36 +3,37 @@ Certificate:
Version: 1 (0x0) Version: 1 (0x0)
Serial Number: 1 (0x1) Serial Number: 1 (0x1)
Signature Algorithm: md5WithRSAEncryption Signature Algorithm: md5WithRSAEncryption
Issuer: C=US, ST=Oregon, L=Portland, O=sawtooth, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com Issuer: C=US, ST=Montana, L=Bozeman, O=sawtooth, OU=consulting, CN=www.sawtooth-consulting.com/emailAddress=info@yassl.com
Validity Validity
Not Before: Mar 8 03:00:47 2005 GMT Not Before: Jun 30 18:52:17 2010 GMT
Not After : Apr 2 03:00:47 2046 GMT Not After : Mar 26 18:52:17 2013 GMT
Subject: C=US, ST=Oregon, L=Portland, O=taoSoftDev, CN=www.taosoftdev.com/emailAddress=info@yassl.com Subject: C=US, ST=Montana, L=Bozeman, O=yaSSL, OU=support, CN=www.yassl.com/emailAddress=info@yassl.com
Subject Public Key Info: Subject Public Key Info:
Public Key Algorithm: rsaEncryption Public Key Algorithm: rsaEncryption
RSA Public Key: (512 bit) RSA Public Key: (512 bit)
Modulus (512 bit): Modulus (512 bit):
00:a4:68:bb:bc:b7:27:5f:3c:f5:78:c6:1a:af:b9: 00:c6:7b:c0:68:81:2f:de:82:3f:f9:ac:c3:86:4a:
95:fc:7e:61:1f:a8:81:0a:ca:43:88:9a:03:e0:d0: 66:b7:ec:d4:f1:f6:64:21:ff:f5:a2:34:42:d0:38:
a6:79:70:16:34:b9:7c:75:54:ca:70:19:66:38:be: 9f:c6:dd:3b:6e:26:65:6a:54:96:dd:d2:7b:eb:36:
6e:28:7e:a5:ff:6b:3c:83:2f:39:42:c3:15:f3:bd: a2:ae:7e:2a:9e:7e:56:a5:b6:87:9f:15:c7:18:66:
f2:25:93:22:e7 7e:16:77:e2:a7
Exponent: 65537 (0x10001) Exponent: 65537 (0x10001)
Signature Algorithm: md5WithRSAEncryption Signature Algorithm: md5WithRSAEncryption
36:72:12:3b:ac:e4:58:83:09:86:4f:71:2a:3a:0d:8a:05:27: 58:a9:98:e7:16:52:4c:40:e7:e1:47:92:19:1b:3a:8f:97:6c:
75:f3:3e:62:4f:ab:b8:70:20:cd:ad:70:ab:91:11:68:f8:82: 7b:b7:b0:cb:20:6d:ad:b5:d3:47:58:d8:e4:f2:3e:32:e9:ef:
33:e2:78:85:a8:16:f5:66:bd:68:2c:5a:26:15:12:1e:6e:83: 87:77:e5:54:36:f4:8d:50:8d:07:b4:77:45:ea:9d:a4:33:36:
c7:6d:62:b9:c3:ff:e1:86:e4:e6 9b:0b:e0:74:58:11:c5:01:7b:4d
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIB9zCCAaECAQEwDQYJKoZIhvcNAQEEBQAwgYkxCzAJBgNVBAYTAlVTMQ8wDQYD MIICFDCCAb4CAQEwDQYJKoZIhvcNAQEEBQAwgZ4xCzAJBgNVBAYTAlVTMRAwDgYD
VQQIEwZPcmVnb24xETAPBgNVBAcTCFBvcnRsYW5kMREwDwYDVQQKEwhzYXd0b290 VQQIEwdNb250YW5hMRAwDgYDVQQHEwdCb3plbWFuMREwDwYDVQQKEwhzYXd0b290
aDEkMCIGA1UEAxMbd3d3LnNhd3Rvb3RoLWNvbnN1bHRpbmcuY29tMR0wGwYJKoZI aDETMBEGA1UECxMKY29uc3VsdGluZzEkMCIGA1UEAxMbd3d3LnNhd3Rvb3RoLWNv
hvcNAQkBFg5pbmZvQHlhc3NsLmNvbTAeFw0wNTAzMDgwMzAwNDdaFw00NjA0MDIw bnN1bHRpbmcuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbTAeFw0x
MzAwNDdaMIGCMQswCQYDVQQGEwJVUzEPMA0GA1UECBMGT3JlZ29uMREwDwYDVQQH MDA2MzAxODUyMTdaFw0xMzAzMjYxODUyMTdaMIGKMQswCQYDVQQGEwJVUzEQMA4G
EwhQb3J0bGFuZDETMBEGA1UEChMKdGFvU29mdERldjEbMBkGA1UEAxMSd3d3LnRh A1UECBMHTW9udGFuYTEQMA4GA1UEBxMHQm96ZW1hbjEOMAwGA1UEChMFeWFTU0wx
b3NvZnRkZXYuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHlhc3NsLmNvbTBcMA0G EDAOBgNVBAsTB3N1cHBvcnQxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkq
CSqGSIb3DQEBAQUAA0sAMEgCQQCkaLu8tydfPPV4xhqvuZX8fmEfqIEKykOImgPg hkiG9w0BCQEWDmluZm9AeWFzc2wuY29tMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJB
0KZ5cBY0uXx1VMpwGWY4vm4ofqX/azyDLzlCwxXzvfIlkyLnAgMBAAEwDQYJKoZI AMZ7wGiBL96CP/msw4ZKZrfs1PH2ZCH/9aI0QtA4n8bdO24mZWpUlt3Se+s2oq5+
hvcNAQEEBQADQQA2chI7rORYgwmGT3EqOg2KBSd18z5iT6u4cCDNrXCrkRFo+IIz Kp5+VqW2h58VxxhmfhZ34qcCAwEAATANBgkqhkiG9w0BAQQFAANBAFipmOcWUkxA
4niFqBb1Zr1oLFomFRIeboPHbWK5w//hhuTm 5+FHkhkbOo+XbHu3sMsgba2100dY2OTyPjLp74d35VQ29I1QjQe0d0XqnaQzNpsL
4HRYEcUBe00=
-----END CERTIFICATE----- -----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIIBOQIBAAJBAKRou7y3J1889XjGGq+5lfx+YR+ogQrKQ4iaA+DQpnlwFjS5fHVU MIIBOwIBAAJBAMZ7wGiBL96CP/msw4ZKZrfs1PH2ZCH/9aI0QtA4n8bdO24mZWpU
ynAZZji+bih+pf9rPIMvOULDFfO98iWTIucCAwEAAQJABLVvMw931DV1vljGKORC lt3Se+s2oq5+Kp5+VqW2h58VxxhmfhZ34qcCAwEAAQJBAJSbGxgjgV+rTZL2Ev58
1HF2LKbx0zJJzt7CX6z6J54vcE79K3NYXdU6o7/j1WTtfD47tFG+4ljGvSYPmrCI viN/IoB25cm/Bn4Heu7DNn2A2kpdGX2cCaf7rEQoIKCiHxvopvxOcd/7nLS/gNli
2QIhANfiY6is6JUJGGgeMxyWeQRPXfaE9Yrk6OhxHhpYf5CTAiEAwvWraeLPy/NE dCECIQD/cX/9fvB1Uajw0fmvwNON9+3P9uJSqpig90zL32pwjQIhAMbqee9TBMN4
B+0w80mh8tCv2tpuKaYMOG53XpYX3N0CIDy/Bj3rUZLGOWjqvoUXzjupPY5lgVYw TxXbgWqA92PrCXe8WDZ3PwoJqdR6MRUDAiEAny+TDF1z6hiWiGTCDgXDkKBlwgjf
7Vyin87YAiUjAiAgM8X5em5KSMc+6+2+8bWfTtsNMjEqDfRMyepLpE0SvQIgTSYL p5aKgR077XzwLu0CICVpWEGg1ZaF/CnaPP7w/pZ2UDOK4vRrfRnAM4bY7H5NAiBS
WWfcZoRUPDM9GEuQ40nifVNjobzvjTW4aYyHCEI= 1eXJ/MCZ2uPfpl7XK2BU9P69KdKUk5WHxdRchVvcDg==
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-CBC,08132C1FFF5BC8CC
gsvuAsGmB8AkR23M25w4E6wuywfBey1Jqh3g71gJcnsUYwynex9dvfAU0lTowOXh
sb7ld1KNjEMzrht9AC1IC0iE1rLqvRQZOdJ7h3n7aHZQ4a/HjcwAhqJq0ZW45m6Q
mpoO5fRISjx2VbKFRUz6Xj2x0/do3IjQhpuUDVrTFFe1sEySM6APZ6CVpcnTOyPR
ADyLDKzOi2E+sj1UXs58pct56FaqTIZPUEflICU3k6q9FPU6gsYANRLfzegclkv4
JAx6mKVSJuYnjCCppx8WBwGJa1J1GcYRJ3qFfdbUzL4bcXTvoFkJEnDkHsXgDUS6
xmT0XGT3IMaW8cwQ8KD8m5YYI/L26Mas/w3eA2ekyMR8pYICjXp/YZtcKxxkQSVE
Uv/+D+20KbNAHIW5Mrxf61cX/CggGEbVP8ZhDY1flh8=
-----END RSA PRIVATE KEY-----
...@@ -47,4 +47,16 @@ to convert rsa private PEM to DER : ...@@ -47,4 +47,16 @@ to convert rsa private PEM to DER :
b) openssl rsa -in key.pem -outform DER -out key.der b) openssl rsa -in key.pem -outform DER -out key.der
**** To encrypt rsa key already in pem **********
a) openssl rsa <server-key.pem.bak -des >server-keyEnc.pem
note location of des, pass = yassl123
*** To make a public key from a private key ******
openssl rsa -in 1024rsa.priv -pubout -out 1024rsa.pub
...@@ -36,15 +36,20 @@ void ClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg) ...@@ -36,15 +36,20 @@ void ClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)
void NonBlockingSSL_Connect(SSL* ssl, SSL_CTX* ctx, SOCKET_T& sockfd) void NonBlockingSSL_Connect(SSL* ssl, SSL_CTX* ctx, SOCKET_T& sockfd)
{ {
int ret = SSL_connect(ssl); int ret = SSL_connect(ssl);
while (ret =! SSL_SUCCESS && SSL_get_error(ssl, 0) == int err = SSL_get_error(ssl, 0);
SSL_ERROR_WANT_READ) { while (ret != SSL_SUCCESS && (err == SSL_ERROR_WANT_READ ||
printf("... client would block\n"); err == SSL_ERROR_WANT_WRITE)) {
if (err == SSL_ERROR_WANT_READ)
printf("... client would read block\n");
else
printf("... client would write block\n");
#ifdef _WIN32 #ifdef _WIN32
Sleep(1000); Sleep(1000);
#else #else
sleep(1); sleep(1);
#endif #endif
ret = SSL_connect(ssl); ret = SSL_connect(ssl);
err = SSL_get_error(ssl, 0);
} }
if (ret != SSL_SUCCESS) if (ret != SSL_SUCCESS)
ClientError(ctx, ssl, sockfd, "SSL_connect failed"); ClientError(ctx, ssl, sockfd, "SSL_connect failed");
...@@ -81,6 +86,7 @@ void client_test(void* args) ...@@ -81,6 +86,7 @@ void client_test(void* args)
#ifdef NON_BLOCKING #ifdef NON_BLOCKING
NonBlockingSSL_Connect(ssl, ctx, sockfd); NonBlockingSSL_Connect(ssl, ctx, sockfd);
#else #else
// if you get an error here see note at top of README
if (SSL_connect(ssl) != SSL_SUCCESS) if (SSL_connect(ssl) != SSL_SUCCESS)
ClientError(ctx, ssl, sockfd, "SSL_connect failed"); ClientError(ctx, ssl, sockfd, "SSL_connect failed");
#endif #endif
......
...@@ -77,7 +77,7 @@ void echoclient_test(void* args) ...@@ -77,7 +77,7 @@ void echoclient_test(void* args)
while (fgets(send, sizeof(send), fin)) { while (fgets(send, sizeof(send), fin)) {
int sendSz = strlen(send) + 1; int sendSz = (int)strlen(send) + 1;
if (SSL_write(ssl, send, sendSz) != sendSz) if (SSL_write(ssl, send, sendSz) != sendSz)
EchoClientError(ctx, ssl, sockfd, "SSL_write failed"); EchoClientError(ctx, ssl, sockfd, "SSL_write failed");
......
...@@ -93,11 +93,11 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) ...@@ -93,11 +93,11 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
#endif #endif
while (!shutdown) { while (!shutdown) {
sockaddr_in client; SOCKADDR_IN_T client;
socklen_t client_len = sizeof(client); socklen_t client_len = sizeof(client);
SOCKET_T clientfd = accept(sockfd, (sockaddr*)&client, SOCKET_T clientfd = accept(sockfd, (sockaddr*)&client,
(ACCEPT_THIRD_T)&client_len); (ACCEPT_THIRD_T)&client_len);
if (clientfd == -1) { if (clientfd == (SOCKET_T) -1) {
SSL_CTX_free(ctx); SSL_CTX_free(ctx);
tcp_close(sockfd); tcp_close(sockfd);
err_sys("tcp accept failed"); err_sys("tcp accept failed");
......
...@@ -35,15 +35,20 @@ void ServerError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg) ...@@ -35,15 +35,20 @@ void ServerError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)
void NonBlockingSSL_Accept(SSL* ssl, SSL_CTX* ctx, SOCKET_T& clientfd) void NonBlockingSSL_Accept(SSL* ssl, SSL_CTX* ctx, SOCKET_T& clientfd)
{ {
int ret = SSL_accept(ssl); int ret = SSL_accept(ssl);
while (ret != SSL_SUCCESS && SSL_get_error(ssl, 0) == int err = SSL_get_error(ssl, 0);
SSL_ERROR_WANT_READ) { while (ret != SSL_SUCCESS && (err == SSL_ERROR_WANT_READ ||
printf("... server would block\n"); err == SSL_ERROR_WANT_WRITE)) {
if (err == SSL_ERROR_WANT_READ)
printf("... server would read block\n");
else
printf("... server would write block\n");
#ifdef _WIN32 #ifdef _WIN32
Sleep(1000); Sleep(1000);
#else #else
sleep(1); sleep(1);
#endif #endif
ret = SSL_accept(ssl); ret = SSL_accept(ssl);
err = SSL_get_error(ssl, 0);
} }
if (ret != SSL_SUCCESS) if (ret != SSL_SUCCESS)
ServerError(ctx, ssl, clientfd, "SSL_accept failed"); ServerError(ctx, ssl, clientfd, "SSL_accept failed");
......
...@@ -46,12 +46,6 @@ typedef unsigned int uint; ...@@ -46,12 +46,6 @@ typedef unsigned int uint;
const uint AUTO = 0xFEEDBEEF; const uint AUTO = 0xFEEDBEEF;
// Checking Policy should implement a check function that tests whether the
// index is within the size limit of the array
struct Check {
void check(uint i, uint limit);
};
struct NoCheck { struct NoCheck {
void check(uint, uint); void check(uint, uint);
...@@ -66,7 +60,7 @@ struct NoCheck { ...@@ -66,7 +60,7 @@ struct NoCheck {
* write to the buffer bulk wise and have the correct size * write to the buffer bulk wise and have the correct size
*/ */
class input_buffer : public Check { class input_buffer : public NoCheck {
uint size_; // number of elements in buffer uint size_; // number of elements in buffer
uint current_; // current offset position in buffer uint current_; // current offset position in buffer
byte* buffer_; // storage for buffer byte* buffer_; // storage for buffer
...@@ -132,7 +126,7 @@ private: ...@@ -132,7 +126,7 @@ private:
* Not using vector because need checked []access and the ability to * Not using vector because need checked []access and the ability to
* write to the buffer bulk wise and retain correct size * write to the buffer bulk wise and retain correct size
*/ */
class output_buffer : public Check { class output_buffer : public NoCheck {
uint current_; // current offset and elements in buffer uint current_; // current offset and elements in buffer
byte* buffer_; // storage for buffer byte* buffer_; // storage for buffer
byte* end_; // end of storage marker byte* end_; // end of storage marker
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc.
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -34,6 +35,7 @@ ...@@ -34,6 +35,7 @@
#include "yassl_types.hpp" // SignatureAlgorithm #include "yassl_types.hpp" // SignatureAlgorithm
#include "buffer.hpp" // input_buffer #include "buffer.hpp" // input_buffer
#include "asn.hpp" // SignerList #include "asn.hpp" // SignerList
#include "openssl/ssl.h" // internal and external use
#include STL_LIST_FILE #include STL_LIST_FILE
#include STL_ALGORITHM_FILE #include STL_ALGORITHM_FILE
...@@ -87,6 +89,7 @@ class CertManager { ...@@ -87,6 +89,7 @@ class CertManager {
bool verifyNone_; // no error if verify fails bool verifyNone_; // no error if verify fails
bool failNoCert_; bool failNoCert_;
bool sendVerify_; bool sendVerify_;
VerifyCallback verifyCallback_; // user verify callback
public: public:
CertManager(); CertManager();
~CertManager(); ~CertManager();
...@@ -118,6 +121,7 @@ public: ...@@ -118,6 +121,7 @@ public:
void setFailNoCert(); void setFailNoCert();
void setSendVerify(); void setSendVerify();
void setPeerX509(X509*); void setPeerX509(X509*);
void setVerifyCallback(VerifyCallback);
private: private:
CertManager(const CertManager&); // hide copy CertManager(const CertManager&); // hide copy
CertManager& operator=(const CertManager&); // and assign CertManager& operator=(const CertManager&); // and assign
......
/* /*
Copyright (C) 2006, 2007 MySQL AB Copyright (c) 2006, 2007 MySQL AB, 2008 Sun Microsystems, Inc.
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -70,6 +71,7 @@ ...@@ -70,6 +71,7 @@
#define SSL_load_error_strings yaSSL_load_error_strings #define SSL_load_error_strings yaSSL_load_error_strings
#define SSL_set_session yaSSL_set_session #define SSL_set_session yaSSL_set_session
#define SSL_get_session yaSSL_get_session #define SSL_get_session yaSSL_get_session
#define SSL_flush_sessions yaSSL_flush_sessions
#define SSL_SESSION_set_timeout yaSSL_SESSION_set_timeout #define SSL_SESSION_set_timeout yaSSL_SESSION_set_timeout
#define SSL_CTX_set_session_cache_mode yaSSL_CTX_set_session_cache_mode #define SSL_CTX_set_session_cache_mode yaSSL_CTX_set_session_cache_mode
#define SSL_get_peer_certificate yaSSL_get_peer_certificate #define SSL_get_peer_certificate yaSSL_get_peer_certificate
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -34,7 +35,7 @@ ...@@ -34,7 +35,7 @@
#include "rsa.h" #include "rsa.h"
#define YASSL_VERSION "1.7.2" #define YASSL_VERSION "2.2.0"
#if defined(__cplusplus) #if defined(__cplusplus)
...@@ -106,6 +107,15 @@ RSA* RSA_generate_key(int, unsigned long, void(*)(int, int, void*), void*); ...@@ -106,6 +107,15 @@ RSA* RSA_generate_key(int, unsigned long, void(*)(int, int, void*), void*);
/* X509 stuff, different file? */ /* X509 stuff, different file? */
/* because mySQL dereferences to use error and current_cert, even after calling
* get functions for local references */
typedef struct X509_STORE_CTX {
int error;
int error_depth;
X509* current_cert;
} X509_STORE_CTX;
typedef struct X509_STORE X509_STORE; typedef struct X509_STORE X509_STORE;
typedef struct X509_LOOKUP X509_LOOKUP; typedef struct X509_LOOKUP X509_LOOKUP;
typedef struct X509_OBJECT { char c; } X509_OBJECT; typedef struct X509_OBJECT { char c; } X509_OBJECT;
...@@ -124,16 +134,6 @@ typedef struct BIO BIO; ...@@ -124,16 +134,6 @@ typedef struct BIO BIO;
/* because mySQL dereferences to use error and current_cert, even after calling
* get functions for local references */
typedef struct X509_STORE_CTX {
int error;
int error_depth;
X509* current_cert;
} X509_STORE_CTX;
X509* X509_STORE_CTX_get_current_cert(X509_STORE_CTX*); X509* X509_STORE_CTX_get_current_cert(X509_STORE_CTX*);
int X509_STORE_CTX_get_error(X509_STORE_CTX*); int X509_STORE_CTX_get_error(X509_STORE_CTX*);
int X509_STORE_CTX_get_error_depth(X509_STORE_CTX*); int X509_STORE_CTX_get_error_depth(X509_STORE_CTX*);
...@@ -170,8 +170,9 @@ enum { /* X509 Constants */ ...@@ -170,8 +170,9 @@ enum { /* X509 Constants */
X509_V_ERR_CRL_SIGNATURE_FAILURE = 10, X509_V_ERR_CRL_SIGNATURE_FAILURE = 10,
X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 11, X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 11,
X509_V_ERR_CRL_HAS_EXPIRED = 12, X509_V_ERR_CRL_HAS_EXPIRED = 12,
X509_V_ERR_CERT_REVOKED = 13 X509_V_ERR_CERT_REVOKED = 13,
X509_V_FLAG_CRL_CHECK = 14,
X509_V_FLAG_CRL_CHECK_ALL = 15
}; };
...@@ -202,7 +203,8 @@ SSL_CTX* SSL_CTX_new(SSL_METHOD*); ...@@ -202,7 +203,8 @@ SSL_CTX* SSL_CTX_new(SSL_METHOD*);
SSL* SSL_new(SSL_CTX*); SSL* SSL_new(SSL_CTX*);
int SSL_set_fd (SSL*, YASSL_SOCKET_T); int SSL_set_fd (SSL*, YASSL_SOCKET_T);
YASSL_SOCKET_T SSL_get_fd(const SSL*); YASSL_SOCKET_T SSL_get_fd(const SSL*);
int SSL_connect(SSL*); int SSL_connect(SSL*); /* if you get an error from connect
see note at top of README */
int SSL_write(SSL*, const void*, int); int SSL_write(SSL*, const void*, int);
int SSL_read(SSL*, void*, int); int SSL_read(SSL*, void*, int);
int SSL_accept(SSL*); int SSL_accept(SSL*);
...@@ -227,6 +229,7 @@ void SSL_load_error_strings(void); ...@@ -227,6 +229,7 @@ void SSL_load_error_strings(void);
int SSL_set_session(SSL *ssl, SSL_SESSION *session); int SSL_set_session(SSL *ssl, SSL_SESSION *session);
SSL_SESSION* SSL_get_session(SSL* ssl); SSL_SESSION* SSL_get_session(SSL* ssl);
void SSL_flush_sessions(SSL_CTX *ctx, long tm);
long SSL_SESSION_set_timeout(SSL_SESSION*, long); long SSL_SESSION_set_timeout(SSL_SESSION*, long);
long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode); long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode);
X509* SSL_get_peer_certificate(SSL*); X509* SSL_get_peer_certificate(SSL*);
...@@ -347,11 +350,11 @@ enum { /* ssl Constants */ ...@@ -347,11 +350,11 @@ enum { /* ssl Constants */
SSL_ERROR_ZERO_RETURN = 84, SSL_ERROR_ZERO_RETURN = 84,
SSL_ERROR_SSL = 85, SSL_ERROR_SSL = 85,
SSL_SENT_SHUTDOWN = 90, SSL_ST_CONNECT = 90,
SSL_RECEIVED_SHUTDOWN = 91, SSL_ST_ACCEPT = 91,
SSL_CB_LOOP = 92, SSL_CB_LOOP = 92,
SSL_ST_CONNECT = 93, SSL_SENT_SHUTDOWN = 93,
SSL_ST_ACCEPT = 94, SSL_RECEIVED_SHUTDOWN = 94,
SSL_CB_ALERT = 95, SSL_CB_ALERT = 95,
SSL_CB_READ = 96, SSL_CB_READ = 96,
SSL_CB_HANDSHAKE_DONE = 97 SSL_CB_HANDSHAKE_DONE = 97
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#ifndef yaSSL_SOCKET_WRAPPER_HPP #ifndef yaSSL_SOCKET_WRAPPER_HPP
#define yaSSL_SOCKET_WRAPPER_HPP #define yaSSL_SOCKET_WRAPPER_HPP
#include <assert.h>
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
...@@ -73,7 +72,8 @@ public: ...@@ -73,7 +72,8 @@ public:
uint get_ready() const; uint get_ready() const;
socket_t get_fd() const; socket_t get_fd() const;
uint send(const byte* buf, unsigned int len, int flags = 0) const; uint send(const byte* buf, unsigned int len, unsigned int& sent,
int flags = 0);
uint receive(byte* buf, unsigned int len, int flags = 0); uint receive(byte* buf, unsigned int len, int flags = 0);
bool wait(); bool wait();
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005-2007 MySQL AB, 2010 Sun Microsystems, Inc.
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -64,7 +65,7 @@ enum YasslError { ...@@ -64,7 +65,7 @@ enum YasslError {
enum Library { yaSSL_Lib = 0, CryptoLib, SocketLib }; enum Library { yaSSL_Lib = 0, CryptoLib, SocketLib };
enum { MAX_ERROR_SZ = 80 }; enum { MAX_ERROR_SZ = 80 };
void SetErrorString(YasslError, char*); void SetErrorString(unsigned long, char*);
/* remove for now, if go back to exceptions use this wrapper /* remove for now, if go back to exceptions use this wrapper
// Base class for all yaSSL exceptions // Base class for all yaSSL exceptions
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc.
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -667,10 +668,12 @@ struct Parameters { ...@@ -667,10 +668,12 @@ struct Parameters {
Cipher suites_[MAX_SUITE_SZ]; Cipher suites_[MAX_SUITE_SZ];
char cipher_name_[MAX_SUITE_NAME]; char cipher_name_[MAX_SUITE_NAME];
char cipher_list_[MAX_CIPHERS][MAX_SUITE_NAME]; char cipher_list_[MAX_CIPHERS][MAX_SUITE_NAME];
bool removeDH_; // for server's later use
Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion, bool haveDH); Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion, bool haveDH);
void SetSuites(ProtocolVersion pv, bool removeDH = false); void SetSuites(ProtocolVersion pv, bool removeDH = false,
bool removeRSA = false, bool removeDSA = false);
void SetCipherNames(); void SetCipherNames();
private: private:
Parameters(const Parameters&); // hide copy Parameters(const Parameters&); // hide copy
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -34,9 +34,8 @@ ...@@ -34,9 +34,8 @@
#include "openssl/ssl.h" // ASN1_STRING and DH #include "openssl/ssl.h" // ASN1_STRING and DH
// Check if _POSIX_THREADS should be forced // Check if _POSIX_THREADS should be forced
#if !defined(_POSIX_THREADS) && (defined(__NETWARE__) || defined(__hpux)) #if !defined(_POSIX_THREADS) && defined(__hpux)
// HPUX does not define _POSIX_THREADS as it's not _fully_ implemented // HPUX does not define _POSIX_THREADS as it's not _fully_ implemented
// Netware supports pthreads but does not announce it
#define _POSIX_THREADS #define _POSIX_THREADS
#endif #endif
...@@ -268,12 +267,14 @@ class Sessions { ...@@ -268,12 +267,14 @@ class Sessions {
STL::list<SSL_SESSION*> list_; STL::list<SSL_SESSION*> list_;
RandomPool random_; // for session cleaning RandomPool random_; // for session cleaning
Mutex mutex_; // no-op for single threaded Mutex mutex_; // no-op for single threaded
int count_; // flush counter
Sessions() {} // only GetSessions can create Sessions() : count_(0) {} // only GetSessions can create
public: public:
SSL_SESSION* lookup(const opaque*, SSL_SESSION* copy = 0); SSL_SESSION* lookup(const opaque*, SSL_SESSION* copy = 0);
void add(const SSL&); void add(const SSL&);
void remove(const opaque*); void remove(const opaque*);
void Flush();
~Sessions(); ~Sessions();
...@@ -425,8 +426,10 @@ private: ...@@ -425,8 +426,10 @@ private:
pem_password_cb passwordCb_; pem_password_cb passwordCb_;
void* userData_; void* userData_;
bool sessionCacheOff_; bool sessionCacheOff_;
bool sessionCacheFlushOff_;
Stats stats_; Stats stats_;
Mutex mutex_; // for Stats Mutex mutex_; // for Stats
VerifyCallback verifyCallback_;
public: public:
explicit SSL_CTX(SSL_METHOD* meth); explicit SSL_CTX(SSL_METHOD* meth);
~SSL_CTX(); ~SSL_CTX();
...@@ -437,18 +440,22 @@ public: ...@@ -437,18 +440,22 @@ public:
const Ciphers& GetCiphers() const; const Ciphers& GetCiphers() const;
const DH_Parms& GetDH_Parms() const; const DH_Parms& GetDH_Parms() const;
const Stats& GetStats() const; const Stats& GetStats() const;
const VerifyCallback getVerifyCallback() const;
pem_password_cb GetPasswordCb() const; pem_password_cb GetPasswordCb() const;
void* GetUserData() const; void* GetUserData() const;
bool GetSessionCacheOff() const; bool GetSessionCacheOff() const;
bool GetSessionCacheFlushOff() const;
void setVerifyPeer(); void setVerifyPeer();
void setVerifyNone(); void setVerifyNone();
void setFailNoCert(); void setFailNoCert();
void setVerifyCallback(VerifyCallback);
bool SetCipherList(const char*); bool SetCipherList(const char*);
bool SetDH(const DH&); bool SetDH(const DH&);
void SetPasswordCb(pem_password_cb cb); void SetPasswordCb(pem_password_cb cb);
void SetUserData(void*); void SetUserData(void*);
void SetSessionCacheOff(); void SetSessionCacheOff();
void SetSessionCacheFlushOff();
void IncrementStats(StatsField); void IncrementStats(StatsField);
void AddCA(x509* ca); void AddCA(x509* ca);
...@@ -525,10 +532,13 @@ class Buffers { ...@@ -525,10 +532,13 @@ class Buffers {
public: public:
typedef STL::list<input_buffer*> inputList; typedef STL::list<input_buffer*> inputList;
typedef STL::list<output_buffer*> outputList; typedef STL::list<output_buffer*> outputList;
int prevSent; // previous plain text bytes sent when got WANT_WRITE
int plainSz; // plain text bytes in buffer to send when got WANT_WRITE
private: private:
inputList dataList_; // list of users app data / handshake inputList dataList_; // list of users app data / handshake
outputList handShakeList_; // buffered handshake msgs outputList handShakeList_; // buffered handshake msgs
input_buffer* rawInput_; // buffered raw input yet to process input_buffer* rawInput_; // buffered raw input yet to process
output_buffer* output_; // WANT_WRITE buffered output
public: public:
Buffers(); Buffers();
~Buffers(); ~Buffers();
...@@ -541,6 +551,8 @@ public: ...@@ -541,6 +551,8 @@ public:
void SetRawInput(input_buffer*); // takes ownership void SetRawInput(input_buffer*); // takes ownership
input_buffer* TakeRawInput(); // takes ownership input_buffer* TakeRawInput(); // takes ownership
void SetOutput(output_buffer*); // takes ownership
output_buffer* TakeOutput(); // takes ownership
private: private:
Buffers(const Buffers&); // hide copy Buffers(const Buffers&); // hide copy
Buffers& operator=(const Buffers&); // and assign Buffers& operator=(const Buffers&); // and assign
...@@ -645,6 +657,7 @@ public: ...@@ -645,6 +657,7 @@ public:
void deriveKeys(); void deriveKeys();
void deriveTLSKeys(); void deriveTLSKeys();
void Send(const byte*, uint); void Send(const byte*, uint);
void SendWriteBuffered();
uint bufferedData(); uint bufferedData();
uint get_SEQIncrement(bool); uint get_SEQIncrement(bool);
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc.
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -25,10 +26,23 @@ ...@@ -25,10 +26,23 @@
#define yaSSL_TYPES_HPP #define yaSSL_TYPES_HPP
#include <stddef.h> #include <stddef.h>
#include <assert.h>
#include "type_traits.hpp" #include "type_traits.hpp"
#ifdef _MSC_VER
// disable conversion warning
// 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
#pragma warning(disable:4244 4996)
#endif
#ifdef _MSC_VER
// disable conversion warning
// 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
#pragma warning(disable:4244 4996)
#endif
namespace yaSSL { namespace yaSSL {
#define YASSL_LIB #define YASSL_LIB
...@@ -74,10 +88,10 @@ namespace yaSSL { ...@@ -74,10 +88,10 @@ namespace yaSSL {
#define NEW_YS new (yaSSL::ys) #define NEW_YS new (yaSSL::ys)
// to resolve compiler generated operator delete on base classes with // to resolve compiler generated operator delete on base classes with
// virtual destructors (when on stack), make sure doesn't get called // virtual destructors (when on stack)
class virtual_base { class virtual_base {
public: public:
static void operator delete(void*) { assert(0); } static void operator delete(void*) { }
}; };
...@@ -163,7 +177,7 @@ const int RMD_LEN = 20; // RIPEMD-160 digest length ...@@ -163,7 +177,7 @@ const int RMD_LEN = 20; // RIPEMD-160 digest length
const int PREFIX = 3; // up to 3 prefix letters for secret rounds const int PREFIX = 3; // up to 3 prefix letters for secret rounds
const int KEY_PREFIX = 7; // up to 7 prefix letters for key rounds const int KEY_PREFIX = 7; // up to 7 prefix letters for key rounds
const int FORTEZZA_MAX = 128; // Maximum Fortezza Key length const int FORTEZZA_MAX = 128; // Maximum Fortezza Key length
const int MAX_SUITE_SZ = 64; // 32 max suites * sizeof(suite) const int MAX_SUITE_SZ = 128; // 64 max suites * sizeof(suite)
const int MAX_SUITE_NAME = 48; // max length of suite name const int MAX_SUITE_NAME = 48; // max length of suite name
const int MAX_CIPHERS = 32; // max supported ciphers for cipher list const int MAX_CIPHERS = 32; // max supported ciphers for cipher list
const int SIZEOF_ENUM = 1; // SSL considers an enum 1 byte, not 4 const int SIZEOF_ENUM = 1; // SSL considers an enum 1 byte, not 4
...@@ -205,6 +219,7 @@ const int SEED_LEN = RAN_LEN * 2; // TLS seed, client + server random ...@@ -205,6 +219,7 @@ const int SEED_LEN = RAN_LEN * 2; // TLS seed, client + server random
const int DEFAULT_TIMEOUT = 500; // Default Session timeout in seconds const int DEFAULT_TIMEOUT = 500; // Default Session timeout in seconds
const int MAX_RECORD_SIZE = 16384; // 2^14, max size by standard const int MAX_RECORD_SIZE = 16384; // 2^14, max size by standard
const int COMPRESS_EXTRA = 1024; // extra compression possible addition const int COMPRESS_EXTRA = 1024; // extra compression possible addition
const int SESSION_FLUSH_COUNT = 256; // when to flush session cache
typedef uint8 Cipher; // first byte is always 0x00 for SSLv3 & TLS typedef uint8 Cipher; // first byte is always 0x00 for SSLv3 & TLS
......
...@@ -32,14 +32,6 @@ namespace yaSSL { ...@@ -32,14 +32,6 @@ namespace yaSSL {
// Checking Policy should implement a check function that tests whether the
// index is within the size limit of the array
void Check::check(uint i, uint limit)
{
assert(i < limit);
}
void NoCheck::check(uint, uint) void NoCheck::check(uint, uint)
{ {
...@@ -83,7 +75,6 @@ input_buffer::~input_buffer() ...@@ -83,7 +75,6 @@ input_buffer::~input_buffer()
// users can pass defualt zero length buffer and then allocate // users can pass defualt zero length buffer and then allocate
void input_buffer::allocate(uint s) void input_buffer::allocate(uint s)
{ {
assert(!buffer_); // find realloc error
buffer_ = NEW_YS byte[s]; buffer_ = NEW_YS byte[s];
end_ = buffer_ + s; end_ = buffer_ + s;
} }
...@@ -141,7 +132,6 @@ void input_buffer::set_current(uint i) ...@@ -141,7 +132,6 @@ void input_buffer::set_current(uint i)
// user passes in AUTO index for ease of use // user passes in AUTO index for ease of use
const byte& input_buffer::operator[](uint i) const byte& input_buffer::operator[](uint i)
{ {
assert (i == AUTO);
check(current_, size_); check(current_, size_);
return buffer_[current_++]; return buffer_[current_++];
} }
...@@ -238,7 +228,6 @@ void output_buffer::set_current(uint c) ...@@ -238,7 +228,6 @@ void output_buffer::set_current(uint c)
// users can pass defualt zero length buffer and then allocate // users can pass defualt zero length buffer and then allocate
void output_buffer::allocate(uint s) void output_buffer::allocate(uint s)
{ {
assert(!buffer_); // find realloc error
buffer_ = NEW_YS byte[s]; end_ = buffer_ + s; buffer_ = NEW_YS byte[s]; end_ = buffer_ + s;
} }
...@@ -254,7 +243,6 @@ const byte* output_buffer::get_buffer() const ...@@ -254,7 +243,6 @@ const byte* output_buffer::get_buffer() const
// user passes in AUTO as index for ease of use // user passes in AUTO as index for ease of use
byte& output_buffer::operator[](uint i) byte& output_buffer::operator[](uint i)
{ {
assert(i == AUTO);
check(current_, get_capacity()); check(current_, get_capacity());
return buffer_[current_++]; return buffer_[current_++];
} }
......
/* /*
Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. Copyright (c) 2005-2007 MySQL AB, 2008, 2009 Sun Microsystems, Inc.
Use is subject to license terms. Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "runtime.hpp" #include "runtime.hpp"
#include "cert_wrapper.hpp" #include "cert_wrapper.hpp"
#include "yassl_int.hpp" #include "yassl_int.hpp"
#include "error.hpp"
#if defined(USE_CML_LIB) #if defined(USE_CML_LIB)
#include "cmapi_cpp.h" #include "cmapi_cpp.h"
...@@ -91,7 +92,7 @@ opaque* x509::use_buffer() ...@@ -91,7 +92,7 @@ opaque* x509::use_buffer()
//CertManager //CertManager
CertManager::CertManager() CertManager::CertManager()
: peerX509_(0), verifyPeer_(false), verifyNone_(false), failNoCert_(false), : peerX509_(0), verifyPeer_(false), verifyNone_(false), failNoCert_(false),
sendVerify_(false) sendVerify_(false), verifyCallback_(0)
{} {}
...@@ -155,6 +156,12 @@ void CertManager::setSendVerify() ...@@ -155,6 +156,12 @@ void CertManager::setSendVerify()
} }
void CertManager::setVerifyCallback(VerifyCallback vc)
{
verifyCallback_ = vc;
}
void CertManager::AddPeerCert(x509* x) void CertManager::AddPeerCert(x509* x)
{ {
peerList_.push_back(x); // take ownership peerList_.push_back(x); // take ownership
...@@ -237,13 +244,14 @@ uint CertManager::get_privateKeyLength() const ...@@ -237,13 +244,14 @@ uint CertManager::get_privateKeyLength() const
int CertManager::Validate() int CertManager::Validate()
{ {
CertList::reverse_iterator last = peerList_.rbegin(); CertList::reverse_iterator last = peerList_.rbegin();
size_t count= peerList_.size(); size_t count = peerList_.size();
while ( count > 1 ) { while ( count > 1 ) {
TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length()); TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());
TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_); TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
if (int err = cert.GetError().What()) int err = cert.GetError().What();
if ( err )
return err; return err;
const TaoCrypt::PublicKey& key = cert.GetPublicKey(); const TaoCrypt::PublicKey& key = cert.GetPublicKey();
...@@ -258,7 +266,8 @@ int CertManager::Validate() ...@@ -258,7 +266,8 @@ int CertManager::Validate()
TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length()); TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());
TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_); TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
if (int err = cert.GetError().What()) int err = cert.GetError().What();
if ( err && err != TaoCrypt::SIG_OTHER_E)
return err; return err;
uint sz = cert.GetPublicKey().size(); uint sz = cert.GetPublicKey().size();
...@@ -270,13 +279,25 @@ int CertManager::Validate() ...@@ -270,13 +279,25 @@ int CertManager::Validate()
else else
peerKeyType_ = dsa_sa_algo; peerKeyType_ = dsa_sa_algo;
size_t iSz= strlen(cert.GetIssuer()) + 1; size_t iSz = strlen(cert.GetIssuer()) + 1;
size_t sSz= strlen(cert.GetCommonName()) + 1; size_t sSz = strlen(cert.GetCommonName()) + 1;
size_t bSz= strlen(cert.GetBeforeDate()) + 1; int bSz = (int)strlen(cert.GetBeforeDate()) + 1;
size_t aSz= strlen(cert.GetAfterDate()) + 1; int aSz = (int)strlen(cert.GetAfterDate()) + 1;
peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(), peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(),
sSz, cert.GetBeforeDate(), (int) bSz, sSz, cert.GetBeforeDate(), bSz,
cert.GetAfterDate(), (int) aSz); cert.GetAfterDate(), aSz);
if (err == TaoCrypt::SIG_OTHER_E && verifyCallback_) {
X509_STORE_CTX store;
store.error = err;
store.error_depth = static_cast<int>(count) - 1;
store.current_cert = peerX509_;
int ok = verifyCallback_(0, &store);
if (ok) return 0;
}
if (err == TaoCrypt::SIG_OTHER_E) return err;
} }
return 0; return 0;
} }
...@@ -307,7 +328,6 @@ int CertManager::SetPrivateKey(const x509& key) ...@@ -307,7 +328,6 @@ int CertManager::SetPrivateKey(const x509& key)
// Store OpenSSL type peer's cert // Store OpenSSL type peer's cert
void CertManager::setPeerX509(X509* x) void CertManager::setPeerX509(X509* x)
{ {
assert(peerX509_ == 0);
if (x == 0) return; if (x == 0) return;
X509_NAME* issuer = x->GetIssuer(); X509_NAME* issuer = x->GetIssuer();
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -953,7 +953,8 @@ x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info) ...@@ -953,7 +953,8 @@ x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info)
info->set = true; info->set = true;
} }
} }
fgets(line,sizeof(line), file); // get blank line // get blank line
if (fgets(line, sizeof(line), file))
begin = ftell(file); begin = ftell(file);
} }
......
...@@ -528,6 +528,7 @@ void ProcessOldClientHello(input_buffer& input, SSL& ssl) ...@@ -528,6 +528,7 @@ void ProcessOldClientHello(input_buffer& input, SSL& ssl)
input.read(len, sizeof(len)); input.read(len, sizeof(len));
uint16 randomLen; uint16 randomLen;
ato16(len, randomLen); ato16(len, randomLen);
if (ch.suite_len_ > MAX_SUITE_SZ || sessionLen > ID_LEN || if (ch.suite_len_ > MAX_SUITE_SZ || sessionLen > ID_LEN ||
randomLen > RAN_LEN) { randomLen > RAN_LEN) {
ssl.SetError(bad_input); ssl.SetError(bad_input);
...@@ -790,8 +791,7 @@ void processReply(SSL& ssl) ...@@ -790,8 +791,7 @@ void processReply(SSL& ssl)
{ {
if (ssl.GetError()) return; if (ssl.GetError()) return;
if (DoProcessReply(ssl)) if (DoProcessReply(ssl)) {
{
// didn't complete process // didn't complete process
if (!ssl.getSocket().IsNonBlocking()) { if (!ssl.getSocket().IsNonBlocking()) {
// keep trying now, blocking ok // keep trying now, blocking ok
...@@ -857,6 +857,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer) ...@@ -857,6 +857,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer)
if (ssl.GetError()) return; if (ssl.GetError()) return;
ServerKeyExchange sk(ssl); ServerKeyExchange sk(ssl);
sk.build(ssl); sk.build(ssl);
if (ssl.GetError()) return;
RecordLayerHeader rlHeader; RecordLayerHeader rlHeader;
HandShakeHeader hsHeader; HandShakeHeader hsHeader;
...@@ -875,8 +876,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer) ...@@ -875,8 +876,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer)
// send change cipher // send change cipher
void sendChangeCipher(SSL& ssl, BufferOutput buffer) void sendChangeCipher(SSL& ssl, BufferOutput buffer)
{ {
if (ssl.getSecurity().get_parms().entity_ == server_end) if (ssl.getSecurity().get_parms().entity_ == server_end) {
{
if (ssl.getSecurity().get_resuming()) if (ssl.getSecurity().get_resuming())
ssl.verifyState(clientKeyExchangeComplete); ssl.verifyState(clientKeyExchangeComplete);
else else
...@@ -929,12 +929,22 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer) ...@@ -929,12 +929,22 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer)
// send data // send data
int sendData(SSL& ssl, const void* buffer, int sz) int sendData(SSL& ssl, const void* buffer, int sz)
{ {
int sent = 0;
if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ)) if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))
ssl.SetError(no_error); ssl.SetError(no_error);
if (ssl.GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
ssl.SetError(no_error);
ssl.SendWriteBuffered();
if (!ssl.GetError()) {
// advance sent to prvevious sent + plain size just sent
sent = ssl.useBuffers().prevSent + ssl.useBuffers().plainSz;
}
}
ssl.verfiyHandShakeComplete(); ssl.verfiyHandShakeComplete();
if (ssl.GetError()) return -1; if (ssl.GetError()) return -1;
int sent = 0;
for (;;) { for (;;) {
int len = min(sz - sent, MAX_RECORD_SIZE); int len = min(sz - sent, MAX_RECORD_SIZE);
...@@ -943,6 +953,8 @@ int sendData(SSL& ssl, const void* buffer, int sz) ...@@ -943,6 +953,8 @@ int sendData(SSL& ssl, const void* buffer, int sz)
Data data; Data data;
if (sent == sz) break;
if (ssl.CompressionOn()) { if (ssl.CompressionOn()) {
if (Compress(static_cast<const opaque*>(buffer) + sent, len, if (Compress(static_cast<const opaque*>(buffer) + sent, len,
tmp) == -1) { tmp) == -1) {
...@@ -957,9 +969,14 @@ int sendData(SSL& ssl, const void* buffer, int sz) ...@@ -957,9 +969,14 @@ int sendData(SSL& ssl, const void* buffer, int sz)
buildMessage(ssl, out, data); buildMessage(ssl, out, data);
ssl.Send(out.get_buffer(), out.get_size()); ssl.Send(out.get_buffer(), out.get_size());
if (ssl.GetError()) return -1; if (ssl.GetError()) {
if (ssl.GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
ssl.useBuffers().plainSz = len;
ssl.useBuffers().prevSent = sent;
}
return -1;
}
sent += len; sent += len;
if (sent == sz) break;
} }
ssl.useLog().ShowData(sent, true); ssl.useLog().ShowData(sent, true);
return sent; return sent;
......
File mode changed from 100644 to 100755
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <fcntl.h> #include <fcntl.h>
#endif // _WIN32 #endif // _WIN32
#if defined(__sun) || defined(__SCO_VERSION__) || defined(__NETWARE__) #if defined(__sun) || defined(__SCO_VERSION__)
#include <sys/filio.h> #include <sys/filio.h>
#endif #endif
...@@ -109,19 +109,28 @@ uint Socket::get_ready() const ...@@ -109,19 +109,28 @@ uint Socket::get_ready() const
} }
uint Socket::send(const byte* buf, unsigned int sz, int flags) const uint Socket::send(const byte* buf, unsigned int sz, unsigned int& written,
int flags)
{ {
const byte* pos = buf; const byte* pos = buf;
const byte* end = pos + sz; const byte* end = pos + sz;
wouldBlock_ = false;
while (pos != end) { while (pos != end) {
int sent = ::send(socket_, reinterpret_cast<const char *>(pos), int sent = ::send(socket_, reinterpret_cast<const char *>(pos),
static_cast<int>(end - pos), flags); static_cast<int>(end - pos), flags);
if (sent == -1) {
if (sent == -1) if (get_lastError() == SOCKET_EWOULDBLOCK ||
get_lastError() == SOCKET_EAGAIN) {
wouldBlock_ = true; // would have blocked this time only
nonBlocking_ = true; // nonblocking, win32 only way to tell
return 0; return 0;
}
return static_cast<uint>(-1);
}
pos += sent; pos += sent;
written += sent;
} }
return sz; return sz;
......
/* /*
Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. Copyright (c) 2005-2007 MySQL AB, 2008-2010 Sun Microsystems, Inc.
Use is subject to license terms. Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
...@@ -246,11 +246,21 @@ YASSL_SOCKET_T SSL_get_fd(const SSL* ssl) ...@@ -246,11 +246,21 @@ YASSL_SOCKET_T SSL_get_fd(const SSL* ssl)
} }
// if you get an error from connect see note at top of README
int SSL_connect(SSL* ssl) int SSL_connect(SSL* ssl)
{ {
if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ)) if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))
ssl->SetError(no_error); ssl->SetError(no_error);
if (ssl->GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
ssl->SetError(no_error);
ssl->SendWriteBuffered();
if (!ssl->GetError())
ssl->useStates().UseConnect() =
ConnectState(ssl->getStates().GetConnect() + 1);
}
ClientState neededState; ClientState neededState;
switch (ssl->getStates().GetConnect()) { switch (ssl->getStates().GetConnect()) {
...@@ -266,6 +276,10 @@ int SSL_connect(SSL* ssl) ...@@ -266,6 +276,10 @@ int SSL_connect(SSL* ssl)
while (ssl->getStates().getClient() < neededState) { while (ssl->getStates().getClient() < neededState) {
if (ssl->GetError()) break; if (ssl->GetError()) break;
processReply(*ssl); processReply(*ssl);
// if resumption failed, reset needed state
if (neededState == serverFinishedComplete)
if (!ssl->getSecurity().get_resuming())
neededState = serverHelloDoneComplete;
} }
if (!ssl->GetError()) if (!ssl->GetError())
ssl->useStates().UseConnect() = FIRST_REPLY_DONE; ssl->useStates().UseConnect() = FIRST_REPLY_DONE;
...@@ -330,6 +344,15 @@ int SSL_accept(SSL* ssl) ...@@ -330,6 +344,15 @@ int SSL_accept(SSL* ssl)
if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ)) if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))
ssl->SetError(no_error); ssl->SetError(no_error);
if (ssl->GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
ssl->SetError(no_error);
ssl->SendWriteBuffered();
if (!ssl->GetError())
ssl->useStates().UseAccept() =
AcceptState(ssl->getStates().GetAccept() + 1);
}
switch (ssl->getStates().GetAccept()) { switch (ssl->getStates().GetAccept()) {
case ACCEPT_BEGIN : case ACCEPT_BEGIN :
...@@ -448,6 +471,9 @@ long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode) ...@@ -448,6 +471,9 @@ long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode)
if (mode == SSL_SESS_CACHE_OFF) if (mode == SSL_SESS_CACHE_OFF)
ctx->SetSessionCacheOff(); ctx->SetSessionCacheOff();
if (mode == SSL_SESS_CACHE_NO_AUTO_CLEAR)
ctx->SetSessionCacheFlushOff();
return SSL_SUCCESS; return SSL_SUCCESS;
} }
...@@ -494,6 +520,15 @@ long SSL_get_default_timeout(SSL* /*ssl*/) ...@@ -494,6 +520,15 @@ long SSL_get_default_timeout(SSL* /*ssl*/)
} }
void SSL_flush_sessions(SSL_CTX *ctx, long /* tm */)
{
if (ctx->GetSessionCacheOff())
return;
GetSessions().Flush();
}
const char* SSL_get_cipher_name(SSL* ssl) const char* SSL_get_cipher_name(SSL* ssl)
{ {
return SSL_get_cipher(ssl); return SSL_get_cipher(ssl);
...@@ -561,7 +596,7 @@ int SSL_get_error(SSL* ssl, int /*previous*/) ...@@ -561,7 +596,7 @@ int SSL_get_error(SSL* ssl, int /*previous*/)
only need to turn on for client, becuase server on by default if built in only need to turn on for client, becuase server on by default if built in
but calling for server will tell you whether it's available or not but calling for server will tell you whether it's available or not
*/ */
int SSL_set_compression(SSL* ssl) int SSL_set_compression(SSL* ssl) /* Chad didn't rename to ya~ because it is prob. bug. */
{ {
return ssl->SetCompression(); return ssl->SetCompression();
} }
...@@ -605,13 +640,13 @@ char* X509_NAME_oneline(X509_NAME* name, char* buffer, int sz) ...@@ -605,13 +640,13 @@ char* X509_NAME_oneline(X509_NAME* name, char* buffer, int sz)
{ {
if (!name->GetName()) return buffer; if (!name->GetName()) return buffer;
size_t len= strlen(name->GetName()) + 1; int len = (int)strlen(name->GetName()) + 1;
int copySz = min((int) len, sz); int copySz = min(len, sz);
if (!buffer) { if (!buffer) {
buffer = (char*)malloc(len); buffer = (char*)malloc(len);
if (!buffer) return buffer; if (!buffer) return buffer;
copySz = (int) len; copySz = len;
} }
if (copySz == 0) if (copySz == 0)
...@@ -694,7 +729,7 @@ int SSL_CTX_use_PrivateKey_file(SSL_CTX* ctx, const char* file, int format) ...@@ -694,7 +729,7 @@ int SSL_CTX_use_PrivateKey_file(SSL_CTX* ctx, const char* file, int format)
} }
void SSL_CTX_set_verify(SSL_CTX* ctx, int mode, VerifyCallback /*vc*/) void SSL_CTX_set_verify(SSL_CTX* ctx, int mode, VerifyCallback vc)
{ {
if (mode & SSL_VERIFY_PEER) if (mode & SSL_VERIFY_PEER)
ctx->setVerifyPeer(); ctx->setVerifyPeer();
...@@ -704,6 +739,8 @@ void SSL_CTX_set_verify(SSL_CTX* ctx, int mode, VerifyCallback /*vc*/) ...@@ -704,6 +739,8 @@ void SSL_CTX_set_verify(SSL_CTX* ctx, int mode, VerifyCallback /*vc*/)
if (mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) if (mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
ctx->setFailNoCert(); ctx->setFailNoCert();
ctx->setVerifyCallback(vc);
} }
...@@ -977,7 +1014,7 @@ char* ERR_error_string(unsigned long errNumber, char* buffer) ...@@ -977,7 +1014,7 @@ char* ERR_error_string(unsigned long errNumber, char* buffer)
static char* msg = (char*)"Please supply a buffer for error string"; static char* msg = (char*)"Please supply a buffer for error string";
if (buffer) { if (buffer) {
SetErrorString(YasslError(errNumber), buffer); SetErrorString(errNumber, buffer);
return buffer; return buffer;
} }
...@@ -1082,7 +1119,6 @@ int EVP_BytesToKey(const EVP_CIPHER* type, const EVP_MD* md, const byte* salt, ...@@ -1082,7 +1119,6 @@ int EVP_BytesToKey(const EVP_CIPHER* type, const EVP_MD* md, const byte* salt,
ivLeft -= store; ivLeft -= store;
} }
} }
assert(keyOutput == (keyLen + ivLen));
return keyOutput; return keyOutput;
} }
...@@ -1451,6 +1487,8 @@ unsigned long err_helper(bool peek = false) ...@@ -1451,6 +1487,8 @@ unsigned long err_helper(bool peek = false)
default : default :
return 0; return 0;
} }
return 0; // shut up compiler
} }
......
...@@ -69,13 +69,13 @@ void SetUpBase(Base& base, ConnectionEnd end, SOCKET_T s) ...@@ -69,13 +69,13 @@ void SetUpBase(Base& base, ConnectionEnd end, SOCKET_T s)
if (base.ca_) if (base.ca_)
if (SSL_CTX_load_verify_locations(base.ctx_, if (SSL_CTX_load_verify_locations(base.ctx_,
base.ca_, 0) != SSL_SUCCESS) assert(0); base.ca_, 0) != SSL_SUCCESS) throw(0);
if (base.cert_) if (base.cert_)
if (SSL_CTX_use_certificate_file(base.ctx_, if (SSL_CTX_use_certificate_file(base.ctx_,
base.cert_, SSL_FILETYPE_PEM) != SSL_SUCCESS) assert(0); base.cert_, SSL_FILETYPE_PEM) != SSL_SUCCESS) throw(0);
if (base.key_) if (base.key_)
if (SSL_CTX_use_PrivateKey_file(base.ctx_, base.key_, if (SSL_CTX_use_PrivateKey_file(base.ctx_, base.key_,
SSL_FILETYPE_PEM) != SSL_SUCCESS) assert(0); SSL_FILETYPE_PEM) != SSL_SUCCESS) throw(0);
if (end == server_end) SetDH(base); if (end == server_end) SetDH(base);
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -26,6 +26,16 @@ ...@@ -26,6 +26,16 @@
#include "openssl/ssl.h" // SSL_ERROR_WANT_READ #include "openssl/ssl.h" // SSL_ERROR_WANT_READ
#include <string.h> // strncpy #include <string.h> // strncpy
#ifdef _MSC_VER
// 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
#pragma warning(disable: 4996)
#endif
#ifdef _MSC_VER
// 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
#pragma warning(disable: 4996)
#endif
namespace yaSSL { namespace yaSSL {
...@@ -50,12 +60,13 @@ Library Error::get_lib() const ...@@ -50,12 +60,13 @@ Library Error::get_lib() const
*/ */
void SetErrorString(YasslError error, char* buffer) void SetErrorString(unsigned long error, char* buffer)
{ {
using namespace TaoCrypt; using namespace TaoCrypt;
const int max = MAX_ERROR_SZ; // shorthand const int max = MAX_ERROR_SZ; // shorthand
int localError = error; // errors from a few enums
switch (error) { switch (localError) {
// yaSSL proper errors // yaSSL proper errors
case range_error : case range_error :
...@@ -123,7 +134,7 @@ void SetErrorString(YasslError error, char* buffer) ...@@ -123,7 +134,7 @@ void SetErrorString(YasslError error, char* buffer)
break; break;
case badVersion_error : case badVersion_error :
strncpy(buffer, "protocl version mismatch", max); strncpy(buffer, "protocol version mismatch", max);
break; break;
case compress_error : case compress_error :
...@@ -143,6 +154,10 @@ void SetErrorString(YasslError error, char* buffer) ...@@ -143,6 +154,10 @@ void SetErrorString(YasslError error, char* buffer)
strncpy(buffer, "the read operation would block", max); strncpy(buffer, "the read operation would block", max);
break; break;
case SSL_ERROR_WANT_WRITE :
strncpy(buffer, "the write operation would block", max);
break;
case CERTFICATE_ERROR : case CERTFICATE_ERROR :
strncpy(buffer, "Unable to verify certificate", max); strncpy(buffer, "Unable to verify certificate", max);
break; break;
......
This diff is collapsed.
/* /*
Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -309,6 +308,21 @@ SSL::SSL(SSL_CTX* ctx) ...@@ -309,6 +308,21 @@ SSL::SSL(SSL_CTX* ctx)
SetError(YasslError(err)); SetError(YasslError(err));
return; return;
} }
else if (serverSide && ctx->GetCiphers().setSuites_ == 0) {
// remove RSA or DSA suites depending on cert key type
// but don't override user sets
ProtocolVersion pv = secure_.get_connection().version_;
bool removeDH = secure_.use_parms().removeDH_;
bool removeRSA = false;
bool removeDSA = false;
if (cm.get_keyType() == rsa_sa_algo)
removeDSA = true;
else
removeRSA = true;
secure_.use_parms().SetSuites(pv, removeDH, removeRSA, removeDSA);
}
} }
else if (serverSide) { else if (serverSide) {
SetError(no_key_file); SetError(no_key_file);
...@@ -321,6 +335,7 @@ SSL::SSL(SSL_CTX* ctx) ...@@ -321,6 +335,7 @@ SSL::SSL(SSL_CTX* ctx)
cm.setVerifyNone(); cm.setVerifyNone();
if (ctx->getMethod()->failNoCert()) if (ctx->getMethod()->failNoCert())
cm.setFailNoCert(); cm.setFailNoCert();
cm.setVerifyCallback(ctx->getVerifyCallback());
if (serverSide) if (serverSide)
crypto_.SetDH(ctx->GetDH_Parms()); crypto_.SetDH(ctx->GetDH_Parms());
...@@ -1040,7 +1055,7 @@ void SSL::fillData(Data& data) ...@@ -1040,7 +1055,7 @@ void SSL::fillData(Data& data)
data.set_length(0); // output, actual data filled data.set_length(0); // output, actual data filled
dataSz = min(dataSz, bufferedData()); dataSz = min(dataSz, bufferedData());
for (uint i = 0; i < elements; i++) { for (size_t i = 0; i < elements; i++) {
input_buffer* front = buffers_.getData().front(); input_buffer* front = buffers_.getData().front();
uint frontSz = front->get_remaining(); uint frontSz = front->get_remaining();
uint readSz = min(dataSz - data.get_length(), frontSz); uint readSz = min(dataSz - data.get_length(), frontSz);
...@@ -1101,7 +1116,7 @@ void SSL::flushBuffer() ...@@ -1101,7 +1116,7 @@ void SSL::flushBuffer()
output_buffer out(sz); output_buffer out(sz);
size_t elements = buffers_.getHandShake().size(); size_t elements = buffers_.getHandShake().size();
for (uint i = 0; i < elements; i++) { for (size_t i = 0; i < elements; i++) {
output_buffer* front = buffers_.getHandShake().front(); output_buffer* front = buffers_.getHandShake().front();
out.write(front->get_buffer(), front->get_size()); out.write(front->get_buffer(), front->get_size());
...@@ -1114,8 +1129,28 @@ void SSL::flushBuffer() ...@@ -1114,8 +1129,28 @@ void SSL::flushBuffer()
void SSL::Send(const byte* buffer, uint sz) void SSL::Send(const byte* buffer, uint sz)
{ {
if (socket_.send(buffer, sz) != sz) unsigned int sent = 0;
if (socket_.send(buffer, sz, sent) != sz) {
if (socket_.WouldBlock()) {
buffers_.SetOutput(NEW_YS output_buffer(sz - sent, buffer + sent,
sz - sent));
SetError(YasslError(SSL_ERROR_WANT_WRITE));
}
else
SetError(send_error); SetError(send_error);
}
}
void SSL::SendWriteBuffered()
{
output_buffer* out = buffers_.TakeOutput();
if (out) {
mySTL::auto_ptr<output_buffer> tmp(out);
Send(out->get_buffer(), out->get_size());
}
} }
...@@ -1420,7 +1455,6 @@ void SSL::addBuffer(output_buffer* b) ...@@ -1420,7 +1455,6 @@ void SSL::addBuffer(output_buffer* b)
void SSL_SESSION::CopyX509(X509* x) void SSL_SESSION::CopyX509(X509* x)
{ {
assert(peerX509_ == 0);
if (x == 0) return; if (x == 0) return;
X509_NAME* issuer = x->GetIssuer(); X509_NAME* issuer = x->GetIssuer();
...@@ -1567,12 +1601,18 @@ Errors& GetErrors() ...@@ -1567,12 +1601,18 @@ Errors& GetErrors()
typedef Mutex::Lock Lock; typedef Mutex::Lock Lock;
void Sessions::add(const SSL& ssl) void Sessions::add(const SSL& ssl)
{ {
if (ssl.getSecurity().get_connection().sessionID_Set_) { if (ssl.getSecurity().get_connection().sessionID_Set_) {
Lock guard(mutex_); Lock guard(mutex_);
list_.push_back(NEW_YS SSL_SESSION(ssl, random_)); list_.push_back(NEW_YS SSL_SESSION(ssl, random_));
count_++;
} }
if (count_ > SESSION_FLUSH_COUNT)
if (!ssl.getSecurity().GetContext()->GetSessionCacheFlushOff())
Flush();
} }
...@@ -1661,6 +1701,25 @@ void Sessions::remove(const opaque* id) ...@@ -1661,6 +1701,25 @@ void Sessions::remove(const opaque* id)
} }
// flush expired sessions from cache
void Sessions::Flush()
{
Lock guard(mutex_);
sess_iterator next = list_.begin();
uint current = lowResTimer();
while (next != list_.end()) {
sess_iterator si = next;
++next;
if ( ((*si)->GetBornOn() + (*si)->GetTimeOut()) < current) {
del_ptr_zero()(*si);
list_.erase(si);
}
}
count_ = 0; // reset flush counter
}
// remove a self thread error // remove a self thread error
void Errors::Remove() void Errors::Remove()
{ {
...@@ -1765,7 +1824,8 @@ bool SSL_METHOD::multipleProtocol() const ...@@ -1765,7 +1824,8 @@ bool SSL_METHOD::multipleProtocol() const
SSL_CTX::SSL_CTX(SSL_METHOD* meth) SSL_CTX::SSL_CTX(SSL_METHOD* meth)
: method_(meth), certificate_(0), privateKey_(0), passwordCb_(0), : method_(meth), certificate_(0), privateKey_(0), passwordCb_(0),
userData_(0), sessionCacheOff_(false) userData_(0), sessionCacheOff_(false), sessionCacheFlushOff_(false),
verifyCallback_(0)
{} {}
...@@ -1792,6 +1852,12 @@ SSL_CTX::GetCA_List() const ...@@ -1792,6 +1852,12 @@ SSL_CTX::GetCA_List() const
} }
const VerifyCallback SSL_CTX::getVerifyCallback() const
{
return verifyCallback_;
}
const x509* SSL_CTX::getCert() const const x509* SSL_CTX::getCert() const
{ {
return certificate_; return certificate_;
...@@ -1852,6 +1918,12 @@ bool SSL_CTX::GetSessionCacheOff() const ...@@ -1852,6 +1918,12 @@ bool SSL_CTX::GetSessionCacheOff() const
} }
bool SSL_CTX::GetSessionCacheFlushOff() const
{
return sessionCacheFlushOff_;
}
void SSL_CTX::SetUserData(void* data) void SSL_CTX::SetUserData(void* data)
{ {
userData_ = data; userData_ = data;
...@@ -1864,6 +1936,12 @@ void SSL_CTX::SetSessionCacheOff() ...@@ -1864,6 +1936,12 @@ void SSL_CTX::SetSessionCacheOff()
} }
void SSL_CTX::SetSessionCacheFlushOff()
{
sessionCacheFlushOff_ = true;
}
void SSL_CTX::setVerifyPeer() void SSL_CTX::setVerifyPeer()
{ {
method_->setVerifyPeer(); method_->setVerifyPeer();
...@@ -1882,6 +1960,12 @@ void SSL_CTX::setFailNoCert() ...@@ -1882,6 +1960,12 @@ void SSL_CTX::setFailNoCert()
} }
void SSL_CTX::setVerifyCallback(VerifyCallback vc)
{
verifyCallback_ = vc;
}
bool SSL_CTX::SetDH(const DH& dh) bool SSL_CTX::SetDH(const DH& dh)
{ {
dhParms_.p_ = dh.p->int_; dhParms_.p_ = dh.p->int_;
...@@ -2167,7 +2251,7 @@ Hashes& sslHashes::use_certVerify() ...@@ -2167,7 +2251,7 @@ Hashes& sslHashes::use_certVerify()
} }
Buffers::Buffers() : rawInput_(0) Buffers::Buffers() : prevSent(0), plainSz(0), rawInput_(0), output_(0)
{} {}
...@@ -2178,12 +2262,18 @@ Buffers::~Buffers() ...@@ -2178,12 +2262,18 @@ Buffers::~Buffers()
STL::for_each(dataList_.begin(), dataList_.end(), STL::for_each(dataList_.begin(), dataList_.end(),
del_ptr_zero()) ; del_ptr_zero()) ;
ysDelete(rawInput_); ysDelete(rawInput_);
ysDelete(output_);
}
void Buffers::SetOutput(output_buffer* ob)
{
output_ = ob;
} }
void Buffers::SetRawInput(input_buffer* ib) void Buffers::SetRawInput(input_buffer* ib)
{ {
assert(rawInput_ == 0);
rawInput_ = ib; rawInput_ = ib;
} }
...@@ -2197,6 +2287,15 @@ input_buffer* Buffers::TakeRawInput() ...@@ -2197,6 +2287,15 @@ input_buffer* Buffers::TakeRawInput()
} }
output_buffer* Buffers::TakeOutput()
{
output_buffer* ret = output_;
output_ = 0;
return ret;
}
const Buffers::inputList& Buffers::getData() const const Buffers::inputList& Buffers::getData() const
{ {
return dataList_; return dataList_;
...@@ -2355,10 +2454,10 @@ ASN1_STRING* X509_NAME::GetEntry(int i) ...@@ -2355,10 +2454,10 @@ ASN1_STRING* X509_NAME::GetEntry(int i)
memcpy(entry_.data, &name_[i], sz_ - i); memcpy(entry_.data, &name_[i], sz_ - i);
if (entry_.data[sz_ -i - 1]) { if (entry_.data[sz_ -i - 1]) {
entry_.data[sz_ - i] = 0; entry_.data[sz_ - i] = 0;
entry_.length = (int) (sz_ - i); entry_.length = int(sz_) - i;
} }
else else
entry_.length = (int) (sz_ - i - 1); entry_.length = int(sz_) - i - 1;
entry_.type = 0; entry_.type = 0;
return &entry_; return &entry_;
...@@ -2471,14 +2570,12 @@ ASN1_STRING* StringHolder::GetString() ...@@ -2471,14 +2570,12 @@ ASN1_STRING* StringHolder::GetString()
// these versions should never get called // these versions should never get called
int Compress(const byte* in, int sz, input_buffer& buffer) int Compress(const byte* in, int sz, input_buffer& buffer)
{ {
assert(0);
return -1; return -1;
} }
int DeCompress(input_buffer& in, int sz, input_buffer& out) int DeCompress(input_buffer& in, int sz, input_buffer& out)
{ {
assert(0);
return -1; return -1;
} }
......
...@@ -21,7 +21,7 @@ Stream Ciphers: ARC4 ...@@ -21,7 +21,7 @@ Stream Ciphers: ARC4
Public Key Crypto: RSA, DSA, Diffie-Hellman Public Key Crypto: RSA, DSA, Diffie-Hellman
Password based key derivation: PBKDF2 from PKCS #5 Password based key derivation: PBKDF2 from PKCS #5
Pseudo Random Number Generators Pseudo Random Number Generators
Lare Integer Support Large Integer Support
Base 16/64 encoding/decoding Base 16/64 encoding/decoding
DER encoding/decoding DER encoding/decoding
X.509 processing X.509 processing
......
...@@ -117,7 +117,7 @@ void bench_des() ...@@ -117,7 +117,7 @@ void bench_des()
double persec = 1 / total * megs; double persec = 1 / total * megs;
printf("3DES %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, printf("3DES %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
persec); persec);
} }
...@@ -137,7 +137,7 @@ void bench_aes(bool show) ...@@ -137,7 +137,7 @@ void bench_aes(bool show)
double persec = 1 / total * megs; double persec = 1 / total * megs;
if (show) if (show)
printf("AES %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, printf("AES %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
persec); persec);
} }
...@@ -156,7 +156,7 @@ void bench_twofish() ...@@ -156,7 +156,7 @@ void bench_twofish()
double persec = 1 / total * megs; double persec = 1 / total * megs;
printf("Twofish %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, printf("Twofish %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
persec); persec);
} }
...@@ -176,7 +176,7 @@ void bench_blowfish() ...@@ -176,7 +176,7 @@ void bench_blowfish()
double persec = 1 / total * megs; double persec = 1 / total * megs;
printf("Blowfish %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, printf("Blowfish %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
persec); persec);
} }
...@@ -195,7 +195,7 @@ void bench_arc4() ...@@ -195,7 +195,7 @@ void bench_arc4()
double persec = 1 / total * megs; double persec = 1 / total * megs;
printf("ARC4 %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, printf("ARC4 %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
persec); persec);
} }
...@@ -217,7 +217,7 @@ void bench_md5() ...@@ -217,7 +217,7 @@ void bench_md5()
double persec = 1 / total * megs; double persec = 1 / total * megs;
printf("MD5 %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, printf("MD5 %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
persec); persec);
} }
...@@ -245,7 +245,7 @@ void bench_sha() ...@@ -245,7 +245,7 @@ void bench_sha()
double persec = 1 / total * megs; double persec = 1 / total * megs;
printf("SHA %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, printf("SHA %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
persec); persec);
} }
...@@ -267,7 +267,7 @@ void bench_ripemd() ...@@ -267,7 +267,7 @@ void bench_ripemd()
double persec = 1 / total * megs; double persec = 1 / total * megs;
printf("RIPEMD %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total, printf("RIPEMD %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
persec); persec);
} }
...@@ -290,7 +290,7 @@ void bench_rsa() ...@@ -290,7 +290,7 @@ void bench_rsa()
byte message[] = "Everyone gets Friday off."; byte message[] = "Everyone gets Friday off.";
byte cipher[128]; // for 1024 bit byte cipher[128]; // for 1024 bit
byte plain[128]; // for 1024 bit byte plain[128]; // for 1024 bit
const int len = strlen((char*)message); const int len = (word32)strlen((char*)message);
int i; int i;
double start = current_time(); double start = current_time();
......
File mode changed from 100644 to 100755
30818702818100DA9A18547FF03B385CC16508C173A7EF4EB61CB40EF8FEF3B31F145051676166BCDC3FE6B799FC394D08C26385F9413F896E09117E46209D6923602683CEA100924A6EE695281775C619DAA94EA8CB3691B4275B0183F1D39639EBC92995FE645D6C1BC28D409E585549BBD2C5DCDD6C208B04EADD8B7A6D997F72CBAD88390F020102
\ No newline at end of file
...@@ -167,6 +167,7 @@ public: ...@@ -167,6 +167,7 @@ public:
void Decode(RSA_PublicKey&); void Decode(RSA_PublicKey&);
private: private:
void ReadHeader(); void ReadHeader();
void ReadHeaderOpenSSL();
}; };
......
...@@ -61,10 +61,6 @@ public: ...@@ -61,10 +61,6 @@ public:
void destroy(pointer p) {p->~T();} void destroy(pointer p) {p->~T();}
size_type max_size() const {return ~size_type(0)/sizeof(T);} size_type max_size() const {return ~size_type(0)/sizeof(T);}
protected: protected:
static void CheckSize(size_t n)
{
assert(n <= ~size_t(0) / sizeof(T));
}
}; };
...@@ -101,7 +97,8 @@ public: ...@@ -101,7 +97,8 @@ public:
pointer allocate(size_type n, const void* = 0) pointer allocate(size_type n, const void* = 0)
{ {
this->CheckSize(n); if (n > this->max_size())
return 0;
if (n == 0) if (n == 0)
return 0; return 0;
return NEW_TC T[n]; return NEW_TC T[n];
...@@ -144,9 +141,8 @@ public: ...@@ -144,9 +141,8 @@ public:
return *this; return *this;
} }
T& operator[] (word32 i) { assert(i < sz_); return buffer_[i]; } T& operator[] (word32 i) { return buffer_[i]; }
const T& operator[] (word32 i) const const T& operator[] (word32 i) const { return buffer_[i]; }
{ assert(i < sz_); return buffer_[i]; }
T* operator+ (word32 i) { return buffer_ + i; } T* operator+ (word32 i) { return buffer_ + i; }
const T* operator+ (word32 i) const { return buffer_ + i; } const T* operator+ (word32 i) const { return buffer_ + i; }
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 }; enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 };
Blowfish(CipherDir DIR, Mode MODE) Blowfish(CipherDir DIR, Mode MODE)
: Mode_BASE(BLOCK_SIZE, DIR, MODE) {} : Mode_BASE(BLOCK_SIZE, DIR, MODE), sbox_(pbox_ + ROUNDS + 2) {}
#ifdef DO_BLOWFISH_ASM #ifdef DO_BLOWFISH_ASM
void Process(byte*, const byte*, word32); void Process(byte*, const byte*, word32);
...@@ -62,8 +62,8 @@ private: ...@@ -62,8 +62,8 @@ private:
static const word32 p_init_[ROUNDS + 2]; static const word32 p_init_[ROUNDS + 2];
static const word32 s_init_[4 * 256]; static const word32 s_init_[4 * 256];
word32 pbox_[ROUNDS + 2]; word32 pbox_[ROUNDS + 2 + 4 * 256];
word32 sbox_[4 * 256]; word32* sbox_;
void crypt_block(const word32 in[2], word32 out[2]) const; void crypt_block(const word32 in[2], word32 out[2]) const;
void AsmProcess(const byte* in, byte* out) const; void AsmProcess(const byte* in, byte* out) const;
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (C) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -39,25 +39,32 @@ public: ...@@ -39,25 +39,32 @@ public:
explicit Source(word32 sz = 0) : buffer_(sz), current_(0) {} explicit Source(word32 sz = 0) : buffer_(sz), current_(0) {}
Source(const byte* b, word32 sz) : buffer_(b, sz), current_(0) {} Source(const byte* b, word32 sz) : buffer_(b, sz), current_(0) {}
word32 remaining() { if (GetError().What()) return 0;
else return buffer_.size() - current_; }
word32 size() const { return buffer_.size(); } word32 size() const { return buffer_.size(); }
void grow(word32 sz) { buffer_.CleanGrow(sz); } void grow(word32 sz) { buffer_.CleanGrow(sz); }
bool IsLeft(word32 sz) { if (remaining() >= sz) return true;
else { SetError(CONTENT_E); return false; } }
const byte* get_buffer() const { return buffer_.get_buffer(); } const byte* get_buffer() const { return buffer_.get_buffer(); }
const byte* get_current() const { return &buffer_[current_]; } const byte* get_current() const { return &buffer_[current_]; }
word32 get_index() const { return current_; } word32 get_index() const { return current_; }
void set_index(word32 i) { current_ = i; } void set_index(word32 i) { if (i < size()) current_ = i; }
byte operator[] (word32 i) { current_ = i; return next(); } byte operator[] (word32 i) { current_ = i; return next(); }
byte next() { return buffer_[current_++]; } byte next() { if (IsLeft(1)) return buffer_[current_++]; else return 0; }
byte prev() { return buffer_[--current_]; } byte prev() { if (current_) return buffer_[--current_]; else return 0; }
void add(const byte* data, word32 len) void add(const byte* data, word32 len)
{ {
if (IsLeft(len)) {
memcpy(buffer_.get_buffer() + current_, data, len); memcpy(buffer_.get_buffer() + current_, data, len);
current_ += len; current_ += len;
} }
}
void advance(word32 i) { current_ += i; } void advance(word32 i) { if (IsLeft(i)) current_ += i; }
void reset(ByteBlock&); void reset(ByteBlock&);
Error GetError() { return error_; } Error GetError() { return error_; }
......
/*
Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
MA 02110-1301 USA.
*/
/* hc128.hpp defines HC128
*/
#ifndef TAO_CRYPT_HC128_HPP
#define TAO_CRYPT_HC128_HPP
#include "misc.hpp"
namespace TaoCrypt {
// HC128 encryption and decryption
class HC128 {
public:
typedef HC128 Encryption;
typedef HC128 Decryption;
HC128() {}
void Process(byte*, const byte*, word32);
void SetKey(const byte*, const byte*);
private:
word32 T_[1024]; /* P[i] = T[i]; Q[i] = T[1024 + i ]; */
word32 X_[16];
word32 Y_[16];
word32 counter1024_; /* counter1024 = i mod 1024 at the ith step */
word32 key_[8];
word32 iv_[8];
void SetIV(const byte*);
void GenerateKeystream(word32*);
void SetupUpdate();
HC128(const HC128&); // hide copy
const HC128 operator=(const HC128&); // and assign
};
} // namespace
#endif // TAO_CRYPT_HC128_HPP
...@@ -110,13 +110,6 @@ namespace TaoCrypt { ...@@ -110,13 +110,6 @@ namespace TaoCrypt {
#endif #endif
// general MIN
template<typename T> inline
const T& min(const T& a, const T& b)
{
return a < b ? a : b;
}
// general MAX // general MAX
template<typename T> inline template<typename T> inline
......
...@@ -30,17 +30,5 @@ extern "C" void* memcpy(void*, const void*, size_t); ...@@ -30,17 +30,5 @@ extern "C" void* memcpy(void*, const void*, size_t);
extern "C" void* memset(void*, int, size_t); extern "C" void* memset(void*, int, size_t);
extern "C" void printk(char *fmt, ...); extern "C" void printk(char *fmt, ...);
#define KERN_ERR "<3>" /* error conditions */
#if defined(NDEBUG)
#define assert(p) ((void)0)
#else
#define assert(expr) \
if (!(expr)) { \
printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \
#expr,__FILE__,__FUNCTION__,__LINE__); }
#endif
#endif // TAOCRYPT_KERNELC_HPP #endif // TAOCRYPT_KERNELC_HPP
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#if !defined(DO_TAOCRYPT_KERNEL_MODE) #if !defined(DO_TAOCRYPT_KERNEL_MODE)
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
#include <string.h> #include <string.h>
#else #else
#include "kernelc.hpp" #include "kernelc.hpp"
...@@ -82,10 +81,10 @@ void CleanUp(); ...@@ -82,10 +81,10 @@ void CleanUp();
// to resolve compiler generated operator delete on base classes with // to resolve compiler generated operator delete on base classes with
// virtual destructors (when on stack), make sure doesn't get called // virtual destructors (when on stack)
class virtual_base { class virtual_base {
public: public:
static void operator delete(void*) { assert(0); } static void operator delete(void*) { }
}; };
#else // YASSL_PURE_C #else // YASSL_PURE_C
...@@ -125,7 +124,7 @@ void CleanUp(); ...@@ -125,7 +124,7 @@ void CleanUp();
// no gas on these systems ?, disable for now // no gas on these systems ?, disable for now
#if defined(__sun__) || defined (__QNX__) || defined (__APPLE__) #if defined(__sun__) || defined (__APPLE__)
#define TAOCRYPT_DISABLE_X86ASM #define TAOCRYPT_DISABLE_X86ASM
#endif #endif
...@@ -366,7 +365,6 @@ inline bool IsPowerOf2(T n) ...@@ -366,7 +365,6 @@ inline bool IsPowerOf2(T n)
template <class T1, class T2> template <class T1, class T2>
inline T2 ModPowerOf2(T1 a, T2 b) inline T2 ModPowerOf2(T1 a, T2 b)
{ {
assert(IsPowerOf2(b));
return T2(a) & (b-1); return T2(a) & (b-1);
} }
...@@ -409,13 +407,11 @@ inline bool IsAligned(const void* p, T* dummy = 0) // VC60 workaround ...@@ -409,13 +407,11 @@ inline bool IsAligned(const void* p, T* dummy = 0) // VC60 workaround
template <class T> inline T rotlFixed(T x, unsigned int y) template <class T> inline T rotlFixed(T x, unsigned int y)
{ {
assert(y < sizeof(T)*8);
return (x<<y) | (x>>(sizeof(T)*8-y)); return (x<<y) | (x>>(sizeof(T)*8-y));
} }
template <class T> inline T rotrFixed(T x, unsigned int y) template <class T> inline T rotrFixed(T x, unsigned int y)
{ {
assert(y < sizeof(T)*8);
return (x>>y) | (x<<(sizeof(T)*8-y)); return (x>>y) | (x<<(sizeof(T)*8-y));
} }
...@@ -425,13 +421,11 @@ template <class T> inline T rotrFixed(T x, unsigned int y) ...@@ -425,13 +421,11 @@ template <class T> inline T rotrFixed(T x, unsigned int y)
template<> inline word32 rotlFixed(word32 x, word32 y) template<> inline word32 rotlFixed(word32 x, word32 y)
{ {
assert(y < 32);
return y ? _lrotl(x, y) : x; return y ? _lrotl(x, y) : x;
} }
template<> inline word32 rotrFixed(word32 x, word32 y) template<> inline word32 rotrFixed(word32 x, word32 y)
{ {
assert(y < 32);
return y ? _lrotr(x, y) : x; return y ? _lrotr(x, y) : x;
} }
...@@ -441,7 +435,9 @@ template<> inline word32 rotrFixed(word32 x, word32 y) ...@@ -441,7 +435,9 @@ template<> inline word32 rotrFixed(word32 x, word32 y)
#undef min #undef min
#endif #endif
inline word32 min(word32 a, word32 b)
template <class T>
inline const T& min(const T& a, const T& b)
{ {
return a < b ? a : b; return a < b ? a : b;
} }
...@@ -486,7 +482,6 @@ inline word64 ByteReverse(word64 value) ...@@ -486,7 +482,6 @@ inline word64 ByteReverse(word64 value)
template <typename T> template <typename T>
inline void ByteReverse(T* out, const T* in, word32 byteCount) inline void ByteReverse(T* out, const T* in, word32 byteCount)
{ {
assert(byteCount % sizeof(T) == 0);
word32 count = byteCount/sizeof(T); word32 count = byteCount/sizeof(T);
for (word32 i=0; i<count; i++) for (word32 i=0; i<count; i++)
out[i] = ByteReverse(in[i]); out[i] = ByteReverse(in[i]);
...@@ -574,7 +569,6 @@ inline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in, ...@@ -574,7 +569,6 @@ inline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in,
word32 inlen) word32 inlen)
{ {
const unsigned int U = sizeof(T); const unsigned int U = sizeof(T);
assert(inlen <= outlen*U);
memcpy(out, in, inlen); memcpy(out, in, inlen);
memset((byte *)out+inlen, 0, outlen*U-inlen); memset((byte *)out+inlen, 0, outlen*U-inlen);
ByteReverseIf(out, out, RoundUpToMultipleOf(inlen, U), order); ByteReverseIf(out, out, RoundUpToMultipleOf(inlen, U), order);
...@@ -583,7 +577,8 @@ inline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in, ...@@ -583,7 +577,8 @@ inline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in,
#ifdef _MSC_VER #ifdef _MSC_VER
// disable conversion warning // disable conversion warning
#pragma warning(disable:4244) // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
#pragma warning(disable:4244 4996)
#endif #endif
...@@ -678,10 +673,7 @@ template <class T> ...@@ -678,10 +673,7 @@ template <class T>
inline T GetWord(bool assumeAligned, ByteOrder order, const byte *block) inline T GetWord(bool assumeAligned, ByteOrder order, const byte *block)
{ {
if (assumeAligned) if (assumeAligned)
{
assert(IsAligned<T>(block));
return ByteReverseIf(*reinterpret_cast<const T *>(block), order); return ByteReverseIf(*reinterpret_cast<const T *>(block), order);
}
else else
return UnalignedGetWord<T>(order, block); return UnalignedGetWord<T>(order, block);
} }
...@@ -699,7 +691,6 @@ inline void PutWord(bool assumeAligned, ByteOrder order, byte* block, T value, ...@@ -699,7 +691,6 @@ inline void PutWord(bool assumeAligned, ByteOrder order, byte* block, T value,
{ {
if (assumeAligned) if (assumeAligned)
{ {
assert(IsAligned<T>(block));
if (xorBlock) if (xorBlock)
*reinterpret_cast<T *>(block) = ByteReverseIf(value, order) *reinterpret_cast<T *>(block) = ByteReverseIf(value, order)
^ *reinterpret_cast<const T *>(xorBlock); ^ *reinterpret_cast<const T *>(xorBlock);
...@@ -812,7 +803,6 @@ inline T SafeLeftShift(T value) ...@@ -812,7 +803,6 @@ inline T SafeLeftShift(T value)
inline inline
word ShiftWordsLeftByBits(word* r, unsigned int n, unsigned int shiftBits) word ShiftWordsLeftByBits(word* r, unsigned int n, unsigned int shiftBits)
{ {
assert (shiftBits<WORD_BITS);
word u, carry=0; word u, carry=0;
if (shiftBits) if (shiftBits)
for (unsigned int i=0; i<n; i++) for (unsigned int i=0; i<n; i++)
...@@ -828,7 +818,6 @@ word ShiftWordsLeftByBits(word* r, unsigned int n, unsigned int shiftBits) ...@@ -828,7 +818,6 @@ word ShiftWordsLeftByBits(word* r, unsigned int n, unsigned int shiftBits)
inline inline
word ShiftWordsRightByBits(word* r, unsigned int n, unsigned int shiftBits) word ShiftWordsRightByBits(word* r, unsigned int n, unsigned int shiftBits)
{ {
assert (shiftBits<WORD_BITS);
word u, carry=0; word u, carry=0;
if (shiftBits) if (shiftBits)
for (int i=n-1; i>=0; i--) for (int i=n-1; i>=0; i--)
......
...@@ -61,9 +61,7 @@ public: ...@@ -61,9 +61,7 @@ public:
explicit Mode_BASE(int sz, CipherDir dir, Mode mode) explicit Mode_BASE(int sz, CipherDir dir, Mode mode)
: blockSz_(sz), reg_(reinterpret_cast<byte*>(r_)), : blockSz_(sz), reg_(reinterpret_cast<byte*>(r_)),
tmp_(reinterpret_cast<byte*>(t_)), dir_(dir), mode_(mode) tmp_(reinterpret_cast<byte*>(t_)), dir_(dir), mode_(mode)
{ {}
assert(sz <= MaxBlockSz);
}
virtual ~Mode_BASE() {} virtual ~Mode_BASE() {}
virtual void Process(byte*, const byte*, word32); virtual void Process(byte*, const byte*, word32);
...@@ -96,8 +94,7 @@ inline void Mode_BASE::Process(byte* out, const byte* in, word32 sz) ...@@ -96,8 +94,7 @@ inline void Mode_BASE::Process(byte* out, const byte* in, word32 sz)
{ {
if (mode_ == ECB) if (mode_ == ECB)
ECB_Process(out, in, sz); ECB_Process(out, in, sz);
else if (mode_ == CBC) else if (mode_ == CBC) {
{
if (dir_ == ENCRYPTION) if (dir_ == ENCRYPTION)
CBC_Encrypt(out, in, sz); CBC_Encrypt(out, in, sz);
else else
......
...@@ -48,8 +48,9 @@ word32 PBKDF2_HMAC<T>::DeriveKey(byte* derived, word32 dLen, const byte* pwd, ...@@ -48,8 +48,9 @@ word32 PBKDF2_HMAC<T>::DeriveKey(byte* derived, word32 dLen, const byte* pwd,
word32 pLen, const byte* salt, word32 sLen, word32 pLen, const byte* salt, word32 sLen,
word32 iterations) const word32 iterations) const
{ {
assert(dLen <= MaxDerivedKeyLength()); if (dLen > MaxDerivedKeyLength())
assert(iterations > 0); return 0;
ByteBlock buffer(T::DIGEST_SIZE); ByteBlock buffer(T::DIGEST_SIZE);
HMAC<T> hmac; HMAC<T> hmac;
......
/*
Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
MA 02110-1301 USA.
*/
/* rabbit.hpp defines Rabbit
*/
#ifndef TAO_CRYPT_RABBIT_HPP
#define TAO_CRYPT_RABBIT_HPP
#include "misc.hpp"
namespace TaoCrypt {
// Rabbit encryption and decryption
class Rabbit {
public:
typedef Rabbit Encryption;
typedef Rabbit Decryption;
enum RabbitCtx { Master = 0, Work = 1 };
Rabbit() {}
void Process(byte*, const byte*, word32);
void SetKey(const byte*, const byte*);
private:
struct Ctx {
word32 x[8];
word32 c[8];
word32 carry;
};
Ctx masterCtx_;
Ctx workCtx_;
void NextState(RabbitCtx);
void SetIV(const byte*);
Rabbit(const Rabbit&); // hide copy
const Rabbit operator=(const Rabbit&); // and assign
};
} // namespace
#endif // TAO_CRYPT_RABBIT_HPP
...@@ -178,7 +178,8 @@ void RSA_Encryptor<Pad>::Encrypt(const byte* plain, word32 sz, byte* cipher, ...@@ -178,7 +178,8 @@ void RSA_Encryptor<Pad>::Encrypt(const byte* plain, word32 sz, byte* cipher,
RandomNumberGenerator& rng) RandomNumberGenerator& rng)
{ {
PK_Lengths lengths(key_.GetModulus()); PK_Lengths lengths(key_.GetModulus());
assert(sz <= lengths.FixedMaxPlaintextLength()); if (sz > lengths.FixedMaxPlaintextLength())
return;
ByteBlock paddedBlock(lengths.PaddedBlockByteLength()); ByteBlock paddedBlock(lengths.PaddedBlockByteLength());
padding_.Pad(plain, sz, paddedBlock.get_buffer(), padding_.Pad(plain, sz, paddedBlock.get_buffer(),
...@@ -195,7 +196,6 @@ word32 RSA_Decryptor<Pad>::Decrypt(const byte* cipher, word32 sz, byte* plain, ...@@ -195,7 +196,6 @@ word32 RSA_Decryptor<Pad>::Decrypt(const byte* cipher, word32 sz, byte* plain,
RandomNumberGenerator& rng) RandomNumberGenerator& rng)
{ {
PK_Lengths lengths(key_.GetModulus()); PK_Lengths lengths(key_.GetModulus());
assert(sz == lengths.FixedCiphertextLength());
if (sz != lengths.FixedCiphertextLength()) if (sz != lengths.FixedCiphertextLength())
return 0; return 0;
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -31,14 +31,10 @@ ...@@ -31,14 +31,10 @@
#ifdef __sun #ifdef __sun
#include <assert.h>
// Handler for pure virtual functions // Handler for pure virtual functions
namespace __Crun { namespace __Crun {
static void pure_error(void) void pure_error(void);
{
assert("Pure virtual method called." == "Aborted");
}
} // namespace __Crun } // namespace __Crun
#endif // __sun #endif // __sun
...@@ -49,21 +45,10 @@ namespace __Crun { ...@@ -49,21 +45,10 @@ namespace __Crun {
#if __GNUC__ > 2 #if __GNUC__ > 2
extern "C" { extern "C" {
#if !defined(DO_TAOCRYPT_KERNEL_MODE) #if defined(DO_TAOCRYPT_KERNEL_MODE)
#include <assert.h>
#else
#include "kernelc.hpp" #include "kernelc.hpp"
#endif #endif
int __cxa_pure_virtual () __attribute__ ((weak));
/* Disallow inline __cxa_pure_virtual() */
static int __cxa_pure_virtual() __attribute__((noinline, used));
static int __cxa_pure_virtual()
{
// oops, pure virtual called!
assert("Pure virtual method called." == "Aborted");
return 0;
}
} // extern "C" } // extern "C"
#endif // __GNUC__ > 2 #endif // __GNUC__ > 2
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <string.h> // strncpy #include <string.h> // strncpy
#include <assert.h> // assert
#include <stdlib.h> // size_t #include <stdlib.h> // size_t
...@@ -41,7 +40,7 @@ public: ...@@ -41,7 +40,7 @@ public:
virtual const char* what() const { return ""; } virtual const char* what() const { return ""; }
// for compiler generated call, never used // for compiler generated call, never used
static void operator delete(void*) { assert(0); } static void operator delete(void*) { }
private: private:
// don't allow dynamic creation of exceptions // don't allow dynamic creation of exceptions
static void* operator new(size_t); static void* operator new(size_t);
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "helpers.hpp" // construct, destory, fill, etc. #include "helpers.hpp" // construct, destory, fill, etc.
#include "algorithm.hpp" // swap #include "algorithm.hpp" // swap
#include <assert.h> // assert
namespace mySTL { namespace mySTL {
...@@ -141,7 +140,7 @@ private: ...@@ -141,7 +140,7 @@ private:
// for growing, n must be bigger than other size // for growing, n must be bigger than other size
vector(size_t n, const vector& other) : vec_(n) vector(size_t n, const vector& other) : vec_(n)
{ {
assert(n > other.size()); if (n > other.size())
vec_.finish_ = uninit_copy(other.vec_.start_, other.vec_.finish_, vec_.finish_ = uninit_copy(other.vec_.start_, other.vec_.finish_,
vec_.start_); vec_.start_);
} }
......
...@@ -21,7 +21,7 @@ libtaocrypt_la_SOURCES = aes.cpp aestables.cpp algebra.cpp arc4.cpp \ ...@@ -21,7 +21,7 @@ libtaocrypt_la_SOURCES = aes.cpp aestables.cpp algebra.cpp arc4.cpp \
asn.cpp bftables.cpp blowfish.cpp coding.cpp des.cpp dh.cpp \ asn.cpp bftables.cpp blowfish.cpp coding.cpp des.cpp dh.cpp \
dsa.cpp file.cpp hash.cpp integer.cpp md2.cpp md4.cpp md5.cpp misc.cpp \ dsa.cpp file.cpp hash.cpp integer.cpp md2.cpp md4.cpp md5.cpp misc.cpp \
random.cpp ripemd.cpp rsa.cpp sha.cpp template_instnt.cpp \ random.cpp ripemd.cpp rsa.cpp sha.cpp template_instnt.cpp \
tftables.cpp twofish.cpp tftables.cpp twofish.cpp crypto.cpp rabbit.cpp hc128.cpp
libtaocrypt_la_CXXFLAGS = @yassl_taocrypt_extra_cxxflags@ -DYASSL_PURE_C \ libtaocrypt_la_CXXFLAGS = @yassl_taocrypt_extra_cxxflags@ -DYASSL_PURE_C \
@yassl_thread_cxxflags@ @yassl_thread_cxxflags@
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -51,7 +51,7 @@ void AES::Process(byte* out, const byte* in, word32 sz) ...@@ -51,7 +51,7 @@ void AES::Process(byte* out, const byte* in, word32 sz)
out += BLOCK_SIZE; out += BLOCK_SIZE;
in += BLOCK_SIZE; in += BLOCK_SIZE;
} }
else if (mode_ == CBC) else if (mode_ == CBC) {
if (dir_ == ENCRYPTION) if (dir_ == ENCRYPTION)
while (blocks--) { while (blocks--) {
r_[0] ^= *(word32*)in; r_[0] ^= *(word32*)in;
...@@ -78,6 +78,7 @@ void AES::Process(byte* out, const byte* in, word32 sz) ...@@ -78,6 +78,7 @@ void AES::Process(byte* out, const byte* in, word32 sz)
out += BLOCK_SIZE; out += BLOCK_SIZE;
in += BLOCK_SIZE; in += BLOCK_SIZE;
} }
}
} }
#endif // DO_AES_ASM #endif // DO_AES_ASM
...@@ -85,7 +86,12 @@ void AES::Process(byte* out, const byte* in, word32 sz) ...@@ -85,7 +86,12 @@ void AES::Process(byte* out, const byte* in, word32 sz)
void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
{ {
assert( (keylen == 16) || (keylen == 24) || (keylen == 32) ); if (keylen <= 16)
keylen = 16;
else if (keylen >= 32)
keylen = 32;
else if (keylen != 24)
keylen = 24;
rounds_ = keylen/4 + 6; rounds_ = keylen/4 + 6;
......
...@@ -33,6 +33,4 @@ const word32 AES::rcon_[] = { ...@@ -33,6 +33,4 @@ const word32 AES::rcon_[] = {
}; };
} // namespace } // namespace
/* /*
Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -187,10 +186,10 @@ Integer AbstractGroup::CascadeScalarMultiply(const Element &x, ...@@ -187,10 +186,10 @@ Integer AbstractGroup::CascadeScalarMultiply(const Element &x,
struct WindowSlider struct WindowSlider
{ {
WindowSlider(const Integer &exp, bool fastNegate, WindowSlider(const Integer &expIn, bool fastNegateIn,
unsigned int windowSizeIn=0) unsigned int windowSizeIn=0)
: exp(exp), windowModulus(Integer::One()), windowSize(windowSizeIn), : exp(expIn), windowModulus(Integer::One()), windowSize(windowSizeIn),
windowBegin(0), fastNegate(fastNegate), firstTime(true), windowBegin(0), fastNegate(fastNegateIn), firstTime(true),
finished(false) finished(false)
{ {
if (windowSize == 0) if (windowSize == 0)
...@@ -248,7 +247,6 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base, ...@@ -248,7 +247,6 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base,
for (i=0; i<expCount; i++) for (i=0; i<expCount; i++)
{ {
assert(expBegin->NotNegative());
exponents.push_back(WindowSlider(*expBegin++, InversionIsFast(), 0)); exponents.push_back(WindowSlider(*expBegin++, InversionIsFast(), 0));
exponents[i].FindNextWindow(); exponents[i].FindNextWindow();
buckets[i].resize(1<<(exponents[i].windowSize-1), Identity()); buckets[i].resize(1<<(exponents[i].windowSize-1), Identity());
...@@ -289,7 +287,7 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base, ...@@ -289,7 +287,7 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base,
r = buckets[i][buckets[i].size()-1]; r = buckets[i][buckets[i].size()-1];
if (buckets[i].size() > 1) if (buckets[i].size() > 1)
{ {
for (int j= (unsigned int) (buckets[i].size()) - 2; j >= 1; j--) for (size_t j = buckets[i].size()-2; j >= 1; j--)
{ {
Accumulate(buckets[i][j], buckets[i][j+1]); Accumulate(buckets[i][j], buckets[i][j+1]);
Accumulate(r, buckets[i][j]); Accumulate(r, buckets[i][j]);
......
This diff is collapsed.
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -53,7 +53,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz) ...@@ -53,7 +53,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz)
out += BLOCK_SIZE; out += BLOCK_SIZE;
in += BLOCK_SIZE; in += BLOCK_SIZE;
} }
else if (mode_ == CBC) else if (mode_ == CBC) {
if (dir_ == ENCRYPTION) if (dir_ == ENCRYPTION)
while (blocks--) { while (blocks--) {
r_[0] ^= *(word32*)in; r_[0] ^= *(word32*)in;
...@@ -78,6 +78,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz) ...@@ -78,6 +78,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz)
out += BLOCK_SIZE; out += BLOCK_SIZE;
in += BLOCK_SIZE; in += BLOCK_SIZE;
} }
}
} }
#endif // DO_BLOWFISH_ASM #endif // DO_BLOWFISH_ASM
...@@ -85,7 +86,10 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz) ...@@ -85,7 +86,10 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz)
void Blowfish::SetKey(const byte* key_string, word32 keylength, CipherDir dir) void Blowfish::SetKey(const byte* key_string, word32 keylength, CipherDir dir)
{ {
assert(keylength >= 4 && keylength <= 56); if (keylength < 4)
keylength = 4;
else if (keylength > 56)
keylength = 56;
unsigned i, j=0, k; unsigned i, j=0, k;
word32 data, dspace[2] = {0, 0}; word32 data, dspace[2] = {0, 0};
...@@ -164,16 +168,21 @@ void Blowfish::crypt_block(const word32 in[2], word32 out[2]) const ...@@ -164,16 +168,21 @@ void Blowfish::crypt_block(const word32 in[2], word32 out[2]) const
word32 left = in[0]; word32 left = in[0];
word32 right = in[1]; word32 right = in[1];
const word32 *const s = sbox_;
const word32* p = pbox_; const word32* p = pbox_;
word32 tmp;
left ^= p[0]; left ^= p[0];
BF_ROUNDS // roll back up and use s and p index instead of just p
for (unsigned i = 0; i < ROUNDS / 2; i++) {
right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
^ p[2*i+1];
#if ROUNDS == 20 left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
BF_EXTRA_ROUNDS ^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
#endif ^ p[2*i+2];
}
right ^= p[ROUNDS + 1]; right ^= p[ROUNDS + 1];
...@@ -187,17 +196,23 @@ typedef BlockGetAndPut<word32, BigEndian> gpBlock; ...@@ -187,17 +196,23 @@ typedef BlockGetAndPut<word32, BigEndian> gpBlock;
void Blowfish::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out) void Blowfish::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out)
const const
{ {
word32 tmp, left, right; word32 left, right;
const word32 *const s = sbox_;
const word32* p = pbox_; const word32* p = pbox_;
gpBlock::Get(in)(left)(right); gpBlock::Get(in)(left)(right);
left ^= p[0]; left ^= p[0];
BF_ROUNDS // roll back up and use s and p index instead of just p
for (unsigned i = 0; i < ROUNDS / 2; i++) {
right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])
^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])
^ p[2*i+1];
#if ROUNDS == 20 left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])
BF_EXTRA_ROUNDS ^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])
#endif ^ p[2*i+2];
}
right ^= p[ROUNDS + 1]; right ^= p[ROUNDS + 1];
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -95,7 +95,6 @@ void HexEncoder::Encode() ...@@ -95,7 +95,6 @@ void HexEncoder::Encode()
void HexDecoder::Decode() void HexDecoder::Decode()
{ {
word32 bytes = coded_.size(); word32 bytes = coded_.size();
assert((bytes % 2) == 0);
decoded_.New(bytes / 2); decoded_.New(bytes / 2);
word32 i(0); word32 i(0);
...@@ -104,15 +103,9 @@ void HexDecoder::Decode() ...@@ -104,15 +103,9 @@ void HexDecoder::Decode()
byte b = coded_.next() - 0x30; // 0 starts at 0x30 byte b = coded_.next() - 0x30; // 0 starts at 0x30
byte b2 = coded_.next() - 0x30; byte b2 = coded_.next() - 0x30;
// sanity checks
assert( b < sizeof(hexDecode)/sizeof(hexDecode[0]) );
assert( b2 < sizeof(hexDecode)/sizeof(hexDecode[0]) );
b = hexDecode[b]; b = hexDecode[b];
b2 = hexDecode[b2]; b2 = hexDecode[b2];
assert( b != bad && b2 != bad );
decoded_[i++] = (b << 4) | b2; decoded_[i++] = (b << 4) | b2;
bytes -= 2; bytes -= 2;
} }
...@@ -174,8 +167,8 @@ void Base64Encoder::Encode() ...@@ -174,8 +167,8 @@ void Base64Encoder::Encode()
} }
encoded_[i++] = '\n'; encoded_[i++] = '\n';
assert(i == outSz);
if (i == outSz)
plain_.reset(encoded_); plain_.reset(encoded_);
} }
...@@ -185,7 +178,7 @@ void Base64Decoder::Decode() ...@@ -185,7 +178,7 @@ void Base64Decoder::Decode()
{ {
word32 bytes = coded_.size(); word32 bytes = coded_.size();
word32 plainSz = bytes - ((bytes + (pemLineSz - 1)) / pemLineSz); word32 plainSz = bytes - ((bytes + (pemLineSz - 1)) / pemLineSz);
plainSz = (plainSz * 3 + 3) / 4; plainSz = ((plainSz * 3) / 4) + 3;
decoded_.New(plainSz); decoded_.New(plainSz);
word32 i = 0; word32 i = 0;
...@@ -197,7 +190,6 @@ void Base64Decoder::Decode() ...@@ -197,7 +190,6 @@ void Base64Decoder::Decode()
byte e3 = coded_.next(); byte e3 = coded_.next();
byte e4 = coded_.next(); byte e4 = coded_.next();
// do asserts first
if (e1 == 0) // end file 0's if (e1 == 0) // end file 0's
break; break;
......
...@@ -183,7 +183,8 @@ word32 DSA_Signer::Sign(const byte* sha_digest, byte* sig, ...@@ -183,7 +183,8 @@ word32 DSA_Signer::Sign(const byte* sha_digest, byte* sig,
Integer kInv = k.InverseMod(q); Integer kInv = k.InverseMod(q);
s_ = (kInv * (H + x*r_)) % q; s_ = (kInv * (H + x*r_)) % q;
assert(!!r_ && !!s_); if (!(!!r_ && !!s_))
return -1;
int rSz = r_.ByteCount(); int rSz = r_.ByteCount();
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "runtime.hpp" #include "runtime.hpp"
#include <string.h> #include <string.h>
#include <assert.h>
#include "hash.hpp" #include "hash.hpp"
...@@ -31,8 +30,6 @@ namespace TaoCrypt { ...@@ -31,8 +30,6 @@ namespace TaoCrypt {
HASHwithTransform::HASHwithTransform(word32 digSz, word32 buffSz) HASHwithTransform::HASHwithTransform(word32 digSz, word32 buffSz)
{ {
assert(digSz <= MaxDigestSz);
assert(buffSz <= MaxBufferSz);
} }
...@@ -113,8 +110,6 @@ void HASHwithTransform::Final(byte* hash) ...@@ -113,8 +110,6 @@ void HASHwithTransform::Final(byte* hash)
HASH64withTransform::HASH64withTransform(word32 digSz, word32 buffSz) HASH64withTransform::HASH64withTransform(word32 digSz, word32 buffSz)
{ {
assert(digSz <= MaxDigestSz);
assert(buffSz <= MaxBufferSz);
} }
......
This diff is collapsed.
This diff is collapsed.
File mode changed from 100644 to 100755
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -84,12 +84,21 @@ namespace STL = STL_NAMESPACE; ...@@ -84,12 +84,21 @@ namespace STL = STL_NAMESPACE;
} }
#if defined(__ICC) || defined(__INTEL_COMPILER) #ifdef __sun
// Handler for pure virtual functions
namespace __Crun {
void pure_error() {
}
}
#endif
#if defined(__ICC) || defined(__INTEL_COMPILER) || (__GNUC__ > 2)
extern "C" { extern "C" {
int __cxa_pure_virtual() { int __cxa_pure_virtual() {
assert("Pure virtual method called." == "Aborted");
return 0; return 0;
} }
...@@ -166,14 +175,6 @@ word Crop(word value, unsigned int size) ...@@ -166,14 +175,6 @@ word Crop(word value, unsigned int size)
#ifdef TAOCRYPT_X86ASM_AVAILABLE #ifdef TAOCRYPT_X86ASM_AVAILABLE
#ifndef _MSC_VER
static jmp_buf s_env;
static void SigIllHandler(int)
{
longjmp(s_env, 1);
}
#endif
bool HaveCpuId() bool HaveCpuId()
{ {
......
/*
Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
MA 02110-1301 USA.
*/
#include "runtime.hpp"
#include "rabbit.hpp"
namespace TaoCrypt {
#define U32V(x) (word32)(x)
#ifdef BIG_ENDIAN_ORDER
#define LITTLE32(x) ByteReverse((word32)x)
#else
#define LITTLE32(x) (x)
#endif
// local
namespace {
/* Square a 32-bit unsigned integer to obtain the 64-bit result and return */
/* the upper 32 bits XOR the lower 32 bits */
word32 RABBIT_g_func(word32 x)
{
/* Temporary variables */
word32 a, b, h, l;
/* Construct high and low argument for squaring */
a = x&0xFFFF;
b = x>>16;
/* Calculate high and low result of squaring */
h = (((U32V(a*a)>>17) + U32V(a*b))>>15) + b*b;
l = x*x;
/* Return high XOR low */
return U32V(h^l);
}
} // namespace local
/* Calculate the next internal state */
void Rabbit::NextState(RabbitCtx which)
{
/* Temporary variables */
word32 g[8], c_old[8], i;
Ctx* ctx;
if (which == Master)
ctx = &masterCtx_;
else
ctx = &workCtx_;
/* Save old counter values */
for (i=0; i<8; i++)
c_old[i] = ctx->c[i];
/* Calculate new counter values */
ctx->c[0] = U32V(ctx->c[0] + 0x4D34D34D + ctx->carry);
ctx->c[1] = U32V(ctx->c[1] + 0xD34D34D3 + (ctx->c[0] < c_old[0]));
ctx->c[2] = U32V(ctx->c[2] + 0x34D34D34 + (ctx->c[1] < c_old[1]));
ctx->c[3] = U32V(ctx->c[3] + 0x4D34D34D + (ctx->c[2] < c_old[2]));
ctx->c[4] = U32V(ctx->c[4] + 0xD34D34D3 + (ctx->c[3] < c_old[3]));
ctx->c[5] = U32V(ctx->c[5] + 0x34D34D34 + (ctx->c[4] < c_old[4]));
ctx->c[6] = U32V(ctx->c[6] + 0x4D34D34D + (ctx->c[5] < c_old[5]));
ctx->c[7] = U32V(ctx->c[7] + 0xD34D34D3 + (ctx->c[6] < c_old[6]));
ctx->carry = (ctx->c[7] < c_old[7]);
/* Calculate the g-values */
for (i=0;i<8;i++)
g[i] = RABBIT_g_func(U32V(ctx->x[i] + ctx->c[i]));
/* Calculate new state values */
ctx->x[0] = U32V(g[0] + rotlFixed(g[7],16) + rotlFixed(g[6], 16));
ctx->x[1] = U32V(g[1] + rotlFixed(g[0], 8) + g[7]);
ctx->x[2] = U32V(g[2] + rotlFixed(g[1],16) + rotlFixed(g[0], 16));
ctx->x[3] = U32V(g[3] + rotlFixed(g[2], 8) + g[1]);
ctx->x[4] = U32V(g[4] + rotlFixed(g[3],16) + rotlFixed(g[2], 16));
ctx->x[5] = U32V(g[5] + rotlFixed(g[4], 8) + g[3]);
ctx->x[6] = U32V(g[6] + rotlFixed(g[5],16) + rotlFixed(g[4], 16));
ctx->x[7] = U32V(g[7] + rotlFixed(g[6], 8) + g[5]);
}
/* IV setup */
void Rabbit::SetIV(const byte* iv)
{
/* Temporary variables */
word32 i0, i1, i2, i3, i;
/* Generate four subvectors */
i0 = LITTLE32(*(word32*)(iv+0));
i2 = LITTLE32(*(word32*)(iv+4));
i1 = (i0>>16) | (i2&0xFFFF0000);
i3 = (i2<<16) | (i0&0x0000FFFF);
/* Modify counter values */
workCtx_.c[0] = masterCtx_.c[0] ^ i0;
workCtx_.c[1] = masterCtx_.c[1] ^ i1;
workCtx_.c[2] = masterCtx_.c[2] ^ i2;
workCtx_.c[3] = masterCtx_.c[3] ^ i3;
workCtx_.c[4] = masterCtx_.c[4] ^ i0;
workCtx_.c[5] = masterCtx_.c[5] ^ i1;
workCtx_.c[6] = masterCtx_.c[6] ^ i2;
workCtx_.c[7] = masterCtx_.c[7] ^ i3;
/* Copy state variables */
for (i=0; i<8; i++)
workCtx_.x[i] = masterCtx_.x[i];
workCtx_.carry = masterCtx_.carry;
/* Iterate the system four times */
for (i=0; i<4; i++)
NextState(Work);
}
/* Key setup */
void Rabbit::SetKey(const byte* key, const byte* iv)
{
/* Temporary variables */
word32 k0, k1, k2, k3, i;
/* Generate four subkeys */
k0 = LITTLE32(*(word32*)(key+ 0));
k1 = LITTLE32(*(word32*)(key+ 4));
k2 = LITTLE32(*(word32*)(key+ 8));
k3 = LITTLE32(*(word32*)(key+12));
/* Generate initial state variables */
masterCtx_.x[0] = k0;
masterCtx_.x[2] = k1;
masterCtx_.x[4] = k2;
masterCtx_.x[6] = k3;
masterCtx_.x[1] = U32V(k3<<16) | (k2>>16);
masterCtx_.x[3] = U32V(k0<<16) | (k3>>16);
masterCtx_.x[5] = U32V(k1<<16) | (k0>>16);
masterCtx_.x[7] = U32V(k2<<16) | (k1>>16);
/* Generate initial counter values */
masterCtx_.c[0] = rotlFixed(k2, 16);
masterCtx_.c[2] = rotlFixed(k3, 16);
masterCtx_.c[4] = rotlFixed(k0, 16);
masterCtx_.c[6] = rotlFixed(k1, 16);
masterCtx_.c[1] = (k0&0xFFFF0000) | (k1&0xFFFF);
masterCtx_.c[3] = (k1&0xFFFF0000) | (k2&0xFFFF);
masterCtx_.c[5] = (k2&0xFFFF0000) | (k3&0xFFFF);
masterCtx_.c[7] = (k3&0xFFFF0000) | (k0&0xFFFF);
/* Clear carry bit */
masterCtx_.carry = 0;
/* Iterate the system four times */
for (i=0; i<4; i++)
NextState(Master);
/* Modify the counters */
for (i=0; i<8; i++)
masterCtx_.c[i] ^= masterCtx_.x[(i+4)&0x7];
/* Copy master instance to work instance */
for (i=0; i<8; i++) {
workCtx_.x[i] = masterCtx_.x[i];
workCtx_.c[i] = masterCtx_.c[i];
}
workCtx_.carry = masterCtx_.carry;
if (iv) SetIV(iv);
}
/* Encrypt/decrypt a message of any size */
void Rabbit::Process(byte* output, const byte* input, word32 msglen)
{
/* Temporary variables */
word32 i;
byte buffer[16];
/* Encrypt/decrypt all full blocks */
while (msglen >= 16) {
/* Iterate the system */
NextState(Work);
/* Encrypt/decrypt 16 bytes of data */
*(word32*)(output+ 0) = *(word32*)(input+ 0) ^
LITTLE32(workCtx_.x[0] ^ (workCtx_.x[5]>>16) ^
U32V(workCtx_.x[3]<<16));
*(word32*)(output+ 4) = *(word32*)(input+ 4) ^
LITTLE32(workCtx_.x[2] ^ (workCtx_.x[7]>>16) ^
U32V(workCtx_.x[5]<<16));
*(word32*)(output+ 8) = *(word32*)(input+ 8) ^
LITTLE32(workCtx_.x[4] ^ (workCtx_.x[1]>>16) ^
U32V(workCtx_.x[7]<<16));
*(word32*)(output+12) = *(word32*)(input+12) ^
LITTLE32(workCtx_.x[6] ^ (workCtx_.x[3]>>16) ^
U32V(workCtx_.x[1]<<16));
/* Increment pointers and decrement length */
input += 16;
output += 16;
msglen -= 16;
}
/* Encrypt/decrypt remaining data */
if (msglen) {
/* Iterate the system */
NextState(Work);
/* Generate 16 bytes of pseudo-random data */
*(word32*)(buffer+ 0) = LITTLE32(workCtx_.x[0] ^
(workCtx_.x[5]>>16) ^ U32V(workCtx_.x[3]<<16));
*(word32*)(buffer+ 4) = LITTLE32(workCtx_.x[2] ^
(workCtx_.x[7]>>16) ^ U32V(workCtx_.x[5]<<16));
*(word32*)(buffer+ 8) = LITTLE32(workCtx_.x[4] ^
(workCtx_.x[1]>>16) ^ U32V(workCtx_.x[7]<<16));
*(word32*)(buffer+12) = LITTLE32(workCtx_.x[6] ^
(workCtx_.x[3]>>16) ^ U32V(workCtx_.x[1]<<16));
/* Encrypt/decrypt the data */
for (i=0; i<msglen; i++)
output[i] = input[i] ^ buffer[i];
}
}
} // namespace
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <time.h> #include <time.h>
#if defined(_WIN32) #if defined(_WIN32)
#define _WIN32_WINNT 0x0400
#include <windows.h> #include <windows.h>
#include <wincrypt.h> #include <wincrypt.h>
#else #else
...@@ -93,67 +92,6 @@ void OS_Seed::GenerateSeed(byte* output, word32 sz) ...@@ -93,67 +92,6 @@ void OS_Seed::GenerateSeed(byte* output, word32 sz)
} }
#elif defined(__NETWARE__)
/* The OS_Seed implementation for Netware */
#include <nks/thread.h>
#include <nks/plat.h>
// Loop on high resulution Read Time Stamp Counter
static void NetwareSeed(byte* output, word32 sz)
{
word32 tscResult;
for (word32 i = 0; i < sz; i += sizeof(tscResult)) {
#if defined(__GNUC__)
asm volatile("rdtsc" : "=A" (tscResult));
#else
#ifdef __MWERKS__
asm {
#else
__asm {
#endif
rdtsc
mov tscResult, eax
}
#endif
memcpy(output, &tscResult, sizeof(tscResult));
output += sizeof(tscResult);
NXThreadYield(); // induce more variance
}
}
OS_Seed::OS_Seed()
{
}
OS_Seed::~OS_Seed()
{
}
void OS_Seed::GenerateSeed(byte* output, word32 sz)
{
/*
Try to use NXSeedRandom as it will generate a strong
seed using the onboard 82802 chip
As it's not always supported, fallback to default
implementation if an error is returned
*/
if (NXSeedRandom(sz, output) != 0)
{
NetwareSeed(output, sz);
}
}
#else #else
/* The default OS_Seed implementation */ /* The default OS_Seed implementation */
......
...@@ -61,7 +61,6 @@ Integer RSA_PrivateKey::CalculateInverse(RandomNumberGenerator& rng, ...@@ -61,7 +61,6 @@ Integer RSA_PrivateKey::CalculateInverse(RandomNumberGenerator& rng,
Integer y = ModularRoot(re, dq_, dp_, q_, p_, u_); Integer y = ModularRoot(re, dq_, dp_, q_, p_, u_);
y = modn.Divide(y, r); // unblind y = modn.Divide(y, r); // unblind
assert(modn.Exponentiate(y, e_) == x); // check
return y; return y;
} }
...@@ -124,7 +123,8 @@ word32 RSA_BlockType2::UnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen, ...@@ -124,7 +123,8 @@ word32 RSA_BlockType2::UnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
unsigned i=1; unsigned i=1;
while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body
} }
assert(i==pkcsBlockLen || pkcsBlock[i-1]==0); if (!(i==pkcsBlockLen || pkcsBlock[i-1]==0))
return 0;
unsigned int outputLen = pkcsBlockLen - i; unsigned int outputLen = pkcsBlockLen - i;
invalid = (outputLen > maxOutputLen) || invalid; invalid = (outputLen > maxOutputLen) || invalid;
...@@ -179,7 +179,8 @@ word32 RSA_BlockType1::UnPad(const byte* pkcsBlock, word32 pkcsBlockLen, ...@@ -179,7 +179,8 @@ word32 RSA_BlockType1::UnPad(const byte* pkcsBlock, word32 pkcsBlockLen,
unsigned i=1; unsigned i=1;
while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body
} }
assert(i==pkcsBlockLen || pkcsBlock[i-1]==0); if (!(i==pkcsBlockLen || pkcsBlock[i-1]==0))
return 0;
unsigned int outputLen = pkcsBlockLen - i; unsigned int outputLen = pkcsBlockLen - i;
invalid = (outputLen > maxOutputLen) || invalid; invalid = (outputLen > maxOutputLen) || invalid;
......
...@@ -61,7 +61,6 @@ template class PBKDF2_HMAC<SHA>; ...@@ -61,7 +61,6 @@ template class PBKDF2_HMAC<SHA>;
template class HMAC<MD5>; template class HMAC<MD5>;
template class HMAC<SHA>; template class HMAC<SHA>;
template class HMAC<RIPEMD160>; template class HMAC<RIPEMD160>;
} }
namespace mySTL { namespace mySTL {
......
/* /*
Copyright (C) 2000-2007 MySQL AB Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -54,7 +54,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz) ...@@ -54,7 +54,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz)
out += BLOCK_SIZE; out += BLOCK_SIZE;
in += BLOCK_SIZE; in += BLOCK_SIZE;
} }
else if (mode_ == CBC) else if (mode_ == CBC) {
if (dir_ == ENCRYPTION) if (dir_ == ENCRYPTION)
while (blocks--) { while (blocks--) {
r_[0] ^= *(word32*)in; r_[0] ^= *(word32*)in;
...@@ -82,6 +82,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz) ...@@ -82,6 +82,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz)
out += BLOCK_SIZE; out += BLOCK_SIZE;
in += BLOCK_SIZE; in += BLOCK_SIZE;
} }
}
} }
#endif // DO_TWOFISH_ASM #endif // DO_TWOFISH_ASM
...@@ -139,8 +140,6 @@ inline word32 Twofish::h(word32 x, const word32* key, unsigned int kLen) ...@@ -139,8 +140,6 @@ inline word32 Twofish::h(word32 x, const word32* key, unsigned int kLen)
void Twofish::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) void Twofish::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
{ {
assert(keylen >= 16 && keylen <= 32);
unsigned int len = (keylen <= 16 ? 2 : (keylen <= 24 ? 3 : 4)); unsigned int len = (keylen <= 16 ? 2 : (keylen <= 24 ? 3 : 4));
word32 key[8]; word32 key[8];
GetUserKey(LittleEndianOrder, key, len*2, userKey, keylen); GetUserKey(LittleEndianOrder, key, len*2, userKey, keylen);
......
...@@ -138,6 +138,10 @@ SOURCE=.\src\hash.cpp ...@@ -138,6 +138,10 @@ SOURCE=.\src\hash.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\hc128.cpp
# End Source File
# Begin Source File
SOURCE=.\src\integer.cpp SOURCE=.\src\integer.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -158,6 +162,10 @@ SOURCE=.\src\misc.cpp ...@@ -158,6 +162,10 @@ SOURCE=.\src\misc.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\rabbit.cpp
# End Source File
# Begin Source File
SOURCE=.\src\random.cpp SOURCE=.\src\random.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -238,6 +246,10 @@ SOURCE=.\include\hash.hpp ...@@ -238,6 +246,10 @@ SOURCE=.\include\hash.hpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\include\hc128.hpp
# End Source File
# Begin Source File
SOURCE=.\include\hmac.hpp SOURCE=.\include\hmac.hpp
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -274,6 +286,10 @@ SOURCE=.\include\pwdbased.hpp ...@@ -274,6 +286,10 @@ SOURCE=.\include\pwdbased.hpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\include\rabbit.hpp
# End Source File
# Begin Source File
SOURCE=.\include\random.hpp SOURCE=.\include\random.hpp
# End Source File # End Source File
# Begin Source File # Begin Source File
......
File mode changed from 100644 to 100755
...@@ -328,3 +328,32 @@ void operator delete[](void* ptr) ...@@ -328,3 +328,32 @@ void operator delete[](void* ptr)
{ {
::operator delete(ptr); ::operator delete(ptr);
} }
extern "C" {
void* XMALLOC(size_t sz, void* head)
{
return ::operator new(sz);
}
void* XREALLOC(void* ptr, size_t sz, void* heap)
{
void* ret = ::operator new(sz);
if (ret && ptr)
memcpy(ret, ptr, sz);
if (ret)
::operator delete(ptr);
return ret;
}
void XFREE(void* ptr, void* heap)
{
::operator delete(ptr);
}
} // extern "C"
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include "coding.hpp" #include "coding.hpp"
#include "random.hpp" #include "random.hpp"
#include "pwdbased.hpp" #include "pwdbased.hpp"
#include "rabbit.hpp"
#include "hc128.hpp"
...@@ -100,16 +102,18 @@ using TaoCrypt::PBKDF2_HMAC; ...@@ -100,16 +102,18 @@ using TaoCrypt::PBKDF2_HMAC;
using TaoCrypt::tcArrayDelete; using TaoCrypt::tcArrayDelete;
using TaoCrypt::GetCert; using TaoCrypt::GetCert;
using TaoCrypt::GetPKCS_Cert; using TaoCrypt::GetPKCS_Cert;
using TaoCrypt::Rabbit;
using TaoCrypt::HC128;
struct testVector { struct testVector {
byte* input_; byte* input_;
byte* output_; byte* output_;
size_t inLen_; word32 inLen_;
size_t outLen_; word32 outLen_;
testVector(const char* in, const char* out) : input_((byte*)in), testVector(const char* in, const char* out) : input_((byte*)in),
output_((byte*)out), inLen_(strlen(in)), outLen_(strlen(out)) {} output_((byte*)out), inLen_((word32)strlen(in)),
outLen_((word32)strlen(out)) {}
}; };
int sha_test(); int sha_test();
...@@ -134,13 +138,15 @@ int dsa_test(); ...@@ -134,13 +138,15 @@ int dsa_test();
int dh_test(); int dh_test();
int pwdbased_test(); int pwdbased_test();
int pkcs12_test(); int pkcs12_test();
int rabbit_test();
int hc128_test();
TaoCrypt::RandomNumberGenerator rng; TaoCrypt::RandomNumberGenerator rng;
void err_sys(const char* msg, int es) void err_sys(const char* msg, int es)
{ {
printf("%s", msg); printf("%s\n", msg);
exit(es); exit(es);
} }
...@@ -243,6 +249,16 @@ void taocrypt_test(void* args) ...@@ -243,6 +249,16 @@ void taocrypt_test(void* args)
else else
printf( "ARC4 test passed!\n"); printf( "ARC4 test passed!\n");
if ( (ret = rabbit_test()) )
err_sys("Rabbit test failed!\n", ret);
else
printf( "Rabbit test passed!\n");
if ( (ret = hc128_test()) )
err_sys("HC128 test failed!\n", ret);
else
printf( "HC128 test passed!\n");
if ( (ret = des_test()) ) if ( (ret = des_test()) )
err_sys("DES test failed!\n", ret); err_sys("DES test failed!\n", ret);
else else
...@@ -320,7 +336,7 @@ void taocrypt_test(void* args) ...@@ -320,7 +336,7 @@ void taocrypt_test(void* args)
void file_test(const char* file, byte* check) void file_test(const char* file, byte* check)
{ {
FILE* f; FILE* f;
int i(0); int i = 0;
MD5 md5; MD5 md5;
byte buf[1024]; byte buf[1024];
byte md5sum[MD5::DIGEST_SIZE]; byte md5sum[MD5::DIGEST_SIZE];
...@@ -329,7 +345,7 @@ void file_test(const char* file, byte* check) ...@@ -329,7 +345,7 @@ void file_test(const char* file, byte* check)
printf("Can't open %s\n", file); printf("Can't open %s\n", file);
return; return;
} }
while( ( i = fread(buf, 1, sizeof(buf), f )) > 0 ) while( ( i = (int)fread(buf, 1, sizeof(buf), f )) > 0 )
md5.Update(buf, i); md5.Update(buf, i);
md5.Final(md5sum); md5.Final(md5sum);
...@@ -718,7 +734,7 @@ int hmac_test() ...@@ -718,7 +734,7 @@ int hmac_test()
int times( sizeof(test_hmacMD5) / sizeof(testVector) ); int times( sizeof(test_hmacMD5) / sizeof(testVector) );
for (int i = 0; i < times; ++i) { for (int i = 0; i < times; ++i) {
hmacMD5.SetKey((byte*)keys[i], strlen(keys[i])); hmacMD5.SetKey((byte*)keys[i], (word32)strlen(keys[i]));
hmacMD5.Update(test_hmacMD5[i].input_, test_hmacMD5[i].inLen_); hmacMD5.Update(test_hmacMD5[i].input_, test_hmacMD5[i].inLen_);
hmacMD5.Final(hash); hmacMD5.Final(hash);
...@@ -761,8 +777,8 @@ int arc4_test() ...@@ -761,8 +777,8 @@ int arc4_test()
ARC4::Encryption enc; ARC4::Encryption enc;
ARC4::Decryption dec; ARC4::Decryption dec;
enc.SetKey((byte*)keys[i], strlen(keys[i])); enc.SetKey((byte*)keys[i], (word32)strlen(keys[i]));
dec.SetKey((byte*)keys[i], strlen(keys[i])); dec.SetKey((byte*)keys[i], (word32)strlen(keys[i]));
enc.Process(cipher, test_arc4[i].input_, test_arc4[i].outLen_); enc.Process(cipher, test_arc4[i].input_, test_arc4[i].outLen_);
dec.Process(plain, cipher, test_arc4[i].outLen_); dec.Process(plain, cipher, test_arc4[i].outLen_);
...@@ -778,6 +794,114 @@ int arc4_test() ...@@ -778,6 +794,114 @@ int arc4_test()
} }
int rabbit_test()
{
byte cipher[16];
byte plain[16];
const char* keys[] =
{
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\xAC\xC3\x51\xDC\xF1\x62\xFC\x3B\xFE\x36\x3D\x2E\x29\x13\x28\x91"
};
const char* ivs[] =
{
"\x00\x00\x00\x00\x00\x00\x00\x00",
"\x59\x7E\x26\xC1\x75\xF5\x73\xC3",
0
};
testVector test_rabbit[] =
{
testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
"\xED\xB7\x05\x67\x37\x5D\xCD\x7C"),
testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
"\x6D\x7D\x01\x22\x92\xCC\xDC\xE0"),
testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
"\x9C\x51\xE2\x87\x84\xC3\x7F\xE9")
};
int times( sizeof(test_rabbit) / sizeof(testVector) );
for (int i = 0; i < times; ++i) {
Rabbit::Encryption enc;
Rabbit::Decryption dec;
enc.SetKey((byte*)keys[i], (byte*)ivs[i]);
dec.SetKey((byte*)keys[i], (byte*)ivs[i]);
enc.Process(cipher, test_rabbit[i].input_, test_rabbit[i].outLen_);
dec.Process(plain, cipher, test_rabbit[i].outLen_);
if (memcmp(plain, test_rabbit[i].input_, test_rabbit[i].outLen_))
return -230 - i;
if (memcmp(cipher, test_rabbit[i].output_, test_rabbit[i].outLen_))
return -240 - i;
}
return 0;
}
int hc128_test()
{
byte cipher[16];
byte plain[16];
const char* keys[] =
{
"\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x00\x53\xA6\xF9\x4C\x9F\xF2\x45\x98\xEB\x3E\x91\xE4\x37\x8A\xDD",
"\x0F\x62\xB5\x08\x5B\xAE\x01\x54\xA7\xFA\x4D\xA0\xF3\x46\x99\xEC"
};
const char* ivs[] =
{
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x0D\x74\xDB\x42\xA9\x10\x77\xDE\x45\xAC\x13\x7A\xE1\x48\xAF\x16",
"\x28\x8F\xF6\x5D\xC4\x2B\x92\xF9\x60\xC7\x2E\x95\xFC\x63\xCA\x31"
};
testVector test_hc128[] =
{
testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
"\x37\x86\x02\xB9\x8F\x32\xA7\x48"),
testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
"\x33\x7F\x86\x11\xC6\xED\x61\x5F"),
testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
"\x2E\x1E\xD1\x2A\x85\x51\xC0\x5A"),
testVector("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x1C\xD8\xAE\xDD\xFE\x52\xE2\x17\xE8\x35\xD0\xB7\xE8\x4E\x29")
};
int times( sizeof(test_hc128) / sizeof(testVector) );
for (int i = 0; i < times; ++i) {
HC128::Encryption enc;
HC128::Decryption dec;
enc.SetKey((byte*)keys[i], (byte*)ivs[i]);
dec.SetKey((byte*)keys[i], (byte*)ivs[i]);
enc.Process(cipher, test_hc128[i].input_, test_hc128[i].outLen_);
dec.Process(plain, cipher, test_hc128[i].outLen_);
if (memcmp(plain, test_hc128[i].input_, test_hc128[i].outLen_))
return -330 - i;
if (memcmp(cipher, test_hc128[i].output_, test_hc128[i].outLen_))
return -340 - i;
}
return 0;
}
int des_test() int des_test()
{ {
//ECB mode //ECB mode
...@@ -1040,7 +1164,7 @@ int rsa_test() ...@@ -1040,7 +1164,7 @@ int rsa_test()
RSAES_Encryptor enc(priv); RSAES_Encryptor enc(priv);
byte message[] = "Everyone gets Friday off."; byte message[] = "Everyone gets Friday off.";
const int len(strlen((char*)message)); const word32 len = (word32)strlen((char*)message);
byte cipher[64]; byte cipher[64];
enc.Encrypt(message, len, cipher, rng); enc.Encrypt(message, len, cipher, rng);
...@@ -1068,6 +1192,8 @@ int rsa_test() ...@@ -1068,6 +1192,8 @@ int rsa_test()
} }
} }
CertDecoder cd(source2, true, 0, false, CertDecoder::CA); CertDecoder cd(source2, true, 0, false, CertDecoder::CA);
if (cd.GetError().What())
err_sys("cert error", -80);
Source source3(cd.GetPublicKey().GetKey(), cd.GetPublicKey().size()); Source source3(cd.GetPublicKey().GetKey(), cd.GetPublicKey().size());
RSA_PublicKey pub(source3); RSA_PublicKey pub(source3);
...@@ -1188,6 +1314,7 @@ int pwdbased_test() ...@@ -1188,6 +1314,7 @@ int pwdbased_test()
} }
/*
int pkcs12_test() int pkcs12_test()
{ {
Source cert; Source cert;
...@@ -1220,4 +1347,5 @@ int pkcs12_test() ...@@ -1220,4 +1347,5 @@ int pkcs12_test()
return 0; return 0;
} }
*/
File mode changed from 100644 to 100755
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment