Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF暗号化機能を追加 #3

Merged
merged 65 commits into from
Mar 21, 2023
Merged

Conversation

fal-works
Copy link
Collaborator

@fal-works fal-works commented Mar 17, 2023

機能追加

  • PDFDocument#encrypt() メソッド追加
    • PDFファイル生成時に暗号化が行われるように
  • PDFDocument#updateId() メソッド追加
    • 暗号化に必要な ID の生成/更新のため
  • PDFDocument#isEncrypted プロパティをメソッドに変更
    • 以前は readonly な変数だったが、encrypt() の実行に伴い状態が変化するようになったため

全般

  • フォーク後の変更履歴を MODIFICATIONS.md に分離
  • バージョンを 1.17.1-mod.2023.3 に更新

依存追加

  • crypto-js
    • ハッシュ計算(MD5)と暗号化(RC4, AES)のため

内部実装拡張

  • src/core/security に暗号化関連のモジュール群を追加
    • ISO 32000-1 の仕様に従った暗号鍵の生成など
    • PDFDocument#encrypt 実行時に、暗号化の準備として PDFSecurity インスタンスが生成・保持される
  • src/core/writers のPDF生成処理にて、実際の暗号化処理を実行する挙動を挿入
    • PDFDocument#encrypt 実行済みの状態で PDFDocument#save を呼んだ場合に実行される
  • src/core/objects / src/core/structures の一部モジュールにて encryptWith メソッドを実装
    • writers (上述) の処理にて、個々のオブジェクトを書込前に暗号化するために使用される

テスト追加

  • ユニットテスト(tests ディレクトリー)
    • メソッド追加などに伴いケースを追加
    • 備考: 暗号化処理の中核部分にランダム処理が存在するため、必要に応じ、当該関数を一時的にモック(mock.ts)に差し替えてテスト実施
  • 統合テスト(apps ディレクトリー)
    • 暗号化機能使用時のケース追加(useObjectStreams false/true 両パターン)

@fal-works fal-works marked this pull request as ready for review March 20, 2023 15:05
@terurou terurou merged commit 5cd2b3e into DenkiYagi:denkiyagi-fork Mar 21, 2023
@fal-works fal-works deleted the encrypt branch March 22, 2023 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants