summaryrefslogtreecommitdiffstats
path: root/test/evp_test.c
AgeCommit message (Collapse)Author
2018-08-14Update copyright yearMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6954)
2018-07-02test/evp_test.c: address sanitizer errors in pderive_test_run.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6614)
2017-08-21evp_test.c: Add PrivPubKeyPair testNicola Tuveri
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3246)
2017-04-16Catch EC_R_UNKNOWN_GROUP in check_unsupported()Rich Salz
If EC support is enabled we should catch also EC_R_UNKNOWN_GROUP as an hint to an unsupported algorithm/curve (e.g. if binary EC support is disabled). Before this commit the issue arise for example if binary EC keys are added in evptests.txt, and the test is run when EC is enabled but EC2m is disabled. E.g. adding these lines to evptests.txt would reproduce the issue: ~~~ PrivateKey=KAS-ECC-CDH_K-163_C0 -----BEGIN PRIVATE KEY----- MGMCAQAwEAYHKoZIzj0CAQYFK4EEAAEETDBKAgEBBBUAZlO2B3OY+tx79eYBWBcB SMPcRSehLgMsAAQHH4sod9YCfZwa3kJE8t6hJpLvI9UFwV7ndiIccrhLNHzjg/OA Z7icPpo= -----END PRIVATE KEY----- PublicKey=KAS-ECC-CDH_K-163_C0-PUBLIC -----BEGIN PUBLIC KEY----- MEAwEAYHKoZIzj0CAQYFK4EEAAEDLAAEBx+LKHfWAn2cGt5CRPLeoSaS7yPVBcFe 53YiHHK4SzR844PzgGe4nD6a -----END PUBLIC KEY----- PublicKey=KAS-ECC-CDH_K-163_C0-Peer-PUBLIC -----BEGIN PUBLIC KEY----- MEAwEAYHKoZIzj0CAQYFK4EEAAEDLAAEBXQjbxQoxDITCUZ4Ols6q7bCfqXWB5CM JRuNoCHLrCgfEj969PrFs9u4 -----END PUBLIC KEY----- Derive=KAS-ECC-CDH_K-163_C0 PeerKey=KAS-ECC-CDH_K-163_C0-Peer-PUBLIC Ctrl=ecdh_cofactor_mode:1 SharedSecret=04325bff38f1b0c83c27f554a6c972a80f14bc23bc ~~~ Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3226) (cherry picked from commit 0c44545c0f5781b1d2401b0d3c93c0376399c8e5)
2017-03-17Fixed PKCS5_PBKDF2_HMAC() to adhere to the documentation.Péter Budai
The documentation of this function states that the password parameter can be NULL. However, the implementation returns an error in this case due to the inner workings of the HMAC_Init_ex() function. With this change, NULL password will be treated as an empty string and PKCS5_PBKDF2_HMAC() no longer fails on this input. I have also added two new test cases that tests the handling of the special values NULL and -1 of the password and passlen parameters, respectively. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1692) (cherry picked from commit fa013b65241dfed9b7d9e10e0adfedc9869c797e)
2017-01-29test/evp_test.c: If no algorithm was specified, don't try to check for DESRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2319) (cherry picked from commit 31b69e9a26c5b127ce273bc5834b9e13e5e25556)
2017-01-25Adjust in and in_len instead of donelenMatt Caswell
Don't use the temp variable donelen in the non-aad fragmented code path. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2275) (cherry picked from commit ef055ec536a3c6e698dd9f45b41d57a32366b4fa)
2017-01-25Fix the overlapping check for fragmented "Update" operationsMatt Caswell
When doing in place encryption the overlapping buffer check can fail incorrectly where we have done a partial block "Update" operation. This fixes things to take account of any pending partial blocks. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2275) (cherry picked from commit 7141ba31969d0b378d08104a51f8f99b9187b9d5)
2017-01-25Update evp_test to make sure passing partial block to "Update" is okMatt Caswell
The previous commit fixed a bug where a partial block had been passed to an "Update" function and it wasn't properly handled. We should catch this type of error in evp_test. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2275) (cherry picked from commit 0b96d77a62d8ac9a45ac1dda47560ced676b5b8d)
2017-01-05Remove BIO_seek/BIO_tell from evp_test.cDr. Stephen Henson
BIO_seek and BIO_tell can cause problems with evp_test.c on some platforms. Avoid them by using a temporary memory BIO to store key PEM data. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2183) (cherry picked from commit 71f60ef3376144885384f2b1b3f00c3d54806f38)
2016-12-16evp_test: when function and reason strings aren't available, just skipRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2093) (cherry picked from commit cd3fe0e09c97700005ed96c8113907cbdfc45edf)
2016-12-14Add function and reason checking to evp_testDr. Stephen Henson
Add options to check the function and reason code matches expected values. Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit 99f2f1dc3e5c95961f57ca41e9fbb76863e69e46)
2016-12-10Additional error tests in evp_test.cDr. Stephen Henson
Support checking for errors during test initialisation and parsing. Add errors and tests for key operation initalisation and ctrl errors. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit cce65266299e2e89303a90c131e8171225a1bf88)
2016-11-20Skipping tests in evp_test leaks memoryTodd Short
When configured with "no-mdc2 enable-crypto-mdebug" the evp_test will leak memory due to skipped tests, and error out. Also fix a skip condition Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1946)
2016-11-10Fix the evp_test Ctrl keyword processingRichard Levitte
Skip the test if the value after ":" is a disabled algorithm, rather than failing it Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit dfbdf4abb7c62156f36925db95728142c4223225)
2016-08-12Check for bad filename in evp_testRich Salz
Thanks to Brian Carpter for reporting this. Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2016-05-17Copyright consolidation 02/10Rich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-16test/evp_test.c: exercise in-place encryption.Andy Polyakov
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-05-06test/evp_test.c: exercise different combinations of data misalignment.Andy Polyakov
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-04-18Make string_to_hex/hex_to_string publicRich Salz
Give the API new names, document it. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-07test/[dane|evp_]test.c: BIO-fy file I/O.Andy Polyakov
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-03-21Fix no-scryptMatt Caswell
Fix the evp tests when no-scrypt is used. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-03-18Fix no-desMatt Caswell
Numerous fixes for no-des. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-03-18Fix no-cmacMatt Caswell
There were a couple of CMAC references without OPENSSL_NO_CMAC guards. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-03-02Generalise KDF test in evp_test.cDr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-03-02Add Ctrl keyword to KDF test in evp_testDr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-09Clean up the tests for auto-init/de-initMatt Caswell
Remove the need to explicitly initialise/deinitialise for the tests Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-05If memory debugging enabled return error on leaks.Dr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-01-30handle "Ctrl" in separate functionDr. Stephen Henson
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-01-30Add support for EVP_PKEY_derive in evp_testDr. Stephen Henson
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-01-30fix warningDr. Stephen Henson
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-01-26Remove /* foo.c */ commentsRich Salz
This was done by the following find . -name '*.[ch]' | /tmp/pl where /tmp/pl is the following three-line script: print unless $. == 1 && m@/\* .*\.[ch] \*/@; close ARGV if eof; # Close file to reset $. And then some hand-editing of other files. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-01-19Add TLS1-PRF test support to evp_testDr. Stephen Henson
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-01-11Enable/disable crypto-mdebug just like other featuresViktor Dukhovni
Also always abort() on leak failure. Reviewed-by: Stephen Henson <steve@openssl.org>
2015-12-16Rename some BUF_xxx to OPENSSL_xxxRich Salz
Rename BUF_{strdup,strlcat,strlcpy,memdup,strndup,strnlen} to OPENSSL_{strdup,strlcat,strlcpy,memdup,strndup,strnlen} Add #define's for the old names. Add CRYPTO_{memdup,strndup}, called by OPENSSL_{memdup,strndup} macros. Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-12-11Adapt EVP tests to the opaque EVP_ENCODE_CTXRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-12-10test/evp_test.c: allow generic AEAD ciphers to be tested.Andy Polyakov
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-12-07Cleanup: fix all sources that used EVP_MD_CTX_(create|init|destroy)Richard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-12-07Adjust all accesses to EVP_MD_CTX to use accessor functions.Richard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-10-23Remove useless codeAlessandro Ghedini
RT#4081 Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-09-17RT3757: base64 encoding bugsEmilia Kasper
Rewrite EVP_DecodeUpdate. In particular: reject extra trailing padding, and padding in the middle of the content. Don't limit line length. Add tests. Previously, the behaviour was ill-defined, and depended on the position of the padding within the input. In addition, this appears to fix a possible two-byte oob read. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Dr Stephen Henson <steve@openssl.org>
2015-09-04RT3998: Allow scrypt to be disabledRich Salz
This does 64-bit division and multiplication, and on 32-bit platforms pulls in libgcc symbols (and MSVC does similar) which may not be available. Mostly done by David Woodhouse. Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2015-05-26Add PBE tests.Dr. Stephen Henson
Add support for PKCS#12 and PBKDF2 password based encryption tests. Add additional test data. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-05-20Add scrypt tests.Dr. Stephen Henson
Add scrypt test support to evp_test and add test values from from draft-josefsson-scrypt-kdf-03. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-05-06Use "==0" instead of "!strcmp" etcRich Salz
For the various string-compare routines (strcmp, strcasecmp, str.*cmp) use "strcmp()==0" instead of "!strcmp()" Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-05-06Initialize potentially uninitialized local variablesGunnar Kudrjavets
Compiling OpenSSL code with MSVC and /W4 results in a number of warnings. One category of warnings is particularly interesting - C4701 (potentially uninitialized local variable 'name' used). This warning pretty much means that there's a code path which results in uninitialized variables being used or returned. Depending on compiler, its options, OS, values in registers and/or stack, the results can be nondeterministic. Cases like this are very hard to debug so it's rational to fix these issues. This patch contains a set of trivial fixes for all the C4701 warnings (just initializing variables to 0 or NULL or appropriate error code) to make sure that deterministic values will be returned from all the execution paths. RT#3835 Signed-off-by: Matt Caswell <matt@openssl.org> Matt's note: All of these appear to be bogus warnings, i.e. there isn't actually a code path where an unitialised variable could be used - its just that the compiler hasn't been able to figure that out from the logic. So this commit is just about silencing spurious warnings. Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-05-04Use safer sizeof variant in mallocRich Salz
For a local variable: TYPE *p; Allocations like this are "risky": p = OPENSSL_malloc(sizeof(TYPE)); if the type of p changes, and the malloc call isn't updated, you could get memory corruption. Instead do this: p = OPENSSL_malloc(sizeof(*p)); Also fixed a few memset() calls that I noticed while doing this. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-05-01free NULL cleanup -- codaRich Salz
After the finale, the "real" final part. :) Do a recursive grep with "-B1 -w [a-zA-Z0-9_]*_free" to see if any of the preceeding lines are an "if NULL" check that can be removed. Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-05-01free null cleanup finaleRich Salz
Don't check for NULL before calling OPENSSL_free Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-31Stop symlinking, move files to intended directoryRichard Levitte
Rather than making include/openssl/foo.h a symlink to crypto/foo/foo.h, this change moves the file to include/openssl/foo.h once and for all. Likewise, move crypto/foo/footest.c to test/footest.c, instead of symlinking it there. Originally-by: Geoff Thorpe <geoff@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>