asn1_k_encode.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* Copyright 1994 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
#include "asn1_k_encode.h"
#include "asn1_make.h"
#include "asn1_encode.h"
#include <assert.h>
/**** asn1 macros ****/
#if 0
int *retlen)
{
asn1_setup();
...
/* for OPTIONAL fields */
/* for string fields (these encoders take an additional argument,
the length of the string) */
/* if you really have to do things yourself... */
&length);
...
asn1_makeseq();
asn1_cleanup();
}
#endif
/* setup() -- create and initialize bookkeeping variables
retval: stores error codes returned from subroutines
length: length of the most-recently produced encoding
sum: cumulative length of the entire encoding */
#define asn1_setup()\
/* asn1_addfield -- add a field, or component, to the encoding */
if(retval){\
asn1buf_destroy(&buf);\
return retval; }\
if(retval){\
asn1buf_destroy(&buf);\
return retval; }\
/* asn1_addlenfield -- add a field whose length must be separately specified */
if(retval){\
asn1buf_destroy(&buf);\
return retval; }\
if(retval){\
asn1buf_destroy(&buf);\
return retval; }\
/* form a sequence (by adding a sequence header to the current encoding) */
#define asn1_makeseq()\
if(retval){\
asn1buf_destroy(&buf);\
return retval; }\
/* add an APPLICATION class tag to the current encoding */
#define asn1_apptag(num)\
if(retval){\
asn1buf_destroy(&buf);\
return retval; }\
/* produce the final output and clean up the workspace */
#define asn1_cleanup()\
return 0
{
}
{
return ASN1_MISSING_FIELD;
retlen);
}
asn1_error_code asn1_encode_principal_name(asn1buf *buf, const krb5_principal val, unsigned int *retlen)
{
asn1_setup();
int n;
return ASN1_MISSING_FIELD;
&length);
}
asn1_makeseq();
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_kerberos_time(asn1buf *buf, const krb5_timestamp val, unsigned int *retlen)
{
}
asn1_error_code asn1_encode_host_address(asn1buf *buf, const krb5_address *val, unsigned int *retlen)
{
asn1_setup();
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_host_addresses(asn1buf *buf, const krb5_address **val, unsigned int *retlen)
{
asn1_setup();
int i;
for(i--; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_encrypted_data(asn1buf *buf, const krb5_enc_data *val, unsigned int *retlen)
{
asn1_setup();
return ASN1_MISSING_FIELD;
/* krb5_kvno should be int */
asn1_makeseq();
asn1_cleanup();
}
{
asn1_setup();
int i;
for(i=0; i<4; i++){
valcopy >>= 8;
}
sum = 5;
&length);
return 0;
}
{
}
{
}
{
}
asn1_error_code asn1_encode_authorization_data(asn1buf *buf, const krb5_authdata **val, unsigned int *retlen)
{
asn1_setup();
int i;
for(i--; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_krb5_authdata_elt(asn1buf *buf, const krb5_authdata *val, unsigned int *retlen)
{
asn1_setup();
return ASN1_MISSING_FIELD;
/* ad-data[1] OCTET STRING */
/* ad-type[0] INTEGER */
/* SEQUENCE */
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_kdc_rep(int msg_type, asn1buf *buf, const krb5_kdc_rep *val, unsigned int *retlen)
{
asn1_setup();
return KRB5_BADMSGTYPE;
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_enc_kdc_rep_part(asn1buf *buf, const krb5_enc_kdc_rep_part *val, unsigned int *retlen)
{
asn1_setup();
/* caddr[11] HostAddresses OPTIONAL */
/* sname[10] PrincipalName */
/* srealm[9] Realm */
/* renew-till[8] KerberosTime OPTIONAL */
/* endtime[7] KerberosTime */
/* starttime[6] KerberosTime OPTIONAL */
/* authtime[5] KerberosTime */
/* flags[4] TicketFlags */
/* key-expiration[3] KerberosTime OPTIONAL */
/* nonce[2] INTEGER */
/* last-req[1] LastReq */
/* key[0] EncryptionKey */
/* EncKDCRepPart ::= SEQUENCE */
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_sequence_of_checksum(asn1buf *buf, const krb5_checksum ** val, unsigned int *retlen)
{
asn1_setup();
int i;
for (i--; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_kdc_req_body(asn1buf *buf, const krb5_kdc_req *rep, unsigned int *retlen)
{
asn1_setup();
/* additional-tickets[11] SEQUENCE OF Ticket OPTIONAL */
/* enc-authorization-data[10] EncryptedData OPTIONAL, */
/* -- Encrypted AuthorizationData encoding */
/* addresses[9] HostAddresses OPTIONAL, */
/* etype[8] SEQUENCE OF INTEGER, -- EncryptionType, */
/* -- in preference order */
/* nonce[7] INTEGER, */
/* rtime[6] KerberosTime OPTIONAL, */
/* till[5] KerberosTime, */
/* from[4] KerberosTime OPTIONAL, */
/* sname[3] PrincipalName OPTIONAL, */
/* realm[2] Realm, -- Server's realm */
/* -- Also client's in AS-REQ */
} else return ASN1_MISSING_FIELD;
}else return ASN1_MISSING_FIELD;
/* cname[1] PrincipalName OPTIONAL, */
/* -- Used only in AS-REQ */
/* kdc-options[0] KDCOptions, */
/* KDC-REQ-BODY ::= SEQUENCE */
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_encryption_key(asn1buf *buf, const krb5_keyblock *val, unsigned int *retlen)
{
asn1_setup();
return ASN1_MISSING_FIELD;
asn1_makeseq();
asn1_cleanup();
}
{
asn1_setup();
return ASN1_MISSING_FIELD;
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_transited_encoding(asn1buf *buf, const krb5_transited *val, unsigned int *retlen)
{
asn1_setup();
return ASN1_MISSING_FIELD;
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_last_req(asn1buf *buf, const krb5_last_req_entry **val, unsigned int *retlen)
{
asn1_setup();
int i;
for(i--; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_last_req_entry(asn1buf *buf, const krb5_last_req_entry *val, unsigned int *retlen)
{
asn1_setup();
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_sequence_of_pa_data(asn1buf *buf, const krb5_pa_data **val, unsigned int *retlen)
{
asn1_setup();
int i;
for(i--; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
{
asn1_setup();
return ASN1_MISSING_FIELD;
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_sequence_of_ticket(asn1buf *buf, const krb5_ticket **val, unsigned int *retlen)
{
asn1_setup();
int i;
for(i--; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
{
asn1_setup();
asn1_makeseq();
asn1_apptag(1);
asn1_cleanup();
}
asn1_error_code asn1_encode_sequence_of_enctype(asn1buf *buf, const int len, const krb5_enctype *val, unsigned int *retlen)
{
asn1_setup();
int i;
for(i=len-1; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_kdc_req(int msg_type, asn1buf *buf, const krb5_kdc_req *val, unsigned int *retlen)
{
asn1_setup();
return KRB5_BADMSGTYPE;
asn1_makeseq();
asn1_cleanup();
}
{
asn1_setup();
if(val->seq_number)
}
return ASN1_MISSING_FIELD;
;
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_sequence_of_krb_cred_info(asn1buf *buf, const krb5_cred_info **val, unsigned int *retlen)
{
asn1_setup();
int i;
for(i--; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_krb_cred_info(asn1buf *buf, const krb5_cred_info *val, unsigned int *retlen)
{
asn1_setup();
}
}
asn1_makeseq();
asn1_cleanup();
}
unsigned int *retlen, int etype_info2)
{
asn1_setup();
return ASN1_MISSING_FIELD;
if (etype_info2)
}
asn1_makeseq();
asn1_cleanup();
}
unsigned int *retlen, int etype_info2)
{
asn1_setup();
int i;
for(i--; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_sequence_of_passwdsequence(asn1buf *buf, const passwd_phrase_element **val, unsigned int *retlen)
{
asn1_setup();
int i;
for(i--; i>=0; i--){
}
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_passwdsequence(asn1buf *buf, const passwd_phrase_element *val, unsigned int *retlen)
{
asn1_setup();
asn1_makeseq();
asn1_cleanup();
}
{
}
asn1_error_code asn1_encode_sam_challenge(asn1buf *buf, const krb5_sam_challenge *val, unsigned int *retlen)
{
asn1_setup();
/* possibly wrong */
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_sam_challenge_2(asn1buf *buf, const krb5_sam_challenge_2 *val, unsigned int *retlen)
{
asn1_setup();
return ASN1_MISSING_FIELD;
if(retval){
return retval;
}
if(retval) {
return retval;
}
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_sam_challenge_2_body(asn1buf *buf, const krb5_sam_challenge_2_body *val, unsigned int *retlen)
{
asn1_setup();
asn1_makeseq();
asn1_cleanup();
}
{
asn1_setup();
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_enc_sam_response_enc(asn1buf *buf, const krb5_enc_sam_response_enc *val, unsigned int *retlen)
{
asn1_setup();
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_enc_sam_response_enc_2(asn1buf *buf, const krb5_enc_sam_response_enc_2 *val, unsigned int *retlen)
{
asn1_setup();
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_sam_response(asn1buf *buf, const krb5_sam_response *val, unsigned int *retlen)
{
asn1_setup();
if (val->sam_patimestamp)
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_sam_response_2(asn1buf *buf, const krb5_sam_response_2 *val, unsigned int *retlen)
{
asn1_setup();
asn1_makeseq();
asn1_cleanup();
}
asn1_error_code asn1_encode_predicted_sam_response(asn1buf *buf, const krb5_predicted_sam_response *val, unsigned int *retlen)
{
asn1_setup();
asn1_makeseq();
asn1_cleanup();
}
/*
* Do some ugliness to insert a raw pre-encoded KRB-SAFE-BODY.
*/
asn1_error_code asn1_encode_krb_saved_safe_body(asn1buf *buf, const krb5_data *body, unsigned int *retlen)
{
if (retval){
return retval;
}
return 0;
}