From: Theodore Tso Date: Mon, 28 Aug 1995 20:24:30 +0000 (+0000) Subject: krb5_decode.c (decode_krb5_alt_method, decode_krb5_etype_info): New X-Git-Tag: krb5-1.0-beta6~1250 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8a8fd722880a25f7edd37d65d30f15420b0d6da7;p=krb5.git krb5_decode.c (decode_krb5_alt_method, decode_krb5_etype_info): New functions for decoding some new data structures. krb5_encode.c (encode_krb5_alt_method, encode_krb5_etype_info): New functions for encoding some new data structures. asn1_k_decode.c (asn1_decode_etype_info_entry, asn1_decode_etype_info): Added new functions to decode some new data structures. asn1_k_encode.c (asn1_encode_etype_info_entry, asn1_encode_etype_info): Added new functions to encode some new data structures. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6606 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index a558cf428..d48e9fe74 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,20 @@ +Mon Aug 28 12:54:05 1995 + + * krb5_decode.c (decode_krb5_alt_method, + decode_krb5_etype_info): New functions for + decoding some new data structures. + + * krb5_encode.c (encode_krb5_alt_method, encode_krb5_etype_info): + New functions for encoding some new data structures. + + * asn1_k_decode.c (asn1_decode_etype_info_entry, + asn1_decode_etype_info): Added new functions to decode + some new data structures. + + * asn1_k_encode.c (asn1_encode_etype_info_entry, + asn1_encode_etype_info): Added new functions to encode + some new data structures. + Fri Aug 25 21:43:42 1995 Theodore Y. Ts'o * krb5_encode.c (encode_krb5_padata_sequence): New function which diff --git a/src/lib/krb5/asn.1/KRB5-asn.py b/src/lib/krb5/asn.1/KRB5-asn.py index 07e967a22..a8a73e45a 100644 --- a/src/lib/krb5/asn.1/KRB5-asn.py +++ b/src/lib/krb5/asn.1/KRB5-asn.py @@ -324,6 +324,13 @@ METHOD-DATA ::= SEQUENCE { method-data[1] OCTET STRING OPTIONAL } +ETYPE-INFO-ENTRY ::= SEQUENCE { + etype[0] INTEGER, + salt[1] OCTET STRING OPTIONAL +} + +ETYPE-INFO ::= SEQUENCE OF ETYPE-INFO-ENTRY + -- These ASN.1 definitions are NOT part of the official Kerberos protocol... -- New ASN.1 definitions for the kadmin protocol. diff --git a/src/lib/krb5/asn.1/asn1_k_decode.c b/src/lib/krb5/asn.1/asn1_k_decode.c index da748c4e8..187f1917b 100644 --- a/src/lib/krb5/asn.1/asn1_k_decode.c +++ b/src/lib/krb5/asn.1/asn1_k_decode.c @@ -657,6 +657,32 @@ asn1_error_code asn1_decode_sequence_of_enctype(buf, num, val) cleanup(); } +asn1_error_code asn1_decode_etype_info_entry(buf, val) + asn1buf * buf; + krb5_etype_info_entry * val; +{ + setup(); + { begin_structure(); + get_field(val->etype,0,asn1_decode_ui_4); + if (tagnum == 1) { + get_lenfield(val->length,val->salt,1,asn1_decode_octetstring); + } else { + val->length = 0; + val->salt = 0; + } + end_structure(); + val->magic = KV5M_ETYPE_INFO_ENTRY; + } + cleanup(); +} + +asn1_error_code asn1_decode_etype_info(buf, val) + asn1buf * buf; + krb5_etype_info_entry *** val; +{ + decode_array_body(krb5_etype_info_entry,asn1_decode_etype_info_entry); +} + asn1_error_code asn1_decode_passwdsequence(buf, val) asn1buf * buf; passwd_phrase_element * val; diff --git a/src/lib/krb5/asn.1/asn1_k_decode.h b/src/lib/krb5/asn.1/asn1_k_decode.h index f58f1845f..a411d1b2e 100644 --- a/src/lib/krb5/asn.1/asn1_k_decode.h +++ b/src/lib/krb5/asn.1/asn1_k_decode.h @@ -138,6 +138,9 @@ asn1_error_code asn1_decode_pa_data asn1_error_code asn1_decode_passwdsequence PROTOTYPE((asn1buf *buf, passwd_phrase_element *val)); +asn1_error_code asn1_decode_etype_info_entry + PROTOTYPE((asn1buf *buf, krb5_etype_info_entry *val)); + /* arrays */ asn1_error_code asn1_decode_authorization_data PROTOTYPE((asn1buf *buf, krb5_authdata ***val)); @@ -158,5 +161,8 @@ asn1_error_code asn1_decode_sequence_of_enctype asn1_error_code asn1_decode_sequence_of_passwdsequence PROTOTYPE((asn1buf *buf, passwd_phrase_element ***val)); +asn1_error_code asn1_decode_etype_info + PROTOTYPE((asn1buf *buf, krb5_etype_info_entry ***val)); + #endif diff --git a/src/lib/krb5/asn.1/asn1_k_encode.c b/src/lib/krb5/asn.1/asn1_k_encode.c index 98c4fc4c9..2bdcf7c7e 100644 --- a/src/lib/krb5/asn.1/asn1_k_encode.c +++ b/src/lib/krb5/asn.1/asn1_k_encode.c @@ -767,6 +767,45 @@ asn1_error_code asn1_encode_krb_cred_info(buf, val, retlen) asn1_cleanup(); } +asn1_error_code asn1_encode_etype_info_entry(buf, val, retlen) + asn1buf * buf; + const krb5_etype_info_entry * val; + int * retlen; +{ + asn1_setup(); + + if(val == NULL || (val->length != 0 && val->salt == NULL)) + return ASN1_MISSING_FIELD; + + if (val->length) + asn1_addlenfield(val->length,val->salt,1, + asn1_encode_octetstring); + asn1_addfield(val->etype,0,asn1_encode_integer); + asn1_makeseq(); + + asn1_cleanup(); +} + +asn1_error_code asn1_encode_etype_info(buf, val, retlen) + asn1buf * buf; + const krb5_etype_info_entry ** val; + int * retlen; +{ + asn1_setup(); + int i; + + if (val == NULL) return ASN1_MISSING_FIELD; + + for(i=0; val[i] != NULL; i++); /* get to the end of the array */ + for(i--; i>=0; i--){ + retval = asn1_encode_etype_info_entry(buf,val[i],&length); + if(retval) return retval; + sum += length; + } + asn1_makeseq(); + asn1_cleanup(); +} + asn1_error_code asn1_encode_sequence_of_passwdsequence(buf, val, retlen) asn1buf * buf; const passwd_phrase_element ** val; @@ -798,3 +837,4 @@ asn1_error_code asn1_encode_passwdsequence(buf, val, retlen) asn1_makeseq(); asn1_cleanup(); } + diff --git a/src/lib/krb5/asn.1/asn1_k_encode.h b/src/lib/krb5/asn.1/asn1_k_encode.h index a4adb5fc4..6add4dad4 100644 --- a/src/lib/krb5/asn.1/asn1_k_encode.h +++ b/src/lib/krb5/asn.1/asn1_k_encode.h @@ -206,6 +206,18 @@ asn1_error_code asn1_encode_last_req_entry asn1_error_code asn1_encode_pa_data PROTOTYPE((asn1buf *buf, const krb5_pa_data *val, int *retlen)); +asn1_error_code asn1_encode_alt_method + PROTOTYPE((asn1buf *buf, const krb5_alt_method *val, + int *retlen)); + +asn1_error_code asn1_encode_etype_info_entry + PROTOTYPE((asn1buf *buf, const krb5_etype_info_entry *val, + int *retlen)); + +asn1_error_code asn1_encode_etype_info + PROTOTYPE((asn1buf *buf, const krb5_etype_info_entry **val, + int *retlen)); + asn1_error_code asn1_encode_passwdsequence PROTOTYPE((asn1buf *buf, const passwd_phrase_element *val, int *retlen)); diff --git a/src/lib/krb5/asn.1/krb5_decode.c b/src/lib/krb5/asn.1/krb5_decode.c index 7fdd8d777..1a5a988bb 100644 --- a/src/lib/krb5/asn.1/krb5_decode.c +++ b/src/lib/krb5/asn.1/krb5_decode.c @@ -615,3 +615,37 @@ krb5_error_code decode_krb5_padata_sequence(code, rep) cleanup(); } +krb5_error_code decode_krb5_alt_method(code, rep) + const krb5_data * code; + krb5_alt_method ** rep; +{ + setup(); + alloc_field(*rep,krb5_alt_method); + { begin_structure(); + get_field((*rep)->method,0,asn1_decode_int); + if (tagnum == 1) { + get_lenfield((*rep)->length,(*rep)->data,1,asn1_decode_octetstring); + } else { + (*rep)->length = 0; + (*rep)->data = 0; + } + (*rep)->magic = KV5M_ALT_METHOD; + end_structure(); + } + cleanup(); +} + +krb5_error_code decode_krb5_etype_info(code, rep) + const krb5_data * code; + krb5_etype_info_entry ***rep; +{ + setup_buf_only(); + *rep = 0; + retval = asn1_decode_etype_info(&buf,rep); + if(retval) return (krb5_error_code)retval; + cleanup(); +} + + + + diff --git a/src/lib/krb5/asn.1/krb5_encode.c b/src/lib/krb5/asn.1/krb5_encode.c index 8928f56b8..885eb03d0 100644 --- a/src/lib/krb5/asn.1/krb5_encode.c +++ b/src/lib/krb5/asn.1/krb5_encode.c @@ -697,6 +697,35 @@ krb5_error_code encode_krb5_authdata(rep, code) krb5_cleanup(); } +krb5_error_code encode_krb5_alt_method(rep, code) + const krb5_alt_method * rep; + krb5_data ** code; +{ + krb5_setup(); + + /* method-data[1] OctetString OPTIONAL */ + if(rep->data != NULL && rep->length > 0) + krb5_addlenfield(rep->length,rep->data,1,asn1_encode_octetstring); + + /* method-type[0] Integer */ + krb5_addfield(rep->method,0,asn1_encode_integer); + + krb5_makeseq(); + + krb5_cleanup(); +} + +krb5_error_code encode_krb5_etype_info( rep, code) + const krb5_etype_info_entry ** rep; + krb5_data ** code; +{ + krb5_setup(); + retval = asn1_encode_etype_info(buf,rep,&length); + if(retval) return retval; + sum += length; + krb5_cleanup(); +} + /* Sandia Additions */ krb5_error_code encode_krb5_pwd_sequence( rep, code) const passwd_phrase_element * rep;