pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pdf-devel] Encryption module page draft


From: David Vazquez
Subject: Re: [pdf-devel] Encryption module page draft
Date: Sat, 09 Aug 2008 05:43:02 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

address@hidden writes:

> Hello David.
>
>    I have written a draft of encryption module wiki
>    page[1]. Operations must be described yet.
>
> Many thanks. Reading the architecture page it is clear what is going
> to be implemented.
>
> I think that this is a good time to write down the API in the
> reference manual. Would you like to prepare the draft taking into
> account the comments made in this mailing list about the issue?
>

Hello jemarch.

I would like it :). So I have already written down the draft. I
include the patch here.

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: address@hidden
# target_branch: file:///home/davazp/projects/gnupdf/
# testament_sha1: f30baf421c90aad1347c975cb84f17f9a0d089ff
# timestamp: 2008-08-09 05:29:30 +0200
# base_revision_id: address@hidden
# 
# Begin patch
=== modified file 'ChangeLog'
--- ChangeLog   2008-08-06 21:45:28 +0000
+++ ChangeLog   2008-08-09 03:27:32 +0000
@@ -1,3 +1,9 @@
+2008-08-09  David Vazquez  <address@hidden>
+
+       * doc/gnupdf.texi (Encryption, Initializating the module)
+       (Creating and destroying Ciphers, Encryption and decryption)
+       (Utils functions, Usage example): New sections.
+
 2008-08-06  Jose E. Marchesi  <address@hidden>
 
        *  Patch by Hans Hohenfeld changing the interface of

=== modified file 'doc/gnupdf.texi'
--- doc/gnupdf.texi     2008-08-06 21:45:28 +0000
+++ doc/gnupdf.texi     2008-08-09 03:27:32 +0000
@@ -86,6 +86,7 @@
 * Encoded Text::
 * Time Management::
 * The Filesystem Module::
+* Encryption::
 @end menu
 
 @node Base Layer Overview
@@ -7850,6 +7851,242 @@
 @end table
 @end deftypefun
 
