]> WPIA git - cassiopeia.git/blobdiff - test/src/X509Req.cpp
fmt: whitespace, padding and indentation formatting
[cassiopeia.git] / test / src / X509Req.cpp
index c6c95ace66a95df140ef8bbc012330e0c13f23d9..f8bb6044c2df33540c2a4d15345d0d40fb97b277 100644 (file)
@@ -1,27 +1,44 @@
-#include <iostream>
-
 #include <boost/test/unit_test.hpp>
 
-#include "X509.h"
+#include <openssl/err.h>
+
 #include "util.h"
 
+#include "crypto/X509.h"
+
+#include <iostream>
+#include <openssl/ssl.h>
+
 BOOST_AUTO_TEST_SUITE( TestX509Req )
 
 BOOST_AUTO_TEST_CASE( CSR ) {
+    ERR_load_crypto_strings();
+    ERR_free_strings();
+    SSL_load_error_strings();
+    ERR_print_errors_fp( stdout );
+    BOOST_REQUIRE( ERR_peek_error() == 0 );
+
     // Testing a valid 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 ) {