123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- /*############################################################################
- # Copyright 2017 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.
- ############################################################################*/
- /// TPM fixture class implementation.
- /*! \file */
- #include "epid/member/tpm2/unittests/tpm2-testhelper.h"
- #include <climits>
- #include <cstring>
- #include "epid/common-testhelper/epid2params_wrapper-testhelper.h"
- #include "epid/common-testhelper/epid_params-testhelper.h"
- extern "C" {
- #include "epid/common/types.h"
- }
- bool operator==(FpElemStr const& lhs, FpElemStr const& rhs) {
- return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
- }
- bool operator==(G1ElemStr const& lhs, G1ElemStr const& rhs) {
- return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs));
- }
- const std::vector<uint8_t> EpidTpm2Test::kTpmFfElemStrData = {
- 0x98, 0x34, 0x87, 0x6d, 0xcf, 0xb0, 0x5c, 0xb1, 0x67, 0xa5, 0xc2,
- 0x49, 0x53, 0xeb, 0xa5, 0x8c, 0x4a, 0xc8, 0x9b, 0x1a, 0xdf, 0x57,
- 0xf2, 0x8f, 0x2f, 0x9d, 0x09, 0xaf, 0x10, 0x7e, 0xe8, 0xf0};
- const G1ElemStr EpidTpm2Test::kEpidPointStr = {
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}};
- const uint8_t
- EpidTpm2Test::kDigestSha256[EPID_SHA256_DIGEST_BITSIZE / CHAR_BIT] = {
- 0x11, 0x40, 0xb5, 0x6c, 0x6d, 0x47, 0x09, 0x0b, 0x05, 0xd6, 0x43,
- 0x56, 0xe0, 0x7c, 0xc6, 0x8e, 0xa1, 0x65, 0x67, 0xfd, 0xa7, 0x07,
- 0x87, 0x9b, 0x36, 0x2d, 0x41, 0x35, 0x63, 0x61, 0x31, 0x22};
- const FpElemStr EpidTpm2Test::kMemberFValue = {
- 0x48, 0x40, 0xb5, 0x6c, 0x6d, 0x47, 0x09, 0x0b, 0x05, 0xd6, 0x43,
- 0x56, 0xe0, 0x7c, 0xc6, 0x8e, 0xa1, 0x65, 0x67, 0xfd, 0xa7, 0x07,
- 0x87, 0x9b, 0x36, 0x2d, 0x41, 0x35, 0x63, 0x61, 0x31, 0xc7};
- const G1ElemStr EpidTpm2Test::kP1Str = {
- {{{0x12, 0xA6, 0x5B, 0xD6, 0x91, 0x8D, 0x50, 0xA7, 0x66, 0xEB, 0x7D,
- 0x52, 0xE3, 0x40, 0x17, 0x60, 0x7F, 0xDF, 0x6C, 0xA1, 0x2C, 0x1A,
- 0x37, 0xE0, 0x92, 0xC0, 0xF7, 0xB9, 0x76, 0xAB, 0xB1, 0x8A}}},
- {{{0x78, 0x65, 0x28, 0xCB, 0xAF, 0x07, 0x52, 0x50, 0x55, 0x7A, 0x5F,
- 0x30, 0x0A, 0xC0, 0xB4, 0x6B, 0xEA, 0x6F, 0xE2, 0xF6, 0x6D, 0x96,
- 0xF7, 0xCD, 0xC8, 0xD3, 0x12, 0x7F, 0x1F, 0x3A, 0x8B, 0x42}}}};
- const G1ElemStr EpidTpm2Test::kg1Str = {
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}};
- const std::vector<uint8_t> EpidTpm2Test::kS2Sha256 = {0, 0, 0, 4,
- 'a', 'b', 'c'};
- const FqElemStr EpidTpm2Test::kY2Sha256Str = {
- {{0x8A, 0x43, 0xA1, 0x04, 0xB1, 0x3F, 0x3C, 0xB4, 0xBD, 0x67, 0x38,
- 0xB1, 0x07, 0xF0, 0x7A, 0x32, 0x7E, 0xCD, 0xF0, 0x2E, 0x62, 0x3E,
- 0x2C, 0x1F, 0x48, 0xAA, 0x0D, 0x6C, 0xDC, 0x48, 0xF9, 0xF7}}};
- const G1ElemStr EpidTpm2Test::kP2Sha256Str = {
- {{{0x2E, 0xBB, 0x50, 0x4D, 0x88, 0xFF, 0x25, 0x62, 0xF3, 0x71, 0x65,
- 0x81, 0xAD, 0xBE, 0x83, 0x6E, 0x54, 0xF5, 0xA6, 0x2A, 0x70, 0xE6,
- 0x18, 0x6B, 0xD5, 0x4A, 0x10, 0x3C, 0x80, 0x08, 0x95, 0x3D}}},
- {{{0x8A, 0x43, 0xA1, 0x04, 0xB1, 0x3F, 0x3C, 0xB4, 0xBD, 0x67, 0x38,
- 0xB1, 0x07, 0xF0, 0x7A, 0x32, 0x7E, 0xCD, 0xF0, 0x2E, 0x62, 0x3E,
- 0x2C, 0x1F, 0x48, 0xAA, 0x0D, 0x6C, 0xDC, 0x48, 0xF9, 0xF7}}}};
- const G1ElemStr EpidTpm2Test::kP2Sha256ExpF = {
- {{{0xd0, 0xf3, 0xd9, 0xea, 0x45, 0x24, 0x96, 0xb8, 0x3e, 0x2f, 0xf2,
- 0x18, 0x12, 0xad, 0xa7, 0xab, 0xe3, 0x1e, 0xff, 0xe7, 0xf7, 0x61,
- 0x28, 0xae, 0x0a, 0x7c, 0x0f, 0xd9, 0x74, 0x0f, 0x4a, 0x94}}},
- {{{0xb7, 0xda, 0xd5, 0x97, 0x33, 0xab, 0xb6, 0x3c, 0xf7, 0x3b, 0xec,
- 0xa4, 0x7f, 0xe6, 0x23, 0xd4, 0xf6, 0xe2, 0x9b, 0xdb, 0xa6, 0xbb,
- 0xdf, 0xee, 0x62, 0x33, 0xcd, 0x88, 0x25, 0x52, 0xba, 0x99}}}};
- const std::vector<uint8_t> EpidTpm2Test::kS2Sha384 = {0, 0, 0, 0,
- 'a', 'b', 'c'};
- const FqElemStr EpidTpm2Test::kY2Sha384Str = {
- {{0x0E, 0x86, 0x11, 0x90, 0xAF, 0xEF, 0xEB, 0x79, 0x4B, 0x3E, 0x80,
- 0x92, 0x94, 0x3B, 0x2F, 0x5E, 0x72, 0x21, 0xEF, 0xF8, 0xBC, 0xE3,
- 0x48, 0xA9, 0xD0, 0x31, 0x19, 0xAC, 0xD1, 0xD7, 0x49, 0x87}}};
- const G1ElemStr EpidTpm2Test::kP2Sha384Str = {
- {{{0xE1, 0xC8, 0x28, 0xB1, 0x9A, 0xDF, 0x5D, 0x4B, 0xC4, 0x25, 0x90,
- 0xFB, 0x38, 0x20, 0xD4, 0x8B, 0x30, 0x8F, 0x95, 0x76, 0xC3, 0x7F,
- 0x9D, 0xAD, 0x94, 0xC4, 0x31, 0x80, 0xD7, 0xDF, 0xD5, 0xFE}}},
- {{{0x0E, 0x86, 0x11, 0x90, 0xAF, 0xEF, 0xEB, 0x79, 0x4B, 0x3E, 0x80,
- 0x92, 0x94, 0x3B, 0x2F, 0x5E, 0x72, 0x21, 0xEF, 0xF8, 0xBC, 0xE3,
- 0x48, 0xA9, 0xD0, 0x31, 0x19, 0xAC, 0xD1, 0xD7, 0x49, 0x87}}}};
- const G1ElemStr EpidTpm2Test::kP2Sha384ExpF = {
- {{{0x97, 0x90, 0xaf, 0xe1, 0xc3, 0x7d, 0x6f, 0xf3, 0x71, 0x88, 0x6c,
- 0x8b, 0x20, 0xc8, 0x50, 0x0d, 0x74, 0x31, 0x2a, 0x7e, 0x7c, 0x8c,
- 0xba, 0xf1, 0xd9, 0xac, 0x2f, 0xb9, 0x7a, 0xbc, 0xbb, 0x58}}},
- {{{0xad, 0x2b, 0xcf, 0x14, 0x2f, 0x60, 0xbb, 0xc8, 0xea, 0x9d, 0x8a,
- 0x54, 0xa6, 0x3b, 0x3b, 0x46, 0x84, 0xdf, 0x72, 0xe2, 0xa9, 0x91,
- 0x2b, 0x06, 0xe5, 0x7f, 0x63, 0x0e, 0x99, 0x7a, 0xe7, 0xd2}}}};
- const std::vector<uint8_t> EpidTpm2Test::kS2Sha512 = {0, 0, 0, 1,
- 'a', 'b', 'c'};
- const FqElemStr EpidTpm2Test::kY2Sha512Str = {
- {{0x4C, 0x0E, 0xA7, 0x62, 0x17, 0xB9, 0xFB, 0xE5, 0x21, 0x7D, 0x54,
- 0x24, 0xE0, 0x2B, 0x87, 0xF7, 0x69, 0x54, 0x0C, 0xC6, 0xAD, 0xF2,
- 0xF2, 0x7B, 0xE6, 0x91, 0xD8, 0xF3, 0x40, 0x6C, 0x8F, 0x03}}};
- const G1ElemStr EpidTpm2Test::kP2Sha512Str = {
- {{{0x8C, 0x62, 0xA0, 0x2D, 0x55, 0x55, 0x55, 0x86, 0xBC, 0x82, 0xA6,
- 0xA2, 0x21, 0x97, 0x9B, 0x9B, 0xB4, 0x03, 0x3D, 0x83, 0xF3, 0xBA,
- 0xDA, 0x9C, 0x42, 0xF7, 0xB3, 0x94, 0x99, 0x2A, 0x96, 0xE4}}},
- {{{0x4C, 0x0E, 0xA7, 0x62, 0x17, 0xB9, 0xFB, 0xE5, 0x21, 0x7D, 0x54,
- 0x24, 0xE0, 0x2B, 0x87, 0xF7, 0x69, 0x54, 0x0C, 0xC6, 0xAD, 0xF2,
- 0xF2, 0x7B, 0xE6, 0x91, 0xD8, 0xF3, 0x40, 0x6C, 0x8F, 0x03}}}};
- const G1ElemStr EpidTpm2Test::kP2Sha512ExpF = {
- {{{0xb4, 0xbc, 0x3d, 0x8c, 0x7b, 0xc3, 0x08, 0x89, 0xa3, 0x0e, 0x66,
- 0x7f, 0x6d, 0x89, 0xab, 0x9b, 0xc4, 0xda, 0x14, 0x93, 0x62, 0x32,
- 0x0d, 0xe2, 0x95, 0xb5, 0x71, 0x2d, 0x75, 0xbe, 0x63, 0xd4}}},
- {{{0xf6, 0x20, 0x85, 0x93, 0x3f, 0xfb, 0xf3, 0xad, 0xa9, 0x7e, 0xd3,
- 0x93, 0x29, 0x22, 0x1b, 0x88, 0x56, 0xf0, 0xbd, 0x62, 0xbd, 0x63,
- 0x8b, 0xcf, 0xe1, 0x62, 0x83, 0xb6, 0x1c, 0x56, 0x29, 0xc3}}}};
- const std::vector<uint8_t> EpidTpm2Test::kS2Sha512256 = {0, 0, 0, 0,
- 'a', 'b', 'c'};
- const FqElemStr EpidTpm2Test::kY2Sha512256Str = {
- {{0x30, 0xbe, 0x3f, 0x12, 0x00, 0x74, 0x48, 0xaa, 0x91, 0x90, 0x84,
- 0x12, 0x4d, 0x58, 0x54, 0xe7, 0x04, 0x65, 0x37, 0x97, 0x88, 0xcf,
- 0x67, 0xa0, 0x8c, 0x56, 0x93, 0xa7, 0x7f, 0xe8, 0x74, 0xfc}}};
- const G1ElemStr EpidTpm2Test::kP2Sha512256Str = {
- {{{0x63, 0x28, 0x40, 0x14, 0x73, 0xd5, 0x91, 0xc4, 0xa2, 0xa4, 0xb6,
- 0xd8, 0xa8, 0x75, 0x21, 0xd1, 0x26, 0x4e, 0x42, 0x13, 0x1f, 0xfa,
- 0xed, 0x90, 0x8d, 0x56, 0x34, 0x57, 0x8a, 0x3a, 0x47, 0xa0}}},
- {{{0x30, 0xbe, 0x3f, 0x12, 0x00, 0x74, 0x48, 0xaa, 0x91, 0x90, 0x84,
- 0x12, 0x4d, 0x58, 0x54, 0xe7, 0x04, 0x65, 0x37, 0x97, 0x88, 0xcf,
- 0x67, 0xa0, 0x8c, 0x56, 0x93, 0xa7, 0x7f, 0xe8, 0x74, 0xfc}}}};
- const G1ElemStr EpidTpm2Test::kP2Sha512256ExpF = {
- {{{0xa7, 0xef, 0x09, 0x07, 0x5e, 0xf1, 0xce, 0x85, 0xe8, 0x85, 0x03,
- 0xbe, 0xdd, 0x2e, 0x32, 0x25, 0xab, 0x58, 0x90, 0xc4, 0x59, 0x60,
- 0x1c, 0x17, 0x3b, 0x8c, 0x62, 0x35, 0xd3, 0x9f, 0x77, 0x8f}}},
- {{{0x38, 0xce, 0x8b, 0x36, 0xc1, 0xb1, 0xae, 0xc5, 0x61, 0x60, 0x12,
- 0xf0, 0x5b, 0xc1, 0xb8, 0x5e, 0xf3, 0xb9, 0xa6, 0x26, 0x7f, 0x27,
- 0x5b, 0x78, 0x61, 0x27, 0xe6, 0x0b, 0x38, 0x37, 0x89, 0x56}}}};
|