7 Kerberos Change Password Protocol (I-D) variant for Windows 2000
14 #include "asn1_make.h"
22 #include <sys/socket.h>
25 #include <arpa/nameser.h>
30 #ifdef HAVE_NETINET_IN_H
31 #define KRB5_USE_INET 1
36 typedef krb5_octet asn1_octet;
37 typedef krb5_error_code asn1_error_code;
38 typedef struct code_buffer_rep {
39 char *base, *bound, *next;
41 typedef enum { UNIVERSAL = 0x00, APPLICATION = 0x40,
42 CONTEXT_SPECIFIC = 0x80, PRIVATE = 0xC0 } asn1_class;
45 static const char rcsid[] = "$Id$";
47 asn1_error_code asn1_encode_realm(asn1buf *buf, const krb5_principal val,
49 asn1_error_code asn1_encode_principal_name(asn1buf *buf,
50 const krb5_principal val,
52 asn1_error_code asn1_encode_octetstring(asn1buf *buf, const int len,
53 const asn1_octet *val, int *retlen);
55 /* From src/lib/krb5/asn.1/krb5_encode.c */
57 /* setup() -- create and initialize bookkeeping variables
58 retval: stores error codes returned from subroutines
59 buf: the coding buffer
60 length: length of the most-recently produced encoding
61 sum: cumulative length of the entire encoding */
63 asn1_error_code retval;\
67 if(rep == NULL) return ASN1_MISSING_FIELD;\
69 retval = asn1buf_create(&buf);\
70 if(retval) return retval
73 /* krb5_addfield -- add a field, or component, to the encoding */
74 #define krb5_addfield(value,tag,encoder)\
75 { retval = encoder(buf,value,&length);\
77 asn1buf_destroy(&buf);\
80 retval = asn1_make_etag(buf,CONTEXT_SPECIFIC,tag,length,&length);\
82 asn1buf_destroy(&buf);\
86 /* krb5_addlenfield -- add a field whose length must be separately specified */
87 #define krb5_addlenfield(len,value,tag,encoder)\
88 { retval = encoder(buf,len,value,&length);\
90 asn1buf_destroy(&buf);\
93 retval = asn1_make_etag(buf,CONTEXT_SPECIFIC,tag,length,&length);\
95 asn1buf_destroy(&buf);\
99 /* form a sequence (by adding a sequence header to the current encoding) */
100 #define krb5_makeseq()\
101 retval = asn1_make_sequence(buf,sum,&length);\
103 asn1buf_destroy(&buf);\
107 /* produce the final output and clean up the workspace */
108 #define krb5_cleanup()\
109 retval = asn12krb5_buf(buf,code);\
111 asn1buf_destroy(&buf);\
113 retval = asn1buf_destroy(&buf);\
119 krb5_error_code encode_krb5_setpw(const krb5_setpw *rep,
124 if (rep->targprinc != NULL)
125 { /* target principal name is OPTIONAL */
126 krb5_addfield(rep->targprinc,2,asn1_encode_realm);
127 krb5_addfield(rep->targprinc,1,asn1_encode_principal_name);
129 krb5_addlenfield(rep->newpasswd.length, rep->newpasswd.data,
130 0, asn1_encode_octetstring);