/*############################################################################
# Copyright 2016 Intel Corporation
#
# 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.
############################################################################*/

/*!
* \file
* \brief Test fixture class for EpidVerifier.
*/
#include <vector>
#include "epid/verifier/1.1/unittests/verifier-testhelper.h"
const Epid11G3ElemStr Epid11VerifierTest::kG3IdentityStr = {0};
const Epid11GroupPubKey Epid11VerifierTest::kPubKeyStr = {
    // gid
    {
        0x00, 0x00, 0x00, 0x7b,
    },
    // h1
    {{0x08, 0x4a, 0x9d, 0x2e, 0xf9, 0x4f, 0x78, 0x02, 0xd7, 0x89, 0x75, 0xb4,
      0xe7, 0x25, 0x26, 0x9f, 0x00, 0x57, 0xad, 0x33, 0x30, 0xea, 0xa9, 0x6c,
      0x00, 0x9e, 0x8b, 0xc8, 0x13, 0x23, 0xcb, 0x06},
     {0x04, 0xbe, 0x42, 0x74, 0x11, 0x07, 0xb1, 0x06, 0xd7, 0xef, 0x5f, 0x66,
      0x87, 0xd9, 0xfa, 0xdd, 0x53, 0xae, 0xd7, 0xf4, 0x54, 0xf8, 0xd0, 0x21,
      0x75, 0xe0, 0x07, 0x44, 0xc9, 0xc3, 0x4e, 0xf7}},
    // h2
    {{0x06, 0xd8, 0xa9, 0x90, 0x02, 0x8f, 0xca, 0xa5, 0x73, 0x36, 0x24, 0x03,
      0xc9, 0xa8, 0x7e, 0x9d, 0x64, 0x12, 0xac, 0xa7, 0xbd, 0x17, 0x7f, 0x7c,
      0x96, 0x8d, 0x2e, 0x13, 0xd9, 0xb2, 0x69, 0x47},
     {0x09, 0xdb, 0xe3, 0xbf, 0xbc, 0xa1, 0x34, 0x0f, 0xc6, 0xe2, 0x00, 0x3d,
      0x98, 0xa3, 0x7d, 0xab, 0xd4, 0x0e, 0xec, 0xde, 0x4f, 0x97, 0xa9, 0xbb,
      0xdd, 0x60, 0x94, 0x24, 0x7b, 0xb3, 0xf5, 0x94}},
    // w
    {{{0x02, 0x43, 0x78, 0x9f, 0x54, 0xc1, 0x21, 0x3a, 0x2b, 0x4d, 0x12, 0x65,
       0x2f, 0x51, 0x94, 0xc6, 0x34, 0x24, 0xd9, 0x7b, 0x06, 0x3a, 0xc4, 0xf5,
       0x56, 0xeb, 0x32, 0xe3, 0xee, 0x7b, 0xad, 0x6b},
      {0x04, 0x90, 0x86, 0x31, 0x18, 0x2a, 0xa4, 0xcf, 0xa3, 0x90, 0xa5, 0x80,
       0x7b, 0xae, 0x3b, 0xb1, 0x77, 0x03, 0xe7, 0x7e, 0xf2, 0xfc, 0x6d, 0x3a,
       0xab, 0x8f, 0xbf, 0x95, 0x40, 0xed, 0x08, 0x03},
      {0x01, 0x05, 0x86, 0xf5, 0x42, 0xea, 0x4d, 0xf7, 0x4f, 0xef, 0x46, 0xdf,
       0x8f, 0xe8, 0x2d, 0xbb, 0x5d, 0x0d, 0x2f, 0x4f, 0xf4, 0xd8, 0x31, 0xc6,
       0x5a, 0x97, 0x98, 0x44, 0xcf, 0x42, 0x5a, 0xf3}},
     {{0x03, 0x5f, 0xb6, 0x38, 0x45, 0x5a, 0x15, 0x1e, 0xb9, 0x54, 0xfa, 0x2c,
       0x3f, 0x68, 0x7b, 0x4e, 0x85, 0x35, 0xf3, 0x5b, 0xe5, 0xdc, 0x96, 0x2b,
       0x18, 0x84, 0x5e, 0x1e, 0x53, 0xdc, 0x22, 0x23},
      {0x06, 0x08, 0x91, 0x5a, 0x2d, 0x27, 0xe2, 0x12, 0x69, 0xfa, 0xab, 0x19,
       0x7c, 0x47, 0x6b, 0xec, 0xde, 0xc6, 0x25, 0xd4, 0x43, 0xb4, 0x65, 0x23,
       0x61, 0x0f, 0x1f, 0x2d, 0xfd, 0xb1, 0x18, 0xb0},
      {0x04, 0x8e, 0x1a, 0xc5, 0x95, 0x9a, 0x0e, 0x37, 0x7c, 0x5e, 0x95, 0x38,
       0xc2, 0xcf, 0xfa, 0x1f, 0xe3, 0x3a, 0x2b, 0x85, 0xa5, 0xfd, 0x6b, 0xc4,
       0x1d, 0xfb, 0x47, 0x27, 0xaf, 0xc1, 0x94, 0xcd}}}};
