Add FPDFSignatureObj_GetDocMDPPermission()

A document is OK to not contain any explicit markup for this, in which
case 0 is returned. If a permission parameter is found, then the
returned level of 1, 2 or 3 controls if no incremental updates are
allowed (1) or incremental updates are OK, but annotations are not
allowed (2) or even annotations are allowed (3).

Note how there is a difference between omitting just the /P key
(implicitly means 2) and omitting the more of this markup, which will
return 0.

This API is meant to be used in combination with the
FPDF_GetTrailerEnds() API, which allows detecting additional incremental
updates after a signature. For example, if a comment is added after
signing, then Permission=1 would result in an invalid signature, while
Permission=3 just results in a partial signature.

Change-Id: I911e9ddaff3a687729e7fe610c013b2ce3283d36
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/75910
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdf_signature_embeddertest.cpp b/fpdfsdk/fpdf_signature_embeddertest.cpp
index d2fd9c6..e91d9c2 100644
--- a/fpdfsdk/fpdf_signature_embeddertest.cpp
+++ b/fpdfsdk/fpdf_signature_embeddertest.cpp
@@ -187,3 +187,16 @@
   EXPECT_EQ('x', time_buffer[0]);
   EXPECT_EQ('\0', time_buffer[1]);
 }
+
+TEST_F(FPDFSignatureEmbedderTest, GetDocMDPPermission) {
+  ASSERT_TRUE(OpenDocument("docmdp.pdf"));
+  FPDF_SIGNATURE signature = FPDF_GetSignatureObject(document(), 0);
+  ASSERT_NE(nullptr, signature);
+
+  // FPDFSignatureObj_GetDocMDPPermission() positive testing.
+  unsigned int permission = FPDFSignatureObj_GetDocMDPPermission(signature);
+  EXPECT_EQ(1U, permission);
+
+  // FPDFSignatureObj_GetDocMDPPermission() negative testing.
+  EXPECT_EQ(0U, FPDFSignatureObj_GetDocMDPPermission(nullptr));
+}