diff --git a/lib/modules/Crypto/pkcs.pmod b/lib/modules/Crypto/pkcs.pmod
new file mode 100644
index 0000000000000000000000000000000000000000..46cda906e0aceceed941a3f292b8f57e8d36bc91
--- /dev/null
+++ b/lib/modules/Crypto/pkcs.pmod
@@ -0,0 +1,15 @@
+/* pkcs.pmod
+ *
+ * Miscellaneous functions needed for pkcs operation.
+ */
+
+/* Construct a PKCS-1 digestinfo */
+string build_digestinfo(string msg, object hash)
+{
+  string d = hash->update(msg)->digest();
+  string id = hash->identifier();
+
+  return sprintf("%c%c%c%c%c%c%s%c%c%c%c%s",
+		 0x30, strlen(id) + strlen(d) + 8, 0x30, strlen(id) + 4,
+		 0x06, strlen(id), id, 0x05, 0x00, 0x04, strlen(d), d);
+}