krb5_error_code encode_krb5_authenticator(const krb5_authenticator *rep, krb5_data **code) { krb5_setup(); /* authorization-data[8] AuthorizationData OPTIONAL */ if(rep->authorization_data != NULL && rep->authorization_data[0] != NULL){ retval = asn1_encode_authorization_data(buf, (const krb5_authdata **) rep->authorization_data, &length); if(retval){ asn1buf_destroy(&buf); return retval; } sum += length; retval = asn1_make_etag(buf,CONTEXT_SPECIFIC,8,length,&length); if(retval){ asn1buf_destroy(&buf); return retval; } sum += length; } /* seq-number[7] INTEGER OPTIONAL */ if(rep->seq_number != 0) krb5_addfield(rep->seq_number,7,asn1_encode_unsigned_integer); /* subkey[6] EncryptionKey OPTIONAL */ if(rep->subkey != NULL) krb5_addfield(rep->subkey,6,asn1_encode_encryption_key); /* ctime[5] KerberosTime */ krb5_addfield(rep->ctime,5,asn1_encode_kerberos_time); /* cusec[4] INTEGER */ krb5_addfield(rep->cusec,4,asn1_encode_integer); /* cksum[3] Checksum OPTIONAL */ if(rep->checksum != NULL) krb5_addfield(rep->checksum,3,asn1_encode_checksum); /* cname[2] PrincipalName */ krb5_addfield(rep->client,2,asn1_encode_principal_name); /* crealm[1] Realm */ krb5_addfield(rep->client,1,asn1_encode_realm); /* authenticator-vno[0] INTEGER */ krb5_addfield(KVNO,0,asn1_encode_integer); /* Authenticator ::= [APPLICATION 2] SEQUENCE */ krb5_makeseq(); krb5_apptag(2); krb5_cleanup(); }
krb5_error_code k5_asn1_full_encode(const void *rep, const struct atype_info *a, krb5_data **code_out) { size_t len; asn1_error_code ret; asn1buf *buf = NULL; krb5_data *d; *code_out = NULL; if (rep == NULL) return ASN1_MISSING_FIELD; ret = asn1buf_create(&buf); if (ret) return ret; ret = encode_atype_and_tag(buf, rep, a, &len); if (ret) goto cleanup; ret = asn12krb5_buf(buf, &d); if (ret) goto cleanup; *code_out = d; cleanup: asn1buf_destroy(&buf); return ret; }
krb5_error_code krb5int_asn1_do_full_encode(const void *rep, krb5_data **code, const struct atype_info *a) { unsigned int length; asn1_error_code retval; asn1buf *buf = NULL; krb5_data *d; *code = NULL; if (rep == NULL) return ASN1_MISSING_FIELD; retval = asn1buf_create(&buf); if (retval) return retval; retval = krb5int_asn1_encode_a_thing(buf, rep, a, &length); if (retval) goto cleanup; retval = asn12krb5_buf(buf, &d); if (retval) goto cleanup; *code = d; cleanup: asn1buf_destroy(&buf); return retval; }
/* * encode_krb5_safe_with_body * * Like encode_krb5_safe(), except takes a saved KRB-SAFE-BODY * encoding to avoid problems with re-encoding. */ krb5_error_code encode_krb5_safe_with_body( const krb5_safe *rep, const krb5_data *body, krb5_data **code) { krb5_setup(); if (body == NULL) { asn1buf_destroy(&buf); return ASN1_MISSING_FIELD; } /* cksum[3] Checksum */ krb5_addfield(rep->checksum,3,asn1_encode_checksum); /* safe-body[2] KRB-SAFE-BODY */ krb5_addfield(body,2,asn1_encode_krb_saved_safe_body); /* msg-type[1] INTEGER */ krb5_addfield(ASN1_KRB_SAFE,1,asn1_encode_integer); /* pvno[0] INTEGER */ krb5_addfield(KVNO,0,asn1_encode_integer); /* KRB-SAFE ::= [APPLICATION 20] SEQUENCE */ krb5_makeseq(); krb5_apptag(20); krb5_cleanup(); }