]> WPIA git - cassiopeia.git/commitdiff
add: require the error messages in the X509Req-CSR test
authorFelix Dörre <felix@dogcraft.de>
Wed, 3 Dec 2014 20:07:15 +0000 (21:07 +0100)
committerBenny Baumann <BenBE@geshi.org>
Sat, 24 Jan 2015 16:39:37 +0000 (17:39 +0100)
test/src/X509Req.cpp

index c6c95ace66a95df140ef8bbc012330e0c13f23d9..750d7fcc99fd3a0f79741a36d24d73348dad07f5 100644 (file)
@@ -2,6 +2,8 @@
 
 #include <boost/test/unit_test.hpp>
 
+#include <openssl/err.h>
+
 #include "X509.h"
 #include "util.h"
 
@@ -12,16 +14,23 @@ BOOST_AUTO_TEST_CASE( CSR ) {
     std::shared_ptr<X509Req> req( X509Req::parseCSR( readFile( "testdata/test.csr" ) ) );
     BOOST_REQUIRE( req );
     BOOST_CHECK( req->verify() == 1 );
+    BOOST_REQUIRE( ERR_peek_error() == 0 );
 
     // Testing a CSR, where the signature content has been tampered with
     req = std::shared_ptr<X509Req>( X509Req::parseCSR( readFile( "testdata/test_false_sig.csr" ) ) );
     BOOST_REQUIRE( req );
     BOOST_CHECK( req->verify() == 0 );
+    BOOST_REQUIRE( ERR_get_error() != 0 ); // RSA_padding_check_PKCS1_type_1:block type is not 01
+    BOOST_REQUIRE( ERR_get_error() != 0 ); // RSA_EAY_PUBLIC_DECRYPT:padding check failed
+    BOOST_REQUIRE( ERR_get_error() != 0 ); // ASN1_item_verify:EVP lib
+    BOOST_REQUIRE( ERR_get_error() == 0 );
 
     // Testing a CSR, where the signature OID is something strange
     req = std::shared_ptr<X509Req>( X509Req::parseCSR( readFile( "testdata/test_invalid_sig.csr" ) ) );
     BOOST_REQUIRE( req );
     BOOST_CHECK( req->verify() < 0 );
+    BOOST_REQUIRE( ERR_get_error() != 0 ); // ASN1_item_verify:unknown signature algorithm
+    BOOST_REQUIRE( ERR_get_error() == 0 );
 }
 
 BOOST_AUTO_TEST_CASE( SPKAC ) {