|
@@ -0,0 +1,181 @@
|
|
|
+//
|
|
|
+// CPDFSignature.h
|
|
|
+// ComPDFKit
|
|
|
+//
|
|
|
+// Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
|
|
|
+//
|
|
|
+// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
|
|
|
+// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
|
|
|
+// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
|
|
|
+// This notice may not be removed from this file.
|
|
|
+//
|
|
|
+
|
|
|
+#import <ComPDFKit/CPDFKitPlatform.h>
|
|
|
+
|
|
|
+@class CPDFDocument;
|
|
|
+
|
|
|
+typedef NS_ENUM(NSInteger, CPDFSignatureOCSPStatus) {
|
|
|
+ CPDFSignatureOCSPStatusNone = -2,
|
|
|
+ CPDFSignatureOCSPStatusFail = -1,
|
|
|
+ CPDFSignatureOCSPStatusGood = 0,
|
|
|
+ CPDFSignatureOCSPStatusRevoked = 1
|
|
|
+};
|
|
|
+
|
|
|
+typedef NS_ENUM(NSInteger, CPDFModifyType) {
|
|
|
+ CPDFModifyNone = 0,
|
|
|
+ CPDFModifyAddPage,
|
|
|
+ CPDFModifyDeletePage,
|
|
|
+ CPDFModifyPage,
|
|
|
+ CPDFModifyAddAnnotation,
|
|
|
+ CPDFModifyDeleteAnnotation,
|
|
|
+ CPDFModifyAnnotation,
|
|
|
+ CPDFModifyFillForm,
|
|
|
+ CPDFModifyRootIncrease,
|
|
|
+ CPDFModifyDocument
|
|
|
+};
|
|
|
+
|
|
|
+@interface CPDFModifyInfo : NSObject
|
|
|
+
|
|
|
+@property (nonatomic,readonly) CPDFModifyType type;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSInteger pageIndex;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSInteger annotationType;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSInteger formType;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSString *info;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@interface CPDFSignatureCertificate : NSObject
|
|
|
+
|
|
|
+// Version 版本
|
|
|
+@property (nonatomic,readonly) NSString *version;
|
|
|
+
|
|
|
+// Signature algorithm 签名算法
|
|
|
+@property (nonatomic,readonly) NSString *signatureAlgorithmOID;
|
|
|
+@property (nonatomic,readonly) NSString *signatureAlgorithmType;
|
|
|
+
|
|
|
+// Subject 主题
|
|
|
+@property (nonatomic,readonly) NSString *subject;
|
|
|
+
|
|
|
+// C(国家),ST(省),L(地区),O(组织),OU(单位),CN(通用名)
|
|
|
+@property (nonatomic,readonly) NSDictionary *subjectDict;
|
|
|
+
|
|
|
+// Issuer 颁发者
|
|
|
+@property (nonatomic,readonly) NSString *issuer;
|
|
|
+
|
|
|
+// C(国家),ST(省),L(地区),O(组织),OU(单位),CN(通用名)
|
|
|
+@property (nonatomic,readonly) NSDictionary *issuerDict;
|
|
|
+
|
|
|
+// Serial number 序列号
|
|
|
+@property (nonatomic,readonly) NSString *serialNumber;
|
|
|
+
|
|
|
+// Validity starts 有效起始日期
|
|
|
+@property (nonatomic,readonly) NSDate *validityStarts;
|
|
|
+
|
|
|
+// Validity ends 有效截止日期
|
|
|
+@property (nonatomic,readonly) NSDate *validityEnds;
|
|
|
+
|
|
|
+// Authority info access 颁发机构信息访问
|
|
|
+@property (nonatomic,readonly) NSArray<NSDictionary *> *authorityInfoAccess;
|
|
|
+
|
|
|
+// Subject key identifier 主题密钥标识符
|
|
|
+@property (nonatomic,readonly) NSString *subjectKeyIdentifier;
|
|
|
+
|
|
|
+// Key usage 密钥用法
|
|
|
+@property (nonatomic,readonly) NSString *keyUsage;
|
|
|
+
|
|
|
+// Certificate policies 证书策略
|
|
|
+@property (nonatomic,readonly) NSString *certificatePolicies;
|
|
|
+
|
|
|
+// Authority key identifier 颁发结构密钥标识符
|
|
|
+@property (nonatomic,readonly) NSString *authorityKeyIdentifier;
|
|
|
+
|
|
|
+// CRL distribution points CRL分发点
|
|
|
+@property (nonatomic,readonly) NSArray<NSString *> *CRLDistributionPoints;
|
|
|
+
|
|
|
+// Basic constraints 基本限制
|
|
|
+@property (nonatomic,readonly) NSString *basicConstraints;
|
|
|
+
|
|
|
+// Public key 公钥
|
|
|
+@property (nonatomic,readonly) NSString *publicKey;
|
|
|
+
|
|
|
+// X.509 data X.509数据
|
|
|
+@property (nonatomic,readonly) NSString *X509Data;
|
|
|
+
|
|
|
+// SHA1 digest SHA1摘要
|
|
|
+@property (nonatomic,readonly) NSString *SHA1Digest;
|
|
|
+
|
|
|
+// MD5 digest MD5摘要
|
|
|
+@property (nonatomic,readonly) NSString *MD5Digest;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSString *ocspURL;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) CPDFSignatureOCSPStatus ocspStatus;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) BOOL isTrusted;
|
|
|
+
|
|
|
+- (void)verifyOCSPWithCompletionHandler:(void (^)(BOOL result, CPDFSignatureOCSPStatus ocspStatus))handler;
|
|
|
+
|
|
|
+- (BOOL)exportToFilePath:(NSString *)filePath;
|
|
|
+
|
|
|
+- (BOOL)addToTrustedCertificates;
|
|
|
+
|
|
|
++ (CPDFSignatureCertificate *)certificateWithPKCS12Path:(NSString *)path password:(NSString *)password;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@interface CPDFSigner : NSObject
|
|
|
+
|
|
|
+@property (nonatomic,readonly) BOOL isSignVerified;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) BOOL isCertTrusted;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSString *name;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSDate *date;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSArray<CPDFSignatureCertificate*> *certificates;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSArray<CPDFSigner*> *timestampSigners;
|
|
|
+
|
|
|
+- (void)checkCertificateIsTrusted;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@interface CPDFSignature : NSObject
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSArray<CPDFSigner *> *signers;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSArray<CPDFModifyInfo *> *modifyInfos;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSUInteger pageIndex;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) NSString *fieldName;
|
|
|
+
|
|
|
+@property (nonatomic,readonly) CGRect bounds;
|
|
|
+
|
|
|
+/**
|
|
|
+ * The access permissions granted for this document.
|
|
|
+ *
|
|
|
+ * @discussion Valid values shall be:
|
|
|
+ * 1 : No changes to the document shall be permitted; any change to the document shall invalidate the signature.
|
|
|
+ * 2 : Permitted changes shall be filling in forms, instantiating page templates, and signing; other changes shall invalidate the signature.
|
|
|
+ * 3 : Permitted changes shall be the same as for 2, as well as annotation creation, deletion, and modification; other changes shall invalidate the signature.
|
|
|
+ */
|
|
|
+@property (nonatomic,readonly) NSInteger permissions;
|
|
|
+
|
|
|
+- (void)verifySignatureWithDocument:(CPDFDocument *)document;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 生成P12证书
|
|
|
+ *
|
|
|
+ * @param info C(国家),ST(省),L(地区),O(组织),OU(单位),CN(通用名),emailaddress(邮箱)
|
|
|
+ * @param password 密码
|
|
|
+ * @param path 保存路径
|
|
|
+ */
|
|
|
++ (BOOL)generatePKCS12CertWithInfo:(NSDictionary *)info password:(NSString *)password toPath:(NSString *)path;
|
|
|
+
|
|
|
+@end
|