27 ASSERT_TRUE(OpenDocument(
"two_signatures.pdf"));
29 FPDF_SIGNATURE signature1 = FPDF_GetSignatureObject(document(), 0);
30 EXPECT_TRUE(signature1);
31 FPDF_SIGNATURE signature2 = FPDF_GetSignatureObject(document(), 1);
32 EXPECT_TRUE(signature2);
33 EXPECT_NE(signature1, signature2);
36 EXPECT_FALSE(FPDF_GetSignatureObject(document(), -1));
37 EXPECT_FALSE(FPDF_GetSignatureObject(document(), 2));
44 ASSERT_TRUE(OpenDocument(
"two_signatures.pdf"));
45 FPDF_SIGNATURE signature = FPDF_GetSignatureObject(document(), 0);
46 EXPECT_TRUE(signature);
50 const uint8_t kExpectedContents[] = {0x30, 0x80, 0x06, 0x09, 0x2A, 0x86, 0x48,
51 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0,
52 0x80, 0x30, 0x80, 0x02, 0x01, 0x01};
53 ASSERT_EQ(
sizeof(kExpectedContents), size);
54 std::vector<
char> contents(size);
56 FPDFSignatureObj_GetContents(signature, contents.data(), size));
57 ASSERT_EQ(0, memcmp(kExpectedContents, contents.data(), size));
66 FPDFSignatureObj_GetContents(signature, contents.data(), contents.size());
67 ASSERT_EQ(
sizeof(kExpectedContents), size);
68 EXPECT_EQ(
'x', contents[0]);
69 EXPECT_EQ(
'\0', contents[1]);
73 ASSERT_TRUE(OpenDocument(
"two_signatures.pdf"));
74 FPDF_SIGNATURE signature = FPDF_GetSignatureObject(document(), 0);
75 EXPECT_TRUE(signature);
79 const std::vector<
int> kExpectedByteRange{0, 10, 30, 10};
80 ASSERT_EQ(kExpectedByteRange.size(), size);
81 std::vector<
int> byte_range(size);
83 FPDFSignatureObj_GetByteRange(signature, byte_range.data(), size));
84 ASSERT_EQ(kExpectedByteRange, byte_range);
92 size = FPDFSignatureObj_GetByteRange(signature, byte_range.data(),
94 ASSERT_EQ(kExpectedByteRange.size(), size);
95 EXPECT_EQ(0, byte_range[0]);
96 EXPECT_EQ(1, byte_range[1]);
100 ASSERT_TRUE(OpenDocument(
"two_signatures.pdf"));
101 FPDF_SIGNATURE signature = FPDF_GetSignatureObject(document(), 0);
102 EXPECT_TRUE(signature);
106 const char kExpectedSubFilter[] =
"ETSI.CAdES.detached";
107 ASSERT_EQ(
sizeof(kExpectedSubFilter), size);
108 std::vector<
char> sub_filter(size);
110 FPDFSignatureObj_GetSubFilter(signature, sub_filter.data(), size));
111 ASSERT_EQ(0, memcmp(kExpectedSubFilter, sub_filter.data(), size));
116 sub_filter.resize(2);
118 sub_filter[1] =
'\0';
119 size = FPDFSignatureObj_GetSubFilter(signature, sub_filter.data(),
121 ASSERT_EQ(
sizeof(kExpectedSubFilter), size);
122 EXPECT_EQ(
'x', sub_filter[0]);
123 EXPECT_EQ(
'\0', sub_filter[1]);
136 ASSERT_TRUE(OpenDocument(
"signature_reason.pdf"));
137 FPDF_SIGNATURE signature = FPDF_GetSignatureObject(document(), 0);
138 EXPECT_TRUE(signature);
141 constexpr char kReason[] =
"test reason";
143 constexpr unsigned long kReasonUTF16Size =
std::size(kReason) * 2;
144 constexpr wchar_t kReasonWide[] = L"test reason";
146 ASSERT_EQ(kReasonUTF16Size, size);
148 std::vector<
unsigned short> buffer(size);
149 ASSERT_EQ(size, FPDFSignatureObj_GetReason(signature, buffer.data(), size));
150 ASSERT_EQ(kReasonWide, GetPlatformWString(buffer.data()));
159 size = FPDFSignatureObj_GetReason(signature, buffer.data(), buffer.size());
160 ASSERT_EQ(kReasonUTF16Size, size);
161 EXPECT_EQ(
'x', buffer[0]);
162 EXPECT_EQ(
'\0', buffer[1]);
166 ASSERT_TRUE(OpenDocument(
"two_signatures.pdf"));
167 FPDF_SIGNATURE signature = FPDF_GetSignatureObject(document(), 0);
168 EXPECT_TRUE(signature);
172 const char kExpectedTime[] =
"D:20200624093114+02'00'";
173 ASSERT_EQ(
sizeof(kExpectedTime), size);
174 std::vector<
char> time_buffer(size);
176 FPDFSignatureObj_GetTime(signature, time_buffer.data(), size));
177 ASSERT_EQ(0, memcmp(kExpectedTime, time_buffer.data(), size));
182 time_buffer.resize(2);
183 time_buffer[0] =
'x';
184 time_buffer[1] =
'\0';
185 size = FPDFSignatureObj_GetTime(signature, time_buffer.data(),
187 ASSERT_EQ(
sizeof(kExpectedTime), size);
188 EXPECT_EQ(
'x', time_buffer[0]);
189 EXPECT_EQ(
'\0', time_buffer[1]);