Compare commits
87 Commits
OpenSSL_1_
...
OpenSSL_1_
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d9e048ceac | ||
![]() |
65a9383e6b | ||
![]() |
c6b82f7ee9 | ||
![]() |
25590043d1 | ||
![]() |
8a5d624d5b | ||
![]() |
ae4a75cecf | ||
![]() |
2e884ce11d | ||
![]() |
da8f1b738c | ||
![]() |
33f44acbbe | ||
![]() |
11c48a0fd2 | ||
![]() |
3cdaca2436 | ||
![]() |
b23da2919b | ||
![]() |
610dfc3ef4 | ||
![]() |
080f395392 | ||
![]() |
f852b60797 | ||
![]() |
e2356454c8 | ||
![]() |
e5420be6cd | ||
![]() |
9c00a95060 | ||
![]() |
ebc71865f0 | ||
![]() |
1dfa62d4c8 | ||
![]() |
8c6364e198 | ||
![]() |
98c2e93723 | ||
![]() |
c053e538b4 | ||
![]() |
6386647298 | ||
![]() |
4b24b754f5 | ||
![]() |
bfff2cc192 | ||
![]() |
d8b177719a | ||
![]() |
d985a68c89 | ||
![]() |
8dad8bc465 | ||
![]() |
235e76bce1 | ||
![]() |
d38c549e60 | ||
![]() |
558189183f | ||
![]() |
77ada38dbd | ||
![]() |
8124ebcd78 | ||
![]() |
04fde2025b | ||
![]() |
6bd61198fb | ||
![]() |
23b5e47ffc | ||
![]() |
fb81e6d300 | ||
![]() |
50ff4afb03 | ||
![]() |
c51f6bccea | ||
![]() |
836a811604 | ||
![]() |
bb65e3f22b | ||
![]() |
b8719c753e | ||
![]() |
92b2530acd | ||
![]() |
9ff94ad7ae | ||
![]() |
60ccb02c4a | ||
![]() |
094fb13876 | ||
![]() |
9c5d75d5a9 | ||
![]() |
ca461ecd11 | ||
![]() |
0ad9fe2d59 | ||
![]() |
a203df7521 | ||
![]() |
144517299c | ||
![]() |
5c468f0c1f | ||
![]() |
83a4ae6b0b | ||
![]() |
9374bc1c10 | ||
![]() |
e9c563fc29 | ||
![]() |
4887e07819 | ||
![]() |
652ac3e93a | ||
![]() |
8d2f61ac70 | ||
![]() |
02a23fa309 | ||
![]() |
bef20d4a68 | ||
![]() |
dddddb2e6c | ||
![]() |
8fcb93613a | ||
![]() |
ecb58c1628 | ||
![]() |
a969ca5cc8 | ||
![]() |
1e4406a854 | ||
![]() |
94fbee800b | ||
![]() |
c50847c28b | ||
![]() |
b1ce2d24dd | ||
![]() |
743fb51d2c | ||
![]() |
0ed781740d | ||
![]() |
d0e542fdc9 | ||
![]() |
457863efdf | ||
![]() |
5bd4fcc5c2 | ||
![]() |
3dd2eebfbc | ||
![]() |
d079b387a3 | ||
![]() |
8eeaeb4b04 | ||
![]() |
0041925844 | ||
![]() |
14fa016b2b | ||
![]() |
7fdccda37d | ||
![]() |
cdc575c46b | ||
![]() |
2f0aaf76f3 | ||
![]() |
6b7887b0ab | ||
![]() |
9ad1b440ae | ||
![]() |
9275ad321f | ||
![]() |
216a2a5fc6 | ||
![]() |
c2c6044933 |
77
.gitignore
vendored
Normal file
77
.gitignore
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# Object files
|
||||
*.o
|
||||
|
||||
# editor artefacts
|
||||
*.swp
|
||||
.#*
|
||||
#*#
|
||||
*~
|
||||
|
||||
# Top level excludes
|
||||
/Makefile.bak
|
||||
/Makefile
|
||||
/*.a
|
||||
/include
|
||||
/*.pc
|
||||
/rehash.time
|
||||
|
||||
# Most *.c files under test/ are symlinks
|
||||
/test/*.c
|
||||
# Apart from these
|
||||
!/test/asn1test.c
|
||||
!/test/methtest.c
|
||||
!/test/dummytest.c
|
||||
!/test/igetest.c
|
||||
!/test/r160test.c
|
||||
!/test/fips_algvs.c
|
||||
|
||||
/test/*.ss
|
||||
/test/*.srl
|
||||
/test/.rnd
|
||||
/test/test*.pem
|
||||
/test/newkey.pem
|
||||
|
||||
# Certificate symbolic links
|
||||
*.0
|
||||
|
||||
# Links under apps
|
||||
/apps/CA.pl
|
||||
/apps/md4.c
|
||||
|
||||
|
||||
# Auto generated headers
|
||||
/crypto/buildinf.h
|
||||
/crypto/opensslconf.h
|
||||
|
||||
# Auto generated assembly language source files
|
||||
*.s
|
||||
!/crypto/bn/asm/pa-risc2.s
|
||||
!/crypto/bn/asm/pa-risc2W.s
|
||||
|
||||
# Executables
|
||||
/apps/openssl
|
||||
/test/sha256t
|
||||
/test/sha512t
|
||||
/test/*test
|
||||
/test/fips_aesavs
|
||||
/test/fips_desmovs
|
||||
/test/fips_dhvs
|
||||
/test/fips_drbgvs
|
||||
/test/fips_dssvs
|
||||
/test/fips_ecdhvs
|
||||
/test/fips_ecdsavs
|
||||
/test/fips_rngvs
|
||||
/test/fips_test_suite
|
||||
*.so*
|
||||
*.dylib*
|
||||
*.dll*
|
||||
# Exceptions
|
||||
!/test/bctest
|
||||
!/crypto/des/times/486-50.sol
|
||||
|
||||
# Misc auto generated files
|
||||
/tools/c_rehash
|
||||
/test/evptests.txt
|
||||
lib
|
||||
Makefile.save
|
||||
*.bak
|
54
CHANGES
54
CHANGES
@@ -2,6 +2,60 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 1.0.0j and 1.0.0k [5 Feb 2013]
|
||||
|
||||
*) Make the decoding of SSLv3, TLS and DTLS CBC records constant time.
|
||||
|
||||
This addresses the flaw in CBC record processing discovered by
|
||||
Nadhem Alfardan and Kenny Paterson. Details of this attack can be found
|
||||
at: http://www.isg.rhul.ac.uk/tls/
|
||||
|
||||
Thanks go to Nadhem Alfardan and Kenny Paterson of the Information
|
||||
Security Group at Royal Holloway, University of London
|
||||
(www.isg.rhul.ac.uk) for discovering this flaw and Adam Langley and
|
||||
Emilia K<>sper for the initial patch.
|
||||
(CVE-2013-0169)
|
||||
[Emilia K<>sper, Adam Langley, Ben Laurie, Andy Polyakov, Steve Henson]
|
||||
|
||||
*) Return an error when checking OCSP signatures when key is NULL.
|
||||
This fixes a DoS attack. (CVE-2013-0166)
|
||||
[Steve Henson]
|
||||
|
||||
*) Call OCSP Stapling callback after ciphersuite has been chosen, so
|
||||
the right response is stapled. Also change SSL_get_certificate()
|
||||
so it returns the certificate actually sent.
|
||||
See http://rt.openssl.org/Ticket/Display.html?id=2836.
|
||||
(This is a backport)
|
||||
[Rob Stradling <rob.stradling@comodo.com>]
|
||||
|
||||
*) Fix possible deadlock when decoding public keys.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.0i and 1.0.0j [10 May 2012]
|
||||
|
||||
*) Sanity check record length before skipping explicit IV in DTLS
|
||||
to fix DoS attack.
|
||||
|
||||
Thanks to Codenomicon for discovering this issue using Fuzz-o-Matic
|
||||
fuzzing as a service testing platform.
|
||||
(CVE-2012-2333)
|
||||
[Steve Henson]
|
||||
|
||||
*) Initialise tkeylen properly when encrypting CMS messages.
|
||||
Thanks to Solar Designer of Openwall for reporting this issue.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.0h and 1.0.0i [19 Apr 2012]
|
||||
|
||||
*) Check for potentially exploitable overflows in asn1_d2i_read_bio
|
||||
BUF_mem_grow and BUF_mem_grow_clean. Refuse attempts to shrink buffer
|
||||
in CRYPTO_realloc_clean.
|
||||
|
||||
Thanks to Tavis Ormandy, Google Security Team, for discovering this
|
||||
issue and to Adam Langley <agl@chromium.org> for fixing it.
|
||||
(CVE-2012-2110)
|
||||
[Adam Langley (Google), Tavis Ormandy, Google Security Team]
|
||||
|
||||
Changes between 1.0.0g and 1.0.0h [12 Mar 2012]
|
||||
|
||||
*) Fix MMA (Bleichenbacher's attack on PKCS #1 v1.5 RSA padding) weakness
|
||||
|
15
Configure
15
Configure
@@ -167,6 +167,7 @@ my %table=(
|
||||
"debug-ben-openbsd","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
|
||||
"debug-ben-openbsd-debug","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DOPENSSL_OPENBSD_DEV_CRYPTO -DOPENSSL_NO_ASM -g3 -O2 -pedantic -Wall -Wshadow -Werror -pipe::(unknown)::::",
|
||||
"debug-ben-debug", "gcc44:$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O2 -pipe::(unknown)::::::",
|
||||
"debug-ben-debug-64", "gcc:$gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=strict-aliasing -Wno-error=uninitialized -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe::${BSDthreads}:::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-ben-no-opt", "gcc: -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DDEBUG_SAFESTACK -DCRYPTO_MDEBUG -Werror -DL_ENDIAN -DTERMIOS -Wall -g3::(unknown)::::::",
|
||||
"debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -pipe::(unknown)::::::",
|
||||
"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}",
|
||||
@@ -175,10 +176,10 @@ my %table=(
|
||||
"debug-steve64", "gcc:$gcc_devteam_warn -m64 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -g -DMD32_REG_T=int::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-steve32", "gcc:$gcc_devteam_warn -m32 -DL_ENDIAN -DCONF_DEBUG -DDEBUG_SAFESTACK -g -pipe::-D_REENTRANT::-rdynamic -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC:-m32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-steve-opt", "gcc:$gcc_devteam_warn -m64 -O3 -DL_ENDIAN -DTERMIO -DCONF_DEBUG -DDEBUG_SAFESTACK -g -DMD32_REG_T=int::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"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)",
|
||||
"debug-levitte-linux-elf-extreme","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 -W -Wundef -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-extreme","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 -W -Wundef -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)",
|
||||
"debug-levitte-linux-elf","gcc:-DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -ggdb -g3 -Wall::-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 -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -ggdb -g3 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-levitte-linux-elf-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DTERMIO -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -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-extreme","gcc:-DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -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)",
|
||||
"debug-geoff32","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -DMD32_REG_T=int -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:BN_LLONG:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-geoff64","gcc:-DBN_DEBUG -DBN_DEBUG_RAND -DBN_STRICT -DPURIFY -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -DMD32_REG_T=int -O1 -ggdb2 -Wall -Werror -Wundef -pedantic -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Wmissing-prototypes -Wmissing-declarations -Wno-long-long::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-linux-pentium","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -mcpu=pentium -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
|
||||
@@ -237,7 +238,7 @@ my %table=(
|
||||
"solaris-sparcv7-cc","cc:-xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${no_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"solaris-sparcv8-cc","cc:-xarch=v8 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"solaris-sparcv9-cc","cc:-xtarget=ultra -xarch=v8plus -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-xarch=v9 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):/usr/ccs/bin/ar rs::/64",
|
||||
"solaris64-sparcv9-cc","cc:-xtarget=ultra -xarch=v9 -xO5 -xstrconst -xdepend -Xa -DB_ENDIAN::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-xarch=v9 -G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::/64",
|
||||
####
|
||||
"debug-solaris-sparcv8-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xarch=v8 -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT::-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv8_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"debug-solaris-sparcv9-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -xtarget=ultra -xarch=v8plus -g -O -xstrconst -Xa -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:ULTRASPARC:-lsocket -lnsl -ldl:BN_LLONG RC4_CHAR RC4_CHUNK_LL DES_PTR DES_RISC1 DES_UNROLL BF_PTR:${sparcv9_asm}:dlfcn:solaris-shared:-KPIC:-G -dy -z text:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
@@ -438,8 +439,8 @@ my %table=(
|
||||
"aix64-gcc","gcc:-maix64 -O -DB_ENDIAN::-pthread:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-maix64 -shared -Wl,-G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X64",
|
||||
# Below targets assume AIX 5. Idea is to effectively disregard $OBJECT_MODE
|
||||
# at build time. $OBJECT_MODE is respected at ./config stage!
|
||||
"aix-cc", "cc:-q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-q32 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 32",
|
||||
"aix64-cc", "cc:-q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-q64 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64",
|
||||
"aix-cc", "cc:-q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::BN_LLONG RC4_CHAR:${ppc32_asm}:aix32:dlfcn:aix-shared::-q32 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 32",
|
||||
"aix64-cc", "cc:-q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst::-qthreaded -D_THREAD_SAFE:AIX::SIXTY_FOUR_BIT_LONG RC4_CHAR:${ppc64_asm}:aix64:dlfcn:aix-shared::-q64 -G:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)::-X 64",
|
||||
|
||||
#
|
||||
# Cray T90 and similar (SDSC)
|
||||
|
22
FAQ
22
FAQ
@@ -10,6 +10,7 @@ OpenSSL - Frequently Asked Questions
|
||||
* Why aren't tools like 'autoconf' and 'libtool' used?
|
||||
* What is an 'engine' version?
|
||||
* How do I check the authenticity of the OpenSSL distribution?
|
||||
* How does the versioning scheme work?
|
||||
|
||||
[LEGAL] Legal questions
|
||||
|
||||
@@ -82,7 +83,7 @@ OpenSSL - Frequently Asked Questions
|
||||
* Which is the current version of OpenSSL?
|
||||
|
||||
The current version is available from <URL: http://www.openssl.org>.
|
||||
OpenSSL 1.0.0h was released on Mar 12th, 2012.
|
||||
OpenSSL 1.0.1c was released on Feb 5th, 2013.
|
||||
|
||||
In addition to the current stable release, you can also access daily
|
||||
snapshots of the OpenSSL development version at <URL:
|
||||
@@ -108,7 +109,9 @@ In addition, you can read the most current versions at
|
||||
<URL: http://www.openssl.org/docs/>. Note that the online documents refer
|
||||
to the very latest development versions of OpenSSL and may include features
|
||||
not present in released versions. If in doubt refer to the documentation
|
||||
that came with the version of OpenSSL you are using.
|
||||
that came with the version of OpenSSL you are using. The pod format
|
||||
documentation is included in each OpenSSL distribution under the docs
|
||||
directory.
|
||||
|
||||
For information on parts of libcrypto that are not yet documented, you
|
||||
might want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's
|
||||
@@ -173,6 +176,19 @@ just do:
|
||||
|
||||
pgp TARBALL.asc
|
||||
|
||||
* How does the versioning scheme work?
|
||||
|
||||
After the release of OpenSSL 1.0.0 the versioning scheme changed. Letter
|
||||
releases (e.g. 1.0.1a) can only contain bug and security fixes and no
|
||||
new features. Minor releases change the last number (e.g. 1.0.2) and
|
||||
can contain new features that retain binary compatibility. Changes to
|
||||
the middle number are considered major releases and neither source nor
|
||||
binary compatibility is guaranteed.
|
||||
|
||||
Therefore the answer to the common question "when will feature X be
|
||||
backported to OpenSSL 1.0.0/0.9.8?" is "never" but it could appear
|
||||
in the next minor release.
|
||||
|
||||
[LEGAL] =======================================================================
|
||||
|
||||
* Do I need patent licenses to use OpenSSL?
|
||||
@@ -284,7 +300,7 @@ current directory in this case, but this has changed with 0.9.6a.)
|
||||
Check out the CA.pl(1) manual page. This provides a simple wrapper round
|
||||
the 'req', 'verify', 'ca' and 'pkcs12' utilities. For finer control check
|
||||
out the manual pages for the individual utilities and the certificate
|
||||
extensions documentation (currently in doc/openssl.txt).
|
||||
extensions documentation (in ca(1), req(1), x509v3_config(5) )
|
||||
|
||||
|
||||
* Why can't I create certificate requests?
|
||||
|
@@ -172,7 +172,7 @@ CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \
|
||||
$${EXHEADER+EXHEADER} $${HEADER+HEADER} \
|
||||
$${GENERAL+GENERAL} $${CFLAGS+CFLAGS} \
|
||||
$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
|
||||
$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \
|
||||
$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}
|
||||
|
||||
|
13
NEWS
13
NEWS
@@ -5,6 +5,19 @@
|
||||
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 1.0.0j and OpenSSL 1.0.0k:
|
||||
|
||||
o Fix for SSL/TLS/DTLS CBC plaintext recovery attack CVE-2013-0169
|
||||
o Fix OCSP bad key DoS attack CVE-2013-0166
|
||||
|
||||
Major changes between OpenSSL 1.0.0i and OpenSSL 1.0.0j:
|
||||
|
||||
o Fix DTLS record length checking bug CVE-2012-2333
|
||||
|
||||
Major changes between OpenSSL 1.0.0h and OpenSSL 1.0.0i:
|
||||
|
||||
o Fix for ASN1 overflow bug CVE-2012-2110
|
||||
|
||||
Major changes between OpenSSL 1.0.0g and OpenSSL 1.0.0h:
|
||||
|
||||
o Fix for CMS/PKCS#7 MMA CVE-2012-0884
|
||||
|
14
PROBLEMS
14
PROBLEMS
@@ -197,3 +197,17 @@ reconfigure with additional no-sse2 [or 386] option passed to ./config.
|
||||
We don't have framework to associate -ldl with no-dso, therefore the only
|
||||
way is to edit Makefile right after ./config no-dso and remove -ldl from
|
||||
EX_LIBS line.
|
||||
|
||||
* hpux-parisc2-cc no-asm build fails with SEGV in ECDSA/DH.
|
||||
|
||||
Compiler bug, presumably at particular patch level. Remaining
|
||||
hpux*-parisc*-cc configurations can be affected too. Drop optimization
|
||||
level to +O2 when compiling bn_nist.o.
|
||||
|
||||
* solaris64-sparcv9-cc link failure
|
||||
|
||||
Solaris 8 ar can fail to maintain symbol table in .a, which results in
|
||||
link failures. Apply 109147-09 or later or modify Makefile generated
|
||||
by ./Configure solaris64-sparcv9-cc and replace RANLIB assignment with
|
||||
|
||||
RANLIB= /usr/ccs/bin/ar rs
|
||||
|
2
README
2
README
@@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.0h 12 Mar 2012
|
||||
OpenSSL 1.0.0k 5 Feb 2013
|
||||
|
||||
Copyright (c) 1998-2011 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
|
5
STATUS
5
STATUS
@@ -1,11 +1,14 @@
|
||||
|
||||
OpenSSL STATUS Last modified at
|
||||
______________ $Date: 2012/03/12 14:24:48 $
|
||||
______________ $Date: 2012/05/10 14:48:54 $
|
||||
|
||||
DEVELOPMENT STATE
|
||||
|
||||
o OpenSSL 1.1.0: Under development...
|
||||
o OpenSSL 1.0.1: Under development...
|
||||
o OpenSSL 1.0.0k: Released on February 5th, 2013
|
||||
o OpenSSL 1.0.0j: Released on May 10th, 2012
|
||||
o OpenSSL 1.0.0i: Released on April 19th, 2012
|
||||
o OpenSSL 1.0.0h: Released on March 12th, 2012
|
||||
o OpenSSL 1.0.0g: Released on January 18th, 2012
|
||||
o OpenSSL 1.0.0f: Released on January 4th, 2012
|
||||
|
14
TABLE
14
TABLE
@@ -810,7 +810,7 @@ $multilib =
|
||||
$cc = cc
|
||||
$cflags = -q32 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst
|
||||
$unistd =
|
||||
$thread_cflag = -qthreaded
|
||||
$thread_cflag = -qthreaded -D_THREAD_SAFE
|
||||
$sys_id = AIX
|
||||
$lflags =
|
||||
$bn_ops = BN_LLONG RC4_CHAR
|
||||
@@ -903,7 +903,7 @@ $multilib =
|
||||
$cc = cc
|
||||
$cflags = -q64 -O -DB_ENDIAN -qmaxmem=16384 -qro -qroconst
|
||||
$unistd =
|
||||
$thread_cflag = -qthreaded
|
||||
$thread_cflag = -qthreaded -D_THREAD_SAFE
|
||||
$sys_id = AIX
|
||||
$lflags =
|
||||
$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHAR
|
||||
@@ -1831,7 +1831,7 @@ $multilib =
|
||||
|
||||
*** debug-levitte-linux-elf
|
||||
$cc = gcc
|
||||
$cflags = -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
|
||||
$cflags = -DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -ggdb -g3 -Wall
|
||||
$unistd =
|
||||
$thread_cflag = -D_REENTRANT
|
||||
$sys_id =
|
||||
@@ -1862,7 +1862,7 @@ $multilib =
|
||||
|
||||
*** debug-levitte-linux-elf-extreme
|
||||
$cc = gcc
|
||||
$cflags = -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 -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe
|
||||
$cflags = -DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DL_ENDIAN -DTERMIO -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe
|
||||
$unistd =
|
||||
$thread_cflag = -D_REENTRANT
|
||||
$sys_id =
|
||||
@@ -1893,7 +1893,7 @@ $multilib =
|
||||
|
||||
*** debug-levitte-linux-noasm
|
||||
$cc = gcc
|
||||
$cflags = -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
|
||||
$cflags = -DLEVITTE_DEBUG -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -ggdb -g3 -Wall
|
||||
$unistd =
|
||||
$thread_cflag = -D_REENTRANT
|
||||
$sys_id =
|
||||
@@ -1924,7 +1924,7 @@ $multilib =
|
||||
|
||||
*** debug-levitte-linux-noasm-extreme
|
||||
$cc = gcc
|
||||
$cflags = -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 -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe
|
||||
$cflags = -DLEVITTE_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_DEBUG -DBN_DEBUG_RAND -DCRYPTO_MDEBUG -DENGINE_CONF_DEBUG -DOPENSSL_NO_ASM -DL_ENDIAN -DTERMIO -DPEDANTIC -ggdb -g3 -pedantic -ansi -Wall -W -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wundef -Wconversion -pipe
|
||||
$unistd =
|
||||
$thread_cflag = -D_REENTRANT
|
||||
$sys_id =
|
||||
@@ -4863,7 +4863,7 @@ $shared_target= solaris-shared
|
||||
$shared_cflag = -KPIC
|
||||
$shared_ldflag = -xarch=v9 -G -dy -z text
|
||||
$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
|
||||
$ranlib = /usr/ccs/bin/ar rs
|
||||
$ranlib =
|
||||
$arflags =
|
||||
$multilib = /64
|
||||
|
||||
|
@@ -2132,7 +2132,7 @@ X509_NAME *parse_name(char *subject, long chtype, int multirdn)
|
||||
X509_NAME *n = NULL;
|
||||
int nid;
|
||||
|
||||
if (!buf || !ne_types || !ne_values)
|
||||
if (!buf || !ne_types || !ne_values || !mval)
|
||||
{
|
||||
BIO_printf(bio_err, "malloc error\n");
|
||||
goto error;
|
||||
@@ -2236,6 +2236,7 @@ X509_NAME *parse_name(char *subject, long chtype, int multirdn)
|
||||
OPENSSL_free(ne_values);
|
||||
OPENSSL_free(ne_types);
|
||||
OPENSSL_free(buf);
|
||||
OPENSSL_free(mval);
|
||||
return n;
|
||||
|
||||
error:
|
||||
@@ -2244,6 +2245,8 @@ error:
|
||||
OPENSSL_free(ne_values);
|
||||
if (ne_types)
|
||||
OPENSSL_free(ne_types);
|
||||
if (mval)
|
||||
OPENSSL_free(mval);
|
||||
if (buf)
|
||||
OPENSSL_free(buf);
|
||||
return NULL;
|
||||
|
@@ -232,6 +232,8 @@ int MAIN(int argc, char **argv)
|
||||
else if (!strcmp(*args,"-camellia256"))
|
||||
cipher = EVP_camellia_256_cbc();
|
||||
#endif
|
||||
else if (!strcmp (*args, "-debug_decrypt"))
|
||||
flags |= CMS_DEBUG_DECRYPT;
|
||||
else if (!strcmp (*args, "-text"))
|
||||
flags |= CMS_TEXT;
|
||||
else if (!strcmp (*args, "-nointern"))
|
||||
@@ -1020,6 +1022,8 @@ int MAIN(int argc, char **argv)
|
||||
ret = 4;
|
||||
if (operation == SMIME_DECRYPT)
|
||||
{
|
||||
if (flags & CMS_DEBUG_DECRYPT)
|
||||
CMS_decrypt(cms, NULL, NULL, NULL, NULL, flags);
|
||||
|
||||
if (secret_key)
|
||||
{
|
||||
|
@@ -332,7 +332,6 @@ bad:
|
||||
BIO_printf(bio_err,"This is going to take a long time\n");
|
||||
if(!dh || !DH_generate_parameters_ex(dh, num, g, &cb))
|
||||
{
|
||||
if(dh) DH_free(dh);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
@@ -617,7 +617,7 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf (bio_err, "-ndays n number of days before next update\n");
|
||||
BIO_printf (bio_err, "-resp_key_id identify reponse by signing certificate key ID\n");
|
||||
BIO_printf (bio_err, "-nrequest n number of requests to accept (default unlimited)\n");
|
||||
BIO_printf (bio_err, "-<dgst alg> use specified digest in the request");
|
||||
BIO_printf (bio_err, "-<dgst alg> use specified digest in the request\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@@ -440,13 +440,7 @@ int MAIN(int argc, char **argv)
|
||||
char *jpake_secret = NULL;
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv23_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv3_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
meth=SSLv2_client_method();
|
||||
#endif
|
||||
|
||||
apps_startup();
|
||||
c_Pause=0;
|
||||
@@ -749,14 +743,13 @@ bad:
|
||||
goto end;
|
||||
}
|
||||
psk_identity = "JPAKE";
|
||||
if (cipher)
|
||||
{
|
||||
BIO_printf(bio_err, "JPAKE sets cipher to PSK\n");
|
||||
goto end;
|
||||
}
|
||||
cipher = "PSK";
|
||||
}
|
||||
|
||||
if (cipher)
|
||||
{
|
||||
BIO_printf(bio_err, "JPAKE sets cipher to PSK\n");
|
||||
goto end;
|
||||
}
|
||||
cipher = "PSK";
|
||||
#endif
|
||||
|
||||
OpenSSL_add_ssl_algorithms();
|
||||
@@ -1603,6 +1596,8 @@ end:
|
||||
EVP_PKEY_free(key);
|
||||
if (pass)
|
||||
OPENSSL_free(pass);
|
||||
if (vpm)
|
||||
X509_VERIFY_PARAM_free(vpm);
|
||||
if (cbuf != NULL) { OPENSSL_cleanse(cbuf,BUFSIZZ); OPENSSL_free(cbuf); }
|
||||
if (sbuf != NULL) { OPENSSL_cleanse(sbuf,BUFSIZZ); OPENSSL_free(sbuf); }
|
||||
if (mbuf != NULL) { OPENSSL_cleanse(mbuf,BUFSIZZ); OPENSSL_free(mbuf); }
|
||||
|
@@ -872,13 +872,7 @@ int MAIN(int argc, char *argv[])
|
||||
/* by default do not send a PSK identity hint */
|
||||
static char *psk_identity_hint=NULL;
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv23_server_method();
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv3_server_method();
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
meth=SSLv2_server_method();
|
||||
#endif
|
||||
|
||||
local_argc=argc;
|
||||
local_argv=argv;
|
||||
@@ -1715,7 +1709,15 @@ end:
|
||||
OPENSSL_free(pass);
|
||||
if (dpass)
|
||||
OPENSSL_free(dpass);
|
||||
if (vpm)
|
||||
X509_VERIFY_PARAM_free(vpm);
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
if (tlscstatp.host)
|
||||
OPENSSL_free(tlscstatp.host);
|
||||
if (tlscstatp.port)
|
||||
OPENSSL_free(tlscstatp.port);
|
||||
if (tlscstatp.path)
|
||||
OPENSSL_free(tlscstatp.path);
|
||||
if (ctx2 != NULL) SSL_CTX_free(ctx2);
|
||||
if (s_cert2)
|
||||
X509_free(s_cert2);
|
||||
|
6
config
6
config
@@ -825,9 +825,11 @@ esac
|
||||
# options="$options -DATALLA"
|
||||
#fi
|
||||
|
||||
($CC -Wa,--help -c -o /dev/null -x assembler /dev/null 2>&1 | \
|
||||
grep \\--noexecstack) 2>&1 > /dev/null && \
|
||||
if expr "$options" : '.*no\-asm' > /dev/null; then :; else
|
||||
sh -c "$CROSS_COMPILE${CC:-gcc} -Wa,--help -c -o /tmp/null.$$.o -x assembler /dev/null && rm /tmp/null.$$.o" 2>&1 | \
|
||||
grep \\--noexecstack >/dev/null && \
|
||||
options="$options -Wa,--noexecstack"
|
||||
fi
|
||||
|
||||
# gcc < 2.8 does not support -march=ultrasparc
|
||||
if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
|
||||
|
@@ -36,7 +36,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$verticalspin=1; # unlike 32-bit version $verticalspin performs
|
||||
# ~15% better on both AMD and Intel cores
|
||||
|
@@ -57,6 +57,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/asn1_mac.h>
|
||||
@@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
BUF_MEM *b;
|
||||
unsigned char *p;
|
||||
int i;
|
||||
int ret=-1;
|
||||
ASN1_const_CTX c;
|
||||
int want=HEADER_SIZE;
|
||||
size_t want=HEADER_SIZE;
|
||||
int eos=0;
|
||||
#if defined(__GNUC__) && defined(__ia64)
|
||||
/* pathetic compiler bug in all known versions as of Nov. 2002 */
|
||||
long off=0;
|
||||
#else
|
||||
int off=0;
|
||||
#endif
|
||||
int len=0;
|
||||
size_t off=0;
|
||||
size_t len=0;
|
||||
|
||||
b=BUF_MEM_new();
|
||||
if (b == NULL)
|
||||
@@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
{
|
||||
want-=(len-off);
|
||||
|
||||
if (!BUF_MEM_grow_clean(b,len+want))
|
||||
if (len + want < len || !BUF_MEM_grow_clean(b,len+want))
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
@@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
goto err;
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
if (len+i < len)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
len+=i;
|
||||
}
|
||||
}
|
||||
/* else data already loaded */
|
||||
|
||||
@@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
{
|
||||
/* no data body so go round again */
|
||||
eos++;
|
||||
if (eos < 0)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
want=HEADER_SIZE;
|
||||
}
|
||||
else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC))
|
||||
@@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
else
|
||||
{
|
||||
/* suck in c.slen bytes of data */
|
||||
want=(int)c.slen;
|
||||
want=c.slen;
|
||||
if (want > (len-off))
|
||||
{
|
||||
want-=(len-off);
|
||||
if (want > INT_MAX /* BIO_read takes an int length */ ||
|
||||
len+want < len)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
if (!BUF_MEM_grow_clean(b,len+want))
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
|
||||
@@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
ASN1_R_NOT_ENOUGH_DATA);
|
||||
goto err;
|
||||
}
|
||||
/* This can't overflow because
|
||||
* |len+want| didn't overflow. */
|
||||
len+=i;
|
||||
want -= i;
|
||||
want-=i;
|
||||
}
|
||||
}
|
||||
off+=(int)c.slen;
|
||||
if (off + c.slen < off)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
off+=c.slen;
|
||||
if (eos <= 0)
|
||||
{
|
||||
break;
|
||||
@@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
}
|
||||
}
|
||||
|
||||
if (off > INT_MAX)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
|
||||
*pb = b;
|
||||
return off;
|
||||
err:
|
||||
if (b != NULL) BUF_MEM_free(b);
|
||||
return(ret);
|
||||
return -1;
|
||||
}
|
||||
|
@@ -567,6 +567,7 @@ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
|
||||
if(mbflag == -1) return -1;
|
||||
mbflag |= MBSTRING_FLAG;
|
||||
stmp.data = NULL;
|
||||
stmp.length = 0;
|
||||
ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING);
|
||||
if(ret < 0) return ret;
|
||||
*out = stmp.data;
|
||||
|
@@ -136,6 +136,12 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ASN1_BIT_STRING *signat
|
||||
|
||||
int mdnid, pknid;
|
||||
|
||||
if (!pkey)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return -1;
|
||||
}
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
|
||||
/* Convert signature OID into digest and public key OIDs */
|
||||
|
@@ -446,11 +446,11 @@ static int asn1_print_fsname(BIO *out, int indent,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_print_boolean_ctx(BIO *out, const int bool,
|
||||
static int asn1_print_boolean_ctx(BIO *out, int boolval,
|
||||
const ASN1_PCTX *pctx)
|
||||
{
|
||||
const char *str;
|
||||
switch (bool)
|
||||
switch (boolval)
|
||||
{
|
||||
case -1:
|
||||
str = "BOOL ABSENT";
|
||||
@@ -574,10 +574,10 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
{
|
||||
case V_ASN1_BOOLEAN:
|
||||
{
|
||||
int bool = *(int *)fld;
|
||||
if (bool == -1)
|
||||
bool = it->size;
|
||||
ret = asn1_print_boolean_ctx(out, bool, pctx);
|
||||
int boolval = *(int *)fld;
|
||||
if (boolval == -1)
|
||||
boolval = it->size;
|
||||
ret = asn1_print_boolean_ctx(out, boolval, pctx);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@@ -175,12 +175,15 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
|
||||
if (key->pkey)
|
||||
{
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
|
||||
EVP_PKEY_free(ret);
|
||||
ret = key->pkey;
|
||||
}
|
||||
else
|
||||
{
|
||||
key->pkey = ret;
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
|
||||
}
|
||||
CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY);
|
||||
|
||||
return ret;
|
||||
|
@@ -960,7 +960,6 @@ int BIO_set_tcp_ndelay(int s, int on)
|
||||
#endif
|
||||
return(ret == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int BIO_socket_nbio(int s, int mode)
|
||||
{
|
||||
@@ -973,3 +972,4 @@ int BIO_socket_nbio(int s, int mode)
|
||||
#endif
|
||||
return(ret == 0);
|
||||
}
|
||||
#endif
|
||||
|
@@ -521,40 +521,40 @@ void BIO_free_all(BIO *bio)
|
||||
|
||||
BIO *BIO_dup_chain(BIO *in)
|
||||
{
|
||||
BIO *ret=NULL,*eoc=NULL,*bio,*new;
|
||||
BIO *ret=NULL,*eoc=NULL,*bio,*new_bio;
|
||||
|
||||
for (bio=in; bio != NULL; bio=bio->next_bio)
|
||||
{
|
||||
if ((new=BIO_new(bio->method)) == NULL) goto err;
|
||||
new->callback=bio->callback;
|
||||
new->cb_arg=bio->cb_arg;
|
||||
new->init=bio->init;
|
||||
new->shutdown=bio->shutdown;
|
||||
new->flags=bio->flags;
|
||||
if ((new_bio=BIO_new(bio->method)) == NULL) goto err;
|
||||
new_bio->callback=bio->callback;
|
||||
new_bio->cb_arg=bio->cb_arg;
|
||||
new_bio->init=bio->init;
|
||||
new_bio->shutdown=bio->shutdown;
|
||||
new_bio->flags=bio->flags;
|
||||
|
||||
/* This will let SSL_s_sock() work with stdin/stdout */
|
||||
new->num=bio->num;
|
||||
new_bio->num=bio->num;
|
||||
|
||||
if (!BIO_dup_state(bio,(char *)new))
|
||||
if (!BIO_dup_state(bio,(char *)new_bio))
|
||||
{
|
||||
BIO_free(new);
|
||||
BIO_free(new_bio);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* copy app data */
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new->ex_data,
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new_bio->ex_data,
|
||||
&bio->ex_data))
|
||||
goto err;
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
eoc=new;
|
||||
eoc=new_bio;
|
||||
ret=eoc;
|
||||
}
|
||||
else
|
||||
{
|
||||
BIO_push(eoc,new);
|
||||
eoc=new;
|
||||
BIO_push(eoc,new_bio);
|
||||
eoc=new_bio;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
|
@@ -186,7 +186,7 @@ static void dgram_adjust_rcv_timeout(BIO *b)
|
||||
{
|
||||
#if defined(SO_RCVTIMEO)
|
||||
bio_dgram_data *data = (bio_dgram_data *)b->ptr;
|
||||
int sz = sizeof(int);
|
||||
union { size_t s; int i; } sz = {0};
|
||||
|
||||
/* Is a timer active? */
|
||||
if (data->next_timeout.tv_sec > 0 || data->next_timeout.tv_usec > 0)
|
||||
@@ -196,8 +196,10 @@ static void dgram_adjust_rcv_timeout(BIO *b)
|
||||
/* Read current socket timeout */
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
int timeout;
|
||||
|
||||
sz.i = sizeof(timeout);
|
||||
if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
|
||||
(void*)&timeout, &sz) < 0)
|
||||
(void*)&timeout, &sz.i) < 0)
|
||||
{ perror("getsockopt"); }
|
||||
else
|
||||
{
|
||||
@@ -205,9 +207,12 @@ static void dgram_adjust_rcv_timeout(BIO *b)
|
||||
data->socket_timeout.tv_usec = (timeout % 1000) * 1000;
|
||||
}
|
||||
#else
|
||||
sz.i = sizeof(data->socket_timeout);
|
||||
if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
|
||||
&(data->socket_timeout), (void *)&sz) < 0)
|
||||
{ perror("getsockopt"); }
|
||||
else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
|
||||
OPENSSL_assert(sz.s<=sizeof(data->socket_timeout));
|
||||
#endif
|
||||
|
||||
/* Get current time */
|
||||
@@ -376,11 +381,10 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
int *ip;
|
||||
struct sockaddr *to = NULL;
|
||||
bio_dgram_data *data = NULL;
|
||||
#if defined(IP_MTU_DISCOVER) || defined(IP_MTU)
|
||||
long sockopt_val = 0;
|
||||
unsigned int sockopt_len = 0;
|
||||
#endif
|
||||
#ifdef OPENSSL_SYS_LINUX
|
||||
#if defined(OPENSSL_SYS_LINUX) && (defined(IP_MTU_DISCOVER) || defined(IP_MTU))
|
||||
int sockopt_val = 0;
|
||||
socklen_t sockopt_len; /* assume that system supporting IP_MTU is
|
||||
* modern enough to define socklen_t */
|
||||
socklen_t addr_len;
|
||||
union {
|
||||
struct sockaddr sa;
|
||||
@@ -462,7 +466,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
break;
|
||||
/* (Linux)kernel sets DF bit on outgoing IP packets */
|
||||
case BIO_CTRL_DGRAM_MTU_DISCOVER:
|
||||
#ifdef OPENSSL_SYS_LINUX
|
||||
#if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO)
|
||||
addr_len = (socklen_t)sizeof(addr);
|
||||
memset((void *)&addr, 0, sizeof(addr));
|
||||
if (getsockname(b->num, &addr.sa, &addr_len) < 0)
|
||||
@@ -470,7 +474,6 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
sockopt_len = sizeof(sockopt_val);
|
||||
switch (addr.sa.sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
@@ -479,7 +482,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
&sockopt_val, sizeof(sockopt_val))) < 0)
|
||||
perror("setsockopt");
|
||||
break;
|
||||
#if OPENSSL_USE_IPV6 && defined(IPV6_MTU_DISCOVER)
|
||||
#if OPENSSL_USE_IPV6 && defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO)
|
||||
case AF_INET6:
|
||||
sockopt_val = IPV6_PMTUDISC_DO;
|
||||
if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
|
||||
@@ -496,7 +499,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
break;
|
||||
#endif
|
||||
case BIO_CTRL_DGRAM_QUERY_MTU:
|
||||
#ifdef OPENSSL_SYS_LINUX
|
||||
#if defined(OPENSSL_SYS_LINUX) && defined(IP_MTU)
|
||||
addr_len = (socklen_t)sizeof(addr);
|
||||
memset((void *)&addr, 0, sizeof(addr));
|
||||
if (getsockname(b->num, &addr.sa, &addr_len) < 0)
|
||||
@@ -658,12 +661,15 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
#endif
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT:
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
{
|
||||
int timeout, sz = sizeof(timeout);
|
||||
union { size_t s; int i; } sz = {0};
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
int timeout;
|
||||
struct timeval *tv = (struct timeval *)ptr;
|
||||
|
||||
sz.i = sizeof(timeout);
|
||||
if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
|
||||
(void*)&timeout, &sz) < 0)
|
||||
(void*)&timeout, &sz.i) < 0)
|
||||
{ perror("getsockopt"); ret = -1; }
|
||||
else
|
||||
{
|
||||
@@ -671,12 +677,20 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
tv->tv_usec = (timeout % 1000) * 1000;
|
||||
ret = sizeof(*tv);
|
||||
}
|
||||
}
|
||||
#else
|
||||
sz.i = sizeof(struct timeval);
|
||||
if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
|
||||
ptr, (void *)&ret) < 0)
|
||||
ptr, (void *)&sz) < 0)
|
||||
{ perror("getsockopt"); ret = -1; }
|
||||
else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
|
||||
{
|
||||
OPENSSL_assert(sz.s<=sizeof(struct timeval));
|
||||
ret = (int)sz.s;
|
||||
}
|
||||
else
|
||||
ret = sz.i;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined(SO_SNDTIMEO)
|
||||
@@ -696,12 +710,15 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
#endif
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT:
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
{
|
||||
int timeout, sz = sizeof(timeout);
|
||||
union { size_t s; int i; } sz = {0};
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
int timeout;
|
||||
struct timeval *tv = (struct timeval *)ptr;
|
||||
|
||||
sz.i = sizeof(timeout);
|
||||
if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
|
||||
(void*)&timeout, &sz) < 0)
|
||||
(void*)&timeout, &sz.i) < 0)
|
||||
{ perror("getsockopt"); ret = -1; }
|
||||
else
|
||||
{
|
||||
@@ -709,12 +726,20 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
tv->tv_usec = (timeout % 1000) * 1000;
|
||||
ret = sizeof(*tv);
|
||||
}
|
||||
}
|
||||
#else
|
||||
sz.i = sizeof(struct timeval);
|
||||
if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
|
||||
ptr, (void *)&ret) < 0)
|
||||
ptr, (void *)&sz) < 0)
|
||||
{ perror("getsockopt"); ret = -1; }
|
||||
else if (sizeof(sz.s)!=sizeof(sz.i) && sz.i==0)
|
||||
{
|
||||
OPENSSL_assert(sz.s<=sizeof(struct timeval));
|
||||
ret = (int)sz.s;
|
||||
}
|
||||
else
|
||||
ret = sz.i;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP:
|
||||
|
@@ -26,7 +26,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
# int bn_mul_mont(
|
||||
$rp="%rdi"; # BN_ULONG *rp,
|
||||
|
@@ -144,26 +144,17 @@ int BN_add_word(BIGNUM *a, BN_ULONG w)
|
||||
a->neg=!(a->neg);
|
||||
return(i);
|
||||
}
|
||||
/* Only expand (and risk failing) if it's possibly necessary */
|
||||
if (((BN_ULONG)(a->d[a->top - 1] + 1) == 0) &&
|
||||
(bn_wexpand(a,a->top+1) == NULL))
|
||||
return(0);
|
||||
i=0;
|
||||
for (;;)
|
||||
for (i=0;w!=0 && i<a->top;i++)
|
||||
{
|
||||
if (i >= a->top)
|
||||
l=w;
|
||||
else
|
||||
l=(a->d[i]+w)&BN_MASK2;
|
||||
a->d[i]=l;
|
||||
if (w > l)
|
||||
w=1;
|
||||
else
|
||||
break;
|
||||
i++;
|
||||
a->d[i] = l = (a->d[i]+w)&BN_MASK2;
|
||||
w = (w>l)?1:0;
|
||||
}
|
||||
if (i >= a->top)
|
||||
if (w && i==a->top)
|
||||
{
|
||||
if (bn_wexpand(a,a->top+1) == NULL) return 0;
|
||||
a->top++;
|
||||
a->d[i]=w;
|
||||
}
|
||||
bn_check_top(a);
|
||||
return(1);
|
||||
}
|
||||
|
@@ -60,6 +60,11 @@
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
|
||||
/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That
|
||||
* function is applied in several functions in this file and this limit ensures
|
||||
* that the result fits in an int. */
|
||||
#define LIMIT_BEFORE_EXPANSION 0x5ffffffc
|
||||
|
||||
BUF_MEM *BUF_MEM_new(void)
|
||||
{
|
||||
BUF_MEM *ret;
|
||||
@@ -105,6 +110,12 @@ int BUF_MEM_grow(BUF_MEM *str, size_t len)
|
||||
str->length=len;
|
||||
return(len);
|
||||
}
|
||||
/* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */
|
||||
if (len > LIMIT_BEFORE_EXPANSION)
|
||||
{
|
||||
BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
n=(len+3)/3*4;
|
||||
if (str->data == NULL)
|
||||
ret=OPENSSL_malloc(n);
|
||||
@@ -142,6 +153,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, size_t len)
|
||||
str->length=len;
|
||||
return(len);
|
||||
}
|
||||
/* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */
|
||||
if (len > LIMIT_BEFORE_EXPANSION)
|
||||
{
|
||||
BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
n=(len+3)/3*4;
|
||||
if (str->data == NULL)
|
||||
ret=OPENSSL_malloc(n);
|
||||
|
@@ -40,7 +40,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
sub hi() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1h/; $r; }
|
||||
sub lo() { my $r=shift; $r =~ s/%[er]([a-d])x/%\1l/;
|
||||
|
@@ -58,7 +58,9 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/cms.h>
|
||||
#include <openssl/bio.h>
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
#include <openssl/comp.h>
|
||||
#endif
|
||||
#include "cms_lcl.h"
|
||||
|
||||
DECLARE_ASN1_ITEM(CMS_CompressedData)
|
||||
|
@@ -74,7 +74,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
||||
X509_ALGOR *calg = ec->contentEncryptionAlgorithm;
|
||||
unsigned char iv[EVP_MAX_IV_LENGTH], *piv = NULL;
|
||||
unsigned char *tkey = NULL;
|
||||
size_t tkeylen;
|
||||
size_t tkeylen = 0;
|
||||
|
||||
int ok = 0;
|
||||
|
||||
@@ -139,10 +139,10 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
||||
CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
tkeylen = EVP_CIPHER_CTX_key_length(ctx);
|
||||
/* Generate random session key */
|
||||
if (!enc || !ec->key)
|
||||
{
|
||||
tkeylen = EVP_CIPHER_CTX_key_length(ctx);
|
||||
tkey = OPENSSL_malloc(tkeylen);
|
||||
if (!tkey)
|
||||
{
|
||||
@@ -174,7 +174,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
||||
/* Only reveal failure if debugging so we don't
|
||||
* leak information which may be useful in MMA.
|
||||
*/
|
||||
if (ec->debug)
|
||||
if (enc || ec->debug)
|
||||
{
|
||||
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
|
||||
CMS_R_INVALID_KEY_LENGTH);
|
||||
|
@@ -500,7 +500,7 @@ void CRYPTO_THREADID_current(CRYPTO_THREADID *id)
|
||||
CRYPTO_THREADID_set_numeric(id, (unsigned long)find_thread(NULL));
|
||||
#else
|
||||
/* For everything else, default to using the address of 'errno' */
|
||||
CRYPTO_THREADID_set_pointer(id, &errno);
|
||||
CRYPTO_THREADID_set_pointer(id, (void*)&errno);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -896,3 +896,16 @@ void OpenSSLDie(const char *file,int line,const char *assertion)
|
||||
}
|
||||
|
||||
void *OPENSSL_stderr(void) { return stderr; }
|
||||
|
||||
int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
const unsigned char *a = in_a;
|
||||
const unsigned char *b = in_b;
|
||||
unsigned char x = 0;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
x |= a[i] ^ b[i];
|
||||
|
||||
return x;
|
||||
}
|
||||
|
@@ -117,7 +117,7 @@ $ ENCRYPT_TYPES = "Basic,"+ -
|
||||
"BUFFER,BIO,STACK,LHASH,RAND,ERR,"+ -
|
||||
"EVP,EVP_2,EVP_3,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
|
||||
"CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5,"+ -
|
||||
"STORE,CMS,PQUEUE,TS,JPAKE"
|
||||
"CMS,PQUEUE,TS,JPAKE,STORE"
|
||||
$!
|
||||
$! Check To Make Sure We Have Valid Command Line Parameters.
|
||||
$!
|
||||
@@ -1021,7 +1021,7 @@ $!
|
||||
$! Set basic C compiler /INCLUDE directories.
|
||||
$!
|
||||
$ CC_INCLUDES = "SYS$DISK:[.''ARCHD'],SYS$DISK:[],SYS$DISK:[-],"+ -
|
||||
"SYS$DISK:[.ENGINE.VENDOR_DEFNS],SYS$DISK:[.EVP],SYS$DISK:[.ASN1]"
|
||||
"SYS$DISK:[.ENGINE.VENDOR_DEFNS],SYS$DISK:[.ASN1],SYS$DISK:[.EVP]"
|
||||
$!
|
||||
$! Check To See If P3 Is Blank.
|
||||
$!
|
||||
|
@@ -547,6 +547,13 @@ unsigned long *OPENSSL_ia32cap_loc(void);
|
||||
#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
|
||||
int OPENSSL_isservice(void);
|
||||
|
||||
/* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. It
|
||||
* takes an amount of time dependent on |len|, but independent of the contents
|
||||
* of |a| and |b|. Unlike memcmp, it cannot be used to put elements into a
|
||||
* defined order as the return value when a != b is undefined, other than to be
|
||||
* non-zero. */
|
||||
int CRYPTO_memcmp(const void *a, const void *b, size_t len);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
|
@@ -774,7 +774,15 @@ void EC_KEY_set_conv_form(EC_KEY *, point_conversion_form_t);
|
||||
/* functions to set/get method specific data */
|
||||
void *EC_KEY_get_key_method_data(EC_KEY *,
|
||||
void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
|
||||
void EC_KEY_insert_key_method_data(EC_KEY *, void *data,
|
||||
/** Sets the key method data of an EC_KEY object, if none has yet been set.
|
||||
* \param key EC_KEY object
|
||||
* \param data opaque data to install.
|
||||
* \param dup_func a function that duplicates |data|.
|
||||
* \param free_func a function that frees |data|.
|
||||
* \param clear_free_func a function that wipes and frees |data|.
|
||||
* \return the previously set data pointer, or NULL if |data| was inserted.
|
||||
*/
|
||||
void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
|
||||
void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
|
||||
/* wrapper functions for the underlying EC_GROUP object */
|
||||
void EC_KEY_set_asn1_flag(EC_KEY *, int);
|
||||
|
@@ -435,18 +435,27 @@ void EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform)
|
||||
void *EC_KEY_get_key_method_data(EC_KEY *key,
|
||||
void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *))
|
||||
{
|
||||
return EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func);
|
||||
void *ret;
|
||||
|
||||
CRYPTO_r_lock(CRYPTO_LOCK_EC);
|
||||
ret = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func);
|
||||
CRYPTO_r_unlock(CRYPTO_LOCK_EC);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
|
||||
void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
|
||||
void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *))
|
||||
{
|
||||
EC_EXTRA_DATA *ex_data;
|
||||
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_EC);
|
||||
ex_data = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func);
|
||||
if (ex_data == NULL)
|
||||
EC_EX_DATA_set_data(&key->method_data, data, dup_func, free_func, clear_free_func);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_EC);
|
||||
|
||||
return ex_data;
|
||||
}
|
||||
|
||||
void EC_KEY_set_asn1_flag(EC_KEY *key, int flag)
|
||||
|
@@ -210,8 +210,15 @@ ECDH_DATA *ecdh_check(EC_KEY *key)
|
||||
ecdh_data = (ECDH_DATA *)ecdh_data_new();
|
||||
if (ecdh_data == NULL)
|
||||
return NULL;
|
||||
EC_KEY_insert_key_method_data(key, (void *)ecdh_data,
|
||||
ecdh_data_dup, ecdh_data_free, ecdh_data_free);
|
||||
data = EC_KEY_insert_key_method_data(key, (void *)ecdh_data,
|
||||
ecdh_data_dup, ecdh_data_free, ecdh_data_free);
|
||||
if (data != NULL)
|
||||
{
|
||||
/* Another thread raced us to install the key_method
|
||||
* data and won. */
|
||||
ecdh_data_free(ecdh_data);
|
||||
ecdh_data = (ECDH_DATA *)data;
|
||||
}
|
||||
}
|
||||
else
|
||||
ecdh_data = (ECDH_DATA *)data;
|
||||
|
@@ -188,8 +188,15 @@ ECDSA_DATA *ecdsa_check(EC_KEY *key)
|
||||
ecdsa_data = (ECDSA_DATA *)ecdsa_data_new();
|
||||
if (ecdsa_data == NULL)
|
||||
return NULL;
|
||||
EC_KEY_insert_key_method_data(key, (void *)ecdsa_data,
|
||||
ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free);
|
||||
data = EC_KEY_insert_key_method_data(key, (void *)ecdsa_data,
|
||||
ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free);
|
||||
if (data != NULL)
|
||||
{
|
||||
/* Another thread raced us to install the key_method
|
||||
* data and won. */
|
||||
ecdsa_data_free(ecdsa_data);
|
||||
ecdsa_data = (ECDSA_DATA *)data;
|
||||
}
|
||||
}
|
||||
else
|
||||
ecdsa_data = (ECDSA_DATA *)data;
|
||||
|
@@ -64,7 +64,9 @@
|
||||
#endif
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/bio.h>
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
#include <openssl/comp.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
#include <openssl/rsa.h>
|
||||
#endif
|
||||
@@ -102,7 +104,6 @@
|
||||
#ifndef OPENSSL_NO_JPAKE
|
||||
#include <openssl/jpake.h>
|
||||
#endif
|
||||
#include <openssl/comp.h>
|
||||
|
||||
void ERR_load_crypto_strings(void)
|
||||
{
|
||||
@@ -126,7 +127,9 @@ void ERR_load_crypto_strings(void)
|
||||
ERR_load_ASN1_strings();
|
||||
ERR_load_CONF_strings();
|
||||
ERR_load_CRYPTO_strings();
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
ERR_load_COMP_strings();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ERR_load_EC_strings();
|
||||
#endif
|
||||
@@ -155,6 +158,5 @@ void ERR_load_crypto_strings(void)
|
||||
#ifndef OPENSSL_NO_JPAKE
|
||||
ERR_load_JPAKE_strings();
|
||||
#endif
|
||||
ERR_load_COMP_strings();
|
||||
#endif
|
||||
}
|
||||
|
@@ -120,7 +120,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; my $dir=$1; my $xlate;
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
no warnings qw(uninitialized);
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$code .= <<EOF;
|
||||
.text
|
||||
|
@@ -361,6 +361,10 @@ void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
/* We don't support shrinking the buffer. Note the memcpy that copies
|
||||
* |old_len| bytes to the new buffer, below. */
|
||||
if (num < old_len) return NULL;
|
||||
|
||||
if (realloc_debug_func != NULL)
|
||||
realloc_debug_func(str, NULL, num, file, line, 0);
|
||||
ret=malloc_ex_func(num,file,line);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* AUTOGENERATED BY objxref.pl, DO NOT EDIT */
|
||||
/* AUTOGENERATED BY crypto/objects/objxref.pl, DO NOT EDIT */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@@ -91,9 +91,12 @@ int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
|
||||
{
|
||||
EVP_PKEY *skey;
|
||||
skey = X509_get_pubkey(signer);
|
||||
ret = OCSP_BASICRESP_verify(bs, skey, 0);
|
||||
EVP_PKEY_free(skey);
|
||||
if(ret <= 0)
|
||||
if (skey)
|
||||
{
|
||||
ret = OCSP_BASICRESP_verify(bs, skey, 0);
|
||||
EVP_PKEY_free(skey);
|
||||
}
|
||||
if(!skey || ret <= 0)
|
||||
{
|
||||
OCSPerr(OCSP_F_OCSP_BASIC_VERIFY, OCSP_R_SIGNATURE_FAILURE);
|
||||
goto end;
|
||||
@@ -108,6 +111,7 @@ int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
|
||||
init_res = X509_STORE_CTX_init(&ctx, st, signer, bs->certs);
|
||||
if(!init_res)
|
||||
{
|
||||
ret = -1;
|
||||
OCSPerr(OCSP_F_OCSP_BASIC_VERIFY,ERR_R_X509_LIB);
|
||||
goto end;
|
||||
}
|
||||
|
@@ -25,11 +25,11 @@
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
#define OPENSSL_VERSION_NUMBER 0x1000008fL
|
||||
#define OPENSSL_VERSION_NUMBER 0x100000bfL
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0h-fips 12 Mar 2012"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0k-fips 5 Feb 2013"
|
||||
#else
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0h 12 Mar 2012"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0k 5 Feb 2013"
|
||||
#endif
|
||||
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
|
@@ -62,12 +62,8 @@ my $flavour = shift;
|
||||
my $output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
|
||||
{ my ($stddev,$stdino,@junk)=stat(STDOUT);
|
||||
my ($outdev,$outino,@junk)=stat($output);
|
||||
|
||||
open STDOUT,">$output" || die "can't open $output: $!"
|
||||
if ($stddev!=$outdev || $stdino!=$outino);
|
||||
}
|
||||
open STDOUT,">$output" || die "can't open $output: $!"
|
||||
if (defined($output));
|
||||
|
||||
my $gas=1; $gas=0 if ($output =~ /\.asm$/);
|
||||
my $elf=1; $elf=0 if (!$gas);
|
||||
|
@@ -430,6 +430,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
STACK_OF(X509_ALGOR) *md_sk=NULL;
|
||||
STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL;
|
||||
PKCS7_RECIP_INFO *ri=NULL;
|
||||
unsigned char *ek = NULL, *tkey = NULL;
|
||||
int eklen = 0, tkeylen = 0;
|
||||
|
||||
i=OBJ_obj2nid(p7->type);
|
||||
p7->state=PKCS7_S_HEADER;
|
||||
@@ -507,8 +509,6 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
int max;
|
||||
X509_OBJECT ret;
|
||||
#endif
|
||||
unsigned char *ek = NULL, *tkey = NULL;
|
||||
int eklen, tkeylen;
|
||||
|
||||
if ((etmp=BIO_new(BIO_f_cipher())) == NULL)
|
||||
{
|
||||
@@ -609,11 +609,13 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
{
|
||||
OPENSSL_cleanse(ek,eklen);
|
||||
OPENSSL_free(ek);
|
||||
ek = NULL;
|
||||
}
|
||||
if (tkey)
|
||||
{
|
||||
OPENSSL_cleanse(tkey,tkeylen);
|
||||
OPENSSL_free(tkey);
|
||||
tkey = NULL;
|
||||
}
|
||||
|
||||
if (out == NULL)
|
||||
@@ -656,6 +658,16 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
if (0)
|
||||
{
|
||||
err:
|
||||
if (ek)
|
||||
{
|
||||
OPENSSL_cleanse(ek,eklen);
|
||||
OPENSSL_free(ek);
|
||||
}
|
||||
if (tkey)
|
||||
{
|
||||
OPENSSL_cleanse(tkey,tkeylen);
|
||||
OPENSSL_free(tkey);
|
||||
}
|
||||
if (out != NULL) BIO_free_all(out);
|
||||
if (btmp != NULL) BIO_free_all(btmp);
|
||||
if (etmp != NULL) BIO_free_all(etmp);
|
||||
|
@@ -72,7 +72,7 @@ Loop: lwarx r5,0,r3
|
||||
Little: mtctr r4
|
||||
stb r0,0(r3)
|
||||
addi r3,r3,1
|
||||
bdnz- \$-8
|
||||
bdnz \$-8
|
||||
blr
|
||||
Lot: andi. r5,r3,3
|
||||
beq Laligned
|
||||
@@ -85,7 +85,7 @@ Laligned:
|
||||
mtctr r5
|
||||
stw r0,0(r3)
|
||||
addi r3,r3,4
|
||||
bdnz- \$-8
|
||||
bdnz \$-8
|
||||
andi. r4,r4,3
|
||||
bne Little
|
||||
blr
|
||||
|
@@ -69,7 +69,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$dat="%rdi"; # arg1
|
||||
$len="%rsi"; # arg2
|
||||
|
@@ -147,7 +147,7 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
|
||||
|
||||
EVP_Digest((void *)param, plen, phash, NULL, EVP_sha1(), NULL);
|
||||
|
||||
if (memcmp(db, phash, SHA_DIGEST_LENGTH) != 0 || bad)
|
||||
if (CRYPTO_memcmp(db, phash, SHA_DIGEST_LENGTH) != 0 || bad)
|
||||
goto decoding_err;
|
||||
else
|
||||
{
|
||||
|
@@ -161,6 +161,7 @@ for($i=0;$i<5;$i++) {
|
||||
$code.=<<___;
|
||||
teq $Xi,sp
|
||||
bne .L_00_15 @ [((11+4)*5+2)*3]
|
||||
sub sp,sp,#25*4
|
||||
___
|
||||
&BODY_00_15(@V); unshift(@V,pop(@V));
|
||||
&BODY_16_19(@V); unshift(@V,pop(@V));
|
||||
@@ -170,7 +171,6 @@ ___
|
||||
$code.=<<___;
|
||||
|
||||
ldr $K,.LK_20_39 @ [+15+16*4]
|
||||
sub sp,sp,#25*4
|
||||
cmn sp,#0 @ [+3], clear carry to denote 20_39
|
||||
.L_20_39_or_60_79:
|
||||
___
|
||||
|
@@ -40,7 +40,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$ctx="%rdi"; # 1st arg
|
||||
$inp="%rsi"; # 2nd arg
|
||||
|
@@ -51,7 +51,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
if ($output =~ /512/) {
|
||||
$func="sha512_block_data_order";
|
||||
|
@@ -2056,31 +2056,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)
|
||||
#define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st))
|
||||
|
||||
|
||||
#define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
|
||||
#define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())
|
||||
#define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i))
|
||||
#define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st)
|
||||
#define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_FREE_FUNC2(OPENSSL_PSTRING, free_func))
|
||||
#define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val), i)
|
||||
#define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st)
|
||||
#define sk_OPENSSL_PSTRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i, CHECKED_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st))
|
||||
#define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i))
|
||||
#define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, ptr))
|
||||
#define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp) \
|
||||
((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \
|
||||
sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
|
||||
#define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st)
|
||||
#define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st))
|
||||
#define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop(CHECKED_STACK_OF(OPENSSL_PSTRING, st))
|
||||
#define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st))
|
||||
#define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))
|
||||
|
||||
|
||||
#define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))
|
||||
#define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())
|
||||
#define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))
|
||||
@@ -2106,6 +2081,31 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)
|
||||
#define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))
|
||||
|
||||
|
||||
#define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
|
||||
#define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())
|
||||
#define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i))
|
||||
#define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st)
|
||||
#define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_FREE_FUNC2(OPENSSL_PSTRING, free_func))
|
||||
#define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val), i)
|
||||
#define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st)
|
||||
#define sk_OPENSSL_PSTRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i, CHECKED_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st))
|
||||
#define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val))
|
||||
#define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i))
|
||||
#define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, ptr))
|
||||
#define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp) \
|
||||
((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \
|
||||
sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))
|
||||
#define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st)
|
||||
#define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st))
|
||||
#define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop(CHECKED_STACK_OF(OPENSSL_PSTRING, st))
|
||||
#define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st))
|
||||
#define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))
|
||||
|
||||
|
||||
#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \
|
||||
SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
|
||||
#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \
|
||||
|
@@ -294,8 +294,6 @@
|
||||
#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf
|
||||
#undef ec_GFp_simple_points_make_affine
|
||||
#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine
|
||||
#undef ec_GFp_simple_group_get_curve_GFp
|
||||
#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp
|
||||
#undef ec_GFp_simple_set_Jprojective_coordinates_GFp
|
||||
#define ec_GFp_simple_set_Jprojective_coordinates_GFp \
|
||||
ec_GFp_smp_set_Jproj_coords_GFp
|
||||
|
@@ -41,7 +41,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; my $dir=$1; my $xlate;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
sub L() { $code.=".byte ".join(',',@_)."\n"; }
|
||||
sub LL(){ $code.=".byte ".join(',',@_).",".join(',',@_)."\n"; }
|
||||
|
@@ -87,7 +87,7 @@ void X509_LOOKUP_free(X509_LOOKUP *ctx)
|
||||
if (ctx == NULL) return;
|
||||
if ( (ctx->method != NULL) &&
|
||||
(ctx->method->free != NULL))
|
||||
ctx->method->free(ctx);
|
||||
(*ctx->method->free)(ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
|
@@ -872,7 +872,7 @@ static int crl_extension_match(X509_CRL *a, X509_CRL *b, int nid)
|
||||
{
|
||||
ASN1_OCTET_STRING *exta, *extb;
|
||||
int i;
|
||||
i = X509_CRL_get_ext_by_NID(a, nid, 0);
|
||||
i = X509_CRL_get_ext_by_NID(a, nid, -1);
|
||||
if (i >= 0)
|
||||
{
|
||||
/* Can't have multiple occurrences */
|
||||
@@ -883,7 +883,7 @@ static int crl_extension_match(X509_CRL *a, X509_CRL *b, int nid)
|
||||
else
|
||||
exta = NULL;
|
||||
|
||||
i = X509_CRL_get_ext_by_NID(b, nid, 0);
|
||||
i = X509_CRL_get_ext_by_NID(b, nid, -1);
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
|
@@ -474,11 +474,11 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
for (i = 0; i < X509_get_ext_count(x); i++)
|
||||
{
|
||||
ex = X509_get_ext(x, i);
|
||||
if (!X509_EXTENSION_get_critical(ex))
|
||||
continue;
|
||||
if (OBJ_obj2nid(X509_EXTENSION_get_object(ex))
|
||||
== NID_freshest_crl)
|
||||
x->ex_flags |= EXFLAG_FRESHEST;
|
||||
if (!X509_EXTENSION_get_critical(ex))
|
||||
continue;
|
||||
if (!X509_supported_extension(ex))
|
||||
{
|
||||
x->ex_flags |= EXFLAG_CRITICAL;
|
||||
|
@@ -7,7 +7,8 @@ if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
open STDOUT,"| $^X ${dir}perlasm/x86_64-xlate.pl $flavour $output";
|
||||
open OUT,"| \"$^X\" ${dir}perlasm/x86_64-xlate.pl $flavour $output";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
if ($win64) { $arg1="%rcx"; $arg2="%rdx"; }
|
||||
else { $arg1="%rdi"; $arg2="%rsi"; }
|
||||
|
@@ -57,7 +57,7 @@ following methods:
|
||||
|
||||
- in all other cases, proxy certificate validation can be enabled
|
||||
before starting the application by setting the envirnoment variable
|
||||
OPENSSL_ALLOW_PROXY with some non-empty value.
|
||||
OPENSSL_ALLOW_PROXY_CERTS with some non-empty value.
|
||||
|
||||
There are thoughts to allow proxy certificates with a line in the
|
||||
default openssl.cnf, but that's still in the future.
|
||||
|
@@ -39,13 +39,13 @@ prints a usage message.
|
||||
|
||||
=item B<-newcert>
|
||||
|
||||
creates a new self signed certificate. The private key and certificate are
|
||||
written to the file "newreq.pem".
|
||||
creates a new self signed certificate. The private key is written to the file
|
||||
"newkey.pem" and the request written to the file "newreq.pem".
|
||||
|
||||
=item B<-newreq>
|
||||
|
||||
creates a new certificate request. The private key and request are
|
||||
written to the file "newreq.pem".
|
||||
creates a new certificate request. The private key is written to the file
|
||||
"newkey.pem" and the request written to the file "newreq.pem".
|
||||
|
||||
=item B<-newreq-nodes>
|
||||
|
||||
|
@@ -6,7 +6,8 @@ EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_DigestInit_ex, EVP_DigestUpdate,
|
||||
EVP_DigestFinal_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_MAX_MD_SIZE,
|
||||
EVP_MD_CTX_copy_ex, EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size,
|
||||
EVP_MD_block_size, EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type,
|
||||
EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2,
|
||||
EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_sha224, EVP_sha256,
|
||||
EVP_sha384, EVP_sha512, EVP_dss, EVP_dss1, EVP_mdc2,
|
||||
EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj -
|
||||
EVP digest routines
|
||||
|
||||
@@ -33,16 +34,15 @@ EVP digest routines
|
||||
|
||||
int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in);
|
||||
|
||||
#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
|
||||
#define EVP_MAX_MD_SIZE 64 /* SHA512 */
|
||||
|
||||
int EVP_MD_type(const EVP_MD *md);
|
||||
int EVP_MD_pkey_type(const EVP_MD *md);
|
||||
int EVP_MD_size(const EVP_MD *md);
|
||||
int EVP_MD_block_size(const EVP_MD *md);
|
||||
|
||||
#define EVP_MD_type(e) ((e)->type)
|
||||
#define EVP_MD_pkey_type(e) ((e)->pkey_type)
|
||||
#define EVP_MD_size(e) ((e)->md_size)
|
||||
#define EVP_MD_block_size(e) ((e)->block_size)
|
||||
|
||||
#define EVP_MD_CTX_md(e) (e)->digest)
|
||||
#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
|
||||
const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
|
||||
#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
|
||||
#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
|
||||
#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
|
||||
|
||||
@@ -56,6 +56,11 @@ EVP digest routines
|
||||
const EVP_MD *EVP_mdc2(void);
|
||||
const EVP_MD *EVP_ripemd160(void);
|
||||
|
||||
const EVP_MD *EVP_sha224(void);
|
||||
const EVP_MD *EVP_sha256(void);
|
||||
const EVP_MD *EVP_sha384(void);
|
||||
const EVP_MD *EVP_sha512(void);
|
||||
|
||||
const EVP_MD *EVP_get_digestbyname(const char *name);
|
||||
#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
|
||||
#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
|
||||
@@ -124,12 +129,14 @@ B<EVP_MD_CTX>.
|
||||
|
||||
EVP_MD_pkey_type() returns the NID of the public key signing algorithm associated
|
||||
with this digest. For example EVP_sha1() is associated with RSA so this will
|
||||
return B<NID_sha1WithRSAEncryption>. This "link" between digests and signature
|
||||
algorithms may not be retained in future versions of OpenSSL.
|
||||
return B<NID_sha1WithRSAEncryption>. Since digests and signature algorithms
|
||||
are no longer linked this function is only retained for compatibility
|
||||
reasons.
|
||||
|
||||
EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_mdc2() and EVP_ripemd160()
|
||||
return B<EVP_MD> structures for the MD2, MD5, SHA, SHA1, MDC2 and RIPEMD160 digest
|
||||
algorithms respectively. The associated signature algorithm is RSA in each case.
|
||||
EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_sha224(), EVP_sha256(),
|
||||
EVP_sha384(), EVP_sha512(), EVP_mdc2() and EVP_ripemd160() return B<EVP_MD>
|
||||
structures for the MD2, MD5, SHA, SHA1, SHA224, SHA256, SHA384, SHA512, MDC2
|
||||
and RIPEMD160 digest algorithms respectively.
|
||||
|
||||
EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest
|
||||
algorithms but using DSS (DSA) for the signature algorithm. Note: there is
|
||||
@@ -171,8 +178,8 @@ The B<EVP> interface to message digests should almost always be used in
|
||||
preference to the low level interfaces. This is because the code then becomes
|
||||
transparent to the digest used and much more flexible.
|
||||
|
||||
SHA1 is the digest of choice for new applications. The other digest algorithms
|
||||
are still in common use.
|
||||
New applications should use the SHA2 digest algorithms such as SHA256.
|
||||
The other digest algorithms are still in common use.
|
||||
|
||||
For most applications the B<impl> parameter to EVP_DigestInit_ex() will be
|
||||
set to NULL to use the default digest implementation.
|
||||
@@ -187,6 +194,19 @@ implementations of digests to be specified.
|
||||
In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use
|
||||
memory leaks will occur.
|
||||
|
||||
Stack allocation of EVP_MD_CTX structures is common, for example:
|
||||
|
||||
EVP_MD_CTX mctx;
|
||||
EVP_MD_CTX_init(&mctx);
|
||||
|
||||
This will cause binary compatibility issues if the size of EVP_MD_CTX
|
||||
structure changes (this will only happen with a major release of OpenSSL).
|
||||
Applications wishing to avoid this should use EVP_MD_CTX_create() instead:
|
||||
|
||||
EVP_MD_CTX *mctx;
|
||||
mctx = EVP_MD_CTX_create();
|
||||
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
This example digests the data "Test Message\n" and "Hello World\n", using the
|
||||
@@ -197,7 +217,7 @@ digest name passed on the command line.
|
||||
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
EVP_MD_CTX mdctx;
|
||||
EVP_MD_CTX *mdctx;
|
||||
const EVP_MD *md;
|
||||
char mess1[] = "Test Message\n";
|
||||
char mess2[] = "Hello World\n";
|
||||
@@ -218,12 +238,12 @@ digest name passed on the command line.
|
||||
exit(1);
|
||||
}
|
||||
|
||||
EVP_MD_CTX_init(&mdctx);
|
||||
EVP_DigestInit_ex(&mdctx, md, NULL);
|
||||
EVP_DigestUpdate(&mdctx, mess1, strlen(mess1));
|
||||
EVP_DigestUpdate(&mdctx, mess2, strlen(mess2));
|
||||
EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
mdctx = EVP_MD_CTX_create();
|
||||
EVP_DigestInit_ex(mdctx, md, NULL);
|
||||
EVP_DigestUpdate(mdctx, mess1, strlen(mess1));
|
||||
EVP_DigestUpdate(mdctx, mess2, strlen(mess2));
|
||||
EVP_DigestFinal_ex(mdctx, md_value, &md_len);
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
|
||||
printf("Digest is: ");
|
||||
for(i = 0; i < md_len; i++) printf("%02x", md_value[i]);
|
||||
|
@@ -117,7 +117,7 @@ L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
|
||||
L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
|
||||
L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
|
||||
L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
|
||||
L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>,
|
||||
L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
|
||||
L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
|
||||
L<EVP_PKEY_keygen(3)|EVP_PKEY_keygen(3)>
|
||||
|
||||
|
@@ -83,7 +83,7 @@ L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
|
||||
L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
|
||||
L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
|
||||
L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
|
||||
L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>,
|
||||
L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
|
||||
L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
|
||||
|
||||
=head1 HISTORY
|
||||
|
@@ -84,7 +84,7 @@ L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
|
||||
L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
|
||||
L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
|
||||
L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
|
||||
L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>,
|
||||
L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
|
||||
|
||||
=head1 HISTORY
|
||||
|
||||
|
@@ -83,7 +83,7 @@ L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
|
||||
L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
|
||||
L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
|
||||
L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
|
||||
L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>,
|
||||
L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
|
||||
L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
|
||||
|
||||
=head1 HISTORY
|
||||
|
@@ -32,7 +32,7 @@ public key algorithm.
|
||||
L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
|
||||
L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
|
||||
L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
|
||||
L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>,
|
||||
L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
|
||||
|
||||
=head1 HISTORY
|
||||
|
||||
|
@@ -151,7 +151,7 @@ L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
|
||||
L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
|
||||
L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
|
||||
L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
|
||||
L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>,
|
||||
L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
|
||||
L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
|
||||
|
||||
=head1 HISTORY
|
||||
|
@@ -86,7 +86,7 @@ L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
|
||||
L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
|
||||
L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
|
||||
L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
|
||||
L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>,
|
||||
L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
|
||||
L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
|
||||
|
||||
=head1 HISTORY
|
||||
|
@@ -81,7 +81,7 @@ L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
|
||||
L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
|
||||
L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
|
||||
L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
|
||||
L<EVP_PKEY_verifyrecover(3)|EVP_PKEY_verifyrecover(3)>,
|
||||
L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
|
||||
L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
|
||||
|
||||
=head1 HISTORY
|
||||
|
@@ -2,23 +2,23 @@
|
||||
|
||||
=head1 NAME
|
||||
|
||||
EVP_PKEY_verifyrecover_init, EVP_PKEY_verifyrecover - recover signature using a public key algorithm
|
||||
EVP_PKEY_verify_recover_init, EVP_PKEY_verify_recover - recover signature using a public key algorithm
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
#include <openssl/evp.h>
|
||||
|
||||
int EVP_PKEY_verifyrecover_init(EVP_PKEY_CTX *ctx);
|
||||
int EVP_PKEY_verifyrecover(EVP_PKEY_CTX *ctx,
|
||||
int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
|
||||
int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
|
||||
unsigned char *rout, size_t *routlen,
|
||||
const unsigned char *sig, size_t siglen);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The EVP_PKEY_verifyrecover_init() function initializes a public key algorithm
|
||||
The EVP_PKEY_verify_recover_init() function initializes a public key algorithm
|
||||
context using key B<pkey> for a verify recover operation.
|
||||
|
||||
The EVP_PKEY_verifyrecover() function recovers signed data
|
||||
The EVP_PKEY_verify_recover() function recovers signed data
|
||||
using B<ctx>. The signature is specified using the B<sig> and
|
||||
B<siglen> parameters. If B<rout> is B<NULL> then the maximum size of the output
|
||||
buffer is written to the B<routlen> parameter. If B<rout> is not B<NULL> then
|
||||
@@ -36,16 +36,16 @@ Sometimes however it is useful to obtain the data originally signed using a
|
||||
signing operation. Only certain public key algorithms can recover a signature
|
||||
in this way (for example RSA in PKCS padding mode).
|
||||
|
||||
After the call to EVP_PKEY_verifyrecover_init() algorithm specific control
|
||||
After the call to EVP_PKEY_verify_recover_init() algorithm specific control
|
||||
operations can be performed to set any appropriate parameters for the
|
||||
operation.
|
||||
|
||||
The function EVP_PKEY_verifyrecover() can be called more than once on the same
|
||||
The function EVP_PKEY_verify_recover() can be called more than once on the same
|
||||
context if several operations are performed using the same parameters.
|
||||
|
||||
=head1 RETURN VALUES
|
||||
|
||||
EVP_PKEY_verifyrecover_init() and EVP_PKEY_verifyrecover() return 1 for success
|
||||
EVP_PKEY_verify_recover_init() and EVP_PKEY_verify_recover() return 1 for success
|
||||
and 0 or a negative value for failure. In particular a return value of -2
|
||||
indicates the operation is not supported by the public key algorithm.
|
||||
|
||||
@@ -66,7 +66,7 @@ Recover digest originally signed using PKCS#1 and SHA256 digest:
|
||||
ctx = EVP_PKEY_CTX_new(verify_key);
|
||||
if (!ctx)
|
||||
/* Error occurred */
|
||||
if (EVP_PKEY_verifyrecover_init(ctx) <= 0)
|
||||
if (EVP_PKEY_verify_recover_init(ctx) <= 0)
|
||||
/* Error */
|
||||
if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
|
||||
/* Error */
|
||||
@@ -74,7 +74,7 @@ Recover digest originally signed using PKCS#1 and SHA256 digest:
|
||||
/* Error */
|
||||
|
||||
/* Determine buffer length */
|
||||
if (EVP_PKEY_verifyrecover(ctx, NULL, &routlen, sig, siglen) <= 0)
|
||||
if (EVP_PKEY_verify_recover(ctx, NULL, &routlen, sig, siglen) <= 0)
|
||||
/* Error */
|
||||
|
||||
rout = OPENSSL_malloc(routlen);
|
||||
@@ -82,7 +82,7 @@ Recover digest originally signed using PKCS#1 and SHA256 digest:
|
||||
if (!rout)
|
||||
/* malloc failure */
|
||||
|
||||
if (EVP_PKEY_verifyrecover(ctx, rout, &routlen, sig, siglen) <= 0)
|
||||
if (EVP_PKEY_verify_recover(ctx, rout, &routlen, sig, siglen) <= 0)
|
||||
/* Error */
|
||||
|
||||
/* Recovered data is routlen bytes written to buffer rout */
|
@@ -369,7 +369,13 @@ int gost_mac(gost_ctx *ctx,int mac_len,const unsigned char *data,
|
||||
memset(buf2,0,8);
|
||||
memcpy(buf2,data+i,data_len-i);
|
||||
mac_block(ctx,buffer,buf2);
|
||||
}
|
||||
i+=8;
|
||||
}
|
||||
if (i==8)
|
||||
{
|
||||
memset(buf2,0,8);
|
||||
mac_block(ctx,buffer,buf2);
|
||||
}
|
||||
get_mac(buffer,mac_len,mac);
|
||||
return 1;
|
||||
}
|
||||
@@ -389,7 +395,13 @@ int gost_mac_iv(gost_ctx *ctx,int mac_len,const unsigned char *iv,const unsigned
|
||||
memset(buf2,0,8);
|
||||
memcpy(buf2,data+i,data_len-i);
|
||||
mac_block(ctx,buffer,buf2);
|
||||
i+=8;
|
||||
}
|
||||
if (i==8)
|
||||
{
|
||||
memset(buf2,0,8);
|
||||
mac_block(ctx,buffer,buf2);
|
||||
}
|
||||
get_mac(buffer,mac_len,mac);
|
||||
return 1;
|
||||
}
|
||||
|
@@ -11,6 +11,14 @@
|
||||
#include <openssl/rand.h>
|
||||
#include "e_gost_err.h"
|
||||
#include "gost_lcl.h"
|
||||
|
||||
#if !defined(CCGOST_DEBUG) && !defined(DEBUG)
|
||||
# ifndef NDEBUG
|
||||
# define NDEBUG
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
static int gost_cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const unsigned char *iv, int enc);
|
||||
static int gost_cipher_init_cpa(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
@@ -206,12 +214,13 @@ int gost_cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
static void gost_crypt_mesh (void *ctx,unsigned char *iv,unsigned char *buf)
|
||||
{
|
||||
struct ossl_gost_cipher_ctx *c = ctx;
|
||||
if (c->count&&c->key_meshing && c->count%1024==0)
|
||||
assert(c->count%8 == 0 && c->count <= 1024);
|
||||
if (c->key_meshing && c->count==1024)
|
||||
{
|
||||
cryptopro_key_meshing(&(c->cctx),iv);
|
||||
}
|
||||
gostcrypt(&(c->cctx),iv,buf);
|
||||
c->count+=8;
|
||||
c->count = c->count%1024 + 8;
|
||||
}
|
||||
|
||||
static void gost_cnt_next (void *ctx, unsigned char *iv, unsigned char *buf)
|
||||
@@ -219,7 +228,8 @@ static void gost_cnt_next (void *ctx, unsigned char *iv, unsigned char *buf)
|
||||
struct ossl_gost_cipher_ctx *c = ctx;
|
||||
word32 g,go;
|
||||
unsigned char buf1[8];
|
||||
if (c->count && c->key_meshing && c->count %1024 ==0)
|
||||
assert(c->count%8 == 0 && c->count <= 1024);
|
||||
if (c->key_meshing && c->count==1024)
|
||||
{
|
||||
cryptopro_key_meshing(&(c->cctx),iv);
|
||||
}
|
||||
@@ -248,7 +258,7 @@ static void gost_cnt_next (void *ctx, unsigned char *iv, unsigned char *buf)
|
||||
buf1[7]=(unsigned char)((g>>24)&0xff);
|
||||
memcpy(iv,buf1,8);
|
||||
gostcrypt(&(c->cctx),buf1,buf);
|
||||
c->count +=8;
|
||||
c->count = c->count%1024 + 8;
|
||||
}
|
||||
|
||||
/* GOST encryption in CFB mode */
|
||||
@@ -511,12 +521,13 @@ static void mac_block_mesh(struct ossl_gost_imit_ctx *c,const unsigned char *dat
|
||||
* interpret internal state of MAC algorithm as iv during keymeshing
|
||||
* (but does initialize internal state from iv in key transport
|
||||
*/
|
||||
if (c->key_meshing&& c->count && c->count %1024 ==0)
|
||||
assert(c->count%8 == 0 && c->count <= 1024);
|
||||
if (c->key_meshing && c->count==1024)
|
||||
{
|
||||
cryptopro_key_meshing(&(c->cctx),buffer);
|
||||
}
|
||||
mac_block(&(c->cctx),c->buffer,data);
|
||||
c->count +=8;
|
||||
c->count = c->count%1024 + 8;
|
||||
}
|
||||
|
||||
int gost_imit_update(EVP_MD_CTX *ctx, const void *data, size_t count)
|
||||
@@ -565,6 +576,12 @@ int gost_imit_final(EVP_MD_CTX *ctx,unsigned char *md)
|
||||
GOSTerr(GOST_F_GOST_IMIT_FINAL, GOST_R_MAC_KEY_NOT_SET);
|
||||
return 0;
|
||||
}
|
||||
if (c->count==0 && c->bytes_left)
|
||||
{
|
||||
unsigned char buffer[8];
|
||||
memset(buffer, 0, 8);
|
||||
gost_imit_update(ctx, buffer, 8);
|
||||
}
|
||||
if (c->bytes_left)
|
||||
{
|
||||
int i;
|
||||
|
@@ -64,6 +64,13 @@ static int gost_engine_finish(ENGINE *e)
|
||||
static int gost_engine_destroy(ENGINE *e)
|
||||
{
|
||||
gost_param_free();
|
||||
|
||||
pmeth_GostR3410_94 = NULL;
|
||||
pmeth_GostR3410_2001 = NULL;
|
||||
pmeth_Gost28147_MAC = NULL;
|
||||
ameth_GostR3410_94 = NULL;
|
||||
ameth_GostR3410_2001 = NULL;
|
||||
ameth_Gost28147_MAC = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -263,7 +270,10 @@ static ENGINE *engine_gost(void)
|
||||
|
||||
void ENGINE_load_gost(void)
|
||||
{
|
||||
ENGINE *toadd =engine_gost();
|
||||
ENGINE *toadd;
|
||||
if (pmeth_GostR3410_94)
|
||||
return;
|
||||
toadd = engine_gost();
|
||||
if (!toadd) return;
|
||||
ENGINE_add(toadd);
|
||||
ENGINE_free(toadd);
|
||||
|
@@ -136,7 +136,7 @@ extern EVP_MD imit_gost_cpa;
|
||||
/* Cipher context used for EVP_CIPHER operation */
|
||||
struct ossl_gost_cipher_ctx {
|
||||
int paramNID;
|
||||
off_t count;
|
||||
unsigned int count;
|
||||
int key_meshing;
|
||||
gost_ctx cctx;
|
||||
};
|
||||
@@ -151,7 +151,7 @@ struct ossl_gost_imit_ctx {
|
||||
gost_ctx cctx;
|
||||
unsigned char buffer[8];
|
||||
unsigned char partial_block[8];
|
||||
off_t count;
|
||||
unsigned int count;
|
||||
int key_meshing;
|
||||
int bytes_left;
|
||||
int key_set;
|
||||
|
@@ -42,7 +42,7 @@ static void circle_xor8 (const byte *w, byte *k)
|
||||
byte buf[8];
|
||||
int i;
|
||||
memcpy(buf,w,8);
|
||||
memcpy(k,w+8,24);
|
||||
memmove(k,w+8,24);
|
||||
for(i=0;i<8;i++)
|
||||
k[i+24]=buf[i]^k[i];
|
||||
}
|
||||
|
@@ -1431,10 +1431,13 @@ static PCCERT_CONTEXT capi_find_cert(CAPI_CTX *ctx, const char *id, HCERTSTORE h
|
||||
static CAPI_KEY *capi_get_key(CAPI_CTX *ctx, const char *contname, char *provname, DWORD ptype, DWORD keyspec)
|
||||
{
|
||||
CAPI_KEY *key;
|
||||
DWORD dwFlags = 0;
|
||||
key = OPENSSL_malloc(sizeof(CAPI_KEY));
|
||||
CAPI_trace(ctx, "capi_get_key, contname=%s, provname=%s, type=%d\n",
|
||||
contname, provname, ptype);
|
||||
if (!CryptAcquireContextA(&key->hprov, contname, provname, ptype, 0))
|
||||
if(ctx->store_flags & CERT_SYSTEM_STORE_LOCAL_MACHINE)
|
||||
dwFlags = CRYPT_MACHINE_KEYSET;
|
||||
if (!CryptAcquireContextA(&key->hprov, contname, provname, ptype, dwFlags))
|
||||
{
|
||||
CAPIerr(CAPI_F_CAPI_GET_KEY, CAPI_R_CRYPTACQUIRECONTEXT_ERROR);
|
||||
capi_addlasterror();
|
||||
|
@@ -2,7 +2,8 @@
|
||||
|
||||
$output=shift;
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
open STDOUT,"| $^X ${dir}../crypto/perlasm/x86_64-xlate.pl $output";
|
||||
open OUT,"| \"$^X\" ${dir}../crypto/perlasm/x86_64-xlate.pl $output";
|
||||
*STDOUT=*OUT;
|
||||
push(@INC,"${dir}.");
|
||||
|
||||
require "uplink-common.pl";
|
||||
|
@@ -2,7 +2,7 @@
|
||||
%define libmaj 1
|
||||
%define libmin 0
|
||||
%define librel 0
|
||||
%define librev h
|
||||
%define librev k
|
||||
Release: 1
|
||||
|
||||
%define openssldir /var/ssl
|
||||
|
24
ssl/Makefile
24
ssl/Makefile
@@ -22,7 +22,7 @@ LIB=$(TOP)/libssl.a
|
||||
SHARED_LIB= libssl$(SHLIB_EXT)
|
||||
LIBSRC= \
|
||||
s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \
|
||||
s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \
|
||||
s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s3_cbc.c \
|
||||
s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \
|
||||
t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \
|
||||
d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c d1_pkt.c \
|
||||
@@ -33,7 +33,7 @@ LIBSRC= \
|
||||
bio_ssl.c ssl_err.c kssl.c t1_reneg.c
|
||||
LIBOBJ= \
|
||||
s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o \
|
||||
s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o \
|
||||
s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o s3_cbc.o \
|
||||
s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o \
|
||||
t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o \
|
||||
d1_meth.o d1_srvr.o d1_clnt.o d1_lib.o d1_pkt.o \
|
||||
@@ -515,6 +515,26 @@ s3_both.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
|
||||
s3_both.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
|
||||
s3_both.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s3_both.c
|
||||
s3_both.o: ssl_locl.h
|
||||
s3_cbc.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
|
||||
s3_cbc.o: ../include/openssl/buffer.h ../include/openssl/comp.h
|
||||
s3_cbc.o: ../include/openssl/crypto.h ../include/openssl/dsa.h
|
||||
s3_cbc.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h
|
||||
s3_cbc.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
|
||||
s3_cbc.o: ../include/openssl/ecdsa.h ../include/openssl/err.h
|
||||
s3_cbc.o: ../include/openssl/evp.h ../include/openssl/hmac.h
|
||||
s3_cbc.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
|
||||
s3_cbc.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
|
||||
s3_cbc.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
|
||||
s3_cbc.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
|
||||
s3_cbc.o: ../include/openssl/pem.h ../include/openssl/pem2.h
|
||||
s3_cbc.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
|
||||
s3_cbc.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
|
||||
s3_cbc.o: ../include/openssl/sha.h ../include/openssl/ssl.h
|
||||
s3_cbc.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
|
||||
s3_cbc.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
|
||||
s3_cbc.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
|
||||
s3_cbc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s3_cbc.c
|
||||
s3_cbc.o: ssl_locl.h
|
||||
s3_clnt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
|
||||
s3_clnt.o: ../include/openssl/bn.h ../include/openssl/buffer.h
|
||||
s3_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h
|
||||
|
@@ -538,6 +538,7 @@ err:
|
||||
|
||||
BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
|
||||
{
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
BIO *ret=NULL,*con=NULL,*ssl=NULL;
|
||||
|
||||
if ((con=BIO_new(BIO_s_connect())) == NULL)
|
||||
@@ -549,6 +550,7 @@ BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
|
||||
return(ret);
|
||||
err:
|
||||
if (con != NULL) BIO_free(con);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
59
ssl/d1_enc.c
59
ssl/d1_enc.c
@@ -126,20 +126,28 @@
|
||||
#include <openssl/des.h>
|
||||
#endif
|
||||
|
||||
/* dtls1_enc encrypts/decrypts the record in |s->wrec| / |s->rrec|, respectively.
|
||||
*
|
||||
* Returns:
|
||||
* 0: (in non-constant time) if the record is publically invalid (i.e. too
|
||||
* short etc).
|
||||
* 1: if the record's padding is valid / the encryption was successful.
|
||||
* -1: if the record's padding/AEAD-authenticator is invalid or, if sending,
|
||||
* an internal error occured. */
|
||||
int dtls1_enc(SSL *s, int send)
|
||||
{
|
||||
SSL3_RECORD *rec;
|
||||
EVP_CIPHER_CTX *ds;
|
||||
unsigned long l;
|
||||
int bs,i,ii,j,k,n=0;
|
||||
int bs,i,j,k,mac_size=0;
|
||||
const EVP_CIPHER *enc;
|
||||
|
||||
if (send)
|
||||
{
|
||||
if (EVP_MD_CTX_md(s->write_hash))
|
||||
{
|
||||
n=EVP_MD_CTX_size(s->write_hash);
|
||||
if (n < 0)
|
||||
mac_size=EVP_MD_CTX_size(s->write_hash);
|
||||
if (mac_size < 0)
|
||||
return -1;
|
||||
}
|
||||
ds=s->enc_write_ctx;
|
||||
@@ -164,9 +172,8 @@ int dtls1_enc(SSL *s, int send)
|
||||
{
|
||||
if (EVP_MD_CTX_md(s->read_hash))
|
||||
{
|
||||
n=EVP_MD_CTX_size(s->read_hash);
|
||||
if (n < 0)
|
||||
return -1;
|
||||
mac_size=EVP_MD_CTX_size(s->read_hash);
|
||||
OPENSSL_assert(mac_size >= 0);
|
||||
}
|
||||
ds=s->enc_read_ctx;
|
||||
rec= &(s->s3->rrec);
|
||||
@@ -231,7 +238,7 @@ int dtls1_enc(SSL *s, int send)
|
||||
if (!send)
|
||||
{
|
||||
if (l == 0 || l%bs != 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EVP_Cipher(ds,rec->data,rec->input,l);
|
||||
@@ -246,43 +253,7 @@ int dtls1_enc(SSL *s, int send)
|
||||
#endif /* KSSL_DEBUG */
|
||||
|
||||
if ((bs != 1) && !send)
|
||||
{
|
||||
ii=i=rec->data[l-1]; /* padding_length */
|
||||
i++;
|
||||
if (s->options&SSL_OP_TLS_BLOCK_PADDING_BUG)
|
||||
{
|
||||
/* First packet is even in size, so check */
|
||||
if ((memcmp(s->s3->read_sequence,
|
||||
"\0\0\0\0\0\0\0\0",8) == 0) && !(ii & 1))
|
||||
s->s3->flags|=TLS1_FLAGS_TLS_PADDING_BUG;
|
||||
if (s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG)
|
||||
i--;
|
||||
}
|
||||
/* TLS 1.0 does not bound the number of padding bytes by the block size.
|
||||
* All of them must have value 'padding_length'. */
|
||||
if (i > (int)rec->length)
|
||||
{
|
||||
/* Incorrect padding. SSLerr() and ssl3_alert are done
|
||||
* by caller: we don't want to reveal whether this is
|
||||
* a decryption error or a MAC verification failure
|
||||
* (see http://www.openssl.org/~bodo/tls-cbc.txt)
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
for (j=(int)(l-i); j<(int)l; j++)
|
||||
{
|
||||
if (rec->data[j] != ii)
|
||||
{
|
||||
/* Incorrect padding */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
rec->length-=i;
|
||||
|
||||
rec->data += bs; /* skip the implicit IV */
|
||||
rec->input += bs;
|
||||
rec->length -= bs;
|
||||
}
|
||||
return tls1_cbc_remove_padding(s, rec, bs, mac_size);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
89
ssl/d1_pkt.c
89
ssl/d1_pkt.c
@@ -368,15 +368,11 @@ static int
|
||||
dtls1_process_record(SSL *s)
|
||||
{
|
||||
int i,al;
|
||||
int clear=0;
|
||||
int enc_err;
|
||||
SSL_SESSION *sess;
|
||||
SSL3_RECORD *rr;
|
||||
unsigned int mac_size;
|
||||
unsigned char md[EVP_MAX_MD_SIZE];
|
||||
int decryption_failed_or_bad_record_mac = 0;
|
||||
unsigned char *mac = NULL;
|
||||
|
||||
|
||||
rr= &(s->s3->rrec);
|
||||
sess = s->session;
|
||||
@@ -406,14 +402,19 @@ dtls1_process_record(SSL *s)
|
||||
|
||||
/* decrypt in place in 'rr->input' */
|
||||
rr->data=rr->input;
|
||||
rr->orig_len=rr->length;
|
||||
|
||||
enc_err = s->method->ssl3_enc->enc(s,0);
|
||||
if (enc_err <= 0)
|
||||
/* enc_err is:
|
||||
* 0: (in non-constant time) if the record is publically invalid.
|
||||
* 1: if the padding is valid
|
||||
* -1: if the padding is invalid */
|
||||
if (enc_err == 0)
|
||||
{
|
||||
/* To minimize information leaked via timing, we will always
|
||||
* perform all computations before discarding the message.
|
||||
*/
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
/* For DTLS we simply ignore bad packets. */
|
||||
rr->length = 0;
|
||||
s->packet_length = 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
#ifdef TLS_DEBUG
|
||||
@@ -423,45 +424,59 @@ printf("\n");
|
||||
#endif
|
||||
|
||||
/* r->length is now the compressed data plus mac */
|
||||
if ( (sess == NULL) ||
|
||||
(s->enc_read_ctx == NULL) ||
|
||||
(s->read_hash == NULL))
|
||||
clear=1;
|
||||
|
||||
if (!clear)
|
||||
if ((sess != NULL) &&
|
||||
(s->enc_read_ctx != NULL) &&
|
||||
(EVP_MD_CTX_md(s->read_hash) != NULL))
|
||||
{
|
||||
/* !clear => s->read_hash != NULL => mac_size != -1 */
|
||||
int t;
|
||||
t=EVP_MD_CTX_size(s->read_hash);
|
||||
OPENSSL_assert(t >= 0);
|
||||
mac_size=t;
|
||||
/* s->read_hash != NULL => mac_size != -1 */
|
||||
unsigned char *mac = NULL;
|
||||
unsigned char mac_tmp[EVP_MAX_MD_SIZE];
|
||||
mac_size=EVP_MD_CTX_size(s->read_hash);
|
||||
OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);
|
||||
|
||||
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+mac_size)
|
||||
/* orig_len is the length of the record before any padding was
|
||||
* removed. This is public information, as is the MAC in use,
|
||||
* therefore we can safely process the record in a different
|
||||
* amount of time if it's too short to possibly contain a MAC.
|
||||
*/
|
||||
if (rr->orig_len < mac_size ||
|
||||
/* CBC records must have a padding length byte too. */
|
||||
(EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE &&
|
||||
rr->orig_len < mac_size+1))
|
||||
{
|
||||
#if 0 /* OK only for stream ciphers (then rr->length is visible from ciphertext anyway) */
|
||||
al=SSL_AD_RECORD_OVERFLOW;
|
||||
SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
|
||||
al=SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_LENGTH_TOO_SHORT);
|
||||
goto f_err;
|
||||
#else
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
#endif
|
||||
}
|
||||
/* check the MAC for rr->input (it's in mac_size bytes at the tail) */
|
||||
if (rr->length >= mac_size)
|
||||
|
||||
if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE)
|
||||
{
|
||||
/* We update the length so that the TLS header bytes
|
||||
* can be constructed correctly but we need to extract
|
||||
* the MAC in constant time from within the record,
|
||||
* without leaking the contents of the padding bytes.
|
||||
* */
|
||||
mac = mac_tmp;
|
||||
ssl3_cbc_copy_mac(mac_tmp, rr, mac_size);
|
||||
rr->length -= mac_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In this case there's no padding, so |rec->orig_len|
|
||||
* equals |rec->length| and we checked that there's
|
||||
* enough bytes for |mac_size| above. */
|
||||
rr->length -= mac_size;
|
||||
mac = &rr->data[rr->length];
|
||||
}
|
||||
else
|
||||
rr->length = 0;
|
||||
i=s->method->ssl3_enc->mac(s,md,0);
|
||||
if (i < 0 || mac == NULL || memcmp(md, mac, mac_size) != 0)
|
||||
{
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
}
|
||||
|
||||
i=s->method->ssl3_enc->mac(s,md,0 /* not send */);
|
||||
if (i < 0 || mac == NULL || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)
|
||||
enc_err = -1;
|
||||
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+mac_size)
|
||||
enc_err = -1;
|
||||
}
|
||||
|
||||
if (decryption_failed_or_bad_record_mac)
|
||||
if (enc_err < 0)
|
||||
{
|
||||
/* decryption failed, silently discard message */
|
||||
rr->length = 0;
|
||||
|
@@ -771,7 +771,7 @@ int dtls1_send_server_hello(SSL *s)
|
||||
p=s->s3->server_random;
|
||||
Time=(unsigned long)time(NULL); /* Time */
|
||||
l2n(Time,p);
|
||||
RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time));
|
||||
RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4);
|
||||
/* Do the message type and length last */
|
||||
d=p= &(buf[DTLS1_HM_HEADER_LENGTH]);
|
||||
|
||||
|
@@ -359,12 +359,14 @@ static int get_server_hello(SSL *s)
|
||||
SSL_R_PEER_ERROR);
|
||||
return(-1);
|
||||
}
|
||||
#ifdef __APPLE_CC__
|
||||
/* The Rhapsody 5.5 (a.k.a. MacOS X) compiler bug
|
||||
* workaround. <appro@fy.chalmers.se> */
|
||||
s->hit=(i=*(p++))?1:0;
|
||||
#else
|
||||
#if 0
|
||||
s->hit=(*(p++))?1:0;
|
||||
/* Some [PPC?] compilers fail to increment p in above
|
||||
statement, e.g. one provided with Rhapsody 5.5, but
|
||||
most recent example XL C 11.1 for AIX, even without
|
||||
optimization flag... */
|
||||
#else
|
||||
s->hit=(*p)?1:0; p++;
|
||||
#endif
|
||||
s->s2->tmp.cert_type= *(p++);
|
||||
n2s(p,i);
|
||||
@@ -937,7 +939,7 @@ static int get_server_verify(SSL *s)
|
||||
s->msg_callback(0, s->version, 0, p, len, s, s->msg_callback_arg); /* SERVER-VERIFY */
|
||||
p += 1;
|
||||
|
||||
if (memcmp(p,s->s2->challenge,s->s2->challenge_length) != 0)
|
||||
if (CRYPTO_memcmp(p,s->s2->challenge,s->s2->challenge_length) != 0)
|
||||
{
|
||||
ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
|
||||
SSLerr(SSL_F_GET_SERVER_VERIFY,SSL_R_CHALLENGE_IS_DIFFERENT);
|
||||
|
@@ -269,8 +269,7 @@ static int ssl2_read_internal(SSL *s, void *buf, int len, int peek)
|
||||
s->s2->ract_data_length-=mac_size;
|
||||
ssl2_mac(s,mac,0);
|
||||
s->s2->ract_data_length-=s->s2->padding;
|
||||
if ( (memcmp(mac,s->s2->mac_data,
|
||||
(unsigned int)mac_size) != 0) ||
|
||||
if ( (CRYPTO_memcmp(mac,s->s2->mac_data,mac_size) != 0) ||
|
||||
(s->s2->rlength%EVP_CIPHER_CTX_block_size(s->enc_read_ctx) != 0))
|
||||
{
|
||||
SSLerr(SSL_F_SSL2_READ_INTERNAL,SSL_R_BAD_MAC_DECODE);
|
||||
|
@@ -240,7 +240,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
|
||||
goto f_err;
|
||||
}
|
||||
|
||||
if (memcmp(p, s->s3->tmp.peer_finish_md, i) != 0)
|
||||
if (CRYPTO_memcmp(p, s->s3->tmp.peer_finish_md, i) != 0)
|
||||
{
|
||||
al=SSL_AD_DECRYPT_ERROR;
|
||||
SSLerr(SSL_F_SSL3_GET_FINISHED,SSL_R_DIGEST_CHECK_FAILED);
|
||||
|
708
ssl/s3_cbc.c
Normal file
708
ssl/s3_cbc.c
Normal file
@@ -0,0 +1,708 @@
|
||||
/* ssl/s3_cbc.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2012 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).
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ssl_locl.h"
|
||||
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
/* MAX_HASH_BIT_COUNT_BYTES is the maximum number of bytes in the hash's length
|
||||
* field. (SHA-384/512 have 128-bit length.) */
|
||||
#define MAX_HASH_BIT_COUNT_BYTES 16
|
||||
|
||||
/* MAX_HASH_BLOCK_SIZE is the maximum hash block size that we'll support.
|
||||
* Currently SHA-384/512 has a 128-byte block size and that's the largest
|
||||
* supported by TLS.) */
|
||||
#define MAX_HASH_BLOCK_SIZE 128
|
||||
|
||||
/* Some utility functions are needed:
|
||||
*
|
||||
* These macros return the given value with the MSB copied to all the other
|
||||
* bits. They use the fact that arithmetic shift shifts-in the sign bit.
|
||||
* However, this is not ensured by the C standard so you may need to replace
|
||||
* them with something else on odd CPUs. */
|
||||
#define DUPLICATE_MSB_TO_ALL(x) ( (unsigned)( (int)(x) >> (sizeof(int)*8-1) ) )
|
||||
#define DUPLICATE_MSB_TO_ALL_8(x) ((unsigned char)(DUPLICATE_MSB_TO_ALL(x)))
|
||||
|
||||
/* constant_time_ge returns 0xff if a>=b and 0x00 otherwise. */
|
||||
static unsigned constant_time_ge(unsigned a, unsigned b)
|
||||
{
|
||||
a -= b;
|
||||
return DUPLICATE_MSB_TO_ALL(~a);
|
||||
}
|
||||
|
||||
/* constant_time_eq_8 returns 0xff if a==b and 0x00 otherwise. */
|
||||
static unsigned char constant_time_eq_8(unsigned char a, unsigned char b)
|
||||
{
|
||||
unsigned c = a ^ b;
|
||||
c--;
|
||||
return DUPLICATE_MSB_TO_ALL_8(c);
|
||||
}
|
||||
|
||||
/* ssl3_cbc_remove_padding removes padding from the decrypted, SSLv3, CBC
|
||||
* record in |rec| by updating |rec->length| in constant time.
|
||||
*
|
||||
* block_size: the block size of the cipher used to encrypt the record.
|
||||
* returns:
|
||||
* 0: (in non-constant time) if the record is publicly invalid.
|
||||
* 1: if the padding was valid
|
||||
* -1: otherwise. */
|
||||
int ssl3_cbc_remove_padding(const SSL* s,
|
||||
SSL3_RECORD *rec,
|
||||
unsigned block_size,
|
||||
unsigned mac_size)
|
||||
{
|
||||
unsigned padding_length, good;
|
||||
const unsigned overhead = 1 /* padding length byte */ + mac_size;
|
||||
|
||||
/* These lengths are all public so we can test them in non-constant
|
||||
* time. */
|
||||
if (overhead > rec->length)
|
||||
return 0;
|
||||
|
||||
padding_length = rec->data[rec->length-1];
|
||||
good = constant_time_ge(rec->length, padding_length+overhead);
|
||||
/* SSLv3 requires that the padding is minimal. */
|
||||
good &= constant_time_ge(block_size, padding_length+1);
|
||||
rec->length -= good & (padding_length+1);
|
||||
return (int)((good & 1) | (~good & -1));
|
||||
}
|
||||
|
||||
/* tls1_cbc_remove_padding removes the CBC padding from the decrypted, TLS, CBC
|
||||
* record in |rec| in constant time and returns 1 if the padding is valid and
|
||||
* -1 otherwise. It also removes any explicit IV from the start of the record
|
||||
* without leaking any timing about whether there was enough space after the
|
||||
* padding was removed.
|
||||
*
|
||||
* block_size: the block size of the cipher used to encrypt the record.
|
||||
* returns:
|
||||
* 0: (in non-constant time) if the record is publicly invalid.
|
||||
* 1: if the padding was valid
|
||||
* -1: otherwise. */
|
||||
int tls1_cbc_remove_padding(const SSL* s,
|
||||
SSL3_RECORD *rec,
|
||||
unsigned block_size,
|
||||
unsigned mac_size)
|
||||
{
|
||||
unsigned padding_length, good, to_check, i;
|
||||
const char has_explicit_iv = s->version == DTLS1_VERSION;
|
||||
const unsigned overhead = 1 /* padding length byte */ +
|
||||
mac_size +
|
||||
(has_explicit_iv ? block_size : 0);
|
||||
|
||||
/* These lengths are all public so we can test them in non-constant
|
||||
* time. */
|
||||
if (overhead > rec->length)
|
||||
return 0;
|
||||
|
||||
padding_length = rec->data[rec->length-1];
|
||||
|
||||
/* NB: if compression is in operation the first packet may not be of
|
||||
* even length so the padding bug check cannot be performed. This bug
|
||||
* workaround has been around since SSLeay so hopefully it is either
|
||||
* fixed now or no buggy implementation supports compression [steve]
|
||||
*/
|
||||
if ( (s->options&SSL_OP_TLS_BLOCK_PADDING_BUG) && !s->expand)
|
||||
{
|
||||
/* First packet is even in size, so check */
|
||||
if ((memcmp(s->s3->read_sequence, "\0\0\0\0\0\0\0\0",8) == 0) &&
|
||||
!(padding_length & 1))
|
||||
{
|
||||
s->s3->flags|=TLS1_FLAGS_TLS_PADDING_BUG;
|
||||
}
|
||||
if ((s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG) &&
|
||||
padding_length > 0)
|
||||
{
|
||||
padding_length--;
|
||||
}
|
||||
}
|
||||
|
||||
good = constant_time_ge(rec->length, overhead+padding_length);
|
||||
/* The padding consists of a length byte at the end of the record and
|
||||
* then that many bytes of padding, all with the same value as the
|
||||
* length byte. Thus, with the length byte included, there are i+1
|
||||
* bytes of padding.
|
||||
*
|
||||
* We can't check just |padding_length+1| bytes because that leaks
|
||||
* decrypted information. Therefore we always have to check the maximum
|
||||
* amount of padding possible. (Again, the length of the record is
|
||||
* public information so we can use it.) */
|
||||
to_check = 255; /* maximum amount of padding. */
|
||||
if (to_check > rec->length-1)
|
||||
to_check = rec->length-1;
|
||||
|
||||
for (i = 0; i < to_check; i++)
|
||||
{
|
||||
unsigned char mask = constant_time_ge(padding_length, i);
|
||||
unsigned char b = rec->data[rec->length-1-i];
|
||||
/* The final |padding_length+1| bytes should all have the value
|
||||
* |padding_length|. Therefore the XOR should be zero. */
|
||||
good &= ~(mask&(padding_length ^ b));
|
||||
}
|
||||
|
||||
/* If any of the final |padding_length+1| bytes had the wrong value,
|
||||
* one or more of the lower eight bits of |good| will be cleared. We
|
||||
* AND the bottom 8 bits together and duplicate the result to all the
|
||||
* bits. */
|
||||
good &= good >> 4;
|
||||
good &= good >> 2;
|
||||
good &= good >> 1;
|
||||
good <<= sizeof(good)*8-1;
|
||||
good = DUPLICATE_MSB_TO_ALL(good);
|
||||
|
||||
rec->length -= good & (padding_length+1);
|
||||
|
||||
/* We can always safely skip the explicit IV. We check at the beginning
|
||||
* of this function that the record has at least enough space for the
|
||||
* IV, MAC and padding length byte. (These can be checked in
|
||||
* non-constant time because it's all public information.) So, if the
|
||||
* padding was invalid, then we didn't change |rec->length| and this is
|
||||
* safe. If the padding was valid then we know that we have at least
|
||||
* overhead+padding_length bytes of space and so this is still safe
|
||||
* because overhead accounts for the explicit IV. */
|
||||
if (has_explicit_iv)
|
||||
{
|
||||
rec->data += block_size;
|
||||
rec->input += block_size;
|
||||
rec->length -= block_size;
|
||||
rec->orig_len -= block_size;
|
||||
}
|
||||
|
||||
return (int)((good & 1) | (~good & -1));
|
||||
}
|
||||
|
||||
#if defined(_M_AMD64) || defined(__x86_64__)
|
||||
#define CBC_MAC_ROTATE_IN_PLACE
|
||||
#endif
|
||||
|
||||
/* ssl3_cbc_copy_mac copies |md_size| bytes from the end of |rec| to |out| in
|
||||
* constant time (independent of the concrete value of rec->length, which may
|
||||
* vary within a 256-byte window).
|
||||
*
|
||||
* ssl3_cbc_remove_padding or tls1_cbc_remove_padding must be called prior to
|
||||
* this function.
|
||||
*
|
||||
* On entry:
|
||||
* rec->orig_len >= md_size
|
||||
* md_size <= EVP_MAX_MD_SIZE
|
||||
*
|
||||
* If CBC_MAC_ROTATE_IN_PLACE is defined then the rotation is performed with
|
||||
* variable accesses in a 64-byte-aligned buffer. Assuming that this fits into
|
||||
* a single cache-line, then the variable memory accesses don't actually affect
|
||||
* the timing. This has been tested to be true on Intel amd64 chips.
|
||||
*/
|
||||
void ssl3_cbc_copy_mac(unsigned char* out,
|
||||
const SSL3_RECORD *rec,
|
||||
unsigned md_size)
|
||||
{
|
||||
#if defined(CBC_MAC_ROTATE_IN_PLACE)
|
||||
unsigned char rotated_mac_buf[EVP_MAX_MD_SIZE*2];
|
||||
unsigned char *rotated_mac;
|
||||
#else
|
||||
unsigned char rotated_mac[EVP_MAX_MD_SIZE];
|
||||
#endif
|
||||
|
||||
/* mac_end is the index of |rec->data| just after the end of the MAC. */
|
||||
unsigned mac_end = rec->length;
|
||||
unsigned mac_start = mac_end - md_size;
|
||||
/* scan_start contains the number of bytes that we can ignore because
|
||||
* the MAC's position can only vary by 255 bytes. */
|
||||
unsigned scan_start = 0;
|
||||
unsigned i, j;
|
||||
unsigned div_spoiler;
|
||||
unsigned rotate_offset;
|
||||
|
||||
OPENSSL_assert(rec->orig_len >= md_size);
|
||||
OPENSSL_assert(md_size <= EVP_MAX_MD_SIZE);
|
||||
|
||||
#if defined(CBC_MAC_ROTATE_IN_PLACE)
|
||||
rotated_mac = (unsigned char*) (((intptr_t)(rotated_mac_buf + 64)) & ~63);
|
||||
#endif
|
||||
|
||||
/* This information is public so it's safe to branch based on it. */
|
||||
if (rec->orig_len > md_size + 255 + 1)
|
||||
scan_start = rec->orig_len - (md_size + 255 + 1);
|
||||
/* div_spoiler contains a multiple of md_size that is used to cause the
|
||||
* modulo operation to be constant time. Without this, the time varies
|
||||
* based on the amount of padding when running on Intel chips at least.
|
||||
*
|
||||
* The aim of right-shifting md_size is so that the compiler doesn't
|
||||
* figure out that it can remove div_spoiler as that would require it
|
||||
* to prove that md_size is always even, which I hope is beyond it. */
|
||||
div_spoiler = md_size >> 1;
|
||||
div_spoiler <<= (sizeof(div_spoiler)-1)*8;
|
||||
rotate_offset = (div_spoiler + mac_start - scan_start) % md_size;
|
||||
|
||||
memset(rotated_mac, 0, md_size);
|
||||
for (i = scan_start; i < rec->orig_len;)
|
||||
{
|
||||
for (j = 0; j < md_size && i < rec->orig_len; i++, j++)
|
||||
{
|
||||
unsigned char mac_started = constant_time_ge(i, mac_start);
|
||||
unsigned char mac_ended = constant_time_ge(i, mac_end);
|
||||
unsigned char b = 0;
|
||||
b = rec->data[i];
|
||||
rotated_mac[j] |= b & mac_started & ~mac_ended;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now rotate the MAC */
|
||||
#if defined(CBC_MAC_ROTATE_IN_PLACE)
|
||||
j = 0;
|
||||
for (i = 0; i < md_size; i++)
|
||||
{
|
||||
unsigned char offset = (div_spoiler + rotate_offset + i) % md_size;
|
||||
out[j++] = rotated_mac[offset];
|
||||
}
|
||||
#else
|
||||
memset(out, 0, md_size);
|
||||
for (i = 0; i < md_size; i++)
|
||||
{
|
||||
unsigned char offset = (div_spoiler + md_size - rotate_offset + i) % md_size;
|
||||
for (j = 0; j < md_size; j++)
|
||||
out[j] |= rotated_mac[i] & constant_time_eq_8(j, offset);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* These functions serialize the state of a hash and thus perform the standard
|
||||
* "final" operation without adding the padding and length that such a function
|
||||
* typically does. */
|
||||
static void tls1_md5_final_raw(void* ctx, unsigned char *md_out)
|
||||
{
|
||||
MD5_CTX *md5 = ctx;
|
||||
l2n(md5->A, md_out);
|
||||
l2n(md5->B, md_out);
|
||||
l2n(md5->C, md_out);
|
||||
l2n(md5->D, md_out);
|
||||
}
|
||||
|
||||
static void tls1_sha1_final_raw(void* ctx, unsigned char *md_out)
|
||||
{
|
||||
SHA_CTX *sha1 = ctx;
|
||||
l2n(sha1->h0, md_out);
|
||||
l2n(sha1->h1, md_out);
|
||||
l2n(sha1->h2, md_out);
|
||||
l2n(sha1->h3, md_out);
|
||||
l2n(sha1->h4, md_out);
|
||||
}
|
||||
#define LARGEST_DIGEST_CTX SHA_CTX
|
||||
|
||||
#ifndef OPENSSL_NO_SHA256
|
||||
static void tls1_sha256_final_raw(void* ctx, unsigned char *md_out)
|
||||
{
|
||||
SHA256_CTX *sha256 = ctx;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
l2n(sha256->h[i], md_out);
|
||||
}
|
||||
}
|
||||
#undef LARGEST_DIGEST_CTX
|
||||
#define LARGEST_DIGEST_CTX SHA256_CTX
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_SHA512
|
||||
static void tls1_sha512_final_raw(void* ctx, unsigned char *md_out)
|
||||
{
|
||||
SHA512_CTX *sha512 = ctx;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
l2n8(sha512->h[i], md_out);
|
||||
}
|
||||
}
|
||||
#undef LARGEST_DIGEST_CTX
|
||||
#define LARGEST_DIGEST_CTX SHA512_CTX
|
||||
#endif
|
||||
|
||||
/* ssl3_cbc_record_digest_supported returns 1 iff |ctx| uses a hash function
|
||||
* which ssl3_cbc_digest_record supports. */
|
||||
char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx)
|
||||
{
|
||||
switch (ctx->digest->type)
|
||||
{
|
||||
case NID_md5:
|
||||
case NID_sha1:
|
||||
#ifndef OPENSSL_NO_SHA256
|
||||
case NID_sha224:
|
||||
case NID_sha256:
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SHA512
|
||||
case NID_sha384:
|
||||
case NID_sha512:
|
||||
#endif
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ssl3_cbc_digest_record computes the MAC of a decrypted, padded SSLv3/TLS
|
||||
* record.
|
||||
*
|
||||
* ctx: the EVP_MD_CTX from which we take the hash function.
|
||||
* ssl3_cbc_record_digest_supported must return true for this EVP_MD_CTX.
|
||||
* md_out: the digest output. At most EVP_MAX_MD_SIZE bytes will be written.
|
||||
* md_out_size: if non-NULL, the number of output bytes is written here.
|
||||
* header: the 13-byte, TLS record header.
|
||||
* data: the record data itself, less any preceeding explicit IV.
|
||||
* data_plus_mac_size: the secret, reported length of the data and MAC
|
||||
* once the padding has been removed.
|
||||
* data_plus_mac_plus_padding_size: the public length of the whole
|
||||
* record, including padding.
|
||||
* is_sslv3: non-zero if we are to use SSLv3. Otherwise, TLS.
|
||||
*
|
||||
* On entry: by virtue of having been through one of the remove_padding
|
||||
* functions, above, we know that data_plus_mac_size is large enough to contain
|
||||
* a padding byte and MAC. (If the padding was invalid, it might contain the
|
||||
* padding too. ) */
|
||||
void ssl3_cbc_digest_record(
|
||||
const EVP_MD_CTX *ctx,
|
||||
unsigned char* md_out,
|
||||
size_t* md_out_size,
|
||||
const unsigned char header[13],
|
||||
const unsigned char *data,
|
||||
size_t data_plus_mac_size,
|
||||
size_t data_plus_mac_plus_padding_size,
|
||||
const unsigned char *mac_secret,
|
||||
unsigned mac_secret_length,
|
||||
char is_sslv3)
|
||||
{
|
||||
union { double align;
|
||||
unsigned char c[sizeof(LARGEST_DIGEST_CTX)]; } md_state;
|
||||
void (*md_final_raw)(void *ctx, unsigned char *md_out);
|
||||
void (*md_transform)(void *ctx, const unsigned char *block);
|
||||
unsigned md_size, md_block_size = 64;
|
||||
unsigned sslv3_pad_length = 40, header_length, variance_blocks,
|
||||
len, max_mac_bytes, num_blocks,
|
||||
num_starting_blocks, k, mac_end_offset, c, index_a, index_b;
|
||||
unsigned int bits; /* at most 18 bits */
|
||||
unsigned char length_bytes[MAX_HASH_BIT_COUNT_BYTES];
|
||||
/* hmac_pad is the masked HMAC key. */
|
||||
unsigned char hmac_pad[MAX_HASH_BLOCK_SIZE];
|
||||
unsigned char first_block[MAX_HASH_BLOCK_SIZE];
|
||||
unsigned char mac_out[EVP_MAX_MD_SIZE];
|
||||
unsigned i, j, md_out_size_u;
|
||||
EVP_MD_CTX md_ctx;
|
||||
/* mdLengthSize is the number of bytes in the length field that terminates
|
||||
* the hash. */
|
||||
unsigned md_length_size = 8;
|
||||
|
||||
/* This is a, hopefully redundant, check that allows us to forget about
|
||||
* many possible overflows later in this function. */
|
||||
OPENSSL_assert(data_plus_mac_plus_padding_size < 1024*1024);
|
||||
|
||||
switch (ctx->digest->type)
|
||||
{
|
||||
case NID_md5:
|
||||
MD5_Init((MD5_CTX*)md_state.c);
|
||||
md_final_raw = tls1_md5_final_raw;
|
||||
md_transform = (void(*)(void *ctx, const unsigned char *block)) MD5_Transform;
|
||||
md_size = 16;
|
||||
sslv3_pad_length = 48;
|
||||
break;
|
||||
case NID_sha1:
|
||||
SHA1_Init((SHA_CTX*)md_state.c);
|
||||
md_final_raw = tls1_sha1_final_raw;
|
||||
md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA1_Transform;
|
||||
md_size = 20;
|
||||
break;
|
||||
#ifndef OPENSSL_NO_SHA256
|
||||
case NID_sha224:
|
||||
SHA224_Init((SHA256_CTX*)md_state.c);
|
||||
md_final_raw = tls1_sha256_final_raw;
|
||||
md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA256_Transform;
|
||||
md_size = 224/8;
|
||||
break;
|
||||
case NID_sha256:
|
||||
SHA256_Init((SHA256_CTX*)md_state.c);
|
||||
md_final_raw = tls1_sha256_final_raw;
|
||||
md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA256_Transform;
|
||||
md_size = 32;
|
||||
break;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SHA512
|
||||
case NID_sha384:
|
||||
SHA384_Init((SHA512_CTX*)md_state.c);
|
||||
md_final_raw = tls1_sha512_final_raw;
|
||||
md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA512_Transform;
|
||||
md_size = 384/8;
|
||||
md_block_size = 128;
|
||||
md_length_size = 16;
|
||||
break;
|
||||
case NID_sha512:
|
||||
SHA512_Init((SHA512_CTX*)md_state.c);
|
||||
md_final_raw = tls1_sha512_final_raw;
|
||||
md_transform = (void(*)(void *ctx, const unsigned char *block)) SHA512_Transform;
|
||||
md_size = 64;
|
||||
md_block_size = 128;
|
||||
md_length_size = 16;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* ssl3_cbc_record_digest_supported should have been
|
||||
* called first to check that the hash function is
|
||||
* supported. */
|
||||
OPENSSL_assert(0);
|
||||
if (md_out_size)
|
||||
*md_out_size = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
OPENSSL_assert(md_length_size <= MAX_HASH_BIT_COUNT_BYTES);
|
||||
OPENSSL_assert(md_block_size <= MAX_HASH_BLOCK_SIZE);
|
||||
OPENSSL_assert(md_size <= EVP_MAX_MD_SIZE);
|
||||
|
||||
header_length = 13;
|
||||
if (is_sslv3)
|
||||
{
|
||||
header_length =
|
||||
mac_secret_length +
|
||||
sslv3_pad_length +
|
||||
8 /* sequence number */ +
|
||||
1 /* record type */ +
|
||||
2 /* record length */;
|
||||
}
|
||||
|
||||
/* variance_blocks is the number of blocks of the hash that we have to
|
||||
* calculate in constant time because they could be altered by the
|
||||
* padding value.
|
||||
*
|
||||
* In SSLv3, the padding must be minimal so the end of the plaintext
|
||||
* varies by, at most, 15+20 = 35 bytes. (We conservatively assume that
|
||||
* the MAC size varies from 0..20 bytes.) In case the 9 bytes of hash
|
||||
* termination (0x80 + 64-bit length) don't fit in the final block, we
|
||||
* say that the final two blocks can vary based on the padding.
|
||||
*
|
||||
* TLSv1 has MACs up to 48 bytes long (SHA-384) and the padding is not
|
||||
* required to be minimal. Therefore we say that the final six blocks
|
||||
* can vary based on the padding.
|
||||
*
|
||||
* Later in the function, if the message is short and there obviously
|
||||
* cannot be this many blocks then variance_blocks can be reduced. */
|
||||
variance_blocks = is_sslv3 ? 2 : 6;
|
||||
/* From now on we're dealing with the MAC, which conceptually has 13
|
||||
* bytes of `header' before the start of the data (TLS) or 71/75 bytes
|
||||
* (SSLv3) */
|
||||
len = data_plus_mac_plus_padding_size + header_length;
|
||||
/* max_mac_bytes contains the maximum bytes of bytes in the MAC, including
|
||||
* |header|, assuming that there's no padding. */
|
||||
max_mac_bytes = len - md_size - 1;
|
||||
/* num_blocks is the maximum number of hash blocks. */
|
||||
num_blocks = (max_mac_bytes + 1 + md_length_size + md_block_size - 1) / md_block_size;
|
||||
/* In order to calculate the MAC in constant time we have to handle
|
||||
* the final blocks specially because the padding value could cause the
|
||||
* end to appear somewhere in the final |variance_blocks| blocks and we
|
||||
* can't leak where. However, |num_starting_blocks| worth of data can
|
||||
* be hashed right away because no padding value can affect whether
|
||||
* they are plaintext. */
|
||||
num_starting_blocks = 0;
|
||||
/* k is the starting byte offset into the conceptual header||data where
|
||||
* we start processing. */
|
||||
k = 0;
|
||||
/* mac_end_offset is the index just past the end of the data to be
|
||||
* MACed. */
|
||||
mac_end_offset = data_plus_mac_size + header_length - md_size;
|
||||
/* c is the index of the 0x80 byte in the final hash block that
|
||||
* contains application data. */
|
||||
c = mac_end_offset % md_block_size;
|
||||
/* index_a is the hash block number that contains the 0x80 terminating
|
||||
* value. */
|
||||
index_a = mac_end_offset / md_block_size;
|
||||
/* index_b is the hash block number that contains the 64-bit hash
|
||||
* length, in bits. */
|
||||
index_b = (mac_end_offset + md_length_size) / md_block_size;
|
||||
/* bits is the hash-length in bits. It includes the additional hash
|
||||
* block for the masked HMAC key, or whole of |header| in the case of
|
||||
* SSLv3. */
|
||||
|
||||
/* For SSLv3, if we're going to have any starting blocks then we need
|
||||
* at least two because the header is larger than a single block. */
|
||||
if (num_blocks > variance_blocks + (is_sslv3 ? 1 : 0))
|
||||
{
|
||||
num_starting_blocks = num_blocks - variance_blocks;
|
||||
k = md_block_size*num_starting_blocks;
|
||||
}
|
||||
|
||||
bits = 8*mac_end_offset;
|
||||
if (!is_sslv3)
|
||||
{
|
||||
/* Compute the initial HMAC block. For SSLv3, the padding and
|
||||
* secret bytes are included in |header| because they take more
|
||||
* than a single block. */
|
||||
bits += 8*md_block_size;
|
||||
memset(hmac_pad, 0, md_block_size);
|
||||
OPENSSL_assert(mac_secret_length <= sizeof(hmac_pad));
|
||||
memcpy(hmac_pad, mac_secret, mac_secret_length);
|
||||
for (i = 0; i < md_block_size; i++)
|
||||
hmac_pad[i] ^= 0x36;
|
||||
|
||||
md_transform(md_state.c, hmac_pad);
|
||||
}
|
||||
|
||||
memset(length_bytes,0,md_length_size-4);
|
||||
length_bytes[md_length_size-4] = (unsigned char)(bits>>24);
|
||||
length_bytes[md_length_size-3] = (unsigned char)(bits>>16);
|
||||
length_bytes[md_length_size-2] = (unsigned char)(bits>>8);
|
||||
length_bytes[md_length_size-1] = (unsigned char)bits;
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
if (is_sslv3)
|
||||
{
|
||||
/* The SSLv3 header is larger than a single block.
|
||||
* overhang is the number of bytes beyond a single
|
||||
* block that the header consumes: either 7 bytes
|
||||
* (SHA1) or 11 bytes (MD5). */
|
||||
unsigned overhang = header_length-md_block_size;
|
||||
md_transform(md_state.c, header);
|
||||
memcpy(first_block, header + md_block_size, overhang);
|
||||
memcpy(first_block + overhang, data, md_block_size-overhang);
|
||||
md_transform(md_state.c, first_block);
|
||||
for (i = 1; i < k/md_block_size - 1; i++)
|
||||
md_transform(md_state.c, data + md_block_size*i - overhang);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* k is a multiple of md_block_size. */
|
||||
memcpy(first_block, header, 13);
|
||||
memcpy(first_block+13, data, md_block_size-13);
|
||||
md_transform(md_state.c, first_block);
|
||||
for (i = 1; i < k/md_block_size; i++)
|
||||
md_transform(md_state.c, data + md_block_size*i - 13);
|
||||
}
|
||||
}
|
||||
|
||||
memset(mac_out, 0, sizeof(mac_out));
|
||||
|
||||
/* We now process the final hash blocks. For each block, we construct
|
||||
* it in constant time. If the |i==index_a| then we'll include the 0x80
|
||||
* bytes and zero pad etc. For each block we selectively copy it, in
|
||||
* constant time, to |mac_out|. */
|
||||
for (i = num_starting_blocks; i <= num_starting_blocks+variance_blocks; i++)
|
||||
{
|
||||
unsigned char block[MAX_HASH_BLOCK_SIZE];
|
||||
unsigned char is_block_a = constant_time_eq_8(i, index_a);
|
||||
unsigned char is_block_b = constant_time_eq_8(i, index_b);
|
||||
for (j = 0; j < md_block_size; j++)
|
||||
{
|
||||
unsigned char b = 0, is_past_c, is_past_cp1;
|
||||
if (k < header_length)
|
||||
b = header[k];
|
||||
else if (k < data_plus_mac_plus_padding_size + header_length)
|
||||
b = data[k-header_length];
|
||||
k++;
|
||||
|
||||
is_past_c = is_block_a & constant_time_ge(j, c);
|
||||
is_past_cp1 = is_block_a & constant_time_ge(j, c+1);
|
||||
/* If this is the block containing the end of the
|
||||
* application data, and we are at the offset for the
|
||||
* 0x80 value, then overwrite b with 0x80. */
|
||||
b = (b&~is_past_c) | (0x80&is_past_c);
|
||||
/* If this the the block containing the end of the
|
||||
* application data and we're past the 0x80 value then
|
||||
* just write zero. */
|
||||
b = b&~is_past_cp1;
|
||||
/* If this is index_b (the final block), but not
|
||||
* index_a (the end of the data), then the 64-bit
|
||||
* length didn't fit into index_a and we're having to
|
||||
* add an extra block of zeros. */
|
||||
b &= ~is_block_b | is_block_a;
|
||||
|
||||
/* The final bytes of one of the blocks contains the
|
||||
* length. */
|
||||
if (j >= md_block_size - md_length_size)
|
||||
{
|
||||
/* If this is index_b, write a length byte. */
|
||||
b = (b&~is_block_b) | (is_block_b&length_bytes[j-(md_block_size-md_length_size)]);
|
||||
}
|
||||
block[j] = b;
|
||||
}
|
||||
|
||||
md_transform(md_state.c, block);
|
||||
md_final_raw(md_state.c, block);
|
||||
/* If this is index_b, copy the hash value to |mac_out|. */
|
||||
for (j = 0; j < md_size; j++)
|
||||
mac_out[j] |= block[j]&is_block_b;
|
||||
}
|
||||
|
||||
EVP_MD_CTX_init(&md_ctx);
|
||||
EVP_DigestInit_ex(&md_ctx, ctx->digest, NULL /* engine */);
|
||||
if (is_sslv3)
|
||||
{
|
||||
/* We repurpose |hmac_pad| to contain the SSLv3 pad2 block. */
|
||||
memset(hmac_pad, 0x5c, sslv3_pad_length);
|
||||
|
||||
EVP_DigestUpdate(&md_ctx, mac_secret, mac_secret_length);
|
||||
EVP_DigestUpdate(&md_ctx, hmac_pad, sslv3_pad_length);
|
||||
EVP_DigestUpdate(&md_ctx, mac_out, md_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Complete the HMAC in the standard manner. */
|
||||
for (i = 0; i < md_block_size; i++)
|
||||
hmac_pad[i] ^= 0x6a;
|
||||
|
||||
EVP_DigestUpdate(&md_ctx, hmac_pad, md_block_size);
|
||||
EVP_DigestUpdate(&md_ctx, mac_out, md_size);
|
||||
}
|
||||
EVP_DigestFinal(&md_ctx, md_out, &md_out_size_u);
|
||||
if (md_out_size)
|
||||
*md_out_size = md_out_size_u;
|
||||
EVP_MD_CTX_cleanup(&md_ctx);
|
||||
}
|
@@ -280,7 +280,16 @@ int ssl3_connect(SSL *s)
|
||||
if (ret <= 0) goto end;
|
||||
|
||||
if (s->hit)
|
||||
{
|
||||
s->state=SSL3_ST_CR_FINISHED_A;
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
if (s->tlsext_ticket_expected)
|
||||
{
|
||||
/* receive renewed session ticket */
|
||||
s->state=SSL3_ST_CR_SESSION_TICKET_A;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
s->state=SSL3_ST_CR_CERT_A;
|
||||
s->init_num=0;
|
||||
|
113
ssl/s3_enc.c
113
ssl/s3_enc.c
@@ -465,12 +465,21 @@ void ssl3_cleanup_key_block(SSL *s)
|
||||
s->s3->tmp.key_block_length=0;
|
||||
}
|
||||
|
||||
/* ssl3_enc encrypts/decrypts the record in |s->wrec| / |s->rrec|, respectively.
|
||||
*
|
||||
* Returns:
|
||||
* 0: (in non-constant time) if the record is publically invalid (i.e. too
|
||||
* short etc).
|
||||
* 1: if the record's padding is valid / the encryption was successful.
|
||||
* -1: if the record's padding is invalid or, if sending, an internal error
|
||||
* occured.
|
||||
*/
|
||||
int ssl3_enc(SSL *s, int send)
|
||||
{
|
||||
SSL3_RECORD *rec;
|
||||
EVP_CIPHER_CTX *ds;
|
||||
unsigned long l;
|
||||
int bs,i;
|
||||
int bs,i,mac_size=0;
|
||||
const EVP_CIPHER *enc;
|
||||
|
||||
if (send)
|
||||
@@ -521,32 +530,16 @@ int ssl3_enc(SSL *s, int send)
|
||||
if (!send)
|
||||
{
|
||||
if (l == 0 || l%bs != 0)
|
||||
{
|
||||
SSLerr(SSL_F_SSL3_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
|
||||
ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED);
|
||||
return 0;
|
||||
}
|
||||
/* otherwise, rec->length >= bs */
|
||||
}
|
||||
|
||||
EVP_Cipher(ds,rec->data,rec->input,l);
|
||||
|
||||
if (EVP_MD_CTX_md(s->read_hash) != NULL)
|
||||
mac_size = EVP_MD_CTX_size(s->read_hash);
|
||||
if ((bs != 1) && !send)
|
||||
{
|
||||
i=rec->data[l-1]+1;
|
||||
/* SSL 3.0 bounds the number of padding bytes by the block size;
|
||||
* padding bytes (except the last one) are arbitrary */
|
||||
if (i > bs)
|
||||
{
|
||||
/* Incorrect padding. SSLerr() and ssl3_alert are done
|
||||
* by caller: we don't want to reveal whether this is
|
||||
* a decryption error or a MAC verification failure
|
||||
* (see http://www.openssl.org/~bodo/tls-cbc.txt) */
|
||||
return -1;
|
||||
}
|
||||
/* now i <= bs <= rec->length */
|
||||
rec->length-=i;
|
||||
}
|
||||
return ssl3_cbc_remove_padding(s, rec, bs, mac_size);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
@@ -704,7 +697,7 @@ int n_ssl3_mac(SSL *ssl, unsigned char *md, int send)
|
||||
EVP_MD_CTX md_ctx;
|
||||
const EVP_MD_CTX *hash;
|
||||
unsigned char *p,rec_char;
|
||||
unsigned int md_size;
|
||||
size_t md_size;
|
||||
int npad;
|
||||
int t;
|
||||
|
||||
@@ -729,28 +722,68 @@ int n_ssl3_mac(SSL *ssl, unsigned char *md, int send)
|
||||
md_size=t;
|
||||
npad=(48/md_size)*md_size;
|
||||
|
||||
/* Chop the digest off the end :-) */
|
||||
EVP_MD_CTX_init(&md_ctx);
|
||||
if (!send &&
|
||||
EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE &&
|
||||
ssl3_cbc_record_digest_supported(hash))
|
||||
{
|
||||
/* This is a CBC-encrypted record. We must avoid leaking any
|
||||
* timing-side channel information about how many blocks of
|
||||
* data we are hashing because that gives an attacker a
|
||||
* timing-oracle. */
|
||||
|
||||
EVP_MD_CTX_copy_ex( &md_ctx,hash);
|
||||
EVP_DigestUpdate(&md_ctx,mac_sec,md_size);
|
||||
EVP_DigestUpdate(&md_ctx,ssl3_pad_1,npad);
|
||||
EVP_DigestUpdate(&md_ctx,seq,8);
|
||||
rec_char=rec->type;
|
||||
EVP_DigestUpdate(&md_ctx,&rec_char,1);
|
||||
p=md;
|
||||
s2n(rec->length,p);
|
||||
EVP_DigestUpdate(&md_ctx,md,2);
|
||||
EVP_DigestUpdate(&md_ctx,rec->input,rec->length);
|
||||
EVP_DigestFinal_ex( &md_ctx,md,NULL);
|
||||
/* npad is, at most, 48 bytes and that's with MD5:
|
||||
* 16 + 48 + 8 (sequence bytes) + 1 + 2 = 75.
|
||||
*
|
||||
* With SHA-1 (the largest hash speced for SSLv3) the hash size
|
||||
* goes up 4, but npad goes down by 8, resulting in a smaller
|
||||
* total size. */
|
||||
unsigned char header[75];
|
||||
unsigned j = 0;
|
||||
memcpy(header+j, mac_sec, md_size);
|
||||
j += md_size;
|
||||
memcpy(header+j, ssl3_pad_1, npad);
|
||||
j += npad;
|
||||
memcpy(header+j, seq, 8);
|
||||
j += 8;
|
||||
header[j++] = rec->type;
|
||||
header[j++] = rec->length >> 8;
|
||||
header[j++] = rec->length & 0xff;
|
||||
|
||||
EVP_MD_CTX_copy_ex( &md_ctx,hash);
|
||||
EVP_DigestUpdate(&md_ctx,mac_sec,md_size);
|
||||
EVP_DigestUpdate(&md_ctx,ssl3_pad_2,npad);
|
||||
EVP_DigestUpdate(&md_ctx,md,md_size);
|
||||
EVP_DigestFinal_ex( &md_ctx,md,&md_size);
|
||||
ssl3_cbc_digest_record(
|
||||
hash,
|
||||
md, &md_size,
|
||||
header, rec->input,
|
||||
rec->length + md_size, rec->orig_len,
|
||||
mac_sec, md_size,
|
||||
1 /* is SSLv3 */);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int md_size_u;
|
||||
/* Chop the digest off the end :-) */
|
||||
EVP_MD_CTX_init(&md_ctx);
|
||||
|
||||
EVP_MD_CTX_cleanup(&md_ctx);
|
||||
EVP_MD_CTX_copy_ex( &md_ctx,hash);
|
||||
EVP_DigestUpdate(&md_ctx,mac_sec,md_size);
|
||||
EVP_DigestUpdate(&md_ctx,ssl3_pad_1,npad);
|
||||
EVP_DigestUpdate(&md_ctx,seq,8);
|
||||
rec_char=rec->type;
|
||||
EVP_DigestUpdate(&md_ctx,&rec_char,1);
|
||||
p=md;
|
||||
s2n(rec->length,p);
|
||||
EVP_DigestUpdate(&md_ctx,md,2);
|
||||
EVP_DigestUpdate(&md_ctx,rec->input,rec->length);
|
||||
EVP_DigestFinal_ex( &md_ctx,md,NULL);
|
||||
|
||||
EVP_MD_CTX_copy_ex( &md_ctx,hash);
|
||||
EVP_DigestUpdate(&md_ctx,mac_sec,md_size);
|
||||
EVP_DigestUpdate(&md_ctx,ssl3_pad_2,npad);
|
||||
EVP_DigestUpdate(&md_ctx,md,md_size);
|
||||
EVP_DigestFinal_ex( &md_ctx,md,&md_size_u);
|
||||
md_size = md_size_u;
|
||||
|
||||
EVP_MD_CTX_cleanup(&md_ctx);
|
||||
}
|
||||
|
||||
ssl3_record_sequence_update(seq);
|
||||
return(md_size);
|
||||
|
100
ssl/s3_pkt.c
100
ssl/s3_pkt.c
@@ -289,11 +289,8 @@ static int ssl3_get_record(SSL *s)
|
||||
unsigned char *p;
|
||||
unsigned char md[EVP_MAX_MD_SIZE];
|
||||
short version;
|
||||
int mac_size;
|
||||
int clear=0;
|
||||
unsigned mac_size;
|
||||
size_t extra;
|
||||
int decryption_failed_or_bad_record_mac = 0;
|
||||
unsigned char *mac = NULL;
|
||||
|
||||
rr= &(s->s3->rrec);
|
||||
sess=s->session;
|
||||
@@ -400,19 +397,18 @@ fprintf(stderr, "Record type=%d, Length=%d\n", rr->type, rr->length);
|
||||
|
||||
/* decrypt in place in 'rr->input' */
|
||||
rr->data=rr->input;
|
||||
rr->orig_len=rr->length;
|
||||
|
||||
enc_err = s->method->ssl3_enc->enc(s,0);
|
||||
if (enc_err <= 0)
|
||||
/* enc_err is:
|
||||
* 0: (in non-constant time) if the record is publically invalid.
|
||||
* 1: if the padding is valid
|
||||
* -1: if the padding is invalid */
|
||||
if (enc_err == 0)
|
||||
{
|
||||
if (enc_err == 0)
|
||||
/* SSLerr() and ssl3_send_alert() have been called */
|
||||
goto err;
|
||||
|
||||
/* Otherwise enc_err == -1, which indicates bad padding
|
||||
* (rec->length has not been changed in this case).
|
||||
* To minimize information leaked via timing, we will perform
|
||||
* the MAC computation anyway. */
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
al=SSL_AD_DECRYPTION_FAILED;
|
||||
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
|
||||
goto f_err;
|
||||
}
|
||||
|
||||
#ifdef TLS_DEBUG
|
||||
@@ -422,53 +418,59 @@ printf("\n");
|
||||
#endif
|
||||
|
||||
/* r->length is now the compressed data plus mac */
|
||||
if ( (sess == NULL) ||
|
||||
(s->enc_read_ctx == NULL) ||
|
||||
(EVP_MD_CTX_md(s->read_hash) == NULL))
|
||||
clear=1;
|
||||
|
||||
if (!clear)
|
||||
if ((sess != NULL) &&
|
||||
(s->enc_read_ctx != NULL) &&
|
||||
(EVP_MD_CTX_md(s->read_hash) != NULL))
|
||||
{
|
||||
/* !clear => s->read_hash != NULL => mac_size != -1 */
|
||||
/* s->read_hash != NULL => mac_size != -1 */
|
||||
unsigned char *mac = NULL;
|
||||
unsigned char mac_tmp[EVP_MAX_MD_SIZE];
|
||||
mac_size=EVP_MD_CTX_size(s->read_hash);
|
||||
OPENSSL_assert(mac_size >= 0);
|
||||
OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);
|
||||
|
||||
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size)
|
||||
/* orig_len is the length of the record before any padding was
|
||||
* removed. This is public information, as is the MAC in use,
|
||||
* therefore we can safely process the record in a different
|
||||
* amount of time if it's too short to possibly contain a MAC.
|
||||
*/
|
||||
if (rr->orig_len < mac_size ||
|
||||
/* CBC records must have a padding length byte too. */
|
||||
(EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE &&
|
||||
rr->orig_len < mac_size+1))
|
||||
{
|
||||
#if 0 /* OK only for stream ciphers (then rr->length is visible from ciphertext anyway) */
|
||||
al=SSL_AD_RECORD_OVERFLOW;
|
||||
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
|
||||
goto f_err;
|
||||
#else
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
#endif
|
||||
}
|
||||
/* check the MAC for rr->input (it's in mac_size bytes at the tail) */
|
||||
if (rr->length >= (unsigned int)mac_size)
|
||||
{
|
||||
rr->length -= mac_size;
|
||||
mac = &rr->data[rr->length];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* record (minus padding) is too short to contain a MAC */
|
||||
#if 0 /* OK only for stream ciphers */
|
||||
al=SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT);
|
||||
goto f_err;
|
||||
#else
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
rr->length = 0;
|
||||
#endif
|
||||
}
|
||||
i=s->method->ssl3_enc->mac(s,md,0);
|
||||
if (i < 0 || mac == NULL || memcmp(md, mac, (size_t)mac_size) != 0)
|
||||
|
||||
if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE)
|
||||
{
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
/* We update the length so that the TLS header bytes
|
||||
* can be constructed correctly but we need to extract
|
||||
* the MAC in constant time from within the record,
|
||||
* without leaking the contents of the padding bytes.
|
||||
* */
|
||||
mac = mac_tmp;
|
||||
ssl3_cbc_copy_mac(mac_tmp, rr, mac_size);
|
||||
rr->length -= mac_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In this case there's no padding, so |rec->orig_len|
|
||||
* equals |rec->length| and we checked that there's
|
||||
* enough bytes for |mac_size| above. */
|
||||
rr->length -= mac_size;
|
||||
mac = &rr->data[rr->length];
|
||||
}
|
||||
|
||||
i=s->method->ssl3_enc->mac(s,md,0 /* not send */);
|
||||
if (i < 0 || mac == NULL || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)
|
||||
enc_err = -1;
|
||||
if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size)
|
||||
enc_err = -1;
|
||||
}
|
||||
|
||||
if (decryption_failed_or_bad_record_mac)
|
||||
if (enc_err < 0)
|
||||
{
|
||||
/* A separate 'decryption_failed' alert was introduced with TLS 1.0,
|
||||
* SSL 3.0 only has 'bad_record_mac'. But unless a decryption
|
||||
|
@@ -1063,7 +1063,7 @@ int ssl3_get_client_hello(SSL *s)
|
||||
goto f_err;
|
||||
}
|
||||
}
|
||||
if (ssl_check_clienthello_tlsext(s) <= 0) {
|
||||
if (ssl_check_clienthello_tlsext_early(s) <= 0) {
|
||||
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT);
|
||||
goto err;
|
||||
}
|
||||
@@ -1282,6 +1282,16 @@ int ssl3_get_client_hello(SSL *s)
|
||||
* s->tmp.new_cipher - the new cipher to use.
|
||||
*/
|
||||
|
||||
/* Handles TLS extensions that we couldn't check earlier */
|
||||
if (s->version >= SSL3_VERSION)
|
||||
{
|
||||
if (ssl_check_clienthello_tlsext_late(s) <= 0)
|
||||
{
|
||||
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret < 0) ret=1;
|
||||
if (0)
|
||||
{
|
||||
@@ -2728,7 +2738,7 @@ int ssl3_get_cert_verify(SSL *s)
|
||||
if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_VERIFY)
|
||||
{
|
||||
s->s3->tmp.reuse_message=1;
|
||||
if ((peer != NULL) && (type | EVP_PKT_SIGN))
|
||||
if ((peer != NULL) && (type & EVP_PKT_SIGN))
|
||||
{
|
||||
al=SSL_AD_UNEXPECTED_MESSAGE;
|
||||
SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_MISSING_VERIFY_MESSAGE);
|
||||
|
@@ -1968,6 +1968,7 @@ void ERR_load_SSL_strings(void);
|
||||
#define SSL_F_SSL_GET_NEW_SESSION 181
|
||||
#define SSL_F_SSL_GET_PREV_SESSION 217
|
||||
#define SSL_F_SSL_GET_SERVER_SEND_CERT 182
|
||||
#define SSL_F_SSL_GET_SERVER_SEND_PKEY 317
|
||||
#define SSL_F_SSL_GET_SIGN_PKEY 183
|
||||
#define SSL_F_SSL_INIT_WBIO_BUFFER 184
|
||||
#define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185
|
||||
|
@@ -349,6 +349,10 @@ typedef struct ssl3_record_st
|
||||
/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */
|
||||
/*r */ unsigned long epoch; /* epoch number, needed by DTLS1 */
|
||||
/*r */ unsigned char seq_num[8]; /* sequence number, needed by DTLS1 */
|
||||
/*rw*/ unsigned int orig_len; /* How many bytes were available before padding
|
||||
was removed? This is used to implement the
|
||||
MAC check in constant time for CBC records.
|
||||
*/
|
||||
} SSL3_RECORD;
|
||||
|
||||
typedef struct ssl3_buffer_st
|
||||
|
@@ -86,6 +86,7 @@ int SSL_library_init(void)
|
||||
EVP_add_cipher(EVP_aes_192_cbc());
|
||||
EVP_add_cipher(EVP_aes_256_cbc());
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
EVP_add_cipher(EVP_camellia_128_cbc());
|
||||
EVP_add_cipher(EVP_camellia_256_cbc());
|
||||
|
@@ -223,6 +223,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
||||
{ERR_FUNC(SSL_F_SSL_GET_NEW_SESSION), "SSL_GET_NEW_SESSION"},
|
||||
{ERR_FUNC(SSL_F_SSL_GET_PREV_SESSION), "SSL_GET_PREV_SESSION"},
|
||||
{ERR_FUNC(SSL_F_SSL_GET_SERVER_SEND_CERT), "SSL_GET_SERVER_SEND_CERT"},
|
||||
{ERR_FUNC(SSL_F_SSL_GET_SERVER_SEND_PKEY), "SSL_GET_SERVER_SEND_PKEY"},
|
||||
{ERR_FUNC(SSL_F_SSL_GET_SIGN_PKEY), "SSL_GET_SIGN_PKEY"},
|
||||
{ERR_FUNC(SSL_F_SSL_INIT_WBIO_BUFFER), "SSL_INIT_WBIO_BUFFER"},
|
||||
{ERR_FUNC(SSL_F_SSL_LOAD_CLIENT_CA_FILE), "SSL_load_client_CA_file"},
|
||||
|
@@ -2107,7 +2107,7 @@ int ssl_check_srvr_ecc_cert_and_alg(X509 *x, const SSL_CIPHER *cs)
|
||||
#endif
|
||||
|
||||
/* THIS NEEDS CLEANING UP */
|
||||
X509 *ssl_get_server_send_cert(SSL *s)
|
||||
CERT_PKEY *ssl_get_server_send_pkey(const SSL *s)
|
||||
{
|
||||
unsigned long alg_k,alg_a;
|
||||
CERT *c;
|
||||
@@ -2162,12 +2162,20 @@ X509 *ssl_get_server_send_cert(SSL *s)
|
||||
i=SSL_PKEY_GOST01;
|
||||
else /* if (alg_a & SSL_aNULL) */
|
||||
{
|
||||
SSLerr(SSL_F_SSL_GET_SERVER_SEND_CERT,ERR_R_INTERNAL_ERROR);
|
||||
SSLerr(SSL_F_SSL_GET_SERVER_SEND_PKEY,ERR_R_INTERNAL_ERROR);
|
||||
return(NULL);
|
||||
}
|
||||
if (c->pkeys[i].x509 == NULL) return(NULL);
|
||||
|
||||
return(c->pkeys[i].x509);
|
||||
return c->pkeys + i;
|
||||
}
|
||||
|
||||
X509 *ssl_get_server_send_cert(const SSL *s)
|
||||
{
|
||||
CERT_PKEY *cpk;
|
||||
cpk = ssl_get_server_send_pkey(s);
|
||||
if (!cpk)
|
||||
return NULL;
|
||||
return cpk->x509;
|
||||
}
|
||||
|
||||
EVP_PKEY *ssl_get_sign_pkey(SSL *s,const SSL_CIPHER *cipher)
|
||||
@@ -2593,7 +2601,9 @@ void ssl_clear_cipher_ctx(SSL *s)
|
||||
/* Fix this function so that it takes an optional type parameter */
|
||||
X509 *SSL_get_certificate(const SSL *s)
|
||||
{
|
||||
if (s->cert != NULL)
|
||||
if (s->server)
|
||||
return(ssl_get_server_send_cert(s));
|
||||
else if (s->cert != NULL)
|
||||
return(s->cert->key->x509);
|
||||
else
|
||||
return(NULL);
|
||||
|
@@ -215,6 +215,15 @@
|
||||
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l) )&0xff))
|
||||
|
||||
#define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>48)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>40)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>32)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>24)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>>16)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
|
||||
*((c)++)=(unsigned char)(((l) )&0xff))
|
||||
|
||||
#define n2l6(c,l) (l =((BN_ULLONG)(*((c)++)))<<40, \
|
||||
l|=((BN_ULLONG)(*((c)++)))<<32, \
|
||||
l|=((BN_ULLONG)(*((c)++)))<<24, \
|
||||
@@ -808,7 +817,8 @@ int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk);
|
||||
int ssl_undefined_function(SSL *s);
|
||||
int ssl_undefined_void_function(void);
|
||||
int ssl_undefined_const_function(const SSL *s);
|
||||
X509 *ssl_get_server_send_cert(SSL *);
|
||||
CERT_PKEY *ssl_get_server_send_pkey(const SSL *s);
|
||||
X509 *ssl_get_server_send_cert(const SSL *);
|
||||
EVP_PKEY *ssl_get_sign_pkey(SSL *,const SSL_CIPHER *);
|
||||
int ssl_cert_type(X509 *x,EVP_PKEY *pkey);
|
||||
void ssl_set_cert_masks(CERT *c, const SSL_CIPHER *cipher);
|
||||
@@ -1056,7 +1066,8 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **data, unsigned char *d,
|
||||
int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **data, unsigned char *d, int n, int *al);
|
||||
int ssl_prepare_clienthello_tlsext(SSL *s);
|
||||
int ssl_prepare_serverhello_tlsext(SSL *s);
|
||||
int ssl_check_clienthello_tlsext(SSL *s);
|
||||
int ssl_check_clienthello_tlsext_early(SSL *s);
|
||||
int ssl_check_clienthello_tlsext_late(SSL *s);
|
||||
int ssl_check_serverhello_tlsext(SSL *s);
|
||||
|
||||
#ifdef OPENSSL_NO_SHA256
|
||||
@@ -1077,4 +1088,29 @@ int ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p, int *len,
|
||||
int maxlen);
|
||||
int ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len,
|
||||
int *al);
|
||||
/* s3_cbc.c */
|
||||
void ssl3_cbc_copy_mac(unsigned char* out,
|
||||
const SSL3_RECORD *rec,
|
||||
unsigned md_size);
|
||||
int ssl3_cbc_remove_padding(const SSL* s,
|
||||
SSL3_RECORD *rec,
|
||||
unsigned block_size,
|
||||
unsigned mac_size);
|
||||
int tls1_cbc_remove_padding(const SSL* s,
|
||||
SSL3_RECORD *rec,
|
||||
unsigned block_size,
|
||||
unsigned mac_size);
|
||||
char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx);
|
||||
void ssl3_cbc_digest_record(
|
||||
const EVP_MD_CTX *ctx,
|
||||
unsigned char* md_out,
|
||||
size_t* md_out_size,
|
||||
const unsigned char header[13],
|
||||
const unsigned char *data,
|
||||
size_t data_plus_mac_size,
|
||||
size_t data_plus_mac_plus_padding_size,
|
||||
const unsigned char *mac_secret,
|
||||
unsigned mac_secret_length,
|
||||
char is_sslv3);
|
||||
|
||||
#endif
|
||||
|
138
ssl/t1_enc.c
138
ssl/t1_enc.c
@@ -350,7 +350,7 @@ int tls1_change_cipher_state(SSL *s, int which)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<s->s3->tmp.key_block_length; i++)
|
||||
printf("%02x", key_block[i]); printf("\n");
|
||||
printf("%02x", s->s3->tmp.key_block[i]); printf("\n");
|
||||
}
|
||||
#endif /* KSSL_DEBUG */
|
||||
|
||||
@@ -635,12 +635,22 @@ err:
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* tls1_enc encrypts/decrypts the record in |s->wrec| / |s->rrec|, respectively.
|
||||
*
|
||||
* Returns:
|
||||
* 0: (in non-constant time) if the record is publically invalid (i.e. too
|
||||
* short etc).
|
||||
* 1: if the record's padding is valid / the encryption was successful.
|
||||
* -1: if the record's padding/AEAD-authenticator is invalid or, if sending,
|
||||
* an internal error occured.
|
||||
*/
|
||||
int tls1_enc(SSL *s, int send)
|
||||
{
|
||||
SSL3_RECORD *rec;
|
||||
EVP_CIPHER_CTX *ds;
|
||||
unsigned long l;
|
||||
int bs,i,ii,j,k,n=0;
|
||||
int bs,i,j,k,pad=0,ret,mac_size=0;
|
||||
int n;
|
||||
const EVP_CIPHER *enc;
|
||||
|
||||
if (send)
|
||||
@@ -676,11 +686,11 @@ int tls1_enc(SSL *s, int send)
|
||||
printf("tls1_enc(%d)\n", send);
|
||||
#endif /* KSSL_DEBUG */
|
||||
|
||||
if ((s->session == NULL) || (ds == NULL) ||
|
||||
(enc == NULL))
|
||||
if ((s->session == NULL) || (ds == NULL) || (enc == NULL))
|
||||
{
|
||||
memmove(rec->data,rec->input,rec->length);
|
||||
rec->input=rec->data;
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -708,13 +718,13 @@ int tls1_enc(SSL *s, int send)
|
||||
|
||||
#ifdef KSSL_DEBUG
|
||||
{
|
||||
unsigned long ui;
|
||||
unsigned long ui;
|
||||
printf("EVP_Cipher(ds=%p,rec->data=%p,rec->input=%p,l=%ld) ==>\n",
|
||||
ds,rec->data,rec->input,l);
|
||||
ds,rec->data,rec->input,l);
|
||||
printf("\tEVP_CIPHER_CTX: %d buf_len, %d key_len [%d %d], %d iv_len\n",
|
||||
ds->buf_len, ds->cipher->key_len,
|
||||
DES_KEY_SZ, DES_SCHEDULE_SZ,
|
||||
ds->cipher->iv_len);
|
||||
ds->buf_len, ds->cipher->key_len,
|
||||
DES_KEY_SZ, DES_SCHEDULE_SZ,
|
||||
ds->cipher->iv_len);
|
||||
printf("\t\tIV: ");
|
||||
for (i=0; i<ds->cipher->iv_len; i++) printf("%02X", ds->iv[i]);
|
||||
printf("\n");
|
||||
@@ -727,68 +737,31 @@ int tls1_enc(SSL *s, int send)
|
||||
if (!send)
|
||||
{
|
||||
if (l == 0 || l%bs != 0)
|
||||
{
|
||||
SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
|
||||
ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
EVP_Cipher(ds,rec->data,rec->input,l);
|
||||
|
||||
#ifdef KSSL_DEBUG
|
||||
{
|
||||
unsigned long i;
|
||||
printf("\trec->data=");
|
||||
unsigned long i;
|
||||
printf("\trec->data=");
|
||||
for (i=0; i<l; i++)
|
||||
printf(" %02x", rec->data[i]); printf("\n");
|
||||
}
|
||||
printf(" %02x", rec->data[i]); printf("\n");
|
||||
}
|
||||
#endif /* KSSL_DEBUG */
|
||||
|
||||
ret = 1;
|
||||
if (EVP_MD_CTX_md(s->read_hash) != NULL)
|
||||
mac_size = EVP_MD_CTX_size(s->read_hash);
|
||||
if ((bs != 1) && !send)
|
||||
{
|
||||
ii=i=rec->data[l-1]; /* padding_length */
|
||||
i++;
|
||||
/* NB: if compression is in operation the first packet
|
||||
* may not be of even length so the padding bug check
|
||||
* cannot be performed. This bug workaround has been
|
||||
* around since SSLeay so hopefully it is either fixed
|
||||
* now or no buggy implementation supports compression
|
||||
* [steve]
|
||||
*/
|
||||
if ( (s->options&SSL_OP_TLS_BLOCK_PADDING_BUG)
|
||||
&& !s->expand)
|
||||
{
|
||||
/* First packet is even in size, so check */
|
||||
if ((memcmp(s->s3->read_sequence,
|
||||
"\0\0\0\0\0\0\0\0",8) == 0) && !(ii & 1))
|
||||
s->s3->flags|=TLS1_FLAGS_TLS_PADDING_BUG;
|
||||
if (s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG)
|
||||
i--;
|
||||
}
|
||||
/* TLS 1.0 does not bound the number of padding bytes by the block size.
|
||||
* All of them must have value 'padding_length'. */
|
||||
if (i > (int)rec->length)
|
||||
{
|
||||
/* Incorrect padding. SSLerr() and ssl3_alert are done
|
||||
* by caller: we don't want to reveal whether this is
|
||||
* a decryption error or a MAC verification failure
|
||||
* (see http://www.openssl.org/~bodo/tls-cbc.txt) */
|
||||
return -1;
|
||||
}
|
||||
for (j=(int)(l-i); j<(int)l; j++)
|
||||
{
|
||||
if (rec->data[j] != ii)
|
||||
{
|
||||
/* Incorrect padding */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
rec->length-=i;
|
||||
}
|
||||
ret = tls1_cbc_remove_padding(s, rec, bs, mac_size);
|
||||
if (pad && !send)
|
||||
rec->length -= pad;
|
||||
}
|
||||
return(1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int tls1_cert_verify_mac(SSL *s, int md_nid, unsigned char *out)
|
||||
{
|
||||
unsigned int ret;
|
||||
@@ -881,7 +854,7 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
|
||||
size_t md_size;
|
||||
int i;
|
||||
EVP_MD_CTX hmac, *mac_ctx;
|
||||
unsigned char buf[5];
|
||||
unsigned char header[13];
|
||||
int stream_mac = (send?(ssl->mac_flags & SSL_MAC_FLAG_WRITE_MAC_STREAM):(ssl->mac_flags&SSL_MAC_FLAG_READ_MAC_STREAM));
|
||||
int t;
|
||||
|
||||
@@ -902,12 +875,6 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
|
||||
OPENSSL_assert(t >= 0);
|
||||
md_size=t;
|
||||
|
||||
buf[0]=rec->type;
|
||||
buf[1]=(unsigned char)(ssl->version>>8);
|
||||
buf[2]=(unsigned char)(ssl->version);
|
||||
buf[3]=rec->length>>8;
|
||||
buf[4]=rec->length&0xff;
|
||||
|
||||
/* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */
|
||||
if (stream_mac)
|
||||
{
|
||||
@@ -926,17 +893,44 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
|
||||
s2n(send?ssl->d1->w_epoch:ssl->d1->r_epoch, p);
|
||||
memcpy (p,&seq[2],6);
|
||||
|
||||
EVP_DigestSignUpdate(mac_ctx,dtlsseq,8);
|
||||
memcpy(header, dtlsseq, 8);
|
||||
}
|
||||
else
|
||||
EVP_DigestSignUpdate(mac_ctx,seq,8);
|
||||
memcpy(header, seq, 8);
|
||||
|
||||
EVP_DigestSignUpdate(mac_ctx,buf,5);
|
||||
EVP_DigestSignUpdate(mac_ctx,rec->input,rec->length);
|
||||
t=EVP_DigestSignFinal(mac_ctx,md,&md_size);
|
||||
OPENSSL_assert(t > 0);
|
||||
header[8]=rec->type;
|
||||
header[9]=(unsigned char)(ssl->version>>8);
|
||||
header[10]=(unsigned char)(ssl->version);
|
||||
header[11]=(rec->length)>>8;
|
||||
header[12]=(rec->length)&0xff;
|
||||
|
||||
if (!send &&
|
||||
EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE &&
|
||||
ssl3_cbc_record_digest_supported(mac_ctx))
|
||||
{
|
||||
/* This is a CBC-encrypted record. We must avoid leaking any
|
||||
* timing-side channel information about how many blocks of
|
||||
* data we are hashing because that gives an attacker a
|
||||
* timing-oracle. */
|
||||
ssl3_cbc_digest_record(
|
||||
mac_ctx,
|
||||
md, &md_size,
|
||||
header, rec->input,
|
||||
rec->length + md_size, rec->orig_len,
|
||||
ssl->s3->read_mac_secret,
|
||||
ssl->s3->read_mac_secret_size,
|
||||
0 /* not SSLv3 */);
|
||||
}
|
||||
else
|
||||
{
|
||||
EVP_DigestSignUpdate(mac_ctx,header,sizeof(header));
|
||||
EVP_DigestSignUpdate(mac_ctx,rec->input,rec->length);
|
||||
t=EVP_DigestSignFinal(mac_ctx,md,&md_size);
|
||||
OPENSSL_assert(t > 0);
|
||||
}
|
||||
|
||||
if (!stream_mac) EVP_MD_CTX_cleanup(&hmac);
|
||||
if (!stream_mac)
|
||||
EVP_MD_CTX_cleanup(&hmac);
|
||||
#ifdef TLS_DEBUG
|
||||
printf("sec=");
|
||||
{unsigned int z; for (z=0; z<md_size; z++) printf("%02X ",mac_sec[z]); printf("\n"); }
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user