+
+
+
address@hidden Encryption
address@hidden Encryption
+
+This section describes related to encryption functions.
+
address@hidden
+* Initializating the module::   
+* Creating and destroying Ciphers::  
+* Encryption and decryption::   
+* Utils functions::  
+* Usage example::           
address@hidden menu
+
address@hidden Initializating the module
address@hidden Initializating the module
+
+The encryption module must be initialized when Libgnupdf library was
+loaded It is *NOT* safe-thread.
+
address@hidden pdf_status_t pdf_crypt_init (void)
+
+Initialize the encryption module.
+
address@hidden @strong
address@hidden Parameters
+None.
address@hidden Returns
+A PDF status value:
address@hidden @code
address@hidden PDF_OK
+The module was initialized successfully.
address@hidden PDF_ERROR
+A error ocurred.
address@hidden table
address@hidden table
address@hidden deftypefun
+
address@hidden Creating and destroying Ciphers
address@hidden Creating and destroying Ciphers
+
address@hidden {Data Type} {pdf_crypt_algo_t}
+Enumeration of encryption algorithms provided.
address@hidden deftp
+
address@hidden {Data Type} {pdf_crypt_t}
+A cipher. It contains data which is required between several calls to
+functions.
address@hidden deftp
+
address@hidden pdf_status_t pdf_crypt_new (pdf_crypt_algo_t @var{algorithm}, 
pdf_crypt_t @var{*cipher})
+
+Create a new cipher.
+
address@hidden @strong
address@hidden Parameters
address@hidden @var
address@hidden algorithm
+The algorithm the cipher will use in order to encrypt or decrypt
+data. Possible values are:
address@hidden @code
address@hidden PDF_CRYPT_IDENTITY
address@hidden PDF_CRYPT_AESV2
address@hidden PDF_CRYPT_V2
address@hidden table
address@hidden cipher
+A pointer to @code{pdf_crypt_t} variable where it will put the cipher.
address@hidden table
address@hidden Returns
+A PDF status value:
address@hidden @code
address@hidden PDF_OK
+The cipher was created sucessfully.
address@hidden PDF_ERROR
+A error ocurred when trying create the cipher.
address@hidden table
address@hidden table
address@hidden deftypefun
+
+
address@hidden pdf_status_t pdf_crypt_destroy (pdf_crypt_t @var{cipher})
+
+Destroy a cipher.
+
address@hidden @strong
address@hidden Parameters
address@hidden @var
address@hidden cipher
+The cipher you want destroy. It must have been created with
address@hidden functions previosly.
address@hidden table
address@hidden Returns
address@hidden @code
+A PDF status value:
address@hidden PDF_OK
+The cipher was destroyed sucessfully.
address@hidden PDF_ERROR
+A error ocurred when trying destroy the cipher.
address@hidden table
address@hidden table
address@hidden deftypefun
+
+
address@hidden Encryption and decryption
address@hidden Encryption and decryption
+
address@hidden pdf_status_t pdf_crypt_setkey (pdf_crypt_t @var{cipher}, 
pdf_char_t  @var{*key}, pdf_size_t  @var{length})
+
+Set the key which will be used to encrypt and decrypt data. This
+function should be called each time @code{pdf_crypt_encrypt} or
address@hidden are called.
+
address@hidden @strong
address@hidden Parameters
address@hidden @var
address@hidden cipher
+A cipher created previously.
address@hidden key
+A pointer to memory where the key is stored.
address@hidden length
+The length of the key in bytes. Note that some algorithms could require
+a fixed length of key.
address@hidden table
address@hidden Returns
+A PDF status value:
address@hidden @code
address@hidden PDF_OK
address@hidden PDF_ERROR
address@hidden table
address@hidden table
address@hidden deftypefun
+
address@hidden pdf_size_t pdf_crypt_encrypt_size (pdf_crypt_t @var{cipher}, 
pdf_char_t  @var{*in}, pdf_size_t  @var{length})
address@hidden deftypefun
+
address@hidden pdf_status_t pdf_crypt_decrypt_size (pdf_crypt_t @var{cipher}, 
pdf_char_t  @var{*in}, pdf_size_t  @var{length})
+
+Compute the lesser valid size for the output buffer in
address@hidden and @code{pdf_crypt_decrypt} functions
+respectively for the given parameters.
+
address@hidden @strong
address@hidden Parameters
address@hidden @var
address@hidden cipher
+A cipher.
address@hidden in
+A pointer to the buffer which will be encrypt.
address@hidden length
+The length of the buffer in bytes.
address@hidden table
address@hidden Returns
+The size of a valid output buffer in @code{pdf_crypt_encrypt} function for 
this parameters.
address@hidden table
address@hidden deftypefun
+
+
address@hidden pdf_status_t pdf_crypt_encrypt (pdf_crypt_t @var{cipher}, 
pdf_char_t  @var{*out}, pdf_size_t  @var{outsize}, pdf_char_t  @var{*in}, 
pdf_size_t  @var{length}) 
+
+Encrypt a buffer. The ciphered text will be put in @var{out}.
+
address@hidden deftypefun
+
address@hidden pdf_status_t pdf_crypt_decrypt (pdf_crypt_t @var{cipher}, 
pdf_char_t  @var{*out}, pdf_size_t  @var{outsize}, pdf_char_t  @var{*in}, 
pdf_size_t  @var{length})
+
+Decrypt a buffer. The plain text will be put in @var{out}.
+
address@hidden @strong
address@hidden Parameters
address@hidden @var
address@hidden cipher
+A cipher.
address@hidden out
+A pointer to the output buffer.
address@hidden outsize
+Size of the output buffer in bytes. The function will rails if it is not
+too large to contain the output.
address@hidden in
+A pointer to input buffer.
address@hidden length
+The length of the input buffer in bytes.
address@hidden table
address@hidden Returns
+A PDF status value:
address@hidden @code
address@hidden PDF_OK
address@hidden PDF_ERROR
address@hidden table
address@hidden table
address@hidden deftypefun
+
address@hidden Utils functions
address@hidden Utils functions
+
address@hidden pdf_status_t pdf_crypt_md5 (pdf_char_t  @var{*out}, pdf_size_t  
@var{outsize}, pdf_char_t  @var{*in}, pdf_size_t  @var{length})
+
+Compute the message-digest md5 function of a buffer in memory.
+
address@hidden @strong
address@hidden Parameters
address@hidden @var
address@hidden out
+A pointer to output buffer.
address@hidden outsize
+The size of output buffer in bytes. This parameter is provided in order
+to avoid a possible overflow. It must be at least 16 bytes.
address@hidden in
+A pointer to the input buffer which md5 will compute on.
address@hidden length
+Size of the input buffer in bytes.
address@hidden table
address@hidden Returns
+A PDF status value:
address@hidden @code
address@hidden PDF_OK
address@hidden PDF_ERROR
address@hidden table
address@hidden table
address@hidden deftypefun
+
address@hidden Usage example
address@hidden Usage example
+
+Assuming that:
address@hidden @code
address@hidden @var{buffer} contains the data you want encrypt
address@hidden @var{size} the length of the buffer:
address@hidden table
+
address@hidden
+xxx
address@hidden example
+
+
 @node Object Layer
 @chapter Object Layer
 

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWUOVMjUABEzfgECwUXf//38t
3yC////6YAtbc3xcDNN9aJ7vXVRdtdGB2aa2mpSneucle44yZNNMJkZAwIxNGCMINGmAAQSiNNCZ
AptTU0aaAAAAAaADQBJAUIhHog0NlNGhoeoAMg00aHqABJqKTTRJ5I0eUGgAaZAA0aAAABEoibSj
0T1PQQ0p6jTaQ8po0aDajTQ0eoNNASJCJ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