/*############################################################################ # 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. ############################################################################*/ /*! * \file * \brief native type serialization unit tests. * * \warning to run the tests in this file you must build a non-shared mode. */ #ifndef SHARED #include <cstring> #include <vector> #include "epid/common-testhelper/epid_gtest-testhelper.h" #include "epid/member/tiny/unittests/member-testhelper.h" #include "gtest/gtest.h" extern "C" { #include "epid/common/types.h" #include "epid/member/tiny/src/native_types.h" #include "epid/member/tiny/src/serialize.h" #include "epid/member/tiny/src/signbasic.h" } /// compares BasicSignature values bool operator==(BasicSignature const& lhs, BasicSignature const& rhs) { return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); } bool operator==(NativeBasicSignature const& lhs, NativeBasicSignature const& rhs) { return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); } bool operator==(NativeGroupPubKey const& lhs, NativeGroupPubKey const& rhs) { return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); } bool operator==(NativePrivKey const& lhs, NativePrivKey const& rhs) { return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); } bool operator==(NativeMembershipCredential const& lhs, NativeMembershipCredential const& rhs) { return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); } namespace { //////////////////////////////////////////////////////////////////////// // BasicSignatureSerialize TEST(TinySerializeTest, BasicSignatureSerializeWorks) { const NativeBasicSignature serialized_BaseSig = { // B {{0xB315D67E, 0x1924AE56, 0xCF527861, 0xEBB789B6, 0x3F429D2A, 0xB193BF9A, 0x6BD8502F, 0x5E73BE39}, {0x0BD51968, 0x0F13472D, 0xC96B5096, 0xA9CD4491, 0x4AB668CF, 0x2123D56C, 0xF30AF180, 0x0DB43C33}}, // K {{0x9C3524E3, 0x4E4CA66B, 0x58731363, 0xB57BC920, 0x1317EBFA, 0xBD71A2D6, 0x046B29FE, 0x64B5A803}, {0x86A7A14A, 0xDE584912, 0xFEFD476A, 0x8559EF80, 0x34D8E1D2, 0x81F6BF1D, 0xE0C42E4B, 0x477FEC10}}, // T {{0x444DB42F, 0xB57CFAA0, 0x3FB8C069, 0x3593EC91, 0xB968BBAA, 0x02D2BFBB, 0xCF2E5D4A, 0xE57236B5}, {0x23C435BE, 0x92D96415, 0x6A552F32, 0x5E071AA9, 0xBBC76EDC, 0xC1C5D18A, 0x654CA5AE, 0xB96FEBB0}}, // c {0xD03D247B, 0x8C2A93E5, 0xCBB14B7A, 0x85919691, 0xC7009CFC, 0xEFD5278B, 0x82D2F470, 0xA2CDE297}, // xs {0xEB24D967, 0xDC578F59, 0x58C76405, 0x1958415E, 0xF08890BD, 0xDB47D06A, 0x7257B3F5, 0x6346AA98}, // sf {0x11B85D46, 0xBEA435F3, 0x11E85329, 0xDD10B17B, 0xC41B1647, 0x268C5DDC, 0x4E39F40C, 0x25421795}, // sa {0xCDA62A84, 0x3CC19531, 0xDCC526F5, 0x3A248BB8, 0xF973B761, 0x3E009735, 0x6FC46BCC, 0x4EBDEDE8}, // sb {0x2E0B26CF, 0x6193CD96, 0xED6E97F8, 0xBB9D186E, 0xB37A5227, 0xF82B38E5, 0x610CAF48, 0x92A3681B}}; BasicSignature result = {0}; const BasicSignature expected_BaseSig = { // B {{0x5E, 0x73, 0xBE, 0x39, 0x6B, 0xD8, 0x50, 0x2F, 0xB1, 0x93, 0xBF, 0x9A, 0x3F, 0x42, 0x9D, 0x2A, 0xEB, 0xB7, 0x89, 0xB6, 0xCF, 0x52, 0x78, 0x61, 0x19, 0x24, 0xAE, 0x56, 0xB3, 0x15, 0xD6, 0x7E}, {0x0D, 0xB4, 0x3C, 0x33, 0xF3, 0x0A, 0xF1, 0x80, 0x21, 0x23, 0xD5, 0x6C, 0x4A, 0xB6, 0x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63, 0x46, 0xAA, 0x98, 0x72, 0x57, 0xB3, 0xF5, 0xDB, 0x47, 0xD0, 0x6A, 0xF0, 0x88, 0x90, 0xBD, 0x19, 0x58, 0x41, 0x5E, 0x58, 0xC7, 0x64, 0x05, 0xDC, 0x57, 0x8F, 0x59, 0xEB, 0x24, 0xD9, 0x67}, // sf {0x25, 0x42, 0x17, 0x95, 0x4E, 0x39, 0xF4, 0x0C, 0x26, 0x8C, 0x5D, 0xDC, 0xC4, 0x1B, 0x16, 0x47, 0xDD, 0x10, 0xB1, 0x7B, 0x11, 0xE8, 0x53, 0x29, 0xBE, 0xA4, 0x35, 0xF3, 0x11, 0xB8, 0x5D, 0x46}, // sa {0x4E, 0xBD, 0xED, 0xE8, 0x6F, 0xC4, 0x6B, 0xCC, 0x3E, 0x00, 0x97, 0x35, 0xF9, 0x73, 0xB7, 0x61, 0x3A, 0x24, 0x8B, 0xB8, 0xDC, 0xC5, 0x26, 0xF5, 0x3C, 0xC1, 0x95, 0x31, 0xCD, 0xA6, 0x2A, 0x84}, // sb {0x92, 0xA3, 0x68, 0x1B, 0x61, 0x0C, 0xAF, 0x48, 0xF8, 0x2B, 0x38, 0xE5, 0xB3, 0x7A, 0x52, 0x27, 0xBB, 0x9D, 0x18, 0x6E, 0xED, 0x6E, 0x97, 0xF8, 0x61, 0x93, 0xCD, 0x96, 0x2E, 0x0B, 0x26, 0xCF}}; BasicSignatureSerialize(&result, &serialized_BaseSig); EXPECT_EQ(expected_BaseSig, result); } //////////////////////////////////////////////////////////////////////// // BasicSignatureDeserialize TEST(TinySerializeTest, BasicSignatureDeserializeWorks) { const BasicSignature deserialized_BaseSig = { // B {{0x5E, 0x73, 0xBE, 0x39, 0x6B, 0xD8, 0x50, 0x2F, 0xB1, 0x93, 0xBF, 0x9A, 0x3F, 0x42, 0x9D, 0x2A, 0xEB, 0xB7, 0x89, 0xB6, 0xCF, 0x52, 0x78, 0x61, 0x19, 0x24, 0xAE, 0x56, 0xB3, 0x15, 0xD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 0x91, 0x96, 0x91, 0xCB, 0xB1, 0x4B, 0x7A, 0x8C, 0x2A, 0x93, 0xE5, 0xD0, 0x3D, 0x24, 0x7B}, // sx {0x63, 0x46, 0xAA, 0x98, 0x72, 0x57, 0xB3, 0xF5, 0xDB, 0x47, 0xD0, 0x6A, 0xF0, 0x88, 0x90, 0xBD, 0x19, 0x58, 0x41, 0x5E, 0x58, 0xC7, 0x64, 0x05, 0xDC, 0x57, 0x8F, 0x59, 0xEB, 0x24, 0xD9, 0x67}, // sf {0x25, 0x42, 0x17, 0x95, 0x4E, 0x39, 0xF4, 0x0C, 0x26, 0x8C, 0x5D, 0xDC, 0xC4, 0x1B, 0x16, 0x47, 0xDD, 0x10, 0xB1, 0x7B, 0x11, 0xE8, 0x53, 0x29, 0xBE, 0xA4, 0x35, 0xF3, 0x11, 0xB8, 0x5D, 0x46}, // sa {0x4E, 0xBD, 0xED, 0xE8, 0x6F, 0xC4, 0x6B, 0xCC, 0x3E, 0x00, 0x97, 0x35, 0xF9, 0x73, 0xB7, 0x61, 0x3A, 0x24, 0x8B, 0xB8, 0xDC, 0xC5, 0x26, 0xF5, 0x3C, 0xC1, 0x95, 0x31, 0xCD, 0xA6, 0x2A, 0x84}, // sb {0x92, 0xA3, 0x68, 0x1B, 0x61, 0x0C, 0xAF, 0x48, 0xF8, 0x2B, 0x38, 0xE5, 0xB3, 0x7A, 0x52, 0x27, 0xBB, 0x9D, 0x18, 0x6E, 0xED, 0x6E, 0x97, 0xF8, 0x61, 0x93, 0xCD, 0x96, 0x2E, 0x0B, 0x26, 0xCF}}; const NativeBasicSignature expected_BaseSig = { // B {{0xB315D67E, 0x1924AE56, 0xCF527861, 0xEBB789B6, 0x3F429D2A, 0xB193BF9A, 0x6BD8502F, 0x5E73BE39}, {0x0BD51968, 0x0F13472D, 0xC96B5096, 0xA9CD4491, 0x4AB668CF, 0x2123D56C, 0xF30AF180, 0x0DB43C33}}, // K {{0x9C3524E3, 0x4E4CA66B, 0x58731363, 0xB57BC920, 0x1317EBFA, 0xBD71A2D6, 0x046B29FE, 0x64B5A803}, {0x86A7A14A, 0xDE584912, 0xFEFD476A, 0x8559EF80, 0x34D8E1D2, 0x81F6BF1D, 0xE0C42E4B, 0x477FEC10}}, // T {{0x444DB42F, 0xB57CFAA0, 0x3FB8C069, 0x3593EC91, 0xB968BBAA, 0x02D2BFBB, 0xCF2E5D4A, 0xE57236B5}, {0x23C435BE, 0x92D96415, 0x6A552F32, 0x5E071AA9, 0xBBC76EDC, 0xC1C5D18A, 0x654CA5AE, 0xB96FEBB0}}, // c {0xD03D247B, 0x8C2A93E5, 0xCBB14B7A, 0x85919691, 0xC7009CFC, 0xEFD5278B, 0x82D2F470, 0xA2CDE297}, // xs {0xEB24D967, 0xDC578F59, 0x58C76405, 0x1958415E, 0xF08890BD, 0xDB47D06A, 0x7257B3F5, 0x6346AA98}, // sf {0x11B85D46, 0xBEA435F3, 0x11E85329, 0xDD10B17B, 0xC41B1647, 0x268C5DDC, 0x4E39F40C, 0x25421795}, // sa {0xCDA62A84, 0x3CC19531, 0xDCC526F5, 0x3A248BB8, 0xF973B761, 0x3E009735, 0x6FC46BCC, 0x4EBDEDE8}, // sb {0x2E0B26CF, 0x6193CD96, 0xED6E97F8, 0xBB9D186E, 0xB37A5227, 0xF82B38E5, 0x610CAF48, 0x92A3681B}}; NativeBasicSignature result = {0}; BasicSignatureDeserialize(&result, &deserialized_BaseSig); EXPECT_EQ(expected_BaseSig, result); } ////////////////////////////////////////////////////////////////////////// // GroupPubKeySerialize Tests TEST_F(EpidMemberTest, GroupPubKeySerializeWorks) { NativeGroupPubKey const input = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, // group id {{{{0xb580e099, 0x434c62fd, 0x64cee3ce, 0xd06d8f9d, 0x7e27b0cb, 0x3d753d61, 0xe21b17eb, 0xb36fff81}}}, {{{0x74f459ee, 0xd8693ea1, 0x82457e7f, 0xee3d6642, 0xe94dae9c, 0xfdb5b79d, 0xe08859a4, 0x3a075680}}}}, // h1 {{{{0xbcdd7fe1, 0x29666163, 0xd55ba704, 0xdc99ed42, 0x5474107b, 0xd5dbca1c, 0x63c2518e, 0xd2742e9f}}}, {{{0xe78e1084, 0x93a56ecc, 0xde4ceacb, 0xda3f517d, 0xe85b087b, 0x48120aa6, 0xe314ac72, 0x765dc06e}}}}, // h2 {{{{{0x0728e896, 0x8dcd3688, 0x6a95cac6, 0x788753f6, 0x401ba5b6, 0x50719451, 0xe20fca1c, 0xbd195a95}}}, {{{0xe2f4b3a1, 0x22d9fde0, 0x0f6c56f5, 0x2414cfd1, 0x15d775f8, 0xa6657a68, 0xb86ae7e5, 0xca78115b}}}}, {{{{0x57e4f33c, 0x0a3b5896, 0x89c2399c, 0x898846dd, 0x5deef56a, 0xbc077230, 0xe8b3c725, 0x9021a7e0}}}, {{{0xee1140a9, 0x837d3e31, 0x8e25c6ad, 0xba6bf0da, 0x1f3deaa2, 0x5d0a88db, 0x1bb6f705, 0x79516936}}}}}}; GroupPubKey const expected = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, // group id {{{{0xb3, 0x6f, 0xff, 0x81, 0xe2, 0x1b, 0x17, 0xeb, 0x3d, 0x75, 0x3d, 0x61, 0x7e, 0x27, 0xb0, 0xcb, 0xd0, 0x6d, 0x8f, 0x9d, 0x64, 0xce, 0xe3, 0xce, 0x43, 0x4c, 0x62, 0xfd, 0xb5, 0x80, 0xe0, 0x99}}}, {{{0x3a, 0x07, 0x56, 0x80, 0xe0, 0x88, 0x59, 0xa4, 0xfd, 0xb5, 0xb7, 0x9d, 0xe9, 0x4d, 0xae, 0x9c, 0xee, 0x3d, 0x66, 0x42, 0x82, 0x45, 0x7e, 0x7f, 0xd8, 0x69, 0x3e, 0xa1, 0x74, 0xf4, 0x59, 0xee}}}}, //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6b, 0xf0, 0xda, 0x8e, 0x25, 0xc6, 0xad, 0x83, 0x7d, 0x3e, 0x31, 0xee, 0x11, 0x40, 0xa9}}}}} // w }; GroupPubKey actual = {0}; GroupPubKeySerialize(&actual, &input); EXPECT_EQ(expected, actual); } ////////////////////////////////////////////////////////////////////////// // GroupPubKeyDeserialize Tests TEST_F(EpidMemberTest, GroupPubKeyDeserializeWorks) { GroupPubKey const input = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, // group id {{{{0xb3, 0x6f, 0xff, 0x81, 0xe2, 0x1b, 0x17, 0xeb, 0x3d, 0x75, 0x3d, 0x61, 0x7e, 0x27, 0xb0, 0xcb, 0xd0, 0x6d, 0x8f, 0x9d, 0x64, 0xce, 0xe3, 0xce, 0x43, 0x4c, 0x62, 0xfd, 0xb5, 0x80, 0xe0, 0x99}}}, {{{0x3a, 0x07, 0x56, 0x80, 0xe0, 0x88, 0x59, 0xa4, 0xfd, 0xb5, 0xb7, 0x9d, 0xe9, 0x4d, 0xae, 0x9c, 0xee, 0x3d, 0x66, 0x42, 0x82, 0x45, 0x7e, 0x7f, 0xd8, 0x69, 0x3e, 0xa1, 0x74, 0xf4, 0x59, 0xee}}}}, // h1 {{{{0xd2, 0x74, 0x2e, 0x9f, 0x63, 0xc2, 0x51, 0x8e, 0xd5, 0xdb, 0xca, 0x1c, 0x54, 0x74, 0x10, 0x7b, 0xdc, 0x99, 0xed, 0x42, 0xd5, 0x5b, 0xa7, 0x04, 0x29, 0x66, 0x61, 0x63, 0xbc, 0xdd, 0x7f, 0xe1}}}, {{{0x76, 0x5d, 0xc0, 0x6e, 0xe3, 0x14, 0xac, 0x72, 0x48, 0x12, 0x0a, 0xa6, 0xe8, 0x5b, 0x08, 0x7b, 0xda, 0x3f, 0x51, 0x7d, 0xde, 0x4c, 0xea, 0xcb, 0x93, 0xa5, 0x6e, 0xcc, 0xe7, 0x8e, 0x10, 0x84}}}}, // h2 {{{{{0xbd, 0x19, 0x5a, 0x95, 0xe2, 0x0f, 0xca, 0x1c, 0x50, 0x71, 0x94, 0x51, 0x40, 0x1b, 0xa5, 0xb6, 0x78, 0x87, 0x53, 0xf6, 0x6a, 0x95, 0xca, 0xc6, 0x8d, 0xcd, 0x36, 0x88, 0x7, 0x28, 0xe8, 0x96}}}, {{{0xca, 0x78, 0x11, 0x5b, 0xb8, 0x6a, 0xe7, 0xe5, 0xa6, 0x65, 0x7a, 0x68, 0x15, 0xd7, 0x75, 0xf8, 0x24, 0x14, 0xcf, 0xd1, 0x0f, 0x6c, 0x56, 0xf5, 0x22, 0xd9, 0xfd, 0xe0, 0xe2, 0xf4, 0xb3, 0xa1}}}}, {{{{0x90, 0x21, 0xa7, 0xe0, 0xe8, 0xb3, 0xc7, 0x25, 0xbc, 0x07, 0x72, 0x30, 0x5d, 0xee, 0xf5, 0x6a, 0x89, 0x88, 0x46, 0xdd, 0x89, 0xc2, 0x39, 0x9c, 0x0a, 0x3b, 0x58, 0x96, 0x57, 0xe4, 0xf3, 0x3c}}}, {{{0x79, 0x51, 0x69, 0x36, 0x1b, 0xb6, 0xf7, 0x05, 0x5d, 0x0a, 0x88, 0xdb, 0x1f, 0x3d, 0xea, 0xa2, 0xba, 0x6b, 0xf0, 0xda, 0x8e, 0x25, 0xc6, 0xad, 0x83, 0x7d, 0x3e, 0x31, 0xee, 0x11, 0x40, 0xa9}}}}} // w }; NativeGroupPubKey const expected = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, // group id {{{{0xb580e099, 0x434c62fd, 0x64cee3ce, 0xd06d8f9d, 0x7e27b0cb, 0x3d753d61, 0xe21b17eb, 0xb36fff81}}}, {{{0x74f459ee, 0xd8693ea1, 0x82457e7f, 0xee3d6642, 0xe94dae9c, 0xfdb5b79d, 0xe08859a4, 0x3a075680}}}}, // h1 {{{{0xbcdd7fe1, 0x29666163, 0xd55ba704, 0xdc99ed42, 0x5474107b, 0xd5dbca1c, 0x63c2518e, 0xd2742e9f}}}, {{{0xe78e1084, 0x93a56ecc, 0xde4ceacb, 0xda3f517d, 0xe85b087b, 0x48120aa6, 0xe314ac72, 0x765dc06e}}}}, // h2 {{{{{0x0728e896, 0x8dcd3688, 0x6a95cac6, 0x788753f6, 0x401ba5b6, 0x50719451, 0xe20fca1c, 0xbd195a95}}}, {{{0xe2f4b3a1, 0x22d9fde0, 0x0f6c56f5, 0x2414cfd1, 0x15d775f8, 0xa6657a68, 0xb86ae7e5, 0xca78115b}}}}, {{{{0x57e4f33c, 0x0a3b5896, 0x89c2399c, 0x898846dd, 0x5deef56a, 0xbc077230, 0xe8b3c725, 0x9021a7e0}}}, {{{0xee1140a9, 0x837d3e31, 0x8e25c6ad, 0xba6bf0da, 0x1f3deaa2, 0x5d0a88db, 0x1bb6f705, 0x79516936}}}}}}; NativeGroupPubKey actual = {0}; GroupPubKeyDeserialize(&actual, &input); EXPECT_EQ(expected, actual); } ////////////////////////////////////////////////////////////////////////// // PrivKeyDeserialize Tests TEST_F(EpidMemberTest, PrivKeyDeserializeWorks) { PrivKey const input = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, // group id {{{{0x46, 0xc9, 0x69, 0xee, 0xf4, 0x68, 0xe1, 0x5f, 0xac, 0xbf, 0xdd, 0x77, 0xeb, 0x4c, 0xaf, 0x8a, 0x87, 0x68, 0x3f, 0x4e, 0xda, 0xf2, 0x96, 0xec, 0x57, 0x08, 0x90, 0xe8, 0x19, 0x62, 0x54, 0xdb}}}, {{{0x1e, 0x52, 0x23, 0x16, 0x91, 0xe4, 0xa8, 0x1d, 0x9a, 0x1b, 0x8a, 0xad, 0x0a, 0xcf, 0x36, 0x4f, 0xae, 0x43, 0xde, 0x62, 0xff, 0xa6, 0x4b, 0xa8, 0x16, 0x24, 0x98, 0x80, 0x82, 0x80, 0x37, 0x77}}}}, // A {0x0a, 0x30, 0xae, 0x43, 0xa1, 0xe0, 0xd7, 0xdf, 0x10, 0x5e, 0xaf, 0xd8, 0x5a, 0x61, 0x10, 0x86, 0xd0, 0x9d, 0xb9, 0xe4, 0x46, 0xdd, 0xb7, 0x1b, 0x00, 0x14, 0x7c, 0x6b, 0x13, 0x72, 0xc3, 0x77}, // x {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} // f }; NativePrivKey const expected = { { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, // group id {{{{0x196254db, 0x570890e8, 0xdaf296ec, 0x87683f4e, 0xeb4caf8a, 0xacbfdd77, 0xf468e15f, 0x46c969ee}}}, {{{0x82803777, 0x16249880, 0xffa64ba8, 0xae43de62, 0x0acf364f, 0x9a1b8aad, 0x91e4a81d, 0x1e522316}}}}, // A {0x1372c377, 0x00147c6b, 0x46ddb71b, 0xd09db9e4, 0x5a611086, 0x105eafd8, 0xa1e0d7df, 0x0a30ae43} // x }, {0x636131c7, 0x362d4135, 0xa707879b, 0xa16567fd, 0xe07cc68e, 0x05d64356, 0x6d47090b, 0x4840b56c} // f }; NativePrivKey actual = {0}; PrivKeyDeserialize(&actual, &input); EXPECT_EQ(expected, actual); } ////////////////////////////////////////////////////////////////////////// // MembershipCredentialDeserialize Tests TEST_F(EpidMemberTest, MembershipCredentialDeserializeWorks) { MembershipCredential const input = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, // group id {{{{0x46, 0xc9, 0x69, 0xee, 0xf4, 0x68, 0xe1, 0x5f, 0xac, 0xbf, 0xdd, 0x77, 0xeb, 0x4c, 0xaf, 0x8a, 0x87, 0x68, 0x3f, 0x4e, 0xda, 0xf2, 0x96, 0xec, 0x57, 0x08, 0x90, 0xe8, 0x19, 0x62, 0x54, 0xdb}}}, {{{0x1e, 0x52, 0x23, 0x16, 0x91, 0xe4, 0xa8, 0x1d, 0x9a, 0x1b, 0x8a, 0xad, 0x0a, 0xcf, 0x36, 0x4f, 0xae, 0x43, 0xde, 0x62, 0xff, 0xa6, 0x4b, 0xa8, 0x16, 0x24, 0x98, 0x80, 0x82, 0x80, 0x37, 0x77}}}}, // A {0x0a, 0x30, 0xae, 0x43, 0xa1, 0xe0, 0xd7, 0xdf, 0x10, 0x5e, 0xaf, 0xd8, 0x5a, 0x61, 0x10, 0x86, 0xd0, 0x9d, 0xb9, 0xe4, 0x46, 0xdd, 0xb7, 0x1b, 0x00, 0x14, 0x7c, 0x6b, 0x13, 0x72, 0xc3, 0x77} // x }; NativeMembershipCredential const expected = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, // group id {{{{0x196254db, 0x570890e8, 0xdaf296ec, 0x87683f4e, 0xeb4caf8a, 0xacbfdd77, 0xf468e15f, 0x46c969ee}}}, {{{0x82803777, 0x16249880, 0xffa64ba8, 0xae43de62, 0x0acf364f, 0x9a1b8aad, 0x91e4a81d, 0x1e522316}}}}, // A {0x1372c377, 0x00147c6b, 0x46ddb71b, 0xd09db9e4, 0x5a611086, 0x105eafd8, 0xa1e0d7df, 0x0a30ae43} // x }; NativeMembershipCredential actual = {0}; MembershipCredentialDeserialize(&actual, &input); EXPECT_EQ(expected, actual); } } // namespace #endif // SHARED