From 8d702bfe4bccba2b07d599ae2ecdd4225fa8a895 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Tue, 5 Nov 2002 21:54:47 +0000 Subject: [PATCH] * asn1_encode.h (asn1_encode_oid): * asn1_encode.c (asn1_encode_oid): New function. * asn1_decode.h (asn1_decode_oid): * asn1_decode.c (asn1_decode_oid): New function. ticket: 1223 target_version: 1.3 component: krb5-libs git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14971 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/asn.1/ChangeLog | 8 ++++++++ src/lib/krb5/asn.1/asn1_decode.c | 10 ++++++++++ src/lib/krb5/asn.1/asn1_decode.h | 2 ++ src/lib/krb5/asn.1/asn1_encode.c | 17 +++++++++++++++++ src/lib/krb5/asn.1/asn1_encode.h | 11 +++++++++++ 5 files changed, 48 insertions(+) diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index f5734ff7c..51273b404 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,11 @@ +2002-11-05 Tom Yu + + * asn1_encode.h (asn1_encode_oid): + * asn1_encode.c (asn1_encode_oid): New function. + + * asn1_decode.h (asn1_decode_oid): + * asn1_decode.c (asn1_decode_oid): New function. + 2002-10-30 Ken Hornstein * KRB5-asn.py: Fix definition for sam-pk-for-sad element. diff --git a/src/lib/krb5/asn.1/asn1_decode.c b/src/lib/krb5/asn.1/asn1_decode.c index 03a28407e..f8170830b 100644 --- a/src/lib/krb5/asn.1/asn1_decode.c +++ b/src/lib/krb5/asn.1/asn1_decode.c @@ -104,6 +104,16 @@ asn1_error_code asn1_decode_unsigned_integer(asn1buf *buf, long unsigned int *va cleanup(); } +asn1_error_code asn1_decode_oid(asn1buf *buf, unsigned int *retlen, asn1_octet **val) +{ + setup(); + tag(ASN1_OBJECTIDENTIFIER); + retval = asn1buf_remove_octetstring(buf, length, val); + if (retval) return retval; + *retlen = length; + cleanup(); +} + asn1_error_code asn1_decode_octetstring(asn1buf *buf, unsigned int *retlen, asn1_octet **val) { setup(); diff --git a/src/lib/krb5/asn.1/asn1_decode.h b/src/lib/krb5/asn.1/asn1_decode.h index bddad8852..449a58900 100644 --- a/src/lib/krb5/asn.1/asn1_decode.h +++ b/src/lib/krb5/asn.1/asn1_decode.h @@ -65,6 +65,8 @@ asn1_error_code asn1_decode_unsigned_integer asn1_error_code asn1_decode_null (asn1buf *buf); +asn1_error_code asn1_decode_oid + (asn1buf *buf, unsigned int *retlen, asn1_octet **val); asn1_error_code asn1_decode_octetstring (asn1buf *buf, unsigned int *retlen, asn1_octet **val); asn1_error_code asn1_decode_generalstring diff --git a/src/lib/krb5/asn.1/asn1_encode.c b/src/lib/krb5/asn.1/asn1_encode.c index 4c0345536..6bd40dfe7 100644 --- a/src/lib/krb5/asn.1/asn1_encode.c +++ b/src/lib/krb5/asn.1/asn1_encode.c @@ -130,6 +130,23 @@ asn1_error_code asn1_encode_unsigned_integer(asn1buf *buf, unsigned long val, return 0; } +asn1_error_code asn1_encode_oid(asn1buf *buf, unsigned int len, + const asn1_octet *val, + unsigned int *retlen) +{ + asn1_error_code retval; + unsigned int length; + + retval = asn1buf_insert_octetstring(buf, len, val); + if (retval) return retval; + retval = asn1_make_tag(buf, UNIVERSAL, PRIMITIVE, ASN1_OBJECTIDENTIFIER, + len, &length); + if (retval) return retval; + + *retlen = len + length; + return 0; +} + asn1_error_code asn1_encode_octetstring(asn1buf *buf, unsigned int len, const asn1_octet *val, unsigned int *retlen) diff --git a/src/lib/krb5/asn.1/asn1_encode.h b/src/lib/krb5/asn.1/asn1_encode.h index 5c14800a4..2acabc294 100644 --- a/src/lib/krb5/asn.1/asn1_encode.h +++ b/src/lib/krb5/asn.1/asn1_encode.h @@ -82,6 +82,17 @@ asn1_error_code asn1_encode_octetstring Returns ENOMEM to signal an unsuccesful attempt to expand the buffer. */ +asn1_error_code asn1_encode_oid + (asn1buf *buf, + const unsigned int len, const asn1_octet *val, + unsigned int *retlen); +/* requires *buf is allocated + modifies *buf, *retlen + effects Inserts the encoding of val into *buf and returns + the length of the encoding in *retlen. + Returns ENOMEM to signal an unsuccesful attempt + to expand the buffer. */ + asn1_error_code asn1_encode_charstring (asn1buf *buf, const unsigned int len, const char *val, -- 2.26.2