1 /* 2 * The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu) 3 * 4 * This code was written by Angelos D. Keromytis in Philadelphia, PA, USA, 5 * in April-May 1998 6 * 7 * Copyright (C) 1998, 1999 by Angelos D. Keromytis. 8 * 9 * Permission to use, copy, and modify this software without fee 10 * is hereby granted, provided that this entire notice is included in 11 * all copies of any software which is or includes a copy or 12 * modification of this software. 13 * 14 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR 15 * IMPLIED WARRANTY. IN PARTICULAR, THE AUTHORS MAKES NO 16 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE 17 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR 18 * PURPOSE. 19 */ 20 21 #ifndef __ASSERTION_H__ 22 #define __ASSERTION_H__ 23 24 /* 25 * These can be changed to reflect more assertions/session or more 26 * sessions respectively 27 */ 28 #define HASHTABLESIZE 37 29 #define SESSIONTABLESIZE 37 30 31 struct keynote_session 32 { 33 int ks_id; 34 int ks_assertioncounter; 35 int ks_values_num; 36 struct environment *ks_env_table[HASHTABLESIZE]; 37 struct environment *ks_env_regex; 38 struct keylist *ks_action_authorizers; 39 struct assertion *ks_assertion_table[HASHTABLESIZE]; 40 char **ks_values; 41 char *ks_authorizers_cache; 42 char *ks_values_cache; 43 struct keynote_session *ks_prev; 44 struct keynote_session *ks_next; 45 }; 46 47 struct keylist 48 { 49 int key_alg; 50 void *key_key; 51 char *key_stringkey; 52 struct keylist *key_next; 53 }; 54 55 struct assertion 56 { 57 void *as_authorizer; 58 char *as_buf; 59 char *as_signature; 60 char *as_authorizer_string_s; 61 char *as_authorizer_string_e; 62 char *as_keypred_s; 63 char *as_keypred_e; 64 char *as_conditions_s; 65 char *as_conditions_e; 66 char *as_signature_string_s; 67 char *as_signature_string_e; 68 char *as_comment_s; 69 char *as_comment_e; 70 char *as_startofsignature; 71 char *as_allbutsignature; 72 int as_id; 73 int as_signeralgorithm; 74 int as_result; 75 int as_error; 76 u_char as_flags; 77 u_char as_internalflags; 78 char as_kresult; 79 char as_sigresult; 80 struct keylist *as_keylist; 81 struct environment *as_env; 82 struct assertion *as_next; 83 }; 84 85 /* Internal flags */ 86 #define ASSERT_IFLAG_WEIRDLICS 0x0001 /* Needs Licensees re-processing */ 87 #define ASSERT_IFLAG_WEIRDAUTH 0x0002 /* Needs Authorizer re-processing */ 88 #define ASSERT_IFLAG_WEIRDSIG 0x0004 /* Needs Signature re-processing */ 89 #define ASSERT_IFLAG_NEEDPROC 0x0008 /* Needs "key field" processing */ 90 #define ASSERT_IFLAG_PROCESSED 0x0010 /* Handled repositioning already */ 91 92 #define KRESULT_UNTOUCHED 0 93 #define KRESULT_IN_PROGRESS 1 /* For cycle detection */ 94 #define KRESULT_DONE 2 95 96 #define KEYWORD_VERSION 1 97 #define KEYWORD_LOCALINIT 2 98 #define KEYWORD_AUTHORIZER 3 99 #define KEYWORD_LICENSEES 4 100 #define KEYWORD_CONDITIONS 5 101 #define KEYWORD_SIGNATURE 6 102 #define KEYWORD_COMMENT 7 103 104 #define KEYNOTE_FLAG_EXPORTALL 0x1 105 106 /* List types for cleanup */ 107 #define LEXTYPE_CHAR 0x1 108 109 /* Length of random initializer */ 110 #define KEYNOTE_RAND_INIT_LEN 1024 111 112 /* Variables */ 113 extern char **keynote_values; 114 extern char *keynote_privkey; 115 116 extern struct assertion *keynote_current_assertion; 117 118 extern struct environment *keynote_init_list; 119 extern struct environment *keynote_temp_list; 120 121 extern struct keylist *keynote_keypred_keylist; 122 123 extern struct keynote_session *keynote_sessions[SESSIONTABLESIZE]; 124 extern struct keynote_session *keynote_current_session; 125 126 extern int keynote_exceptionflag; 127 extern int keynote_used_variable; 128 extern int keynote_returnvalue; 129 extern int keynote_justrecord; 130 extern int keynote_donteval; 131 extern int keynote_errno; 132 133 /* Extern definitions */ 134 extern int knlineno; 135 136 /* Function prototypes */ 137 extern int keynote_env_add(char *, char *, struct environment **, u_int, int); 138 extern char *keynote_env_lookup(char *, struct environment **, u_int); 139 extern int keynote_env_delete(char *, struct environment **, u_int); 140 extern struct keylist *keynote_keylist_find(struct keylist *, char *); 141 extern struct environment *keynote_get_envlist(char *, char *, int); 142 extern struct assertion *keynote_parse_assertion(char *, int, int); 143 extern int keynote_evaluate_authorizer(struct assertion *, int); 144 extern struct assertion *keynote_find_assertion(void *, int, int); 145 extern void keynote_env_cleanup(struct environment **, u_int); 146 extern int keynote_get_key_algorithm(char *, int *, int *); 147 extern int keynote_sigverify_assertion(struct assertion *); 148 extern int keynote_evaluate_assertion(struct assertion *); 149 extern int keynote_parse_keypred(struct assertion *, int); 150 extern int keynote_keylist_add(struct keylist **, char *); 151 extern int keynote_add_htable(struct assertion *, int); 152 extern void keynote_free_assertion(struct assertion *); 153 extern int keynote_in_action_authorizers(void *, int); 154 extern struct keynote_session *keynote_find_session(int); 155 extern void keynote_keylist_free(struct keylist *); 156 extern void keynote_free_env(struct environment *); 157 extern int keynote_in_authorizers(void *, int); 158 extern int keynote_sremove_assertion(int, int); 159 extern u_int keynote_stringhash(char *, u_int); 160 extern char *keynote_get_private_key(char *); 161 extern void keynote_free_key(void *, int); 162 extern int keynote_evaluate_query(void); 163 extern int keynote_lex_add(void *, int); 164 extern void keynote_lex_remove(void *); 165 extern void keynote_cleanup_kth(void); 166 extern int keynote_retindex(char *); 167 extern void knerror(char *); 168 extern int knparse(); 169 extern int knlex(); 170 #endif /* __ASSERTION_H__ */ 171