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_4_5-3-g6bf745b


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_4_5-3-g6bf745b
Date: Tue, 02 Jun 2015 07:47:22 +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=6bf745b7ef5791d55498c75d0fffc5df33876c26

The branch, master has been updated
       via  6bf745b7ef5791d55498c75d0fffc5df33876c26 (commit)
       via  ea87e27ec2517fa4f38513967f05851c9a0b99f9 (commit)
       via  6f247d75a82e4753b8069c56c24ef70e426ccc27 (commit)
      from  3e55bfc26cce210b2c7b20cc314bdf580968be53 (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 6bf745b7ef5791d55498c75d0fffc5df33876c26
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue Jun 2 09:45:11 2015 +0200

    doc update

commit ea87e27ec2517fa4f38513967f05851c9a0b99f9
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue Jun 2 09:44:17 2015 +0200

    export asn1_get_object_id_der

commit 6f247d75a82e4753b8069c56c24ef70e426ccc27
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue Jun 2 09:39:46 2015 +0200

    enforce type checks in asn1_decode_simple_der and ber

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

Summary of changes:
 NEWS           |    4 ++++
 lib/decoding.c |   29 ++++++++++++++++++-----------
 lib/int.h      |    7 +++++++
 lib/libtasn1.h |    5 +++++
 4 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/NEWS b/NEWS
index 2d84a22..b0c5a08 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
 GNU Libtasn1 NEWS                                     -*- outline -*-
 
+* Noteworthy changes in release 4.6 (unreleased) [stable]
+- API and ABI changes since last version:
+  asn1_get_object_id_der: New function
+
 * Noteworthy changes in release 4.5 (released 2015-04-29) [stable]
 - Corrected an invalid memory access in octet string decoding.
   Reported by Hanno Böck.
diff --git a/lib/decoding.c b/lib/decoding.c
index 42ddc6b..5cc7c89 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -346,8 +346,20 @@ _asn1_get_time_der (unsigned type, const unsigned char 
*der, int der_len, int *r
   return ASN1_SUCCESS;
 }
 
-static int
-_asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
+/**
+ * asn1_get_objectid_der:
+ * @der: DER data to decode containing the OBJECT IDENTIFIER
+ * @der_len: Length of DER data to decode.
+ * @ret_len: Output variable containing the length of the DER data.
+ * @str: Pre-allocated output buffer to put the textual object id in.
+ * @str_size: Length of pre-allocated output buffer.
+ *
+ * Converts a DER encoded object identifier to its textual form.
+ *
+ * Returns: %ASN1_SUCCESS on success, or an error.
+ **/
+int
+asn1_get_object_id_der (const unsigned char *der, int der_len, int *ret_len,
                        char *str, int str_size)
 {
   int len_len, len, k;
@@ -419,7 +431,7 @@ _asn1_get_objectid_der (const unsigned char *der, int 
der_len, int *ret_len,
  *
  * Extract a BIT SEQUENCE from DER data.
  *
- * Returns: Return %ASN1_SUCCESS on success, or an error.
+ * Returns: %ASN1_SUCCESS on success, or an error.
  **/
 int
 asn1_get_bit_der (const unsigned char *der, int der_len,
@@ -1224,7 +1236,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, 
int *max_ider_len,
              break;
            case ASN1_ETYPE_OBJECT_ID:
              result =
-               _asn1_get_objectid_der (der + counter, ider_len, &len2,
+               asn1_get_object_id_der (der + counter, ider_len, &len2,
                                        temp, sizeof (temp));
              if (result != ASN1_SUCCESS)
                {
@@ -2110,7 +2122,7 @@ asn1_decode_simple_der (unsigned int etype, const 
unsigned char *der,
   if (der == NULL || der_len == 0)
     return ASN1_VALUE_NOT_VALID;
 
-  if (ETYPE_OK (etype) == 0)
+  if (ETYPE_OK (etype) == 0 || ETYPE_IS_STRING(etype) == 0)
     return ASN1_VALUE_NOT_VALID;
 
   /* doesn't handle constructed classes */
@@ -2228,12 +2240,7 @@ asn1_decode_simple_ber (unsigned int etype, const 
unsigned char *der,
   if (der_len <= 0)
     return ASN1_DER_ERROR;
 
-  if (class == ASN1_CLASS_STRUCTURED && (etype == ASN1_ETYPE_GENERALSTRING ||
-      etype == ASN1_ETYPE_NUMERIC_STRING || etype == ASN1_ETYPE_IA5_STRING ||
-      etype == ASN1_ETYPE_TELETEX_STRING || etype == 
ASN1_ETYPE_PRINTABLE_STRING ||
-      etype == ASN1_ETYPE_UNIVERSAL_STRING || etype == ASN1_ETYPE_BMP_STRING ||
-      etype == ASN1_ETYPE_UTF8_STRING || etype == ASN1_ETYPE_VISIBLE_STRING ||
-      etype == ASN1_ETYPE_OCTET_STRING))
+  if (class == ASN1_CLASS_STRUCTURED && ETYPE_IS_STRING(etype))
     {
 
       len_len = 1;
diff --git a/lib/int.h b/lib/int.h
index 8cc79cc..ee870c7 100644
--- a/lib/int.h
+++ b/lib/int.h
@@ -102,6 +102,13 @@ typedef struct tag_and_class_st
                           etype <= _asn1_tags_size && \
                           _asn1_tags[etype].desc != NULL)?1:0)
 
+#define ETYPE_IS_STRING(etype) ((etype == ASN1_ETYPE_GENERALSTRING || \
+       etype == ASN1_ETYPE_NUMERIC_STRING || etype == ASN1_ETYPE_IA5_STRING || 
\
+       etype == ASN1_ETYPE_TELETEX_STRING || etype == 
ASN1_ETYPE_PRINTABLE_STRING || \
+       etype == ASN1_ETYPE_UNIVERSAL_STRING || etype == ASN1_ETYPE_BMP_STRING 
|| \
+       etype == ASN1_ETYPE_UTF8_STRING || etype == ASN1_ETYPE_VISIBLE_STRING 
|| \
+       etype == ASN1_ETYPE_OCTET_STRING)?1:0)
+
 extern unsigned int _asn1_tags_size;
 extern const tag_and_class_st _asn1_tags[];
 
diff --git a/lib/libtasn1.h b/lib/libtasn1.h
index 53cec5e..4d3772b 100644
--- a/lib/libtasn1.h
+++ b/lib/libtasn1.h
@@ -374,6 +374,11 @@ extern "C"
                      int *ret_len, unsigned char *str,
                      int str_size, int *bit_len);
 
+  extern ASN1_API int
+    asn1_get_object_id_der (const unsigned char *der,
+                            int der_len, int *ret_len,
+                           char *str, int str_size);
+
 /* Compatibility types */
 
   typedef int asn1_retCode;    /* type returned by libtasn1 functions */


hooks/post-receive
-- 
GNU libtasn1



reply via email to

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