Compare commits
136 Commits
OpenSSL_0_
...
OpenSSL_0_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2cb94952a | ||
|
|
0615396d2d | ||
|
|
82877ea449 | ||
|
|
81fae49db9 | ||
|
|
74ff8dc975 | ||
|
|
ac319217d0 | ||
|
|
cdb13ae8d0 | ||
|
|
ab700807d9 | ||
|
|
744b91bb9f | ||
|
|
d69f85bf15 | ||
|
|
52ee969e29 | ||
|
|
55f0501201 | ||
|
|
b2710ee19a | ||
|
|
bbfcc4724d | ||
|
|
c31cc72d79 | ||
|
|
d1049ad93e | ||
|
|
5f4cc234fb | ||
|
|
d31a13953c | ||
|
|
28f5873179 | ||
|
|
8f813338f1 | ||
|
|
6555dfa486 | ||
|
|
5eee0253e5 | ||
|
|
594c723f98 | ||
|
|
f418265865 | ||
|
|
53707e2eec | ||
|
|
fde794e898 | ||
|
|
082f19b42d | ||
|
|
e31c620686 | ||
|
|
570253315f | ||
|
|
5dcdac6e4e | ||
|
|
eea3fce854 | ||
|
|
215c49d032 | ||
|
|
923df53e25 | ||
|
|
1a684d0020 | ||
|
|
dc3b721fa0 | ||
|
|
4479ce9c1c | ||
|
|
4a0d3530e0 | ||
|
|
9907d2992d | ||
|
|
9d9224f184 | ||
|
|
78d4d87e39 | ||
|
|
6211633273 | ||
|
|
3a4cf918bf | ||
|
|
e25eb309ec | ||
|
|
ffa2b2aa7d | ||
|
|
a77a95584d | ||
|
|
68bb98159f | ||
|
|
8e6905d238 | ||
|
|
1a8521ff24 | ||
|
|
9d5460d72d | ||
|
|
35e59297fc | ||
|
|
9b945233b1 | ||
|
|
b065dc2eee | ||
|
|
66c4bb1a70 | ||
|
|
36abe6fe61 | ||
|
|
3c786aa6c8 | ||
|
|
e5cce6d356 | ||
|
|
723b7d81e4 | ||
|
|
a3ddd7358b | ||
|
|
45c027f31f | ||
|
|
3b62e9eb0d | ||
|
|
34a8c7ec87 | ||
|
|
d4a6240005 | ||
|
|
5c6f76da0a | ||
|
|
4636341b05 | ||
|
|
be3b770d8f | ||
|
|
af32387b3f | ||
|
|
115fc340cb | ||
|
|
900f7a8776 | ||
|
|
4877e30504 | ||
|
|
4656ec3852 | ||
|
|
e336441197 | ||
|
|
20d6182f33 | ||
|
|
aa145866f9 | ||
|
|
fdff41e166 | ||
|
|
07b4bc3979 | ||
|
|
0c66d3ae37 | ||
|
|
bd869183d5 | ||
|
|
7e2bf83100 | ||
|
|
25e52a78fb | ||
|
|
47c4bb2ddf | ||
|
|
951dfbb13a | ||
|
|
81780a3b62 | ||
|
|
c574d0cdf2 | ||
|
|
c987c3f999 | ||
|
|
1a5e414863 | ||
|
|
ec3639385e | ||
|
|
f01cfca6a4 | ||
|
|
7d5af5e0fa | ||
|
|
8fdb296cbd | ||
|
|
879b30aaa3 | ||
|
|
40ddcb717a | ||
|
|
da1841a075 | ||
|
|
0a0a10d127 | ||
|
|
df20b6e79b | ||
|
|
f4f1dc39e0 | ||
|
|
340b4dd7df | ||
|
|
4b9dcd821f | ||
|
|
669c5c9380 | ||
|
|
7f9aa6c59b | ||
|
|
d9c06b56ca | ||
|
|
d045e1d77e | ||
|
|
6d14cc7ec1 | ||
|
|
eb499b2854 | ||
|
|
65a82ef6d7 | ||
|
|
616f581650 | ||
|
|
57e802656f | ||
|
|
5d7f15daf8 | ||
|
|
ec67e3b7e4 | ||
|
|
0d3ff3c073 | ||
|
|
325e48867c | ||
|
|
8de95bc05b | ||
|
|
5e3003bb52 | ||
|
|
e6e3f38bfa | ||
|
|
aa17ab7e57 | ||
|
|
35908bd040 | ||
|
|
4a9cfd763e | ||
|
|
0e73294e26 | ||
|
|
b610f46bae | ||
|
|
1921a1adb2 | ||
|
|
6d2cd23f40 | ||
|
|
14fb67f28a | ||
|
|
c552680473 | ||
|
|
edbf9f878d | ||
|
|
2745ddfc33 | ||
|
|
808606034a | ||
|
|
e18eef3d7a | ||
|
|
e78fc11a95 | ||
|
|
83231cb376 | ||
|
|
986ad56124 | ||
|
|
b723a7b11b | ||
|
|
1b6b67b17e | ||
|
|
1ee3236f72 | ||
|
|
b03a4917be | ||
|
|
84971b39f5 | ||
|
|
5ab3e743f3 | ||
|
|
1c5dc844e7 |
242
CHANGES
242
CHANGES
@@ -2,6 +2,149 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 0.9.8d and 0.9.8e [23 Feb 2007]
|
||||
|
||||
*) Include "!eNULL" in SSL_DEFAULT_CIPHER_LIST to make sure that
|
||||
a ciphersuite string such as "DEFAULT:RSA" cannot enable
|
||||
authentication-only ciphersuites.
|
||||
[Bodo Moeller]
|
||||
|
||||
*) Since AES128 and AES256 (and similarly Camellia128 and
|
||||
Camellia256) share a single mask bit in the logic of
|
||||
ssl/ssl_ciph.c, the code for masking out disabled ciphers needs a
|
||||
kludge to work properly if AES128 is available and AES256 isn't
|
||||
(or if Camellia128 is available and Camellia256 isn't).
|
||||
[Victor Duchovni]
|
||||
|
||||
*) Fix the BIT STRING encoding generated by crypto/ec/ec_asn1.c
|
||||
(within i2d_ECPrivateKey, i2d_ECPKParameters, i2d_ECParameters):
|
||||
When a point or a seed is encoded in a BIT STRING, we need to
|
||||
prevent the removal of trailing zero bits to get the proper DER
|
||||
encoding. (By default, crypto/asn1/a_bitstr.c assumes the case
|
||||
of a NamedBitList, for which trailing 0 bits need to be removed.)
|
||||
[Bodo Moeller]
|
||||
|
||||
*) Have SSL/TLS server implementation tolerate "mismatched" record
|
||||
protocol version while receiving ClientHello even if the
|
||||
ClientHello is fragmented. (The server can't insist on the
|
||||
particular protocol version it has chosen before the ServerHello
|
||||
message has informed the client about his choice.)
|
||||
[Bodo Moeller]
|
||||
|
||||
*) Add RFC 3779 support.
|
||||
[Rob Austein for ARIN, Ben Laurie]
|
||||
|
||||
*) Load error codes if they are not already present instead of using a
|
||||
static variable. This allows them to be cleanly unloaded and reloaded.
|
||||
Improve header file function name parsing.
|
||||
[Steve Henson]
|
||||
|
||||
*) extend SMTP and IMAP protocol emulation in s_client to use EHLO
|
||||
or CAPABILITY handshake as required by RFCs.
|
||||
[Goetz Babin-Ebell]
|
||||
|
||||
Changes between 0.9.8c and 0.9.8d [28 Sep 2006]
|
||||
|
||||
*) Introduce limits to prevent malicious keys being able to
|
||||
cause a denial of service. (CVE-2006-2940)
|
||||
[Steve Henson, Bodo Moeller]
|
||||
|
||||
*) Fix ASN.1 parsing of certain invalid structures that can result
|
||||
in a denial of service. (CVE-2006-2937) [Steve Henson]
|
||||
|
||||
*) Fix buffer overflow in SSL_get_shared_ciphers() function.
|
||||
(CVE-2006-3738) [Tavis Ormandy and Will Drewry, Google Security Team]
|
||||
|
||||
*) Fix SSL client code which could crash if connecting to a
|
||||
malicious SSLv2 server. (CVE-2006-4343)
|
||||
[Tavis Ormandy and Will Drewry, Google Security Team]
|
||||
|
||||
*) Since 0.9.8b, ciphersuite strings naming explicit ciphersuites
|
||||
match only those. Before that, "AES256-SHA" would be interpreted
|
||||
as a pattern and match "AES128-SHA" too (since AES128-SHA got
|
||||
the same strength classification in 0.9.7h) as we currently only
|
||||
have a single AES bit in the ciphersuite description bitmap.
|
||||
That change, however, also applied to ciphersuite strings such as
|
||||
"RC4-MD5" that intentionally matched multiple ciphersuites --
|
||||
namely, SSL 2.0 ciphersuites in addition to the more common ones
|
||||
from SSL 3.0/TLS 1.0.
|
||||
|
||||
So we change the selection algorithm again: Naming an explicit
|
||||
ciphersuite selects this one ciphersuite, and any other similar
|
||||
ciphersuite (same bitmap) from *other* protocol versions.
|
||||
Thus, "RC4-MD5" again will properly select both the SSL 2.0
|
||||
ciphersuite and the SSL 3.0/TLS 1.0 ciphersuite.
|
||||
|
||||
Since SSL 2.0 does not have any ciphersuites for which the
|
||||
128/256 bit distinction would be relevant, this works for now.
|
||||
The proper fix will be to use different bits for AES128 and
|
||||
AES256, which would have avoided the problems from the beginning;
|
||||
however, bits are scarce, so we can only do this in a new release
|
||||
(not just a patchlevel) when we can change the SSL_CIPHER
|
||||
definition to split the single 'unsigned long mask' bitmap into
|
||||
multiple values to extend the available space.
|
||||
|
||||
[Bodo Moeller]
|
||||
|
||||
Changes between 0.9.8b and 0.9.8c [05 Sep 2006]
|
||||
|
||||
*) Avoid PKCS #1 v1.5 signature attack discovered by Daniel Bleichenbacher
|
||||
(CVE-2006-4339) [Ben Laurie and Google Security Team]
|
||||
|
||||
*) Add AES IGE and biIGE modes.
|
||||
[Ben Laurie]
|
||||
|
||||
*) Change the Unix randomness entropy gathering to use poll() when
|
||||
possible instead of select(), since the latter has some
|
||||
undesirable limitations.
|
||||
[Darryl Miles via Richard Levitte and Bodo Moeller]
|
||||
|
||||
*) Disable "ECCdraft" ciphersuites more thoroughly. Now special
|
||||
treatment in ssl/ssl_ciph.s makes sure that these ciphersuites
|
||||
cannot be implicitly activated as part of, e.g., the "AES" alias.
|
||||
However, please upgrade to OpenSSL 0.9.9[-dev] for
|
||||
non-experimental use of the ECC ciphersuites to get TLS extension
|
||||
support, which is required for curve and point format negotiation
|
||||
to avoid potential handshake problems.
|
||||
[Bodo Moeller]
|
||||
|
||||
*) Disable rogue ciphersuites:
|
||||
|
||||
- SSLv2 0x08 0x00 0x80 ("RC4-64-MD5")
|
||||
- SSLv3/TLSv1 0x00 0x61 ("EXP1024-RC2-CBC-MD5")
|
||||
- SSLv3/TLSv1 0x00 0x60 ("EXP1024-RC4-MD5")
|
||||
|
||||
The latter two were purportedly from
|
||||
draft-ietf-tls-56-bit-ciphersuites-0[01].txt, but do not really
|
||||
appear there.
|
||||
|
||||
Also deactivate the remaining ciphersuites from
|
||||
draft-ietf-tls-56-bit-ciphersuites-01.txt. These are just as
|
||||
unofficial, and the ID has long expired.
|
||||
[Bodo Moeller]
|
||||
|
||||
*) Fix RSA blinding Heisenbug (problems sometimes occured on
|
||||
dual-core machines) and other potential thread-safety issues.
|
||||
[Bodo Moeller]
|
||||
|
||||
*) Add the symmetric cipher Camellia (128-bit, 192-bit, 256-bit key
|
||||
versions), which is now available for royalty-free use
|
||||
(see http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html).
|
||||
Also, add Camellia TLS ciphersuites from RFC 4132.
|
||||
|
||||
To minimize changes between patchlevels in the OpenSSL 0.9.8
|
||||
series, Camellia remains excluded from compilation unless OpenSSL
|
||||
is configured with 'enable-camellia'.
|
||||
[NTT]
|
||||
|
||||
*) Disable the padding bug check when compression is in use. The padding
|
||||
bug check assumes the first packet is of even length, this is not
|
||||
necessarily true if compresssion is enabled and can result in false
|
||||
positives causing handshake failure. The actual bug test is ancient
|
||||
code so it is hoped that implementations will either have fixed it by
|
||||
now or any which still have the bug do not support compression.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 0.9.8a and 0.9.8b [04 May 2006]
|
||||
|
||||
*) When applying a cipher rule check to see if string match is an explicit
|
||||
@@ -84,6 +227,9 @@
|
||||
|
||||
Changes between 0.9.7h and 0.9.8 [05 Jul 2005]
|
||||
|
||||
[NB: OpenSSL 0.9.7i and later 0.9.7 patch levels were released after
|
||||
OpenSSL 0.9.8.]
|
||||
|
||||
*) Add libcrypto.pc and libssl.pc for those who feel they need them.
|
||||
[Richard Levitte]
|
||||
|
||||
@@ -901,6 +1047,102 @@
|
||||
differing sizes.
|
||||
[Richard Levitte]
|
||||
|
||||
Changes between 0.9.7l and 0.9.7m [xx XXX xxxx]
|
||||
|
||||
*) Cleanse PEM buffers before freeing them since they may contain
|
||||
sensitive data.
|
||||
[Benjamin Bennett <ben@psc.edu>]
|
||||
|
||||
*) Include "!eNULL" in SSL_DEFAULT_CIPHER_LIST to make sure that
|
||||
a ciphersuite string such as "DEFAULT:RSA" cannot enable
|
||||
authentication-only ciphersuites.
|
||||
[Bodo Moeller]
|
||||
|
||||
*) Since AES128 and AES256 share a single mask bit in the logic of
|
||||
ssl/ssl_ciph.c, the code for masking out disabled ciphers needs a
|
||||
kludge to work properly if AES128 is available and AES256 isn't.
|
||||
[Victor Duchovni]
|
||||
|
||||
*) Have SSL/TLS server implementation tolerate "mismatched" record
|
||||
protocol version while receiving ClientHello even if the
|
||||
ClientHello is fragmented. (The server can't insist on the
|
||||
particular protocol version it has chosen before the ServerHello
|
||||
message has informed the client about his choice.)
|
||||
[Bodo Moeller]
|
||||
|
||||
*) Load error codes if they are not already present instead of using a
|
||||
static variable. This allows them to be cleanly unloaded and reloaded.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 0.9.7k and 0.9.7l [28 Sep 2006]
|
||||
|
||||
*) Introduce limits to prevent malicious keys being able to
|
||||
cause a denial of service. (CVE-2006-2940)
|
||||
[Steve Henson, Bodo Moeller]
|
||||
|
||||
*) Fix ASN.1 parsing of certain invalid structures that can result
|
||||
in a denial of service. (CVE-2006-2937) [Steve Henson]
|
||||
|
||||
*) Fix buffer overflow in SSL_get_shared_ciphers() function.
|
||||
(CVE-2006-3738) [Tavis Ormandy and Will Drewry, Google Security Team]
|
||||
|
||||
*) Fix SSL client code which could crash if connecting to a
|
||||
malicious SSLv2 server. (CVE-2006-4343)
|
||||
[Tavis Ormandy and Will Drewry, Google Security Team]
|
||||
|
||||
*) Change ciphersuite string processing so that an explicit
|
||||
ciphersuite selects this one ciphersuite (so that "AES256-SHA"
|
||||
will no longer include "AES128-SHA"), and any other similar
|
||||
ciphersuite (same bitmap) from *other* protocol versions (so that
|
||||
"RC4-MD5" will still include both the SSL 2.0 ciphersuite and the
|
||||
SSL 3.0/TLS 1.0 ciphersuite). This is a backport combining
|
||||
changes from 0.9.8b and 0.9.8d.
|
||||
[Bodo Moeller]
|
||||
|
||||
Changes between 0.9.7j and 0.9.7k [05 Sep 2006]
|
||||
|
||||
*) Avoid PKCS #1 v1.5 signature attack discovered by Daniel Bleichenbacher
|
||||
(CVE-2006-4339) [Ben Laurie and Google Security Team]
|
||||
|
||||
*) Change the Unix randomness entropy gathering to use poll() when
|
||||
possible instead of select(), since the latter has some
|
||||
undesirable limitations.
|
||||
[Darryl Miles via Richard Levitte and Bodo Moeller]
|
||||
|
||||
*) Disable rogue ciphersuites:
|
||||
|
||||
- SSLv2 0x08 0x00 0x80 ("RC4-64-MD5")
|
||||
- SSLv3/TLSv1 0x00 0x61 ("EXP1024-RC2-CBC-MD5")
|
||||
- SSLv3/TLSv1 0x00 0x60 ("EXP1024-RC4-MD5")
|
||||
|
||||
The latter two were purportedly from
|
||||
draft-ietf-tls-56-bit-ciphersuites-0[01].txt, but do not really
|
||||
appear there.
|
||||
|
||||
Also deactive the remaining ciphersuites from
|
||||
draft-ietf-tls-56-bit-ciphersuites-01.txt. These are just as
|
||||
unofficial, and the ID has long expired.
|
||||
[Bodo Moeller]
|
||||
|
||||
*) Fix RSA blinding Heisenbug (problems sometimes occured on
|
||||
dual-core machines) and other potential thread-safety issues.
|
||||
[Bodo Moeller]
|
||||
|
||||
Changes between 0.9.7i and 0.9.7j [04 May 2006]
|
||||
|
||||
*) Adapt fipsld and the build system to link against the validated FIPS
|
||||
module in FIPS mode.
|
||||
[Steve Henson]
|
||||
|
||||
*) Fixes for VC++ 2005 build under Windows.
|
||||
[Steve Henson]
|
||||
|
||||
*) Add new Windows build target VC-32-GMAKE for VC++. This uses GNU make
|
||||
from a Windows bash shell such as MSYS. It is autodetected from the
|
||||
"config" script when run from a VC++ environment. Modify standard VC++
|
||||
build to use fipscanister.o from the GNU make build.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 0.9.7h and 0.9.7i [14 Oct 2005]
|
||||
|
||||
*) Wrapped the definition of EVP_MAX_MD_SIZE in a #ifdef OPENSSL_FIPS.
|
||||
|
||||
21
Configure
21
Configure
@@ -155,7 +155,7 @@ my %table=(
|
||||
"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
|
||||
"debug-bodo", "gcc:-DL_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBIO_PAIR_DEBUG -DPEDANTIC -g -march=i486 -pedantic -Wshadow -Wall::-D_REENTRANT:::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
|
||||
"debug-ulf", "gcc:-DTERMIOS -DL_ENDIAN -march=i486 -Wall -DBN_DEBUG -DBN_DEBUG_RAND -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -g -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations:::CYGWIN32:::${no_asm}:win32:cygwin-shared:::.dll",
|
||||
"debug-steve", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -mcpu=i486 -pedantic -Wno-long-long -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared",
|
||||
"debug-steve", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -march=i486 -pedantic -Wno-long-long -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared",
|
||||
"debug-steve-linux-pseudo64", "gcc:-DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DOPENSSL_NO_ASM -g -mcpu=i486 -Wall -Werror -Wshadow -pipe::-D_REENTRANT::-rdynamic -ldl:SIXTY_FOUR_BIT:${no_asm}:dlfcn:linux-shared",
|
||||
"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-noasm","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -DPEDANTIC -ggdb -g3 -mcpu=i486 -pedantic -ansi -Wall -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
@@ -195,7 +195,7 @@ my %table=(
|
||||
|
||||
#### Solaris x86 with Sun C setups
|
||||
"solaris-x86-cc","cc:-fast -O -Xa::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"solaris64-x86_64-cc","cc:-fast -xarch=amd64 -xstrconst -Xa -DL_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK BF_PTR2 DES_INT DES_UNROLL:${no_asm}:dlfcn:solaris-shared:-KPIC:-xarch=amd64 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"solaris64-x86_64-cc","cc:-fast -xarch=amd64 -xstrconst -Xa -DL_ENDIAN::-D_REENTRANT::-lsocket -lnsl -ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK BF_PTR2 DES_INT DES_UNROLL:${x86_64_asm}:dlfcn:solaris-shared:-KPIC:-xarch=amd64 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
|
||||
#### SPARC Solaris with GNU C setups
|
||||
"solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-fPIC:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
@@ -285,7 +285,7 @@ my %table=(
|
||||
# with debugging of the following config.
|
||||
"hpux64-ia64-cc","cc:-Ae +DD64 +O3 +Olit=all -z -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX DES_UNROLL DES_RISC1 DES_INT:${ia64_asm}:dlfcn:hpux-shared:+Z:+DD64 -b:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
# GCC builds...
|
||||
"hpux-ia64-gcc","gcc:-O3 -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX DES_UNROLL DES_RISC1 DES_INT::bn-ia64.o::aes-ia64.o:::sha256-ia64.o sha512-ia64.o::rc4-ia64.o:::dlfcn:hpux-shared:-fpic:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"hpux-ia64-gcc","gcc:-O3 -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX DES_UNROLL DES_RISC1 DES_INT:${ia64_asm}:dlfcn:hpux-shared:-fpic:-shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"hpux64-ia64-gcc","gcc:-mlp64 -O3 -DB_ENDIAN -D_REENTRANT::::-ldl:SIXTY_FOUR_BIT_LONG MD2_CHAR RC4_INDEX DES_UNROLL DES_RISC1 DES_INT:${ia64_asm}:dlfcn:hpux-shared:-fpic:-mlp64 -shared:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
|
||||
# Legacy HPUX 9.X configs...
|
||||
@@ -568,6 +568,7 @@ my $threads=0;
|
||||
my $no_shared=0; # but "no-shared" is default
|
||||
my $zlib=1; # but "no-zlib" is default
|
||||
my $no_krb5=0; # but "no-krb5" is implied unless "--with-krb5-..." is used
|
||||
my $no_rfc3779=1; # but "no-rfc3779" is default
|
||||
my $no_asm=0;
|
||||
my $no_dso=0;
|
||||
my $no_gmp=0;
|
||||
@@ -600,9 +601,11 @@ my $perl;
|
||||
# All of the following is disabled by default (RC5 was enabled before 0.9.8):
|
||||
|
||||
my %disabled = ( # "what" => "comment"
|
||||
"camellia" => "default",
|
||||
"gmp" => "default",
|
||||
"mdc2" => "default",
|
||||
"rc5" => "default",
|
||||
"rfc3779" => "default",
|
||||
"shared" => "default",
|
||||
"zlib" => "default",
|
||||
"zlib-dynamic" => "default"
|
||||
@@ -613,7 +616,7 @@ my %disabled = ( # "what" => "comment"
|
||||
# For symmetry, "disable-..." is a synonym for "no-...".
|
||||
|
||||
# This is what $depflags will look like with the above default:
|
||||
my $default_depflags = "-DOPENSSL_NO_GMP -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 ";
|
||||
my $default_depflags = "-DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_GMP -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 ";
|
||||
|
||||
|
||||
my $no_sse2=0;
|
||||
@@ -918,7 +921,7 @@ foreach (sort (keys %disabled))
|
||||
|
||||
my $IsMK1MF=scalar grep /^$target$/,@MK1MF_Builds;
|
||||
|
||||
$IsMK1MF=1 if ($target eq "mingw" && $^O ne "cygwin");
|
||||
$IsMK1MF=1 if ($target eq "mingw" && $^O ne "cygwin" && !is_msys());
|
||||
|
||||
$exe_ext=".exe" if ($target eq "Cygwin" || $target eq "DJGPP" || $target eq "mingw");
|
||||
$exe_ext=".pm" if ($target =~ /vos/);
|
||||
@@ -1806,3 +1809,11 @@ sub test_sanity
|
||||
print STDERR "No sanity errors detected!\n" if $errorcnt == 0;
|
||||
return $errorcnt;
|
||||
}
|
||||
|
||||
# Attempt to detect MSYS environment
|
||||
|
||||
sub is_msys
|
||||
{
|
||||
return 1 if (exists $ENV{"TERM"} && $ENV{"TERM"} eq "msys");
|
||||
return 0;
|
||||
}
|
||||
|
||||
7
FAQ
7
FAQ
@@ -74,7 +74,7 @@ OpenSSL - Frequently Asked Questions
|
||||
* Which is the current version of OpenSSL?
|
||||
|
||||
The current version is available from <URL: http://www.openssl.org>.
|
||||
OpenSSL 0.9.8b was released on May 4th, 2006.
|
||||
OpenSSL 0.9.8e was released on February 23rd, 2007.
|
||||
|
||||
In addition to the current stable release, you can also access daily
|
||||
snapshots of the OpenSSL development version at <URL:
|
||||
@@ -679,8 +679,9 @@ libraries. If your platform is not one of these, consult the INSTALL
|
||||
file.
|
||||
|
||||
Multi-threaded applications must provide two callback functions to
|
||||
OpenSSL. This is described in the threads(3) manpage.
|
||||
|
||||
OpenSSL by calling CRYPTO_set_locking_callback() and
|
||||
CRYPTO_set_id_callback(). This is described in the threads(3)
|
||||
manpage.
|
||||
|
||||
* I've compiled a program under Windows and it crashes: why?
|
||||
|
||||
|
||||
8
INSTALL
8
INSTALL
@@ -302,10 +302,10 @@
|
||||
Note on shared libraries
|
||||
------------------------
|
||||
|
||||
Shared library is currently an experimental feature. The only reason to
|
||||
have them would be to conserve memory on systems where several program
|
||||
are using OpenSSL. Binary backward compatibility can't be guaranteed
|
||||
before OpenSSL version 1.0.
|
||||
Shared libraries have certain caveats. Binary backward compatibility
|
||||
can't be guaranteed before OpenSSL version 1.0. The only reason to
|
||||
use them would be to conserve memory on systems where several programs
|
||||
are using OpenSSL.
|
||||
|
||||
For some systems, the OpenSSL Configure script knows what is needed to
|
||||
build shared libraries for libcrypto and libssl. On these systems,
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -12,7 +12,7 @@
|
||||
---------------
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
@@ -111,7 +111,7 @@ SHLIBDIRS= crypto ssl
|
||||
SDIRS= \
|
||||
objects \
|
||||
md2 md4 md5 sha mdc2 hmac ripemd \
|
||||
des aes rc2 rc4 rc5 idea bf cast \
|
||||
des aes rc2 rc4 rc5 idea bf cast camellia \
|
||||
bn ec rsa dsa ecdsa dh ecdh dso engine \
|
||||
buffer bio stack lhash rand err \
|
||||
evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \
|
||||
|
||||
@@ -455,7 +455,7 @@ link_o.hpux:
|
||||
@if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).sl; \
|
||||
expr "$(CFLAGS)" : 'DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
|
||||
expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS='-Wl,-Fl'; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
|
||||
29
NEWS
29
NEWS
@@ -5,6 +5,22 @@
|
||||
This file gives a brief overview of the major changes between each OpenSSL
|
||||
release. For more details please read the CHANGES file.
|
||||
|
||||
Major changes between OpenSSL 0.9.8d and OpenSSL 0.9.8e:
|
||||
|
||||
o Various ciphersuite selection fixes.
|
||||
o RFC3779 support.
|
||||
|
||||
Major changes between OpenSSL 0.9.8c and OpenSSL 0.9.8d:
|
||||
|
||||
o Introduce limits to prevent malicious key DoS (CVE-2006-2940)
|
||||
o Fix security issues (CVE-2006-2937, CVE-2006-3737, CVE-2006-4343)
|
||||
o Changes to ciphersuite selection algorithm
|
||||
|
||||
Major changes between OpenSSL 0.9.8b and OpenSSL 0.9.8c:
|
||||
|
||||
o Fix Daniel Bleichenbacher forged signature attack, CVE-2006-4339
|
||||
o New cipher Camellia
|
||||
|
||||
Major changes between OpenSSL 0.9.8a and OpenSSL 0.9.8b:
|
||||
|
||||
o Cipher string fixes.
|
||||
@@ -17,7 +33,7 @@
|
||||
|
||||
Major changes between OpenSSL 0.9.8 and OpenSSL 0.9.8a:
|
||||
|
||||
o Fix potential SSL 2.0 rollback, CAN-2005-2969
|
||||
o Fix potential SSL 2.0 rollback, CVE-2005-2969
|
||||
o Extended Windows CE support
|
||||
|
||||
Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.8:
|
||||
@@ -94,6 +110,15 @@
|
||||
o Added initial support for Win64.
|
||||
o Added alternate pkg-config files.
|
||||
|
||||
Major changes between OpenSSL 0.9.7k and OpenSSL 0.9.7l:
|
||||
|
||||
o Introduce limits to prevent malicious key DoS (CVE-2006-2940)
|
||||
o Fix security issues (CVE-2006-2937, CVE-2006-3737, CVE-2006-4343)
|
||||
|
||||
Major changes between OpenSSL 0.9.7j and OpenSSL 0.9.7k:
|
||||
|
||||
o Fix Daniel Bleichenbacher forged signature attack, CVE-2006-4339
|
||||
|
||||
Major changes between OpenSSL 0.9.7i and OpenSSL 0.9.7j:
|
||||
|
||||
o Visual C++ 2005 fixes.
|
||||
@@ -105,7 +130,7 @@
|
||||
|
||||
Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.7h:
|
||||
|
||||
o Fix SSL 2.0 Rollback, CAN-2005-2969
|
||||
o Fix SSL 2.0 Rollback, CVE-2005-2969
|
||||
o Allow use of fixed-length exponent on DSA signing
|
||||
o Default fixed-window RSA, DSA, DH private-key operations
|
||||
|
||||
|
||||
8
README
8
README
@@ -1,7 +1,7 @@
|
||||
|
||||
OpenSSL 0.9.8b 04 May 2006
|
||||
OpenSSL 0.9.8e 23 Feb 2007
|
||||
|
||||
Copyright (c) 1998-2005 The OpenSSL Project
|
||||
Copyright (c) 1998-2007 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
All rights reserved.
|
||||
|
||||
@@ -113,6 +113,10 @@
|
||||
|
||||
The MDC2 algorithm is patented by IBM.
|
||||
|
||||
NTT and Mitsubishi have patents and pending patents on the Camellia
|
||||
algorithm, but allow use at no charge without requiring an explicit
|
||||
licensing agreement: http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
|
||||
10
STATUS
10
STATUS
@@ -1,13 +1,21 @@
|
||||
|
||||
OpenSSL STATUS Last modified at
|
||||
______________ $Date: 2006/05/04 12:46:40 $
|
||||
______________ $Date: 2007/02/23 12:12:27 $
|
||||
|
||||
DEVELOPMENT STATE
|
||||
|
||||
o OpenSSL 0.9.9: Under development...
|
||||
o OpenSSL 0.9.8e: Released on February 23rd, 2007
|
||||
o OpenSSL 0.9.8d: Released on September 28th, 2006
|
||||
o OpenSSL 0.9.8c: Released on September 5th, 2006
|
||||
o OpenSSL 0.9.8b: Released on May 4th, 2006
|
||||
o OpenSSL 0.9.8a: Released on October 11th, 2005
|
||||
o OpenSSL 0.9.8: Released on July 5th, 2005
|
||||
o OpenSSL 0.9.7m: Released on February 23rd, 2007
|
||||
o OpenSSL 0.9.7l: Released on September 28th, 2006
|
||||
o OpenSSL 0.9.7k: Released on September 5th, 2006
|
||||
o OpenSSL 0.9.7j: Released on May 4th, 2006
|
||||
o OpenSSL 0.9.7i: Released on October 14th, 2005
|
||||
o OpenSSL 0.9.7h: Released on October 11th, 2005
|
||||
o OpenSSL 0.9.7g: Released on April 11th, 2005
|
||||
o OpenSSL 0.9.7f: Released on March 22nd, 2005
|
||||
|
||||
14
TABLE
14
TABLE
@@ -1649,7 +1649,7 @@ $arflags =
|
||||
|
||||
*** debug-steve
|
||||
$cc = gcc
|
||||
$cflags = -DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -mcpu=i486 -pedantic -Wno-long-long -Wall -Werror -Wshadow -pipe
|
||||
$cflags = -DL_ENDIAN -DREF_CHECK -DCONF_DEBUG -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG_ALL -DPEDANTIC -g -march=i486 -pedantic -Wno-long-long -Wall -Werror -Wshadow -pipe
|
||||
$unistd =
|
||||
$thread_cflag = -D_REENTRANT
|
||||
$sys_id =
|
||||
@@ -1982,10 +1982,10 @@ $bn_ops = SIXTY_FOUR_BIT MD2_CHAR RC4_INDEX DES_UNROLL DES_RISC1 DES_INT
|
||||
$cpuid_obj =
|
||||
$bn_obj = bn-ia64.o
|
||||
$des_obj =
|
||||
$aes_obj = aes-ia64.o
|
||||
$aes_obj = aes_core.o aes_cbc.o aes-ia64.o
|
||||
$bf_obj =
|
||||
$md5_obj =
|
||||
$sha1_obj = sha256-ia64.o sha512-ia64.o
|
||||
$sha1_obj = sha1-ia64.o sha256-ia64.o sha512-ia64.o
|
||||
$cast_obj =
|
||||
$rc4_obj = rc4-ia64.o
|
||||
$rmd160_obj =
|
||||
@@ -3680,15 +3680,15 @@ $thread_cflag = -D_REENTRANT
|
||||
$sys_id =
|
||||
$lflags = -lsocket -lnsl -ldl
|
||||
$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK BF_PTR2 DES_INT DES_UNROLL
|
||||
$cpuid_obj =
|
||||
$bn_obj =
|
||||
$cpuid_obj = x86_64cpuid.o
|
||||
$bn_obj = x86_64-gcc.o
|
||||
$des_obj =
|
||||
$aes_obj =
|
||||
$bf_obj =
|
||||
$md5_obj =
|
||||
$md5_obj = md5-x86_64.o
|
||||
$sha1_obj =
|
||||
$cast_obj =
|
||||
$rc4_obj =
|
||||
$rc4_obj = rc4-x86_64.o
|
||||
$rmd160_obj =
|
||||
$rc5_obj =
|
||||
$dso_scheme = dlfcn
|
||||
|
||||
@@ -290,14 +290,15 @@ dgst.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
|
||||
dgst.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
|
||||
dgst.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
|
||||
dgst.o: ../include/openssl/err.h ../include/openssl/evp.h
|
||||
dgst.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
|
||||
dgst.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
|
||||
dgst.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
|
||||
dgst.o: ../include/openssl/pem.h ../include/openssl/pem2.h
|
||||
dgst.o: ../include/openssl/pkcs7.h ../include/openssl/safestack.h
|
||||
dgst.o: ../include/openssl/sha.h ../include/openssl/stack.h
|
||||
dgst.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
|
||||
dgst.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h dgst.c
|
||||
dgst.o: ../include/openssl/hmac.h ../include/openssl/lhash.h
|
||||
dgst.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
|
||||
dgst.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
dgst.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
|
||||
dgst.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
|
||||
dgst.o: ../include/openssl/safestack.h ../include/openssl/sha.h
|
||||
dgst.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
||||
dgst.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
|
||||
dgst.o: ../include/openssl/x509_vfy.h apps.h dgst.c
|
||||
dh.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
|
||||
dh.o: ../include/openssl/bn.h ../include/openssl/buffer.h
|
||||
dh.o: ../include/openssl/conf.h ../include/openssl/crypto.h
|
||||
|
||||
@@ -1520,6 +1520,7 @@ err:
|
||||
if (x509) X509_free(x509);
|
||||
X509_CRL_free(crl);
|
||||
NCONF_free(conf);
|
||||
NCONF_free(extconf);
|
||||
OBJ_cleanup();
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
|
||||
48
apps/dgst.c
48
apps/dgst.c
@@ -66,6 +66,7 @@
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
#undef BUFSIZE
|
||||
#define BUFSIZE 1024*8
|
||||
@@ -75,7 +76,7 @@
|
||||
|
||||
int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
EVP_PKEY *key, unsigned char *sigin, int siglen, const char *title,
|
||||
const char *file);
|
||||
const char *file,BIO *bmd,const char *hmac_key);
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
@@ -104,6 +105,7 @@ int MAIN(int argc, char **argv)
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
char *engine=NULL;
|
||||
#endif
|
||||
char *hmac_key=NULL;
|
||||
|
||||
apps_startup();
|
||||
|
||||
@@ -188,6 +190,12 @@ int MAIN(int argc, char **argv)
|
||||
out_bin = 1;
|
||||
else if (strcmp(*argv,"-d") == 0)
|
||||
debug=1;
|
||||
else if (!strcmp(*argv,"-hmac"))
|
||||
{
|
||||
if (--argc < 1)
|
||||
break;
|
||||
hmac_key=*++argv;
|
||||
}
|
||||
else if ((m=EVP_get_digestbyname(&((*argv)[1]))) != NULL)
|
||||
md=m;
|
||||
else
|
||||
@@ -261,7 +269,7 @@ int MAIN(int argc, char **argv)
|
||||
{
|
||||
BIO_set_callback(in,BIO_debug_callback);
|
||||
/* needed for windows 3.1 */
|
||||
BIO_set_callback_arg(in,bio_err);
|
||||
BIO_set_callback_arg(in,(char *)bio_err);
|
||||
}
|
||||
|
||||
if(!app_passwd(bio_err, passargin, NULL, &passin, NULL))
|
||||
@@ -358,7 +366,7 @@ int MAIN(int argc, char **argv)
|
||||
{
|
||||
BIO_set_fp(in,stdin,BIO_NOCLOSE);
|
||||
err=do_fp(out, buf,inp,separator, out_bin, sigkey, sigbuf,
|
||||
siglen,"","(stdin)");
|
||||
siglen,"","(stdin)",bmd,hmac_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -376,14 +384,15 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
if(!out_bin)
|
||||
{
|
||||
size_t len = strlen(name)+strlen(argv[i])+5;
|
||||
size_t len = strlen(name)+strlen(argv[i])+(hmac_key ? 5 : 0)+5;
|
||||
tmp=tofree=OPENSSL_malloc(len);
|
||||
BIO_snprintf(tmp,len,"%s(%s)= ",name,argv[i]);
|
||||
BIO_snprintf(tmp,len,"%s%s(%s)= ",
|
||||
hmac_key ? "HMAC-" : "",name,argv[i]);
|
||||
}
|
||||
else
|
||||
tmp="";
|
||||
r=do_fp(out,buf,inp,separator,out_bin,sigkey,sigbuf,
|
||||
siglen,tmp,argv[i]);
|
||||
siglen,tmp,argv[i],bmd,hmac_key);
|
||||
if(r)
|
||||
err=r;
|
||||
if(tofree)
|
||||
@@ -410,11 +419,23 @@ end:
|
||||
|
||||
int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
EVP_PKEY *key, unsigned char *sigin, int siglen, const char *title,
|
||||
const char *file)
|
||||
const char *file,BIO *bmd,const char *hmac_key)
|
||||
{
|
||||
int len;
|
||||
unsigned int len;
|
||||
int i;
|
||||
EVP_MD_CTX *md_ctx;
|
||||
HMAC_CTX hmac_ctx;
|
||||
|
||||
if (hmac_key)
|
||||
{
|
||||
EVP_MD *md;
|
||||
|
||||
BIO_get_md(bmd,&md);
|
||||
HMAC_CTX_init(&hmac_ctx);
|
||||
HMAC_Init_ex(&hmac_ctx,hmac_key,strlen(hmac_key),md, NULL);
|
||||
BIO_get_md_ctx(bmd,&md_ctx);
|
||||
BIO_set_md_ctx(bmd,&hmac_ctx.md_ctx);
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
i=BIO_read(bp,(char *)buf,BUFSIZE);
|
||||
@@ -457,6 +478,11 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(hmac_key)
|
||||
{
|
||||
HMAC_Final(&hmac_ctx,buf,&len);
|
||||
HMAC_CTX_cleanup(&hmac_ctx);
|
||||
}
|
||||
else
|
||||
len=BIO_gets(bp,(char *)buf,BUFSIZE);
|
||||
|
||||
@@ -464,7 +490,7 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
else
|
||||
{
|
||||
BIO_write(out,title,strlen(title));
|
||||
for (i=0; i<len; i++)
|
||||
for (i=0; i<(int)len; i++)
|
||||
{
|
||||
if (sep && (i != 0))
|
||||
BIO_printf(out, ":");
|
||||
@@ -472,6 +498,10 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
}
|
||||
BIO_printf(out, "\n");
|
||||
}
|
||||
if (hmac_key)
|
||||
{
|
||||
BIO_set_md_ctx(bmd,md_ctx);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,9 @@
|
||||
* -aes128 - encrypt output if PEM format
|
||||
* -aes192 - encrypt output if PEM format
|
||||
* -aes256 - encrypt output if PEM format
|
||||
* -camellia128 - encrypt output if PEM format
|
||||
* -camellia192 - encrypt output if PEM format
|
||||
* -camellia256 - encrypt output if PEM format
|
||||
* -text - print a text version
|
||||
* -modulus - print the DSA public key
|
||||
*/
|
||||
@@ -211,6 +214,10 @@ bad:
|
||||
#ifndef OPENSSL_NO_AES
|
||||
BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
|
||||
BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf(bio_err," -camellia128, -camellia192, -camellia256\n");
|
||||
BIO_printf(bio_err," encrypt PEM output with cbc camellia\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -text print the key in text\n");
|
||||
BIO_printf(bio_err," -noout don't print key out\n");
|
||||
|
||||
@@ -347,7 +347,10 @@ bad:
|
||||
}
|
||||
|
||||
if (noout)
|
||||
{
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
BIO_printf(bio_err, "writing EC key\n");
|
||||
if (outformat == FORMAT_ASN1)
|
||||
|
||||
16
apps/enc.c
16
apps/enc.c
@@ -340,7 +340,7 @@ bad:
|
||||
}
|
||||
|
||||
/* It must be large enough for a base64 encoded line */
|
||||
if (n < 80) n=80;
|
||||
if (base64 && n < 80) n=80;
|
||||
|
||||
bsize=(int)n;
|
||||
if (verbose) BIO_printf(bio_err,"bufsize=%d\n",bsize);
|
||||
@@ -365,12 +365,16 @@ bad:
|
||||
{
|
||||
BIO_set_callback(in,BIO_debug_callback);
|
||||
BIO_set_callback(out,BIO_debug_callback);
|
||||
BIO_set_callback_arg(in,bio_err);
|
||||
BIO_set_callback_arg(out,bio_err);
|
||||
BIO_set_callback_arg(in,(char *)bio_err);
|
||||
BIO_set_callback_arg(out,(char *)bio_err);
|
||||
}
|
||||
|
||||
if (inf == NULL)
|
||||
{
|
||||
if (bufsize != NULL)
|
||||
setvbuf(stdin, (char *)NULL, _IONBF, 0);
|
||||
BIO_set_fp(in,stdin,BIO_NOCLOSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BIO_read_filename(in,inf) <= 0)
|
||||
@@ -421,6 +425,8 @@ bad:
|
||||
if (outf == NULL)
|
||||
{
|
||||
BIO_set_fp(out,stdout,BIO_NOCLOSE);
|
||||
if (bufsize != NULL)
|
||||
setvbuf(stdout, (char *)NULL, _IONBF, 0);
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
@@ -447,7 +453,7 @@ bad:
|
||||
if (debug)
|
||||
{
|
||||
BIO_set_callback(b64,BIO_debug_callback);
|
||||
BIO_set_callback_arg(b64,bio_err);
|
||||
BIO_set_callback_arg(b64,(char *)bio_err);
|
||||
}
|
||||
if (olb64)
|
||||
BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL);
|
||||
@@ -565,7 +571,7 @@ bad:
|
||||
if (debug)
|
||||
{
|
||||
BIO_set_callback(benc,BIO_debug_callback);
|
||||
BIO_set_callback_arg(benc,bio_err);
|
||||
BIO_set_callback_arg(benc,(char *)bio_err);
|
||||
}
|
||||
|
||||
if (printkey)
|
||||
|
||||
@@ -147,6 +147,14 @@ int MAIN(int argc, char **argv)
|
||||
enc=EVP_aes_192_cbc();
|
||||
else if (strcmp(*argv,"-aes256") == 0)
|
||||
enc=EVP_aes_256_cbc();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
else if (strcmp(*argv,"-camellia128") == 0)
|
||||
enc=EVP_camellia_128_cbc();
|
||||
else if (strcmp(*argv,"-camellia192") == 0)
|
||||
enc=EVP_camellia_192_cbc();
|
||||
else if (strcmp(*argv,"-camellia256") == 0)
|
||||
enc=EVP_camellia_256_cbc();
|
||||
#endif
|
||||
else if (**argv != '-' && dsaparams == NULL)
|
||||
{
|
||||
@@ -174,6 +182,10 @@ bad:
|
||||
BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
|
||||
BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf(bio_err," -camellia128, -camellia192, -camellia256\n");
|
||||
BIO_printf(bio_err," encrypt PEM output with cbc camellia\n");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n");
|
||||
#endif
|
||||
|
||||
@@ -167,6 +167,14 @@ int MAIN(int argc, char **argv)
|
||||
enc=EVP_aes_192_cbc();
|
||||
else if (strcmp(*argv,"-aes256") == 0)
|
||||
enc=EVP_aes_256_cbc();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
else if (strcmp(*argv,"-camellia128") == 0)
|
||||
enc=EVP_camellia_128_cbc();
|
||||
else if (strcmp(*argv,"-camellia192") == 0)
|
||||
enc=EVP_camellia_192_cbc();
|
||||
else if (strcmp(*argv,"-camellia256") == 0)
|
||||
enc=EVP_camellia_256_cbc();
|
||||
#endif
|
||||
else if (strcmp(*argv,"-passout") == 0)
|
||||
{
|
||||
@@ -190,6 +198,10 @@ bad:
|
||||
#ifndef OPENSSL_NO_AES
|
||||
BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
|
||||
BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf(bio_err," -camellia128, -camellia192, -camellia256\n");
|
||||
BIO_printf(bio_err," encrypt PEM output with cbc camellia\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -out file output the key to 'file\n");
|
||||
BIO_printf(bio_err," -passout arg output file pass phrase source\n");
|
||||
|
||||
@@ -143,26 +143,9 @@ $ LIB_FILES = "VERIFY;ASN1PARS;REQ;DGST;DH;DHPARAM;ENC;PASSWD;GENDH;ERRSTR;"+-
|
||||
"X509;GENRSA;GENDSA;S_SERVER;S_CLIENT;SPEED;"+-
|
||||
"S_TIME;APPS;S_CB;S_SOCKET;APP_RAND;VERSION;SESS_ID;"+-
|
||||
"CIPHERS;NSEQ;PKCS12;PKCS8;SPKAC;SMIME;RAND;ENGINE;OCSP;PRIME"
|
||||
$ APP_FILES := OPENSSL,'OBJ_DIR'VERIFY.OBJ,ASN1PARS.OBJ,REQ.OBJ,DGST.OBJ,DH.OBJ,DHPARAM.OBJ,ENC.OBJ,PASSWD.OBJ,GENDH.OBJ,ERRSTR.OBJ,-
|
||||
CA.OBJ,PKCS7.OBJ,CRL2P7.OBJ,CRL.OBJ,-
|
||||
RSA.OBJ,RSAUTL.OBJ,DSA.OBJ,DSAPARAM.OBJ,EC.OBJ,ECPARAM.OBJ,-
|
||||
X509.OBJ,GENRSA.OBJ,GENDSA.OBJ,S_SERVER.OBJ,S_CLIENT.OBJ,SPEED.OBJ,-
|
||||
S_TIME.OBJ,APPS.OBJ,S_CB.OBJ,S_SOCKET.OBJ,APP_RAND.OBJ,VERSION.OBJ,SESS_ID.OBJ,-
|
||||
CIPHERS.OBJ,NSEQ.OBJ,PKCS12.OBJ,PKCS8.OBJ,SPKAC.OBJ,SMIME.OBJ,RAND.OBJ,ENGINE.OBJ,OCSP.OBJ,PRIME.OBJ
|
||||
$ TCPIP_PROGRAMS = ",,"
|
||||
$ IF COMPILER .EQS. "VAXC" THEN -
|
||||
TCPIP_PROGRAMS = ",OPENSSL,"
|
||||
$!$ APP_FILES := VERIFY;ASN1PARS;REQ;DGST;DH;ENC;GENDH;ERRSTR;CA;-
|
||||
$! PKCS7;CRL2P7;CRL;-
|
||||
$! RSA;DSA;DSAPARAM;-
|
||||
$! X509;GENRSA;GENDSA;-
|
||||
$! S_SERVER,'OBJ_DIR'S_SOCKET.OBJ,'OBJ_DIR'S_CB.OBJ;-
|
||||
$! S_CLIENT,'OBJ_DIR'S_SOCKET.OBJ,'OBJ_DIR'S_CB.OBJ;-
|
||||
$! SPEED;-
|
||||
$! S_TIME,'OBJ_DIR'S_CB.OBJ;VERSION;SESS_ID;CIPHERS;NSEQ
|
||||
$!$ TCPIP_PROGRAMS = ",,"
|
||||
$!$ IF COMPILER .EQS. "VAXC" THEN -
|
||||
$! TCPIP_PROGRAMS = ",S_SERVER,S_CLIENT,SESS_ID,CIPHERS,S_TIME,"
|
||||
$!
|
||||
$! Setup exceptional compilations
|
||||
$!
|
||||
|
||||
@@ -139,6 +139,7 @@ int MAIN(int argc, char **argv)
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
SSL_load_error_strings();
|
||||
OpenSSL_add_ssl_algorithms();
|
||||
args = argv + 1;
|
||||
reqnames = sk_new_null();
|
||||
ids = sk_OCSP_CERTID_new_null();
|
||||
@@ -726,6 +727,11 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(bio_err, "SSL is disabled\n");
|
||||
goto end;
|
||||
#endif
|
||||
if (ctx == NULL)
|
||||
{
|
||||
BIO_printf(bio_err, "Error creating SSL context.\n");
|
||||
goto end;
|
||||
}
|
||||
SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
|
||||
sbio = BIO_new_ssl(ctx, 1);
|
||||
cbio = BIO_push(sbio, cbio);
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -445,7 +445,11 @@ static int do_cmd(LHASH *prog, int argc, char *argv[])
|
||||
for (fp=functions; fp->name != NULL; fp++)
|
||||
{
|
||||
nl=0;
|
||||
#ifdef OPENSSL_NO_CAMELLIA
|
||||
if (((i++) % 5) == 0)
|
||||
#else
|
||||
if (((i++) % 4) == 0)
|
||||
#endif
|
||||
{
|
||||
BIO_printf(bio_err,"\n");
|
||||
nl=1;
|
||||
@@ -466,7 +470,11 @@ static int do_cmd(LHASH *prog, int argc, char *argv[])
|
||||
BIO_printf(bio_err,"\nCipher commands (see the `enc' command for more details)\n");
|
||||
}
|
||||
}
|
||||
#ifdef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf(bio_err,"%-15s",fp->name);
|
||||
#else
|
||||
BIO_printf(bio_err,"%-18s",fp->name);
|
||||
#endif
|
||||
}
|
||||
BIO_printf(bio_err,"\n\n");
|
||||
ret=0;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -161,6 +161,11 @@ int MAIN(int argc, char **argv)
|
||||
else if (!strcmp(*args,"-aes128")) enc=EVP_aes_128_cbc();
|
||||
else if (!strcmp(*args,"-aes192")) enc=EVP_aes_192_cbc();
|
||||
else if (!strcmp(*args,"-aes256")) enc=EVP_aes_256_cbc();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
else if (!strcmp(*args,"-camellia128")) enc=EVP_camellia_128_cbc();
|
||||
else if (!strcmp(*args,"-camellia192")) enc=EVP_camellia_192_cbc();
|
||||
else if (!strcmp(*args,"-camellia256")) enc=EVP_camellia_256_cbc();
|
||||
#endif
|
||||
else if (!strcmp (*args, "-noiter")) iter = 1;
|
||||
else if (!strcmp (*args, "-maciter"))
|
||||
@@ -175,7 +180,8 @@ int MAIN(int argc, char **argv)
|
||||
args++;
|
||||
if (!strcmp(*args, "NONE"))
|
||||
cert_pbe = -1;
|
||||
cert_pbe=OBJ_txt2nid(*args);
|
||||
else
|
||||
cert_pbe=OBJ_txt2nid(*args);
|
||||
if(cert_pbe == NID_undef) {
|
||||
BIO_printf(bio_err,
|
||||
"Unknown PBE algorithm %s\n", *args);
|
||||
@@ -303,6 +309,10 @@ int MAIN(int argc, char **argv)
|
||||
#ifndef OPENSSL_NO_AES
|
||||
BIO_printf (bio_err, "-aes128, -aes192, -aes256\n");
|
||||
BIO_printf (bio_err, " encrypt PEM output with cbc aes\n");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf (bio_err, "-camellia128, -camellia192, -camellia256\n");
|
||||
BIO_printf (bio_err, " encrypt PEM output with cbc camellia\n");
|
||||
#endif
|
||||
BIO_printf (bio_err, "-nodes don't encrypt private keys\n");
|
||||
BIO_printf (bio_err, "-noiter don't use encryption iteration\n");
|
||||
@@ -526,8 +536,11 @@ int MAIN(int argc, char **argv)
|
||||
X509_free(sk_X509_value(chain2, 0));
|
||||
sk_X509_free(chain2);
|
||||
} else {
|
||||
BIO_printf (bio_err, "Error %s getting chain.\n",
|
||||
if (vret >= 0)
|
||||
BIO_printf (bio_err, "Error %s getting chain.\n",
|
||||
X509_verify_cert_error_string(vret));
|
||||
else
|
||||
ERR_print_errors(bio_err);
|
||||
goto export_end;
|
||||
}
|
||||
}
|
||||
@@ -801,7 +814,7 @@ int get_cert_chain (X509 *cert, X509_STORE *store, STACK_OF(X509) **chain)
|
||||
{
|
||||
X509_STORE_CTX store_ctx;
|
||||
STACK_OF(X509) *chn;
|
||||
int i;
|
||||
int i = 0;
|
||||
|
||||
/* FIXME: Should really check the return status of X509_STORE_CTX_init
|
||||
* for an error, but how that fits into the return value of this
|
||||
@@ -809,13 +822,17 @@ int get_cert_chain (X509 *cert, X509_STORE *store, STACK_OF(X509) **chain)
|
||||
X509_STORE_CTX_init(&store_ctx, store, cert, NULL);
|
||||
if (X509_verify_cert(&store_ctx) <= 0) {
|
||||
i = X509_STORE_CTX_get_error (&store_ctx);
|
||||
if (i == 0)
|
||||
/* avoid returning 0 if X509_verify_cert() did not
|
||||
* set an appropriate error value in the context */
|
||||
i = -1;
|
||||
chn = NULL;
|
||||
goto err;
|
||||
}
|
||||
chn = X509_STORE_CTX_get1_chain(&store_ctx);
|
||||
i = 0;
|
||||
*chain = chn;
|
||||
} else
|
||||
chn = X509_STORE_CTX_get1_chain(&store_ctx);
|
||||
err:
|
||||
X509_STORE_CTX_cleanup(&store_ctx);
|
||||
*chain = chn;
|
||||
|
||||
return i;
|
||||
}
|
||||
@@ -825,12 +842,14 @@ int alg_print (BIO *x, X509_ALGOR *alg)
|
||||
PBEPARAM *pbe;
|
||||
const unsigned char *p;
|
||||
p = alg->parameter->value.sequence->data;
|
||||
pbe = d2i_PBEPARAM (NULL, &p, alg->parameter->value.sequence->length);
|
||||
pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
|
||||
if (!pbe)
|
||||
return 1;
|
||||
BIO_printf (bio_err, "%s, Iteration %ld\n",
|
||||
OBJ_nid2ln(OBJ_obj2nid(alg->algorithm)),
|
||||
ASN1_INTEGER_get(pbe->iter));
|
||||
PBEPARAM_free (pbe);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Load all certificates from a given file */
|
||||
|
||||
18
apps/progs.h
18
apps/progs.h
@@ -165,6 +165,24 @@ FUNCTION functions[] = {
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_AES
|
||||
{FUNC_TYPE_CIPHER,"aes-256-ecb",enc_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FUNC_TYPE_CIPHER,"camellia-128-cbc",enc_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FUNC_TYPE_CIPHER,"camellia-128-ecb",enc_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FUNC_TYPE_CIPHER,"camellia-192-cbc",enc_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FUNC_TYPE_CIPHER,"camellia-192-ecb",enc_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FUNC_TYPE_CIPHER,"camellia-256-cbc",enc_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FUNC_TYPE_CIPHER,"camellia-256-ecb",enc_main},
|
||||
#endif
|
||||
{FUNC_TYPE_CIPHER,"base64",enc_main},
|
||||
#ifndef OPENSSL_NO_DES
|
||||
|
||||
@@ -57,6 +57,9 @@ foreach (
|
||||
"aes-128-cbc", "aes-128-ecb",
|
||||
"aes-192-cbc", "aes-192-ecb",
|
||||
"aes-256-cbc", "aes-256-ecb",
|
||||
"camellia-128-cbc", "camellia-128-ecb",
|
||||
"camellia-192-cbc", "camellia-192-ecb",
|
||||
"camellia-256-cbc", "camellia-256-ecb",
|
||||
"base64",
|
||||
"des", "des3", "desx", "idea", "rc4", "rc4-40",
|
||||
"rc2", "bf", "cast", "rc5",
|
||||
@@ -75,6 +78,7 @@ foreach (
|
||||
$t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_);
|
||||
if ($_ =~ /des/) { $t="#ifndef OPENSSL_NO_DES\n${t}#endif\n"; }
|
||||
elsif ($_ =~ /aes/) { $t="#ifndef OPENSSL_NO_AES\n${t}#endif\n"; }
|
||||
elsif ($_ =~ /camellia/) { $t="#ifndef OPENSSL_NO_CAMELLIA\n${t}#endif\n"; }
|
||||
elsif ($_ =~ /idea/) { $t="#ifndef OPENSSL_NO_IDEA\n${t}#endif\n"; }
|
||||
elsif ($_ =~ /rc4/) { $t="#ifndef OPENSSL_NO_RC4\n${t}#endif\n"; }
|
||||
elsif ($_ =~ /rc2/) { $t="#ifndef OPENSSL_NO_RC2\n${t}#endif\n"; }
|
||||
|
||||
@@ -84,6 +84,9 @@
|
||||
* -aes128 - encrypt output if PEM format
|
||||
* -aes192 - encrypt output if PEM format
|
||||
* -aes256 - encrypt output if PEM format
|
||||
* -camellia128 - encrypt output if PEM format
|
||||
* -camellia192 - encrypt output if PEM format
|
||||
* -camellia256 - encrypt output if PEM format
|
||||
* -text - print a text version
|
||||
* -modulus - print the RSA key modulus
|
||||
* -check - verify key consistency
|
||||
@@ -211,6 +214,10 @@ bad:
|
||||
#ifndef OPENSSL_NO_AES
|
||||
BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
|
||||
BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf(bio_err," -camellia128, -camellia192, -camellia256\n");
|
||||
BIO_printf(bio_err," encrypt PEM output with cbc camellia\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -text print the key in text\n");
|
||||
BIO_printf(bio_err," -noout don't print key out\n");
|
||||
|
||||
107
apps/s_client.c
107
apps/s_client.c
@@ -226,7 +226,7 @@ static void sc_usage(void)
|
||||
BIO_printf(bio_err," -starttls prot - use the STARTTLS command before starting TLS\n");
|
||||
BIO_printf(bio_err," for those protocols that support it, where\n");
|
||||
BIO_printf(bio_err," 'prot' defines which one to assume. Currently,\n");
|
||||
BIO_printf(bio_err," only \"smtp\" and \"pop3\" are supported.\n");
|
||||
BIO_printf(bio_err," only \"smtp\", \"pop3\", \"imap\", and \"ftp\" are supported.\n");
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n");
|
||||
#endif
|
||||
@@ -234,6 +234,15 @@ static void sc_usage(void)
|
||||
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
PROTO_OFF = 0,
|
||||
PROTO_SMTP,
|
||||
PROTO_POP3,
|
||||
PROTO_IMAP,
|
||||
PROTO_FTP
|
||||
};
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
@@ -260,7 +269,7 @@ int MAIN(int argc, char **argv)
|
||||
int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
|
||||
SSL_CTX *ctx=NULL;
|
||||
int ret=1,in_init=1,i,nbio_test=0;
|
||||
int starttls_proto = 0;
|
||||
int starttls_proto = PROTO_OFF;
|
||||
int prexit = 0, vflags = 0;
|
||||
SSL_METHOD *meth=NULL;
|
||||
#ifdef sock_type
|
||||
@@ -269,6 +278,7 @@ int MAIN(int argc, char **argv)
|
||||
int sock_type=SOCK_STREAM;
|
||||
BIO *sbio;
|
||||
char *inrand=NULL;
|
||||
int mbuf_len=0;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
char *engine_id=NULL;
|
||||
ENGINE *e=NULL;
|
||||
@@ -466,9 +476,13 @@ int MAIN(int argc, char **argv)
|
||||
if (--argc < 1) goto bad;
|
||||
++argv;
|
||||
if (strcmp(*argv,"smtp") == 0)
|
||||
starttls_proto = 1;
|
||||
starttls_proto = PROTO_SMTP;
|
||||
else if (strcmp(*argv,"pop3") == 0)
|
||||
starttls_proto = 2;
|
||||
starttls_proto = PROTO_POP3;
|
||||
else if (strcmp(*argv,"imap") == 0)
|
||||
starttls_proto = PROTO_IMAP;
|
||||
else if (strcmp(*argv,"ftp") == 0)
|
||||
starttls_proto = PROTO_FTP;
|
||||
else
|
||||
goto bad;
|
||||
}
|
||||
@@ -693,7 +707,7 @@ re_start:
|
||||
{
|
||||
con->debug=1;
|
||||
BIO_set_callback(sbio,bio_dump_callback);
|
||||
BIO_set_callback_arg(sbio,bio_c_out);
|
||||
BIO_set_callback_arg(sbio,(char *)bio_c_out);
|
||||
}
|
||||
if (c_msg)
|
||||
{
|
||||
@@ -719,18 +733,93 @@ re_start:
|
||||
sbuf_off=0;
|
||||
|
||||
/* This is an ugly hack that does a lot of assumptions */
|
||||
if (starttls_proto == 1)
|
||||
/* We do have to handle multi-line responses which may come
|
||||
in a single packet or not. We therefore have to use
|
||||
BIO_gets() which does need a buffering BIO. So during
|
||||
the initial chitchat we do push a buffering BIO into the
|
||||
chain that is removed again later on to not disturb the
|
||||
rest of the s_client operation. */
|
||||
if (starttls_proto == PROTO_SMTP)
|
||||
{
|
||||
BIO_read(sbio,mbuf,BUFSIZZ);
|
||||
int foundit=0;
|
||||
BIO *fbio = BIO_new(BIO_f_buffer());
|
||||
BIO_push(fbio, sbio);
|
||||
/* wait for multi-line response to end from SMTP */
|
||||
do
|
||||
{
|
||||
mbuf_len = BIO_gets(fbio,mbuf,BUFSIZZ);
|
||||
}
|
||||
while (mbuf_len>3 && mbuf[3]=='-');
|
||||
/* STARTTLS command requires EHLO... */
|
||||
BIO_printf(fbio,"EHLO openssl.client.net\r\n");
|
||||
BIO_flush(fbio);
|
||||
/* wait for multi-line response to end EHLO SMTP response */
|
||||
do
|
||||
{
|
||||
mbuf_len = BIO_gets(fbio,mbuf,BUFSIZZ);
|
||||
if (strstr(mbuf,"STARTTLS"))
|
||||
foundit=1;
|
||||
}
|
||||
while (mbuf_len>3 && mbuf[3]=='-');
|
||||
BIO_flush(fbio);
|
||||
BIO_pop(fbio);
|
||||
BIO_free(fbio);
|
||||
if (!foundit)
|
||||
BIO_printf(bio_err,
|
||||
"didn't found starttls in server response,"
|
||||
" try anyway...\n");
|
||||
BIO_printf(sbio,"STARTTLS\r\n");
|
||||
BIO_read(sbio,sbuf,BUFSIZZ);
|
||||
}
|
||||
if (starttls_proto == 2)
|
||||
else if (starttls_proto == PROTO_POP3)
|
||||
{
|
||||
BIO_read(sbio,mbuf,BUFSIZZ);
|
||||
BIO_printf(sbio,"STLS\r\n");
|
||||
BIO_read(sbio,sbuf,BUFSIZZ);
|
||||
}
|
||||
else if (starttls_proto == PROTO_IMAP)
|
||||
{
|
||||
int foundit=0;
|
||||
BIO *fbio = BIO_new(BIO_f_buffer());
|
||||
BIO_push(fbio, sbio);
|
||||
BIO_gets(fbio,mbuf,BUFSIZZ);
|
||||
/* STARTTLS command requires CAPABILITY... */
|
||||
BIO_printf(fbio,". CAPABILITY\r\n");
|
||||
BIO_flush(fbio);
|
||||
/* wait for multi-line CAPABILITY response */
|
||||
do
|
||||
{
|
||||
mbuf_len = BIO_gets(fbio,mbuf,BUFSIZZ);
|
||||
if (strstr(mbuf,"STARTTLS"))
|
||||
foundit=1;
|
||||
}
|
||||
while (mbuf_len>3 && mbuf[0]!='.');
|
||||
BIO_flush(fbio);
|
||||
BIO_pop(fbio);
|
||||
BIO_free(fbio);
|
||||
if (!foundit)
|
||||
BIO_printf(bio_err,
|
||||
"didn't found STARTTLS in server response,"
|
||||
" try anyway...\n");
|
||||
BIO_printf(sbio,". STARTTLS\r\n");
|
||||
BIO_read(sbio,sbuf,BUFSIZZ);
|
||||
}
|
||||
else if (starttls_proto == PROTO_FTP)
|
||||
{
|
||||
BIO *fbio = BIO_new(BIO_f_buffer());
|
||||
BIO_push(fbio, sbio);
|
||||
/* wait for multi-line response to end from FTP */
|
||||
do
|
||||
{
|
||||
mbuf_len = BIO_gets(fbio,mbuf,BUFSIZZ);
|
||||
}
|
||||
while (mbuf_len>3 && mbuf[3]=='-');
|
||||
BIO_flush(fbio);
|
||||
BIO_pop(fbio);
|
||||
BIO_free(fbio);
|
||||
BIO_printf(sbio,"AUTH TLS\r\n");
|
||||
BIO_read(sbio,sbuf,BUFSIZZ);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -755,7 +844,7 @@ re_start:
|
||||
{
|
||||
BIO_printf(bio_err,"%s",mbuf);
|
||||
/* We don't need to know any more */
|
||||
starttls_proto = 0;
|
||||
starttls_proto = PROTO_OFF;
|
||||
}
|
||||
|
||||
if (reconnect)
|
||||
|
||||
@@ -1234,7 +1234,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
|
||||
{
|
||||
con->debug=1;
|
||||
BIO_set_callback(SSL_get_rbio(con),bio_dump_callback);
|
||||
BIO_set_callback_arg(SSL_get_rbio(con),bio_s_out);
|
||||
BIO_set_callback_arg(SSL_get_rbio(con),(char *)bio_s_out);
|
||||
}
|
||||
if (s_msg)
|
||||
{
|
||||
@@ -1638,7 +1638,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
|
||||
{
|
||||
con->debug=1;
|
||||
BIO_set_callback(SSL_get_rbio(con),bio_dump_callback);
|
||||
BIO_set_callback_arg(SSL_get_rbio(con),bio_s_out);
|
||||
BIO_set_callback_arg(SSL_get_rbio(con),(char *)bio_s_out);
|
||||
}
|
||||
if (s_msg)
|
||||
{
|
||||
|
||||
18
apps/smime.c
18
apps/smime.c
@@ -160,6 +160,14 @@ int MAIN(int argc, char **argv)
|
||||
cipher = EVP_aes_192_cbc();
|
||||
else if (!strcmp(*args,"-aes256"))
|
||||
cipher = EVP_aes_256_cbc();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
else if (!strcmp(*args,"-camellia128"))
|
||||
cipher = EVP_camellia_128_cbc();
|
||||
else if (!strcmp(*args,"-camellia192"))
|
||||
cipher = EVP_camellia_192_cbc();
|
||||
else if (!strcmp(*args,"-camellia256"))
|
||||
cipher = EVP_camellia_256_cbc();
|
||||
#endif
|
||||
else if (!strcmp (*args, "-text"))
|
||||
flags |= PKCS7_TEXT;
|
||||
@@ -423,6 +431,10 @@ int MAIN(int argc, char **argv)
|
||||
#ifndef OPENSSL_NO_AES
|
||||
BIO_printf (bio_err, "-aes128, -aes192, -aes256\n");
|
||||
BIO_printf (bio_err, " encrypt PEM output with cbc aes\n");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf (bio_err, "-camellia128, -camellia192, -camellia256\n");
|
||||
BIO_printf (bio_err, " encrypt PEM output with cbc camellia\n");
|
||||
#endif
|
||||
BIO_printf (bio_err, "-nointern don't search certificates in message for signer\n");
|
||||
BIO_printf (bio_err, "-nosigs don't verify message signature\n");
|
||||
@@ -638,12 +650,6 @@ int MAIN(int argc, char **argv)
|
||||
if ((flags & PKCS7_DETACHED) && (outformat == FORMAT_SMIME))
|
||||
flags |= PKCS7_STREAM;
|
||||
p7 = PKCS7_sign(signer, key, other, in, flags);
|
||||
/* Don't need to rewind for partial signing */
|
||||
if (!(flags & PKCS7_STREAM) && (BIO_reset(in) != 0))
|
||||
{
|
||||
BIO_printf(bio_err, "Can't rewind input file\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
113
apps/speed.c
113
apps/speed.c
@@ -164,6 +164,9 @@
|
||||
#ifndef OPENSSL_NO_AES
|
||||
#include <openssl/aes.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
#include <openssl/camellia.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
#include <openssl/md2.h>
|
||||
#endif
|
||||
@@ -269,7 +272,7 @@ static void print_result(int alg,int run_no,int count,double time_used);
|
||||
static int do_multi(int multi);
|
||||
#endif
|
||||
|
||||
#define ALGOR_NUM 21
|
||||
#define ALGOR_NUM 24
|
||||
#define SIZE_NUM 5
|
||||
#define RSA_NUM 4
|
||||
#define DSA_NUM 3
|
||||
@@ -281,7 +284,9 @@ static const char *names[ALGOR_NUM]={
|
||||
"md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
|
||||
"des cbc","des ede3","idea cbc",
|
||||
"rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc",
|
||||
"aes-128 cbc","aes-192 cbc","aes-256 cbc","evp","sha256","sha512"};
|
||||
"aes-128 cbc","aes-192 cbc","aes-256 cbc",
|
||||
"camellia-128 cbc","camellia-192 cbc","camellia-256 cbc",
|
||||
"evp","sha256","sha512"};
|
||||
static double results[ALGOR_NUM][SIZE_NUM];
|
||||
static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
|
||||
static double rsa_results[RSA_NUM][2];
|
||||
@@ -548,6 +553,17 @@ int MAIN(int argc, char **argv)
|
||||
0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
|
||||
0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
static const unsigned char ckey24[24]=
|
||||
{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
|
||||
0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
|
||||
0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
|
||||
static const unsigned char ckey32[32]=
|
||||
{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
|
||||
0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
|
||||
0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
|
||||
0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_AES
|
||||
#define MAX_BLOCK_SIZE 128
|
||||
#else
|
||||
@@ -567,6 +583,9 @@ int MAIN(int argc, char **argv)
|
||||
#ifndef OPENSSL_NO_AES
|
||||
AES_KEY aes_ks1, aes_ks2, aes_ks3;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3;
|
||||
#endif
|
||||
#define D_MD2 0
|
||||
#define D_MDC2 1
|
||||
#define D_MD4 2
|
||||
@@ -585,9 +604,12 @@ int MAIN(int argc, char **argv)
|
||||
#define D_CBC_128_AES 15
|
||||
#define D_CBC_192_AES 16
|
||||
#define D_CBC_256_AES 17
|
||||
#define D_EVP 18
|
||||
#define D_SHA256 19
|
||||
#define D_SHA512 20
|
||||
#define D_CBC_128_CML 18
|
||||
#define D_CBC_192_CML 19
|
||||
#define D_CBC_256_CML 20
|
||||
#define D_EVP 21
|
||||
#define D_SHA256 22
|
||||
#define D_SHA512 23
|
||||
double d=0.0;
|
||||
long c[ALGOR_NUM][SIZE_NUM];
|
||||
#define R_DSA_512 0
|
||||
@@ -930,6 +952,12 @@ int MAIN(int argc, char **argv)
|
||||
else if (strcmp(*argv,"aes-256-cbc") == 0) doit[D_CBC_256_AES]=1;
|
||||
else
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
if (strcmp(*argv,"camellia-128-cbc") == 0) doit[D_CBC_128_CML]=1;
|
||||
else if (strcmp(*argv,"camellia-192-cbc") == 0) doit[D_CBC_192_CML]=1;
|
||||
else if (strcmp(*argv,"camellia-256-cbc") == 0) doit[D_CBC_256_CML]=1;
|
||||
else
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
#if 0 /* was: #ifdef RSAref */
|
||||
if (strcmp(*argv,"rsaref") == 0)
|
||||
@@ -1000,6 +1028,15 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
if (strcmp(*argv,"camellia") == 0)
|
||||
{
|
||||
doit[D_CBC_128_CML]=1;
|
||||
doit[D_CBC_192_CML]=1;
|
||||
doit[D_CBC_256_CML]=1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
if (strcmp(*argv,"rsa") == 0)
|
||||
{
|
||||
@@ -1126,6 +1163,10 @@ int MAIN(int argc, char **argv)
|
||||
#ifndef OPENSSL_NO_AES
|
||||
BIO_printf(bio_err,"aes-128-cbc aes-192-cbc aes-256-cbc ");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf(bio_err,"\n");
|
||||
BIO_printf(bio_err,"camellia-128-cbc camellia-192-cbc camellia-256-cbc ");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
BIO_printf(bio_err,"rc4");
|
||||
#endif
|
||||
@@ -1163,6 +1204,9 @@ int MAIN(int argc, char **argv)
|
||||
#ifndef OPENSSL_NO_AES
|
||||
BIO_printf(bio_err,"aes ");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf(bio_err,"camellia ");
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
BIO_printf(bio_err,"rsa ");
|
||||
#endif
|
||||
@@ -1171,7 +1215,8 @@ int MAIN(int argc, char **argv)
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
|
||||
!defined(OPENSSL_NO_DES) || !defined(OPENSSL_NO_RSA) || \
|
||||
!defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_AES)
|
||||
!defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_AES) || \
|
||||
!defined(OPENSSL_NO_CAMELLIA)
|
||||
BIO_printf(bio_err,"\n");
|
||||
#endif
|
||||
|
||||
@@ -1265,6 +1310,11 @@ int MAIN(int argc, char **argv)
|
||||
AES_set_encrypt_key(key24,192,&aes_ks2);
|
||||
AES_set_encrypt_key(key32,256,&aes_ks3);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
Camellia_set_key(key16,128,&camellia_ks1);
|
||||
Camellia_set_key(ckey24,192,&camellia_ks2);
|
||||
Camellia_set_key(ckey32,256,&camellia_ks3);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
idea_set_encrypt_key(key16,&idea_ks);
|
||||
#endif
|
||||
@@ -1318,6 +1368,9 @@ int MAIN(int argc, char **argv)
|
||||
c[D_CBC_128_AES][0]=count;
|
||||
c[D_CBC_192_AES][0]=count;
|
||||
c[D_CBC_256_AES][0]=count;
|
||||
c[D_CBC_128_CML][0]=count;
|
||||
c[D_CBC_192_CML][0]=count;
|
||||
c[D_CBC_256_CML][0]=count;
|
||||
c[D_SHA256][0]=count;
|
||||
c[D_SHA512][0]=count;
|
||||
|
||||
@@ -1350,6 +1403,9 @@ int MAIN(int argc, char **argv)
|
||||
c[D_CBC_128_AES][i]=c[D_CBC_128_AES][i-1]*l0/l1;
|
||||
c[D_CBC_192_AES][i]=c[D_CBC_192_AES][i-1]*l0/l1;
|
||||
c[D_CBC_256_AES][i]=c[D_CBC_256_AES][i-1]*l0/l1;
|
||||
c[D_CBC_128_CML][i]=c[D_CBC_128_CML][i-1]*l0/l1;
|
||||
c[D_CBC_192_CML][i]=c[D_CBC_192_CML][i-1]*l0/l1;
|
||||
c[D_CBC_256_CML][i]=c[D_CBC_256_CML][i-1]*l0/l1;
|
||||
}
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
rsa_c[R_RSA_512][0]=count/2000;
|
||||
@@ -1743,6 +1799,51 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
if (doit[D_CBC_128_CML])
|
||||
{
|
||||
for (j=0; j<SIZE_NUM; j++)
|
||||
{
|
||||
print_message(names[D_CBC_128_CML],c[D_CBC_128_CML][j],lengths[j]);
|
||||
Time_F(START);
|
||||
for (count=0,run=1; COND(c[D_CBC_128_CML][j]); count++)
|
||||
Camellia_cbc_encrypt(buf,buf,
|
||||
(unsigned long)lengths[j],&camellia_ks1,
|
||||
iv,CAMELLIA_ENCRYPT);
|
||||
d=Time_F(STOP);
|
||||
print_result(D_CBC_128_CML,j,count,d);
|
||||
}
|
||||
}
|
||||
if (doit[D_CBC_192_CML])
|
||||
{
|
||||
for (j=0; j<SIZE_NUM; j++)
|
||||
{
|
||||
print_message(names[D_CBC_192_CML],c[D_CBC_192_CML][j],lengths[j]);
|
||||
Time_F(START);
|
||||
for (count=0,run=1; COND(c[D_CBC_192_CML][j]); count++)
|
||||
Camellia_cbc_encrypt(buf,buf,
|
||||
(unsigned long)lengths[j],&camellia_ks2,
|
||||
iv,CAMELLIA_ENCRYPT);
|
||||
d=Time_F(STOP);
|
||||
print_result(D_CBC_192_CML,j,count,d);
|
||||
}
|
||||
}
|
||||
if (doit[D_CBC_256_CML])
|
||||
{
|
||||
for (j=0; j<SIZE_NUM; j++)
|
||||
{
|
||||
print_message(names[D_CBC_256_CML],c[D_CBC_256_CML][j],lengths[j]);
|
||||
Time_F(START);
|
||||
for (count=0,run=1; COND(c[D_CBC_256_CML][j]); count++)
|
||||
Camellia_cbc_encrypt(buf,buf,
|
||||
(unsigned long)lengths[j],&camellia_ks3,
|
||||
iv,CAMELLIA_ENCRYPT);
|
||||
d=Time_F(STOP);
|
||||
print_result(D_CBC_256_CML,j,count,d);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
if (doit[D_CBC_IDEA])
|
||||
|
||||
22
certs/aol1.pem
Normal file
22
certs/aol1.pem
Normal file
@@ -0,0 +1,22 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDpDCCAoygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEc
|
||||
MBoGA1UEChMTQW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBP
|
||||
bmxpbmUgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAxMB4XDTAyMDUyODA2
|
||||
MDAwMFoXDTM3MTExOTIwNDMwMFowYzELMAkGA1UEBhMCVVMxHDAaBgNVBAoTE0Ft
|
||||
ZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2EgT25saW5lIFJvb3Qg
|
||||
Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP
|
||||
ADCCAQoCggEBAKgv6KRpBgNHw+kqmP8ZonCaxlCyfqXfaE0bfA+2l2h9LaaLl+lk
|
||||
hsmj76CGv2BlnEtUiMJIxUo5vxTjWVXlGbR0yLQFOVwWpeKVBeASrlmLojNoWBym
|
||||
1BW32J/X3HGrfpq/m44zDyL9Hy7nBzbvYjnF3cu6JRQj3gzGPTzOggjmZj7aUTsW
|
||||
OqMFf6Dch9Wc/HKpoH145LcxVR5lu9RhsCFg7RAycsWSJR74kEoYeEfffjA3PlAb
|
||||
2xzTa5qGUwew76wGePiEmf4hjUyAtgyC9mZweRrTT6PP8c9GsEsPPt2IYriMqQko
|
||||
O3rHl+Ee5fSfwMCuJKDIodkP1nsmgmkyPacCAwEAAaNjMGEwDwYDVR0TAQH/BAUw
|
||||
AwEB/zAdBgNVHQ4EFgQUAK3Zo/Z59m50qX8zPYEX10zPM94wHwYDVR0jBBgwFoAU
|
||||
AK3Zo/Z59m50qX8zPYEX10zPM94wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
|
||||
BQUAA4IBAQB8itEfGDeC4Liwo+1WlchiYZwFos3CYiZhzRAW18y0ZTTQEYqtqKkF
|
||||
Zu90821fnZmv9ov761KyBZiibyrFVL0lvV+uyIbqRizBs73B6UlwGBaXCBOMIOAb
|
||||
LjpHyx7kADCVW/RFo8AasAFOq73AI25jP4BKxQft3OJvx8Fi8eNy1gTIdGcL+oir
|
||||
oQHIb/AUr9KZzVGTfu0uOMe9zkZQPXLjeSWdm4grECDdpbgyn43gKd8hdIaC2y+C
|
||||
MMbHNYaz+ZZfRtsMRf3zUMNvxsNIrUam4SdHCh0Om7bCd39j8uB9Gr784N/Xx6ds
|
||||
sPmuujz9dLQR6FgNgLzTqIA6me11zEZ7
|
||||
-----END CERTIFICATE-----
|
||||
33
certs/aol2.pem
Normal file
33
certs/aol2.pem
Normal file
@@ -0,0 +1,33 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFpDCCA4ygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEc
|
||||
MBoGA1UEChMTQW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBP
|
||||
bmxpbmUgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAyMB4XDTAyMDUyODA2
|
||||
MDAwMFoXDTM3MDkyOTE0MDgwMFowYzELMAkGA1UEBhMCVVMxHDAaBgNVBAoTE0Ft
|
||||
ZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2EgT25saW5lIFJvb3Qg
|
||||
Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
|
||||
ADCCAgoCggIBAMxBRR3pPU0Q9oyxQcngXssNt79Hc9PwVU3dxgz6sWYFas14tNwC
|
||||
206B89enfHG8dWOgXeMHDEjsJcQDIPT/DjsS/5uN4cbVG7RtIuOx238hZK+GvFci
|
||||
KtZHgVdEglZTvYYUAQv8f3SkWq7xuhG1m1hagLQ3eAkzfDJHA1zEpYNI9FdWboE2
|
||||
JxhP7JsowtS013wMPgwr38oE18aO6lhOqKSlGBxsRZijQdEt0sdtjRnxrXm3gT+9
|
||||
BoInLRBYBbV4Bbkv2wxrkJB+FFk4u5QkE+XRnRTf04JNRvCAOVIyD+OEsnpD8l7e
|
||||
Xz8d3eOyG6ChKiMDbi4BFYdcpnV1x5dhvt6G3NRI270qv0pV2uh9UPu0gBe4lL8B
|
||||
PeraunzgWGcXuVjgiIZGZ2ydEEdYMtA1fHkqkKJaEBEjNa0vzORKW6fIJ/KD3l67
|
||||
Xnfn6KVuY8INXWHQjNJsWiEOyiijzirplcdIz5ZvHZIlyMbGwcEMBawmxNJ10uEq
|
||||
Z8A9W6Wa6897GqidFEXlD6CaZd4vKL3Ob5Rmg0gp2OpljK+T2WSfVVcmv2/LNzGZ
|
||||
o2C7HK2JNDJiuEMhBnIMoVxtRsX6Kc8w3onccVvdtjc+31D1uAclJuW8tf48ArO3
|
||||
+L5DwYcRlJ4jbBeKuIonDFRH8KmzwICMoCfrHRnjB453cMor9H124HhnAgMBAAGj
|
||||
YzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFE1FwWg4u3OpaaEg5+31IqEj
|
||||
FNeeMB8GA1UdIwQYMBaAFE1FwWg4u3OpaaEg5+31IqEjFNeeMA4GA1UdDwEB/wQE
|
||||
AwIBhjANBgkqhkiG9w0BAQUFAAOCAgEAZ2sGuV9FOypLM7PmG2tZTiLMubekJcmn
|
||||
xPBUlgtk87FYT15R/LKXeydlwuXK5w0MJXti4/qftIe3RUavg6WXSIylvfEWK5t2
|
||||
LHo1YGwRgJfMqZJS5ivmae2p+DYtLHe/YUjRYwu5W1LtGLBDQiKmsXeu3mnFzccc
|
||||
obGlHBD7GL4acN3Bkku+KVqdPzW+5X1R+FXgJXUjhx5c3LqdsKyzadsXg8n33gy8
|
||||
CNyRnqjQ1xU3c6U1uPx+xURABsPr+CKAXEfOAuMRn0T//ZoyzH1kUQ7rVyZ2OuMe
|
||||
IjzCpjbdGe+n/BLzJsBZMYVMnNjP36TMzCmT/5RtdlwTCJfy7aULTd3oyWgOZtMA
|
||||
DjMSW7yV5TKQqLPGbIOtd+6Lfn6xqavT4fG2wLHqiMDn05DpKJKUe2h7lyoKZy2F
|
||||
AjgQ5ANh1NolNscIWC2hp1GvMApJ9aZphwctREZ2jirlmjvXGKL8nDgQzMY70rUX
|
||||
Om/9riW99XJZZLF0KjhfGEzfz3EEWjbUvy+ZnOjZurGV5gJLIaFb1cFPj65pbVPb
|
||||
AZO1XB4Y3WRayhgoPmMEEf0cjQAPuDffZ4qdZqkCapH/E8ovXYO8h5Ns3CRRFgQl
|
||||
Zvqz2cK6Kb6aSDiCmfS/O0oxGfm/jiEzFMpPVF/7zvuPcX/9XhmgD0uRuMRUvAaw
|
||||
RY8mkaKO/qk=
|
||||
-----END CERTIFICATE-----
|
||||
23
certs/aoltw1.pem
Normal file
23
certs/aoltw1.pem
Normal file
@@ -0,0 +1,23 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIID5jCCAs6gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzELMAkGA1UEBhMCVVMx
|
||||
HTAbBgNVBAoTFEFPTCBUaW1lIFdhcm5lciBJbmMuMRwwGgYDVQQLExNBbWVyaWNh
|
||||
IE9ubGluZSBJbmMuMTcwNQYDVQQDEy5BT0wgVGltZSBXYXJuZXIgUm9vdCBDZXJ0
|
||||
aWZpY2F0aW9uIEF1dGhvcml0eSAxMB4XDTAyMDUyOTA2MDAwMFoXDTM3MTEyMDE1
|
||||
MDMwMFowgYMxCzAJBgNVBAYTAlVTMR0wGwYDVQQKExRBT0wgVGltZSBXYXJuZXIg
|
||||
SW5jLjEcMBoGA1UECxMTQW1lcmljYSBPbmxpbmUgSW5jLjE3MDUGA1UEAxMuQU9M
|
||||
IFRpbWUgV2FybmVyIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMTCCASIw
|
||||
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnej8Mlo2k06AX3dLm/WpcZuS+U
|
||||
0pPlLYnKhHw/EEMbjIt8hFj4JHxIzyr9wBXZGH6EGhfT257XyuTZ16pYUYfw8ItI
|
||||
TuLCxFlpMGK2MKKMCxGZYTVtfu/FsRkGIBKOQuHfD5YQUqjPnF+VFNivO3ULMSAf
|
||||
RC+iYkGzuxgh28pxPIzstrkNn+9R7017EvILDOGsQI93f7DKeHEMXRZxcKLXwjqF
|
||||
zQ6axOAAsNUl6twr5JQtOJyJQVdkKGUZHLZEtMgxa44Be3ZZJX8VHIQIfHNlIAqh
|
||||
BC4aMqiaILGcLCFZ5/vP7nAtCMpjPiybkxlqpMKX/7eGV4iFbJ4VFitNLLMCAwEA
|
||||
AaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUoTYwFsuGkABFgFOxj8jY
|
||||
PXy+XxIwHwYDVR0jBBgwFoAUoTYwFsuGkABFgFOxj8jYPXy+XxIwDgYDVR0PAQH/
|
||||
BAQDAgGGMA0GCSqGSIb3DQEBBQUAA4IBAQCKIBilvrMvtKaEAEAwKfq0FHNMeUWn
|
||||
9nDg6H5kHgqVfGphwu9OH77/yZkfB2FK4V1Mza3u0FIy2VkyvNp5ctZ7CegCgTXT
|
||||
Ct8RHcl5oIBN/lrXVtbtDyqvpxh1MwzqwWEFT2qaifKNuZ8u77BfWgDrvq2g+EQF
|
||||
Z7zLBO+eZMXpyD8Fv8YvBxzDNnGGyjhmSs3WuEvGbKeXO/oTLW4jYYehY0KswsuX
|
||||
n2Fozy1MBJ3XJU8KDk2QixhWqJNIV9xvrr2eZ1d3iVCzvhGbRWeDhhmH05i9CBoW
|
||||
H1iCC+GWaQVLjuyDUTEH1dSf/1l7qG6Fz9NLqUmwX7A5KGgOc90lmt4S
|
||||
-----END CERTIFICATE-----
|
||||
34
certs/aoltw2.pem
Normal file
34
certs/aoltw2.pem
Normal file
@@ -0,0 +1,34 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIF5jCCA86gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBgzELMAkGA1UEBhMCVVMx
|
||||
HTAbBgNVBAoTFEFPTCBUaW1lIFdhcm5lciBJbmMuMRwwGgYDVQQLExNBbWVyaWNh
|
||||
IE9ubGluZSBJbmMuMTcwNQYDVQQDEy5BT0wgVGltZSBXYXJuZXIgUm9vdCBDZXJ0
|
||||
aWZpY2F0aW9uIEF1dGhvcml0eSAyMB4XDTAyMDUyOTA2MDAwMFoXDTM3MDkyODIz
|
||||
NDMwMFowgYMxCzAJBgNVBAYTAlVTMR0wGwYDVQQKExRBT0wgVGltZSBXYXJuZXIg
|
||||
SW5jLjEcMBoGA1UECxMTQW1lcmljYSBPbmxpbmUgSW5jLjE3MDUGA1UEAxMuQU9M
|
||||
IFRpbWUgV2FybmVyIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMjCCAiIw
|
||||
DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALQ3WggWmRToVbEbJGv8x4vmh6mJ
|
||||
7ouZzU9AhqS2TcnZsdw8TQ2FTBVsRotSeJ/4I/1n9SQ6aF3Q92RhQVSji6UI0ilb
|
||||
m2BPJoPRYxJWSXakFsKlnUWsi4SVqBax7J/qJBrvuVdcmiQhLE0OcR+mrF1FdAOY
|
||||
xFSMFkpBd4aVdQxHAWZg/BXxD+r1FHjHDtdugRxev17nOirYlxcwfACtCJ0zr7iZ
|
||||
YYCLqJV+FNwSbKTQ2O9ASQI2+W6p1h2WVgSysy0WVoaP2SBXgM1nEG2wTPDaRrbq
|
||||
JS5Gr42whTg0ixQmgiusrpkLjhTXUr2eacOGAgvqdnUxCc4zGSGFQ+aJLZ8lN2fx
|
||||
I2rSAG2X+Z/nKcrdH9cG6rjJuQkhn8g/BsXS6RJGAE57COtCPStIbp1n3UsC5ETz
|
||||
kxmlJ85per5n0/xQpCyrw2u544BMzwVhSyvcG7mm0tCq9Stz+86QNZ8MUhy/XCFh
|
||||
EVsVS6kkUfykXPcXnbDS+gfpj1bkGoxoigTTfFrjnqKhynFbotSg5ymFXQNoKk/S
|
||||
Btc9+cMDLz9l+WceR0DTYw/j1Y75hauXTLPXJuuWCpTehTacyH+BCQJJKg71ZDIM
|
||||
gtG6aoIbs0t0EfOMd9afv9w3pKdVBC/UMejTRrkDfNoSTllkt1ExMVCgyhwn2RAu
|
||||
rda9EGYrw7AiShJbAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
|
||||
FE9pbQN+nZ8HGEO8txBO1b+pxCAoMB8GA1UdIwQYMBaAFE9pbQN+nZ8HGEO8txBO
|
||||
1b+pxCAoMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQUFAAOCAgEAO/Ouyugu
|
||||
h4X7ZVnnrREUpVe8WJ8kEle7+z802u6teio0cnAxa8cZmIDJgt43d15Ui47y6mdP
|
||||
yXSEkVYJ1eV6moG2gcKtNuTxVBFT8zRFASbI5Rq8NEQh3q0l/HYWdyGQgJhXnU7q
|
||||
7C+qPBR7V8F+GBRn7iTGvboVsNIYvbdVgaxTwOjdaRITQrcCtQVBynlQboIOcXKT
|
||||
RuidDV29rs4prWPVVRaAMCf/drr3uNZK49m1+VLQTkCpx+XCMseqdiThawVQ68W/
|
||||
ClTluUI8JPu3B5wwn3la5uBAUhX0/Kr0VvlEl4ftDmVyXr4m+02kLQgH3thcoNyB
|
||||
M5kYJRF3p+v9WAksmWsbivNSPxpNSGDxoPYzAlOL7SUJuA0t7Zdz7NeWH45gDtoQ
|
||||
my8YJPamTQr5O8t1wswvziRpyQoijlmn94IM19drNZxDAGrElWe6nEXLuA4399xO
|
||||
AU++CrYD062KRffaJ00psUjf5BHklka9bAI+1lHIlRcBFanyqqryvy9lG2/QuRqT
|
||||
9Y41xICHPpQvZuTpqP9BnHAqTyo5GJUefvthATxRCC4oGKQWDzH9OmwjkyB24f0H
|
||||
hdFbP9IcczLd+rn4jM8Ch3qaluTtT4mNU0OrDhPAARW0eTjb/G49nlG2uBOLZ8/5
|
||||
fNkiHfZdxRwBL5joeiQYvITX+txyW/fBOmg=
|
||||
-----END CERTIFICATE-----
|
||||
23
config
23
config
@@ -527,9 +527,9 @@ case "$GUESSOS" in
|
||||
esac
|
||||
if [ "$CC" = "gcc" ]; then
|
||||
case ${ISA:-generic} in
|
||||
EV5|EV45) options="$options -mcpu=ev5";;
|
||||
EV56|PCA56) options="$options -mcpu=ev56";;
|
||||
*) options="$options -mcpu=ev6";;
|
||||
EV5|EV45) options="$options -march=ev5";;
|
||||
EV56|PCA56) options="$options -march=ev56";;
|
||||
*) options="$options -march=ev6";;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
@@ -585,18 +585,21 @@ case "$GUESSOS" in
|
||||
OUT="linux-generic32" ;;
|
||||
arm*b-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
|
||||
arm*l-*-linux2) OUT="linux-generic32"; options="$options -DL_ENDIAN" ;;
|
||||
sh*b-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
|
||||
sh*-*-linux2) OUT="linux-generic32"; options="$options -DL_ENDIAN" ;;
|
||||
m68k*-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN" ;;
|
||||
s390*-*-linux2) OUT="linux-generic32"; options="$options -DB_ENDIAN -DNO_ASM" ;;
|
||||
x86_64-*-linux?) OUT="linux-x86_64" ;;
|
||||
*86-*-linux2) OUT="linux-elf"
|
||||
if [ "$GCCVER" -gt 28 ]; then
|
||||
if grep '^model.*Pentium' /proc/cpuinfo >/dev/null ; then
|
||||
options="$options -mcpu=pentium"
|
||||
options="$options -march=pentium"
|
||||
fi
|
||||
if grep '^model.*Pentium Pro' /proc/cpuinfo >/dev/null ; then
|
||||
options="$options -mcpu=pentiumpro"
|
||||
options="$options -march=pentiumpro"
|
||||
fi
|
||||
if grep '^model.*K6' /proc/cpuinfo >/dev/null ; then
|
||||
options="$options -mcpu=k6"
|
||||
options="$options -march=k6"
|
||||
fi
|
||||
fi ;;
|
||||
*-*-linux1) OUT="linux-aout" ;;
|
||||
@@ -717,9 +720,9 @@ case "$GUESSOS" in
|
||||
fi
|
||||
fi
|
||||
elif [ $CPU_VERSION -ge 528 ]; then # PA-RISC 1.1+ CPU
|
||||
OUT="hpux-parisc-${CC}
|
||||
OUT="hpux-parisc-${CC}"
|
||||
elif [ $CPU_VERSION -ge 523 ]; then # PA-RISC 1.0 CPU
|
||||
OUT="hpux-parisc-${CC}
|
||||
OUT="hpux-parisc-${CC}"
|
||||
else # Motorola(?) CPU
|
||||
OUT="hpux-$CC"
|
||||
fi
|
||||
@@ -774,7 +777,7 @@ esac
|
||||
# options="$options -DATALLA"
|
||||
#fi
|
||||
|
||||
# gcc < 2.8 does not support -mcpu=ultrasparc
|
||||
# gcc < 2.8 does not support -march=ultrasparc
|
||||
if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
|
||||
then
|
||||
echo "WARNING! Falling down to 'solaris-sparcv8-gcc'."
|
||||
@@ -794,7 +797,7 @@ case "$GUESSOS" in
|
||||
i386-*) options="$options 386" ;;
|
||||
esac
|
||||
|
||||
for i in bf cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 aes ripemd rsa sha
|
||||
for i in aes bf camellia cast des dh dsa ec hmac idea md2 md5 mdc2 rc2 rc4 rc5 ripemd rsa sha
|
||||
do
|
||||
if [ ! -d crypto/$i ]
|
||||
then
|
||||
|
||||
@@ -23,8 +23,10 @@ TEST=
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=aes_core.c aes_misc.c aes_ecb.c aes_cbc.c aes_cfb.c aes_ofb.c aes_ctr.c
|
||||
LIBOBJ=aes_misc.o aes_ecb.o aes_cfb.o aes_ofb.o aes_ctr.o $(AES_ASM_OBJ)
|
||||
LIBSRC=aes_core.c aes_misc.c aes_ecb.c aes_cbc.c aes_cfb.c aes_ofb.c \
|
||||
aes_ctr.c aes_ige.c
|
||||
LIBOBJ=aes_misc.o aes_ecb.o aes_cfb.o aes_ofb.o aes_ctr.o aes_ige.o \
|
||||
$(AES_ASM_OBJ)
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
@@ -103,6 +105,13 @@ aes_ctr.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
|
||||
aes_ctr.o: ../../include/openssl/opensslconf.h aes_ctr.c aes_locl.h
|
||||
aes_ecb.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
|
||||
aes_ecb.o: ../../include/openssl/opensslconf.h aes_ecb.c aes_locl.h
|
||||
aes_ige.o: ../../e_os.h ../../include/openssl/aes.h ../../include/openssl/bio.h
|
||||
aes_ige.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
aes_ige.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
aes_ige.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
aes_ige.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
aes_ige.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
aes_ige.o: ../../include/openssl/symhacks.h ../cryptlib.h aes_ige.c aes_locl.h
|
||||
aes_misc.o: ../../include/openssl/aes.h ../../include/openssl/e_os2.h
|
||||
aes_misc.o: ../../include/openssl/opensslconf.h
|
||||
aes_misc.o: ../../include/openssl/opensslv.h aes_locl.h aes_misc.c
|
||||
|
||||
@@ -119,6 +119,17 @@ void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
unsigned char ecount_buf[AES_BLOCK_SIZE],
|
||||
unsigned int *num);
|
||||
|
||||
/* For IGE, see also http://www.links.org/files/openssl-ige.pdf */
|
||||
/* NB: the IV is _two_ blocks long */
|
||||
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
/* NB: the IV is _four_ blocks long */
|
||||
void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
const AES_KEY *key2, const unsigned char *ivec,
|
||||
const int enc);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -44,22 +44,14 @@ Te0[x] = S [x].[02, 01, 01, 03];
|
||||
Te1[x] = S [x].[03, 02, 01, 01];
|
||||
Te2[x] = S [x].[01, 03, 02, 01];
|
||||
Te3[x] = S [x].[01, 01, 03, 02];
|
||||
Te4[x] = S [x].[01, 01, 01, 01];
|
||||
|
||||
Td0[x] = Si[x].[0e, 09, 0d, 0b];
|
||||
Td1[x] = Si[x].[0b, 0e, 09, 0d];
|
||||
Td2[x] = Si[x].[0d, 0b, 0e, 09];
|
||||
Td3[x] = Si[x].[09, 0d, 0b, 0e];
|
||||
Td4[x] = Si[x].[01, 01, 01, 01];
|
||||
Td4[x] = Si[x].[01];
|
||||
*/
|
||||
|
||||
#ifdef AES_ASM
|
||||
extern const u32 AES_Te[5][256];
|
||||
#define Te0 AES_Te[0]
|
||||
#define Te1 AES_Te[1]
|
||||
#define Te2 AES_Te[2]
|
||||
#define Te3 AES_Te[3]
|
||||
#else
|
||||
static const u32 Te0[256] = {
|
||||
0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
|
||||
0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
|
||||
@@ -324,81 +316,7 @@ static const u32 Te3[256] = {
|
||||
0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
|
||||
0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
|
||||
};
|
||||
#endif
|
||||
static const u32 Te4[256] = {
|
||||
0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
|
||||
0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
|
||||
0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
|
||||
0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
|
||||
0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
|
||||
0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
|
||||
0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
|
||||
0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
|
||||
0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
|
||||
0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
|
||||
0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
|
||||
0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
|
||||
0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
|
||||
0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
|
||||
0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
|
||||
0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
|
||||
0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
|
||||
0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
|
||||
0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
|
||||
0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
|
||||
0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
|
||||
0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
|
||||
0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
|
||||
0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
|
||||
0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
|
||||
0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
|
||||
0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
|
||||
0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
|
||||
0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
|
||||
0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
|
||||
0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
|
||||
0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
|
||||
0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
|
||||
0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
|
||||
0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
|
||||
0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
|
||||
0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
|
||||
0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
|
||||
0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
|
||||
0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
|
||||
0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
|
||||
0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
|
||||
0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
|
||||
0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
|
||||
0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
|
||||
0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
|
||||
0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
|
||||
0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
|
||||
0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
|
||||
0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
|
||||
0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
|
||||
0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
|
||||
0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
|
||||
0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
|
||||
0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
|
||||
0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
|
||||
0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
|
||||
0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
|
||||
0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
|
||||
0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
|
||||
0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
|
||||
0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
|
||||
0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
|
||||
0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
|
||||
};
|
||||
|
||||
#ifdef AES_ASM
|
||||
extern const u32 AES_Td[5][256];
|
||||
#define Td0 AES_Td[0]
|
||||
#define Td1 AES_Td[1]
|
||||
#define Td2 AES_Td[2]
|
||||
#define Td3 AES_Td[3]
|
||||
#else
|
||||
static const u32 Td0[256] = {
|
||||
0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
|
||||
0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
|
||||
@@ -663,72 +581,39 @@ static const u32 Td3[256] = {
|
||||
0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
|
||||
0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
|
||||
};
|
||||
#endif
|
||||
static const u32 Td4[256] = {
|
||||
0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
|
||||
0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
|
||||
0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
|
||||
0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
|
||||
0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
|
||||
0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
|
||||
0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
|
||||
0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
|
||||
0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
|
||||
0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
|
||||
0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
|
||||
0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
|
||||
0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
|
||||
0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
|
||||
0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
|
||||
0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
|
||||
0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
|
||||
0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
|
||||
0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
|
||||
0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
|
||||
0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
|
||||
0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
|
||||
0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
|
||||
0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
|
||||
0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
|
||||
0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
|
||||
0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
|
||||
0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
|
||||
0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
|
||||
0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
|
||||
0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
|
||||
0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
|
||||
0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
|
||||
0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
|
||||
0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
|
||||
0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
|
||||
0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
|
||||
0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
|
||||
0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
|
||||
0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
|
||||
0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
|
||||
0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
|
||||
0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
|
||||
0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
|
||||
0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
|
||||
0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
|
||||
0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
|
||||
0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
|
||||
0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
|
||||
0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
|
||||
0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
|
||||
0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
|
||||
0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
|
||||
0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
|
||||
0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
|
||||
0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
|
||||
0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
|
||||
0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
|
||||
0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
|
||||
0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
|
||||
0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
|
||||
0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
|
||||
0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
|
||||
0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
|
||||
static const u8 Td4[256] = {
|
||||
0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U,
|
||||
0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU,
|
||||
0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U,
|
||||
0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU,
|
||||
0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU,
|
||||
0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU,
|
||||
0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U,
|
||||
0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U,
|
||||
0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U,
|
||||
0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U,
|
||||
0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU,
|
||||
0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U,
|
||||
0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU,
|
||||
0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U,
|
||||
0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U,
|
||||
0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU,
|
||||
0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU,
|
||||
0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U,
|
||||
0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U,
|
||||
0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU,
|
||||
0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U,
|
||||
0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU,
|
||||
0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U,
|
||||
0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U,
|
||||
0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U,
|
||||
0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU,
|
||||
0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU,
|
||||
0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU,
|
||||
0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U,
|
||||
0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U,
|
||||
0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U,
|
||||
0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU,
|
||||
};
|
||||
static const u32 rcon[] = {
|
||||
0x01000000, 0x02000000, 0x04000000, 0x08000000,
|
||||
@@ -768,10 +653,10 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||
while (1) {
|
||||
temp = rk[3];
|
||||
rk[4] = rk[0] ^
|
||||
(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
|
||||
(Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
|
||||
(Te4[(temp ) & 0xff] & 0x0000ff00) ^
|
||||
(Te4[(temp >> 24) ] & 0x000000ff) ^
|
||||
(Te2[(temp >> 16) & 0xff] & 0xff000000) ^
|
||||
(Te3[(temp >> 8) & 0xff] & 0x00ff0000) ^
|
||||
(Te0[(temp ) & 0xff] & 0x0000ff00) ^
|
||||
(Te1[(temp >> 24) ] & 0x000000ff) ^
|
||||
rcon[i];
|
||||
rk[5] = rk[1] ^ rk[4];
|
||||
rk[6] = rk[2] ^ rk[5];
|
||||
@@ -788,10 +673,10 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||
while (1) {
|
||||
temp = rk[ 5];
|
||||
rk[ 6] = rk[ 0] ^
|
||||
(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
|
||||
(Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
|
||||
(Te4[(temp ) & 0xff] & 0x0000ff00) ^
|
||||
(Te4[(temp >> 24) ] & 0x000000ff) ^
|
||||
(Te2[(temp >> 16) & 0xff] & 0xff000000) ^
|
||||
(Te3[(temp >> 8) & 0xff] & 0x00ff0000) ^
|
||||
(Te0[(temp ) & 0xff] & 0x0000ff00) ^
|
||||
(Te1[(temp >> 24) ] & 0x000000ff) ^
|
||||
rcon[i];
|
||||
rk[ 7] = rk[ 1] ^ rk[ 6];
|
||||
rk[ 8] = rk[ 2] ^ rk[ 7];
|
||||
@@ -810,10 +695,10 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||
while (1) {
|
||||
temp = rk[ 7];
|
||||
rk[ 8] = rk[ 0] ^
|
||||
(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
|
||||
(Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
|
||||
(Te4[(temp ) & 0xff] & 0x0000ff00) ^
|
||||
(Te4[(temp >> 24) ] & 0x000000ff) ^
|
||||
(Te2[(temp >> 16) & 0xff] & 0xff000000) ^
|
||||
(Te3[(temp >> 8) & 0xff] & 0x00ff0000) ^
|
||||
(Te0[(temp ) & 0xff] & 0x0000ff00) ^
|
||||
(Te1[(temp >> 24) ] & 0x000000ff) ^
|
||||
rcon[i];
|
||||
rk[ 9] = rk[ 1] ^ rk[ 8];
|
||||
rk[10] = rk[ 2] ^ rk[ 9];
|
||||
@@ -823,10 +708,10 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
|
||||
}
|
||||
temp = rk[11];
|
||||
rk[12] = rk[ 4] ^
|
||||
(Te4[(temp >> 24) ] & 0xff000000) ^
|
||||
(Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te4[(temp ) & 0xff] & 0x000000ff);
|
||||
(Te2[(temp >> 24) ] & 0xff000000) ^
|
||||
(Te3[(temp >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te0[(temp >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te1[(temp ) & 0xff] & 0x000000ff);
|
||||
rk[13] = rk[ 5] ^ rk[12];
|
||||
rk[14] = rk[ 6] ^ rk[13];
|
||||
rk[15] = rk[ 7] ^ rk[14];
|
||||
@@ -865,25 +750,25 @@ int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
|
||||
for (i = 1; i < (key->rounds); i++) {
|
||||
rk += 4;
|
||||
rk[0] =
|
||||
Td0[Te4[(rk[0] >> 24) ] & 0xff] ^
|
||||
Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^
|
||||
Td2[Te4[(rk[0] >> 8) & 0xff] & 0xff] ^
|
||||
Td3[Te4[(rk[0] ) & 0xff] & 0xff];
|
||||
Td0[Te1[(rk[0] >> 24) ] & 0xff] ^
|
||||
Td1[Te1[(rk[0] >> 16) & 0xff] & 0xff] ^
|
||||
Td2[Te1[(rk[0] >> 8) & 0xff] & 0xff] ^
|
||||
Td3[Te1[(rk[0] ) & 0xff] & 0xff];
|
||||
rk[1] =
|
||||
Td0[Te4[(rk[1] >> 24) ] & 0xff] ^
|
||||
Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^
|
||||
Td2[Te4[(rk[1] >> 8) & 0xff] & 0xff] ^
|
||||
Td3[Te4[(rk[1] ) & 0xff] & 0xff];
|
||||
Td0[Te1[(rk[1] >> 24) ] & 0xff] ^
|
||||
Td1[Te1[(rk[1] >> 16) & 0xff] & 0xff] ^
|
||||
Td2[Te1[(rk[1] >> 8) & 0xff] & 0xff] ^
|
||||
Td3[Te1[(rk[1] ) & 0xff] & 0xff];
|
||||
rk[2] =
|
||||
Td0[Te4[(rk[2] >> 24) ] & 0xff] ^
|
||||
Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^
|
||||
Td2[Te4[(rk[2] >> 8) & 0xff] & 0xff] ^
|
||||
Td3[Te4[(rk[2] ) & 0xff] & 0xff];
|
||||
Td0[Te1[(rk[2] >> 24) ] & 0xff] ^
|
||||
Td1[Te1[(rk[2] >> 16) & 0xff] & 0xff] ^
|
||||
Td2[Te1[(rk[2] >> 8) & 0xff] & 0xff] ^
|
||||
Td3[Te1[(rk[2] ) & 0xff] & 0xff];
|
||||
rk[3] =
|
||||
Td0[Te4[(rk[3] >> 24) ] & 0xff] ^
|
||||
Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^
|
||||
Td2[Te4[(rk[3] >> 8) & 0xff] & 0xff] ^
|
||||
Td3[Te4[(rk[3] ) & 0xff] & 0xff];
|
||||
Td0[Te1[(rk[3] >> 24) ] & 0xff] ^
|
||||
Td1[Te1[(rk[3] >> 16) & 0xff] & 0xff] ^
|
||||
Td2[Te1[(rk[3] >> 8) & 0xff] & 0xff] ^
|
||||
Td3[Te1[(rk[3] ) & 0xff] & 0xff];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1051,31 +936,31 @@ void AES_encrypt(const unsigned char *in, unsigned char *out,
|
||||
* map cipher state to byte array block:
|
||||
*/
|
||||
s0 =
|
||||
(Te4[(t0 >> 24) ] & 0xff000000) ^
|
||||
(Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te4[(t2 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te4[(t3 ) & 0xff] & 0x000000ff) ^
|
||||
(Te2[(t0 >> 24) ] & 0xff000000) ^
|
||||
(Te3[(t1 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te0[(t2 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te1[(t3 ) & 0xff] & 0x000000ff) ^
|
||||
rk[0];
|
||||
PUTU32(out , s0);
|
||||
s1 =
|
||||
(Te4[(t1 >> 24) ] & 0xff000000) ^
|
||||
(Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te4[(t3 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te4[(t0 ) & 0xff] & 0x000000ff) ^
|
||||
(Te2[(t1 >> 24) ] & 0xff000000) ^
|
||||
(Te3[(t2 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te0[(t3 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te1[(t0 ) & 0xff] & 0x000000ff) ^
|
||||
rk[1];
|
||||
PUTU32(out + 4, s1);
|
||||
s2 =
|
||||
(Te4[(t2 >> 24) ] & 0xff000000) ^
|
||||
(Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te4[(t0 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te4[(t1 ) & 0xff] & 0x000000ff) ^
|
||||
(Te2[(t2 >> 24) ] & 0xff000000) ^
|
||||
(Te3[(t3 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te0[(t0 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te1[(t1 ) & 0xff] & 0x000000ff) ^
|
||||
rk[2];
|
||||
PUTU32(out + 8, s2);
|
||||
s3 =
|
||||
(Te4[(t3 >> 24) ] & 0xff000000) ^
|
||||
(Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te4[(t1 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te4[(t2 ) & 0xff] & 0x000000ff) ^
|
||||
(Te2[(t3 >> 24) ] & 0xff000000) ^
|
||||
(Te3[(t0 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Te0[(t1 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Te1[(t2 ) & 0xff] & 0x000000ff) ^
|
||||
rk[3];
|
||||
PUTU32(out + 12, s3);
|
||||
}
|
||||
@@ -1242,31 +1127,31 @@ void AES_decrypt(const unsigned char *in, unsigned char *out,
|
||||
* map cipher state to byte array block:
|
||||
*/
|
||||
s0 =
|
||||
(Td4[(t0 >> 24) ] & 0xff000000) ^
|
||||
(Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Td4[(t1 ) & 0xff] & 0x000000ff) ^
|
||||
(Td4[(t0 >> 24) ] << 24) ^
|
||||
(Td4[(t3 >> 16) & 0xff] << 16) ^
|
||||
(Td4[(t2 >> 8) & 0xff] << 8) ^
|
||||
(Td4[(t1 ) & 0xff]) ^
|
||||
rk[0];
|
||||
PUTU32(out , s0);
|
||||
s1 =
|
||||
(Td4[(t1 >> 24) ] & 0xff000000) ^
|
||||
(Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Td4[(t2 ) & 0xff] & 0x000000ff) ^
|
||||
(Td4[(t1 >> 24) ] << 24) ^
|
||||
(Td4[(t0 >> 16) & 0xff] << 16) ^
|
||||
(Td4[(t3 >> 8) & 0xff] << 8) ^
|
||||
(Td4[(t2 ) & 0xff]) ^
|
||||
rk[1];
|
||||
PUTU32(out + 4, s1);
|
||||
s2 =
|
||||
(Td4[(t2 >> 24) ] & 0xff000000) ^
|
||||
(Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Td4[(t3 ) & 0xff] & 0x000000ff) ^
|
||||
(Td4[(t2 >> 24) ] << 24) ^
|
||||
(Td4[(t1 >> 16) & 0xff] << 16) ^
|
||||
(Td4[(t0 >> 8) & 0xff] << 8) ^
|
||||
(Td4[(t3 ) & 0xff]) ^
|
||||
rk[2];
|
||||
PUTU32(out + 8, s2);
|
||||
s3 =
|
||||
(Td4[(t3 >> 24) ] & 0xff000000) ^
|
||||
(Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^
|
||||
(Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^
|
||||
(Td4[(t0 ) & 0xff] & 0x000000ff) ^
|
||||
(Td4[(t3 >> 24) ] << 24) ^
|
||||
(Td4[(t2 >> 16) & 0xff] << 16) ^
|
||||
(Td4[(t1 >> 8) & 0xff] << 8) ^
|
||||
(Td4[(t0 ) & 0xff]) ^
|
||||
rk[3];
|
||||
PUTU32(out + 12, s3);
|
||||
}
|
||||
|
||||
283
crypto/aes/aes_ige.c
Normal file
283
crypto/aes/aes_ige.c
Normal file
@@ -0,0 +1,283 @@
|
||||
/* crypto/aes/aes_ige.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cryptlib.h"
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include "aes_locl.h"
|
||||
|
||||
/*
|
||||
static void hexdump(FILE *f,const char *title,const unsigned char *s,int l)
|
||||
{
|
||||
int n=0;
|
||||
|
||||
fprintf(f,"%s",title);
|
||||
for( ; n < l ; ++n)
|
||||
{
|
||||
if((n%16) == 0)
|
||||
fprintf(f,"\n%04x",n);
|
||||
fprintf(f," %02x",s[n]);
|
||||
}
|
||||
fprintf(f,"\n");
|
||||
}
|
||||
*/
|
||||
|
||||
/* N.B. The IV for this mode is _twice_ the block size */
|
||||
|
||||
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc)
|
||||
{
|
||||
unsigned long n;
|
||||
unsigned long len = length;
|
||||
unsigned char tmp[AES_BLOCK_SIZE];
|
||||
unsigned char tmp2[AES_BLOCK_SIZE];
|
||||
unsigned char prev[AES_BLOCK_SIZE];
|
||||
const unsigned char *iv = ivec;
|
||||
const unsigned char *iv2 = ivec + AES_BLOCK_SIZE;
|
||||
|
||||
OPENSSL_assert(in && out && key && ivec);
|
||||
OPENSSL_assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
|
||||
OPENSSL_assert((length%AES_BLOCK_SIZE) == 0);
|
||||
|
||||
if (AES_ENCRYPT == enc)
|
||||
{
|
||||
/* XXX: Do a separate case for when in != out (strictly should
|
||||
check for overlap, too) */
|
||||
while (len >= AES_BLOCK_SIZE)
|
||||
{
|
||||
/* hexdump(stdout, "in", in, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout, "iv", iv, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
out[n] = in[n] ^ iv[n];
|
||||
/* hexdump(stdout, "in ^ iv", out, AES_BLOCK_SIZE); */
|
||||
AES_encrypt(out, out, key);
|
||||
/* hexdump(stdout,"enc", out, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout,"iv2", iv2, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
out[n] ^= iv2[n];
|
||||
/* hexdump(stdout,"out", out, AES_BLOCK_SIZE); */
|
||||
iv = out;
|
||||
memcpy(prev, in, AES_BLOCK_SIZE);
|
||||
iv2 = prev;
|
||||
len -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
memcpy(ivec, iv, AES_BLOCK_SIZE);
|
||||
memcpy(ivec + AES_BLOCK_SIZE, iv2, AES_BLOCK_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (len >= AES_BLOCK_SIZE)
|
||||
{
|
||||
memcpy(tmp, in, AES_BLOCK_SIZE);
|
||||
memcpy(tmp2, in, AES_BLOCK_SIZE);
|
||||
/* hexdump(stdout, "in", in, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout, "iv2", iv2, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
tmp[n] ^= iv2[n];
|
||||
/* hexdump(stdout, "in ^ iv2", tmp, AES_BLOCK_SIZE); */
|
||||
AES_decrypt(tmp, out, key);
|
||||
/* hexdump(stdout, "dec", out, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout, "iv", ivec, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
out[n] ^= ivec[n];
|
||||
/* hexdump(stdout, "out", out, AES_BLOCK_SIZE); */
|
||||
memcpy(ivec, tmp2, AES_BLOCK_SIZE);
|
||||
iv2 = out;
|
||||
len -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
memcpy(ivec + AES_BLOCK_SIZE, iv2, AES_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that its effectively impossible to do biIGE in anything other
|
||||
* than a single pass, so no provision is made for chaining.
|
||||
*/
|
||||
|
||||
/* N.B. The IV for this mode is _four times_ the block size */
|
||||
|
||||
void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const AES_KEY *key,
|
||||
const AES_KEY *key2, const unsigned char *ivec,
|
||||
const int enc)
|
||||
{
|
||||
unsigned long n;
|
||||
unsigned long len = length;
|
||||
unsigned char tmp[AES_BLOCK_SIZE];
|
||||
unsigned char tmp2[AES_BLOCK_SIZE];
|
||||
unsigned char tmp3[AES_BLOCK_SIZE];
|
||||
unsigned char prev[AES_BLOCK_SIZE];
|
||||
const unsigned char *iv;
|
||||
const unsigned char *iv2;
|
||||
|
||||
OPENSSL_assert(in && out && key && ivec);
|
||||
OPENSSL_assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc));
|
||||
OPENSSL_assert((length%AES_BLOCK_SIZE) == 0);
|
||||
|
||||
if (AES_ENCRYPT == enc)
|
||||
{
|
||||
/* XXX: Do a separate case for when in != out (strictly should
|
||||
check for overlap, too) */
|
||||
|
||||
/* First the forward pass */
|
||||
iv = ivec;
|
||||
iv2 = ivec + AES_BLOCK_SIZE;
|
||||
while (len >= AES_BLOCK_SIZE)
|
||||
{
|
||||
/* hexdump(stdout, "in", in, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout, "iv", iv, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
out[n] = in[n] ^ iv[n];
|
||||
/* hexdump(stdout, "in ^ iv", out, AES_BLOCK_SIZE); */
|
||||
AES_encrypt(out, out, key);
|
||||
/* hexdump(stdout,"enc", out, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout,"iv2", iv2, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
out[n] ^= iv2[n];
|
||||
/* hexdump(stdout,"out", out, AES_BLOCK_SIZE); */
|
||||
iv = out;
|
||||
memcpy(prev, in, AES_BLOCK_SIZE);
|
||||
iv2 = prev;
|
||||
len -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
/* And now backwards */
|
||||
iv = ivec + AES_BLOCK_SIZE*2;
|
||||
iv2 = ivec + AES_BLOCK_SIZE*3;
|
||||
len = length;
|
||||
while(len >= AES_BLOCK_SIZE)
|
||||
{
|
||||
out -= AES_BLOCK_SIZE;
|
||||
/* hexdump(stdout, "intermediate", out, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout, "iv", iv, AES_BLOCK_SIZE); */
|
||||
/* XXX: reduce copies by alternating between buffers */
|
||||
memcpy(tmp, out, AES_BLOCK_SIZE);
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
out[n] ^= iv[n];
|
||||
/* hexdump(stdout, "out ^ iv", out, AES_BLOCK_SIZE); */
|
||||
AES_encrypt(out, out, key);
|
||||
/* hexdump(stdout,"enc", out, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout,"iv2", iv2, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
out[n] ^= iv2[n];
|
||||
/* hexdump(stdout,"out", out, AES_BLOCK_SIZE); */
|
||||
iv = out;
|
||||
memcpy(prev, tmp, AES_BLOCK_SIZE);
|
||||
iv2 = prev;
|
||||
len -= AES_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* First backwards */
|
||||
iv = ivec + AES_BLOCK_SIZE*2;
|
||||
iv2 = ivec + AES_BLOCK_SIZE*3;
|
||||
in += length;
|
||||
out += length;
|
||||
while (len >= AES_BLOCK_SIZE)
|
||||
{
|
||||
in -= AES_BLOCK_SIZE;
|
||||
out -= AES_BLOCK_SIZE;
|
||||
memcpy(tmp, in, AES_BLOCK_SIZE);
|
||||
memcpy(tmp2, in, AES_BLOCK_SIZE);
|
||||
/* hexdump(stdout, "in", in, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout, "iv2", iv2, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
tmp[n] ^= iv2[n];
|
||||
/* hexdump(stdout, "in ^ iv2", tmp, AES_BLOCK_SIZE); */
|
||||
AES_decrypt(tmp, out, key);
|
||||
/* hexdump(stdout, "dec", out, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout, "iv", iv, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
out[n] ^= iv[n];
|
||||
/* hexdump(stdout, "out", out, AES_BLOCK_SIZE); */
|
||||
memcpy(tmp3, tmp2, AES_BLOCK_SIZE);
|
||||
iv = tmp3;
|
||||
iv2 = out;
|
||||
len -= AES_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
/* And now forwards */
|
||||
iv = ivec;
|
||||
iv2 = ivec + AES_BLOCK_SIZE;
|
||||
len = length;
|
||||
while (len >= AES_BLOCK_SIZE)
|
||||
{
|
||||
memcpy(tmp, out, AES_BLOCK_SIZE);
|
||||
memcpy(tmp2, out, AES_BLOCK_SIZE);
|
||||
/* hexdump(stdout, "intermediate", out, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout, "iv2", iv2, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
tmp[n] ^= iv2[n];
|
||||
/* hexdump(stdout, "out ^ iv2", tmp, AES_BLOCK_SIZE); */
|
||||
AES_decrypt(tmp, out, key);
|
||||
/* hexdump(stdout, "dec", out, AES_BLOCK_SIZE); */
|
||||
/* hexdump(stdout, "iv", ivec, AES_BLOCK_SIZE); */
|
||||
for(n=0 ; n < AES_BLOCK_SIZE ; ++n)
|
||||
out[n] ^= iv[n];
|
||||
/* hexdump(stdout, "out", out, AES_BLOCK_SIZE); */
|
||||
memcpy(tmp3, tmp2, AES_BLOCK_SIZE);
|
||||
iv = tmp3;
|
||||
iv2 = out;
|
||||
len -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@
|
||||
#include <openssl/aes.h>
|
||||
#include "aes_locl.h"
|
||||
|
||||
const char *AES_version="AES" OPENSSL_VERSION_PTEXT;
|
||||
const char AES_version[]="AES" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
const char *AES_options(void) {
|
||||
#ifdef FULL_UNROLL
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# forms are granted according to the OpenSSL license.
|
||||
# ====================================================================
|
||||
#
|
||||
# Version 3.4.
|
||||
# Version 3.6.
|
||||
#
|
||||
# You might fail to appreciate this module performance from the first
|
||||
# try. If compared to "vanilla" linux-ia32-icc target, i.e. considered
|
||||
@@ -66,6 +66,13 @@
|
||||
# stack. This unfortunately has rather strong impact on small block CBC
|
||||
# performance, ~2x deterioration on 16-byte block if compared to 3.3.
|
||||
#
|
||||
# Version 3.5 checks if there is L1 cache aliasing between user-supplied
|
||||
# key schedule and S-boxes and abstains from copying the former if
|
||||
# there is no. This allows end-user to consciously retain small block
|
||||
# performance by aligning key schedule in specific manner.
|
||||
#
|
||||
# Version 3.6 compresses Td4 to 256 bytes and prefetches it in ECB.
|
||||
#
|
||||
# Current ECB performance numbers for 128-bit key in CPU cycles per
|
||||
# processed byte [measure commonly used by AES benchmarkers] are:
|
||||
#
|
||||
@@ -505,28 +512,27 @@ sub declast()
|
||||
if($i==3) { &mov ($key,&DWP(12,"esp")); }
|
||||
else { &mov ($out,$s[0]); }
|
||||
&and ($out,0xFF);
|
||||
&mov ($out,&DWP(2048,$td,$out,4));
|
||||
&and ($out,0x000000ff);
|
||||
&movz ($out,&DWP(2048,$td,$out,1));
|
||||
|
||||
if ($i==3) { $tmp=$s[1]; }
|
||||
&movz ($tmp,&HB($s[1]));
|
||||
&mov ($tmp,&DWP(2048,$td,$tmp,4));
|
||||
&and ($tmp,0x0000ff00);
|
||||
&movz ($tmp,&DWP(2048,$td,$tmp,1));
|
||||
&shl ($tmp,8);
|
||||
&xor ($out,$tmp);
|
||||
|
||||
if ($i==3) { $tmp=$s[2]; &mov ($s[1],$acc); }
|
||||
else { mov ($tmp,$s[2]); }
|
||||
&shr ($tmp,16);
|
||||
&and ($tmp,0xFF);
|
||||
&mov ($tmp,&DWP(2048,$td,$tmp,4));
|
||||
&and ($tmp,0x00ff0000);
|
||||
&movz ($tmp,&DWP(2048,$td,$tmp,1));
|
||||
&shl ($tmp,16);
|
||||
&xor ($out,$tmp);
|
||||
|
||||
if ($i==3) { $tmp=$s[3]; &mov ($s[2],&DWP(8,"esp")); }
|
||||
else { &mov ($tmp,$s[3]); }
|
||||
&shr ($tmp,24);
|
||||
&mov ($tmp,&DWP(2048,$td,$tmp,4));
|
||||
&and ($tmp,0xff000000);
|
||||
&movz ($tmp,&DWP(2048,$td,$tmp,1));
|
||||
&shl ($tmp,24);
|
||||
&xor ($out,$tmp);
|
||||
if ($i<2) { &mov (&DWP(4+4*$i,"esp"),$out); }
|
||||
if ($i==3) { &mov ($s[3],&DWP(4,"esp")); }
|
||||
@@ -687,70 +693,38 @@ sub declast()
|
||||
&_data_word(0x7101a839, 0xdeb30c08, 0x9ce4b4d8, 0x90c15664);
|
||||
&_data_word(0x6184cb7b, 0x70b632d5, 0x745c6c48, 0x4257b8d0);
|
||||
#Td4:
|
||||
&data_word(0x52525252, 0x09090909, 0x6a6a6a6a, 0xd5d5d5d5);
|
||||
&data_word(0x30303030, 0x36363636, 0xa5a5a5a5, 0x38383838);
|
||||
&data_word(0xbfbfbfbf, 0x40404040, 0xa3a3a3a3, 0x9e9e9e9e);
|
||||
&data_word(0x81818181, 0xf3f3f3f3, 0xd7d7d7d7, 0xfbfbfbfb);
|
||||
&data_word(0x7c7c7c7c, 0xe3e3e3e3, 0x39393939, 0x82828282);
|
||||
&data_word(0x9b9b9b9b, 0x2f2f2f2f, 0xffffffff, 0x87878787);
|
||||
&data_word(0x34343434, 0x8e8e8e8e, 0x43434343, 0x44444444);
|
||||
&data_word(0xc4c4c4c4, 0xdededede, 0xe9e9e9e9, 0xcbcbcbcb);
|
||||
&data_word(0x54545454, 0x7b7b7b7b, 0x94949494, 0x32323232);
|
||||
&data_word(0xa6a6a6a6, 0xc2c2c2c2, 0x23232323, 0x3d3d3d3d);
|
||||
&data_word(0xeeeeeeee, 0x4c4c4c4c, 0x95959595, 0x0b0b0b0b);
|
||||
&data_word(0x42424242, 0xfafafafa, 0xc3c3c3c3, 0x4e4e4e4e);
|
||||
&data_word(0x08080808, 0x2e2e2e2e, 0xa1a1a1a1, 0x66666666);
|
||||
&data_word(0x28282828, 0xd9d9d9d9, 0x24242424, 0xb2b2b2b2);
|
||||
&data_word(0x76767676, 0x5b5b5b5b, 0xa2a2a2a2, 0x49494949);
|
||||
&data_word(0x6d6d6d6d, 0x8b8b8b8b, 0xd1d1d1d1, 0x25252525);
|
||||
&data_word(0x72727272, 0xf8f8f8f8, 0xf6f6f6f6, 0x64646464);
|
||||
&data_word(0x86868686, 0x68686868, 0x98989898, 0x16161616);
|
||||
&data_word(0xd4d4d4d4, 0xa4a4a4a4, 0x5c5c5c5c, 0xcccccccc);
|
||||
&data_word(0x5d5d5d5d, 0x65656565, 0xb6b6b6b6, 0x92929292);
|
||||
&data_word(0x6c6c6c6c, 0x70707070, 0x48484848, 0x50505050);
|
||||
&data_word(0xfdfdfdfd, 0xedededed, 0xb9b9b9b9, 0xdadadada);
|
||||
&data_word(0x5e5e5e5e, 0x15151515, 0x46464646, 0x57575757);
|
||||
&data_word(0xa7a7a7a7, 0x8d8d8d8d, 0x9d9d9d9d, 0x84848484);
|
||||
&data_word(0x90909090, 0xd8d8d8d8, 0xabababab, 0x00000000);
|
||||
&data_word(0x8c8c8c8c, 0xbcbcbcbc, 0xd3d3d3d3, 0x0a0a0a0a);
|
||||
&data_word(0xf7f7f7f7, 0xe4e4e4e4, 0x58585858, 0x05050505);
|
||||
&data_word(0xb8b8b8b8, 0xb3b3b3b3, 0x45454545, 0x06060606);
|
||||
&data_word(0xd0d0d0d0, 0x2c2c2c2c, 0x1e1e1e1e, 0x8f8f8f8f);
|
||||
&data_word(0xcacacaca, 0x3f3f3f3f, 0x0f0f0f0f, 0x02020202);
|
||||
&data_word(0xc1c1c1c1, 0xafafafaf, 0xbdbdbdbd, 0x03030303);
|
||||
&data_word(0x01010101, 0x13131313, 0x8a8a8a8a, 0x6b6b6b6b);
|
||||
&data_word(0x3a3a3a3a, 0x91919191, 0x11111111, 0x41414141);
|
||||
&data_word(0x4f4f4f4f, 0x67676767, 0xdcdcdcdc, 0xeaeaeaea);
|
||||
&data_word(0x97979797, 0xf2f2f2f2, 0xcfcfcfcf, 0xcececece);
|
||||
&data_word(0xf0f0f0f0, 0xb4b4b4b4, 0xe6e6e6e6, 0x73737373);
|
||||
&data_word(0x96969696, 0xacacacac, 0x74747474, 0x22222222);
|
||||
&data_word(0xe7e7e7e7, 0xadadadad, 0x35353535, 0x85858585);
|
||||
&data_word(0xe2e2e2e2, 0xf9f9f9f9, 0x37373737, 0xe8e8e8e8);
|
||||
&data_word(0x1c1c1c1c, 0x75757575, 0xdfdfdfdf, 0x6e6e6e6e);
|
||||
&data_word(0x47474747, 0xf1f1f1f1, 0x1a1a1a1a, 0x71717171);
|
||||
&data_word(0x1d1d1d1d, 0x29292929, 0xc5c5c5c5, 0x89898989);
|
||||
&data_word(0x6f6f6f6f, 0xb7b7b7b7, 0x62626262, 0x0e0e0e0e);
|
||||
&data_word(0xaaaaaaaa, 0x18181818, 0xbebebebe, 0x1b1b1b1b);
|
||||
&data_word(0xfcfcfcfc, 0x56565656, 0x3e3e3e3e, 0x4b4b4b4b);
|
||||
&data_word(0xc6c6c6c6, 0xd2d2d2d2, 0x79797979, 0x20202020);
|
||||
&data_word(0x9a9a9a9a, 0xdbdbdbdb, 0xc0c0c0c0, 0xfefefefe);
|
||||
&data_word(0x78787878, 0xcdcdcdcd, 0x5a5a5a5a, 0xf4f4f4f4);
|
||||
&data_word(0x1f1f1f1f, 0xdddddddd, 0xa8a8a8a8, 0x33333333);
|
||||
&data_word(0x88888888, 0x07070707, 0xc7c7c7c7, 0x31313131);
|
||||
&data_word(0xb1b1b1b1, 0x12121212, 0x10101010, 0x59595959);
|
||||
&data_word(0x27272727, 0x80808080, 0xecececec, 0x5f5f5f5f);
|
||||
&data_word(0x60606060, 0x51515151, 0x7f7f7f7f, 0xa9a9a9a9);
|
||||
&data_word(0x19191919, 0xb5b5b5b5, 0x4a4a4a4a, 0x0d0d0d0d);
|
||||
&data_word(0x2d2d2d2d, 0xe5e5e5e5, 0x7a7a7a7a, 0x9f9f9f9f);
|
||||
&data_word(0x93939393, 0xc9c9c9c9, 0x9c9c9c9c, 0xefefefef);
|
||||
&data_word(0xa0a0a0a0, 0xe0e0e0e0, 0x3b3b3b3b, 0x4d4d4d4d);
|
||||
&data_word(0xaeaeaeae, 0x2a2a2a2a, 0xf5f5f5f5, 0xb0b0b0b0);
|
||||
&data_word(0xc8c8c8c8, 0xebebebeb, 0xbbbbbbbb, 0x3c3c3c3c);
|
||||
&data_word(0x83838383, 0x53535353, 0x99999999, 0x61616161);
|
||||
&data_word(0x17171717, 0x2b2b2b2b, 0x04040404, 0x7e7e7e7e);
|
||||
&data_word(0xbabababa, 0x77777777, 0xd6d6d6d6, 0x26262626);
|
||||
&data_word(0xe1e1e1e1, 0x69696969, 0x14141414, 0x63636363);
|
||||
&data_word(0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d);
|
||||
&data_byte(0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38);
|
||||
&data_byte(0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb);
|
||||
&data_byte(0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87);
|
||||
&data_byte(0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb);
|
||||
&data_byte(0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d);
|
||||
&data_byte(0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e);
|
||||
&data_byte(0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2);
|
||||
&data_byte(0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25);
|
||||
&data_byte(0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16);
|
||||
&data_byte(0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92);
|
||||
&data_byte(0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda);
|
||||
&data_byte(0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84);
|
||||
&data_byte(0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a);
|
||||
&data_byte(0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06);
|
||||
&data_byte(0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02);
|
||||
&data_byte(0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b);
|
||||
&data_byte(0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea);
|
||||
&data_byte(0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73);
|
||||
&data_byte(0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85);
|
||||
&data_byte(0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e);
|
||||
&data_byte(0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89);
|
||||
&data_byte(0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b);
|
||||
&data_byte(0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20);
|
||||
&data_byte(0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4);
|
||||
&data_byte(0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31);
|
||||
&data_byte(0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f);
|
||||
&data_byte(0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d);
|
||||
&data_byte(0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef);
|
||||
&data_byte(0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0);
|
||||
&data_byte(0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61);
|
||||
&data_byte(0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26);
|
||||
&data_byte(0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d);
|
||||
&function_end_B("_x86_AES_decrypt");
|
||||
|
||||
# void AES_decrypt (const void *inp,void *out,const AES_KEY *key);
|
||||
@@ -770,6 +744,18 @@ sub declast()
|
||||
&blindpop("ebp");
|
||||
&lea ("ebp",&DWP(&label("AES_Td")."-".&label("pic_point"),"ebp"));
|
||||
|
||||
# prefetch Td4
|
||||
&lea ("ebp",&DWP(2048+128,"ebp"));
|
||||
&mov ($s0,&DWP(0-128,"ebp"));
|
||||
&mov ($s1,&DWP(32-128,"ebp"));
|
||||
&mov ($s2,&DWP(64-128,"ebp"));
|
||||
&mov ($s3,&DWP(96-128,"ebp"));
|
||||
&mov ($s0,&DWP(128-128,"ebp"));
|
||||
&mov ($s1,&DWP(160-128,"ebp"));
|
||||
&mov ($s2,&DWP(192-128,"ebp"));
|
||||
&mov ($s3,&DWP(224-128,"ebp"));
|
||||
&lea ("ebp",&DWP(-2048-128,"ebp"));
|
||||
|
||||
&mov ($s0,&DWP(0,$acc)); # load input data
|
||||
&mov ($s1,&DWP(4,$acc));
|
||||
&mov ($s2,&DWP(8,$acc));
|
||||
@@ -805,6 +791,7 @@ my $_ivp=&DWP(36,"esp"); #copy of wparam(4)
|
||||
my $_tmp=&DWP(40,"esp"); #volatile variable
|
||||
my $ivec=&DWP(44,"esp"); #ivec[16]
|
||||
my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
my $mark=&DWP(60+240,"esp"); #copy of aes_key->rounds
|
||||
|
||||
&public_label("AES_Te");
|
||||
&public_label("AES_Td");
|
||||
@@ -865,18 +852,27 @@ my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
&mov ($_key,$s3); # save copy of key
|
||||
&mov ($_ivp,$acc); # save copy of ivp
|
||||
|
||||
&mov ($mark,0); # copy of aes_key->rounds = 0;
|
||||
if ($compromise) {
|
||||
&cmp ($s2,$compromise);
|
||||
&jb (&label("skip_ecopy"));
|
||||
}
|
||||
# copy key schedule to stack
|
||||
&mov ("ecx",244/4);
|
||||
# do we copy key schedule to stack?
|
||||
&mov ($s1 eq "ebx" ? $s1 : "",$s3);
|
||||
&mov ($s2 eq "ecx" ? $s2 : "",244/4);
|
||||
&sub ($s1,"ebp");
|
||||
&mov ("esi",$s3);
|
||||
&and ($s1,0xfff);
|
||||
&lea ("edi",$aes_key);
|
||||
&mov ($_key,"edi");
|
||||
&cmp ($s1,2048);
|
||||
&jb (&label("do_ecopy"));
|
||||
&cmp ($s1,4096-244);
|
||||
&jb (&label("skip_ecopy"));
|
||||
&align (4);
|
||||
&data_word(0xF689A5F3); # rep movsd
|
||||
&set_label("skip_ecopy") if ($compromise);
|
||||
&set_label("do_ecopy");
|
||||
&mov ($_key,"edi");
|
||||
&data_word(0xA5F3F689); # rep movsd
|
||||
&set_label("skip_ecopy");
|
||||
|
||||
&mov ($acc,$s0);
|
||||
&mov ($key,16);
|
||||
@@ -942,18 +938,16 @@ my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
&mov (&DWP(8,$acc),$s2);
|
||||
&mov (&DWP(12,$acc),$s3);
|
||||
|
||||
&cmp ($mark,0); # was the key schedule copied?
|
||||
&mov ("edi",$_key);
|
||||
&mov ("esp",$_esp);
|
||||
if ($compromise) {
|
||||
&cmp (&wparam(2),$compromise);
|
||||
&jb (&label("skip_ezero"));
|
||||
}
|
||||
&je (&label("skip_ezero"));
|
||||
# zero copy of key schedule
|
||||
&mov ("ecx",240/4);
|
||||
&xor ("eax","eax");
|
||||
&align (4);
|
||||
&data_word(0xF689ABF3); # rep stosd
|
||||
&set_label("skip_ezero") if ($compromise);
|
||||
&data_word(0xABF3F689); # rep stosd
|
||||
&set_label("skip_ezero")
|
||||
&popf ();
|
||||
&set_label("enc_out");
|
||||
&function_end_A();
|
||||
@@ -968,7 +962,7 @@ my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
&cmp ($key,$acc); # compare with inp
|
||||
&je (&label("enc_in_place"));
|
||||
&align (4);
|
||||
&data_word(0xF689A4F3); # rep movsb # copy input
|
||||
&data_word(0xA4F3F689); # rep movsb # copy input
|
||||
&jmp (&label("enc_skip_in_place"));
|
||||
&set_label("enc_in_place");
|
||||
&lea ($key,&DWP(0,$key,$s2));
|
||||
@@ -976,7 +970,7 @@ my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
&mov ($s2,$s1);
|
||||
&xor ($s0,$s0);
|
||||
&align (4);
|
||||
&data_word(0xF689AAF3); # rep stosb # zero tail
|
||||
&data_word(0xAAF3F689); # rep stosb # zero tail
|
||||
&pop ($key); # pop ivp
|
||||
|
||||
&mov ($acc,$_out); # output as input
|
||||
@@ -996,10 +990,10 @@ my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
|
||||
# ... and make sure it doesn't alias with AES_Td modulo 4096
|
||||
&mov ($s0,"ebp");
|
||||
&lea ($s1,&DWP(3072,"ebp"));
|
||||
&lea ($s1,&DWP(2048+256,"ebp"));
|
||||
&mov ($s3,$key);
|
||||
&and ($s0,0xfff); # s = %ebp&0xfff
|
||||
&and ($s1,0xfff); # e = (%ebp+3072)&0xfff
|
||||
&and ($s1,0xfff); # e = (%ebp+2048+256)&0xfff
|
||||
&and ($s3,0xfff); # p = %esp&0xfff
|
||||
|
||||
&cmp ($s3,$s1); # if (p>=e) %esp =- (p-e);
|
||||
@@ -1030,21 +1024,30 @@ my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
&mov ($_key,$s3); # save copy of key
|
||||
&mov ($_ivp,$acc); # save copy of ivp
|
||||
|
||||
&mov ($mark,0); # copy of aes_key->rounds = 0;
|
||||
if ($compromise) {
|
||||
&cmp ($s2,$compromise);
|
||||
&jb (&label("skip_dcopy"));
|
||||
}
|
||||
# copy key schedule to stack
|
||||
&mov ("ecx",244/4);
|
||||
# do we copy key schedule to stack?
|
||||
&mov ($s1 eq "ebx" ? $s1 : "",$s3);
|
||||
&mov ($s2 eq "ecx" ? $s2 : "",244/4);
|
||||
&sub ($s1,"ebp");
|
||||
&mov ("esi",$s3);
|
||||
&and ($s1,0xfff);
|
||||
&lea ("edi",$aes_key);
|
||||
&mov ($_key,"edi");
|
||||
&cmp ($s1,2048+256);
|
||||
&jb (&label("do_dcopy"));
|
||||
&cmp ($s1,4096-244);
|
||||
&jb (&label("skip_dcopy"));
|
||||
&align (4);
|
||||
&data_word(0xF689A5F3); # rep movsd
|
||||
&set_label("skip_dcopy") if ($compromise);
|
||||
&set_label("do_dcopy");
|
||||
&mov ($_key,"edi");
|
||||
&data_word(0xA5F3F689); # rep movsd
|
||||
&set_label("skip_dcopy");
|
||||
|
||||
&mov ($acc,$s0);
|
||||
&mov ($key,24);
|
||||
&mov ($key,18);
|
||||
&align (4);
|
||||
&set_label("prefetch_td");
|
||||
&mov ($s0,&DWP(0,"ebp"));
|
||||
@@ -1054,7 +1057,7 @@ my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
&lea ("ebp",&DWP(128,"ebp"));
|
||||
&dec ($key);
|
||||
&jnz (&label("prefetch_td"));
|
||||
&sub ("ebp",3072);
|
||||
&sub ("ebp",2048+256);
|
||||
|
||||
&cmp ($acc,$_out);
|
||||
&je (&label("dec_in_place")); # in-place processing...
|
||||
@@ -1121,7 +1124,7 @@ my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
&lea ($s2 eq "ecx" ? $s2 : "",&DWP(16,$acc));
|
||||
&mov ($acc eq "esi" ? $acc : "",$key);
|
||||
&mov ($key eq "edi" ? $key : "",$_out); # load out
|
||||
&data_word(0xF689A4F3); # rep movsb # copy output
|
||||
&data_word(0xA4F3F689); # rep movsb # copy output
|
||||
&mov ($key,$_inp); # use inp as temp ivp
|
||||
&jmp (&label("dec_end"));
|
||||
|
||||
@@ -1188,22 +1191,20 @@ my $aes_key=&DWP(60,"esp"); #copy of aes_key
|
||||
&lea ($key,&DWP(0,$key,$s2));
|
||||
&lea ($acc,&DWP(16,$acc,$s2));
|
||||
&neg ($s2 eq "ecx" ? $s2 : "");
|
||||
&data_word(0xF689A4F3); # rep movsb # restore tail
|
||||
&data_word(0xA4F3F689); # rep movsb # restore tail
|
||||
|
||||
&align (4);
|
||||
&set_label("dec_out");
|
||||
&cmp ($mark,0); # was the key schedule copied?
|
||||
&mov ("edi",$_key);
|
||||
&mov ("esp",$_esp);
|
||||
if ($compromise) {
|
||||
&cmp (&wparam(2),$compromise);
|
||||
&jb (&label("skip_dzero"));
|
||||
}
|
||||
&je (&label("skip_dzero"));
|
||||
# zero copy of key schedule
|
||||
&mov ("ecx",240/4);
|
||||
&xor ("eax","eax");
|
||||
&align (4);
|
||||
&data_word(0xF689ABF3); # rep stosd
|
||||
&set_label("skip_dzero") if ($compromise);
|
||||
&data_word(0xABF3F689); # rep stosd
|
||||
&set_label("skip_dzero")
|
||||
&popf ();
|
||||
&function_end("AES_cbc_encrypt");
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ static int do_buf(unsigned char *buf, int buflen,
|
||||
q = buf + buflen;
|
||||
outlen = 0;
|
||||
while(p != q) {
|
||||
if(p == buf) orflags = CHARTYPE_FIRST_ESC_2253;
|
||||
if(p == buf && flags & ASN1_STRFLGS_ESC_2253) orflags = CHARTYPE_FIRST_ESC_2253;
|
||||
else orflags = 0;
|
||||
switch(type & BUF_TYPE_WIDTH_MASK) {
|
||||
case 4:
|
||||
@@ -197,7 +197,7 @@ static int do_buf(unsigned char *buf, int buflen,
|
||||
default:
|
||||
return -1; /* invalid width */
|
||||
}
|
||||
if (p == q) orflags = CHARTYPE_LAST_ESC_2253;
|
||||
if (p == q && flags & ASN1_STRFLGS_ESC_2253) orflags = CHARTYPE_LAST_ESC_2253;
|
||||
if(type & BUF_TYPE_CONVUTF8) {
|
||||
unsigned char utfbuf[6];
|
||||
int utflen;
|
||||
|
||||
@@ -123,7 +123,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
|
||||
{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_EX_D2I), "ASN1_TEMPLATE_EX_D2I"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NEW), "ASN1_TEMPLATE_NEW"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I), "ASN1_TEMPLATE_NOEXP_D2I"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TIME_SET), "ASN1_TIME_SET"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TIME_SET), "ASN1_TIME_set"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING), "ASN1_TYPE_get_int_octetstring"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_OCTETSTRING), "ASN1_TYPE_get_octetstring"},
|
||||
{ERR_FUNC(ASN1_F_ASN1_UNPACK_STRING), "ASN1_unpack_string"},
|
||||
@@ -168,10 +168,10 @@ static ERR_STRING_DATA ASN1_str_functs[]=
|
||||
{ERR_FUNC(ASN1_F_OID_MODULE_INIT), "OID_MODULE_INIT"},
|
||||
{ERR_FUNC(ASN1_F_PARSE_TAGGING), "PARSE_TAGGING"},
|
||||
{ERR_FUNC(ASN1_F_PKCS5_PBE2_SET), "PKCS5_pbe2_set"},
|
||||
{ERR_FUNC(ASN1_F_PKCS5_PBE_SET), "PKCS5_PBE_SET"},
|
||||
{ERR_FUNC(ASN1_F_PKCS5_PBE_SET), "PKCS5_pbe_set"},
|
||||
{ERR_FUNC(ASN1_F_X509_CINF_NEW), "X509_CINF_NEW"},
|
||||
{ERR_FUNC(ASN1_F_X509_CRL_ADD0_REVOKED), "X509_CRL_ADD0_REVOKED"},
|
||||
{ERR_FUNC(ASN1_F_X509_INFO_NEW), "X509_INFO_NEW"},
|
||||
{ERR_FUNC(ASN1_F_X509_CRL_ADD0_REVOKED), "X509_CRL_add0_revoked"},
|
||||
{ERR_FUNC(ASN1_F_X509_INFO_NEW), "X509_INFO_new"},
|
||||
{ERR_FUNC(ASN1_F_X509_NAME_ENCODE), "X509_NAME_ENCODE"},
|
||||
{ERR_FUNC(ASN1_F_X509_NAME_EX_D2I), "X509_NAME_EX_D2I"},
|
||||
{ERR_FUNC(ASN1_F_X509_NAME_EX_NEW), "X509_NAME_EX_NEW"},
|
||||
@@ -287,15 +287,12 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
|
||||
|
||||
void ERR_load_ASN1_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(ASN1_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,ASN1_str_functs);
|
||||
ERR_load_strings(0,ASN1_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
static int asn1_get_length(const unsigned char **pp,int *inf,long *rl,int max);
|
||||
static void asn1_put_length(unsigned char **pp, int length);
|
||||
const char *ASN1_version="ASN.1" OPENSSL_VERSION_PTEXT;
|
||||
const char ASN1_version[]="ASN.1" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
static int _asn1_check_infinite_end(const unsigned char **p, long len)
|
||||
{
|
||||
|
||||
@@ -99,7 +99,7 @@ extern "C" {
|
||||
#define ASN1_ITEM_start(itname) \
|
||||
const ASN1_ITEM * itname##_it(void) \
|
||||
{ \
|
||||
static const ASN1_ITEM local_it = { \
|
||||
static const ASN1_ITEM local_it = {
|
||||
|
||||
#define ASN1_ITEM_end(itname) \
|
||||
}; \
|
||||
|
||||
@@ -445,9 +445,9 @@ err:
|
||||
int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
|
||||
{
|
||||
char *s,*c,*b;
|
||||
int ret=0,l,ll,i,first=1;
|
||||
int ret=0,l,i;
|
||||
|
||||
ll=80-2-obase;
|
||||
l=80-2-obase;
|
||||
|
||||
b=s=X509_NAME_oneline(name,NULL,0);
|
||||
if (!*s)
|
||||
@@ -457,7 +457,6 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
|
||||
}
|
||||
s++; /* skip the first slash */
|
||||
|
||||
l=ll;
|
||||
c=s;
|
||||
for (;;)
|
||||
{
|
||||
@@ -479,16 +478,6 @@ int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
|
||||
(*s == '\0'))
|
||||
#endif
|
||||
{
|
||||
if ((l <= 0) && !first)
|
||||
{
|
||||
first=0;
|
||||
if (BIO_write(bp,"\n",1) != 1) goto err;
|
||||
for (i=0; i<obase; i++)
|
||||
{
|
||||
if (BIO_write(bp," ",1) != 1) goto err;
|
||||
}
|
||||
l=ll;
|
||||
}
|
||||
i=s-c;
|
||||
if (BIO_write(bp,c,i) != i) goto err;
|
||||
c+=i;
|
||||
|
||||
@@ -93,7 +93,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
int tag, int aclass, char opt, ASN1_TLC *ctx);
|
||||
|
||||
/* Table to convert tags to bit values, used for MSTRING type */
|
||||
static unsigned long tag2bit[32] = {
|
||||
static const unsigned long tag2bit[32] = {
|
||||
0, 0, 0, B_ASN1_BIT_STRING, /* tags 0 - 3 */
|
||||
B_ASN1_OCTET_STRING, 0, 0, B_ASN1_UNKNOWN,/* tags 4- 7 */
|
||||
B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN,/* tags 8-11 */
|
||||
@@ -832,6 +832,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
}
|
||||
else if (ret == -1)
|
||||
return -1;
|
||||
ret = 0;
|
||||
/* SEQUENCE, SET and "OTHER" are left in encoded form */
|
||||
if ((utype == V_ASN1_SEQUENCE)
|
||||
|| (utype == V_ASN1_SET) || (utype == V_ASN1_OTHER))
|
||||
@@ -878,7 +879,10 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
* for UNIVERSAL class and ignore the tag.
|
||||
*/
|
||||
if (!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL))
|
||||
{
|
||||
free_cont = 1;
|
||||
goto err;
|
||||
}
|
||||
len = buf.length;
|
||||
/* Append a final null to string */
|
||||
if (!BUF_MEM_grow_clean(&buf, len + 1))
|
||||
|
||||
@@ -102,7 +102,7 @@ ASN1_SEQUENCE_enc(X509_REQ_INFO, enc, rinf_cb) = {
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS(X509_REQ_INFO)
|
||||
|
||||
ASN1_SEQUENCE_ref(X509_REQ, 0, CRYPTO_LOCK_X509_INFO) = {
|
||||
ASN1_SEQUENCE_ref(X509_REQ, 0, CRYPTO_LOCK_X509_REQ) = {
|
||||
ASN1_SIMPLE(X509_REQ, req_info, X509_REQ_INFO),
|
||||
ASN1_SIMPLE(X509_REQ, sig_alg, X509_ALGOR),
|
||||
ASN1_SIMPLE(X509_REQ, signature, ASN1_BIT_STRING)
|
||||
|
||||
@@ -94,6 +94,10 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
ret->ex_pathlen = -1;
|
||||
ret->skid = NULL;
|
||||
ret->akid = NULL;
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
ret->rfc3779_addr = NULL;
|
||||
ret->rfc3779_asid = NULL;
|
||||
#endif
|
||||
ret->aux = NULL;
|
||||
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data);
|
||||
break;
|
||||
@@ -109,6 +113,10 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
ASN1_OCTET_STRING_free(ret->skid);
|
||||
AUTHORITY_KEYID_free(ret->akid);
|
||||
policy_cache_free(ret->policy_cache);
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free);
|
||||
ASIdentifiers_free(ret->rfc3779_asid);
|
||||
#endif
|
||||
|
||||
if (ret->name != NULL) OPENSSL_free(ret->name);
|
||||
break;
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
* CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
|
||||
*/
|
||||
|
||||
const char *BF_version="Blowfish" OPENSSL_VERSION_PTEXT;
|
||||
const char BF_version[]="Blowfish" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
const char *BF_options(void)
|
||||
{
|
||||
|
||||
@@ -196,28 +196,32 @@ extern "C" {
|
||||
*/
|
||||
#define BIO_FLAGS_MEM_RDONLY 0x200
|
||||
|
||||
#define BIO_set_flags(b,f) ((b)->flags|=(f))
|
||||
#define BIO_get_flags(b) ((b)->flags)
|
||||
typedef struct bio_st BIO;
|
||||
|
||||
void BIO_set_flags(BIO *b, int flags);
|
||||
int BIO_test_flags(const BIO *b, int flags);
|
||||
void BIO_clear_flags(BIO *b, int flags);
|
||||
|
||||
#define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
|
||||
#define BIO_set_retry_special(b) \
|
||||
((b)->flags|=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
|
||||
BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
|
||||
#define BIO_set_retry_read(b) \
|
||||
((b)->flags|=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
|
||||
BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
|
||||
#define BIO_set_retry_write(b) \
|
||||
((b)->flags|=(BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
|
||||
BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
|
||||
|
||||
/* These are normally used internally in BIOs */
|
||||
#define BIO_clear_flags(b,f) ((b)->flags&= ~(f))
|
||||
#define BIO_clear_retry_flags(b) \
|
||||
((b)->flags&= ~(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
#define BIO_get_retry_flags(b) \
|
||||
((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
|
||||
|
||||
/* These should be used by the application to tell why we should retry */
|
||||
#define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ)
|
||||
#define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE)
|
||||
#define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL)
|
||||
#define BIO_retry_type(a) ((a)->flags & BIO_FLAGS_RWS)
|
||||
#define BIO_should_retry(a) ((a)->flags & BIO_FLAGS_SHOULD_RETRY)
|
||||
#define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ)
|
||||
#define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE)
|
||||
#define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
|
||||
#define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS)
|
||||
#define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
|
||||
|
||||
/* The next three are used in conjunction with the
|
||||
* BIO_should_io_special() condition. After this returns true,
|
||||
@@ -246,14 +250,14 @@ extern "C" {
|
||||
#define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN))
|
||||
#define BIO_cb_post(a) ((a)&BIO_CB_RETURN)
|
||||
|
||||
#define BIO_set_callback(b,cb) ((b)->callback=(cb))
|
||||
#define BIO_set_callback_arg(b,arg) ((b)->cb_arg=(char *)(arg))
|
||||
#define BIO_get_callback_arg(b) ((b)->cb_arg)
|
||||
#define BIO_get_callback(b) ((b)->callback)
|
||||
#define BIO_method_name(b) ((b)->method->name)
|
||||
#define BIO_method_type(b) ((b)->method->type)
|
||||
long (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long);
|
||||
void BIO_set_callback(BIO *b,
|
||||
long (*callback)(struct bio_st *,int,const char *,int, long,long));
|
||||
char *BIO_get_callback_arg(const BIO *b);
|
||||
void BIO_set_callback_arg(BIO *b, char *arg);
|
||||
|
||||
typedef struct bio_st BIO;
|
||||
const char * BIO_method_name(const BIO *b);
|
||||
int BIO_method_type(const BIO *b);
|
||||
|
||||
typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
|
||||
|
||||
@@ -386,6 +390,7 @@ typedef struct bio_f_buffer_ctx_struct
|
||||
#define BIO_C_NWRITE0 145
|
||||
#define BIO_C_NWRITE 146
|
||||
#define BIO_C_RESET_READ_REQUEST 147
|
||||
#define BIO_C_SET_MD_CTX 148
|
||||
|
||||
|
||||
#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg)
|
||||
|
||||
@@ -143,15 +143,12 @@ static ERR_STRING_DATA BIO_str_reasons[]=
|
||||
|
||||
void ERR_load_BIO_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(BIO_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,BIO_str_functs);
|
||||
ERR_load_strings(0,BIO_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -141,6 +141,52 @@ int BIO_free(BIO *a)
|
||||
void BIO_vfree(BIO *a)
|
||||
{ BIO_free(a); }
|
||||
|
||||
void BIO_clear_flags(BIO *b, int flags)
|
||||
{
|
||||
b->flags &= ~flags;
|
||||
}
|
||||
|
||||
int BIO_test_flags(const BIO *b, int flags)
|
||||
{
|
||||
return (b->flags & flags);
|
||||
}
|
||||
|
||||
void BIO_set_flags(BIO *b, int flags)
|
||||
{
|
||||
b->flags |= flags;
|
||||
}
|
||||
|
||||
long (*BIO_get_callback(const BIO *b))(struct bio_st *,int,const char *,int, long,long)
|
||||
{
|
||||
return b->callback;
|
||||
}
|
||||
|
||||
void BIO_set_callback(BIO *b, long (*cb)(struct bio_st *,int,const char *,int, long,long))
|
||||
{
|
||||
b->callback = cb;
|
||||
}
|
||||
|
||||
void BIO_set_callback_arg(BIO *b, char *arg)
|
||||
{
|
||||
b->cb_arg = arg;
|
||||
}
|
||||
|
||||
char * BIO_get_callback_arg(const BIO *b)
|
||||
{
|
||||
return b->cb_arg;
|
||||
}
|
||||
|
||||
const char * BIO_method_name(const BIO *b)
|
||||
{
|
||||
return b->method->name;
|
||||
}
|
||||
|
||||
int BIO_method_type(const BIO *b)
|
||||
{
|
||||
return b->method->type;
|
||||
}
|
||||
|
||||
|
||||
int BIO_read(BIO *b, void *out, int outl)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifdef __SUNPRO_C
|
||||
# include "../bn_asm.c" /* kind of dirty hack for Sun Studio */
|
||||
#else
|
||||
/*
|
||||
* x86_64 BIGNUM accelerator version 0.1, December 2002.
|
||||
*
|
||||
@@ -591,3 +594,4 @@ void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a)
|
||||
r[6]=c1;
|
||||
r[7]=c2;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -137,15 +137,12 @@ static ERR_STRING_DATA BN_str_reasons[]=
|
||||
|
||||
void ERR_load_BN_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(BN_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,BN_str_functs);
|
||||
ERR_load_strings(0,BN_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
#include "cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
const char *BN_version="Big Number" OPENSSL_VERSION_PTEXT;
|
||||
const char BN_version[]="Big Number" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
/* This stuff appears to be completely unused, so is deprecated */
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
|
||||
@@ -55,6 +55,59 @@
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Details about Montgomery multiplication algorithms can be found at
|
||||
@@ -353,18 +406,32 @@ BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)
|
||||
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
|
||||
const BIGNUM *mod, BN_CTX *ctx)
|
||||
{
|
||||
if (*pmont)
|
||||
return *pmont;
|
||||
CRYPTO_w_lock(lock);
|
||||
int got_write_lock = 0;
|
||||
BN_MONT_CTX *ret;
|
||||
|
||||
CRYPTO_r_lock(lock);
|
||||
if (!*pmont)
|
||||
{
|
||||
BN_MONT_CTX *mtmp;
|
||||
mtmp = BN_MONT_CTX_new();
|
||||
if (mtmp && !BN_MONT_CTX_set(mtmp, mod, ctx))
|
||||
BN_MONT_CTX_free(mtmp);
|
||||
else
|
||||
*pmont = mtmp;
|
||||
CRYPTO_r_unlock(lock);
|
||||
CRYPTO_w_lock(lock);
|
||||
got_write_lock = 1;
|
||||
|
||||
if (!*pmont)
|
||||
{
|
||||
ret = BN_MONT_CTX_new();
|
||||
if (ret && !BN_MONT_CTX_set(ret, mod, ctx))
|
||||
BN_MONT_CTX_free(ret);
|
||||
else
|
||||
*pmont = ret;
|
||||
}
|
||||
}
|
||||
CRYPTO_w_unlock(lock);
|
||||
return *pmont;
|
||||
|
||||
ret = *pmont;
|
||||
|
||||
if (got_write_lock)
|
||||
CRYPTO_w_unlock(lock);
|
||||
else
|
||||
CRYPTO_r_unlock(lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -378,13 +378,14 @@ static int probable_prime(BIGNUM *rnd, int bits)
|
||||
{
|
||||
int i;
|
||||
BN_ULONG mods[NUMPRIMES];
|
||||
BN_ULONG delta,d;
|
||||
BN_ULONG delta,maxdelta;
|
||||
|
||||
again:
|
||||
if (!BN_rand(rnd,bits,1,1)) return(0);
|
||||
/* we now have a random number 'rand' to test. */
|
||||
for (i=1; i<NUMPRIMES; i++)
|
||||
mods[i]=BN_mod_word(rnd,(BN_ULONG)primes[i]);
|
||||
maxdelta=BN_MASK2 - primes[NUMPRIMES-1];
|
||||
delta=0;
|
||||
loop: for (i=1; i<NUMPRIMES; i++)
|
||||
{
|
||||
@@ -392,12 +393,8 @@ again:
|
||||
* that gcd(rnd-1,primes) == 1 (except for 2) */
|
||||
if (((mods[i]+delta)%primes[i]) <= 1)
|
||||
{
|
||||
d=delta;
|
||||
delta+=2;
|
||||
/* perhaps need to check for overflow of
|
||||
* delta (but delta can be up to 2^32)
|
||||
* 21-May-98 eay - added overflow check */
|
||||
if (delta < d) goto again;
|
||||
if (delta > maxdelta) goto again;
|
||||
goto loop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
#include <openssl/buffer.h>
|
||||
#include "bn_lcl.h"
|
||||
|
||||
static const char *Hex="0123456789ABCDEF";
|
||||
static const char Hex[]="0123456789ABCDEF";
|
||||
|
||||
/* Must 'OPENSSL_free' the returned data */
|
||||
char *BN_bn2hex(const BIGNUM *a)
|
||||
|
||||
@@ -88,15 +88,12 @@ static ERR_STRING_DATA BUF_str_reasons[]=
|
||||
|
||||
void ERR_load_BUF_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(BUF_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,BUF_str_functs);
|
||||
ERR_load_strings(0,BUF_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
103
crypto/camellia/Makefile
Normal file
103
crypto/camellia/Makefile
Normal file
@@ -0,0 +1,103 @@
|
||||
#
|
||||
# crypto/camellia/Makefile
|
||||
#
|
||||
|
||||
DIR= camellia
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
CPP= $(CC) -E
|
||||
INCLUDES=
|
||||
CFLAG=-g
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
CAMELLIA_ASM_OBJ=
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
ASFLAGS= $(INCLUDES) $(ASFLAG)
|
||||
AFLAGS= $(ASFLAGS)
|
||||
|
||||
GENERAL=Makefile
|
||||
#TEST=camelliatest.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=camellia.c cmll_misc.c cmll_ecb.c cmll_cbc.c cmll_ofb.c \
|
||||
cmll_cfb.c cmll_ctr.c
|
||||
|
||||
LIBOBJ= camellia.o cmll_misc.o cmll_ecb.o cmll_cbc.o cmll_ofb.o \
|
||||
cmll_cfb.o cmll_ctr.o $(CAMELLIA_ASM_OBJ)
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= camellia.h
|
||||
HEADER= cmll_locl.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
$(LIBOBJ): $(LIBSRC)
|
||||
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
camellia.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
camellia.o: camellia.c camellia.h cmll_locl.h
|
||||
cmll_cbc.o: ../../include/openssl/camellia.h ../../include/openssl/e_os2.h
|
||||
cmll_cbc.o: ../../include/openssl/opensslconf.h cmll_cbc.c cmll_locl.h
|
||||
cmll_cfb.o: ../../e_os.h ../../include/openssl/camellia.h
|
||||
cmll_cfb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
|
||||
cmll_cfb.o: cmll_cfb.c cmll_locl.h
|
||||
cmll_ctr.o: ../../include/openssl/camellia.h ../../include/openssl/e_os2.h
|
||||
cmll_ctr.o: ../../include/openssl/opensslconf.h cmll_ctr.c cmll_locl.h
|
||||
cmll_ecb.o: ../../include/openssl/camellia.h ../../include/openssl/e_os2.h
|
||||
cmll_ecb.o: ../../include/openssl/opensslconf.h cmll_ecb.c cmll_locl.h
|
||||
cmll_misc.o: ../../include/openssl/camellia.h ../../include/openssl/e_os2.h
|
||||
cmll_misc.o: ../../include/openssl/opensslconf.h
|
||||
cmll_misc.o: ../../include/openssl/opensslv.h cmll_locl.h cmll_misc.c
|
||||
cmll_ofb.o: ../../include/openssl/camellia.h ../../include/openssl/e_os2.h
|
||||
cmll_ofb.o: ../../include/openssl/opensslconf.h cmll_locl.h cmll_ofb.c
|
||||
1624
crypto/camellia/camellia.c
Normal file
1624
crypto/camellia/camellia.c
Normal file
File diff suppressed because it is too large
Load Diff
129
crypto/camellia/camellia.h
Normal file
129
crypto/camellia/camellia.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/* crypto/camellia/camellia.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CAMELLIA_H
|
||||
#define HEADER_CAMELLIA_H
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#ifdef OPENSSL_NO_CAMELLIA
|
||||
#error CAMELLIA is disabled.
|
||||
#endif
|
||||
|
||||
#define CAMELLIA_ENCRYPT 1
|
||||
#define CAMELLIA_DECRYPT 0
|
||||
|
||||
/* Because array size can't be a const in C, the following two are macros.
|
||||
Both sizes are in bytes. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This should be a hidden type, but EVP requires that the size be known */
|
||||
|
||||
#define CAMELLIA_BLOCK_SIZE 16
|
||||
#define CAMELLIA_TABLE_BYTE_LEN 272
|
||||
#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
|
||||
|
||||
/* to match with WORD */
|
||||
typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
|
||||
|
||||
struct camellia_key_st
|
||||
{
|
||||
KEY_TABLE_TYPE rd_key;
|
||||
int bitLength;
|
||||
void (*enc)(const unsigned int *subkey, unsigned int *io);
|
||||
void (*dec)(const unsigned int *subkey, unsigned int *io);
|
||||
};
|
||||
|
||||
typedef struct camellia_key_st CAMELLIA_KEY;
|
||||
|
||||
int Camellia_set_key(const unsigned char *userKey, const int bits,
|
||||
CAMELLIA_KEY *key);
|
||||
|
||||
void Camellia_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key);
|
||||
void Camellia_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key);
|
||||
|
||||
void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key, const int enc);
|
||||
void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, const int enc);
|
||||
void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
|
||||
const int nbits,const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec,const int enc);
|
||||
void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num);
|
||||
void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char ivec[CAMELLIA_BLOCK_SIZE],
|
||||
unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],
|
||||
unsigned int *num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !HEADER_Camellia_H */
|
||||
|
||||
273
crypto/camellia/cmll_cbc.c
Normal file
273
crypto/camellia/cmll_cbc.c
Normal file
@@ -0,0 +1,273 @@
|
||||
/* crypto/camellia/camellia_cbc.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAMELLIA_DEBUG
|
||||
# ifndef NDEBUG
|
||||
# define NDEBUG
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/camellia.h>
|
||||
#include "cmll_locl.h"
|
||||
|
||||
void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, const int enc) {
|
||||
|
||||
unsigned long n;
|
||||
unsigned long len = length;
|
||||
const unsigned char *iv = ivec;
|
||||
union { u32 t32[CAMELLIA_BLOCK_SIZE/sizeof(u32)];
|
||||
u8 t8 [CAMELLIA_BLOCK_SIZE]; } tmp;
|
||||
const union { long one; char little; } camellia_endian = {1};
|
||||
|
||||
|
||||
assert(in && out && key && ivec);
|
||||
assert((CAMELLIA_ENCRYPT == enc)||(CAMELLIA_DECRYPT == enc));
|
||||
|
||||
if(((size_t)in|(size_t)out|(size_t)ivec) % sizeof(u32) == 0)
|
||||
{
|
||||
if (CAMELLIA_ENCRYPT == enc)
|
||||
{
|
||||
while (len >= CAMELLIA_BLOCK_SIZE)
|
||||
{
|
||||
XOR4WORD2((u32 *)out,
|
||||
(u32 *)in, (u32 *)iv);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
key->enc(key->rd_key, (u32 *)out);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
iv = out;
|
||||
len -= CAMELLIA_BLOCK_SIZE;
|
||||
in += CAMELLIA_BLOCK_SIZE;
|
||||
out += CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
if (len)
|
||||
{
|
||||
for(n=0; n < len; ++n)
|
||||
out[n] = in[n] ^ iv[n];
|
||||
for(n=len; n < CAMELLIA_BLOCK_SIZE; ++n)
|
||||
out[n] = iv[n];
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
key->enc(key->rd_key, (u32 *)out);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
iv = out;
|
||||
}
|
||||
memcpy(ivec,iv,CAMELLIA_BLOCK_SIZE);
|
||||
}
|
||||
else if (in != out)
|
||||
{
|
||||
while (len >= CAMELLIA_BLOCK_SIZE)
|
||||
{
|
||||
memcpy(out,in,CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
key->dec(key->rd_key,(u32 *)out);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
XOR4WORD((u32 *)out, (u32 *)iv);
|
||||
iv = in;
|
||||
len -= CAMELLIA_BLOCK_SIZE;
|
||||
in += CAMELLIA_BLOCK_SIZE;
|
||||
out += CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
if (len)
|
||||
{
|
||||
memcpy(tmp.t8, in, CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
key->dec(key->rd_key, tmp.t32);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
for(n=0; n < len; ++n)
|
||||
out[n] = tmp.t8[n] ^ iv[n];
|
||||
iv = in;
|
||||
}
|
||||
memcpy(ivec,iv,CAMELLIA_BLOCK_SIZE);
|
||||
}
|
||||
else /* in == out */
|
||||
{
|
||||
while (len >= CAMELLIA_BLOCK_SIZE)
|
||||
{
|
||||
memcpy(tmp.t8, in, CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
key->dec(key->rd_key, (u32 *)out);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
XOR4WORD((u32 *)out, (u32 *)ivec);
|
||||
memcpy(ivec, tmp.t8, CAMELLIA_BLOCK_SIZE);
|
||||
len -= CAMELLIA_BLOCK_SIZE;
|
||||
in += CAMELLIA_BLOCK_SIZE;
|
||||
out += CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
if (len)
|
||||
{
|
||||
memcpy(tmp.t8, in, CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
key->dec(key->rd_key,(u32 *)out);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD((u32 *)out);
|
||||
for(n=0; n < len; ++n)
|
||||
out[n] ^= ivec[n];
|
||||
for(n=len; n < CAMELLIA_BLOCK_SIZE; ++n)
|
||||
out[n] = tmp.t8[n];
|
||||
memcpy(ivec, tmp.t8, CAMELLIA_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* no aligned */
|
||||
{
|
||||
if (CAMELLIA_ENCRYPT == enc)
|
||||
{
|
||||
while (len >= CAMELLIA_BLOCK_SIZE)
|
||||
{
|
||||
for(n=0; n < CAMELLIA_BLOCK_SIZE; ++n)
|
||||
tmp.t8[n] = in[n] ^ iv[n];
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
key->enc(key->rd_key, tmp.t32);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
memcpy(out, tmp.t8, CAMELLIA_BLOCK_SIZE);
|
||||
iv = out;
|
||||
len -= CAMELLIA_BLOCK_SIZE;
|
||||
in += CAMELLIA_BLOCK_SIZE;
|
||||
out += CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
if (len)
|
||||
{
|
||||
for(n=0; n < len; ++n)
|
||||
tmp.t8[n] = in[n] ^ iv[n];
|
||||
for(n=len; n < CAMELLIA_BLOCK_SIZE; ++n)
|
||||
tmp.t8[n] = iv[n];
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
key->enc(key->rd_key, tmp.t32);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
memcpy(out, tmp.t8, CAMELLIA_BLOCK_SIZE);
|
||||
iv = out;
|
||||
}
|
||||
memcpy(ivec,iv,CAMELLIA_BLOCK_SIZE);
|
||||
}
|
||||
else if (in != out)
|
||||
{
|
||||
while (len >= CAMELLIA_BLOCK_SIZE)
|
||||
{
|
||||
memcpy(tmp.t8,in,CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
key->dec(key->rd_key,tmp.t32);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
for(n=0; n < CAMELLIA_BLOCK_SIZE; ++n)
|
||||
out[n] = tmp.t8[n] ^ iv[n];
|
||||
iv = in;
|
||||
len -= CAMELLIA_BLOCK_SIZE;
|
||||
in += CAMELLIA_BLOCK_SIZE;
|
||||
out += CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
if (len)
|
||||
{
|
||||
memcpy(tmp.t8, in, CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
key->dec(key->rd_key, tmp.t32);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
for(n=0; n < len; ++n)
|
||||
out[n] = tmp.t8[n] ^ iv[n];
|
||||
iv = in;
|
||||
}
|
||||
memcpy(ivec,iv,CAMELLIA_BLOCK_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (len >= CAMELLIA_BLOCK_SIZE)
|
||||
{
|
||||
memcpy(tmp.t8, in, CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
key->dec(key->rd_key, tmp.t32);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
for(n=0; n < CAMELLIA_BLOCK_SIZE; ++n)
|
||||
tmp.t8[n] ^= ivec[n];
|
||||
memcpy(ivec, in, CAMELLIA_BLOCK_SIZE);
|
||||
memcpy(out, tmp.t8, CAMELLIA_BLOCK_SIZE);
|
||||
len -= CAMELLIA_BLOCK_SIZE;
|
||||
in += CAMELLIA_BLOCK_SIZE;
|
||||
out += CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
if (len)
|
||||
{
|
||||
memcpy(tmp.t8, in, CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
key->dec(key->rd_key,tmp.t32);
|
||||
if (camellia_endian.little)
|
||||
SWAP4WORD(tmp.t32);
|
||||
for(n=0; n < len; ++n)
|
||||
tmp.t8[n] ^= ivec[n];
|
||||
memcpy(ivec, in, CAMELLIA_BLOCK_SIZE);
|
||||
memcpy(out,tmp.t8,len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
235
crypto/camellia/cmll_cfb.c
Normal file
235
crypto/camellia/cmll_cfb.c
Normal file
@@ -0,0 +1,235 @@
|
||||
/* crypto/camellia/camellia_cfb.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef CAMELLIA_DEBUG
|
||||
# ifndef NDEBUG
|
||||
# define NDEBUG
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/camellia.h>
|
||||
#include "cmll_locl.h"
|
||||
#include "e_os.h"
|
||||
|
||||
|
||||
/* The input and output encrypted as though 128bit cfb mode is being
|
||||
* used. The extra state information to record how much of the
|
||||
* 128bit block we have used is contained in *num;
|
||||
*/
|
||||
|
||||
void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc)
|
||||
{
|
||||
|
||||
unsigned int n;
|
||||
unsigned long l = length;
|
||||
unsigned char c;
|
||||
|
||||
assert(in && out && key && ivec && num);
|
||||
|
||||
n = *num;
|
||||
|
||||
if (enc)
|
||||
{
|
||||
while (l--)
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
Camellia_encrypt(ivec, ivec, key);
|
||||
}
|
||||
ivec[n] = *(out++) = *(in++) ^ ivec[n];
|
||||
n = (n+1) % CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (l--)
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
Camellia_encrypt(ivec, ivec, key);
|
||||
}
|
||||
c = *(in);
|
||||
*(out++) = *(in++) ^ ivec[n];
|
||||
ivec[n] = c;
|
||||
n = (n+1) % CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
*num=n;
|
||||
}
|
||||
|
||||
/* This expects a single block of size nbits for both in and out. Note that
|
||||
it corrupts any extra bits in the last byte of out */
|
||||
void Camellia_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
|
||||
const int nbits,const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec,const int enc)
|
||||
{
|
||||
int n,rem,num;
|
||||
unsigned char ovec[CAMELLIA_BLOCK_SIZE*2];
|
||||
|
||||
if (nbits<=0 || nbits>128) return;
|
||||
|
||||
/* fill in the first half of the new IV with the current IV */
|
||||
memcpy(ovec,ivec,CAMELLIA_BLOCK_SIZE);
|
||||
/* construct the new IV */
|
||||
Camellia_encrypt(ivec,ivec,key);
|
||||
num = (nbits+7)/8;
|
||||
if (enc) /* encrypt the input */
|
||||
for(n=0 ; n < num ; ++n)
|
||||
out[n] = (ovec[CAMELLIA_BLOCK_SIZE+n] = in[n] ^ ivec[n]);
|
||||
else /* decrypt the input */
|
||||
for(n=0 ; n < num ; ++n)
|
||||
out[n] = (ovec[CAMELLIA_BLOCK_SIZE+n] = in[n]) ^ ivec[n];
|
||||
/* shift ovec left... */
|
||||
rem = nbits%8;
|
||||
num = nbits/8;
|
||||
if(rem==0)
|
||||
memcpy(ivec,ovec+num,CAMELLIA_BLOCK_SIZE);
|
||||
else
|
||||
for(n=0 ; n < CAMELLIA_BLOCK_SIZE ; ++n)
|
||||
ivec[n] = ovec[n+num]<<rem | ovec[n+num+1]>>(8-rem);
|
||||
|
||||
/* it is not necessary to cleanse ovec, since the IV is not secret */
|
||||
}
|
||||
|
||||
/* N.B. This expects the input to be packed, MS bit first */
|
||||
void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc)
|
||||
{
|
||||
unsigned int n;
|
||||
unsigned char c[1],d[1];
|
||||
|
||||
assert(in && out && key && ivec && num);
|
||||
assert(*num == 0);
|
||||
|
||||
memset(out,0,(length+7)/8);
|
||||
for(n=0 ; n < length ; ++n)
|
||||
{
|
||||
c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0;
|
||||
Camellia_cfbr_encrypt_block(c,d,1,key,ivec,enc);
|
||||
out[n/8]=(out[n/8]&~(1 << (7-n%8)))|((d[0]&0x80) >> (n%8));
|
||||
}
|
||||
}
|
||||
|
||||
void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num, const int enc)
|
||||
{
|
||||
unsigned int n;
|
||||
|
||||
assert(in && out && key && ivec && num);
|
||||
assert(*num == 0);
|
||||
|
||||
for(n=0 ; n < length ; ++n)
|
||||
Camellia_cfbr_encrypt_block(&in[n],&out[n],8,key,ivec,enc);
|
||||
}
|
||||
|
||||
143
crypto/camellia/cmll_ctr.c
Normal file
143
crypto/camellia/cmll_ctr.c
Normal file
@@ -0,0 +1,143 @@
|
||||
/* crypto/camellia/camellia_ctr.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAMELLIA_DEBUG
|
||||
# ifndef NDEBUG
|
||||
# define NDEBUG
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#include <openssl/camellia.h>
|
||||
#include "cmll_locl.h"
|
||||
|
||||
/* NOTE: the IV/counter CTR mode is big-endian. The rest of the Camellia code
|
||||
* is endian-neutral. */
|
||||
/* increment counter (128-bit int) by 1 */
|
||||
static void Camellia_ctr128_inc(unsigned char *counter)
|
||||
{
|
||||
unsigned long c;
|
||||
|
||||
/* Grab bottom dword of counter and increment */
|
||||
c = GETU32(counter + 12);
|
||||
c++; c &= 0xFFFFFFFF;
|
||||
PUTU32(counter + 12, c);
|
||||
|
||||
/* if no overflow, we're done */
|
||||
if (c)
|
||||
return;
|
||||
|
||||
/* Grab 1st dword of counter and increment */
|
||||
c = GETU32(counter + 8);
|
||||
c++; c &= 0xFFFFFFFF;
|
||||
PUTU32(counter + 8, c);
|
||||
|
||||
/* if no overflow, we're done */
|
||||
if (c)
|
||||
return;
|
||||
|
||||
/* Grab 2nd dword of counter and increment */
|
||||
c = GETU32(counter + 4);
|
||||
c++; c &= 0xFFFFFFFF;
|
||||
PUTU32(counter + 4, c);
|
||||
|
||||
/* if no overflow, we're done */
|
||||
if (c)
|
||||
return;
|
||||
|
||||
/* Grab top dword of counter and increment */
|
||||
c = GETU32(counter + 0);
|
||||
c++; c &= 0xFFFFFFFF;
|
||||
PUTU32(counter + 0, c);
|
||||
}
|
||||
|
||||
/* The input encrypted as though 128bit counter mode is being
|
||||
* used. The extra state information to record how much of the
|
||||
* 128bit block we have used is contained in *num, and the
|
||||
* encrypted counter is kept in ecount_buf. Both *num and
|
||||
* ecount_buf must be initialised with zeros before the first
|
||||
* call to Camellia_ctr128_encrypt().
|
||||
*
|
||||
* This algorithm assumes that the counter is in the x lower bits
|
||||
* of the IV (ivec), and that the application has full control over
|
||||
* overflow and the rest of the IV. This implementation takes NO
|
||||
* responsability for checking that the counter doesn't overflow
|
||||
* into the rest of the IV when incremented.
|
||||
*/
|
||||
void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char ivec[CAMELLIA_BLOCK_SIZE],
|
||||
unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],
|
||||
unsigned int *num)
|
||||
{
|
||||
|
||||
unsigned int n;
|
||||
unsigned long l=length;
|
||||
|
||||
assert(in && out && key && counter && num);
|
||||
assert(*num < CAMELLIA_BLOCK_SIZE);
|
||||
|
||||
n = *num;
|
||||
|
||||
while (l--)
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
Camellia_encrypt(ivec, ecount_buf, key);
|
||||
Camellia_ctr128_inc(ivec);
|
||||
}
|
||||
*(out++) = *(in++) ^ ecount_buf[n];
|
||||
n = (n+1) % CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
*num=n;
|
||||
}
|
||||
|
||||
74
crypto/camellia/cmll_ecb.c
Normal file
74
crypto/camellia/cmll_ecb.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/* crypto/camellia/camellia_ecb.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAMELLIA_DEBUG
|
||||
# ifndef NDEBUG
|
||||
# define NDEBUG
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#include <openssl/camellia.h>
|
||||
#include "cmll_locl.h"
|
||||
|
||||
void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key, const int enc)
|
||||
{
|
||||
|
||||
assert(in && out && key);
|
||||
assert((CAMELLIA_ENCRYPT == enc)||(CAMELLIA_DECRYPT == enc));
|
||||
|
||||
if (CAMELLIA_ENCRYPT == enc)
|
||||
Camellia_encrypt(in, out, key);
|
||||
else
|
||||
Camellia_decrypt(in, out, key);
|
||||
}
|
||||
|
||||
165
crypto/camellia/cmll_locl.h
Normal file
165
crypto/camellia/cmll_locl.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/* crypto/camellia/camellia_locl.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) .
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
* Intellectual Property information for Camellia:
|
||||
* http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html
|
||||
*
|
||||
* News Release for Announcement of Camellia open source:
|
||||
* http://www.ntt.co.jp/news/news06e/0604/060413a.html
|
||||
*
|
||||
* The Camellia Code included herein is developed by
|
||||
* NTT (Nippon Telegraph and Telephone Corporation), and is contributed
|
||||
* to the OpenSSL project.
|
||||
*
|
||||
* The Camellia Code is licensed pursuant to the OpenSSL open source
|
||||
* license provided below.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CAMELLIA_LOCL_H
|
||||
#define HEADER_CAMELLIA_LOCL_H
|
||||
|
||||
#include "openssl/e_os2.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned int u32;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
|
||||
# define SWAP(x) ( _lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00 )
|
||||
# define GETU32(p) SWAP(*((u32 *)(p)))
|
||||
# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
|
||||
# define CAMELLIA_SWAP4(x) (x = ( _lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) )
|
||||
|
||||
#else /* not windows */
|
||||
# define GETU32(pt) (((u32)(pt)[0] << 24) \
|
||||
^ ((u32)(pt)[1] << 16) \
|
||||
^ ((u32)(pt)[2] << 8) \
|
||||
^ ((u32)(pt)[3]))
|
||||
|
||||
# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); \
|
||||
(ct)[1] = (u8)((st) >> 16); \
|
||||
(ct)[2] = (u8)((st) >> 8); \
|
||||
(ct)[3] = (u8)(st); }
|
||||
|
||||
#if (defined (__GNUC__) && (defined(__x86_64__) || defined(__x86_64)))
|
||||
#define CAMELLIA_SWAP4(x) \
|
||||
do{\
|
||||
asm("bswap %1" : "+r" (x));\
|
||||
}while(0)
|
||||
#else
|
||||
#define CAMELLIA_SWAP4(x) \
|
||||
do{\
|
||||
x = ((u32)x << 16) + ((u32)x >> 16);\
|
||||
x = (((u32)x & 0xff00ff) << 8) + (((u32)x >> 8) & 0xff00ff);\
|
||||
} while(0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define COPY4WORD(dst, src) \
|
||||
do \
|
||||
{ \
|
||||
(dst)[0]=(src)[0]; \
|
||||
(dst)[1]=(src)[1]; \
|
||||
(dst)[2]=(src)[2]; \
|
||||
(dst)[3]=(src)[3]; \
|
||||
}while(0)
|
||||
|
||||
#define SWAP4WORD(word) \
|
||||
do \
|
||||
{ \
|
||||
CAMELLIA_SWAP4((word)[0]); \
|
||||
CAMELLIA_SWAP4((word)[1]); \
|
||||
CAMELLIA_SWAP4((word)[2]); \
|
||||
CAMELLIA_SWAP4((word)[3]); \
|
||||
}while(0)
|
||||
|
||||
#define XOR4WORD(a, b)/* a = a ^ b */ \
|
||||
do \
|
||||
{ \
|
||||
(a)[0]^=(b)[0]; \
|
||||
(a)[1]^=(b)[1]; \
|
||||
(a)[2]^=(b)[2]; \
|
||||
(a)[3]^=(b)[3]; \
|
||||
}while(0)
|
||||
|
||||
#define XOR4WORD2(a, b, c)/* a = b ^ c */ \
|
||||
do \
|
||||
{ \
|
||||
(a)[0]=(b)[0]^(c)[0]; \
|
||||
(a)[1]=(b)[1]^(c)[1]; \
|
||||
(a)[2]=(b)[2]^(c)[2]; \
|
||||
(a)[3]=(b)[3]^(c)[3]; \
|
||||
}while(0)
|
||||
|
||||
|
||||
void camellia_setup128(const u8 *key, u32 *subkey);
|
||||
void camellia_setup192(const u8 *key, u32 *subkey);
|
||||
void camellia_setup256(const u8 *key, u32 *subkey);
|
||||
|
||||
void camellia_encrypt128(const u32 *subkey, u32 *io);
|
||||
void camellia_decrypt128(const u32 *subkey, u32 *io);
|
||||
void camellia_encrypt256(const u32 *subkey, u32 *io);
|
||||
void camellia_decrypt256(const u32 *subkey, u32 *io);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef HEADER_CAMELLIA_LOCL_H */
|
||||
|
||||
116
crypto/camellia/cmll_misc.c
Normal file
116
crypto/camellia/cmll_misc.c
Normal file
@@ -0,0 +1,116 @@
|
||||
/* crypto/camellia/camellia_misc.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/camellia.h>
|
||||
#include "cmll_locl.h"
|
||||
|
||||
const char CAMELLIA_version[]="CAMELLIA" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
int Camellia_set_key(const unsigned char *userKey, const int bits,
|
||||
CAMELLIA_KEY *key)
|
||||
{
|
||||
if (!userKey || !key)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(bits)
|
||||
{
|
||||
case 128:
|
||||
camellia_setup128(userKey, (unsigned int *)key->rd_key);
|
||||
key->enc = camellia_encrypt128;
|
||||
key->dec = camellia_decrypt128;
|
||||
break;
|
||||
case 192:
|
||||
camellia_setup192(userKey, (unsigned int *)key->rd_key);
|
||||
key->enc = camellia_encrypt256;
|
||||
key->dec = camellia_decrypt256;
|
||||
break;
|
||||
case 256:
|
||||
camellia_setup256(userKey, (unsigned int *)key->rd_key);
|
||||
key->enc = camellia_encrypt256;
|
||||
key->dec = camellia_decrypt256;
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
||||
key->bitLength = bits;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Camellia_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key)
|
||||
{
|
||||
u32 tmp[CAMELLIA_BLOCK_SIZE/sizeof(u32)];
|
||||
const union { long one; char little; } camellia_endian = {1};
|
||||
|
||||
memcpy(tmp, in, CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little) SWAP4WORD(tmp);
|
||||
key->enc(key->rd_key, tmp);
|
||||
if (camellia_endian.little) SWAP4WORD(tmp);
|
||||
memcpy(out, tmp, CAMELLIA_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
void Camellia_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const CAMELLIA_KEY *key)
|
||||
{
|
||||
u32 tmp[CAMELLIA_BLOCK_SIZE/sizeof(u32)];
|
||||
const union { long one; char little; } camellia_endian = {1};
|
||||
|
||||
memcpy(tmp, in, CAMELLIA_BLOCK_SIZE);
|
||||
if (camellia_endian.little) SWAP4WORD(tmp);
|
||||
key->dec(key->rd_key, tmp);
|
||||
if (camellia_endian.little) SWAP4WORD(tmp);
|
||||
memcpy(out, tmp, CAMELLIA_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
141
crypto/camellia/cmll_ofb.c
Normal file
141
crypto/camellia/cmll_ofb.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/* crypto/camellia/camellia_ofb.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
*/
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef CAMELLIA_DEBUG
|
||||
# ifndef NDEBUG
|
||||
# define NDEBUG
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <openssl/camellia.h>
|
||||
#include "cmll_locl.h"
|
||||
|
||||
/* The input and output encrypted as though 128bit ofb mode is being
|
||||
* used. The extra state information to record how much of the
|
||||
* 128bit block we have used is contained in *num;
|
||||
*/
|
||||
void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const unsigned long length, const CAMELLIA_KEY *key,
|
||||
unsigned char *ivec, int *num) {
|
||||
|
||||
unsigned int n;
|
||||
unsigned long l=length;
|
||||
|
||||
assert(in && out && key && ivec && num);
|
||||
|
||||
n = *num;
|
||||
|
||||
while (l--) {
|
||||
if (n == 0) {
|
||||
Camellia_encrypt(ivec, ivec, key);
|
||||
}
|
||||
*(out++) = *(in++) ^ ivec[n];
|
||||
n = (n+1) % CAMELLIA_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
*num=n;
|
||||
}
|
||||
@@ -60,7 +60,7 @@
|
||||
#include "cast_lcl.h"
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
const char *CAST_version="CAST" OPENSSL_VERSION_PTEXT;
|
||||
const char CAST_version[]="CAST" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
||||
CAST_KEY *ks, int enc)
|
||||
|
||||
@@ -31,6 +31,24 @@ static int zlib_stateful_compress_block(COMP_CTX *ctx, unsigned char *out,
|
||||
static int zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out,
|
||||
unsigned int olen, unsigned char *in, unsigned int ilen);
|
||||
|
||||
|
||||
/* memory allocations functions for zlib intialization */
|
||||
static void* zlib_zalloc(void* opaque, unsigned int no, unsigned int size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p=OPENSSL_malloc(no*size);
|
||||
if (p)
|
||||
memset(p, 0, no*size);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static void zlib_zfree(void* opaque, void* address)
|
||||
{
|
||||
OPENSSL_free(address);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int zlib_compress_block(COMP_CTX *ctx, unsigned char *out,
|
||||
unsigned int olen, unsigned char *in, unsigned int ilen);
|
||||
@@ -133,8 +151,8 @@ static int zlib_stateful_init(COMP_CTX *ctx)
|
||||
if (state == NULL)
|
||||
goto err;
|
||||
|
||||
state->istream.zalloc = Z_NULL;
|
||||
state->istream.zfree = Z_NULL;
|
||||
state->istream.zalloc = zlib_zalloc;
|
||||
state->istream.zfree = zlib_zfree;
|
||||
state->istream.opaque = Z_NULL;
|
||||
state->istream.next_in = Z_NULL;
|
||||
state->istream.next_out = Z_NULL;
|
||||
@@ -145,8 +163,8 @@ static int zlib_stateful_init(COMP_CTX *ctx)
|
||||
if (err != Z_OK)
|
||||
goto err;
|
||||
|
||||
state->ostream.zalloc = Z_NULL;
|
||||
state->ostream.zfree = Z_NULL;
|
||||
state->ostream.zalloc = zlib_zalloc;
|
||||
state->ostream.zfree = zlib_zfree;
|
||||
state->ostream.opaque = Z_NULL;
|
||||
state->ostream.next_in = Z_NULL;
|
||||
state->ostream.next_out = Z_NULL;
|
||||
@@ -158,17 +176,6 @@ static int zlib_stateful_init(COMP_CTX *ctx)
|
||||
goto err;
|
||||
|
||||
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_COMP,ctx,&ctx->ex_data);
|
||||
if (zlib_stateful_ex_idx == -1)
|
||||
{
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_COMP);
|
||||
if (zlib_stateful_ex_idx == -1)
|
||||
zlib_stateful_ex_idx =
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_COMP,
|
||||
0,NULL,NULL,NULL,zlib_stateful_free_ex_data);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_COMP);
|
||||
if (zlib_stateful_ex_idx == -1)
|
||||
goto err;
|
||||
}
|
||||
CRYPTO_set_ex_data(&ctx->ex_data,zlib_stateful_ex_idx,state);
|
||||
return 1;
|
||||
err:
|
||||
@@ -379,7 +386,25 @@ COMP_METHOD *COMP_zlib(void)
|
||||
if (zlib_loaded)
|
||||
#endif
|
||||
#if defined(ZLIB) || defined(ZLIB_SHARED)
|
||||
{
|
||||
/* init zlib_stateful_ex_idx here so that in a multi-process
|
||||
* application it's enough to intialize openssl before forking
|
||||
* (idx will be inherited in all the children) */
|
||||
if (zlib_stateful_ex_idx == -1)
|
||||
{
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_COMP);
|
||||
if (zlib_stateful_ex_idx == -1)
|
||||
zlib_stateful_ex_idx =
|
||||
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_COMP,
|
||||
0,NULL,NULL,NULL,zlib_stateful_free_ex_data);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_COMP);
|
||||
if (zlib_stateful_ex_idx == -1)
|
||||
goto err;
|
||||
}
|
||||
|
||||
meth = &zlib_stateful_method;
|
||||
}
|
||||
err:
|
||||
#endif
|
||||
|
||||
return(meth);
|
||||
|
||||
@@ -82,15 +82,12 @@ static ERR_STRING_DATA COMP_str_reasons[]=
|
||||
|
||||
void ERR_load_COMP_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(COMP_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,COMP_str_functs);
|
||||
ERR_load_strings(0,COMP_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ static int def_dump(const CONF *conf, BIO *bp);
|
||||
static int def_is_number(const CONF *conf, char c);
|
||||
static int def_to_int(const CONF *conf, char c);
|
||||
|
||||
const char *CONF_def_version="CONF_def" OPENSSL_VERSION_PTEXT;
|
||||
const char CONF_def_version[]="CONF_def" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
static CONF_METHOD default_method = {
|
||||
"OpenSSL default",
|
||||
|
||||
@@ -118,15 +118,12 @@ static ERR_STRING_DATA CONF_str_reasons[]=
|
||||
|
||||
void ERR_load_CONF_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(CONF_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,CONF_str_functs);
|
||||
ERR_load_strings(0,CONF_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
#include <openssl/conf_api.h>
|
||||
#include <openssl/lhash.h>
|
||||
|
||||
const char *CONF_version="CONF" OPENSSL_VERSION_PTEXT;
|
||||
const char CONF_version[]="CONF" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
static CONF_METHOD *default_CONF_method=NULL;
|
||||
|
||||
|
||||
@@ -92,15 +92,12 @@ static ERR_STRING_DATA CRYPTO_str_reasons[]=
|
||||
|
||||
void ERR_load_CRYPTO_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(CRYPTO_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,CRYPTO_str_functs);
|
||||
ERR_load_strings(0,CRYPTO_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ DECLARE_STACK_OF(CRYPTO_dynlock)
|
||||
IMPLEMENT_STACK_OF(CRYPTO_dynlock)
|
||||
|
||||
/* real #defines in crypto.h, keep these upto date */
|
||||
static const char* lock_names[CRYPTO_NUM_LOCKS] =
|
||||
static const char* const lock_names[CRYPTO_NUM_LOCKS] =
|
||||
{
|
||||
"<<ERROR>>",
|
||||
"err",
|
||||
|
||||
@@ -78,7 +78,7 @@ $!
|
||||
$ ENCRYPT_TYPES = "Basic,"+ -
|
||||
"OBJECTS,"+ -
|
||||
"MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ -
|
||||
"DES,RC2,RC4,RC5,IDEA,BF,CAST,"+ -
|
||||
"DES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,"+ -
|
||||
"BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,AES,"+ -
|
||||
"BUFFER,BIO,STACK,LHASH,RAND,ERR,"+ -
|
||||
"EVP,EVP_2,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
|
||||
@@ -182,6 +182,8 @@ $ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64"
|
||||
$ LIB_IDEA = "i_cbc,i_cfb64,i_ofb64,i_ecb,i_skey"
|
||||
$ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64"
|
||||
$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64"
|
||||
$ LIB_CAMELLIA = "camellia,cmll_misc,cmll_ecb,cmll_cbc,cmll_ofb,"+ -
|
||||
"cmll_cfb,cmll_ctr"
|
||||
$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper"
|
||||
$ IF F$TRNLNM("OPENSSL_NO_ASM").OR.ARCH.EQS."AXP" THEN LIB_BN_ASM = "bn_asm"
|
||||
$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_ctx,bn_mul,bn_mod,"+ -
|
||||
@@ -207,7 +209,8 @@ $ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ -
|
||||
"tb_rsa,tb_dsa,tb_ecdsa,tb_dh,tb_ecdh,tb_rand,tb_store,"+ -
|
||||
"tb_cipher,tb_digest,"+ -
|
||||
"eng_openssl,eng_dyn,eng_cnf,eng_cryptodev,eng_padlock"
|
||||
$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,aes_ctr"
|
||||
$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,"+ -
|
||||
"aes_ctr,aes_ige"
|
||||
$ LIB_BUFFER = "buffer,buf_err"
|
||||
$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
|
||||
"bss_mem,bss_null,bss_fd,"+ -
|
||||
@@ -223,7 +226,7 @@ $ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ -
|
||||
$ LIB_ERR = "err,err_all,err_prn"
|
||||
$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err"
|
||||
$ LIB_EVP = "encode,digest,evp_enc,evp_key,evp_acnf,"+ -
|
||||
"e_des,e_bf,e_idea,e_des3,"+ -
|
||||
"e_des,e_bf,e_idea,e_des3,e_camellia,"+ -
|
||||
"e_rc4,e_aes,names,"+ -
|
||||
"e_xcbc_d,e_rc2,e_cast,e_rc5"
|
||||
$ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1," + -
|
||||
@@ -256,7 +259,8 @@ $ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ -
|
||||
"v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ -
|
||||
"v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld,v3_purp,v3_info,"+ -
|
||||
"v3_ocsp,v3_akeya,v3_pmaps,v3_pcons,v3_ncons,v3_pcia,v3_pci,"+ -
|
||||
"pcy_cache,pcy_node,pcy_data,pcy_map,pcy_tree,pcy_lib"
|
||||
"pcy_cache,pcy_node,pcy_data,pcy_map,pcy_tree,pcy_lib,"+ -
|
||||
"v3_asid,v3_addr"
|
||||
$ LIB_CONF = "conf_err,conf_lib,conf_api,conf_def,conf_mod,conf_mall,conf_sap"
|
||||
$ LIB_TXT_DB = "txt_db"
|
||||
$ LIB_PKCS7 = "pk7_asn1,pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,"+ -
|
||||
|
||||
@@ -25,7 +25,7 @@ and then you can use the 'DES_PTR' option.
|
||||
|
||||
The file options.txt has the options listed for best speed on quite a
|
||||
few systems. Look and the options (UNROLL, PTR, RISC2 etc) and then
|
||||
turn on the relevent option in the Makefile
|
||||
turn on the relevant option in the Makefile.
|
||||
|
||||
There are some special Makefile targets that make life easier.
|
||||
make cc - standard cc build
|
||||
|
||||
@@ -67,5 +67,5 @@
|
||||
#define DES_version OSSL_DES_version
|
||||
#define libdes_version OSSL_libdes_version
|
||||
|
||||
OPENSSL_EXTERN const char *OSSL_DES_version; /* SSLeay version string */
|
||||
OPENSSL_EXTERN const char *OSSL_libdes_version; /* old libdes version string */
|
||||
OPENSSL_EXTERN const char OSSL_DES_version[]; /* SSLeay version string */
|
||||
OPENSSL_EXTERN const char OSSL_libdes_version[]; /* old libdes version string */
|
||||
|
||||
@@ -62,8 +62,8 @@
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/bio.h>
|
||||
|
||||
OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT;
|
||||
OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT;
|
||||
OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT;
|
||||
OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
const char *DES_options(void)
|
||||
{
|
||||
|
||||
@@ -73,6 +73,10 @@
|
||||
#include <openssl/bn.h>
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_DH_MAX_MODULUS_BITS
|
||||
# define OPENSSL_DH_MAX_MODULUS_BITS 10000
|
||||
#endif
|
||||
|
||||
#define DH_FLAG_CACHE_MONT_P 0x01
|
||||
#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH
|
||||
* implementation now uses constant time
|
||||
@@ -221,6 +225,7 @@ void ERR_load_DH_strings(void);
|
||||
/* Reason codes. */
|
||||
#define DH_R_BAD_GENERATOR 101
|
||||
#define DH_R_INVALID_PUBKEY 102
|
||||
#define DH_R_MODULUS_TOO_LARGE 103
|
||||
#define DH_R_NO_PRIVATE_VALUE 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -84,6 +84,7 @@ static ERR_STRING_DATA DH_str_reasons[]=
|
||||
{
|
||||
{ERR_REASON(DH_R_BAD_GENERATOR) ,"bad generator"},
|
||||
{ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"},
|
||||
{ERR_REASON(DH_R_MODULUS_TOO_LARGE) ,"modulus too large"},
|
||||
{ERR_REASON(DH_R_NO_PRIVATE_VALUE) ,"no private value"},
|
||||
{0,NULL}
|
||||
};
|
||||
@@ -92,15 +93,12 @@ static ERR_STRING_DATA DH_str_reasons[]=
|
||||
|
||||
void ERR_load_DH_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(DH_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,DH_str_functs);
|
||||
ERR_load_strings(0,DH_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -173,12 +173,18 @@ err:
|
||||
|
||||
static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
|
||||
{
|
||||
BN_CTX *ctx;
|
||||
BN_CTX *ctx=NULL;
|
||||
BN_MONT_CTX *mont=NULL;
|
||||
BIGNUM *tmp;
|
||||
int ret= -1;
|
||||
int check_result;
|
||||
|
||||
if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS)
|
||||
{
|
||||
DHerr(DH_F_COMPUTE_KEY,DH_R_MODULUS_TOO_LARGE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL) goto err;
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
|
||||
const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
|
||||
const char DH_version[]="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
static const DH_METHOD *default_DH_method = NULL;
|
||||
|
||||
|
||||
@@ -84,6 +84,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_DSA_MAX_MODULUS_BITS
|
||||
# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
|
||||
#endif
|
||||
|
||||
#define DSA_FLAG_CACHE_MONT_P 0x01
|
||||
#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DSA
|
||||
* implementation now uses constant time
|
||||
@@ -270,8 +274,10 @@ void ERR_load_DSA_strings(void);
|
||||
#define DSA_F_SIG_CB 114
|
||||
|
||||
/* Reason codes. */
|
||||
#define DSA_R_BAD_Q_VALUE 102
|
||||
#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
|
||||
#define DSA_R_MISSING_PARAMETERS 101
|
||||
#define DSA_R_MODULUS_TOO_LARGE 103
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -89,8 +89,10 @@ static ERR_STRING_DATA DSA_str_functs[]=
|
||||
|
||||
static ERR_STRING_DATA DSA_str_reasons[]=
|
||||
{
|
||||
{ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q value"},
|
||||
{ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"},
|
||||
{ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"},
|
||||
{ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus too large"},
|
||||
{0,NULL}
|
||||
};
|
||||
|
||||
@@ -98,15 +100,12 @@ static ERR_STRING_DATA DSA_str_reasons[]=
|
||||
|
||||
void ERR_load_DSA_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(DSA_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,DSA_str_functs);
|
||||
ERR_load_strings(0,DSA_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
#include <openssl/dh.h>
|
||||
#endif
|
||||
|
||||
const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT;
|
||||
const char DSA_version[]="DSA" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
static const DSA_METHOD *default_DSA_method = NULL;
|
||||
|
||||
|
||||
@@ -304,6 +304,18 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (BN_num_bits(dsa->q) != 160)
|
||||
{
|
||||
DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_BAD_Q_VALUE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (BN_num_bits(dsa->p) > OPENSSL_DSA_MAX_MODULUS_BITS)
|
||||
{
|
||||
DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MODULUS_TOO_LARGE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
BN_init(&u1);
|
||||
BN_init(&u2);
|
||||
BN_init(&t1);
|
||||
|
||||
@@ -136,15 +136,12 @@ static ERR_STRING_DATA DSO_str_reasons[]=
|
||||
|
||||
void ERR_load_DSO_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(DSO_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,DSO_str_functs);
|
||||
ERR_load_strings(0,DSO_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -93,6 +93,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef OPENSSL_ECC_MAX_FIELD_BITS
|
||||
# define OPENSSL_ECC_MAX_FIELD_BITS 661
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
/* values as defined in X9.62 (ECDSA) and elsewhere */
|
||||
POINT_CONVERSION_COMPRESSED = 2,
|
||||
@@ -482,6 +486,7 @@ void ERR_load_EC_strings(void);
|
||||
#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
|
||||
#define EC_R_DISCRIMINANT_IS_ZERO 118
|
||||
#define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
|
||||
#define EC_R_FIELD_TOO_LARGE 138
|
||||
#define EC_R_GROUP2PKPARAMETERS_FAILURE 120
|
||||
#define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
|
||||
#define EC_R_INCOMPATIBLE_OBJECTS 101
|
||||
@@ -492,7 +497,9 @@ void ERR_load_EC_strings(void);
|
||||
#define EC_R_INVALID_FIELD 103
|
||||
#define EC_R_INVALID_FORM 104
|
||||
#define EC_R_INVALID_GROUP_ORDER 122
|
||||
#define EC_R_INVALID_PENTANOMIAL_BASIS 132
|
||||
#define EC_R_INVALID_PRIVATE_KEY 123
|
||||
#define EC_R_INVALID_TRINOMIAL_BASIS 137
|
||||
#define EC_R_MISSING_PARAMETERS 124
|
||||
#define EC_R_MISSING_PRIVATE_KEY 125
|
||||
#define EC_R_NOT_A_NIST_PRIME 135
|
||||
|
||||
@@ -529,6 +529,8 @@ static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
|
||||
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
curve->seed->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
|
||||
curve->seed->flags |= ASN1_STRING_FLAG_BITS_LEFT;
|
||||
if (!ASN1_BIT_STRING_set(curve->seed, group->seed,
|
||||
(int)group->seed_len))
|
||||
{
|
||||
@@ -741,6 +743,7 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
|
||||
EC_GROUP *ret = NULL;
|
||||
BIGNUM *p = NULL, *a = NULL, *b = NULL;
|
||||
EC_POINT *point=NULL;
|
||||
long field_bits;
|
||||
|
||||
if (!params->fieldID || !params->fieldID->fieldType ||
|
||||
!params->fieldID->p.ptr)
|
||||
@@ -779,6 +782,13 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
|
||||
|
||||
char_two = params->fieldID->p.char_two;
|
||||
|
||||
field_bits = char_two->m;
|
||||
if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS)
|
||||
{
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_FIELD_TOO_LARGE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ((p = BN_new()) == NULL)
|
||||
{
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE);
|
||||
@@ -799,6 +809,13 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
|
||||
}
|
||||
|
||||
tmp_long = ASN1_INTEGER_get(char_two->p.tpBasis);
|
||||
|
||||
if (!(char_two->m > tmp_long && tmp_long > 0))
|
||||
{
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_TRINOMIAL_BASIS);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* create the polynomial */
|
||||
if (!BN_set_bit(p, (int)char_two->m))
|
||||
goto err;
|
||||
@@ -817,6 +834,13 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!(char_two->m > penta->k3 && penta->k3 > penta->k2 && penta->k2 > penta->k1 && penta->k1 > 0))
|
||||
{
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_PENTANOMIAL_BASIS);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* create the polynomial */
|
||||
if (!BN_set_bit(p, (int)char_two->m)) goto err;
|
||||
if (!BN_set_bit(p, (int)penta->k1)) goto err;
|
||||
@@ -853,6 +877,20 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (BN_is_negative(p) || BN_is_zero(p))
|
||||
{
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_FIELD);
|
||||
goto err;
|
||||
}
|
||||
|
||||
field_bits = BN_num_bits(p);
|
||||
if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS)
|
||||
{
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_FIELD_TOO_LARGE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* create the EC_GROUP structure */
|
||||
ret = EC_GROUP_new_curve_GFp(p, a, b, NULL);
|
||||
}
|
||||
@@ -910,6 +948,16 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (BN_is_negative(a) || BN_is_zero(a))
|
||||
{
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_GROUP_ORDER);
|
||||
goto err;
|
||||
}
|
||||
if (BN_num_bits(a) > (int)field_bits + 1) /* Hasse bound */
|
||||
{
|
||||
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_GROUP_ORDER);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* extract the cofactor (optional) */
|
||||
if (params->cofactor == NULL)
|
||||
@@ -1245,6 +1293,8 @@ int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out)
|
||||
goto err;
|
||||
}
|
||||
|
||||
priv_key->publicKey->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);
|
||||
priv_key->publicKey->flags |= ASN1_STRING_FLAG_BITS_LEFT;
|
||||
if (!M_ASN1_BIT_STRING_set(priv_key->publicKey, buffer,
|
||||
buf_len))
|
||||
{
|
||||
|
||||
@@ -188,6 +188,7 @@ static ERR_STRING_DATA EC_str_reasons[]=
|
||||
{ERR_REASON(EC_R_D2I_ECPKPARAMETERS_FAILURE),"d2i ecpkparameters failure"},
|
||||
{ERR_REASON(EC_R_DISCRIMINANT_IS_ZERO) ,"discriminant is zero"},
|
||||
{ERR_REASON(EC_R_EC_GROUP_NEW_BY_NAME_FAILURE),"ec group new by name failure"},
|
||||
{ERR_REASON(EC_R_FIELD_TOO_LARGE) ,"field too large"},
|
||||
{ERR_REASON(EC_R_GROUP2PKPARAMETERS_FAILURE),"group2pkparameters failure"},
|
||||
{ERR_REASON(EC_R_I2D_ECPKPARAMETERS_FAILURE),"i2d ecpkparameters failure"},
|
||||
{ERR_REASON(EC_R_INCOMPATIBLE_OBJECTS) ,"incompatible objects"},
|
||||
@@ -198,7 +199,9 @@ static ERR_STRING_DATA EC_str_reasons[]=
|
||||
{ERR_REASON(EC_R_INVALID_FIELD) ,"invalid field"},
|
||||
{ERR_REASON(EC_R_INVALID_FORM) ,"invalid form"},
|
||||
{ERR_REASON(EC_R_INVALID_GROUP_ORDER) ,"invalid group order"},
|
||||
{ERR_REASON(EC_R_INVALID_PENTANOMIAL_BASIS),"invalid pentanomial basis"},
|
||||
{ERR_REASON(EC_R_INVALID_PRIVATE_KEY) ,"invalid private key"},
|
||||
{ERR_REASON(EC_R_INVALID_TRINOMIAL_BASIS),"invalid trinomial basis"},
|
||||
{ERR_REASON(EC_R_MISSING_PARAMETERS) ,"missing parameters"},
|
||||
{ERR_REASON(EC_R_MISSING_PRIVATE_KEY) ,"missing private key"},
|
||||
{ERR_REASON(EC_R_NOT_A_NIST_PRIME) ,"not a NIST prime"},
|
||||
@@ -224,15 +227,12 @@ static ERR_STRING_DATA EC_str_reasons[]=
|
||||
|
||||
void ERR_load_EC_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(EC_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,EC_str_functs);
|
||||
ERR_load_strings(0,EC_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
static ERR_STRING_DATA ECDH_str_functs[]=
|
||||
{
|
||||
{ERR_FUNC(ECDH_F_ECDH_COMPUTE_KEY), "ECDH_compute_key"},
|
||||
{ERR_FUNC(ECDH_F_ECDH_DATA_NEW_METHOD), "ECDH_DATA_new_method"},
|
||||
{ERR_FUNC(ECDH_F_ECDH_DATA_NEW_METHOD), "ECDH_DATA_NEW_METHOD"},
|
||||
{0,NULL}
|
||||
};
|
||||
|
||||
@@ -87,15 +87,12 @@ static ERR_STRING_DATA ECDH_str_reasons[]=
|
||||
|
||||
void ERR_load_ECDH_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(ECDH_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,ECDH_str_functs);
|
||||
ERR_load_strings(0,ECDH_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
#endif
|
||||
#include <openssl/err.h>
|
||||
|
||||
const char *ECDH_version="ECDH" OPENSSL_VERSION_PTEXT;
|
||||
const char ECDH_version[]="ECDH" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
static const ECDH_METHOD *default_ECDH_method = NULL;
|
||||
|
||||
|
||||
@@ -261,6 +261,7 @@ void ERR_load_ECDSA_strings(void);
|
||||
#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 101
|
||||
#define ECDSA_R_ERR_EC_LIB 102
|
||||
#define ECDSA_R_MISSING_PARAMETERS 103
|
||||
#define ECDSA_R_NEED_NEW_SETUP_VALUES 106
|
||||
#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104
|
||||
#define ECDSA_R_SIGNATURE_MALLOC_FAILED 105
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
static ERR_STRING_DATA ECDSA_str_functs[]=
|
||||
{
|
||||
{ERR_FUNC(ECDSA_F_ECDSA_DATA_NEW_METHOD), "ECDSA_DATA_new_method"},
|
||||
{ERR_FUNC(ECDSA_F_ECDSA_DATA_NEW_METHOD), "ECDSA_DATA_NEW_METHOD"},
|
||||
{ERR_FUNC(ECDSA_F_ECDSA_DO_SIGN), "ECDSA_do_sign"},
|
||||
{ERR_FUNC(ECDSA_F_ECDSA_DO_VERIFY), "ECDSA_do_verify"},
|
||||
{ERR_FUNC(ECDSA_F_ECDSA_SIGN_SETUP), "ECDSA_sign_setup"},
|
||||
@@ -83,6 +83,7 @@ static ERR_STRING_DATA ECDSA_str_reasons[]=
|
||||
{ERR_REASON(ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"},
|
||||
{ERR_REASON(ECDSA_R_ERR_EC_LIB) ,"err ec lib"},
|
||||
{ERR_REASON(ECDSA_R_MISSING_PARAMETERS) ,"missing parameters"},
|
||||
{ERR_REASON(ECDSA_R_NEED_NEW_SETUP_VALUES),"need new setup values"},
|
||||
{ERR_REASON(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED),"random number generation failed"},
|
||||
{ERR_REASON(ECDSA_R_SIGNATURE_MALLOC_FAILED),"signature malloc failed"},
|
||||
{0,NULL}
|
||||
@@ -92,15 +93,12 @@ static ERR_STRING_DATA ECDSA_str_reasons[]=
|
||||
|
||||
void ERR_load_ECDSA_strings(void)
|
||||
{
|
||||
static int init=1;
|
||||
|
||||
if (init)
|
||||
{
|
||||
init=0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
if (ERR_func_error_string(ECDSA_str_functs[0].error) == NULL)
|
||||
{
|
||||
ERR_load_strings(0,ECDSA_str_functs);
|
||||
ERR_load_strings(0,ECDSA_str_reasons);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/bn.h>
|
||||
|
||||
const char *ECDSA_version="ECDSA" OPENSSL_VERSION_PTEXT;
|
||||
const char ECDSA_version[]="ECDSA" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
static const ECDSA_METHOD *default_ECDSA_method = NULL;
|
||||
|
||||
|
||||
@@ -299,8 +299,21 @@ static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dgst_len,
|
||||
ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (BN_is_zero(s))
|
||||
{
|
||||
/* if kinv and r have been supplied by the caller
|
||||
* don't to generate new kinv and r values */
|
||||
if (in_kinv != NULL && in_r != NULL)
|
||||
{
|
||||
ECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ECDSA_R_NEED_NEW_SETUP_VALUES);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* s != 0 => we have a valid signature */
|
||||
break;
|
||||
}
|
||||
while (BN_is_zero(s));
|
||||
while (1);
|
||||
|
||||
ok = 1;
|
||||
err:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user