Commit 724af49c authored by Georgi Kodinov's avatar Georgi Kodinov

Bug #13706828: UPGRADE YASSL FROM 1.7.2 TO 2.1.4

$SUBJ$
1. Took a diff between the previous base version and the
mysql sources.
2. Added the new 2.1.4 base version.
3. Reviewed and re-applied the diff from step #1.
parent a25adb1c
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 1.9.9 (1/26/2010)
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 +131,7 @@ See libcurl build instructions below under 1.3.0 and note in 1.5.8. ...@@ -13,7 +131,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 +636,7 @@ in the source and include files. ...@@ -518,7 +636,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,7 +86,8 @@ void client_test(void* args) ...@@ -81,7 +86,8 @@ void client_test(void* args)
#ifdef NON_BLOCKING #ifdef NON_BLOCKING
NonBlockingSSL_Connect(ssl, ctx, sockfd); NonBlockingSSL_Connect(ssl, ctx, sockfd);
#else #else
if (SSL_connect(ssl) != SSL_SUCCESS) // if you get an error here see note at top of README
if (SSL_connect(ssl) != SSL_SUCCESS)
ClientError(ctx, ssl, sockfd, "SSL_connect failed"); ClientError(ctx, ssl, sockfd, "SSL_connect failed");
#endif #endif
showPeer(ssl); showPeer(ssl);
...@@ -105,7 +111,7 @@ void client_test(void* args) ...@@ -105,7 +111,7 @@ void client_test(void* args)
int input = SSL_read(ssl, reply, sizeof(reply)); int input = SSL_read(ssl, reply, sizeof(reply));
if (input > 0) { if (input > 0) {
reply[input] = 0; reply[input] = 0;
printf("Server response: %s\n", reply); printf("Server response: %s\n", reply);
} }
#ifdef TEST_RESUME #ifdef TEST_RESUME
...@@ -121,18 +127,18 @@ void client_test(void* args) ...@@ -121,18 +127,18 @@ void client_test(void* args)
tcp_connect(sockfd); tcp_connect(sockfd);
SSL_set_fd(sslResume, sockfd); SSL_set_fd(sslResume, sockfd);
SSL_set_session(sslResume, session); SSL_set_session(sslResume, session);
if (SSL_connect(sslResume) != SSL_SUCCESS) if (SSL_connect(sslResume) != SSL_SUCCESS)
ClientError(ctx, sslResume, sockfd, "SSL_resume failed"); ClientError(ctx, sslResume, sockfd, "SSL_resume failed");
showPeer(sslResume); showPeer(sslResume);
if (SSL_write(sslResume, msg, sizeof(msg)) != sizeof(msg)) if (SSL_write(sslResume, msg, sizeof(msg)) != sizeof(msg))
ClientError(ctx, sslResume, sockfd, "SSL_write failed"); ClientError(ctx, sslResume, sockfd, "SSL_write failed");
input = SSL_read(sslResume, reply, sizeof(reply)); input = SSL_read(sslResume, reply, sizeof(reply));
if (input > 0) { if (input > 0) {
reply[input] = 0; reply[input] = 0;
printf("Server response: %s\n", reply); printf("Server response: %s\n", reply);
} }
SSL_shutdown(sslResume); SSL_shutdown(sslResume);
......
...@@ -74,10 +74,10 @@ void echoclient_test(void* args) ...@@ -74,10 +74,10 @@ void echoclient_test(void* args)
char send[1024]; char send[1024];
char reply[1024]; char reply[1024];
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");
...@@ -86,7 +86,7 @@ void echoclient_test(void* args) ...@@ -86,7 +86,7 @@ void echoclient_test(void* args)
break; break;
} }
if (SSL_read(ssl, reply, sizeof(reply)) > 0) if (SSL_read(ssl, reply, sizeof(reply)) > 0)
fputs(reply, fout); fputs(reply, fout);
} }
......
...@@ -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");
...@@ -111,11 +111,11 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) ...@@ -111,11 +111,11 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
tcp_close(clientfd); tcp_close(clientfd);
continue; continue;
} }
char command[1024]; char command[1024];
int echoSz(0); int echoSz(0);
while ( (echoSz = SSL_read(ssl, command, sizeof(command))) > 0) { while ( (echoSz = SSL_read(ssl, command, sizeof(command))) > 0) {
if ( strncmp(command, "quit", 4) == 0) { if ( strncmp(command, "quit", 4) == 0) {
printf("client sent quit command: shutting down!\n"); printf("client sent quit command: shutting down!\n");
shutdown = true; shutdown = true;
...@@ -127,7 +127,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) ...@@ -127,7 +127,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
char header[] = "<html><body BGCOLOR=\"#ffffff\">\n<pre>\n"; char header[] = "<html><body BGCOLOR=\"#ffffff\">\n<pre>\n";
char body[] = "greetings from yaSSL\n"; char body[] = "greetings from yaSSL\n";
char footer[] = "</body></html>\r\n\r\n"; char footer[] = "</body></html>\r\n\r\n";
strncpy(command, type, sizeof(type)); strncpy(command, type, sizeof(type));
echoSz = sizeof(type) - 1; echoSz = sizeof(type) - 1;
...@@ -140,7 +140,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) ...@@ -140,7 +140,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
if (SSL_write(ssl, command, echoSz) != echoSz) if (SSL_write(ssl, command, echoSz) != echoSz)
EchoError(ctx, ssl, sockfd, clientfd, "SSL_write failed"); EchoError(ctx, ssl, sockfd, clientfd, "SSL_write failed");
break; break;
} }
command[echoSz] = 0; command[echoSz] = 0;
......
...@@ -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");
...@@ -78,14 +83,14 @@ THREAD_RETURN YASSL_API server_test(void* args) ...@@ -78,14 +83,14 @@ THREAD_RETURN YASSL_API server_test(void* args)
SSL* ssl = SSL_new(ctx); SSL* ssl = SSL_new(ctx);
SSL_set_fd(ssl, clientfd); SSL_set_fd(ssl, clientfd);
#ifdef NON_BLOCKING #ifdef NON_BLOCKING
NonBlockingSSL_Accept(ssl, ctx, clientfd); NonBlockingSSL_Accept(ssl, ctx, clientfd);
#else #else
if (SSL_accept(ssl) != SSL_SUCCESS) if (SSL_accept(ssl) != SSL_SUCCESS)
ServerError(ctx, ssl, clientfd, "SSL_accept failed"); ServerError(ctx, ssl, clientfd, "SSL_accept failed");
#endif #endif
showPeer(ssl); showPeer(ssl);
printf("Using Cipher Suite: %s\n", SSL_get_cipher(ssl)); printf("Using Cipher Suite: %s\n", SSL_get_cipher(ssl));
...@@ -93,7 +98,7 @@ THREAD_RETURN YASSL_API server_test(void* args) ...@@ -93,7 +98,7 @@ THREAD_RETURN YASSL_API server_test(void* args)
int input = SSL_read(ssl, command, sizeof(command)); int input = SSL_read(ssl, command, sizeof(command));
if (input > 0) { if (input > 0) {
command[input] = 0; command[input] = 0;
printf("First client command: %s\n", command); printf("First client command: %s\n", command);
} }
char msg[] = "I hear you, fa shizzle!"; char msg[] = "I hear you, fa shizzle!";
......
...@@ -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
......
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
#include "prefix_ssl.h" #include "prefix_ssl.h"
#endif #endif
#include <stdio.h> /* ERR_print fp */ #include <stdio.h> /* ERR_print fp */
#include "opensslv.h" /* for version number */ #include "opensslv.h" /* for version number */
#include "rsa.h" #include "rsa.h"
#define YASSL_VERSION "1.7.2" #define YASSL_VERSION "2.1.4"
#if defined(__cplusplus) #if defined(__cplusplus)
...@@ -43,9 +43,9 @@ extern "C" { ...@@ -43,9 +43,9 @@ extern "C" {
#endif #endif
void yaSSL_CleanUp(); /* call once at end of application use to void yaSSL_CleanUp(); /* call once at end of application use to
free static singleton memory holders, free static singleton memory holders,
not a leak per se, but helpful when not a leak per se, but helpful when
looking for them */ looking for them */
#if defined(__cplusplus) #if defined(__cplusplus)
} // extern } // extern
...@@ -70,11 +70,11 @@ extern "C" { ...@@ -70,11 +70,11 @@ extern "C" {
class X509; class X509;
class X509_NAME; class X509_NAME;
#else #else
typedef struct SSL SSL; typedef struct SSL SSL;
typedef struct SSL_SESSION SSL_SESSION; typedef struct SSL_SESSION SSL_SESSION;
typedef struct SSL_METHOD SSL_METHOD; typedef struct SSL_METHOD SSL_METHOD;
typedef struct SSL_CTX SSL_CTX; typedef struct SSL_CTX SSL_CTX;
typedef struct SSL_CIPHER SSL_CIPHER; typedef struct SSL_CIPHER SSL_CIPHER;
typedef struct RSA RSA; typedef struct RSA RSA;
...@@ -107,6 +107,15 @@ RSA* RSA_generate_key(int, unsigned long, void(*)(int, int, void*), void*); ...@@ -107,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;
...@@ -125,16 +134,6 @@ typedef struct BIO BIO; ...@@ -125,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*);
...@@ -205,7 +204,7 @@ SSL* SSL_new(SSL_CTX*); ...@@ -205,7 +204,7 @@ 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*); /* if you get an error from connect int SSL_connect(SSL*); /* if you get an error from connect
see note at top of REAMDE */ 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*);
...@@ -351,11 +350,11 @@ enum { /* ssl Constants */ ...@@ -351,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
...@@ -366,7 +365,7 @@ enum { /* ssl Constants */ ...@@ -366,7 +365,7 @@ enum { /* ssl Constants */
SSL_METHOD *SSLv3_method(void); SSL_METHOD *SSLv3_method(void);
SSL_METHOD *SSLv3_server_method(void); SSL_METHOD *SSLv3_server_method(void);
SSL_METHOD *SSLv3_client_method(void); SSL_METHOD *SSLv3_client_method(void);
SSL_METHOD *TLSv1_server_method(void); SSL_METHOD *TLSv1_server_method(void);
SSL_METHOD *TLSv1_client_method(void); SSL_METHOD *TLSv1_client_method(void);
SSL_METHOD *TLSv1_1_server_method(void); SSL_METHOD *TLSv1_1_server_method(void);
SSL_METHOD *TLSv1_1_client_method(void); SSL_METHOD *TLSv1_1_client_method(void);
......
...@@ -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();
......
...@@ -168,7 +168,7 @@ private: ...@@ -168,7 +168,7 @@ private:
// openSSL X509 names // openSSL X509 names
class X509_NAME { class X509_NAME {
char* name_; char* name_;
size_t sz_; size_t sz_;
ASN1_STRING entry_; ASN1_STRING entry_;
public: public:
...@@ -246,11 +246,11 @@ public: ...@@ -246,11 +246,11 @@ public:
SSL_SESSION(const SSL&, RandomPool&); SSL_SESSION(const SSL&, RandomPool&);
~SSL_SESSION(); ~SSL_SESSION();
const opaque* GetID() const; const opaque* GetID() const;
const opaque* GetSecret() const; const opaque* GetSecret() const;
const Cipher* GetSuite() const; const Cipher* GetSuite() const;
uint GetBornOn() const; uint GetBornOn() const;
uint GetTimeOut() const; uint GetTimeOut() const;
X509* GetPeerX509() const; X509* GetPeerX509() const;
void SetTimeOut(uint); void SetTimeOut(uint);
...@@ -417,33 +417,33 @@ class SSL_CTX { ...@@ -417,33 +417,33 @@ class SSL_CTX {
public: public:
typedef STL::list<x509*> CertList; typedef STL::list<x509*> CertList;
private: private:
SSL_METHOD* method_; SSL_METHOD* method_;
x509* certificate_; x509* certificate_;
x509* privateKey_; x509* privateKey_;
CertList caList_; CertList caList_;
Ciphers ciphers_; Ciphers ciphers_;
DH_Parms dhParms_; DH_Parms dhParms_;
pem_password_cb passwordCb_; pem_password_cb passwordCb_;
void* userData_; void* userData_;
bool sessionCacheOff_; bool sessionCacheOff_;
bool sessionCacheFlushOff_; bool sessionCacheFlushOff_;
Stats stats_; Stats stats_;
Mutex mutex_; // for Stats Mutex mutex_; // for Stats
VerifyCallback verifyCallback_; VerifyCallback verifyCallback_;
public: public:
explicit SSL_CTX(SSL_METHOD* meth); explicit SSL_CTX(SSL_METHOD* meth);
~SSL_CTX(); ~SSL_CTX();
const x509* getCert() const; const x509* getCert() const;
const x509* getKey() const; const x509* getKey() const;
const SSL_METHOD* getMethod() const; const SSL_METHOD* getMethod() const;
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;
VerifyCallback getVerifyCallback() 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; bool GetSessionCacheFlushOff() const;
void setVerifyPeer(); void setVerifyPeer();
...@@ -532,10 +532,13 @@ class Buffers { ...@@ -532,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();
...@@ -546,11 +549,13 @@ public: ...@@ -546,11 +549,13 @@ public:
inputList& useData(); inputList& useData();
outputList& useHandShake(); outputList& useHandShake();
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
}; };
...@@ -652,6 +657,7 @@ public: ...@@ -652,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);
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#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"
...@@ -37,6 +36,13 @@ ...@@ -37,6 +36,13 @@
#endif #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
...@@ -63,29 +69,29 @@ namespace yaSSL { ...@@ -63,29 +69,29 @@ namespace yaSSL {
template<typename T> template<typename T>
void ysDelete(T* ptr) void ysDelete(T* ptr)
{ {
if (ptr) ptr->~T(); if (ptr) ptr->~T();
::operator delete(ptr, yaSSL::ys); ::operator delete(ptr, yaSSL::ys);
} }
template<typename T> template<typename T>
void ysArrayDelete(T* ptr) void ysArrayDelete(T* ptr)
{ {
// can't do array placement destruction since not tracking size in // can't do array placement destruction since not tracking size in
// allocation, only allow builtins to use array placement since they // allocation, only allow builtins to use array placement since they
// don't need destructors called // don't need destructors called
typedef char builtin[TaoCrypt::IsFundamentalType<T>::Yes ? 1 : -1]; typedef char builtin[TaoCrypt::IsFundamentalType<T>::Yes ? 1 : -1];
(void)sizeof(builtin); (void)sizeof(builtin);
::operator delete[](ptr, yaSSL::ys); ::operator delete[](ptr, yaSSL::ys);
} }
#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*) { }
}; };
...@@ -124,7 +130,7 @@ typedef opaque byte; ...@@ -124,7 +130,7 @@ typedef opaque byte;
typedef unsigned int uint; typedef unsigned int uint;
#ifdef USE_SYS_STL #ifdef USE_SYS_STL
// use system STL // use system STL
#define STL_VECTOR_FILE <vector> #define STL_VECTOR_FILE <vector>
......
...@@ -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_++];
} }
......
...@@ -250,7 +250,8 @@ int CertManager::Validate() ...@@ -250,7 +250,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 )
return err; return err;
const TaoCrypt::PublicKey& key = cert.GetPublicKey(); const TaoCrypt::PublicKey& key = cert.GetPublicKey();
...@@ -266,7 +267,7 @@ int CertManager::Validate() ...@@ -266,7 +267,7 @@ int CertManager::Validate()
TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_); TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
int err = cert.GetError().What(); int err = cert.GetError().What();
if ( err ) if ( err && err != TaoCrypt::SIG_OTHER_E)
return err; return err;
uint sz = cert.GetPublicKey().size(); uint sz = cert.GetPublicKey().size();
...@@ -327,7 +328,6 @@ int CertManager::SetPrivateKey(const x509& key) ...@@ -327,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();
......
...@@ -955,7 +955,7 @@ x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info) ...@@ -955,7 +955,7 @@ x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info)
} }
// get blank line // get blank line
if (fgets(line, sizeof(line), file)) if (fgets(line, sizeof(line), file))
begin = ftell(file); begin = ftell(file);
} }
} }
......
...@@ -50,7 +50,7 @@ void buildClientHello(SSL& ssl, ClientHello& hello) ...@@ -50,7 +50,7 @@ void buildClientHello(SSL& ssl, ClientHello& hello)
hello.suite_len_ = ssl.getSecurity().get_parms().suites_size_; hello.suite_len_ = ssl.getSecurity().get_parms().suites_size_;
memcpy(hello.cipher_suites_, ssl.getSecurity().get_parms().suites_, memcpy(hello.cipher_suites_, ssl.getSecurity().get_parms().suites_,
hello.suite_len_); hello.suite_len_);
hello.comp_len_ = 1; hello.comp_len_ = 1;
hello.set_length(sizeof(ProtocolVersion) + hello.set_length(sizeof(ProtocolVersion) +
RAN_LEN + RAN_LEN +
...@@ -528,8 +528,9 @@ void ProcessOldClientHello(input_buffer& input, SSL& ssl) ...@@ -528,8 +528,9 @@ 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);
return; return;
} }
...@@ -707,7 +708,7 @@ int DoProcessReply(SSL& ssl) ...@@ -707,7 +708,7 @@ int DoProcessReply(SSL& ssl)
{ {
// wait for input if blocking // wait for input if blocking
if (!ssl.useSocket().wait()) { if (!ssl.useSocket().wait()) {
ssl.SetError(receive_error); ssl.SetError(receive_error);
return 0; return 0;
} }
uint ready = ssl.getSocket().get_ready(); uint ready = ssl.getSocket().get_ready();
...@@ -750,8 +751,8 @@ int DoProcessReply(SSL& ssl) ...@@ -750,8 +751,8 @@ int DoProcessReply(SSL& ssl)
if (static_cast<uint>(RECORD_HEADER) > buffer.get_remaining()) if (static_cast<uint>(RECORD_HEADER) > buffer.get_remaining())
needHdr = true; needHdr = true;
else { else {
buffer >> hdr; buffer >> hdr;
ssl.verifyState(hdr); ssl.verifyState(hdr);
} }
// make sure we have enough input in buffer to process this record // make sure we have enough input in buffer to process this record
...@@ -789,9 +790,8 @@ int DoProcessReply(SSL& ssl) ...@@ -789,9 +790,8 @@ int DoProcessReply(SSL& ssl)
void processReply(SSL& ssl) 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
...@@ -913,7 +913,7 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer) ...@@ -913,7 +913,7 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer)
} }
else { else {
if (!ssl.getSecurity().GetContext()->GetSessionCacheOff()) if (!ssl.getSecurity().GetContext()->GetSessionCacheOff())
GetSessions().add(ssl); // store session GetSessions().add(ssl); // store session
if (side == client_end) if (side == client_end)
buildFinished(ssl, ssl.useHashes().use_verify(), server); // server buildFinished(ssl, ssl.useHashes().use_verify(), server); // server
} }
...@@ -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;
...@@ -992,7 +1009,7 @@ int receiveData(SSL& ssl, Data& data, bool peek) ...@@ -992,7 +1009,7 @@ int receiveData(SSL& ssl, Data& data, bool peek)
if (peek) if (peek)
ssl.PeekData(data); ssl.PeekData(data);
else else
ssl.fillData(data); ssl.fillData(data);
ssl.useLog().ShowData(data.get_length()); ssl.useLog().ShowData(data.get_length());
if (ssl.GetError()) return -1; if (ssl.GetError()) return -1;
......
File mode changed from 100644 to 100755
...@@ -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 ||
return 0; get_lastError() == SOCKET_EAGAIN) {
wouldBlock_ = true; // would have blocked this time only
nonBlocking_ = true; // nonblocking, win32 only way to tell
return 0;
}
return static_cast<uint>(-1);
}
pos += sent; pos += sent;
written += sent;
} }
return sz; return sz;
...@@ -140,8 +149,8 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags) ...@@ -140,8 +149,8 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags)
get_lastError() == SOCKET_EAGAIN) { get_lastError() == SOCKET_EAGAIN) {
wouldBlock_ = true; // would have blocked this time only wouldBlock_ = true; // would have blocked this time only
nonBlocking_ = true; // socket nonblocking, win32 only way to tell nonBlocking_ = true; // socket nonblocking, win32 only way to tell
return 0; return 0;
} }
} }
else if (recvd == 0) else if (recvd == 0)
return static_cast<uint>(-1); return static_cast<uint>(-1);
......
...@@ -252,60 +252,73 @@ int SSL_connect(SSL* ssl) ...@@ -252,60 +252,73 @@ 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()) {
case CONNECT_BEGIN : case CONNECT_BEGIN :
sendClientHello(*ssl); sendClientHello(*ssl);
if (!ssl->GetError()) if (!ssl->GetError())
ssl->useStates().UseConnect() = CLIENT_HELLO_SENT; ssl->useStates().UseConnect() = CLIENT_HELLO_SENT;
case CLIENT_HELLO_SENT : case CLIENT_HELLO_SENT :
neededState = ssl->getSecurity().get_resuming() ? neededState = ssl->getSecurity().get_resuming() ?
serverFinishedComplete : serverHelloDoneComplete; serverFinishedComplete : serverHelloDoneComplete;
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;
case FIRST_REPLY_DONE : case FIRST_REPLY_DONE :
if(ssl->getCrypto().get_certManager().sendVerify()) if(ssl->getCrypto().get_certManager().sendVerify())
sendCertificate(*ssl); sendCertificate(*ssl);
if (!ssl->getSecurity().get_resuming()) if (!ssl->getSecurity().get_resuming())
sendClientKeyExchange(*ssl); sendClientKeyExchange(*ssl);
if(ssl->getCrypto().get_certManager().sendVerify()) if(ssl->getCrypto().get_certManager().sendVerify())
sendCertificateVerify(*ssl); sendCertificateVerify(*ssl);
sendChangeCipher(*ssl); sendChangeCipher(*ssl);
sendFinished(*ssl, client_end); sendFinished(*ssl, client_end);
ssl->flushBuffer(); ssl->flushBuffer();
if (!ssl->GetError()) if (!ssl->GetError())
ssl->useStates().UseConnect() = FINISHED_DONE; ssl->useStates().UseConnect() = FINISHED_DONE;
case FINISHED_DONE : case FINISHED_DONE :
if (!ssl->getSecurity().get_resuming()) if (!ssl->getSecurity().get_resuming())
while (ssl->getStates().getClient() < serverFinishedComplete) { while (ssl->getStates().getClient() < serverFinishedComplete) {
if (ssl->GetError()) break; if (ssl->GetError()) break;
processReply(*ssl); processReply(*ssl);
} }
if (!ssl->GetError()) if (!ssl->GetError())
ssl->useStates().UseConnect() = SECOND_REPLY_DONE; ssl->useStates().UseConnect() = SECOND_REPLY_DONE;
case SECOND_REPLY_DONE : case SECOND_REPLY_DONE :
ssl->verifyState(serverFinishedComplete); ssl->verifyState(serverFinishedComplete);
ssl->useLog().ShowTCP(ssl->getSocket().get_fd()); ssl->useLog().ShowTCP(ssl->getSocket().get_fd());
if (ssl->GetError()) { if (ssl->GetError()) {
GetErrors().Add(ssl->GetError()); GetErrors().Add(ssl->GetError());
return SSL_FATAL_ERROR; return SSL_FATAL_ERROR;
} }
return SSL_SUCCESS; return SSL_SUCCESS;
default : default :
return SSL_FATAL_ERROR; // unkown state return SSL_FATAL_ERROR; // unkown state
...@@ -331,27 +344,36 @@ int SSL_accept(SSL* ssl) ...@@ -331,27 +344,36 @@ 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 :
processReply(*ssl); processReply(*ssl);
if (!ssl->GetError()) if (!ssl->GetError())
ssl->useStates().UseAccept() = ACCEPT_FIRST_REPLY_DONE; ssl->useStates().UseAccept() = ACCEPT_FIRST_REPLY_DONE;
case ACCEPT_FIRST_REPLY_DONE : case ACCEPT_FIRST_REPLY_DONE :
sendServerHello(*ssl); sendServerHello(*ssl);
if (!ssl->getSecurity().get_resuming()) { if (!ssl->getSecurity().get_resuming()) {
sendCertificate(*ssl); sendCertificate(*ssl);
if (ssl->getSecurity().get_connection().send_server_key_) if (ssl->getSecurity().get_connection().send_server_key_)
sendServerKeyExchange(*ssl); sendServerKeyExchange(*ssl);
if(ssl->getCrypto().get_certManager().verifyPeer()) if(ssl->getCrypto().get_certManager().verifyPeer())
sendCertificateRequest(*ssl); sendCertificateRequest(*ssl);
sendServerHelloDone(*ssl); sendServerHelloDone(*ssl);
ssl->flushBuffer(); ssl->flushBuffer();
} }
if (!ssl->GetError()) if (!ssl->GetError())
...@@ -359,40 +381,40 @@ int SSL_accept(SSL* ssl) ...@@ -359,40 +381,40 @@ int SSL_accept(SSL* ssl)
case SERVER_HELLO_DONE : case SERVER_HELLO_DONE :
if (!ssl->getSecurity().get_resuming()) { if (!ssl->getSecurity().get_resuming()) {
while (ssl->getStates().getServer() < clientFinishedComplete) { while (ssl->getStates().getServer() < clientFinishedComplete) {
if (ssl->GetError()) break; if (ssl->GetError()) break;
processReply(*ssl); processReply(*ssl);
}
} }
}
if (!ssl->GetError()) if (!ssl->GetError())
ssl->useStates().UseAccept() = ACCEPT_SECOND_REPLY_DONE; ssl->useStates().UseAccept() = ACCEPT_SECOND_REPLY_DONE;
case ACCEPT_SECOND_REPLY_DONE : case ACCEPT_SECOND_REPLY_DONE :
sendChangeCipher(*ssl); sendChangeCipher(*ssl);
sendFinished(*ssl, server_end); sendFinished(*ssl, server_end);
ssl->flushBuffer(); ssl->flushBuffer();
if (!ssl->GetError()) if (!ssl->GetError())
ssl->useStates().UseAccept() = ACCEPT_FINISHED_DONE; ssl->useStates().UseAccept() = ACCEPT_FINISHED_DONE;
case ACCEPT_FINISHED_DONE : case ACCEPT_FINISHED_DONE :
if (ssl->getSecurity().get_resuming()) { if (ssl->getSecurity().get_resuming()) {
while (ssl->getStates().getServer() < clientFinishedComplete) { while (ssl->getStates().getServer() < clientFinishedComplete) {
if (ssl->GetError()) break; if (ssl->GetError()) break;
processReply(*ssl); processReply(*ssl);
} }
} }
if (!ssl->GetError()) if (!ssl->GetError())
ssl->useStates().UseAccept() = ACCEPT_THIRD_REPLY_DONE; ssl->useStates().UseAccept() = ACCEPT_THIRD_REPLY_DONE;
case ACCEPT_THIRD_REPLY_DONE : case ACCEPT_THIRD_REPLY_DONE :
ssl->useLog().ShowTCP(ssl->getSocket().get_fd()); ssl->useLog().ShowTCP(ssl->getSocket().get_fd());
if (ssl->GetError()) { if (ssl->GetError()) {
GetErrors().Add(ssl->GetError()); GetErrors().Add(ssl->GetError());
return SSL_FATAL_ERROR; return SSL_FATAL_ERROR;
} }
return SSL_SUCCESS; return SSL_SUCCESS;
default: default:
return SSL_FATAL_ERROR; // unknown state return SSL_FATAL_ERROR; // unknown state
...@@ -1097,7 +1119,6 @@ int EVP_BytesToKey(const EVP_CIPHER* type, const EVP_MD* md, const byte* salt, ...@@ -1097,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;
} }
......
...@@ -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);
......
...@@ -31,6 +31,11 @@ ...@@ -31,6 +31,11 @@
#pragma warning(disable: 4996) #pragma warning(disable: 4996)
#endif #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 {
...@@ -59,8 +64,9 @@ void SetErrorString(unsigned long error, char* buffer) ...@@ -59,8 +64,9 @@ 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 :
...@@ -121,7 +127,7 @@ void SetErrorString(unsigned long error, char* buffer) ...@@ -121,7 +127,7 @@ void SetErrorString(unsigned long error, char* buffer)
case certificate_error : case certificate_error :
strncpy(buffer, "unable to proccess cerificate", max); strncpy(buffer, "unable to proccess cerificate", max);
break; break;
case privateKey_error : case privateKey_error :
strncpy(buffer, "unable to proccess private key, bad format", max); strncpy(buffer, "unable to proccess private key, bad format", max);
...@@ -130,7 +136,7 @@ void SetErrorString(unsigned long error, char* buffer) ...@@ -130,7 +136,7 @@ void SetErrorString(unsigned long error, char* buffer)
case badVersion_error : case badVersion_error :
strncpy(buffer, "protocol version mismatch", max); strncpy(buffer, "protocol version mismatch", max);
break; break;
case compress_error : case compress_error :
strncpy(buffer, "compression error", max); strncpy(buffer, "compression error", max);
break; break;
...@@ -148,6 +154,10 @@ void SetErrorString(unsigned long error, char* buffer) ...@@ -148,6 +154,10 @@ void SetErrorString(unsigned long 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;
......
...@@ -117,7 +117,7 @@ void ClientDiffieHellmanPublic::build(SSL& ssl) ...@@ -117,7 +117,7 @@ void ClientDiffieHellmanPublic::build(SSL& ssl)
if (*dhClient.get_agreedKey() == 0) if (*dhClient.get_agreedKey() == 0)
ssl.set_preMaster(dhClient.get_agreedKey() + 1, keyLength - 1); ssl.set_preMaster(dhClient.get_agreedKey() + 1, keyLength - 1);
else else
ssl.set_preMaster(dhClient.get_agreedKey(), keyLength); ssl.set_preMaster(dhClient.get_agreedKey(), keyLength);
} }
...@@ -135,8 +135,7 @@ void DH_Server::build(SSL& ssl) ...@@ -135,8 +135,7 @@ void DH_Server::build(SSL& ssl)
mySTL::auto_ptr<Auth> auth; mySTL::auto_ptr<Auth> auth;
const CertManager& cert = ssl.getCrypto().get_certManager(); const CertManager& cert = ssl.getCrypto().get_certManager();
if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) {
{
if (cert.get_keyType() != rsa_sa_algo) { if (cert.get_keyType() != rsa_sa_algo) {
ssl.SetError(privateKey_error); ssl.SetError(privateKey_error);
return; return;
...@@ -925,8 +924,6 @@ Data::Data(uint16 len, opaque* b) ...@@ -925,8 +924,6 @@ Data::Data(uint16 len, opaque* b)
void Data::SetData(uint16 len, const opaque* buffer) void Data::SetData(uint16 len, const opaque* buffer)
{ {
assert(write_buffer_ == 0);
length_ = len; length_ = len;
write_buffer_ = buffer; write_buffer_ = buffer;
} }
...@@ -992,6 +989,11 @@ void Data::Process(input_buffer& input, SSL& ssl) ...@@ -992,6 +989,11 @@ void Data::Process(input_buffer& input, SSL& ssl)
int dataSz = msgSz - ivExtra - digestSz - pad - padSz; int dataSz = msgSz - ivExtra - digestSz - pad - padSz;
opaque verify[SHA_LEN]; opaque verify[SHA_LEN];
if (dataSz < 0) {
ssl.SetError(bad_input);
return;
}
const byte* rawData = input.get_buffer() + input.get_current(); const byte* rawData = input.get_buffer() + input.get_current();
// read data // read data
...@@ -1006,10 +1008,10 @@ void Data::Process(input_buffer& input, SSL& ssl) ...@@ -1006,10 +1008,10 @@ void Data::Process(input_buffer& input, SSL& ssl)
tmp.get_buffer(), tmp.get_size())); tmp.get_buffer(), tmp.get_size()));
} }
else { else {
input_buffer* data; input_buffer* data;
ssl.addData(data = NEW_YS input_buffer(dataSz)); ssl.addData(data = NEW_YS input_buffer(dataSz));
input.read(data->get_buffer(), dataSz); input.read(data->get_buffer(), dataSz);
data->add_size(dataSz); data->add_size(dataSz);
} }
if (ssl.isTLS()) if (ssl.isTLS())
...@@ -1294,12 +1296,11 @@ void ServerHello::Process(input_buffer&, SSL& ssl) ...@@ -1294,12 +1296,11 @@ void ServerHello::Process(input_buffer&, SSL& ssl)
ssl.set_pending(cipher_suite_[1]); ssl.set_pending(cipher_suite_[1]);
ssl.set_random(random_, server_end); ssl.set_random(random_, server_end);
if (id_len_) if (id_len_)
ssl.set_sessionID(session_id_); ssl.set_sessionID(session_id_);
else else
ssl.useSecurity().use_connection().sessionID_Set_ = false; ssl.useSecurity().use_connection().sessionID_Set_ = false;
if (ssl.getSecurity().get_resuming()) if (ssl.getSecurity().get_resuming()) {
{
if (memcmp(session_id_, ssl.getSecurity().get_resume().GetID(), if (memcmp(session_id_, ssl.getSecurity().get_resume().GetID(),
ID_LEN) == 0) { ID_LEN) == 0) {
ssl.set_masterSecret(ssl.getSecurity().get_resume().GetSecret()); ssl.set_masterSecret(ssl.getSecurity().get_resume().GetSecret());
...@@ -1423,7 +1424,7 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello) ...@@ -1423,7 +1424,7 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello)
if (hello.id_len_) input.read(hello.session_id_, ID_LEN); if (hello.id_len_) input.read(hello.session_id_, ID_LEN);
// Suites // Suites
byte tmp[2]; byte tmp[2];
uint16 len; uint16 len;
tmp[0] = input[AUTO]; tmp[0] = input[AUTO];
tmp[1] = input[AUTO]; tmp[1] = input[AUTO];
...@@ -1431,8 +1432,8 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello) ...@@ -1431,8 +1432,8 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello)
hello.suite_len_ = min(len, static_cast<uint16>(MAX_SUITE_SZ)); hello.suite_len_ = min(len, static_cast<uint16>(MAX_SUITE_SZ));
input.read(hello.cipher_suites_, hello.suite_len_); input.read(hello.cipher_suites_, hello.suite_len_);
if (len > hello.suite_len_) // ignore extra suites if (len > hello.suite_len_) // ignore extra suites
input.set_current(input.get_current() + len - hello.suite_len_); input.set_current(input.get_current() + len - hello.suite_len_);
// Compression // Compression
hello.comp_len_ = input[AUTO]; hello.comp_len_ = input[AUTO];
...@@ -1496,8 +1497,9 @@ void ClientHello::Process(input_buffer&, SSL& ssl) ...@@ -1496,8 +1497,9 @@ void ClientHello::Process(input_buffer&, SSL& ssl)
if (ssl.GetMultiProtocol()) { // SSLv23 support if (ssl.GetMultiProtocol()) { // SSLv23 support
if (ssl.isTLS() && client_version_.minor_ < 1) { if (ssl.isTLS() && client_version_.minor_ < 1) {
// downgrade to SSLv3 // downgrade to SSLv3
ssl.useSecurity().use_connection().TurnOffTLS(); ssl.useSecurity().use_connection().TurnOffTLS();
ProtocolVersion pv = ssl.getSecurity().get_connection().version_;
ProtocolVersion pv = ssl.getSecurity().get_connection().version_;
bool removeDH = ssl.getSecurity().get_parms().removeDH_; bool removeDH = ssl.getSecurity().get_parms().removeDH_;
bool removeRSA = false; bool removeRSA = false;
bool removeDSA = false; bool removeDSA = false;
...@@ -1511,7 +1513,7 @@ void ClientHello::Process(input_buffer&, SSL& ssl) ...@@ -1511,7 +1513,7 @@ void ClientHello::Process(input_buffer&, SSL& ssl)
// reset w/ SSL suites // reset w/ SSL suites
ssl.useSecurity().use_parms().SetSuites(pv, removeDH, removeRSA, ssl.useSecurity().use_parms().SetSuites(pv, removeDH, removeRSA,
removeDSA); removeDSA);
} }
else if (ssl.isTLSv1_1() && client_version_.minor_ == 1) else if (ssl.isTLSv1_1() && client_version_.minor_ == 1)
// downgrade to TLSv1, but use same suites // downgrade to TLSv1, but use same suites
ssl.useSecurity().use_connection().TurnOffTLS1_1(); ssl.useSecurity().use_connection().TurnOffTLS1_1();
...@@ -1542,6 +1544,7 @@ void ClientHello::Process(input_buffer&, SSL& ssl) ...@@ -1542,6 +1544,7 @@ void ClientHello::Process(input_buffer&, SSL& ssl)
ssl.set_session(session); ssl.set_session(session);
ssl.useSecurity().set_resuming(true); ssl.useSecurity().set_resuming(true);
ssl.matchSuite(session->GetSuite(), SUITE_LEN); ssl.matchSuite(session->GetSuite(), SUITE_LEN);
if (ssl.GetError()) return;
ssl.set_pending(ssl.getSecurity().get_parms().suite_[1]); ssl.set_pending(ssl.getSecurity().get_parms().suite_[1]);
ssl.set_masterSecret(session->GetSecret()); ssl.set_masterSecret(session->GetSecret());
...@@ -2038,7 +2041,7 @@ void Finished::Process(input_buffer& input, SSL& ssl) ...@@ -2038,7 +2041,7 @@ void Finished::Process(input_buffer& input, SSL& ssl)
// verify hashes // verify hashes
const Finished& verify = ssl.getHashes().get_verify(); const Finished& verify = ssl.getHashes().get_verify();
uint finishedSz = ssl.isTLS() ? TLS_FINISHED_SZ : FINISHED_SZ; uint finishedSz = ssl.isTLS() ? TLS_FINISHED_SZ : FINISHED_SZ;
input.read(hashes_.md5_, finishedSz); input.read(hashes_.md5_, finishedSz);
if (memcmp(&hashes_, &verify.hashes_, finishedSz)) { if (memcmp(&hashes_, &verify.hashes_, finishedSz)) {
......
...@@ -308,7 +308,7 @@ SSL::SSL(SSL_CTX* ctx) ...@@ -308,7 +308,7 @@ SSL::SSL(SSL_CTX* ctx)
SetError(YasslError(err)); SetError(YasslError(err));
return; return;
} }
else if (serverSide && !(ctx->GetCiphers().setSuites_)) { else if (serverSide) {
// remove RSA or DSA suites depending on cert key type // remove RSA or DSA suites depending on cert key type
ProtocolVersion pv = secure_.get_connection().version_; ProtocolVersion pv = secure_.get_connection().version_;
...@@ -1128,8 +1128,28 @@ void SSL::flushBuffer() ...@@ -1128,8 +1128,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;
SetError(send_error);
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);
}
}
void SSL::SendWriteBuffered()
{
output_buffer* out = buffers_.TakeOutput();
if (out) {
mySTL::auto_ptr<output_buffer> tmp(out);
Send(out->get_buffer(), out->get_size());
}
} }
...@@ -1291,7 +1311,6 @@ void SSL::matchSuite(const opaque* peer, uint length) ...@@ -1291,7 +1311,6 @@ void SSL::matchSuite(const opaque* peer, uint length)
if (secure_.use_parms().suites_[i] == peer[j]) { if (secure_.use_parms().suites_[i] == peer[j]) {
secure_.use_parms().suite_[0] = 0x00; secure_.use_parms().suite_[0] = 0x00;
secure_.use_parms().suite_[1] = peer[j]; secure_.use_parms().suite_[1] = peer[j];
return; return;
} }
...@@ -1435,7 +1454,6 @@ void SSL::addBuffer(output_buffer* b) ...@@ -1435,7 +1454,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();
...@@ -1833,7 +1851,7 @@ SSL_CTX::GetCA_List() const ...@@ -1833,7 +1851,7 @@ SSL_CTX::GetCA_List() const
} }
VerifyCallback SSL_CTX::getVerifyCallback() const const VerifyCallback SSL_CTX::getVerifyCallback() const
{ {
return verifyCallback_; return verifyCallback_;
} }
...@@ -2232,7 +2250,7 @@ Hashes& sslHashes::use_certVerify() ...@@ -2232,7 +2250,7 @@ Hashes& sslHashes::use_certVerify()
} }
Buffers::Buffers() : rawInput_(0) Buffers::Buffers() : prevSent(0), plainSz(0), rawInput_(0), output_(0)
{} {}
...@@ -2243,12 +2261,18 @@ Buffers::~Buffers() ...@@ -2243,12 +2261,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;
} }
...@@ -2262,6 +2286,15 @@ input_buffer* Buffers::TakeRawInput() ...@@ -2262,6 +2286,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_;
...@@ -2536,14 +2569,12 @@ ASN1_STRING* StringHolder::GetString() ...@@ -2536,14 +2569,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();
......
...@@ -49,8 +49,8 @@ BSC32=bscmake.exe ...@@ -49,8 +49,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "benchmark - Win32 Debug" !ELSEIF "$(CFG)" == "benchmark - Win32 Debug"
...@@ -64,7 +64,7 @@ LINK32=link.exe ...@@ -64,7 +64,7 @@ LINK32=link.exe
# PROP Output_Dir "Debug" # PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug" # PROP Intermediate_Dir "Debug"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"
...@@ -72,8 +72,8 @@ BSC32=bscmake.exe ...@@ -72,8 +72,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF !ENDIF
......
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; }
......
...@@ -59,11 +59,11 @@ public: ...@@ -59,11 +59,11 @@ public:
void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION); void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION);
void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); } void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }
private: 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 + 4 * 256]; word32 pbox_[ROUNDS + 2 + 4 * 256];
word32* sbox_; 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;
......
...@@ -84,7 +84,7 @@ private: ...@@ -84,7 +84,7 @@ private:
// DES_EDE3 // DES_EDE3
class DES_EDE3 : public Mode_BASE { class DES_EDE3 : public Mode_BASE {
public: public:
DES_EDE3(CipherDir DIR, Mode MODE) DES_EDE3(CipherDir DIR, Mode MODE)
: Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {} : Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}
void SetKey(const byte*, word32, CipherDir dir); void SetKey(const byte*, word32, CipherDir dir);
......
...@@ -63,8 +63,8 @@ protected: ...@@ -63,8 +63,8 @@ protected:
word32 buffLen_; // in bytes word32 buffLen_; // in bytes
HashLengthType loLen_; // length in bytes HashLengthType loLen_; // length in bytes
HashLengthType hiLen_; // length in bytes HashLengthType hiLen_; // length in bytes
word32 digest_[MaxDigestSz]; word32 digest_[MaxDigestSz];
word32 buffer_[MaxBufferSz / sizeof(word32)]; word32 buffer_[MaxBufferSz / sizeof(word32)];
virtual void Transform() = 0; virtual void Transform() = 0;
......
/*
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
...@@ -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"
...@@ -62,30 +61,30 @@ void CleanUp(); ...@@ -62,30 +61,30 @@ void CleanUp();
template<typename T> template<typename T>
void tcDelete(T* ptr) void tcDelete(T* ptr)
{ {
if (ptr) ptr->~T(); if (ptr) ptr->~T();
::operator delete(ptr, TaoCrypt::tc); ::operator delete(ptr, TaoCrypt::tc);
} }
template<typename T> template<typename T>
void tcArrayDelete(T* ptr) void tcArrayDelete(T* ptr)
{ {
// can't do array placement destruction since not tracking size in // can't do array placement destruction since not tracking size in
// allocation, only allow builtins to use array placement since they // allocation, only allow builtins to use array placement since they
// don't need destructors called // don't need destructors called
typedef char builtin[IsFundamentalType<T>::Yes ? 1 : -1]; typedef char builtin[IsFundamentalType<T>::Yes ? 1 : -1];
(void)sizeof(builtin); (void)sizeof(builtin);
::operator delete[](ptr, TaoCrypt::tc); ::operator delete[](ptr, TaoCrypt::tc);
} }
#define NEW_TC new (TaoCrypt::tc) #define NEW_TC new (TaoCrypt::tc)
// 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
...@@ -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,14 +407,12 @@ inline bool IsAligned(const void* p, T* dummy = 0) // VC60 workaround ...@@ -409,14 +407,12 @@ 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));
} }
#ifdef INTEL_INTRINSICS #ifdef INTEL_INTRINSICS
...@@ -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;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#ifdef __sun #ifdef __sun
#include <assert.h>
// Handler for pure virtual functions // Handler for pure virtual functions
namespace __Crun { namespace __Crun {
...@@ -46,9 +45,7 @@ namespace __Crun { ...@@ -46,9 +45,7 @@ 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)); int __cxa_pure_virtual () __attribute__ ((weak));
......
...@@ -62,7 +62,7 @@ typedef unsigned int word32; ...@@ -62,7 +62,7 @@ typedef unsigned int word32;
// compilers we've found 64-bit multiply insructions for // compilers we've found 64-bit multiply insructions for
#if defined(__GNUC__) || defined(_MSC_VER) || defined(__DECCXX) #if defined(__GNUC__) || defined(_MSC_VER) || defined(__DECCXX)
#if !(defined(__ICC) || defined(__INTEL_COMPILER)) #if !(defined(__ICC) || defined(__INTEL_COMPILER))
#define HAVE_64_MULTIPLY #define HAVE_64_MULTIPLY
#endif #endif
#endif #endif
......
...@@ -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,9 +140,9 @@ private: ...@@ -141,9 +140,9 @@ 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@
......
...@@ -78,7 +78,7 @@ void AES::Process(byte* out, const byte* in, word32 sz) ...@@ -78,7 +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
...@@ -86,8 +86,13 @@ void AES::Process(byte* out, const byte* in, word32 sz) ...@@ -86,8 +86,13 @@ 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;
word32 temp, *rk = key_; word32 temp, *rk = key_;
...@@ -245,34 +250,34 @@ void AES::encrypt(const byte* inBlock, const byte* xorBlock, ...@@ -245,34 +250,34 @@ void AES::encrypt(const byte* inBlock, const byte* xorBlock,
for (;;) { for (;;) {
t0 = t0 =
Te0[GETBYTE(s0, 3)] ^ Te0[GETBYTE(s0, 3)] ^
Te1[GETBYTE(s1, 2)] ^ Te1[GETBYTE(s1, 2)] ^
Te2[GETBYTE(s2, 1)] ^ Te2[GETBYTE(s2, 1)] ^
Te3[GETBYTE(s3, 0)] ^ Te3[GETBYTE(s3, 0)] ^
rk[4]; rk[4];
t1 = t1 =
Te0[GETBYTE(s1, 3)] ^ Te0[GETBYTE(s1, 3)] ^
Te1[GETBYTE(s2, 2)] ^ Te1[GETBYTE(s2, 2)] ^
Te2[GETBYTE(s3, 1)] ^ Te2[GETBYTE(s3, 1)] ^
Te3[GETBYTE(s0, 0)] ^ Te3[GETBYTE(s0, 0)] ^
rk[5]; rk[5];
t2 = t2 =
Te0[GETBYTE(s2, 3)] ^ Te0[GETBYTE(s2, 3)] ^
Te1[GETBYTE(s3, 2)] ^ Te1[GETBYTE(s3, 2)] ^
Te2[GETBYTE(s0, 1)] ^ Te2[GETBYTE(s0, 1)] ^
Te3[GETBYTE(s1, 0)] ^ Te3[GETBYTE(s1, 0)] ^
rk[6]; rk[6];
t3 = t3 =
Te0[GETBYTE(s3, 3)] ^ Te0[GETBYTE(s3, 3)] ^
Te1[GETBYTE(s0, 2)] ^ Te1[GETBYTE(s0, 2)] ^
Te2[GETBYTE(s1, 1)] ^ Te2[GETBYTE(s1, 1)] ^
Te3[GETBYTE(s2, 0)] ^ Te3[GETBYTE(s2, 0)] ^
rk[7]; rk[7];
rk += 8; rk += 8;
if (--r == 0) { if (--r == 0) {
break; break;
} }
s0 = s0 =
Te0[GETBYTE(t0, 3)] ^ Te0[GETBYTE(t0, 3)] ^
Te1[GETBYTE(t1, 2)] ^ Te1[GETBYTE(t1, 2)] ^
...@@ -421,7 +426,7 @@ void AES::decrypt(const byte* inBlock, const byte* xorBlock, ...@@ -421,7 +426,7 @@ void AES::decrypt(const byte* inBlock, const byte* xorBlock,
(Td4[GETBYTE(t3, 2)] & 0x00ff0000) ^ (Td4[GETBYTE(t3, 2)] & 0x00ff0000) ^
(Td4[GETBYTE(t2, 1)] & 0x0000ff00) ^ (Td4[GETBYTE(t2, 1)] & 0x0000ff00) ^
(Td4[GETBYTE(t1, 0)] & 0x000000ff) ^ (Td4[GETBYTE(t1, 0)] & 0x000000ff) ^
rk[0]; rk[0];
s1 = s1 =
(Td4[GETBYTE(t1, 3)] & 0xff000000) ^ (Td4[GETBYTE(t1, 3)] & 0xff000000) ^
(Td4[GETBYTE(t0, 2)] & 0x00ff0000) ^ (Td4[GETBYTE(t0, 2)] & 0x00ff0000) ^
......
...@@ -33,6 +33,4 @@ const word32 AES::rcon_[] = { ...@@ -33,6 +33,4 @@ const word32 AES::rcon_[] = {
}; };
} // namespace } // namespace
...@@ -247,7 +247,6 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base, ...@@ -247,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());
...@@ -288,7 +287,7 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base, ...@@ -288,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]);
......
...@@ -104,7 +104,7 @@ void ARC4::Process(byte* out, const byte* in, word32 length) ...@@ -104,7 +104,7 @@ void ARC4::Process(byte* out, const byte* in, word32 length)
#ifdef DO_ARC4_ASM #ifdef DO_ARC4_ASM
#ifdef _MSC_VER #ifdef _MSC_VER
__declspec(naked) __declspec(naked)
#else #else
__attribute__ ((noinline)) __attribute__ ((noinline))
#endif #endif
......
This diff is collapsed.
...@@ -86,7 +86,10 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz) ...@@ -86,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};
...@@ -165,16 +168,21 @@ void Blowfish::crypt_block(const word32 in[2], word32 out[2]) const ...@@ -165,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];
...@@ -188,17 +196,23 @@ typedef BlockGetAndPut<word32, BigEndian> gpBlock; ...@@ -188,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];
......
...@@ -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,9 +167,9 @@ void Base64Encoder::Encode() ...@@ -174,9 +167,9 @@ void Base64Encoder::Encode()
} }
encoded_[i++] = '\n'; encoded_[i++] = '\n';
assert(i == outSz);
if (i == outSz)
plain_.reset(encoded_); plain_.reset(encoded_);
} }
...@@ -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);
} }
...@@ -73,15 +70,15 @@ void HASHwithTransform::Update(const byte* data, word32 len) ...@@ -73,15 +70,15 @@ void HASHwithTransform::Update(const byte* data, word32 len)
// Final process, place digest in hash // Final process, place digest in hash
void HASHwithTransform::Final(byte* hash) void HASHwithTransform::Final(byte* hash)
{ {
word32 blockSz = getBlockSize(); word32 blockSz = getBlockSize();
word32 digestSz = getDigestSize(); word32 digestSz = getDigestSize();
word32 padSz = getPadSize(); word32 padSz = getPadSize();
ByteOrder order = getByteOrder(); ByteOrder order = getByteOrder();
AddLength(buffLen_); // before adding pads AddLength(buffLen_); // before adding pads
HashLengthType preLoLen = GetBitCountLo(); HashLengthType preLoLen = GetBitCountLo();
HashLengthType preHiLen = GetBitCountHi(); HashLengthType preHiLen = GetBitCountHi();
byte* local = reinterpret_cast<byte*>(buffer_); byte* local = reinterpret_cast<byte*>(buffer_);
local[buffLen_++] = 0x80; // add 1 local[buffLen_++] = 0x80; // add 1
...@@ -95,7 +92,7 @@ void HASHwithTransform::Final(byte* hash) ...@@ -95,7 +92,7 @@ void HASHwithTransform::Final(byte* hash)
buffLen_ = 0; buffLen_ = 0;
} }
memset(&local[buffLen_], 0, padSz - buffLen_); memset(&local[buffLen_], 0, padSz - buffLen_);
ByteReverseIf(local, local, blockSz, order); ByteReverseIf(local, local, blockSz, order);
memcpy(&local[padSz], order ? &preHiLen : &preLoLen, sizeof(preLoLen)); memcpy(&local[padSz], order ? &preHiLen : &preLoLen, sizeof(preLoLen));
...@@ -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
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "algorithm.hpp" #include "algorithm.hpp"
#endif #endif
namespace STL = STL_NAMESPACE; namespace STL = STL_NAMESPACE;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
namespace STL = STL_NAMESPACE; namespace STL = STL_NAMESPACE;
namespace TaoCrypt { namespace TaoCrypt {
...@@ -108,14 +108,14 @@ void MD5::Update(const byte* data, word32 len) ...@@ -108,14 +108,14 @@ void MD5::Update(const byte* data, word32 len)
// at once for asm // at once for asm
if (buffLen_ == 0) { if (buffLen_ == 0) {
word32 times = len / BLOCK_SIZE; word32 times = len / BLOCK_SIZE;
if (times) { if (times) {
AsmTransform(data, times); AsmTransform(data, times);
const word32 add = BLOCK_SIZE * times; const word32 add = BLOCK_SIZE * times;
AddLength(add); AddLength(add);
len -= add; len -= add;
data += add; data += add;
} }
} }
// cache any data left // cache any data left
......
...@@ -41,28 +41,28 @@ namespace STL = STL_NAMESPACE; ...@@ -41,28 +41,28 @@ namespace STL = STL_NAMESPACE;
void* operator new(size_t sz, TaoCrypt::new_t) void* operator new(size_t sz, TaoCrypt::new_t)
{ {
void* ptr = malloc(sz ? sz : 1); void* ptr = malloc(sz ? sz : 1);
if (!ptr) abort(); if (!ptr) abort();
return ptr; return ptr;
} }
void operator delete(void* ptr, TaoCrypt::new_t) void operator delete(void* ptr, TaoCrypt::new_t)
{ {
if (ptr) free(ptr); if (ptr) free(ptr);
} }
void* operator new[](size_t sz, TaoCrypt::new_t nt) void* operator new[](size_t sz, TaoCrypt::new_t nt)
{ {
return ::operator new(sz, nt); return ::operator new(sz, nt);
} }
void operator delete[](void* ptr, TaoCrypt::new_t nt) void operator delete[](void* ptr, TaoCrypt::new_t nt)
{ {
::operator delete(ptr, nt); ::operator delete(ptr, nt);
} }
...@@ -89,7 +89,6 @@ namespace STL = STL_NAMESPACE; ...@@ -89,7 +89,6 @@ namespace STL = STL_NAMESPACE;
// Handler for pure virtual functions // Handler for pure virtual functions
namespace __Crun { namespace __Crun {
void pure_error() { void pure_error() {
assert(!"Aborted: pure virtual method called.");
} }
} }
...@@ -100,7 +99,6 @@ namespace __Crun { ...@@ -100,7 +99,6 @@ namespace __Crun {
extern "C" { extern "C" {
int __cxa_pure_virtual() { int __cxa_pure_virtual() {
assert(!"Aborted: pure virtual method called.");
return 0; return 0;
} }
...@@ -196,8 +194,8 @@ bool HaveCpuId() ...@@ -196,8 +194,8 @@ bool HaveCpuId()
return true; return true;
#else #else
word32 eax, ebx; word32 eax, ebx;
__asm__ __volatile __asm__ __volatile
( (
/* Put EFLAGS in eax and ebx */ /* Put EFLAGS in eax and ebx */
"pushf;" "pushf;"
"pushf;" "pushf;"
...@@ -214,9 +212,9 @@ bool HaveCpuId() ...@@ -214,9 +212,9 @@ bool HaveCpuId()
"pop %0;" "pop %0;"
"popf" "popf"
: "=r" (eax), "=r" (ebx) : "=r" (eax), "=r" (ebx)
: :
: "cc" : "cc"
); );
if (eax == ebx) if (eax == ebx)
return false; return false;
......
/*
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
...@@ -96,13 +96,13 @@ void OS_Seed::GenerateSeed(byte* output, word32 sz) ...@@ -96,13 +96,13 @@ void OS_Seed::GenerateSeed(byte* output, word32 sz)
/* The default OS_Seed implementation */ /* The default OS_Seed implementation */
OS_Seed::OS_Seed() OS_Seed::OS_Seed()
{ {
fd_ = open("/dev/urandom",O_RDONLY); fd_ = open("/dev/urandom",O_RDONLY);
if (fd_ == -1) { if (fd_ == -1) {
fd_ = open("/dev/random",O_RDONLY); fd_ = open("/dev/random",O_RDONLY);
if (fd_ == -1) if (fd_ == -1)
error_.SetError(OPEN_RAN_E); error_.SetError(OPEN_RAN_E);
} }
} }
......
...@@ -110,14 +110,14 @@ void RIPEMD160::Update(const byte* data, word32 len) ...@@ -110,14 +110,14 @@ void RIPEMD160::Update(const byte* data, word32 len)
// all at once for asm // all at once for asm
if (buffLen_ == 0) { if (buffLen_ == 0) {
word32 times = len / BLOCK_SIZE; word32 times = len / BLOCK_SIZE;
if (times) { if (times) {
AsmTransform(data, times); AsmTransform(data, times);
const word32 add = BLOCK_SIZE * times; const word32 add = BLOCK_SIZE * times;
AddLength(add); AddLength(add);
len -= add; len -= add;
data += add; data += add;
} }
} }
// cache any data left // cache any data left
......
...@@ -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;
......
...@@ -344,14 +344,14 @@ void SHA::Update(const byte* data, word32 len) ...@@ -344,14 +344,14 @@ void SHA::Update(const byte* data, word32 len)
// all at once for asm // all at once for asm
if (buffLen_ == 0) { if (buffLen_ == 0) {
word32 times = len / BLOCK_SIZE; word32 times = len / BLOCK_SIZE;
if (times) { if (times) {
AsmTransform(data, times); AsmTransform(data, times);
const word32 add = BLOCK_SIZE * times; const word32 add = BLOCK_SIZE * times;
AddLength(add); AddLength(add);
len -= add; len -= add;
data += add; data += add;
} }
} }
// cache any data left // cache any data left
......
...@@ -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 {
......
...@@ -140,8 +140,6 @@ inline word32 Twofish::h(word32 x, const word32* key, unsigned int kLen) ...@@ -140,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);
} }
...@@ -176,7 +182,7 @@ byte* cipher = 0; // block output ...@@ -176,7 +182,7 @@ byte* cipher = 0; // block output
void taocrypt_test(void* args) void taocrypt_test(void* args)
{ {
((func_args*)args)->return_code = -1; // error state ((func_args*)args)->return_code = -1; // error state
msg = NEW_TC byte[24]; msg = NEW_TC byte[24];
plain = NEW_TC byte[24]; plain = NEW_TC byte[24];
cipher = NEW_TC byte[24]; cipher = NEW_TC byte[24];
...@@ -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,16 +336,16 @@ void taocrypt_test(void* args) ...@@ -320,16 +336,16 @@ 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];
if( !( f = fopen( file, "rb" ) )) { if( !( f = fopen( file, "rb" ) )) {
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
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "runtime.hpp" #include "runtime.hpp"
#include "openssl/ssl.h" /* openssl compatibility test */ #include "openssl/ssl.h" /* openssl compatibility test */
#include "error.hpp"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
...@@ -32,6 +33,10 @@ ...@@ -32,6 +33,10 @@
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
#include <process.h> #include <process.h>
#ifdef TEST_IPV6 // don't require newer SDK for IPV4
#include <ws2tcpip.h>
#include <wspiapi.h>
#endif
#define SOCKET_T unsigned int #define SOCKET_T unsigned int
#else #else
#include <string.h> #include <string.h>
...@@ -42,6 +47,9 @@ ...@@ -42,6 +47,9 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#ifdef TEST_IPV6
#include <netdb.h>
#endif
#include <pthread.h> #include <pthread.h>
#ifdef NON_BLOCKING #ifdef NON_BLOCKING
#include <fcntl.h> #include <fcntl.h>
...@@ -50,6 +58,13 @@ ...@@ -50,6 +58,13 @@
#endif /* _WIN32 */ #endif /* _WIN32 */
#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
#if !defined(_SOCKLEN_T) && (defined(_WIN32) || defined(__APPLE__)) #if !defined(_SOCKLEN_T) && (defined(_WIN32) || defined(__APPLE__))
typedef int socklen_t; typedef int socklen_t;
#endif #endif
...@@ -64,6 +79,15 @@ ...@@ -64,6 +79,15 @@
#endif #endif
#ifdef TEST_IPV6
typedef sockaddr_in6 SOCKADDR_IN_T;
#define AF_INET_V AF_INET6
#else
typedef sockaddr_in SOCKADDR_IN_T;
#define AF_INET_V AF_INET
#endif
// Check if _POSIX_THREADS should be forced // Check if _POSIX_THREADS should be forced
#if !defined(_POSIX_THREADS) && 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
...@@ -73,7 +97,7 @@ ...@@ -73,7 +97,7 @@
#ifndef _POSIX_THREADS #ifndef _POSIX_THREADS
typedef unsigned int THREAD_RETURN; typedef unsigned int THREAD_RETURN;
typedef unsigned long THREAD_TYPE; typedef HANDLE THREAD_TYPE;
#define YASSL_API __stdcall #define YASSL_API __stdcall
#else #else
typedef void* THREAD_RETURN; typedef void* THREAD_RETURN;
...@@ -120,8 +144,8 @@ void start_thread(THREAD_FUNC, func_args*, THREAD_TYPE*); ...@@ -120,8 +144,8 @@ void start_thread(THREAD_FUNC, func_args*, THREAD_TYPE*);
void join_thread(THREAD_TYPE); void join_thread(THREAD_TYPE);
// yaSSL // yaSSL
const char* const yasslIP = "127.0.0.1"; const char* const yasslIP = "127.0.0.1";
const unsigned short yasslPort = 11111; const unsigned short yasslPort = 11111;
// client // client
...@@ -180,7 +204,7 @@ extern "C" { ...@@ -180,7 +204,7 @@ extern "C" {
static int PasswordCallBack(char* passwd, int sz, int rw, void* userdata) static int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
{ {
strncpy(passwd, "12345678", sz); strncpy(passwd, "yassl123", sz);
return 8; return 8;
} }
...@@ -300,14 +324,35 @@ inline void tcp_set_nonblocking(SOCKET_T& sockfd) ...@@ -300,14 +324,35 @@ inline void tcp_set_nonblocking(SOCKET_T& sockfd)
} }
inline void tcp_socket(SOCKET_T& sockfd, sockaddr_in& addr) inline void tcp_socket(SOCKET_T& sockfd, SOCKADDR_IN_T& addr)
{ {
sockfd = socket(AF_INET, SOCK_STREAM, 0); sockfd = socket(AF_INET_V, SOCK_STREAM, 0);
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
#ifdef TEST_IPV6
addr.sin6_family = AF_INET_V;
addr.sin6_port = htons(yasslPort);
addr.sin6_addr = in6addr_loopback;
/* // for external testing later
addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET_V;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
getaddrinfo(yasslIP6, yasslPortStr, &hints, info);
// then use info connect(sockfd, info->ai_addr, info->ai_addrlen)
if (*info == 0)
err_sys("getaddrinfo failed");
*/ // end external testing later
#else
addr.sin_family = AF_INET_V;
addr.sin_port = htons(yasslPort); addr.sin_port = htons(yasslPort);
addr.sin_addr.s_addr = inet_addr(yasslIP); addr.sin_addr.s_addr = inet_addr(yasslIP);
#endif
} }
...@@ -318,13 +363,13 @@ inline void tcp_close(SOCKET_T& sockfd) ...@@ -318,13 +363,13 @@ inline void tcp_close(SOCKET_T& sockfd)
#else #else
close(sockfd); close(sockfd);
#endif #endif
sockfd = -1; sockfd = (SOCKET_T) -1;
} }
inline void tcp_connect(SOCKET_T& sockfd) inline void tcp_connect(SOCKET_T& sockfd)
{ {
sockaddr_in addr; SOCKADDR_IN_T addr;
tcp_socket(sockfd, addr); tcp_socket(sockfd, addr);
if (connect(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) { if (connect(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) {
...@@ -336,9 +381,15 @@ inline void tcp_connect(SOCKET_T& sockfd) ...@@ -336,9 +381,15 @@ inline void tcp_connect(SOCKET_T& sockfd)
inline void tcp_listen(SOCKET_T& sockfd) inline void tcp_listen(SOCKET_T& sockfd)
{ {
sockaddr_in addr; SOCKADDR_IN_T addr;
tcp_socket(sockfd, addr); tcp_socket(sockfd, addr);
#ifndef _WIN32
int on = 1;
socklen_t len = sizeof(on);
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
#endif
if (bind(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) { if (bind(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) {
tcp_close(sockfd); tcp_close(sockfd);
err_sys("tcp bind failed"); err_sys("tcp bind failed");
...@@ -355,7 +406,7 @@ inline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args) ...@@ -355,7 +406,7 @@ inline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args)
{ {
tcp_listen(sockfd); tcp_listen(sockfd);
sockaddr_in client; SOCKADDR_IN_T client;
socklen_t client_len = sizeof(client); socklen_t client_len = sizeof(client);
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) #if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)
...@@ -369,7 +420,7 @@ inline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args) ...@@ -369,7 +420,7 @@ inline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args)
clientfd = accept(sockfd, (sockaddr*)&client, (ACCEPT_THIRD_T)&client_len); clientfd = accept(sockfd, (sockaddr*)&client, (ACCEPT_THIRD_T)&client_len);
if (clientfd == -1) { if (clientfd == (SOCKET_T) -1) {
tcp_close(sockfd); tcp_close(sockfd);
err_sys("tcp accept failed"); err_sys("tcp accept failed");
} }
...@@ -387,10 +438,8 @@ inline void showPeer(SSL* ssl) ...@@ -387,10 +438,8 @@ inline void showPeer(SSL* ssl)
char* issuer = X509_NAME_oneline(X509_get_issuer_name(peer), 0, 0); char* issuer = X509_NAME_oneline(X509_get_issuer_name(peer), 0, 0);
char* subject = X509_NAME_oneline(X509_get_subject_name(peer), 0, 0); char* subject = X509_NAME_oneline(X509_get_subject_name(peer), 0, 0);
printf("peer's cert info:\n"); printf("peer's cert info:\n issuer : %s\n subject: %s\n", issuer,
printf("issuer : %s\n", issuer); subject);
printf("subject: %s\n", subject);
free(subject); free(subject);
free(issuer); free(issuer);
} }
...@@ -436,5 +485,19 @@ inline DH* set_tmpDH(SSL_CTX* ctx) ...@@ -436,5 +485,19 @@ inline DH* set_tmpDH(SSL_CTX* ctx)
} }
inline int verify_callback(int preverify_ok, X509_STORE_CTX* ctx)
{
X509* err_cert = X509_STORE_CTX_get_current_cert(ctx);
int err = X509_STORE_CTX_get_error(ctx);
int depth = X509_STORE_CTX_get_error_depth(ctx);
// test allow self signed
if (err_cert && depth == 0 && err == TaoCrypt::SIG_OTHER_E)
return 1;
return 0;
}
#endif // yaSSL_TEST_HPP #endif // yaSSL_TEST_HPP
...@@ -119,7 +119,7 @@ int main(int argc, char** argv) ...@@ -119,7 +119,7 @@ int main(int argc, char** argv)
void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread) void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
{ {
#ifndef _POSIX_THREADS #ifndef _POSIX_THREADS
*thread = _beginthreadex(0, 0, fun, args, 0, 0); *thread = (HANDLE)_beginthreadex(0, 0, fun, args, 0, 0);
#else #else
pthread_create(thread, 0, fun, args); pthread_create(thread, 0, fun, args);
#endif #endif
...@@ -129,9 +129,9 @@ void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread) ...@@ -129,9 +129,9 @@ void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
void join_thread(THREAD_TYPE thread) void join_thread(THREAD_TYPE thread)
{ {
#ifndef _POSIX_THREADS #ifndef _POSIX_THREADS
int res = WaitForSingleObject(reinterpret_cast<HANDLE>(thread), INFINITE); int res = WaitForSingleObject(thread, INFINITE);
assert(res == WAIT_OBJECT_0); assert(res == WAIT_OBJECT_0);
res = CloseHandle(reinterpret_cast<HANDLE>(thread)); res = CloseHandle(thread);
assert(res); assert(res);
#else #else
pthread_join(thread, 0); pthread_join(thread, 0);
...@@ -158,7 +158,7 @@ int test_openSSL_des() ...@@ -158,7 +158,7 @@ int test_openSSL_des()
{ {
/* test des encrypt/decrypt */ /* test des encrypt/decrypt */
char data[] = "this is my data "; char data[] = "this is my data ";
int dataSz = strlen(data); int dataSz = (int)strlen(data);
DES_key_schedule key[3]; DES_key_schedule key[3];
byte iv[8]; byte iv[8];
EVP_BytesToKey(EVP_des_ede3_cbc(), EVP_md5(), NULL, (byte*)data, dataSz, 1, EVP_BytesToKey(EVP_des_ede3_cbc(), EVP_md5(), NULL, (byte*)data, dataSz, 1,
......
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