const Epid11Params Epid11VerifierTest::kParamsStr = {
#include "epid/common/1.1/src/epid11params_tate.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kGrpXPrivRl = {
#include "epid/common-testhelper/1.1/testdata/grp_x/privrl.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kGrpXPrivRlSingleEntry = {
#include "epid/common-testhelper/1.1/testdata/grp_x/privrl_single_entry.inc"
};

const Epid11VerifierPrecomp Epid11VerifierTest::kVerifierPrecompStr = {
#include "epid/verifier/1.1/unittests/testdata/verifier_precmp.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kSigRl = {
    // gid
    0x00, 0x00, 0x00, 0x7b,
    // rev
    0x00, 0x00, 0x00, 0x02,
    // n2
    0x00, 0x00, 0x00, 0x02,
    // bks
    // bk1
    0x09, 0x0d, 0x6f, 0x82, 0x77, 0x88, 0x49, 0x53, 0xba, 0x1e, 0x1b, 0x0e,
    0x5e, 0xae, 0xc0, 0x27, 0xad, 0xe3, 0xb1, 0x09, 0x4f, 0xcd, 0xb6, 0xe6,
    0x6f, 0x7f, 0xa3, 0x1a, 0x1e, 0xfb, 0x52, 0x72, 0xfa, 0x85, 0x0f, 0x5c,
    0x97, 0x61, 0xbf, 0x46, 0x7e, 0xec, 0xd6, 0x64, 0xda, 0xa9, 0x8e, 0xf5,
    0xd3, 0xdf, 0xfa, 0x13, 0x5a, 0xb2, 0x3e, 0xeb, 0x0a, 0x9d, 0x02, 0xc0,
    0x33, 0xec, 0x2a, 0x70, 0x41, 0xb7, 0xa4, 0xc8, 0x43, 0x3f, 0x0b, 0xc2,
    0x80, 0x31, 0xbe, 0x75, 0x65, 0xe9, 0xbb, 0x81, 0x73, 0x5b, 0x91, 0x4f,
    0x3f, 0xd7, 0xbe, 0xb5, 0x19, 0x56, 0x3f, 0x18, 0x95, 0xea, 0xc1, 0xd7,
    0xa4, 0x5e, 0xb9, 0x86, 0xfc, 0xe5, 0xc4, 0x0f, 0x54, 0x37, 0xab, 0xed,
    0x59, 0x20, 0xce, 0x67, 0x68, 0x3c, 0x25, 0x4d, 0xbc, 0x5f, 0x6a, 0x4d,
    0x5a, 0xa7, 0x93, 0xce, 0x90, 0x2d, 0x3e, 0x5a,
    // bk2
    0x67, 0x58, 0xb2, 0x9c, 0xad, 0x61, 0x1f, 0xfb, 0x74, 0x23, 0xea, 0x40,
    0xe9, 0x66, 0x26, 0xb0, 0x43, 0xdc, 0x7e, 0xc7, 0x48, 0x88, 0x56, 0x59,
    0xf3, 0x35, 0x9f, 0xdb, 0xfa, 0xa2, 0x49, 0x51, 0x85, 0x35, 0x42, 0x50,
    0x8e, 0x79, 0x79, 0xc0, 0x6c, 0xcc, 0x39, 0x0b, 0xad, 0x3b, 0x39, 0x33,
    0xae, 0xb2, 0xa1, 0xc5, 0x28, 0x6f, 0x48, 0x3a, 0xd2, 0x63, 0x5d, 0xfb,
    0x1b, 0x1f, 0x8a, 0x63, 0x5b, 0x9f, 0xe7, 0x93, 0x5f, 0xc6, 0x1e, 0xe5,
    0x9b, 0x52, 0x04, 0x03, 0x85, 0x28, 0x5c, 0x24, 0x96, 0xaa, 0xbb, 0xe1,
    0xdd, 0x03, 0x90, 0x68, 0xe0, 0x13, 0xe8, 0x90, 0x9e, 0x68, 0x8e, 0xa0,
    0xec, 0x7b, 0xf5, 0xe9, 0x29, 0x4a, 0x3e, 0x78, 0xbd, 0xb6, 0x3c, 0x10,
    0xf8, 0xec, 0xc6, 0x2c, 0x4b, 0x4d, 0x8a, 0xc1, 0x3d, 0x65, 0xf5, 0x93,
    0x8d, 0x5b, 0x07, 0x3f, 0x78, 0x92, 0x1c, 0xfa};
const std::vector<uint8_t> Epid11VerifierTest::kEmptySigRl = {
    // gid
    0x00, 0x00, 0x00, 0x7b,
    // rev
    0x00, 0x00, 0x00, 0x00,
    // n2
    0x00, 0x00, 0x00, 0x00,
    // not bk's
};

