aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eet/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eet/src/lib')
-rw-r--r--libraries/eet/src/lib/Eet.h17
-rw-r--r--libraries/eet/src/lib/Makefile.in4
-rw-r--r--libraries/eet/src/lib/eet_alloc.c2
-rw-r--r--libraries/eet/src/lib/eet_cipher.c71
-rw-r--r--libraries/eet/src/lib/eet_data.c21
-rw-r--r--libraries/eet/src/lib/eet_dictionary.c6
-rw-r--r--libraries/eet/src/lib/eet_image.c19
7 files changed, 99 insertions, 41 deletions
diff --git a/libraries/eet/src/lib/Eet.h b/libraries/eet/src/lib/Eet.h
index 2df7fbf..7495090 100644
--- a/libraries/eet/src/lib/Eet.h
+++ b/libraries/eet/src/lib/Eet.h
@@ -6,7 +6,7 @@
6 @mainpage Eet Library Documentation 6 @mainpage Eet Library Documentation
7 7
8 @version 1.5.0 8 @version 1.5.0
9 @date 2000-2011 9 @date 2000-2012
10 10
11 Please see the @ref authors page for contact details. 11 Please see the @ref authors page for contact details.
12 12
@@ -30,7 +30,7 @@
30 Eet is extremely fast, small and simple. Eet files can be very small and 30 Eet is extremely fast, small and simple. Eet files can be very small and
31 highly compressed, making them very optimal for just sending across the 31 highly compressed, making them very optimal for just sending across the
32 internet without having to archive, compress or decompress and install them. 32 internet without having to archive, compress or decompress and install them.
33 They allow for lightning-fast random-acess reads once created, making them 33 They allow for lightning-fast random-access reads once created, making them
34 perfect for storing data that is written once (or rarely) and read many 34 perfect for storing data that is written once (or rarely) and read many
35 times, but the program does not want to have to read it all in at once. 35 times, but the program does not want to have to read it all in at once.
36 36
@@ -577,7 +577,7 @@ EAPI Eet_File_Mode
577eet_mode_get(Eet_File *ef); 577eet_mode_get(Eet_File *ef);
578 578
579/** 579/**
580 * Close an eet file handle and flush and writes pending. 580 * Close an eet file handle and flush pending writes.
581 * @param ef A valid eet file handle. 581 * @param ef A valid eet file handle.
582 * 582 *
583 * This function will flush any pending writes to disk if the eet file 583 * This function will flush any pending writes to disk if the eet file
@@ -645,6 +645,17 @@ eet_dictionary_string_check(Eet_Dictionary *ed,
645 const char *string); 645 const char *string);
646 646
647/** 647/**
648 * Return the number of strings inside a dictionary
649 * @param ed A valid dictionary handle
650 * @return the number of strings inside a dictionary
651 *
652 * @since 1.6.0
653 * @ingroup Eet_File_Group
654 */
655EAPI int
656eet_dictionary_count(const Eet_Dictionary *ed);
657
658/**
648 * Read a specified entry from an eet file and return data 659 * Read a specified entry from an eet file and return data
649 * @param ef A valid eet file handle opened for reading. 660 * @param ef A valid eet file handle opened for reading.
650 * @param name Name of the entry. eg: "/base/file_i_want". 661 * @param name Name of the entry. eg: "/base/file_i_want".
diff --git a/libraries/eet/src/lib/Makefile.in b/libraries/eet/src/lib/Makefile.in
index 2a3fec0..c0367b3 100644
--- a/libraries/eet/src/lib/Makefile.in
+++ b/libraries/eet/src/lib/Makefile.in
@@ -172,6 +172,8 @@ EINA_LIBS = @EINA_LIBS@
172EVIL_CFLAGS = @EVIL_CFLAGS@ 172EVIL_CFLAGS = @EVIL_CFLAGS@
173EVIL_LIBS = @EVIL_LIBS@ 173EVIL_LIBS = @EVIL_LIBS@
174EXEEXT = @EXEEXT@ 174EXEEXT = @EXEEXT@
175EXOTIC_CFLAGS = @EXOTIC_CFLAGS@
176EXOTIC_LIBS = @EXOTIC_LIBS@
175FGREP = @FGREP@ 177FGREP = @FGREP@
176GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ 178GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
177GNUTLS_LIBS = @GNUTLS_LIBS@ 179GNUTLS_LIBS = @GNUTLS_LIBS@
@@ -211,6 +213,8 @@ PACKAGE_URL = @PACKAGE_URL@
211PACKAGE_VERSION = @PACKAGE_VERSION@ 213PACKAGE_VERSION = @PACKAGE_VERSION@
212PATH_SEPARATOR = @PATH_SEPARATOR@ 214PATH_SEPARATOR = @PATH_SEPARATOR@
213PKG_CONFIG = @PKG_CONFIG@ 215PKG_CONFIG = @PKG_CONFIG@
216PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
217PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
214RANLIB = @RANLIB@ 218RANLIB = @RANLIB@
215SED = @SED@ 219SED = @SED@
216SET_MAKE = @SET_MAKE@ 220SET_MAKE = @SET_MAKE@
diff --git a/libraries/eet/src/lib/eet_alloc.c b/libraries/eet/src/lib/eet_alloc.c
index 85351ad..29e276c 100644
--- a/libraries/eet/src/lib/eet_alloc.c
+++ b/libraries/eet/src/lib/eet_alloc.c
@@ -3,6 +3,7 @@
3#endif 3#endif
4 4
5#include <Eina.h> 5#include <Eina.h>
6
6#include "Eet.h" 7#include "Eet.h"
7#include "Eet_private.h" 8#include "Eet_private.h"
8 9
@@ -90,4 +91,3 @@ eet_mempool_shutdown(void)
90 mempool_array[i]->mp = NULL; 91 mempool_array[i]->mp = NULL;
91 } 92 }
92} 93}
93
diff --git a/libraries/eet/src/lib/eet_cipher.c b/libraries/eet/src/lib/eet_cipher.c
index 37a0899..2425e22 100644
--- a/libraries/eet/src/lib/eet_cipher.c
+++ b/libraries/eet/src/lib/eet_cipher.c
@@ -56,6 +56,9 @@ void *alloca(size_t);
56 56
57#ifdef HAVE_CIPHER 57#ifdef HAVE_CIPHER
58# ifdef HAVE_GNUTLS 58# ifdef HAVE_GNUTLS
59# if defined EET_USE_NEW_PUBKEY_VERIFY_HASH || defined EET_USE_NEW_PRIVKEY_SIGN_DATA
60# include <gnutls/abstract.h>
61# endif
59# include <gnutls/x509.h> 62# include <gnutls/x509.h>
60# include <gcrypt.h> 63# include <gcrypt.h>
61# else /* ifdef HAVE_GNUTLS */ 64# else /* ifdef HAVE_GNUTLS */
@@ -497,6 +500,10 @@ eet_identity_sign(FILE *fp,
497 gnutls_datum_t datum = { NULL, 0 }; 500 gnutls_datum_t datum = { NULL, 0 };
498 size_t sign_len = 0; 501 size_t sign_len = 0;
499 size_t cert_len = 0; 502 size_t cert_len = 0;
503#ifdef EET_USE_NEW_PRIVKEY_SIGN_DATA
504 gnutls_datum_t signum = { NULL, 0 };
505 gnutls_privkey_t privkey;
506#endif
500# else /* ifdef HAVE_GNUTLS */ 507# else /* ifdef HAVE_GNUTLS */
501 EVP_MD_CTX md_ctx; 508 EVP_MD_CTX md_ctx;
502 unsigned int sign_len = 0; 509 unsigned int sign_len = 0;
@@ -528,6 +535,28 @@ eet_identity_sign(FILE *fp,
528 datum.size = st_buf.st_size; 535 datum.size = st_buf.st_size;
529 536
530 /* Get the signature length */ 537 /* Get the signature length */
538#ifdef EET_USE_NEW_PRIVKEY_SIGN_DATA
539 if (gnutls_privkey_init(&privkey) < 0)
540 {
541 err = EET_ERROR_SIGNATURE_FAILED;
542 goto on_error;
543 }
544
545 if (gnutls_privkey_import_x509(privkey, key->private_key, 0) < 0)
546 {
547 err = EET_ERROR_SIGNATURE_FAILED;
548 goto on_error;
549 }
550
551 if (gnutls_privkey_sign_data(privkey, GNUTLS_DIG_SHA1, 0, &datum, &signum) < 0)
552 {
553 err = EET_ERROR_SIGNATURE_FAILED;
554 goto on_error;
555 }
556
557 sign = signum.data;
558 sign_len = signum.size;
559#else
531 if (gnutls_x509_privkey_sign_data(key->private_key, GNUTLS_DIG_SHA1, 0, 560 if (gnutls_x509_privkey_sign_data(key->private_key, GNUTLS_DIG_SHA1, 0,
532 &datum, sign, &sign_len) && 561 &datum, sign, &sign_len) &&
533 !sign_len) 562 !sign_len)
@@ -550,6 +579,7 @@ eet_identity_sign(FILE *fp,
550 579
551 goto on_error; 580 goto on_error;
552 } 581 }
582#endif
553 583
554 /* Get the certificate length */ 584 /* Get the certificate length */
555 if (gnutls_x509_crt_export(key->certificate, GNUTLS_X509_FMT_DER, cert, 585 if (gnutls_x509_crt_export(key->certificate, GNUTLS_X509_FMT_DER, cert,
@@ -696,6 +726,10 @@ eet_identity_check(const void *data_base,
696 gnutls_datum_t datum; 726 gnutls_datum_t datum;
697 gnutls_datum_t signature; 727 gnutls_datum_t signature;
698# if EET_USE_NEW_GNUTLS_API 728# if EET_USE_NEW_GNUTLS_API
729# if EET_USE_NEW_PUBKEY_VERIFY_HASH
730 gnutls_pubkey_t pubkey;
731 gnutls_digest_algorithm_t hash_algo;
732# endif
699 unsigned char *hash; 733 unsigned char *hash;
700 gcry_md_hd_t md; 734 gcry_md_hd_t md;
701 int err; 735 int err;
@@ -724,28 +758,32 @@ eet_identity_check(const void *data_base,
724 758
725 hash = gcry_md_read(md, GCRY_MD_SHA1); 759 hash = gcry_md_read(md, GCRY_MD_SHA1);
726 if (!hash) 760 if (!hash)
727 { 761 goto on_error;
728 gcry_md_close(md);
729 return NULL;
730 }
731 762
732 datum.size = gcry_md_get_algo_dlen(GCRY_MD_SHA1); 763 datum.size = gcry_md_get_algo_dlen(GCRY_MD_SHA1);
733 datum.data = hash; 764 datum.data = hash;
734 765
766# ifdef EET_USE_NEW_PUBKEY_VERIFY_HASH
767 if (gnutls_pubkey_init(&pubkey) < 0)
768 goto on_error;
769
770 if (gnutls_pubkey_import_x509(pubkey, cert, 0) < 0)
771 goto on_error;
772
773 if (gnutls_pubkey_get_verify_algorithm(pubkey, &signature, &hash_algo) < 0)
774 goto on_error;
775
776 if (gnutls_pubkey_verify_hash(pubkey, 0, &datum, &signature) < 0)
777 goto on_error;
778# else
735 if (!gnutls_x509_crt_verify_hash(cert, 0, &datum, &signature)) 779 if (!gnutls_x509_crt_verify_hash(cert, 0, &datum, &signature))
736 { 780 goto on_error;
737 gcry_md_close(md); 781# endif
738 return NULL;
739 }
740 782
741 if (sha1) 783 if (sha1)
742 { 784 {
743 *sha1 = malloc(datum.size); 785 *sha1 = malloc(datum.size);
744 if (!*sha1) 786 if (!*sha1) goto on_error;
745 {
746 gcry_md_close(md);
747 return NULL;
748 }
749 787
750 memcpy(*sha1, hash, datum.size); 788 memcpy(*sha1, hash, datum.size);
751 *sha1_length = datum.size; 789 *sha1_length = datum.size;
@@ -818,6 +856,13 @@ eet_identity_check(const void *data_base,
818 *raw_signature_length = sign_len; 856 *raw_signature_length = sign_len;
819 857
820 return cert_der; 858 return cert_der;
859# ifdef HAVE_GNUTLS
860# if EET_USE_NEW_GNUTLS_API
861 on_error:
862 gcry_md_close(md);
863 return NULL;
864# endif
865# endif
821#else /* ifdef HAVE_SIGNATURE */ 866#else /* ifdef HAVE_SIGNATURE */
822 data_base = NULL; 867 data_base = NULL;
823 data_length = 0; 868 data_length = 0;
diff --git a/libraries/eet/src/lib/eet_data.c b/libraries/eet/src/lib/eet_data.c
index 56b9ee0..d502f44 100644
--- a/libraries/eet/src/lib/eet_data.c
+++ b/libraries/eet/src/lib/eet_data.c
@@ -21,18 +21,6 @@
21#include "Eet.h" 21#include "Eet.h"
22#include "Eet_private.h" 22#include "Eet_private.h"
23 23
24#ifdef _WIN32
25# define FMT_CHAR "%c"
26# define FMT_UCHAR "%c"
27# define FMT_LONG_LONG "%I64i"
28# define FMT_ULONG_LONG "%I64u"
29#else
30# define FMT_CHAR "%hhi"
31# define FMT_UCHAR "%hhu"
32# define FMT_LONG_LONG "%lli"
33# define FMT_ULONG_LONG "%llu"
34#endif
35
36/* 24/*
37 * routines for doing data -> struct and struct -> data conversion 25 * routines for doing data -> struct and struct -> data conversion
38 * 26 *
@@ -3108,7 +3096,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed,
3108 if (!strcmp(tok3, "char:")) 3096 if (!strcmp(tok3, "char:"))
3109 { 3097 {
3110 n->type = EET_T_CHAR; 3098 n->type = EET_T_CHAR;
3111 sscanf(tok4, FMT_CHAR, 3099 sscanf(tok4, "%hhi",
3112 &(n->data.value.c)); 3100 &(n->data.value.c));
3113 } 3101 }
3114 else if (!strcmp(tok3, "short:")) 3102 else if (!strcmp(tok3, "short:"))
@@ -3126,7 +3114,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed,
3126 else if (!strcmp(tok3, "long_long:")) 3114 else if (!strcmp(tok3, "long_long:"))
3127 { 3115 {
3128 n->type = EET_T_LONG_LONG; 3116 n->type = EET_T_LONG_LONG;
3129 sscanf(tok4, FMT_LONG_LONG, 3117 sscanf(tok4, "%lli",
3130 &(n->data.value.l)); 3118 &(n->data.value.l));
3131 } 3119 }
3132 else if (!strcmp(tok3, "float:")) 3120 else if (!strcmp(tok3, "float:"))
@@ -3144,7 +3132,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed,
3144 else if (!strcmp(tok3, "uchar:")) 3132 else if (!strcmp(tok3, "uchar:"))
3145 { 3133 {
3146 n->type = EET_T_UCHAR; 3134 n->type = EET_T_UCHAR;
3147 sscanf(tok4, FMT_UCHAR, 3135 sscanf(tok4, "%hhu",
3148 &(n->data.value.uc)); 3136 &(n->data.value.uc));
3149 } 3137 }
3150 else if (!strcmp(tok3, "ushort:")) 3138 else if (!strcmp(tok3, "ushort:"))
@@ -3162,7 +3150,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed,
3162 else if (!strcmp(tok3, "ulong_long:")) 3150 else if (!strcmp(tok3, "ulong_long:"))
3163 { 3151 {
3164 n->type = EET_T_ULONG_LONG; 3152 n->type = EET_T_ULONG_LONG;
3165 sscanf(tok4, FMT_ULONG_LONG, 3153 sscanf(tok4, "%llu",
3166 &(n->data.value.ul)); 3154 &(n->data.value.ul));
3167 } 3155 }
3168 else if (!strcmp(tok3, "string:")) 3156 else if (!strcmp(tok3, "string:"))
@@ -4996,4 +4984,3 @@ eet_data_xattr_cipher_set(const char *filename,
4996 4984
4997 return ret; 4985 return ret;
4998} 4986}
4999
diff --git a/libraries/eet/src/lib/eet_dictionary.c b/libraries/eet/src/lib/eet_dictionary.c
index 287860d..c79239b 100644
--- a/libraries/eet/src/lib/eet_dictionary.c
+++ b/libraries/eet/src/lib/eet_dictionary.c
@@ -169,6 +169,12 @@ eet_dictionary_string_get_size(const Eet_Dictionary *ed,
169 return 0; 169 return 0;
170} 170}
171 171
172EAPI int
173eet_dictionary_count(const Eet_Dictionary *ed)
174{
175 return ed->count;
176}
177
172int 178int
173eet_dictionary_string_get_hash(const Eet_Dictionary *ed, 179eet_dictionary_string_get_hash(const Eet_Dictionary *ed,
174 int idx) 180 int idx)
diff --git a/libraries/eet/src/lib/eet_image.c b/libraries/eet/src/lib/eet_image.c
index 8c6c03c..b622236 100644
--- a/libraries/eet/src/lib/eet_image.c
+++ b/libraries/eet/src/lib/eet_image.c
@@ -246,7 +246,7 @@ eet_data_image_jpeg_rgb_decode(const void *data,
246 unsigned int w, 246 unsigned int w,
247 unsigned int h, 247 unsigned int h,
248 unsigned int row_stride); 248 unsigned int row_stride);
249static void * 249static int
250eet_data_image_jpeg_alpha_decode(const void *data, 250eet_data_image_jpeg_alpha_decode(const void *data,
251 int size, 251 int size,
252 unsigned int src_x, 252 unsigned int src_x,
@@ -560,7 +560,7 @@ eet_data_image_jpeg_rgb_decode(const void *data,
560 return 1; 560 return 1;
561} 561}
562 562
563static void * 563static int
564eet_data_image_jpeg_alpha_decode(const void *data, 564eet_data_image_jpeg_alpha_decode(const void *data,
565 int size, 565 int size,
566 unsigned int src_x, 566 unsigned int src_x,
@@ -577,6 +577,10 @@ eet_data_image_jpeg_alpha_decode(const void *data,
577 unsigned int x, y, l, scans; 577 unsigned int x, y, l, scans;
578 unsigned int i, iw; 578 unsigned int i, iw;
579 579
580 /* FIXME: handle src_x, src_y and row_stride correctly */
581 if (!d)
582 return 0;
583
580 memset(&cinfo, 0, sizeof (struct jpeg_decompress_struct)); 584 memset(&cinfo, 0, sizeof (struct jpeg_decompress_struct));
581 585
582 cinfo.err = jpeg_std_error(&(jerr.pub)); 586 cinfo.err = jpeg_std_error(&(jerr.pub));
@@ -584,14 +588,14 @@ eet_data_image_jpeg_alpha_decode(const void *data,
584 jerr.pub.emit_message = _JPEGErrorHandler2; 588 jerr.pub.emit_message = _JPEGErrorHandler2;
585 jerr.pub.output_message = _JPEGErrorHandler; 589 jerr.pub.output_message = _JPEGErrorHandler;
586 if (setjmp(jerr.setjmp_buffer)) 590 if (setjmp(jerr.setjmp_buffer))
587 return NULL; 591 return 0;
588 592
589 jpeg_create_decompress(&cinfo); 593 jpeg_create_decompress(&cinfo);
590 594
591 if (eet_jpeg_membuf_src(&cinfo, data, (size_t)size)) 595 if (eet_jpeg_membuf_src(&cinfo, data, (size_t)size))
592 { 596 {
593 jpeg_destroy_decompress(&cinfo); 597 jpeg_destroy_decompress(&cinfo);
594 return NULL; 598 return 0;
595 } 599 }
596 600
597 jpeg_read_header(&cinfo, TRUE); 601 jpeg_read_header(&cinfo, TRUE);
@@ -609,7 +613,7 @@ eet_data_image_jpeg_alpha_decode(const void *data,
609 cinfo.src = NULL; 613 cinfo.src = NULL;
610 614
611 jpeg_destroy_decompress(&cinfo); 615 jpeg_destroy_decompress(&cinfo);
612 return NULL; 616 return 0;
613 } 617 }
614 618
615 /* end head decoding */ 619 /* end head decoding */
@@ -620,11 +624,12 @@ eet_data_image_jpeg_alpha_decode(const void *data,
620 cinfo.src = NULL; 624 cinfo.src = NULL;
621 625
622 jpeg_destroy_decompress(&cinfo); 626 jpeg_destroy_decompress(&cinfo);
623 return NULL; 627 return 0;
624 } 628 }
625 629
626 tdata = alloca(w * 16 * 3); 630 tdata = alloca(w * 16 * 3);
627 ptr2 = d; 631 ptr2 = d;
632
628 if (cinfo.output_components == 1) 633 if (cinfo.output_components == 1)
629 { 634 {
630 for (i = 0; i < (unsigned int)cinfo.rec_outbuf_height; i++) 635 for (i = 0; i < (unsigned int)cinfo.rec_outbuf_height; i++)
@@ -666,7 +671,7 @@ eet_data_image_jpeg_alpha_decode(const void *data,
666 /* end data decoding */ 671 /* end data decoding */
667 jpeg_finish_decompress(&cinfo); 672 jpeg_finish_decompress(&cinfo);
668 jpeg_destroy_decompress(&cinfo); 673 jpeg_destroy_decompress(&cinfo);
669 return d; 674 return 1;
670} 675}
671 676
672static void * 677static void *