Add a function to get the raw signature data.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 26 Nov 2008 10:45:47 +0000 (10:45 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 26 Nov 2008 10:45:47 +0000 (10:45 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eet@37809 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/Eet.h
src/lib/Eet_private.h
src/lib/eet_cipher.c
src/lib/eet_lib.c

index 4b34c06..c586eb0 100644 (file)
@@ -307,6 +307,12 @@ extern "C" {
      */
    EAPI const void *eet_identity_x509(Eet_File *ef, int *der_length);
 
+    /**
+     * Get the raw signature associated with an Eet_File. Will return NULL
+     * if the file is not signed.
+     */
+   EAPI const void *eet_identity_signature(Eet_File *ef, int *signature_length);
+
    /**
     * Display the x509 der certificate to out.
     *
index e3a1435..1701328 100644 (file)
@@ -70,6 +70,7 @@ int   _eet_hash_gen(const char *key, int hash_size);
 
 const void* eet_identity_check(const void *data_base, unsigned int data_length,
                               const void *signature_base, unsigned int signature_length,
+                              const void **raw_signature_base, unsigned int *raw_signature_length,
                               int *x509_length);
 Eet_Error eet_cipher(const void *data, unsigned int size, const char *key, unsigned int length, void **result, unsigned int *result_length);
 Eet_Error eet_decipher(const void *data, unsigned int size, const char *key, unsigned int length, void **result, unsigned int *result_length);
index 2de8711..96949f5 100644 (file)
@@ -477,6 +477,7 @@ eet_identity_sign(FILE *fp, Eet_Key *key)
 const void*
 eet_identity_check(const void *data_base, unsigned int data_length,
                   const void *signature_base, unsigned int signature_length,
+                  const void **raw_signature_base, unsigned int *raw_signature_length,
                   int *x509_length)
 {
 #ifdef HAVE_SIGNATURE
@@ -554,6 +555,8 @@ eet_identity_check(const void *data_base, unsigned int data_length,
      return NULL;
 # endif
    if (x509_length) *x509_length = cert_len;
+   if (raw_signature_base) *raw_signature_base = sign;
+   if (raw_signature_length) *raw_signature_length = sign_len;
    return cert_der;
 #else
    return NULL;
index 44b510c..5de1c6e 100644 (file)
@@ -89,13 +89,17 @@ struct _Eet_File
    Eet_Key             *key;
    const unsigned char  *data;
    const void           *x509_der;
+   const void           *signature;
+
+   Eet_File_Mode         mode;
 
    int                   magic;
    int                   references;
 
-   Eet_File_Mode         mode;
    int                   data_size;
    int                   x509_length;
+   unsigned int          signature_length;
+
    time_t                mtime;
 
    unsigned char         writes_pending : 1;
@@ -1022,12 +1026,16 @@ eet_internal_read2(Eet_File *ef)
    /* Check if the file is signed */
    ef->x509_der = NULL;
    ef->x509_length = 0;
+   ef->signature = NULL;
+   ef->signature_length = 0;
+
    if (signature_base_offset < ef->data_size)
      {
 #ifdef HAVE_SIGNATURE
        const unsigned char *buffer = ((const unsigned char*) ef->data) + signature_base_offset;
        ef->x509_der = eet_identity_check(ef->data, signature_base_offset,
                                          buffer, ef->data_size - signature_base_offset,
+                                         &ef->signature, &ef->signature_length,
                                          &ef->x509_length);
 
        if (eet_test_close(ef->x509_der == NULL, ef)) return NULL;
@@ -1440,6 +1448,15 @@ eet_identity_x509(Eet_File *ef, int *der_length)
    return ef->x509_der;
 }
 
+EAPI const void *
+eet_identity_signature(Eet_File *ef, int *signature_length)
+{
+   if (!ef->signature) return NULL;
+
+   if (signature_length) *signature_length = ef->signature_length;
+   return ef->signature;
+}
+
 EAPI Eet_Error
 eet_identity_set(Eet_File *ef, Eet_Key *key)
 {