37 #ifndef ARPA2_IDENTITY_H
38 #define ARPA2_IDENTITY_H
73 #define A2ID_MAXLEN ( 64 + 1 + 4*255 )
74 #define A2ID_BUFSIZE ( 64 + 1 + 4*255 + 1 )
76 #define A2SEL_MAXLEN ( 64 + 1 + 4*255 )
77 #define A2SEL_BUFSIZE ( 64 + 1 + 4*255 + 1 )
130 A2ID_OFS_PLUS_SERVICE,
132 A2ID_OFS_PLUS_SVCARGS,
136 A2ID_OFS_PLUS_ALIASES,
166 uint32_t sigflags, expireday;
167 uint16_t ofs [A2ID_OFS_COUNT];
168 char txt [A2SEL_BUFSIZE];
337 return (* tested->txt ==
'\0');
347 return (tested->ofs [A2ID_OFS_ALIASES ] < tested->ofs [A2ID_OFS_PLUS_SIG]) &&
348 (tested->ofs [A2ID_OFS_PLUS_SIG] == tested->ofs [A2ID_OFS_AT_DOMAIN]);
358 return (tested->ofs [A2ID_OFS_PLUS_ALIASES] == tested->ofs [A2ID_OFS_PLUS_SIG]) &&
359 (tested->ofs [A2ID_OFS_SIGPLUS ] < tested->ofs [A2ID_OFS_AT_DOMAIN]);
371 (tested->ofs [A2ID_OFS_SIGVALUE] == tested->ofs [A2ID_OFS_SIGPLUS]);
383 #define a2id_equal(a,b) (0 == strcmp ((a)->txt, (b)->txt))
394 #define a2sel_equal(a,b) (0 == strcmp ((a)->txt, (b)->txt))
410 #define a2id_match(id,sel) (a2sel_subseteq ((id),(sel)))
412 #define a2id_member(id,sel) (a2id_match ((id),(sel)))
436 #define a2sel_subseteq(s,g) a2sel_special ((s), (g))
453 uint16_t newofs,
bool before);
517 #define a2id_iterate_init(in,cursor) a2sel_iterate_init ((const a2sel_t *) (start), (cursor))
521 #define a2id_iterate_next(in,cursor) a2sel_iterate_next ((const a2sel_t *) (start), (cursor))
589 #define a2sel_abstractions_domain(steps) ((steps) >> 7)
590 #define a2sel_abstractions_username(steps) ((steps) & 0x007f)
657 A2ID_SIGDATA_EXPIRATION,
658 A2ID_SIGDATA_REMOTE_DOMAIN,
659 A2ID_SIGDATA_REMOTE_USERID,
660 A2ID_SIGDATA_LOCAL_ALIASES,
664 A2ID_SIGDATA_SESSIONID,
665 A2ID_SIGDATA_SUBJECT,
667 A2ID_SIGDATA_CRYPTLOCAL,
673 #define A2ID_SIGFLAG_EXPIRATION ( 1 << A2ID_SIGDATA_EXPIRATION )
674 #define A2ID_SIGFLAG_REMOTE_DOMAIN ( 1 << A2ID_SIGDATA_REMOTE_DOMAIN )
675 #define A2ID_SIGFLAG_REMOTE_USERID ( 1 << A2ID_SIGDATA_REMOTE_USERID )
676 #define A2ID_SIGFLAG_LOCAL_ALIASES ( 1 << A2ID_SIGDATA_LOCAL_ALIASES )
677 #define A2ID_SIGFLAG_SESSIONID ( 1 << A2ID_SIGDATA_SESSIONID )
678 #define A2ID_SIGFLAG_SUBJECT ( 1 << A2ID_SIGDATA_SUBJECT )
679 #define A2ID_SIGFLAG_TOPIC ( 1 << A2ID_SIGDATA_TOPIC )
680 #define A2ID_SIGFLAG_CRYPTLOCAL ( 1 << A2ID_SIGDATA_CRYPTLOCAL )
720 void *cbdata,
const a2id_t *
id,
721 uint8_t *buf, uint16_t *buflen);
748 void *cbdata_rid,
const a2id_t *lid,
749 uint8_t *buf, uint16_t *buflen);
863 #define a2sel_detail(descr,id) do { ; } while (0)
864 #define a2id_detail(descr,id) a2sel_detail ((descr), (a2sel_t *) (id))
866 #include <arpa2/except.h>
868 int arrows = A2ID_OFS_COUNT;
869 int buflen = sel->ofs [A2ID_OFS_END] + arrows + 1;
875 assertxt (sel->ofs [A2ID_OFS_COUNT - arrows] >= selofs,
876 "A2ID_OFS_xxx are not monotonically rising");
877 if (sel->ofs [A2ID_OFS_COUNT - arrows] == selofs) {
878 buf [bufofs++] =
'|';
882 buf [bufofs++] = sel->txt [selofs++];
#define log_detail(fmt,...)
log_detail(fmt,...)
Definition: except.h:288
#define assertxt(test, fmt,...)
assertxt(test,fmt,...)
Definition: except.h:88
bool a2sel_abstractions(const a2sel_t *specific, const a2sel_t *generic, uint16_t *steps)
Count the number of abstractions to go from one ARPA2 Selector (or Identity) to another ARPA2 Selecto...
bool a2sel_iterate_init(const a2sel_t *start, a2sel_t *cursor)
Iterate an ARPA2 Selector or ARPA2 Identity.
bool a2sel_quickiter_next(a2sel_quickiter *iter)
Iterate to the next Quick Iterator value.
bool a2sel_quickiter_init(a2sel_quickiter *iter)
Lightweight / Lightning-fast ARPA2 Selector and Identity iteration.
bool a2sel_iterate_next(const a2sel_t *start, a2sel_t *cursor)
Progress to the next Iterator value.
bool a2id_sign(a2id_t *tbs, a2id_sigdata_cb cb, void *cbdata)
Possibly attach a signature to an ARPA2 Identity, by adding extra characters to its username.
void a2id_dropkeys(void)
Wipe all keys clean.
a2id_sigdata_t
Signature data types.
Definition: identity.h:654
bool a2id_sigdata_cb(a2id_sigdata_t sd, void *cbdata, const a2id_t *id, uint8_t *buf, uint16_t *buflen)
Callback function prototype to retrieve signature data.
Definition: identity.h:719
bool a2id_addkey(int keyfd)
Add a key to be used for signed identities.
bool a2id_sigdata_base(a2id_sigdata_t sd, void *cbdata_rid, const a2id_t *lid, uint8_t *buf, uint16_t *buflen)
Basic callback function for a signed ARPA2 Identity.
bool a2id_verify(a2id_t *a2id_to_be_verified, a2id_sigdata_cb cb, void *cbdata)
Try to verify a signature on an ARPA2 Identity.
static bool a2act_isdynamicrecipe(const a2act_t *tested)
Test if an a2act_t is a recipe for a Dynamic Actor Identity.
Definition: identity.h:369
static bool a2act_isdynamic(const a2act_t *tested)
Test if an a2act_t is a Dynamic Actor Identity.
Definition: identity.h:357
bool a2id_parse(a2id_t *out, const char *in, unsigned inlen)
Parse and normalise a string into an ARPA2 Identity.
static void a2sel_detail(char *descr, const a2sel_t *sel)
Print a parsed ARPA2 Identity structure on the detail debugging output.
Definition: identity.h:867
bool a2id_parse_remote(a2id_t *out, const char *in, unsigned inlen)
Parse and normalise a string into a remote ARPA2 Identity.
bool a2sel_parse(a2sel_t *out, const char *in, unsigned inlen)
Parse and normalise a string into an ARPA2 Selector.
a2sel_t a2id_t
ARPA2 Identity.
Definition: identity.h:182
a2id_offset_t
Offsets into parsed identity strings.
Definition: identity.h:128
bool a2act_parse(a2act_t *out, const char *in, unsigned inlen, unsigned nact)
Parse and normalise a string into an ARPA2 Actor Identity.
bool a2sel_textshift(a2id_t *shifty, a2id_offset_t ofsidx, uint16_t newofs, bool before)
Shift text in an ARPA2 Selector.
static bool a2act_isstatic(const a2act_t *tested)
Test if an a2act_t is a Static Actor Identity.
Definition: identity.h:346
bool a2sel_special(const a2sel_t *special, const a2sel_t *general)
Test if the left ARPA2 Selector is a specialised form of the right ARPA2 Selector.
static bool a2act_isempty(const a2act_t *tested)
Test if an a2act_t is an empty Actor Identity.
Definition: identity.h:336
a2id_t a2act_t
ARPA2 Actor Identity.
Definition: identity.h:207
void a2id_init(void)
Initialise the ARPA2 Identity system.
void a2id_fini(void)
Finalise the ARPA2 Identity system.
Storage structure for Quick Iteration.
Definition: identity.h:526
ARPA2 Selector.
Definition: identity.h:165