pdf-devel
[Top][All Lists]
Advanced

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

[pdf-devel] Examples for the crypt module API


From: David Vazquez
Subject: [pdf-devel] Examples for the crypt module API
Date: Tue, 7 Oct 2008 19:42:01 +0200 (CEST)
User-agent: SquirrelMail/1.4.9a

I have written some examples for crypt module API.

jemarch, I could take a simple task, any suggestion?

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: address@hidden
# target_branch: http://bzr.savannah.gnu.org/r/pdf/libgnupdf/branches\
#   /trunk/
# testament_sha1: 8cadf9b6dc75994d8f14951c9eb00f7545d9adec
# timestamp: 2008-10-07 19:28:56 +0200
# base_revision_id: address@hidden
#
# Begin patch
=== modified file 'doc/gnupdf.texi'
--- doc/gnupdf.texi     2008-10-02 20:49:15 +0000
+++ doc/gnupdf.texi     2008-10-07 17:28:21 +0000
@@ -8083,7 +8083,14 @@
 @end table
 @item Usage example
 @example
-xxx
+pdf_status_t st;
+
+st = pdf_crypt_init ();
+
+if (st != PDF_OK)
address@hidden
+   /* Error */
address@hidden
 @end example
 @end table
 @end deftypefun
@@ -8130,7 +8137,15 @@
 @end table
 @item Usage example
 @example
-xxx
+pdf_status_t st;
+pdf_crypt_cipher_t cipher;
+
+st = pdf_crypt_cipher_new (PDF_CRYPT_CIPHER_ALG_AESV2, &cipher);
+
+if (st != PDF_OK)
address@hidden
+   /* Error */
address@hidden
 @end example
 @end table
 @end deftypefun
@@ -8157,7 +8172,9 @@
 @end table
 @item Usage example
 @example
-xxx
+pdf_crypt_cipher_t cipher;
+pdf_crypt_cipher_new (PDF_CRYPT_CIPHER_ALG_AESV2, &cipher);
+pdf_crypt_cipher_destroy (cipher);
 @end example
 @end table
 @end deftypefun
@@ -8192,6 +8209,20 @@
 @item PDF_ERROR
 A error ocurred while trying to set the key.
 @end table
address@hidden Usage example
address@hidden
+pdf_status_t st;
+pdf_crypt_cipher_t cipher;
+pdf_char_t key[16];
+
+/* ... */
+st = pdf_crypt_cipher_setkey (&cipher, key, sizeof(key));
+
+if (st != PDF_OK)
address@hidden
+   /* Error */
address@hidden
address@hidden example
 @end table
 @end deftypefun

@@ -8213,6 +8244,15 @@
 @item Returns
 The size of a valid output buffer in @code{pdf_crypt_cipher_encrypt}
 function for this parameters.
address@hidden Usage example
address@hidden
+pdf_crypt_cipher_t cipher;
+pdf_size_t size;
+pdf_char_t in[16];
+
+/* ...prepare the cipher... */
+size = pdf_crypt_cipher_encrypt_size (cipher, in, sizeof (in));
address@hidden example
 @end table
 @end deftypefun

@@ -8234,6 +8274,16 @@
 @item Returns
 The size of a valid output buffer in @code{pdf_crypt_cipher_encrypt}
 function for this parameters.
address@hidden Usage example
address@hidden
+pdf_crypt_cipher_t cipher;
+pdf_size_t size;
+pdf_char_t *in;
+pdf_size_t in_size;
+
+/* ...prepare the cipher... */
+size = pdf_crypt_cipher_decrypt_size (cipher, in, in_size);
address@hidden example
 @end table
 @end deftypefun

@@ -8269,7 +8319,23 @@
 @end table
 @item Usage example
 @example
-xxx
+pdf_crypt_cipher_t cipher;
+pdf_status_t st;
+pdf_char_t *out;
+pdf_char_t *in;
+pdf_size_t out_size;
+pdf_size_t in_size;
+
+/* ... */
+out_size = pdf_crypt_cipher_encrypt_size (cipher, in, in_size);
+out = pdf_alloc (out_size);
+
+st = pdf_crypt_cipher_encrypt (cipher, out, out_size, in, in_size,
&out_size);
+
+if (st != PDF_OK)
address@hidden
+  /* Error*/
address@hidden
 @end example
 @end table
 @end deftypefun
@@ -8306,7 +8372,23 @@
 @end table
 @item Usage example
 @example
-xxx
+pdf_crypt_cipher_t cipher;
+pdf_status_t st;
+pdf_char_t *out;
+pdf_char_t *in;
+pdf_size_t out_size;
+pdf_size_t in_size;
+
+/* ... */
+out_size = pdf_crypt_cipher_decrypt_size (cipher, in, in_size);
+out = pdf_alloc (out_size);
+
+st = pdf_crypt_crypt_decrypt (cipher, out, out_size, in, in_size,
&out_size);
+
+if (st != PDF_OK)
address@hidden
+  /* Error*/
address@hidden
 @end example
 @end table
 @end deftypefun
@@ -8352,7 +8434,15 @@
 @end table
 @item Usage example
 @example
-xxx
+pdf_status_t st;
+pdf_crypt_md_t md;
+
+st = pdf_crypt_md_new (&md, PDF_CRYPT_MD_MD5);
+
+if (st != PDF_OK)
address@hidden
+   /* Error /*
address@hidden
 @end example
 @end table
 @end deftypefun
@@ -8387,7 +8477,24 @@
 @end table
 @item Usage example
 @example
-xxx
+pdf_crypt_md_t md;
+pdf_char_t out[16];
+pdf_char_t *in;
+pdf_size_t in_size;
+pdf_status_t st;
+
+/* ...Prepare IN and IN_SIZE variables */
+
+pdf_crypt_md_new (&md, PDF_CRYPT_MD_MD5);
+
+st = pdf_crypt_md_hash (md, out, sizeof(out), in, in_size);
+
+if (st != PDF_OK)
address@hidden
+   /* Error */
address@hidden
+
+pdf_crypt_md_destroy (md);
 @end example
 @end table
 @end deftypefun
@@ -8413,7 +8520,14 @@
 @end table
 @item Usage example
 @example
-xxx
+pdf_status_t st;
+pdf_crypt_md_t md;
+
+st = pdf_crypt_md_new (&md, PDF_CRYPT_MD_MD5);
+
+/* ... /*
+
+pdf_crypt_md_destroy (md);
 @end example
 @end table
 @end deftypefun

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWQAe4g8AAw3fgAAQcXf//3/v
3zq////6YAY+98+7dDqQzsaoAAAcZMmhiMTRgEYCYQBgJpo0yNAMcZMmhiMTRgEYCYQBgJpo0yNA
MNFNiU/UaFDag2poANAAAGgAaAAkiFTT009UNBpo0yAAA0aNGgNAA0A2pRpJiafqjTE9TBMIBoA0
aHomJhPUDRoIpCCYICGCNDSMU9KA9ID1NB6nqaae0RqRie+stadIQEC0VPZV3BFRqQiWsHp4qA9M
QNNmKayKZ5iVYJsWoRq0iDRm7RtRd3IO8UmJlAyFwyLytocYQiDKqcosKiITSQsJB813n2g+36NI
JXBM+Omh8viUX6/UPBLR3rKede4t4wRCnriDpVAhaIXstFS1WzYox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