Implement asn1_encode_enumerated
authorSam Hartman <hartmans@mit.edu>
Wed, 23 Oct 2002 20:15:59 +0000 (20:15 +0000)
committerSam Hartman <hartmans@mit.edu>
Wed, 23 Oct 2002 20:15:59 +0000 (20:15 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14937 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/asn.1/ChangeLog
src/lib/krb5/asn.1/asn1_encode.c
src/lib/krb5/asn.1/asn1_encode.h
src/lib/krb5/asn.1/krbasn1.h

index db2fe2508f9ed02dccd5d437272795374b2bcf1c..ed71c85b6cc578c2889bf6c5d89cba066c21dff5 100644 (file)
@@ -1,3 +1,13 @@
+2002-07-02  Sam Hartman  <hartmans@mit.edu>
+
+       * asn1_encode.h: Document asn1_encode_enumerated
+
+       * asn1_encode.c (asn1_encode_enumerated): New function; split out
+       asn1_encode_integer's guts into asn1_encode_integer_interal and
+       add this function to add different universal tag for enumerated 
+
+       * krbasn1.h (ASN1_ENUMERATED): enumerated is universal 10
+
 2002-10-07  Tom Yu  <tlyu@mit.edu>
 
        * asn1_get.c (asn1_get_tag_indef): Stomp on asn1class,
index 9bc9f573242be75eaf97b7556ade0737dc40d271..4c034553672dd530225ea3498d41c1da4603a4d4 100644 (file)
 #include "asn1_encode.h"
 #include "asn1_make.h"
 
-asn1_error_code asn1_encode_integer(asn1buf *buf, long val,
-                                   unsigned int *retlen)
+static asn1_error_code asn1_encode_integer_internal(asn1buf *buf,  long val,
+                                                   unsigned int *retlen)
 {
   asn1_error_code retval;
   unsigned int length = 0;
-  unsigned int partlen;
   long valcopy;
   int digit;
   
@@ -57,7 +56,41 @@ asn1_error_code asn1_encode_integer(asn1buf *buf, long val,
     length++;
   }
 
-  retval = asn1_make_tag(buf,UNIVERSAL,PRIMITIVE,ASN1_INTEGER,length, &partlen); 
+
+  *retlen = length;
+  return 0;
+}
+
+asn1_error_code asn1_encode_integer(asn1buf * buf,  long val,
+ unsigned int *retlen)
+{
+  asn1_error_code retval;
+  unsigned int length = 0;
+  unsigned  int partlen;
+  retval = asn1_encode_integer_internal(buf, val, &partlen);
+  if (retval) return retval;
+
+  length = partlen;
+    retval = asn1_make_tag(buf,UNIVERSAL,PRIMITIVE,ASN1_INTEGER,length, &partlen); 
+  if(retval) return retval;
+  length += partlen;
+
+  *retlen = length;
+  return 0;
+}
+
+asn1_error_code
+asn1_encode_enumerated(asn1buf * buf, const long val,
+                      unsigned int *retlen)
+{
+  asn1_error_code retval;
+  unsigned int length = 0;
+  unsigned  int partlen;
+  retval = asn1_encode_integer_internal(buf, val, &partlen);
+  if (retval) return retval;
+
+  length = partlen;
+    retval = asn1_make_tag(buf,UNIVERSAL,PRIMITIVE,ASN1_ENUMERATED,length, &partlen); 
   if(retval) return retval;
   length += partlen;
 
index e5ae4bbb1559ace3ddaf36640b992ccb8686a851..5c14800a4a7d89a46dbf9b28364f5f4622107565 100644 (file)
@@ -58,6 +58,9 @@ asn1_error_code asn1_encode_integer
              Returns ENOMEM to signal an unsuccesful attempt
               to expand the buffer. */
 
+asn1_error_code asn1_encode_enumerated
+(asn1buf *buf, const long val, unsigned int *retlen);
+
 asn1_error_code asn1_encode_unsigned_integer
        (asn1buf *buf, const unsigned long val, 
                   unsigned int *retlen);
index f4e23387a5148868f86899ad9057a78df28467cd..7a45298adac235b7827321b41511905a09472697 100644 (file)
@@ -57,6 +57,7 @@ typedef int asn1_tagnum;
 #define ASN1_OCTETSTRING       4
 #define ASN1_NULL              5
 #define ASN1_OBJECTIDENTIFIER  6
+#define ASN1_ENUMERATED 10
 #define ASN1_SEQUENCE          16
 #define ASN1_SET               17
 #define ASN1_PRINTABLESTRING   19