const OctStr32 Epid11VerifierTest::kOctStr32_1 = {0x00, 0x00, 0x00, 0x01};

const std::vector<uint8_t> Epid11VerifierTest::kGroupRlEmptyBuf = {
    // RLVer
    0x00, 0x00, 0x00, 0x00,
    // n3
    0x00, 0x00, 0x00, 0x00};

const std::vector<uint8_t> Epid11VerifierTest::kGroupRl3GidBuf = {
    // RLVer
    0x00, 0x00, 0x00, 0x03,
    // n3
    0x00, 0x00, 0x00, 0x03,
    // gid[0]
    0x00, 0x00, 0x00, 0x01,
    // gid[1]
    0x00, 0x00, 0x00, 0x02,
    // gid[2]
    0x00, 0x00, 0x00, 0x03,
};

const std::vector<uint8_t> Epid11VerifierTest::kMsg0 = {
    't', 'e', 's', 't', ' ', 'm', 'e', 's', 's', 'a', 'g', 'e'};
const std::vector<uint8_t> Epid11VerifierTest::kBsn0 = {'b', 'a', 's', 'e', 'n',
                                                        'a', 'm', 'e', '1'};

const std::vector<uint8_t> Epid11VerifierTest::kSigGrpXMember0Sha256Bsn0Msg0 = {
#include "epid/common-testhelper/1.1/testdata/grp_x/member0/sig_sha256_bsn0_msg0.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kSigGrpXMember0Sha256Bsn0Msg0SingleEntry = {
#include "epid/common-testhelper/1.1/testdata/grp_x/member0/sig_sha256_bsn0_msg0_single_entry.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kSigGrpXMember0Sha256Bsn0Msg0ThreeEntry = {
#include "epid/common-testhelper/1.1/testdata/grp_x/member0/sig_sha256_bsn0_msg0_three_entry.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kSigGrpXMember0Sha256Bsn0Msg1 = {
#include "epid/common-testhelper/1.1/testdata/grp_x/member0/sig_sha256_bsn0_msg1.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kSigGrpXMember0Sha256Bsn1Msg0 = {
#include "epid/common-testhelper/1.1/testdata/grp_x/member0/sig_sha256_bsn1_msg0.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kSigGrpXMember0Sha256RandbaseMsg0 = {
#include "epid/common-testhelper/1.1/testdata/grp_x/member0/sig_sha256_rndbase_msg0.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kSigGrpXMember0Sha256RandbaseMsg0N2One = {
#include "epid/common-testhelper/1.1/testdata/grp_x/sig_sha256_bsnrnd_msg0.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kSigGrpXMember0Sha256RandbaseMsg1 = {
#include "epid/common-testhelper/1.1/testdata/grp_x/member0/sig_sha256_rndbase_msg1.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kSigGrpXMember1Sha256Bsn0Msg0 = {
#include "epid/common-testhelper/1.1/testdata/grp_x/member1/sig_sha256_bsn0_msg0.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kSigGrpXRevokedPrivKey000Sha256Bsn0Msg0 = {
#include "epid/common-testhelper/1.1/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey000.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kSigGrpXRevokedPrivKey001Sha256Bsn0Msg0 = {
#include "epid/common-testhelper/1.1/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey001.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kSigGrpXRevokedPrivKey002Sha256Bsn0Msg0 = {
#include "epid/common-testhelper/1.1/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey002.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kGrpRlRevokedGrpXSingleEntry = {
#include "epid/common-testhelper/1.1/testdata/grprl_revoked_grp_x_single_entry.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kGrpRlRevokedGrpXFirstEntry = {
#include "epid/common-testhelper/1.1/testdata/grprl_revoked_grp_x_first_entry.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kGrpRlRevokedGrpXMiddleEntry = {
#include "epid/common-testhelper/1.1/testdata/grprl_revoked_grp_x_middle_entry.inc"
};
const std::vector<uint8_t> Epid11VerifierTest::kGrpRlRevokedGrpXLastEntry = {
#include "epid/common-testhelper/1.1/testdata/grprl_revoked_grp_x_last_entry.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kGrpXSigRlMember0Bsn0Msg0SingleEntry = {
#include "epid/common-testhelper/1.1/testdata/grp_x/sigrl_member0_sig_bsn0_msg0_revoked_single_entry.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kGrpXSigRlMember0Bsn0Msg0FirstEntry = {
#include "epid/common-testhelper/1.1/testdata/grp_x/sigrl_member0_sig_bsn0_msg0_revoked_first_entry.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kGrpXSigRlMember0Bsn0Msg0MiddleEntry = {
#include "epid/common-testhelper/1.1/testdata/grp_x/sigrl_member0_sig_bsn0_msg0_revoked_middle_entry.inc"
};
const std::vector<uint8_t>
    Epid11VerifierTest::kGrpXSigRlMember0Bsn0Msg0LastEntry = {
#include "epid/common-testhelper/1.1/testdata/grp_x/sigrl_member0_sig_bsn0_msg0_revoked_last_entry.inc"
};
