text: /*
   * #%L
   * %%
   * Copyright (C) 2018 BMW Car IT GmbH
   * %%
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   * #L%
   */
  #include <algorithm>
  
  #include <gmock/gmock.h>
  #include <gtest/gtest.h>
  #include <openssl/evp.h>
  
  #include "IOUtils.h"
  #include "mococrw/hash.h"
  #include "asymmetric_crypto_ctx.cpp"
  
  using namespace std::string_literals;
  
  using namespace mococrw;
  
  class SignatureTestsStrategy {
  public:
      std::shared_ptr<MessageSignatureCtx> signCtx;
      std::shared_ptr<MessageVerificationCtx> verifyCtx;
      std::vector<uint8_t> validSignature;
  };
  
  class SignatureTest : public ::testing::Test,
                        public ::testing::WithParamInterface<SignatureTestsStrategy>
  {
  protected:
      static const AsymmetricKeypair _keyPairRsa;
      static const AsymmetricKeypair _keyPairEcc;
      static const AsymmetricKeypair _keyPairEd25519;
      static const AsymmetricKeypair _keyPairEd448;
  
      /* The SHA256 digest of the test message. */
      static const std::vector<uint8_t> _testMessageDigestSHA256;
      /* The SHA512 digest of the test message. */
      static const std::vector<uint8_t> _testMessageDigestSHA512;
      /* The SHA1 digest of the test message. */
      static const std::vector<uint8_t> _testMessageDigestSHA1;
  
      /* Valid RSA keys belonging to the same key pair. */
      static const AsymmetricPublicKey _validRsaPublicKey;
      static const AsymmetricPrivateKey _validRsaPrivateKey;
  
      /* Valid ECC PRIME_256v1 keys belonging to the same key pair. */
      static const AsymmetricPublicKey _validEccPublicKey;
      static const AsymmetricPrivateKey _validEccPrivateKey;
      static const X509Certificate _validEccCertificate;
  
      static const AsymmetricPublicKey _invalidEccPublicKey;
  
      /* Valid Ed25519 keys belonging to the same key pair. */
      static const AsymmetricPrivateKey _validEd25519PrivateKey;
      static const AsymmetricPublicKey _validEd25519PublicKey;
      static const X509Certificate _validEd25519Certificate;
  
      /* Valid Ed448 keys belonging to the same key pair */
      static const AsymmetricPrivateKey _validEd448PrivateKey;
      static const AsymmetricPublicKey _validEd448PublicKey;
      static const X509Certificate _validEd448Certificate;
  
      /* The signatures of the hashed test message with the previously declared private key */
      static const std::vector<uint8_t>& _validEd25519Signature;
      static const std::vector<uint8_t>& _validEd448Signature;
      static const std::vector<uint8_t>& _validPKCS1SignatureSHA256;
      static const std::vector<uint8_t>& _validEccSignatureSHA1;
  
      /* Pre-configured padding modes for RSA operations */
      static const std::shared_ptr<PKCSPadding> _PKCSPadding;
      static const std::shared_ptr<PSSPadding> _PSSPadding;
      static const std::shared_ptr<PSSPadding> _PSSPaddingModifiedSalt;
  
      /* Message for sign-verify tests */
      static const std::vector<uint8_t> signVerifyTestMessage;
  public:
      static const std::vector<SignatureTestsStrategy> SignatureTestData;
  };
  
  const AsymmetricKeypair SignatureTest::_keyPairRsa = mococrw::AsymmetricKeypair::generateRSA();
  const AsymmetricKeypair SignatureTest::_keyPairEcc = mococrw::AsymmetricKeypair::generateECC();
  const AsymmetricKeypair SignatureTest::_keyPairEd448 = mococrw::AsymmetricKeypair::generateEd448();
  const AsymmetricKeypair SignatureTest::_keyPairEd25519 = mococrw::AsymmetricKeypair::generateEd25519();
  
  const X509Certificate SignatureTest::_validEccCertificate = X509Certificate::fromPEM(
  R"(-----BEGIN CERTIFICATE-----
  MIICjzCCAjWgAwIBAgIBADAKBggqhkjOPQQDAjCBvDESMBAGA1UEAwwJSW1BVGVh
  cG90MQswCQYDVQQGEwJERTENMAsGA1UEBwwEb2JlbjEQMA4GA1UECAwHbmViZW5h
  bjEWMBQGA1UECwwNTGludXggU3VwcG9ydDERMA8GA1UECgwITGludXggQUcxIjAg
  BgkqhkiG9w0BCQEWE3N1cHBvcnRAZXhhbXBsZS5jb20xKTAnBgNVBAUTIDA4RTM2
  REQ1MDE5NDE0MzIzNThBRkU4MjU2QkM2RUZEMB4XDTE4MTEyNzE3MjUyN1oXDTE4
  MTEyNzE3MjcyN1owgbwxEjAQBgNVBAMMCUltQVRlYXBvdDELMAkGA1UEBhMCREUx
  DTALBgNVBAcMBG9iZW4xEDAOBgNVBAgMB25lYmVuYW4xFjAUBgNVBAsMDUxpbnV4
  IFN1cHBvcnQxETAPBgNVBAoMCExpbnV4IEFHMSIwIAYJKoZIhvcNAQkBFhNzdXBw
  b3J0QGV4YW1wbGUuY29tMSkwJwYDVQQFEyAwOEUzNkRENTAxOTQxNDMyMzU4QUZF
  ODI1NkJDNkVGRDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABKGWituJ9NwjpXXQ
  FkpS4I4TdtAF7TGGTgQw+YZbtnih2kYRWUY19nSL/6hbDpWsGklNMJIjDqEaQwn1
  7sX4PkWjJjAkMA4GA1UdDwEB/wQEAwIBhjASBgNVHRMBAf8ECDAGAQH/AgEBMAoG
  CCqGSM49BAMCA0gAMEUCIDFaFwDfQ3wy8L51WqpwYeA5IQkn8sMXJ6zrhntWUYfX
  AiEApz/8/0+5CjFNIhfdNqJrDvGE4R7sf0yphQ/0NnLO/44=
  -----END CERTIFICATE-----)");
  
  const AsymmetricPublicKey SignatureTest::_validRsaPublicKey = AsymmetricPublicKey::readPublicKeyFromPEM(
  R"(-----BEGIN PUBLIC KEY-----
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp3YVsDAXbXXafN19SliI
  evUMvQyk4bdCL/UUNzED/esA68NKr0C7IO7+wG04mdV8HoMTmXevcNyu7Gfk6nBW
  BIOb1JazvyfloxmpDK602/WEzDP6AMCY3jk6nB3nYP4ydxH/lwiYwfnpnFlp+8C/
  zgqROmbYyQi83DXJZlVjZWr+UZfyvoF4geRkiTd41epjSxR9A7eK3lQ3d0OnD09c
  rtrq3QTVf/i+Rrw7czc2j88vbYJAnd2MyuLI4dbiOoEAvdp3O5oqFBIC0SrNMpE/
  gIozEnABGPQyClIeOlxJrydGnwUAxL8SA83MNyxT4B3+WByXsJf2oC05CsZxvFwF
  NQIDAQAB
  -----END PUBLIC KEY-----)");
  
  const AsymmetricPublicKey SignatureTest::_validEccPublicKey = AsymmetricPublicKey::readPublicKeyFromPEM(
  R"(-----BEGIN PUBLIC KEY-----
  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEoZaK24n03COlddAWSlLgjhN20AXt
  MYZOBDD5hlu2eKHaRhFZRjX2dIv/qFsOlawaSU0wkiMOoRpDCfXuxfg+RQ==
  -----END PUBLIC KEY-----)");
  
  const AsymmetricPublicKey SignatureTest::_invalidEccPublicKey = AsymmetricPublicKey::readPublicKeyFromPEM(
  R"(-----BEGIN PUBLIC KEY-----
  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEokMAQr8qdmAzAuI8lqnhkO+R3gxM
  qfdiYjxBqRq225MTwfCqc46ksOCKyonMzUmcHfY1EzrdOEib+6FWGyeE5w==
  -----END PUBLIC KEY-----)");
  
  const AsymmetricPrivateKey SignatureTest::_validRsaPrivateKey = AsymmetricPrivateKey::readPrivateKeyFromPEM(
  R"(-----BEGIN PRIVATE KEY-----
  MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCndhWwMBdtddp8
  3X1KWIh69Qy9DKTht0Iv9RQ3MQP96wDrw0qvQLsg7v7AbTiZ1XwegxOZd69w3K7s
  Z+TqcFYEg5vUlrO/J+WjGakMrrTb9YTMM/oAwJjeOTqcHedg/jJ3Ef+XCJjB+emc
  WWn7wL/OCpE6ZtjJCLzcNclmVWNlav5Rl/K+gXiB5GSJN3jV6mNLFH0Dt4reVDd3
  Q6cPT1yu2urdBNV/+L5GvDtzNzaPzy9tgkCd3YzK4sjh1uI6gQC92nc7mioUEgLR
  Ks0ykT+AijMScAEY9DIKUh46XEmvJ0afBQDEvxIDzcw3LFPgHf5YHJewl/agLTkK
  xnG8XAU1AgMBAAECggEATVNzlFXAm6TN7NaBojDbZJt+9FTAVhG/GFH8sbeKdldr
  p3IYLHCheAWj0MseVbqEg7pW9IiVlHHyu+sFg1O4BIGZFUM5YM1VdkjFDLwne2IV
  ng1qJarJa+PVMn2Ed/8o4l6HPQCVOQzjWHTZQYyxhLzQbr1K4RmNy8lyZDSNnyhX
  Er3FGU3E3lvoaBEOo2Kznu51GwZH2kqWZdYVe9For27Y3mf9uqKdkkG6Y/yV+5TN
  YKiKMYKYtA5MW4kHOxRqVgJDFx8xmfYbTfIkKKYgcO5WtO+xcS0kg1+1Gnox6xrD
  fCgALgERorKzgybwgEBGkIrexnFQYTmvW7a/+7W9iQKBgQDb53A4SdCHFI0r3Iue
  X7lmQn5oE06a/yAanGVSBE3SjC3vT7HUQsBoKZ7YH1PMppwg9pqHzNpBwneJ5tz/
  5h9RtKCeO9MqCx0Fbt+GxhTi99JnuGlCoWeMHHmKCQ09Kt9f7Uu9pmYMrTuNTQkL
  8KC8fT/cAGWqvvzauX3R5vV6FwKBgQDC8vRQKYNcsSDSFBWOhqANcq8fGEarNcpy
  w/1zqsOCt8Ti8Px6+3hjvjSlYatClwjaRjJCauI2/tFDdx2GmClmQ6RTckyNR/t+
  K5U+YW9xb9cullJrSUnFNTDxOmZxw/Dh2P8vaHEmd6UXdgCq9/4weOgTGN99AfGC
  fscYgySmkwKBgQDH6nO++Hw3EZv10B6t8GBgcvrwKv0/M8k/6AbEtVz6mK357f3A
  9p5tE8lwuao5Vw6BeS+rXbTeK6j5GYS4r8CxSwDqWYDzq/7KPa3AnLvIS3xhBunK
  xWmZmxlzQB9lCGDimJxO4cPMqoCFSQ98Z1n5gfRYUZQb0l2ViySzesCYKQKBgBHy
  8I+Y4uFb5ZuyAbIXrxDN6FXClG8bCsK6TNGjfVDBvrzuVzCziogUcSBw96Wv5j7C
  i8oVsTJDD91YUD2eMOGbhLuyIF45rGwXcyxFKE+XboZ5jKkYHFSt6w2qxNfgpIMG
  yagBw7k49thMIw+auaqY1zU66wjFbwkGxyn4mR1FAoGBAKDnwWHgIVHFjI1wf/Vu
  r7/HRKKAqTfz8m5F/LmmmMfDB1LpNtWtyNVBZzLCDuCNqTuxIIl8eWWpTQu5uYfV
  I81xKRx2By82a1Py9gzQAozGmMtwV8CornxwU2wbUmoiADStDouzr/wqlOFo780O
  5xWdBSm554PdnwbLVRUxX3aP
  -----END PRIVATE KEY-----)", "");
  
  const AsymmetricPrivateKey SignatureTest::_validEccPrivateKey = AsymmetricPrivateKey::readPrivateKeyFromPEM(
  R"(-----BEGIN PRIVATE KEY-----
  MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg+g/5RMyEkKBwEtdk
  a29Ix3qgyrGBjpRnMBPvELa/jHWhRANCAAShlorbifTcI6V10BZKUuCOE3bQBe0x
  hk4EMPmGW7Z4odpGEVlGNfZ0i/+oWw6VrBpJTTCSIw6hGkMJ9e7F+D5F
  -----END PRIVATE KEY-----)", "");
  
  const AsymmetricPrivateKey SignatureTest::_validEd25519PrivateKey = AsymmetricPrivateKey::readPrivateKeyFromPEM(
  R"(-----BEGIN PRIVATE KEY-----
  MC4CAQAwBQYDK2VwBCIEIHP1o8LJ4jNkuTyDT6uNtqLankRkQeAyAIflqvnjutC2
  -----END PRIVATE KEY-----)", "");
  
  const AsymmetricPublicKey SignatureTest::_validEd25519PublicKey = AsymmetricPublicKey::readPublicKeyFromPEM(
  R"(-----BEGIN PUBLIC KEY-----
  MCowBQYDK2VwAyEAr9xxqFSYOgv915bZwftq62t6/y9jfQ2qY85Zy3HXeQA=
  -----END PUBLIC KEY-----)");
  
  const X509Certificate SignatureTest::_validEd25519Certificate = X509Certificate::fromPEM(
  R"(-----BEGIN CERTIFICATE-----
  MIIBnzCCAVGgAwIBAgIUVlF6bdywGCd6R4AK5fIw4qTqXdEwBQYDK2VwMEUxCzAJ
  BgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5l
  dCBXaWRnaXRzIFB0eSBMdGQwHhcNMTkwNzA4MTQxNjEwWhcNMjAwNzA3MTQxNjEw
  WjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwY
  SW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMCowBQYDK2VwAyEAr9xxqFSYOgv915bZ
  wftq62t6/y9jfQ2qY85Zy3HXeQCjUzBRMB0GA1UdDgQWBBSTj+s7u6bAdeccsIiU
  lTDtzbHlsDAfBgNVHSMEGDAWgBSTj+s7u6bAdeccsIiUlTDtzbHlsDAPBgNVHRMB
  Af8EBTADAQH/MAUGAytlcANBAKmkt1ddr1LU79HRfOAp8sfhNbDlrIpQWmYiu+Pz
  GAMQq3gZlq2o/6lU0o0zI6wVMWPlMTNNu1qVuNOMe8uTkQo=
  -----END CERTIFICATE-----)");
  
  const AsymmetricPrivateKey SignatureTest::_validEd448PrivateKey = AsymmetricPrivateKey::readPrivateKeyFromPEM(
  R"(-----BEGIN PRIVATE KEY-----
  MEcCAQAwBQYDK2VxBDsEOWlC44jv5bZiqT7dsOFrZkCYAjSpbNpWR/z+0qgCZQSk
  sSh8jk/iQYiNFH18bBFzh4qCMpTaWf/Dqw==
  -----END PRIVATE KEY-----)", "");
  
  const AsymmetricPublicKey SignatureTest::_validEd448PublicKey = AsymmetricPublicKey::readPublicKeyFromPEM(
  R"(-----BEGIN PUBLIC KEY-----
  MEMwBQYDK2VxAzoAn6AkwA6wgkvGj8eD9InZMXJZYhkNZodgMlPlOWkoWxf19roL
  7y84BN6+fKydGisX9Olenr/fx7SA
  -----END PUBLIC KEY-----)");
  
  const X509Certificate SignatureTest::_validEd448Certificate = X509Certificate::fromPEM(
  R"(-----BEGIN CERTIFICATE-----
  MIIB6jCCAWqgAwIBAgIUV2uwWMEmTUgfBSoWUtPysr6KQYgwBQYDK2VxMEUxCzAJ
  BgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5l
  dCBXaWRnaXRzIFB0eSBMdGQwHhcNMTkwODA2MTA1OTE4WhcNMjAwODA1MTA1OTE4
  WjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwY
  SW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMEMwBQYDK2VxAzoAn6AkwA6wgkvGj8eD
  9InZMXJZYhkNZodgMlPlOWkoWxf19roL7y84BN6+fKydGisX9Olenr/fx7SAo1Mw
  UTAdBgNVHQ4EFgQUopUIHDDifvlx05vHq+v43aznwvEwHwYDVR0jBBgwFoAUopUI
  HDDifvlx05vHq+v43aznwvEwDwYDVR0TAQH/BAUwAwEB/zAFBgMrZXEDcwBuBncx
  0iQ1ZYm2BSk9/uAuQWYzmG7s+aNXrT6T4Y0TT84jp7ySR6fuNMH0JrPcB16AavL3
  4c/32gBN9uKqcavB4Zse0/vVBC4bLcgynrucQA4/CENhsR+ZwlKRoeVHd8WyCTMK
  zP5yYI+AQefisKPtMAA=
  -----END CERTIFICATE-----)");
  
  /*
   * All of the _testMessageDigest* variables contain the hashed "Hello World!" string
   */
  const std::vector<uint8_t> SignatureTest::_testMessageDigestSHA256{
          0x7F, 0x83, 0xB1, 0x65, 0x7F, 0xF1, 0xFC, 0x53, 0xB9, 0x2D, 0xC1, 0x81, 0x48, 0xA1, 0xD6,
          0x5D, 0xFC, 0x2D, 0x4B, 0x1F, 0xA3, 0xD6, 0x77, 0x28, 0x4A, 0xDD, 0xD2, 0x00, 0x12, 0x6D,
          0x90, 0x69};
  
  const std::vector<uint8_t> SignatureTest::_testMessageDigestSHA512{
          0x86, 0x18, 0x44, 0xD6, 0x70, 0x4E, 0x85, 0x73, 0xFE, 0xC3, 0x4D, 0x96, 0x7E, 0x20, 0xBC,
          0xFE, 0xF3, 0xD4, 0x24, 0xCF, 0x48, 0xBE, 0x04, 0xE6, 0xDC, 0x08, 0xF2, 0xBD, 0x58, 0xC7,
          0x29, 0x74, 0x33, 0x71, 0x01, 0x5E, 0xAD, 0x89, 0x1C, 0xC3, 0xCF, 0x1C, 0x9D, 0x34, 0xB4,
          0x92, 0x64, 0xB5, 0x10, 0x75, 0x1B, 0x1F, 0xF9, 0xE5, 0x37, 0x93, 0x7B, 0xC4, 0x6B, 0x5D,
          0x6F, 0xF4, 0xEC, 0xC8};
  
  const std::vector<uint8_t> SignatureTest::_testMessageDigestSHA1{
          0x2e, 0xf7, 0xbd, 0xe6, 0x08, 0xce, 0x54, 0x04, 0xe9, 0x7d, 0x5f, 0x04, 0x2f, 0x95, 0xf8,
          0x9f, 0x1c, 0x23, 0x28, 0x71};
  
  const std::shared_ptr<PKCSPadding> SignatureTest::_PKCSPadding =
      std::make_shared<PKCSPadding>();
  
  const std::shared_ptr<PSSPadding> SignatureTest::_PSSPadding = std::make_shared<PSSPadding>();
  
  const std::shared_ptr<PSSPadding> SignatureTest::_PSSPaddingModifiedSalt = std::make_shared<PSSPadding>(nullptr, 13);
  
  const std::vector<SignatureTestsStrategy> SignatureTest::SignatureTestData = {
      // [0] PKCS Padded RSA Signature using SHA1
      {
          std::make_shared<RSASignaturePrivateKeyCtx>(_validRsaPrivateKey, DigestTypes::SHA1, _PKCSPadding),
          std::make_shared<RSASignaturePublicKeyCtx>(_validRsaPublicKey, DigestTypes::SHA1, _PKCSPadding),
          {
              0x9c, 0xc4, 0x76, 0x1c, 0x05, 0x1a, 0xfc, 0x8e, 0x0d, 0xb6, 0x8b, 0x7e, 0x99, 0x35,
              0x63, 0x49, 0x8e, 0xf3, 0xfd, 0x96, 0x8d, 0x45, 0xb3, 0x5f, 0x3c, 0x81, 0x09, 0x43,
              0x07, 0x56, 0x40, 0x67, 0x32, 0x8f, 0x79, 0x9c, 0xed, 0x34, 0x06, 0x45, 0x00, 0x7f,
              0x86, 0x71, 0xc4, 0x91, 0x14, 0x7d, 0x5c, 0x11, 0x98, 0xf5, 0x1d, 0x30, 0xc4, 0xc4,
              0xc0, 0x42, 0x19, 0xbb, 0xdb, 0x7c, 0x1d, 0x69, 0xb0, 0xf4, 0xd5, 0x5e, 0xbc, 0x8d,
              0xf9, 0x56, 0xa3, 0x05, 0xc7, 0x52, 0xdc, 0xd2, 0xa1, 0x68, 0x65, 0xcc, 0xbb, 0x01,
              0xc5, 0x01, 0x1d, 0xd3, 0x35, 0xa4, 0x7c, 0x72, 0x0d, 0x02, 0xde, 0x70, 0xc3, 0xf9,
              0xd5, 0xa3, 0x79, 0xbe, 0x01, 0x32, 0x2f, 0xfc, 0xbe, 0x2c, 0xb5, 0xfc, 0xf0, 0xa2,
              0x4c, 0xf8, 0xff, 0xa9, 0x4a, 0x1f, 0xda, 0x06, 0x18, 0x4f, 0x93, 0xa1, 0x00, 0xa1,
              0x39, 0xc2, 0xce, 0xb1, 0x99, 0x2c, 0x02, 0xf6, 0x79, 0xfd, 0xb6, 0x37, 0x3c, 0xe4,
              0xdf, 0xc5, 0xc8, 0x15, 0x95, 0xf6, 0xe7, 0xfc, 0xfd, 0x51, 0x5c, 0xdc, 0xf2, 0x4c,
              0xf0, 0x14, 0x0f, 0x32, 0xa9, 0x25, 0x51, 0xc5, 0x9a, 0x56, 0xfe, 0x60, 0x44, 0xbe,
              0x85, 0x2b, 0x31, 0x66, 0xd7, 0xd2, 0x04, 0x32, 0x79, 0x1a, 0xb7, 0x3e, 0xaa, 0x41,
              0xa5, 0xe6, 0x22, 0xa6, 0x9e, 0xc6, 0x17, 0x5a, 0x11, 0x37, 0x94, 0x03, 0x21, 0x80,
              0x2c, 0x3d, 0x6f, 0x85, 0x20, 0x75, 0x3c, 0xe3, 0x02, 0x4e, 0xa2, 0xe3, 0xd9, 0xe0,
              0xbb, 0x2b, 0x59, 0xbf, 0xe9, 0xf6, 0x47, 0xb7, 0xfb, 0x71, 0x10, 0x46, 0x5b, 0xba,
              0x4a, 0x9a, 0xe3, 0x82, 0xb4, 0x4c, 0x00, 0xa8, 0x36, 0x53, 0x9d, 0x0a, 0x43, 0x1b,
              0xb1, 0x82, 0xb7, 0x04, 0x63, 0xcc, 0xde, 0x5e, 0xc3, 0xa6, 0xff, 0xe0, 0x90, 0x3b,
              0xec, 0xe2, 0xdb, 0x57
          }
      },
      // [1] PKCS Padded RSA Signature using SHA256
      {
          std::make_shared<RSASignaturePrivateKeyCtx>(_validRsaPrivateKey, DigestTypes::SHA256, _PKCSPadding),
          std::make_shared<RSASignaturePublicKeyCtx>(_validRsaPublicKey, DigestTypes::SHA256, _PKCSPadding),
          {
              0x16, 0x00, 0x22, 0xd8, 0x72, 0x91, 0x6f, 0xd6, 0x24, 0x0c, 0xbd, 0x1c, 0xde, 0x25,
              0x4c, 0x8e, 0x9f, 0x8d, 0x55, 0xaa, 0xe7, 0x1a, 0x10, 0xe0, 0x56, 0x67, 0x5d, 0x5c,
              0xd8, 0x0a, 0x0b, 0x58, 0x35, 0xa6, 0x5b, 0x77, 0x05, 0x80, 0x4d, 0x8e, 0xde, 0xcc,
              0x65, 0x7a, 0xdb, 0xb0, 0x46, 0x72, 0x3c, 0x41, 0x38, 0xa4, 0xe7, 0x75, 0x4c, 0x84,
              0x5d, 0x6d, 0xd2, 0x3c, 0xbd, 0x39, 0x61, 0x16, 0x66, 0xca, 0x0e, 0xa1, 0xb2, 0x51,
              0xa6, 0x30, 0xd2, 0x69, 0xfd, 0x25, 0xb1, 0x85, 0x66, 0x7d, 0x2c, 0x7b, 0x83, 0xa2,
              0x45, 0xd6, 0x51, 0xed, 0xd1, 0x43, 0x22, 0x61, 0x3a, 0xe3, 0x03, 0xe8, 0xd2, 0x90,
              0x39, 0xb1, 0xd0, 0xdb, 0x3b, 0x9f, 0xb6, 0x4f, 0x9f, 0x5e, 0x27, 0x8c, 0x63, 0x33,
              0x56, 0xd1, 0x65, 0xb4, 0x1b, 0x64, 0x1c, 0xe8, 0x08, 0xd9, 0x20, 0x78, 0xf7, 0xe0,
              0x65, 0x69, 0xe6, 0x3e, 0x74, 0xe6, 0x5d, 0x74, 0x8e, 0xa6, 0xb8, 0x46, 0x90, 0x4e,
              0x3b, 0x33, 0x28, 0x81, 0xcf, 0x85, 0x32, 0x3c, 0x69, 0xf6, 0x66, 0x25, 0xa0, 0x93,
              0x9c, 0x7c, 0xc1, 0x2a, 0xbb, 0xaa, 0x7e, 0xde, 0xbb, 0xc0, 0x9a, 0x38, 0x4a, 0x2b,
              0xb3, 0xfe, 0xd5, 0xcb, 0xb3, 0x4a, 0x2a, 0xdd, 0x13, 0x8d, 0xb8, 0x79, 0x80, 0xc3,
              0xdb, 0x18, 0x86, 0xeb, 0xec, 0x0a, 0xbd, 0x7c, 0x9c, 0xe9, 0x6a, 0x1e, 0x87, 0x76,
              0xf7, 0xc4, 0x0d, 0x53, 0x6f, 0xd8, 0x09, 0x6c, 0xe7, 0x01, 0x11, 0xc1, 0x7b, 0x84,
              0xa1, 0x7c, 0x64, 0xe2, 0x88, 0xf1, 0x01, 0x76, 0x93, 0x38, 0x47, 0xc0, 0x10, 0x33,
              0x9b, 0x22, 0x43, 0x14, 0xbe, 0x6e, 0xd5, 0x9a, 0x0e, 0x55, 0x90, 0x6d, 0x29, 0xd9,
              0x54, 0xaa, 0x18, 0x37, 0xe1, 0x83, 0xff, 0x28, 0x46, 0x31, 0x35, 0xa8, 0x00, 0x23,
              0x79, 0x0f, 0x83, 0x0d
          }
      },
      // [2] PKCS Padded RSA Signature using SHA512
      {
          std::make_shared<RSASignaturePrivateKeyCtx>(_validRsaPrivateKey, DigestTypes::SHA512, _PKCSPadding),
          std::make_shared<RSASignaturePublicKeyCtx>(_validRsaPublicKey, DigestTypes::SHA512, _PKCSPadding),
          {
              0x77, 0x10, 0x46, 0xcc, 0xdf, 0xcc, 0x45, 0xd7, 0xef, 0xe0, 0xc6, 0x19, 0xf4, 0xd1,
              0x4c, 0xc9, 0x55, 0x31, 0xc5, 0x4b, 0xeb, 0x82, 0xc3, 0xc8, 0x89, 0x1d, 0x33, 0x24,
              0xe8, 0xda, 0x0f, 0x40, 0x01, 0xc7, 0x8c, 0x1d, 0x25, 0x84, 0x6e, 0x46, 0x7c, 0xbb,
              0x0e, 0xaa, 0x24, 0xaf, 0x86, 0xbc, 0x3a, 0xb7, 0x98, 0x32, 0x71, 0x17, 0xc4, 0x45,
              0xd7, 0x06, 0xf5, 0x30, 0xaf, 0x7d, 0x50, 0xa4, 0xa1, 0xc5, 0x67, 0x71, 0x17, 0x7d,
              0xf1, 0x0d, 0xc1, 0xea, 0x02, 0x69, 0x6c, 0x46, 0x70, 0x4a, 0x88, 0x16, 0x8c, 0xf5,
              0xeb, 0xab, 0x74, 0x3f, 0x6e, 0x99, 0x15, 0x37, 0x60, 0x2d, 0x6a, 0xa1, 0x03, 0x55,
              0x31, 0x3b, 0x3a, 0xa4, 0xb2, 0x38, 0x16, 0xc1, 0xdc, 0xdf, 0xb9, 0xaf, 0x56, 0x1d,
              0xcb, 0xe9, 0xac, 0x46, 0x9a, 0xa7, 0x48, 0x04, 0x5c, 0x2d, 0x15, 0x04, 0x76, 0x26,
              0xde, 0xb2, 0x89, 0xdc, 0x06, 0xf5, 0xaf, 0xa6, 0x6f, 0xdd, 0x72, 0x05, 0x8f, 0x12,
              0xff, 0x6a, 0x6a, 0x5c, 0x2e, 0xad, 0x09, 0xad, 0xcd, 0x20, 0x68, 0x8b, 0x7c, 0xc8,
              0x98, 0x30, 0xb1, 0x0f, 0xa1, 0x73, 0x75, 0x92, 0xdb, 0x32, 0x32, 0x82, 0x7a, 0x5a,
              0x65, 0x46, 0x49, 0xe1, 0x8d, 0x23, 0xb9, 0x2e, 0x99, 0xa4, 0xea, 0x57, 0x5f, 0x1f,
              0x6a, 0xc7, 0x56, 0x3e, 0x5c, 0x04, 0x44, 0xcc, 0xb0, 0x66, 0xb1, 0x6e, 0xb1, 0x33,
              0x09, 0x4f, 0x52, 0x03, 0x78, 0x56, 0x12, 0x28, 0x2d, 0xd5, 0x38, 0x3f, 0x48, 0x8f,
              0xc8, 0x64, 0x8b, 0xea, 0xd6, 0xff, 0xd1, 0xef, 0xd3, 0xe7, 0x10, 0x48, 0xf3, 0x44,
              0x3e, 0x48, 0x6a, 0xce, 0xc4, 0xd0, 0x0a, 0x26, 0x38, 0x17, 0xfe, 0x3d, 0x7b, 0xbe,
              0x82, 0x83, 0xfe, 0x98, 0x59, 0x01, 0x35, 0xbb, 0xb6, 0x60, 0xf7, 0xaa, 0x0e, 0x90,
              0xf7, 0xde, 0xa6, 0xaa
          }
      },
      // [3] PSS Padded RSA Signature using SHA1
      {
          std::make_shared<RSASignaturePrivateKeyCtx>(_validRsaPrivateKey, DigestTypes::SHA1, _PSSPadding),
          std::make_shared<RSASignaturePublicKeyCtx>(_validRsaPublicKey, DigestTypes::SHA1, _PSSPadding),
          {
              0x16, 0x8c, 0xff, 0xa4, 0x22, 0x41, 0x64, 0x82, 0x4d, 0x15, 0xa4, 0x4b, 0x59, 0x25,
              0x30, 0x08, 0x28, 0x35, 0x50, 0xe2, 0xbf, 0xb5, 0x5e, 0x55, 0x27, 0x25, 0x5e, 0xb5,
              0xc5, 0x4b, 0xf3, 0x87, 0x2a, 0x13, 0x1b, 0x50, 0x9e, 0x07, 0x98, 0x2f, 0x33, 0x96,
              0x6a, 0xdf, 0x3f, 0x3f, 0x90, 0x45, 0xf6, 0x52, 0xa4, 0x6d, 0x09, 0x3e, 0x36, 0x12,
              0x36, 0x60, 0xd3, 0x2b, 0x44, 0x39, 0xe2, 0xca, 0x11, 0x09, 0x51, 0xb3, 0x0e, 0x0a,
              0x9e, 0x5f, 0x8b, 0x45, 0x4a, 0xae, 0x28, 0x70, 0x6d, 0xb5, 0x99, 0x21, 0x08, 0xbd,
              0x13, 0xa5, 0x48, 0x39, 0x8f, 0x53, 0x98, 0x52, 0x43, 0xfa, 0x98, 0x2e, 0x10, 0xb3,
              0xcc, 0xf4, 0x62, 0xcf, 0xcd, 0x88, 0x5f, 0x41, 0xa5, 0xc4, 0xaf, 0x19, 0x2c, 0xd2,
              0x0c, 0x6f, 0xfe, 0x28, 0xa6, 0x91, 0xdf, 0xd3, 0x5c, 0x81, 0xa8, 0x4d, 0x98, 0x3f,
              0x5a, 0x99, 0x1a, 0x08, 0x27, 0x5a, 0xbe, 0xd1, 0x41, 0x07, 0xd2, 0x63, 0x79, 0x39,
              0x13, 0x52, 0x04, 0x6d, 0x54, 0x8b, 0xd8, 0x0f, 0xa8, 0x47, 0x8b, 0x5a, 0x6e, 0x8f,
              0x76, 0x08, 0x7a, 0x7f, 0x99, 0x63, 0xe8, 0x6b, 0x73, 0xd5, 0xc0, 0x1a, 0x34, 0xfd,
              0x18, 0x1c, 0x41, 0x9a, 0xb3, 0x76, 0x83, 0xb8, 0xf7, 0xe7, 0x72, 0x27, 0x17, 0x8e,
              0xd6, 0xf8, 0x1c, 0xa0, 0xb1, 0x58, 0x91, 0x86, 0x50, 0xed, 0x19, 0xb4, 0xa6, 0x85,
              0xda, 0xef, 0x9c, 0xe5, 0x64, 0xff, 0x5e, 0xae, 0x5b, 0x64, 0x67, 0x06, 0x57, 0xa2,
              0xfc, 0x23, 0xf6, 0x11, 0x71, 0xbf, 0x60, 0x4e, 0x33, 0x9d, 0x13, 0x9a, 0x7f, 0x98,
              0x41, 0x00, 0xa3, 0xc8, 0x51, 0x99, 0xab, 0x56, 0x44, 0xdc, 0x37, 0x6a, 0xe5, 0x53,
              0x2b, 0xbf, 0x5d, 0x39, 0xe8, 0x55, 0xc2, 0xb8, 0x36, 0xa7, 0xa9, 0xba, 0x2d, 0x92,
              0xb0, 0x7b, 0xf1, 0xdf
          }
      },
      // [4] PSS Padded RSA Signature using SHA256
      {
          std::make_shared<RSASignaturePrivateKeyCtx>(_validRsaPrivateKey, DigestTypes::SHA256, _PSSPadding),
          std::make_shared<RSASignaturePublicKeyCtx>(_validRsaPublicKey, DigestTypes::SHA256, _PSSPadding),
          {
              0x83, 0x7f, 0x04, 0xb9, 0x50, 0x91, 0xa9, 0x68, 0x6d, 0x0b, 0x1b, 0xce, 0xaf, 0xb3,
              0x3c, 0x52, 0xe8, 0x0b, 0x1b, 0xa6, 0x21, 0x6f, 0x2d, 0xfc, 0xf7, 0x58, 0x7e, 0xa9,
              0x39, 0xb7, 0x12, 0x67, 0x89, 0x9e, 0x2c, 0xdc, 0xcc, 0xc9, 0xa6, 0x02, 0xb0, 0x76,
              0xea, 0x43, 0xe0, 0xea, 0x75, 0xae, 0x6f, 0x80, 0x16, 0xa6, 0xc9, 0x32, 0x9e, 0x6f,
              0xd4, 0x85, 0x58, 0x2c, 0x2f, 0x66, 0x1c, 0xd3, 0xf0, 0x02, 0x82, 0xa3, 0xbc, 0xfa,
              0x6f, 0xe1, 0x16, 0x07, 0x44, 0xeb, 0xe0, 0x8c, 0xf1, 0x8a, 0x6d, 0x8a, 0xfc, 0x3e,
              0x98, 0xa3, 0xfe, 0xa1, 0x06, 0xa0, 0xf3, 0x09, 0xf4, 0xa8, 0x8d, 0x46, 0xca, 0x98,
              0x41, 0xc7, 0x8d, 0xc0, 0x24, 0xc2, 0x09, 0x8b, 0xc7, 0xf4, 0x4c, 0x90, 0x6d, 0xd6,
              0x8f, 0x5a, 0x45, 0x3c, 0x4b, 0x90, 0x07, 0x0b, 0x28, 0xc6, 0xeb, 0x04, 0x80, 0x53,
              0xa4, 0x52, 0x21, 0xfb, 0x04, 0xef, 0x9b, 0x58, 0x5d, 0xc4, 0x15, 0x32, 0x01, 0x56,
              0xdd, 0xed, 0xed, 0x1a, 0x75, 0x97, 0xae, 0x2a, 0x99, 0x0f, 0x37, 0x92, 0x64, 0x49,
              0x14, 0x62, 0x86, 0x8d, 0xf0, 0xb8, 0xa5, 0x46, 0x84, 0xd9, 0xfa, 0x7a, 0x91, 0x41,
              0x1c, 0x28, 0x3f, 0x52, 0xe7, 0x63, 0x2e, 0xb2, 0xdd, 0x1c, 0x5f, 0x11, 0x71, 0x1d,
              0xd9, 0x41, 0x5d, 0x01, 0x62, 0xba, 0x8c, 0x20, 0x62, 0x14, 0xb4, 0x17, 0x1d, 0xff,
              0xc3, 0x49, 0x4a, 0x4b, 0x88, 0xf9, 0x60, 0x96, 0x4f, 0xa9, 0x22, 0x74, 0x53, 0x0e,
              0xf1, 0xd5, 0x82, 0x4a, 0x7c, 0x28, 0x47, 0xc0, 0xaa, 0x6d, 0x14, 0xe3, 0xe9, 0x73,
              0x68, 0x1c, 0xa5, 0x89, 0x42, 0xd7, 0x7b, 0x96, 0x6a, 0xfa, 0xa4, 0x52, 0x70, 0x31,
              0xa9, 0x6e, 0x0f, 0xf4, 0x05, 0xc0, 0xd8, 0x9a, 0xcc, 0x8b, 0xaf, 0xf6, 0xe3, 0xbd,
              0xf1, 0x91, 0x27, 0x53
          }
      },
      // [5] PSS Padded RSA Signature using SHA512
      {
          std::make_shared<RSASignaturePrivateKeyCtx>(_validRsaPrivateKey, DigestTypes::SHA512, _PSSPadding),
          std::make_shared<RSASignaturePublicKeyCtx>(_validRsaPublicKey, DigestTypes::SHA512, _PSSPadding),
          {
              0x33, 0xcc, 0x0a, 0x7c, 0x70, 0xe3, 0xc5, 0x7f, 0xe3, 0xd5, 0x0c, 0x76, 0x95, 0x59,
              0xd5, 0xfc, 0xa0, 0xd6, 0x42, 0xee, 0xde, 0xac, 0xb3, 0xc4, 0xe5, 0x8c, 0xb2, 0x1a,
              0x65, 0xd6, 0x41, 0xd1, 0xc0, 0xd0, 0x08, 0x12, 0x2f, 0x57, 0xe1, 0x26, 0xb0, 0xf4,
              0x5d, 0x46, 0x62, 0xfa, 0x86, 0x33, 0x63, 0xa9, 0x74, 0x31, 0x37, 0xd2, 0x29, 0x83,
              0x9f, 0x42, 0xbd, 0x3a, 0x72, 0x9e, 0xc6, 0x81, 0xa9, 0x11, 0x69, 0x60, 0x89, 0xc1,
              0x05, 0x1c, 0x71, 0x05, 0x51, 0x09, 0xf6, 0x3d, 0x37, 0x5d, 0xa7, 0xf4, 0x59, 0x07,
              0x8f, 0x71, 0x00, 0xd9, 0xb4, 0x55, 0x77, 0x0c, 0x8f, 0xd7, 0x07, 0x36, 0xb0, 0x8f,
              0x69, 0x4d, 0xbd, 0x97, 0x02, 0x2e, 0x0f, 0x0a, 0x8b, 0x85, 0x31, 0xe1, 0x39, 0x57,
              0x55, 0x74, 0x23, 0x69, 0x4d, 0x55, 0x09, 0x93, 0xc4, 0x2a, 0x07, 0xa7, 0x2f, 0xb6,
              0x69, 0xb6, 0xcb, 0x11, 0x0f, 0xc0, 0x25, 0x57, 0xb1, 0x7d, 0xd9, 0x85, 0x35, 0x0e,
              0x8d, 0x6c, 0x05, 0xe4, 0xfb, 0x61, 0x46, 0x20, 0x9a, 0x2e, 0x8a, 0xe9, 0xcb, 0x17,
              0x0c, 0xce, 0x3b, 0x16, 0x53, 0x71, 0x9b, 0x1c, 0xaa, 0xa8, 0x1c, 0x6a, 0xc4, 0x9e,
              0x6e, 0x67, 0xf8, 0x22, 0xb8, 0xa9, 0xcb, 0xf8, 0xe7, 0xe9, 0xbc, 0x46, 0x4e, 0x56,
              0xf3, 0x5b, 0x36, 0x2c, 0xa7, 0xaa, 0x2f, 0x1a, 0x18, 0x04, 0xbc, 0x49, 0xb1, 0xef,
              0xb0, 0x55, 0x46, 0xea, 0x18, 0x42, 0x07, 0x7f, 0xa2, 0xf4, 0x47, 0x4d, 0x91, 0x53,
              0xea, 0xcf, 0x25, 0x20, 0x75, 0xc1, 0x57, 0xa4, 0xa8, 0x6b, 0x53, 0xd6, 0xd3, 0x60,
              0x98, 0x06, 0xd0, 0x94, 0x24, 0xcd, 0xe1, 0x31, 0x34, 0x80, 0x83, 0x81, 0xcb, 0xd2,
              0x03, 0x3d, 0xb2, 0x72, 0xe1, 0xf9, 0xb5, 0xa9, 0x56, 0x34, 0xca, 0x7c, 0x5b, 0xb8,
              0x75, 0x6f, 0x57, 0x51
          }
      },
      // [6] PSS Padded RSA Signature using SHA512 and using Certificate to verify
      {
          std::make_shared<RSASignaturePrivateKeyCtx>(_validRsaPrivateKey, DigestTypes::SHA512, _PSSPadding),
          std::make_shared<RSASignaturePublicKeyCtx>(loadCertFromFile("signCertificate.pem"), DigestTypes::SHA512, _PSSPadding),
          {
              0x66, 0xeb, 0x5f, 0xe2, 0x18, 0x7c, 0xb4, 0xe1, 0x14, 0xe3, 0x52, 0xe0, 0xa6, 0x7d,
              0x80, 0x31, 0x01, 0xd3, 0xd6, 0x08, 0x93, 0x22, 0xbd, 0xe9, 0x3c, 0x76, 0x99, 0x01,
              0x7b, 0x17, 0x25, 0x38, 0x5d, 0xa7, 0x9e, 0xf0, 0x96, 0xb6, 0xf2, 0x34, 0xd0, 0xba,
              0xe6, 0xbb, 0xf2, 0xaf, 0x3f, 0x46, 0x32, 0xfd, 0x6a, 0x6a, 0x08, 0x27, 0x59, 0x0e,
              0xf7, 0xd4, 0xfb, 0x82, 0xff, 0xb6, 0xb8, 0x02, 0xbb, 0xd3, 0x0c, 0x6e, 0xa7, 0xfb,
              0x56, 0x86, 0x9c, 0x39, 0xca, 0xc6, 0x54, 0x26, 0xce, 0x93, 0xd6, 0x7c, 0xd2, 0xc3,
              0xdc, 0x53, 0x5d, 0x61, 0x6e, 0xff, 0xbc, 0x67, 0x86, 0x71, 0x3d, 0x58, 0x6c, 0x0f,
              0xa3, 0xde, 0x64, 0x4e, 0x52, 0x3a, 0x11, 0x56, 0xa0, 0x5d, 0xca, 0xb5, 0x1f, 0x8c,
              0xd7, 0x26, 0x3b, 0x53, 0x89, 0x3e, 0x6e, 0x97, 0x2e, 0xfe, 0x91, 0xfe, 0x13, 0x86,
              0x72, 0x03, 0x65, 0xc4, 0x0f, 0x1c, 0x75, 0x10, 0x23, 0x93, 0xf0, 0xc7, 0xc7, 0x14,
              0xce, 0x01, 0xac, 0xb9, 0x8c, 0xca, 0x44, 0x87, 0x52, 0xa2, 0x14, 0xed, 0xad, 0x4a,
              0xe6, 0xd0, 0x14, 0x36, 0xa1, 0x07, 0x70, 0x1f, 0x4e, 0x8b, 0x25, 0x03, 0xd3, 0x12,
              0xe7, 0xd3, 0xdd, 0xd3, 0xc1, 0xb6, 0x44, 0x99, 0x2e, 0x96, 0x71, 0x4c, 0x5f, 0xf8,
              0x57, 0x47, 0xc1, 0xca, 0x29, 0xad, 0xa3, 0xa4, 0xbb, 0x48, 0xc6, 0x53, 0xe1, 0x43,
              0x0e, 0xbd, 0x4e, 0x76, 0x2a, 0xe3, 0x71, 0x23, 0x83, 0x72, 0x21, 0x48, 0x7c, 0xa7,
              0xf9, 0xe6, 0xd4, 0x33, 0x82, 0x10, 0xec, 0xee, 0x6f, 0x92, 0xa9, 0x49, 0xf2, 0xc4,
              0xe3, 0x06, 0xab, 0x01, 0x06, 0x5c, 0x4d, 0xc4, 0x43, 0xab, 0xcf, 0xc7, 0x6b, 0xfb,
              0x80, 0x21, 0xa8, 0x44, 0x1c, 0x3d, 0xf4, 0x7a, 0xdc, 0x63, 0xd2, 0x74, 0xb9, 0x2a,
              0xa1, 0x21, 0x99, 0x63
          }
      },
      // [7] PSS Padded RSA Signature (with non-default salt length) using SHA256
      {
          std::make_shared<RSASignaturePrivateKeyCtx>(_validRsaPrivateKey, DigestTypes::SHA256, _PSSPaddingModifiedSalt),
          std::make_shared<RSASignaturePublicKeyCtx>(_validRsaPublicKey, DigestTypes::SHA256, _PSSPaddingModifiedSalt),
          {
              0x43, 0x2b, 0x3b, 0x9d, 0x48, 0xfa, 0xec, 0x0b, 0x88, 0x5b, 0x0b, 0xf7, 0x58, 0xeb,
              0xb1, 0x37, 0xa3, 0x5f, 0x7b, 0xc5, 0x99, 0x75, 0x35, 0x36, 0xff, 0x0c, 0x39, 0xf2,
              0x25, 0xe2, 0xfa, 0x19, 0x2e, 0x00, 0x87, 0x13, 0x00, 0xca, 0x81, 0x0e, 0x25, 0x85,
              0x61, 0xe1, 0xaf, 0x7d, 0xf4, 0xd6, 0x56, 0xd6, 0x3e, 0xea, 0x55, 0x2a, 0x2f, 0x2c,
              0x5c, 0x74, 0x86, 0xf3, 0x1a, 0x1e, 0xc7, 0xe1, 0x81, 0x28, 0xf3, 0x8e, 0xe8, 0x79,
              0x4f, 0x77, 0x41, 0x57, 0x50, 0xd5, 0x9b, 0x42, 0x40, 0xcf, 0x9d, 0x92, 0xd4, 0x27,
              0xa8, 0xce, 0x57, 0x30, 0x6a, 0xa7, 0x71, 0x5a, 0x3d, 0x3b, 0x57, 0x39, 0x7b, 0x56,
              0x84, 0x2f, 0x42, 0x6d, 0x5c, 0xab, 0x0f, 0xb5, 0x4c, 0x93, 0x80, 0x56, 0xf2, 0xb4,
              0x70, 0x5e, 0x13, 0x0f, 0xae, 0x63, 0x6c, 0x8f, 0x21, 0x84, 0x66, 0x11, 0x88, 0x10,
              0xd2, 0x4c, 0xe2, 0xe4, 0x87, 0xbf, 0x76, 0x5f, 0x92, 0x62, 0xc6, 0xb7, 0x94, 0x76,
              0x77, 0x9c, 0xe5, 0x0e, 0x5e, 0x9d, 0x95, 0xce, 0xe0, 0x3b, 0xcd, 0xc4, 0x6e, 0x21,
              0x90, 0xa3, 0x2a, 0x6b, 0xf9, 0x53, 0xb1, 0x2a, 0xec, 0x10, 0xb6, 0x25, 0xc2, 0x74,
              0xe2, 0xd8, 0x37, 0x71, 0xf3, 0x34, 0x48, 0xe4, 0x2b, 0xa4, 0x85, 0x48, 0xcd, 0x5f,
              0x90, 0x35, 0x47, 0x35, 0x4b, 0x19, 0x39, 0x98, 0xc4, 0xd2, 0x4e, 0xa3, 0xce, 0x4d,
              0xe4, 0xdd, 0x5b, 0x88, 0xc1, 0x4d, 0x80, 0xcd, 0x3a, 0x86, 0x33, 0x46, 0xa3, 0x4d,
              0xdf, 0xb8, 0x84, 0x14, 0xda, 0x1e, 0x89, 0xf1, 0xe4, 0x95, 0xaf, 0x89, 0xc3, 0xec,
              0x7a, 0xa0, 0x62, 0x67, 0xfa, 0xc0, 0xed, 0xc1, 0xf5, 0x9a, 0xc7, 0x1e, 0x24, 0xf0,
              0xa9, 0x50, 0xed, 0x18, 0x76, 0x43, 0xd3, 0x77, 0xe1, 0xd3, 0x19, 0x48, 0x85, 0x01,
              0x93, 0x91, 0xde, 0x1e
          }
      },
      // [8] ECDSA Signature using SHA1
      {
          std::make_shared<ECDSASignaturePrivateKeyCtx>(_validEccPrivateKey, DigestTypes::SHA1),
          std::make_shared<ECDSASignaturePublicKeyCtx>(_validEccPublicKey, DigestTypes::SHA1),
          {
              0x30, 0x44, 0x02, 0x20, 0x08, 0x2d, 0x04, 0x4c, 0x12, 0xf1, 0x9a, 0xab, 0x29, 0x58,
              0x5c, 0x58, 0x44, 0xab, 0x67, 0xc9, 0x33, 0x0c, 0x2e, 0x20, 0x04, 0xf5, 0xa3, 0xc1,
              0x14, 0xdf, 0x26, 0xed, 0x13, 0x7e, 0x5d, 0xc0, 0x02, 0x20, 0x59, 0x5f, 0xd6, 0x88,
              0xaa, 0x2e, 0x29, 0xde, 0xf9, 0x38, 0x58, 0x7d, 0x58, 0x28, 0xd7, 0x79, 0x9a, 0xd6,
              0x20, 0x30, 0xae, 0x7e, 0xfb, 0x04, 0xa9, 0x70, 0xec, 0x0b, 0x17, 0xf3, 0x2d, 0x20
          }
      },
      // [9] ECDSA Signature using SHA256
      {
          std::make_shared<ECDSASignaturePrivateKeyCtx>(_validEccPrivateKey, DigestTypes::SHA256),
          std::make_shared<ECDSASignaturePublicKeyCtx>(_validEccPublicKey, DigestTypes::SHA256),
          {
              0x30, 0x45, 0x02, 0x20, 0x79, 0x65, 0x52, 0xe1, 0xd0, 0x2e, 0x8e, 0x14, 0x16, 0xd4,
              0x10, 0x29, 0x38, 0x30, 0x73, 0x5b, 0x49, 0x92, 0x00, 0x21, 0x9e, 0x60, 0x5c, 0x19,
              0xb1, 0x03, 0x4e, 0x2d, 0x59, 0x8e, 0x64, 0xce, 0x02, 0x21, 0x00, 0xd5, 0x48, 0xb1,
              0x91, 0x77, 0xe3, 0x20, 0x7a, 0xe5, 0x09, 0x0a, 0xdb, 0xa4, 0xab, 0xf0, 0x30, 0x9e,
              0xaf, 0x34, 0xb6, 0xa2, 0xd1, 0x1f, 0xe1, 0x38, 0xf8, 0xf1, 0x41, 0x67, 0x3e, 0x81,
              0x2a
          }
      },
      // [10] ECDSA Signature using SHA512
      {
          std::make_shared<ECDSASignaturePrivateKeyCtx>(_validEccPrivateKey, DigestTypes::SHA512),
          std::make_shared<ECDSASignaturePublicKeyCtx>(_validEccPublicKey, DigestTypes::SHA512),
          {
              0x30, 0x45, 0x02, 0x21, 0x00, 0xeb, 0x9b, 0x42, 0x71, 0xab, 0x1c, 0x5e, 0x02, 0x00,
              0xe0, 0x17, 0x95, 0xf2, 0x47, 0x77, 0xf6, 0x5f, 0xc5, 0x91, 0xe5, 0xd2, 0x51, 0xde,
              0xd9, 0x22, 0x9d, 0x4b, 0xab, 0x86, 0xe5, 0xc8, 0x70, 0x02, 0x20, 0x2f, 0xf2, 0x25,
              0x48, 0x93, 0x12, 0xee, 0x9c, 0x65, 0x39, 0xb5, 0x14, 0x4a, 0x6d, 0x20, 0xea, 0x22,
              0x46, 0x4a, 0x90, 0x7b, 0xca, 0xa9, 0x01, 0xf1, 0xb8, 0xae, 0xff, 0x05, 0x80, 0xd9,
              0x3a
          }
      },
      // [11] ECDSA Signature using SHA512 and using a certifcate for the cerification
      {
          std::make_shared<ECDSASignaturePrivateKeyCtx>(_validEccPrivateKey, DigestTypes::SHA512),
          std::make_shared<ECDSASignaturePublicKeyCtx>(_validEccCertificate, DigestTypes::SHA512),
          {
              0x30, 0x45, 0x02, 0x21, 0x00, 0x94, 0x9a, 0x85, 0xda, 0xc4, 0x45, 0xcf, 0x28, 0xfb,
              0x79, 0x38, 0x9b, 0xf0, 0x1c, 0xc8, 0x77, 0x54, 0x7e, 0x86, 0x5c, 0x8c, 0x65, 0x5a,
              0x3f, 0x7b, 0x0f, 0x83, 0x5a, 0xd2, 0x65, 0x0d, 0x38, 0x02, 0x20, 0x2f, 0x9f, 0x3a,
              0x2d, 0x14, 0xd9, 0x45, 0xd0, 0x88, 0x48, 0x40, 0x3d, 0x2b, 0x7e, 0x51, 0x6e, 0x37,
              0x61, 0xe8, 0xc8, 0xfe, 0xcb, 0xb7, 0x49, 0xc0, 0xc2, 0x64, 0x92, 0x46, 0x51, 0x77,
              0xc7
          }
      },
      // [12] Ed448 Signature
      {
          std::make_shared<EdDSASignaturePrivateKeyCtx>(_validEd448PrivateKey),
          std::make_shared<EdDSASignaturePublicKeyCtx>(_validEd448PublicKey),
          {
              0x03, 0x1e, 0x1c, 0x0a, 0x77, 0x56, 0x4b, 0x58, 0x01, 0x7a, 0x63, 0x8c, 0xc5, 0x77, 0xeb,
              0x62, 0x3b, 0x86, 0xc1, 0xf3, 0x93, 0x7b, 0x37, 0x52, 0x09, 0x42, 0x1e, 0x6f, 0x36, 0xd9,
              0xca, 0xaa, 0xc6, 0x82, 0x73, 0x40, 0x5a, 0xe4, 0xa5, 0x08, 0x78, 0xe0, 0xac, 0xdb, 0x6b,
              0xac, 0x04, 0x22, 0x87, 0x3d, 0x62, 0xa1, 0x33, 0xab, 0x96, 0x26, 0x80, 0x25, 0x1b, 0xf2,
              0xd0, 0xeb, 0x1c, 0x67, 0x95, 0xb9, 0xa1, 0x22, 0x35, 0x83, 0x07, 0x48, 0x72, 0xe6, 0xd5,
              0x31, 0xd0, 0x23, 0xa7, 0x13, 0x8b, 0xd2, 0xe8, 0xcf, 0x83, 0xb2, 0x20, 0x0d, 0xc8, 0xfb,
              0x7c, 0xa6, 0x4a, 0x86, 0xb6, 0xde, 0x95, 0x0f, 0x3c, 0x4d, 0x94, 0x48, 0xda, 0xfe, 0xd6,
              0x53, 0xa3, 0xe5, 0xf5, 0xfb, 0x32, 0xa5, 0x1a, 0x00
          }
      },
      // [13] Ed448 Signature with certificate
      {
          std::make_shared<EdDSASignaturePrivateKeyCtx>(_validEd448PrivateKey),
          std::make_shared<EdDSASignaturePublicKeyCtx>(_validEd448Certificate),
          {
              0x03, 0x1e, 0x1c, 0x0a, 0x77, 0x56, 0x4b, 0x58, 0x01, 0x7a, 0x63, 0x8c, 0xc5, 0x77, 0xeb,
              0x62, 0x3b, 0x86, 0xc1, 0xf3, 0x93, 0x7b, 0x37, 0x52, 0x09, 0x42, 0x1e, 0x6f, 0x36, 0xd9,
              0xca, 0xaa, 0xc6, 0x82, 0x73, 0x40, 0x5a, 0xe4, 0xa5, 0x08, 0x78, 0xe0, 0xac, 0xdb, 0x6b,
              0xac, 0x04, 0x22, 0x87, 0x3d, 0x62, 0xa1, 0x33, 0xab, 0x96, 0x26, 0x80, 0x25, 0x1b, 0xf2,
              0xd0, 0xeb, 0x1c, 0x67, 0x95, 0xb9, 0xa1, 0x22, 0x35, 0x83, 0x07, 0x48, 0x72, 0xe6, 0xd5,
              0x31, 0xd0, 0x23, 0xa7, 0x13, 0x8b, 0xd2, 0xe8, 0xcf, 0x83, 0xb2, 0x20, 0x0d, 0xc8, 0xfb,
              0x7c, 0xa6, 0x4a, 0x86, 0xb6, 0xde, 0x95, 0x0f, 0x3c, 0x4d, 0x94, 0x48, 0xda, 0xfe, 0xd6,
              0x53, 0xa3, 0xe5, 0xf5, 0xfb, 0x32, 0xa5, 0x1a, 0x00
          }
      },
      // [14] Ed25519 Signature
      {
          std::make_shared<EdDSASignaturePrivateKeyCtx>(_validEd25519PrivateKey),
          std::make_shared<EdDSASignaturePublicKeyCtx>(_validEd25519PublicKey),
          {
              0xb0, 0xcd, 0x02, 0xef, 0xd6, 0x35, 0x8b, 0x7c, 0x88, 0xed, 0x39, 0xd2, 0x4d, 0x7e, 0xa5,
              0x78, 0xaa, 0x2c, 0x5a, 0x5c, 0x73, 0xda, 0xfa, 0x6d, 0x8d, 0x9c, 0x57, 0x65, 0x8d, 0x7d,
              0x4e, 0xd2, 0xb9, 0xe0, 0xe9, 0x08, 0x35, 0xb6, 0x77, 0xb7, 0x15, 0xb5, 0x33, 0x0e, 0x77,
              0xe1, 0xa5, 0x88, 0x9c, 0x77, 0x19, 0xc9, 0x08, 0x07, 0x44, 0xcc, 0x4e, 0x84, 0xae, 0xda,
              0x9c, 0xd7, 0x3a, 0x02
          }
      },
      // [15] Ed25519 Signature with certificate
      {
          std::make_shared<EdDSASignaturePrivateKeyCtx>(_validEd25519PrivateKey),
          std::make_shared<EdDSASignaturePublicKeyCtx>(_validEd25519Certificate),
          {
              0xb0, 0xcd, 0x02, 0xef, 0xd6, 0x35, 0x8b, 0x7c, 0x88, 0xed, 0x39, 0xd2, 0x4d, 0x7e, 0xa5,
              0x78, 0xaa, 0x2c, 0x5a, 0x5c, 0x73, 0xda, 0xfa, 0x6d, 0x8d, 0x9c, 0x57, 0x65, 0x8d, 0x7d,
              0x4e, 0xd2, 0xb9, 0xe0, 0xe9, 0x08, 0x35, 0xb6, 0x77, 0xb7, 0x15, 0xb5, 0x33, 0x0e, 0x77,
              0xe1, 0xa5, 0x88, 0x9c, 0x77, 0x19, 0xc9, 0x08, 0x07, 0x44, 0xcc, 0x4e, 0x84, 0xae, 0xda,
              0x9c, 0xd7, 0x3a, 0x02
          }
      }
  };
  
  const std::vector<uint8_t>& SignatureTest::_validPKCS1SignatureSHA256 = SignatureTestData[1].validSignature;
  const std::vector<uint8_t>& SignatureTest::_validEccSignatureSHA1 = SignatureTestData[8].validSignature;
  const std::vector<uint8_t>& SignatureTest::_validEd448Signature = SignatureTestData[12].validSignature;
  const std::vector<uint8_t>& SignatureTest::_validEd25519Signature = SignatureTestData[14].validSignature;
  
  const std::vector<uint8_t> SignatureTest::signVerifyTestMessage = {
      'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!'
  };
  
  /**
   * @brief Tests whether the created signatures will pass the verification
   */
  TEST_P(SignatureTest, testSuccessfulSignatureAndVerification)
  {
      auto dataSet = GetParam();
      std::vector<uint8_t> signature;
  
      EXPECT_NO_THROW(signature = dataSet.signCtx->signMessage(signVerifyTestMessage));
      EXPECT_NO_THROW(dataSet.verifyCtx->verifyMessage(signature, signVerifyTestMessage));
  }
  
  /**
   * @brief Tests whether modified signatures will not pass the verification
   */
  TEST_P(SignatureTest, testUnsuccessfulSignatureAndVerificationWithModifiedSignature)
  {
      auto dataSet = GetParam();
      std::vector<uint8_t> signature;
  
      EXPECT_NO_THROW(signature = dataSet.signCtx->signMessage(signVerifyTestMessage));
      signature.front() ^= 0xaa;
      signature.back() ^= 0xaa;
      ASSERT_THROW(dataSet.verifyCtx->verifyMessage(signature, signVerifyTestMessage), MoCOCrWException);
  }
  
  /**
   * @brief Tests whether a known valid signature can be verified
   */
  TEST_P(SignatureTest, testSuccessfullVerificationOfKnownValidSignature)
  {
      auto param = GetParam();
      EXPECT_NO_THROW(param.verifyCtx->verifyMessage(param.validSignature, signVerifyTestMessage));
  }
  
  INSTANTIATE_TEST_CASE_P(testSuccessfulSigningAndVerification, SignatureTest,
                          testing::ValuesIn(SignatureTest::SignatureTestData));
  
  INSTANTIATE_TEST_CASE_P(testUnsuccessfulSignatureAndVerificationWithModifiedSignature, SignatureTest,
                          testing::ValuesIn(SignatureTest::SignatureTestData));
  
  INSTANTIATE_TEST_CASE_P(testSuccessfullVerificationOfKnownValidSignature, SignatureTest,
                          testing::ValuesIn(SignatureTest::SignatureTestData));
  
  
  /**
   * @brief Tests whether the RSA signature context is creating the same PKCS1 signature
   * by comparing the result to a known signature.
   */
  TEST_F(SignatureTest, testSuccessfulRsaSignatureOfMessageDigestPKCS1ComparedToKnownOutput)
  {
      std::vector<uint8_t> signature;
  
      auto ctx256 = RSASignaturePrivateKeyCtx(_validRsaPrivateKey, DigestTypes::SHA256, _PKCSPadding);
      EXPECT_NO_THROW(signature = ctx256.signDigest(_testMessageDigestSHA256));
      EXPECT_EQ(_validPKCS1SignatureSHA256, signature);
   }
  
  /**
   * @brief Unsuccessful case where the message digest length is incompatible with the padding mode,
   *        when using PKCS1.
   */
  TEST_F(SignatureTest, testUnsuccessfulRsaSignatureWithInvalidDigestLengthPKCS1)
  {
      std::vector<uint8_t> signature;
      std::vector<uint8_t> messageDigest;
  
      messageDigest = sha256(_testMessageDigestSHA1);
  
      auto signCtx512 = RSASignaturePrivateKeyCtx(_keyPairRsa, DigestTypes::SHA512, _PKCSPadding);
      EXPECT_THROW(signature = signCtx512.signDigest(messageDigest), MoCOCrWException);
  }
  
  /**
   * @brief Signature fails due to an invalid salt length value.
   */
  TEST_F(SignatureTest, testUnsuccessfulRsaSignatureWithInvalidSaltLength)
  {
      auto padding = std::make_shared<PSSPadding>(std::make_shared<MGF1>(), -200);
      auto signCtx256 = RSASignaturePrivateKeyCtx(_keyPairRsa, DigestTypes::SHA256, padding);
      /* Invalid case */
      ASSERT_THROW(signCtx256.signDigest(_testMessageDigestSHA256), MoCOCrWException);
  }
  
  /**
   * @brief Verification fails due to an invalid public key.
   */
  TEST_F(SignatureTest, testUnsuccessfulRsaVerificationWithWrongPublicKey)
  {
      std::vector<uint8_t> signature;
  
      auto signCtx256 = RSASignaturePrivateKeyCtx(_keyPairRsa, DigestTypes::SHA256, _PSSPadding);
      EXPECT_NO_THROW(signature = signCtx256.signDigest(_testMessageDigestSHA256));
  
      /* Load Public Key file */
      auto pubKey = loadPubkeyFromFile("root1.pubkey.pem");
      auto verifyCtx256 = RSASignaturePublicKeyCtx(pubKey, DigestTypes::SHA256, _PSSPadding);
  
      /* Using different public key */
      ASSERT_THROW(verifyCtx256.verifyDigest(signature, _testMessageDigestSHA256), MoCOCrWException);
  }
  
  /**
   * @brief Verification fails due to an invalid padding mode.
   */
  TEST_F(SignatureTest, testUnsuccessfulRsaVerificationWithWrongPadding)
  {
      std::vector<uint8_t> signature;
  
      auto signCtx256 = RSASignaturePrivateKeyCtx(_keyPairRsa, DigestTypes::SHA256, _PSSPadding);
      EXPECT_NO_THROW(signature = signCtx256.signDigest(_testMessageDigestSHA256));
  
      auto verifyCtx256 = RSASignaturePublicKeyCtx(_keyPairRsa, DigestTypes::SHA256, _PKCSPadding);
      ASSERT_THROW(verifyCtx256.verifyDigest(signature, _testMessageDigestSHA256), MoCOCrWException);
  }
  
  /**
   * @brief Verification fails due to an invalid hashing function.
   */
  TEST_F(SignatureTest, testUnsuccessfulRsaVerificationWithWrongHashingFunction)
  {
      std::vector<uint8_t> signature;
  
      auto signCtx256 = RSASignaturePrivateKeyCtx(_keyPairRsa, DigestTypes::SHA256, _PSSPadding);
      EXPECT_NO_THROW(signature = signCtx256.signDigest(_testMessageDigestSHA256));
  
      auto verifyCtx512 = RSASignaturePublicKeyCtx(_keyPairRsa, DigestTypes::SHA512, _PSSPadding);
      ASSERT_THROW(verifyCtx512.verifyDigest(signature, _testMessageDigestSHA256), MoCOCrWException);
  }
  
  /**
   * @brief Verification fails due to an invalid masking function.
   */
  TEST_F(SignatureTest, testUnsuccessfulRsaVerificationWithWrongMaskingFunction)
  {
      std::vector<uint8_t> signature;
  
      auto signCtx256 = RSASignaturePrivateKeyCtx(_keyPairRsa, DigestTypes::SHA256, _PSSPadding);
      EXPECT_NO_THROW(signature = signCtx256.signDigest(_testMessageDigestSHA256));
  
      auto padding = std::make_shared<PSSPadding>(std::make_shared<MGF1>(DigestTypes::SHA512));
      auto verifyCtx256_512 = RSASignaturePublicKeyCtx(_keyPairRsa, DigestTypes::SHA256, padding);
      ASSERT_THROW(verifyCtx256_512.verifyDigest(signature, _testMessageDigestSHA256), MoCOCrWException);
  }
  
  /**
   * @brief Verification fails due to an invalid salt length.
   */
  TEST_F(SignatureTest, testUnsuccessfulRsaVerificationWithWrongSaltLength)
  {
      std::vector<uint8_t> signature;
  
      auto signCtx256 = RSASignaturePrivateKeyCtx(_keyPairRsa, DigestTypes::SHA256, _PSSPadding);
      EXPECT_NO_THROW(signature = signCtx256.signDigest(_testMessageDigestSHA256));
  
      auto padding = std::make_shared<PSSPadding>(std::make_shared<MGF1>(DigestTypes::SHA256), 2);
      auto verifyCtx256 = RSASignaturePublicKeyCtx(_keyPairRsa, DigestTypes::SHA256, padding);
      ASSERT_THROW(verifyCtx256.verifyDigest(signature, _testMessageDigestSHA256), MoCOCrWException);
  }
  
  /**
   * @brief Unsuccessful verification due to an invalid ECC public key.
   */
  TEST_F(SignatureTest, testUnsuccessfulEccVerificationWithWrongPublicKey)
  {
      auto verifyCtx1 = ECDSASignaturePublicKeyCtx(_invalidEccPublicKey, DigestTypes::SHA1);
      ASSERT_THROW(verifyCtx1.verifyDigest(_validEccSignatureSHA1,  _testMessageDigestSHA1),
                   MoCOCrWException);
  }
  
  /**
   * @brief Tests that verification of an Ed25519 signature using a wrong public key fails.
   */
  TEST_F(SignatureTest, testUnsuccessfulEd25519VerificationWithWrongPublicKey)
  {
      auto verifyCtx = EdDSASignaturePublicKeyCtx(_keyPairEd25519);
      ASSERT_THROW(verifyCtx.verifyMessage(_validEd25519Signature, signVerifyTestMessage), MoCOCrWException);
  }
  
  /**
   * @brief Tests that verification of an Ed448 signature using a wrong public key fails.
   */
  TEST_F(SignatureTest, testUnsuccessfulEd448VerificationWithWrongPublicKey)
  {
      auto verifyCtx = EdDSASignaturePublicKeyCtx(_keyPairEd448);
      ASSERT_THROW(verifyCtx.verifyMessage(_validEd448Signature, signVerifyTestMessage), MoCOCrWException);
  }
  