+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,
#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;
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;
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);