libtasn1-commit
[Top][All Lists]
Advanced

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

[SCM] GNU libtasn1 branch, master, updated. libtasn1_3_6-44-g9d82632


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_3_6-44-g9d82632
Date: Thu, 26 Jun 2014 08:17:26 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU libtasn1".

http://git.savannah.gnu.org/cgit/libtasn1.git/commit/?id=9d8263225b82469c6c1209e1f448d0f021544628

The branch, master has been updated
       via  9d8263225b82469c6c1209e1f448d0f021544628 (commit)
       via  d9751e077f02ed4718c5e274ef384a1f72250b34 (commit)
       via  317486161fcf615c4093ac00608b880f2361373f (commit)
       via  8a7e190c538a1c4077d44762eea4651cb5d58116 (commit)
      from  4a6b8002c35d98a3bb39d566ef1bb11117d11868 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9d8263225b82469c6c1209e1f448d0f021544628
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Fri Jun 20 15:29:17 2014 +0200

    bumped version

commit d9751e077f02ed4718c5e274ef384a1f72250b34
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Fri Jun 20 15:29:09 2014 +0200

    doc update

commit 317486161fcf615c4093ac00608b880f2361373f
Author: Karel Slany <address@hidden>
Date:   Fri Jun 20 15:05:09 2014 +0200

    Renamed asn1_der_decoding_relaxed(), added ASN1_DECODE_FLAG_ALLOW_PADDING.

commit 8a7e190c538a1c4077d44762eea4651cb5d58116
Author: Karel Slany <address@hidden>
Date:   Fri Jun 20 11:49:41 2014 +0200

    Added asn1_der_decoding_relaxed().

-----------------------------------------------------------------------

Summary of changes:
 NEWS             |    6 +++++
 lib/decoding.c   |   57 ++++++++++++++++++++++++++++++++++++++++++-----------
 lib/libtasn1.h   |   10 ++++++++-
 lib/libtasn1.map |    1 +
 4 files changed, 61 insertions(+), 13 deletions(-)

diff --git a/NEWS b/NEWS
index c948c5d..34d56c4 100644
--- a/NEWS
+++ b/NEWS
@@ -8,8 +8,14 @@ GNU Libtasn1 NEWS                                     -*- 
outline -*-
   is a sequence element.
 - Several optimizations in DER decoding of structures with sequences
   containing many elements.
+- asn1_der_decoding2() is introduced and allows flags to be passed on
+  the decoding process. Currently only ASN1_DECODE_FLAG_ALLOW_PADDING is
+  defined and that allows decoding DER structures that contain arbitrary
+  data past their end. Contributed by Karel Slany.
 - API and ABI changes since last version:
+  ASN1_DECODE_FLAG_ALLOW_PADDING: New definition
   asn1_dup_node: New function
+  asn1_der_decoding2: New function
   asn1_der_decoding_element: Made alias to asn1_der_decoding
 
 * Noteworthy changes in release 3.6 (released 2014-05-25) [stable]
diff --git a/lib/decoding.c b/lib/decoding.c
index f5a8fca..b7e49b4 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -871,21 +871,23 @@ static void delete_unneeded_choice_fields(asn1_node p)
 }
 
 
-
 /**
- * asn1_der_decoding:
+ * asn1_der_decoding2
  * @element: pointer to an ASN1 structure.
  * @ider: vector that contains the DER encoding.
- * @ider_len: number of bytes of address@hidden: @address@hidden
+ * @max_ider_len: pointer to an integer giving the information about the
+ *   maximal number of bytes occupied by address@hidden The real size of the 
DER
+ *   encoding is returned through this pointer.
+ * @flags: flags controlling the behaviour of the function.
  * @errorDescription: null-terminated string contains details when an
  *   error occurred.
  *
- * Fill the structure address@hidden with values of a DER encoding
- * string. The structure must just be created with function
- * asn1_create_element(). 
+ * Fill the structure address@hidden with values of a DER encoding string. The
+ * structure must just be created with function asn1_create_element().
  *
- * Note that the address@hidden variable is provided as a pointer for
- * historical reasons.
+ * If %ASN1_DECODE_FLAG_ALLOW_PADDING flag is set then the function will ignore
+ * padding after the decoded DER data. Upon a successful return the value of
+ * address@hidden will be set to the number of bytes decoded.
  *
  * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
  *   if @ELEMENT is %NULL, and %ASN1_TAG_ERROR or
@@ -893,8 +895,8 @@ static void delete_unneeded_choice_fields(asn1_node p)
  *   name (address@hidden deleted).
  **/
 int
-asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
-                  char *errorDescription)
+asn1_der_decoding2 (asn1_node *element, const void *ider, int *max_ider_len,
+                   unsigned int flags, char *errorDescription)
 {
   asn1_node node, p, p2, p3;
   char temp[128];
@@ -902,7 +904,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, 
int ider_len,
   asn1_node ptail = NULL;
   unsigned char class;
   unsigned long tag;
-  int indefinite, result, total_len = ider_len;
+  int indefinite, result, total_len = *max_ider_len, ider_len = *max_ider_len;
   const unsigned char *der = ider;
 
   node = *element;
@@ -1468,13 +1470,16 @@ asn1_der_decoding (asn1_node * element, const void 
*ider, int ider_len,
 
   _asn1_delete_not_used (*element);
 
-  if (ider_len != 0)
+  if ((ider_len < 0) ||
+      (!(flags & ASN1_DECODE_FLAG_ALLOW_PADDING) && (ider_len != 0)))
     {
       warn();
       result = ASN1_DER_ERROR;
       goto cleanup;
     }
 
+  *max_ider_len = total_len - ider_len;
+
   return ASN1_SUCCESS;
 
 cleanup:
@@ -1482,6 +1487,34 @@ cleanup:
   return result;
 }
 
+
+/**
+ * asn1_der_decoding:
+ * @element: pointer to an ASN1 structure.
+ * @ider: vector that contains the DER encoding.
+ * @ider_len: number of bytes of address@hidden: @address@hidden
+ * @errorDescription: null-terminated string contains details when an
+ *   error occurred.
+ *
+ * Fill the structure address@hidden with values of a DER encoding
+ * string. The structure must just be created with function
+ * asn1_create_element(). 
+ *
+ * Note that the address@hidden variable is provided as a pointer for
+ * historical reasons.
+ *
+ * Returns: %ASN1_SUCCESS if DER encoding OK, %ASN1_ELEMENT_NOT_FOUND
+ *   if @ELEMENT is %NULL, and %ASN1_TAG_ERROR or
+ *   %ASN1_DER_ERROR if the der encoding doesn't match the structure
+ *   name (address@hidden deleted).
+ **/
+int
+asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
+                  char *errorDescription)
+{
+  return asn1_der_decoding2 (element, ider, &ider_len, 0, errorDescription);
+}
+
 #define FOUND        1
 #define SAME_BRANCH  2
 #define OTHER_BRANCH 3
diff --git a/lib/libtasn1.h b/lib/libtasn1.h
index f798a75..8f7ff0b 100644
--- a/lib/libtasn1.h
+++ b/lib/libtasn1.h
@@ -44,7 +44,7 @@ extern "C"
 {
 #endif
 
-#define ASN1_VERSION "3.6"
+#define ASN1_VERSION "4.0"
 
 #if defined(__GNUC__) && !defined(ASN1_INTERNAL_BUILD)
 # define _ASN1_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + 
__GNUC_PATCHLEVEL__)
@@ -184,6 +184,9 @@ extern "C"
 /* makes sure the values are zeroized prior to deinitialization */
 #define ASN1_DELETE_FLAG_ZEROIZE 1
 
+/* Flags used by asn1_der_decoding2(). */
+#define ASN1_DECODE_FLAG_ALLOW_PADDING 1
+
 
   struct asn1_data_node_st
   {
@@ -259,6 +262,11 @@ extern "C"
                     void *ider, int *len, char *ErrorDescription);
 
   extern ASN1_API int
+    asn1_der_decoding2 (asn1_node *element, const void *ider,
+                       int *max_ider_len, unsigned int flags,
+                       char *errorDescription);
+
+  extern ASN1_API int
     asn1_der_decoding (asn1_node * element, const void *ider,
                       int len, char *errorDescription);
 
diff --git a/lib/libtasn1.map b/lib/libtasn1.map
index 1a23d31..6424219 100644
--- a/lib/libtasn1.map
+++ b/lib/libtasn1.map
@@ -26,6 +26,7 @@ LIBTASN1_0_3
     asn1_delete_element;
     asn1_delete_structure;
     asn1_der_coding;
+    asn1_der_decoding2;
     asn1_der_decoding;
     asn1_der_decoding_element;
     asn1_der_decoding_startEnd;


hooks/post-receive
-- 
GNU libtasn1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]