From 6edc916a5a8d44e1d7708f5018828e0d2020690b Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Fri, 2 Jun 1995 09:49:11 +0000 Subject: [PATCH] Adding access control --- asn/Makefile | 4 +- asn/proto.c | 96 ++++++++++++++++++++++++++++++++++- asn/prt-acc.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ asn/prt-rsc.c | 14 ++++-- 4 files changed, 263 insertions(+), 7 deletions(-) create mode 100644 asn/prt-acc.c diff --git a/asn/Makefile b/asn/Makefile index 02329af..45b8768 100644 --- a/asn/Makefile +++ b/asn/Makefile @@ -1,7 +1,7 @@ # Copyright (C) 1994, Index Data I/S # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile,v 1.13 1995-05-30 10:25:45 quinn Exp $ +# $Id: Makefile,v 1.14 1995-06-02 09:49:11 quinn Exp $ SHELL=/bin/sh INCLUDE=-I../include -I. @@ -11,7 +11,7 @@ LIBINCLUDE=-L$(LIBDIR) DEFS=$(INCLUDE) LIB=$(LIBDIR)/libasn.a LIBS=-lodr -lasn -PO = proto.o diagbib1.o zget.o +PO = proto.o diagbib1.o zget.o prt-rsc.o prt-acc.o CPP=$(CC) -E all: $(LIB) diff --git a/asn/proto.c b/asn/proto.c index 3f17ff0..26ca7bf 100644 --- a/asn/proto.c +++ b/asn/proto.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: proto.c,v $ - * Revision 1.25 1995-05-25 11:00:08 quinn + * Revision 1.26 1995-06-02 09:49:13 quinn + * Adding access control + * + * Revision 1.25 1995/05/25 11:00:08 quinn * *** empty log message *** * * Revision 1.24 1995/05/22 13:58:18 quinn @@ -110,6 +113,97 @@ int z_UserInformationField(ODR o, Z_UserInformationField **p, int opt) 11, opt); } +int z_InfoCategory(ODR o, Z_InfoCategory **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_oid, &(*p)->categoryTypeId, ODR_CONTEXT, 1, 1) && + odr_implicit(o, odr_integer, &(*p)->categoryValue, ODR_CONTEXT, 2, 0) && + odr_sequence_end(o); +} + +int z_OtherInformationUnit(ODR o, Z_OtherInformationUnit **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_OtherInfo_characterInfo, + odr_visiblestring}, + {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_OtherInfo_binaryInfo, + odr_octetstring}, + {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_OtherInfo_externallyDefinedInfo, + odr_external}, + {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_OtherInfo_oid, odr_oid}, + {-1, -1, -1, -1, 0} + }; + + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, z_InfoCategory, &(*p)->category, ODR_CONTEXT, 1, 1) && + odr_choice(o, arm, &(*p)->which, &(*p)->information) && + odr_sequence_end(o); +} + +int z_OtherInformation(ODR o, Z_OtherInformation **p, int opt) +{ + if (o->direction == ODR_ENCODE) + *p = odr_malloc(o, sizeof(**p)); + + odr_implicit_settag(o, ODR_CONTEXT, 201); + if (odr_sequence_of(o, z_OtherInformationUnit, &(*p)->list, + &(*p)->num_elements)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +int z_StringOrNumeric(ODR o, Z_StringOrNumeric **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_StringOrNumeric_string, + odr_visiblestring}, + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_StringOrNumeric_numeric, + odr_integer}, + {-1, -1, -1, -1, 0} + }; + + if (o->direction == ODR_DECODE) + *p = odr_malloc(o, sizeof(**p)); + if (odr_choice(o, arm, &(*p)->u, &(*p)->which)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +/* + * check tagging!! + */ +int z_Unit(ODR o, Z_Unit **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_visiblestring, &(*p)->unitSystem, ODR_CONTEXT, + 1, 1) && + odr_explicit(o, z_StringOrNumeric, &(*p)->unitType, ODR_CONTEXT, + 2, 1) && + odr_explicit(o, z_StringOrNumeric, &(*p)->unit, ODR_CONTEXT, 3, 1) && + odr_implicit(o, odr_integer, &(*p)->scaleFactor, ODR_CONTEXT, 4, 1) && + odr_sequence_end(o); +} + +int z_IntUnit(ODR o, Z_IntUnit **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 1, 0) && + odr_implicit(o, z_Unit, &(*p)->unitUsed, ODR_CONTEXT, 2, 0) && + odr_sequence_end(o); +} + /* ---------------------- INITIALIZE SERVICE ------------------- */ #if 0 diff --git a/asn/prt-acc.c b/asn/prt-acc.c new file mode 100644 index 0000000..93ca152 --- /dev/null +++ b/asn/prt-acc.c @@ -0,0 +1,156 @@ +/* + * Copyright (c) 1995, Index Data. + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Log: prt-acc.c,v $ + * Revision 1.1 1995-06-02 09:49:15 quinn + * Adding access control + * + * + */ + +#include + +int z_Encryption1(ODR o, Z_Encryption1 **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_octetstring, &(*p)->cryptType, ODR_CONTEXT, 1, 1) && + odr_implicit(o, odr_octetstring, &(*p)->credential, ODR_CONTEXT, 2, + 1) && + odr_implicit(o, odr_octetstring, &(*p)->data, ODR_CONTEXT, 3, 0) && + odr_sequence_end(o); +} + +int z_EnumeratedPrompt1(ODR o, Z_EnumeratedPrompt1 **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_implicit(o, odr_integer, &(*p)->type, ODR_CONTEXT, 1, 0) && + odr_implicit(o, odr_visiblestring, &(*p)->suggestedString, ODR_CONTEXT, + 2, 1) && + odr_sequence_end(o); +} + +int z_PromptId1(ODR o, Z_PromptId1 **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_PromptId1_enumeratedPrompt, + z_EnumeratedPrompt1}, + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_PromptId1_nonEnumeratedPrompt, + odr_visiblestring}, + {-1, -1, -1, -1, 0} + }; + + if (o->direction == ODR_DECODE) + *p = odr_malloc(o, sizeof(**p)); + if (odr_choice(o, arm, &(*p)->u, &(*p)->which)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +int z_PromptInfo1(ODR o, Z_PromptInfo1 **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Challenge1_character, + odr_visiblestring}, + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Challenge1_encrypted, + z_Encryption1}, + {-1, -1, -1, -1, 0} + }; + + if (o->direction == ODR_DECODE) + *p = odr_malloc(o, sizeof(**p)); + if (odr_choice(o, arm, &(*p)->u, &(*p)->which)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +int z_ChallengeUnit1(ODR o, Z_ChallengeUnit1 **p, int opt) +{ + if (!odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_explicit(o, z_PromptId1, &(*p)->promptId, ODR_CONTEXT, 1, 0) && + odr_implicit(o, odr_visiblestring, &(*p)->defaultResponse, ODR_CONTEXT, + 2, 1) && + odr_explicit(o, z_PromptInfo1, &(*p)->promptInfo, ODR_CONTEXT, 3, 1) && + odr_implicit(o, odr_visiblestring, &(*p)->regExpr, ODR_CONTEXT, 4, 1) && + odr_implicit(o, odr_null, &(*p)->responseRequired, ODR_CONTEXT, 5, 1) && + odr_implicit_settag(o, ODR_CONTEXT, 6) && + (odr_sequence_of(o, odr_visiblestring, &(*p)->allowedValues, + &(*p)->num_values) || odr_ok(o)) && + odr_implicit(o, odr_null, &(*p)->shouldSave, ODR_CONTEXT, 7, 1) && + odr_implicit(o, odr_integer, &(*p)->dataType, ODR_CONTEXT, 8, 1) && + odr_sequence_end(o); +} + +int z_Challenge1(ODR o, Z_Challenge1 **p, int opt) +{ + if (o->direction == ODR_ENCODE) + *p = odr_malloc(o, sizeof(**p)); + if (odr_sequence_of(o, z_ChallengeUnit1, &(*p)->list, + &(*p)->num_challenges)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +int z_DiagRec(ODR, Z_DiagRec **, int); + +int z_ResponseUnit1(ODR o, Z_ResponseUnit1 **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Response1_string, odr_visiblestring}, + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Response1_accept, odr_bool}, + {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Response1_acknowledge, odr_null}, + {ODR_EXPLICIT, ODR_CONTEXT, 4, Z_Response1_diagnostic, z_DiagRec}, + {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_Response1_encrypted, z_Encryption1}, + {-1, -1, -1, -1, 0} + }; + + if (odr_sequence_begin(o, p, sizeof(**p))) + return opt && odr_ok(o); + return + odr_explicit(o, z_PromptId1, &(*p)->promptId, ODR_CONTEXT, 1, 0) && + odr_constructed_begin(o, p, ODR_CONTEXT, 2) && + odr_choice(o, arm, &(*p)->u, &(*p)->which) && + odr_constructed_end(o) && + odr_sequence_end(o); +} + +int z_Response1(ODR o, Z_Response1 **p, int opt) +{ + if (o->direction == ODR_ENCODE) + *p = odr_malloc(o, sizeof(**p)); + if (odr_sequence_of(o, z_ResponseUnit1, &(*p)->list, + &(*p)->num_responses)) + return 1; + *p = 0; + return opt && odr_ok(o); +} + +int z_PromptObject1(ODR o, Z_PromptObject1 **p, int opt) +{ + static Odr_arm arm[] = + { + {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_PromptObject1_challenge, z_Challenge1}, + {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_PromptObject1_response, z_Response1}, + {-1, -1, -1, -1, 0} + }; + + if (o->direction == ODR_DECODE) + *p = odr_malloc(o, sizeof(**p)); + if (odr_choice(o, arm, &(*p)->u, &(*p)->which)) + return 1; + *p = 0; + return opt && odr_ok(o); +} diff --git a/asn/prt-rsc.c b/asn/prt-rsc.c index f3acf35..5b7eb17 100644 --- a/asn/prt-rsc.c +++ b/asn/prt-rsc.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: prt-rsc.c,v $ - * Revision 1.2 1995-06-01 14:34:53 quinn + * Revision 1.3 1995-06-02 09:49:15 quinn + * Adding access control + * + * Revision 1.2 1995/06/01 14:34:53 quinn * Work * * Revision 1.1 1995/06/01 11:22:17 quinn @@ -17,7 +20,7 @@ /* -------------------- Resource 1 ------------------------- */ -int z_Estimate1(ODR o, Z_Estimate1, int opt) +int z_Estimate1(ODR o, Z_Estimate1 **p, int opt) { if (!odr_sequence_begin(o, p, sizeof(**p))) return opt && odr_ok(o); @@ -25,7 +28,7 @@ int z_Estimate1(ODR o, Z_Estimate1, int opt) odr_implicit(o, odr_integer, &(*p)->type, ODR_CONTEXT, 1, 0) && odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 2, 0) && odr_implicit(o, odr_integer, &(*p)->currencyCode, ODR_CONTEXT, 3, 1) && - odr_sequence-end(o); + odr_sequence_end(o); } int z_ResourceReport1(ODR o, Z_ResourceReport1 **p, int opt) @@ -42,12 +45,15 @@ int z_ResourceReport1(ODR o, Z_ResourceReport1 **p, int opt) /* -------------------- Resource 2 ------------------------- */ +int z_StringOrNumeric(ODR, Z_StringOrNumeric **, int); +int z_IntUnit(ODR, Z_IntUnit **, int); + int z_Estimate2(ODR o, Z_Estimate2 **p, int opt) { if (!odr_sequence_begin(o, p, sizeof(**p))) return opt && odr_ok(o); return - odr_implicit(o, z_StringorNumeric, &(*p)->type, ODR_CONTEXT, 1, 0) && + odr_explicit(o, z_StringOrNumeric, &(*p)->type, ODR_CONTEXT, 1, 0) && odr_implicit(o, z_IntUnit, &(*p)->value, ODR_CONTEXT, 2, 0) && odr_sequence_end(o); } -- 1.7.10.4