flowchart LR
Passwords[password bytes] --> Padding[pdf_pad_password]
Padding --> FileKey[pdf_encryption_file_key]
FileKey --> ObjectKey[pdf_encryption_object_key]
ObjectKey --> ARC4[pdf_arc4_crypt_object]
ObjectKey --> AES[pdf_aesv2_encrypt_object_data]
Permissions[PdfPermission list] --> Mask[pdf_p_of_permissions]///|
test "arc4 primitive is symmetric" {
let key = try! @core.pdf_bytes_of_int_array([1, 2, 3, 4, 5])
let plain = try! @core.pdf_bytes_of_int_array([80, 68, 70])
let cipher = try! @crypt_core.pdf_arc4_crypt(key, plain)
let roundtrip = try! @crypt_core.pdf_arc4_crypt(key, cipher)
if @core.pdf_int_array_of_bytes(roundtrip) != [80, 68, 70] {
fail("expected ARC4 to decrypt back to the original bytes")
}
}///|
test "digest and permission helpers expose PDF primitives" {
let data = try! @core.pdf_bytes_of_int_array([97, 98, 99])
inspect(@crypt_core.pdf_md5_digest(data).length(), content="16")
let mask = @crypt_core.pdf_p_of_permissions([PdfNoPrint, PdfNoCopy])
let permissions = @crypt_core.pdf_permissions_of_p(mask)
let mut saw_copy = false
for permission in permissions {
if permission == PdfNoCopy {
saw_copy = true
}
}
if !saw_copy {
fail("expected permission round trip to include PdfNoCopy")
}
}#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfAesV3RandomField::equal(PdfAesV3RandomField, PdfAesV3RandomField) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfAesV3RandomField::not_equal(x : PdfAesV3RandomField, y : PdfAesV3RandomField) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfAesV3RandomField::to_json(PdfAesV3RandomField) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfAesV3RandomField::to_repr(PdfAesV3RandomField) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfEncryptionMethod::equal(PdfEncryptionMethod, PdfEncryptionMethod) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfEncryptionMethod::not_equal(x : PdfEncryptionMethod, y : PdfEncryptionMethod) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfEncryptionMethod::to_json(PdfEncryptionMethod) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfEncryptionMethod::to_repr(PdfEncryptionMethod) -> Reprpub(all) struct PdfEncryptionValues {
crypt_type : PdfCryptType
user_entry : Bytes
owner_entry : Bytes
permissions : Int
file_id : Bytes
encrypt_metadata : Bool
permissions_entry : Bytes?
user_encryption_key : Bytes?
owner_encryption_key : Bytes?
} derive(Eq, Debug)#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfEncryptionValues::equal(PdfEncryptionValues, PdfEncryptionValues) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfEncryptionValues::not_equal(x : PdfEncryptionValues, y : PdfEncryptionValues) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfEncryptionValues::to_repr(PdfEncryptionValues) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfPermission::equal(PdfPermission, PdfPermission) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfPermission::not_equal(x : PdfPermission, y : PdfPermission) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfPermission::to_json(PdfPermission) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfPermission::to_repr(PdfPermission) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfSavedEncryption::equal(PdfSavedEncryption, PdfSavedEncryption) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfSavedEncryption::not_equal(x : PdfSavedEncryption, y : PdfSavedEncryption) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PdfSavedEncryption::to_repr(PdfSavedEncryption) -> Reprfn pdf_aes_cbc_decrypt(key : BytesView, data : BytesView, remove_padding? : Bool) -> Bytes raise PdfErrorfn pdf_aes_cbc_encrypt_with_iv(key : BytesView, iv : BytesView, data : BytesView) -> Bytes raise PdfErrorfn pdf_aes_ecb_decrypt(key : BytesView, data : BytesView, remove_padding? : Bool) -> Bytes raise PdfErrorfn pdf_aesv2_decrypt_object_data(object_number : Int, generation : Int, file_key : BytesView, key_length_bits : Int, data : BytesView) -> Bytes raise PdfErrorfn pdf_aesv2_encrypt_object_data(object_number : Int, generation : Int, file_key : BytesView, key_length_bits : Int, data : BytesView, iv : BytesView) -> Bytes raise PdfErrorfn pdf_aesv3_encrypt_object_data(file_key : BytesView, data : BytesView, iv : BytesView) -> Bytes raise PdfErrorfn pdf_arc4_crypt_object(object_number : Int, generation : Int, file_key : BytesView, key_length_bits : Int, data : BytesView) -> Bytes raise PdfErrorfn pdf_authenticate_owner_password(no_encrypt_metadata : Bool, owner_password : BytesView, revision : Int, user_entry : BytesView, owner_entry : BytesView, permissions : Int, file_id : BytesView, key_length_bits : Int) -> Bool raise PdfErrorfn pdf_authenticate_user_password(no_encrypt_metadata : Bool, user_password : BytesView, revision : Int, user_entry : BytesView, owner_entry : BytesView, permissions : Int, file_id : BytesView, key_length_bits : Int) -> Bool raise PdfErrorfn pdf_bytes_prefix_equal(left : BytesView, right : BytesView, length : Int) -> Boolfn pdf_crypt_low_byte(value : Int, shift : Int) -> Bytefn pdf_encryption_file_key(no_encrypt_metadata : Bool, password : BytesView, revision : Int, owner_entry : BytesView, permissions : Int, file_id : BytesView, key_length_bits : Int) -> Bytesfn pdf_encryption_object_key(crypt_type : PdfCryptType, object_number : Int, generation : Int, file_key : BytesView, key_length_bits : Int) -> Bytesfn pdf_make_owner_password_entry(revision : Int, owner_password : BytesView, user_password : BytesView, key_length_bits : Int) -> Bytes raise PdfErrorfn pdf_make_user_password_entry(no_encrypt_metadata : Bool, user_password : BytesView, revision : Int, owner_entry : BytesView, permissions : Int, file_id : BytesView, key_length_bits : Int) -> Bytes raise PdfErrorfn pdf_pad_password(password : BytesView) -> Bytesfn pdf_password_padding() -> Bytesfn pdf_sha256_digest(data : BytesView) -> Bytesfn pdf_sha384_digest(data : BytesView) -> Bytesfn pdf_sha512_digest(data : BytesView) -> Bytesfn pdf_user_password_from_owner_password(revision : Int, owner_password : BytesView, owner_entry : BytesView, key_length_bits : Int) -> Bytes raise PdfErrorInstall
Download zipByte-oriented PDF reading, writing, and manipulation toolkit for MoonBit.
Dependencies