xref: /openbsd-src/lib/libkeynote/keynote.3 (revision d905fc10a3527c993c262ab7a5c86ba8232b3bdc)
1*d905fc10Sjsg.\" $OpenBSD: keynote.3,v 1.55 2022/02/18 10:24:32 jsg Exp $
2ad6f4f89Sangelos.\"
3ad6f4f89Sangelos.\" The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
4ad6f4f89Sangelos.\"
5ad6f4f89Sangelos.\" This code was written by Angelos D. Keromytis in Philadelphia, PA, USA,
6ad6f4f89Sangelos.\" in April-May 1998
7ad6f4f89Sangelos.\"
8ad6f4f89Sangelos.\" Copyright (C) 1998, 1999 by Angelos D. Keromytis.
9ad6f4f89Sangelos.\"
105e4ac158Sderaadt.\" Permission to use, copy, and modify this software with or without fee
11ad6f4f89Sangelos.\" is hereby granted, provided that this entire notice is included in
12ad6f4f89Sangelos.\" all copies of any software which is or includes a copy or
13ad6f4f89Sangelos.\" modification of this software.
14ad6f4f89Sangelos.\" You may use this code under the GNU public license if you so wish. Please
15ad6f4f89Sangelos.\" contribute changes back to the author.
16ad6f4f89Sangelos.\"
17ad6f4f89Sangelos.\" THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
18ad6f4f89Sangelos.\" IMPLIED WARRANTY. IN PARTICULAR, THE AUTHORS MAKES NO
19ad6f4f89Sangelos.\" REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
20ad6f4f89Sangelos.\" MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
21ad6f4f89Sangelos.\" PURPOSE.
22ad6f4f89Sangelos.\"
23*d905fc10Sjsg.Dd $Mdocdate: February 18 2022 $
24d04ba2ccSjmc.Dt KN_INIT 3
25ad6f4f89Sangelos.\" .TH KeyNote 3 local
267f3168a2Saaron.Os
27ad6f4f89Sangelos.Sh NAME
28d04ba2ccSjmc.Nm kn_init ,
29d04ba2ccSjmc.Nm kn_add_assertion ,
30d04ba2ccSjmc.Nm kn_remove_assertion ,
31d04ba2ccSjmc.Nm kn_add_action ,
32d04ba2ccSjmc.Nm kn_remove_action ,
33d04ba2ccSjmc.Nm kn_add_authorizer ,
34d04ba2ccSjmc.Nm kn_remove_authorizer ,
35d04ba2ccSjmc.Nm kn_do_query ,
36d04ba2ccSjmc.Nm kn_get_failed ,
37d04ba2ccSjmc.Nm kn_cleanup_action_environment ,
38d04ba2ccSjmc.Nm kn_close ,
39d04ba2ccSjmc.Nm kn_query ,
40d04ba2ccSjmc.Nm kn_read_asserts ,
41d04ba2ccSjmc.Nm kn_keycompare ,
42d04ba2ccSjmc.Nm kn_get_authorizer ,
43d04ba2ccSjmc.Nm kn_get_licensees ,
44d04ba2ccSjmc.Nm kn_encode_base64 ,
45d04ba2ccSjmc.Nm kn_decode_base64 ,
46d04ba2ccSjmc.Nm kn_encode_hex ,
47d04ba2ccSjmc.Nm kn_decode_hex ,
48d04ba2ccSjmc.Nm kn_encode_key ,
49d04ba2ccSjmc.Nm kn_decode_key ,
50d04ba2ccSjmc.Nm kn_sign_assertion ,
51d04ba2ccSjmc.Nm kn_verify_assertion ,
52d04ba2ccSjmc.Nm kn_free_key ,
53d04ba2ccSjmc.Nm kn_get_string
54f855b20bSangelos.Nd a trust-management system library
55ad6f4f89Sangelos.Sh SYNOPSIS
56ec5cd23eSschwarze.In sys/types.h
57ec5cd23eSschwarze.In regex.h
58ec5cd23eSschwarze.In keynote.h
59ad6f4f89Sangelos.Bd -literal
60d2b3e63fSderaadtstruct environment {
61ad6f4f89Sangelos	char               *env_name;
62ad6f4f89Sangelos	char               *env_value;
63ad6f4f89Sangelos	int                 env_flags;
64ad6f4f89Sangelos	regex_t             env_regex;
65ad6f4f89Sangelos	struct environment *env_next;
66ad6f4f89Sangelos};
67ad6f4f89Sangelos
68d2b3e63fSderaadtstruct keynote_deckey {
69ad6f4f89Sangelos	int   dec_algorithm;
70ad6f4f89Sangelos	void *dec_key;
71ad6f4f89Sangelos};
72ad6f4f89Sangelos
73d2b3e63fSderaadtstruct keynote_binary {
74ad6f4f89Sangelos	int   bn_len;
75ad6f4f89Sangelos	char *bn_key;
76ad6f4f89Sangelos};
779186b70cSangelos
78d2b3e63fSderaadtstruct keynote_keylist {
799186b70cSangelos	int                     key_alg;
809186b70cSangelos	void                   *key_key;
819186b70cSangelos	char                   *key_stringkey;
829186b70cSangelos	struct keynote_keylist *key_next;
839186b70cSangelos};
84ad6f4f89Sangelos.Ed
850b5f7278Smpech.Vt extern int keynote_errno;
86ad6f4f89Sangelos.Ft int
87ad6f4f89Sangelos.Fn kn_init "void"
88ad6f4f89Sangelos.Ft int
89ad6f4f89Sangelos.Fn kn_add_assertion "int sessid" "char *assertion" "int len" "int flags"
90ad6f4f89Sangelos.Ft int
91ad6f4f89Sangelos.Fn kn_remove_assertion "int sessid" "int assertid"
92ad6f4f89Sangelos.Ft int
93ad6f4f89Sangelos.Fn kn_add_action "int sessid" "char *name" "char *value" "int flags"
94ad6f4f89Sangelos.Ft int
95ad6f4f89Sangelos.Fn kn_remove_action "int sessid" "char *name"
96ad6f4f89Sangelos.Ft int
97ad6f4f89Sangelos.Fn kn_add_authorizer "int sessid" "char *principal"
98ad6f4f89Sangelos.Ft int
99ad6f4f89Sangelos.Fn kn_remove_authorizer "int sessid" "char *principal"
100ad6f4f89Sangelos.Ft int
101ad6f4f89Sangelos.Fn kn_do_query "int sessid" "char **returnvalues" "int numvalues"
102ad6f4f89Sangelos.Ft int
103ad6f4f89Sangelos.Fn kn_get_failed "int sessid" "int type" "int seq"
104ad6f4f89Sangelos.Ft int
1059186b70cSangelos.Fn kn_cleanup_action_environment "int sessid"
1069186b70cSangelos.Ft int
107ad6f4f89Sangelos.Fn kn_close "int sessid"
108ad6f4f89Sangelos.Ft int
109e5e2d3bdSschwarze.Fo kn_query
110e5e2d3bdSschwarze.Fa "struct environment *env"
111e5e2d3bdSschwarze.Fa "char **returnvalues"
112e5e2d3bdSschwarze.Fa "int numvalues"
113e5e2d3bdSschwarze.Fa "char **trusted"
114e5e2d3bdSschwarze.Fa "int *trustedlen"
115e5e2d3bdSschwarze.Fa "int numtrusted"
116e5e2d3bdSschwarze.Fa "char **untrusted"
117e5e2d3bdSschwarze.Fa "int *untrustedlen"
118e5e2d3bdSschwarze.Fa "int numuntrusted"
119e5e2d3bdSschwarze.Fa "char **authorizers"
120d8425cbaSsobrado.Fa "int numauthorizers"
121e5e2d3bdSschwarze.Fc
122ad6f4f89Sangelos.Ft char **
123ad6f4f89Sangelos.Fn kn_read_asserts "char *array" "int arraylen" "int *numassertions"
124ad6f4f89Sangelos.Ft int
1252350ed37Sangelos.Fn kn_keycompare "void *key1" "void *key2" "int algorithm"
1269186b70cSangelos.Ft void *
1279186b70cSangelos.Fn kn_get_authorizer "int sessid" "int assertid" "int *algorithm"
1289186b70cSangelos.Ft struct keynote_keylist *
1299186b70cSangelos.Fn kn_get_licensees "int sessid" "int assertid"
1302350ed37Sangelos.Ft int
131ad6f4f89Sangelos.Fn kn_encode_base64 "unsigned char const *src" "unsigned int srclen" "char *dst" "unsigned int dstlen"
132ad6f4f89Sangelos.Ft int
133ad6f4f89Sangelos.Fn kn_decode_base64 "char const *src" "unsigned char *dst" "unsigned int dstlen"
134ad6f4f89Sangelos.Ft int
135ad6f4f89Sangelos.Fn kn_encode_hex "unsigned char *src" "char **dst" "int srclen"
136ad6f4f89Sangelos.Ft int
137ad6f4f89Sangelos.Fn kn_decode_hex "char *src" "char **dst"
138ad6f4f89Sangelos.Ft char *
139ad6f4f89Sangelos.Fn kn_encode_key "struct keynote_deckey *dc" "int iencoding" "int encoding" "int keytype"
140ad6f4f89Sangelos.Ft int
141ad6f4f89Sangelos.Fn kn_decode_key "struct keynote_deckey *dc" "char *key" "int keytype"
142ad6f4f89Sangelos.Ft char *
143ad6f4f89Sangelos.Fn kn_sign_assertion "char *assertion" "int len" "char *key" "char *algorithm" "int vflag"
144ad6f4f89Sangelos.Ft int
145ad6f4f89Sangelos.Fn kn_verify_assertion "char *assertion" "int len"
146088d08c7Sangelos.Ft void
147088d08c7Sangelos.Fn kn_free_key "struct keynote_deckey *"
148c5ba4a6fSangelos.Ft char *
149c5ba4a6fSangelos.Fn kn_get_string "char *"
150ad6f4f89Sangelos.Fd Link options: -lkeynote -lm -lcrypto
151ad6f4f89Sangelos.Sh DESCRIPTION
1529186b70cSangelosFor more details on
1530b5f7278Smpech.Nm keynote ,
1549186b70cSangelossee RFC 2704.
1559186b70cSangelos.Pp
156ad6f4f89Sangelos.Va keynote_errno
1570b5f7278Smpechcontains an error code if some library call failed.
1580b5f7278SmpechFailed calls return \-1 (if their return value is integer), or
159ad6f4f89Sangelos.Dv NULL
160ad6f4f89Sangelos(if their return value is a pointer) and set
161ad6f4f89Sangelos.Va keynote_errno .
162ad6f4f89SangelosThe defined error codes are:
163ad6f4f89Sangelos.Bl -tag -width "ERROR_NOTFOUND" -offset indent
164ad6f4f89Sangelos.It Li ERROR_MEMORY
165ad6f4f89SangelosSome memory allocation or usage error was encountered.
166ad6f4f89Sangelos.It Li ERROR_SYNTAX
167ad6f4f89SangelosSome syntactic or logical error was encountered.
168ad6f4f89Sangelos.It Li ERROR_NOTFOUND
169ad6f4f89SangelosOne of the arguments referred to a nonexistent structure or entry.
170ad6f4f89Sangelos.El
171ad6f4f89Sangelos.Pp
172ad6f4f89SangelosIf no errors were encountered,
173ad6f4f89Sangelos.Va keynote_errno
1740b5f7278Smpechwill be set to 0.
1750b5f7278SmpechThis variable should be reset to 0 if an error was encountered,
1760b5f7278Smpechprior to calling other library routines.
177ad6f4f89Sangelos.Pp
178ad6f4f89SangelosThe main interface to
1790b5f7278Smpech.Nm
1800b5f7278Smpechis centered around the concept of a session.
1810b5f7278SmpechA session describes a collection of policies, assertions, action
1820b5f7278Smpechauthorizers, return values, and action attributes that the
1830b5f7278Smpech.Nm
1840b5f7278Smpechsystem uses to evaluate a query.
1850b5f7278SmpechInformation is not shared between sessions.
1860b5f7278SmpechPolicies, credentials, action authorizers, and action
187ad6f4f89Sangelosattributes can be added or deleted at any point during the lifetime of
1880b5f7278Smpecha session.
1890b5f7278SmpechFurthermore, an application can discover which assertions failed to be
1900b5f7278Smpechevaluated, and in what way, during a query.
191ad6f4f89Sangelos.Pp
192ad6f4f89SangelosFor those applications that only need to do a simple query, there
193ad6f4f89Sangelosexists a single call that takes as arguments all the necessary
1940b5f7278Smpechinformation and performs all the necessary steps.
1950b5f7278SmpechThis is essentially a wrapper that calls the session API functions as
1960b5f7278Smpechnecessary.
197ad6f4f89Sangelos.Pp
198ad6f4f89SangelosFinally, there exist functions for doing ASCII to hexadecimal and
199ad6f4f89SangelosBase64 encoding (and vice versa), for encoding/decoding keys between
200ad6f4f89SangelosASCII and binary formats, and for signing and verifying assertions.
201ad6f4f89Sangelos.Pp
202ad6f4f89SangelosThe description of all
2030b5f7278Smpech.Nm
204ad6f4f89Sangeloslibrary functions follows.
205ad6f4f89Sangelos.Pp
206ad6f4f89Sangelos.Fn kn_init
207ad6f4f89Sangeloscreates a new
2080b5f7278Smpech.Nm
2090b5f7278Smpechsession, and performs any necessary initializations.
2100b5f7278SmpechOn success, this function returns the new session ID, which is used by
2110b5f7278Smpechall subsequent calls with a
212ad6f4f89Sangelos.Fa sessid
213ad6f4f89Sangelosargument.
21462127031SaaronOn failure, it returns \-1 and sets
215ad6f4f89Sangelos.Va keynote_errno
216ad6f4f89Sangelosto
217ad6f4f89Sangelos.Er ERROR_MEMORY .
218ad6f4f89Sangelos.Pp
219ad6f4f89Sangelos.Fn kn_add_assertion
220ad6f4f89Sangelosadds the assertion pointed to by the array
221ad6f4f89Sangelos.Fa assertion ,
222ad6f4f89Sangelosof length
223ad6f4f89Sangelos.Fa len
224ad6f4f89Sangelosin the session identified by
225ad6f4f89Sangelos.Fa sessid .
226ad6f4f89SangelosThe first argument can be discarded after the call to this function.
227ad6f4f89SangelosThe following flags are defined:
228ad6f4f89Sangelos.Bl -tag -width ASSERT_FLAG_LOCAL -offset indent
229ad6f4f89Sangelos.It ASSERT_FLAG_LOCAL
230ad6f4f89SangelosMark this assertion as ultimately trusted.
231ad6f4f89SangelosTrusted assertions need not be signed, and the
232ad6f4f89Sangelos.Fa Authorizer
233ad6f4f89Sangelosand
234ad6f4f89Sangelos.Fa Licensees
235ad6f4f89Sangelosfields can have non-key entries.
236ad6f4f89Sangelos.El
237ad6f4f89Sangelos.Pp
238ad6f4f89SangelosAt least one (trusted) assertion should have
239ad6f4f89Sangelos.Dv POLICY
240ad6f4f89Sangelosas the
241ad6f4f89Sangelos.Fa Authorizer .
242ad6f4f89SangelosOn success, this function will return an assertion ID which can be
243ad6f4f89Sangelosused to remove the assertion from the session, by using
2441e7790adSschwarze.Fn kn_remove_assertion .
24562127031SaaronOn failure, \-1 is returned, and
246ad6f4f89Sangelos.Va keynote_errno
247ad6f4f89Sangelosis set to
248ad6f4f89Sangelos.Er ERROR_NOTFOUND
249ad6f4f89Sangelosif the session was not found,
250ad6f4f89Sangelos.Er ERROR_SYNTAX
251ad6f4f89Sangelosif the assertion was syntactically incorrect, or
252ad6f4f89Sangelos.Er ERROR_MEMORY
253ad6f4f89Sangelosif necessary memory could not be allocated.
254ad6f4f89Sangelos.Pp
255ad6f4f89Sangelos.Fn kn_remove_assertion
256ad6f4f89Sangelosremoves the assertion identified by
257ad6f4f89Sangelos.Fa assertid
258ad6f4f89Sangelosfrom the session identified by
259ad6f4f89Sangelos.Fa sessid .
2600b5f7278SmpechOn success, this function returns 0.
2610b5f7278SmpechOn failure, it returns \-1 and sets
262ad6f4f89Sangelos.Va keynote_errno
263ad6f4f89Sangelosto
264ad6f4f89Sangelos.Er ERROR_NOTFOUND .
265ad6f4f89Sangelos.Pp
266ad6f4f89Sangelos.Fn kn_add_action
267ad6f4f89Sangelosinserts the variable
268ad6f4f89Sangelos.Fa name
269ad6f4f89Sangelosin the action environment of session
270ad6f4f89Sangelos.Fa sessid ,
271ad6f4f89Sangeloswith the value
272ad6f4f89Sangelos.Fa value .
273ad6f4f89SangelosThe same attribute may be added more than once, but only the last
274ad6f4f89Sangelosinstance will be used (memory resources are consumed however).
275ad6f4f89Sangelos.Pp
276ad6f4f89SangelosThe
277ad6f4f89Sangelos.Fa flags
278ad6f4f89Sangelosspecified are formed by or'ing the following values:
279ad6f4f89Sangelos.Bl -tag -width ENVIRONMENT_FLAG_REGEX -offset indent
280ad6f4f89Sangelos.It ENVIRONMENT_FLAG_FUNC
281ad6f4f89SangelosIn this case,
282ad6f4f89Sangelos.Fa value
283ad6f4f89Sangelosis a pointer to a function that takes as argument a string and returns
2840b5f7278Smpecha string.
2850b5f7278SmpechThis is used to implement callbacks for getting action attribute values.
2860b5f7278SmpechThe argument passed to such a callback function is a string identifying
2870b5f7278Smpechthe action attribute whose value is requested, and should return a pointer
2880b5f7278Smpechto string containing that value (this pointer will not be freed by the
2890b5f7278Smpechlibrary), the empty string if the value was not found, or a
290ad6f4f89Sangelos.Dv NULL
291ad6f4f89Sangelosto indicate an error (and may set
292ad6f4f89Sangelos.Va keynote_errno
2930b5f7278Smpechappropriately).
2940b5f7278SmpechPrior to first use (currently, at the time the attribute is added to the
2950b5f7278Smpechsession environment), such functions are called with
296ad6f4f89Sangelos.Dv KEYNOTE_CALLBACK_INITIALIZE
2970b5f7278Smpechas the argument (defined in keynote.h) so that they can perform any special
2980b5f7278Smpechinitializations.
2990b5f7278SmpechFurthermore, when the session is deleted, all such functions will be called
3000b5f7278Smpechwith
301ad6f4f89Sangelos.Dv KEYNOTE_CALLBACK_CLEANUP
3020b5f7278Smpechto perform any special cleanup (such as free any allocated memory).
3030b5f7278SmpechA function may be called with either of these arguments more than once,
3040b5f7278Smpechif it has been defined as the callback function for more than one attribute.
305ad6f4f89Sangelos.It ENVIRONMENT_FLAG_REGEX
306ad6f4f89SangelosIn this case,
307ad6f4f89Sangelos.Fa name
308ad6f4f89Sangelosis a regular expression that may match more than one attribute.
3090b5f7278SmpechIn case of conflict between a regular expression and a
3100b5f7278Smpech.Dq simple
3110b5f7278Smpechattribute, the latter will be given priority.
3120b5f7278SmpechIn case of conflict between two regular expression attributes, the one added
3130b5f7278Smpechlater will be given priority.
3140b5f7278SmpechA callback function should never change the current
3150b5f7278Smpech.Nm
316ad6f4f89Sangelossession, start/invoke/operate on another session, or call one of the
317ad6f4f89Sangelossession-API functions.
318ad6f4f89Sangelos.El
319ad6f4f89Sangelos.Pp
320ad6f4f89SangelosThe combination of the two flags may be used to specify callback
321ad6f4f89Sangelosfunctions that handle large sets of attributes (even to the extent of
3220b5f7278Smpechhaving one callback function handling all attribute references).
3230b5f7278SmpechThis is particularly useful when the action attribute set is particularly
324ad6f4f89Sangeloslarge.
325ad6f4f89Sangelos.Pp
326ad6f4f89SangelosOn success,
3271e7790adSschwarze.Fn kn_add_action
328cc15c4a4Sjmcreturns 0.
329cc15c4a4SjmcOn failure, it returns \-1 and sets
3300b5f7278Smpech.Va keynote_errno
3310b5f7278Smpechto
332ad6f4f89Sangelos.Er ERROR_NOTFOUND
333ad6f4f89Sangelosif the session was not found,
334ad6f4f89Sangelos.Er ERROR_SYNTAX
335ad6f4f89Sangelosif the
336ad6f4f89Sangelos.Fa name
337ad6f4f89Sangeloswas invalid (e.g., started with an underscore character) or was
338ad6f4f89Sangelos.Dv NULL ,
339ad6f4f89Sangelosor
340ad6f4f89Sangelos.Er ERROR_MEMORY
341ad6f4f89Sangelosif necessary memory could not be allocated.
342ad6f4f89Sangelos.Pp
343ad6f4f89Sangelos.Fn kn_remove_action
344ad6f4f89Sangelosremoves action attribute
345ad6f4f89Sangelos.Fa name
346ad6f4f89Sangelosfrom the environment of session
347ad6f4f89Sangelos.Fa sessid .
348ad6f4f89SangelosNotice that if more than one instances of
349ad6f4f89Sangelos.Fa name
350ad6f4f89Sangelosexist, only the one added last will be deleted.
3510b5f7278SmpechOn success, this function returns 0.
3520b5f7278SmpechOn failure, it returns \-1 and
353ad6f4f89Sangelos.Va keynote_errno
354ad6f4f89Sangelosis set to
355ad6f4f89Sangelos.Er ERROR_NOTFOUND
356ad6f4f89Sangelosif the session or the attribute were not found, or
357ad6f4f89Sangelos.Er ERROR_SYNTAX
3580b5f7278Smpechif the name was invalid.
3590b5f7278SmpechIf the attribute value was a callback, that function will be called with
3600b5f7278Smpechthe define
361ad6f4f89Sangelos.Dv KEYNOTE_CALLBACK_CLEANUP
362ad6f4f89Sangelosas the argument.
363ad6f4f89Sangelos.Pp
364ad6f4f89Sangelos.Fn kn_add_authorizer
365ad6f4f89Sangelosadds the principal pointed to by
366ad6f4f89Sangelos.Fa principal
367ad6f4f89Sangelosto the action authorizers list of session
368ad6f4f89Sangelos.Fa sessid .
3690b5f7278SmpechThe principal is typically an ASCII-encoded key.
3700b5f7278SmpechOn success, this function will return 0.
3710b5f7278SmpechOn failure, it returns \-1 and sets
372ad6f4f89Sangelos.Va keynote_errno
373ad6f4f89Sangelosto
374ad6f4f89Sangelos.Er ERROR_NOTFOUND
375ad6f4f89Sangelosif the session was not found,
376ad6f4f89Sangelos.Er ERROR_SYNTAX
377ad6f4f89Sangelosif the encoding was invalid, or
378ad6f4f89Sangelos.Er ERROR_MEMORY
379ad6f4f89Sangelosif necessary memory could not be allocated.
380ad6f4f89Sangelos.Pp
381ad6f4f89Sangelos.Fn kn_remove_authorizer
382ad6f4f89Sangelosremoves
383ad6f4f89Sangelos.Fa principal
384ad6f4f89Sangelosfrom the action authorizer list of session
385ad6f4f89Sangelos.Fa sessid .
3860b5f7278SmpechOn success, this function returns 0.
3870b5f7278SmpechOn failure, it returns \-1 and sets
388ad6f4f89Sangelos.Va keynote_errno
389ad6f4f89Sangelosto
390ad6f4f89Sangelos.Er ERROR_NOTFOUND
391ad6f4f89Sangelosif the session was not found.
392ad6f4f89Sangelos.Pp
393ad6f4f89Sangelos.Fn kn_do_query
394ad6f4f89Sangelosevaluates the request based on the assertions, action attributes, and
395ad6f4f89Sangelosaction authorizers added to session
396ad6f4f89Sangelos.Fa sessid .
397ad6f4f89Sangelos.Fa returnvalues
3980b5f7278Smpechis an ordered array of strings that contain the return values.
3990b5f7278SmpechThe lowest-ordered return value is contained in
4004299d45eSschwarze.Fa returnvalues Ns Bq 0 ,
401ad6f4f89Sangelosand the highest-ordered value is
4024299d45eSschwarze.Fa returnvalues Ns Bq Fa numvalues No \- 1 .
403ad6f4f89SangelosIf
404ad6f4f89Sangelos.Fa returnvalues
405ad6f4f89Sangelosis
406ad6f4f89Sangelos.Dv NULL ,
407ad6f4f89Sangelosthe
408ad6f4f89Sangelos.Fa returnvalues
409ad6f4f89Sangelosfrom the previous call to
4101e7790adSschwarze.Fn kn_do_query
4110b5f7278Smpechwill be used.
4120b5f7278SmpechThe programmer SHOULD NOT free
413ad6f4f89Sangelos.Fa returnvalues
414ad6f4f89Sangelosafter the call to
4151e7790adSschwarze.Fn kn_do_query
416ad6f4f89Sangelosif this feature is used, as the array is not replicated internally.
417ad6f4f89SangelosOn success, this function returns an index into the
418ad6f4f89Sangelos.Fa returnvalues
4190b5f7278Smpecharray.
4200b5f7278SmpechOn failure, it returns \-1 and sets
421ad6f4f89Sangelos.Va keynote_errno
422ad6f4f89Sangelosto
423ad6f4f89Sangelos.Er ERROR_NOTFOUND
424ad6f4f89Sangelosif the session was not found or the authorizers list was empty,
425ad6f4f89Sangelos.Er ERROR_SYNTAX
426ad6f4f89Sangelosif no
427ad6f4f89Sangelos.Fa returnvalues
428ad6f4f89Sangeloshave been specified, or
429ad6f4f89Sangelos.Er ERROR_MEMORY
430ad6f4f89Sangelosif necessary memory could not be allocated.
431ad6f4f89Sangelos.Pp
432ad6f4f89Sangelos.Fn kn_get_failed
433ad6f4f89Sangelosreturns the assertion ID of the
434ad6f4f89Sangelos.Fa num'th
435ad6f4f89Sangelosassertion (starting from zero) in session
436ad6f4f89Sangelos.Fa sessid
4370b5f7278Smpechthat was somehow invalid during evaluation.
4380b5f7278SmpechThis function is typically called after
4391e7790adSschwarze.Fn kn_do_query
440ad6f4f89Sangelosis used to evaluate a request.
441ad6f4f89Sangelos.Fa type
4420b5f7278Smpechspecifies the type of failure the application is interested in.
4430b5f7278SmpechIt can be set to:
444ad6f4f89Sangelos.Bl -tag -width KEYNOTE_ERROR_SIGNATURE -offset indent
445ad6f4f89Sangelos.It KEYNOTE_ERROR_ANY
446ad6f4f89Sangelosto indicate interest in any error.
447ad6f4f89Sangelos.It KEYNOTE_ERROR_SYNTAX
448ad6f4f89Sangelosfor syntactic or semantic errors.
449ad6f4f89Sangelos.It KEYNOTE_ERROR_MEMORY
450ad6f4f89Sangelosfor memory-related problems.
451ad6f4f89Sangelos.It KEYNOTE_ERROR_SIGNATURE
45281c71ef0Sangelosif the assertion could not be cryptographically verified.
453ad6f4f89Sangelos.El
454ad6f4f89Sangelos.Pp
4550b5f7278SmpechThese values are defined in keynote.h.
4560b5f7278SmpechAn application can then delete the offending assertion using
4571e7790adSschwarze.Fn kn_remove_assertion .
4580b5f7278SmpechFor example, to remove all assertion whose signature failed, an application
4590b5f7278Smpechcould do something like:
460ad6f4f89Sangelos.Bd -literal
461ad6f4f89Sangelos  while ((assertid = kn_get_failed(sessid, KEYNOTE_ERROR_SIGNATURE, 0)
462ad6f4f89Sangelos         != -1)
463ad6f4f89Sangelos    kn_remove_assertion(sessid, assertid);
464ad6f4f89Sangelos.Ed
465ad6f4f89Sangelos.Pp
466ad6f4f89SangelosOn success,
4671e7790adSschwarze.Fn kn_get_failed
4680b5f7278Smpechreturns an assertion ID.
4690b5f7278SmpechOn failure, or when no assertion matching the given criteria is found,
4700b5f7278Smpechit returns \-1 and set
471ad6f4f89Sangelos.Va keynote_errno
472ad6f4f89Sangelosto
473ad6f4f89Sangelos.Er ERROR_NOTFOUND .
474ad6f4f89Sangelos.Pp
4759186b70cSangelos.Fn kn_cleanup_action_environment
4769186b70cSangelosremoves all action attributes from the action environment of session
4779186b70cSangelos.Fa sessid .
4789186b70cSangelosIt returns 0 on success.
4799186b70cSangelos.Pp
480ad6f4f89Sangelos.Fn kn_close
481ad6f4f89Sangeloscloses session
482ad6f4f89Sangelos.Fa sessid
483ad6f4f89Sangelosand frees all related resources, deleting action attributes, action
4840b5f7278Smpechauthorizers, and assertions.
4850b5f7278SmpechOn success, this function returns 0.
4860b5f7278SmpechOn failure, it returns \-1 and sets
487ad6f4f89Sangelos.Va keynote_errno
488ad6f4f89Sangelosto
489ad6f4f89Sangelos.Er ERROR_NOTFOUND
490ad6f4f89Sangelosif the session was not found.
491ad6f4f89Sangelos.Pp
492ad6f4f89Sangelos.Fn kn_read_asserts
493ad6f4f89Sangelosparses the string
494ad6f4f89Sangelos.Fa array
495ad6f4f89Sangelosof length
496ad6f4f89Sangelos.Fa arraylen
497204e95a6Sangelosand returns an array of pointers to strings containing copies of
498204e95a6Sangelosthe assertions found in
499ad6f4f89Sangelos.Fa array .
500204e95a6SangelosBoth the array of pointers and the strings are allocated by
501204e95a6Sangelos.Fn kn_read_asserts
502204e95a6Sangelosdynamically, and thus should be freed by the programmer when they are
503204e95a6Sangelosno longer needed.
504ad6f4f89Sangelos.Fa numassertions
505ad6f4f89Sangeloscontains the number of assertions (and thus strings in the returned
506ad6f4f89Sangelosarray) found in
507ad6f4f89Sangelos.Fa array .
508805e681cSangelosOn failure, this function returns
509805e681cSangelos.Dv NULL
510805e681cSangelosand sets
511ad6f4f89Sangelos.Va keynote_errno
512ad6f4f89Sangelosto
513ad6f4f89Sangelos.Er ERROR_MEMORY
514ad6f4f89Sangelosif necessary memory could not be allocated, or
515ad6f4f89Sangelos.Er ERROR_SYNTAX
516ad6f4f89Sangelosif
517ad6f4f89Sangelos.Fa array
518ad6f4f89Sangeloswas
519ad6f4f89Sangelos.Dv NULL .
520805e681cSangelosNote that if there were no assertions found in
521805e681cSangelos.Fa array ,
522805e681cSangelosa valid pointer will be returned, but
523805e681cSangelos.Fa numassertions
5240b5f7278Smpechwill contain the value zero on return.
5250b5f7278SmpechThe returned pointer should be freed by the programmer.
526ad6f4f89Sangelos.Pp
5272350ed37Sangelos.Fn kn_keycompare
5282350ed37Sangeloscompares
5292350ed37Sangelos.Fa key1
5302350ed37Sangelosand
5312350ed37Sangelos.Fa key2
5322350ed37Sangelos(which must be of the same
5332350ed37Sangelos.Fa algorithm )
5342350ed37Sangelosand returns 1 if equal and 0 otherwise.
5352350ed37Sangelos.Pp
5369186b70cSangelos.Fn kn_get_authorizer
5379186b70cSangelosreturns the authorizer key (in binary format) for assertion
5389186b70cSangelos.Fa assertid
5399186b70cSangelosin session
5409186b70cSangelos.Fa sessid .
5419186b70cSangelosIt also sets the
5429186b70cSangelos.Fa algorithm
5439186b70cSangelosargument to the algorithm of the authorizer key.
5449186b70cSangelosOn failure,
5459186b70cSangelos.Fn kn_get_authorizer
5469186b70cSangelosreturns
5475c9f9f31Saaron.Dv NULL ,
5489186b70cSangelosand sets
5499186b70cSangelos.Va keynote_errno
5509186b70cSangelosto
5519186b70cSangelos.Er ERROR_NOTFOUND .
5529186b70cSangelos.Pp
5539186b70cSangelos.Fn kn_get_licensees
5549186b70cSangelosreturns the licensee key(s) for assertion
5559186b70cSangelos.Fa assertid
5569186b70cSangelosin session
5579186b70cSangelos.Fa sessid .
5589186b70cSangelosThe keys are returned in a linked list of
5599186b70cSangelos.Fa struct keynote_keylist
5609186b70cSangelosstructures.
5619186b70cSangelosOn failure,
5629186b70cSangelos.Fn kn_get_licensees
5639186b70cSangelosreturns
5645c9f9f31Saaron.Dv NULL .
5659186b70cSangelosand sets
5669186b70cSangelos.Va keynote_errno
5679186b70cSangelosto
5689186b70cSangelos.Er ERROR_NOTFOUND .
5699186b70cSangelos.Pp
570ad6f4f89Sangelos.Fn kn_query
571ad6f4f89Sangelostakes as arguments a list of action attributes in
572ad6f4f89Sangelos.Fa env ,
573ad6f4f89Sangelosa list of return values in
574ad6f4f89Sangelos.Fa returnvalues
5754eeabb3eSjmc(the number of returnvalues is indicated by
576ad6f4f89Sangelos.Fa numvalues ) ,
5772cfcb93bSaarona number
5782cfcb93bSaaron.Pf ( Fa numtrusted )
579ad6f4f89Sangelosof locally-trusted assertions in
580ad6f4f89Sangelos.Fa trusted
581ad6f4f89Sangelos(the length of each assertion is given by the respective element of
582ad6f4f89Sangelos.Fa trustedlen ) ,
5832cfcb93bSaarona number
5842cfcb93bSaaron.Pf ( Fa numuntrusted )
585ad6f4f89Sangelosof assertions that need to be cryptographically verified in
586ad6f4f89Sangelos.Fa untrusted
587ad6f4f89Sangelos(the length of each assertion is given by the respective element of
588ad6f4f89Sangelos.Fa untrustedlen ) ,
5892cfcb93bSaaronand a number
5902cfcb93bSaaron.Pf ( Fa numauthorizers )
591ad6f4f89Sangelosof action authorizers in
592ad6f4f89Sangelos.Fa authorizers .
593ad6f4f89Sangelos.Fa env
594ad6f4f89Sangelosis a linked list of
595ad6f4f89Sangelos.Fa struct environment
596ee997aeaSmpechstructures.
597ee997aeaSmpechThe
598ad6f4f89Sangelos.Fa env_name ,
599ad6f4f89Sangelos.Fa env_value ,
600ad6f4f89Sangelosand
601ad6f4f89Sangelos.Fa env_flags
602ad6f4f89Sangelosfields correspond to the
603ad6f4f89Sangelos.Fa name ,
604ad6f4f89Sangelos.Fa value ,
605ad6f4f89Sangelosand
606ad6f4f89Sangelos.Fa flags
607ad6f4f89Sangelosarguments to
6081e7790adSschwarze.Fn kn_add_assertion
609ad6f4f89Sangelosrespectively.
610ad6f4f89Sangelos.Fa env_regex
6110b5f7278Smpechis not used.
6120b5f7278SmpechOn success, this function returns an index in
613ad6f4f89Sangelos.Fa returnvalues
6140b5f7278Smpechindicating the returned value to the query.
6150b5f7278SmpechOn failure, it returns \-1 and sets
616ad6f4f89Sangelos.Va keynote_errno
617ad6f4f89Sangelosto the same values as
6181e7790adSschwarze.Fn kn_do_query ,
619f7dfd180Sangelosor to
620f7dfd180Sangelos.Er ERROR_MEMORY
621f7dfd180Sangelosif a trusted or untrusted assertion could not be added to the session due
6220b5f7278Smpechto lack of memory resources.
6230b5f7278SmpechSyntax errors in assertions will not be reported by
624f7dfd180Sangelos.Fn kn_query .
625ad6f4f89Sangelos.Pp
626ad6f4f89Sangelos.Fn kn_encode_base64
627ad6f4f89Sangelosconverts the data of length
628ad6f4f89Sangelos.Fa srclen
629ad6f4f89Sangeloscontained in
630ad6f4f89Sangelos.Fa src
631ad6f4f89Sangelosin Base64 encoding and stores them in
632ad6f4f89Sangelos.Fa dst
633ad6f4f89Sangeloswhich is of length
634ad6f4f89Sangelos.Fa dstlen .
635ad6f4f89SangelosThe actual length of the encoding stored in
636ad6f4f89Sangelos.Fa dst
637ad6f4f89Sangelosis returned.
6380b5f7278Smpech.Fa dst
6390b5f7278Smpechshould be long enough to also contain the trailing
6400b5f7278Smpechstring terminator.
6410b5f7278SmpechIf
642ad6f4f89Sangelos.Fa dst
643ad6f4f89Sangelosis not long enough to contain the encoded data, this function returns
64462127031Saaron\-1 and sets
645ad6f4f89Sangelos.Va keynote_errno
646ad6f4f89Sangelosto
647ad6f4f89Sangelos.Er ERROR_SYNTAX .
648ad6f4f89Sangelos.Pp
649ad6f4f89Sangelos.Fn kn_decode_base64
650ad6f4f89Sangelosdecodes the Base64-encoded data stored in
651ad6f4f89Sangelos.Fa src
652ad6f4f89Sangelosand stores the result in
653ad6f4f89Sangelos.Fa dst ,
654ad6f4f89Sangeloswhich is of length
655ad6f4f89Sangelos.Fa dstlen .
6560b5f7278SmpechThe actual length of the decoded data is returned on success.
6570b5f7278SmpechOn failure, this function returns \-1 and sets
658ad6f4f89Sangelos.Va keynote_errno
659ad6f4f89Sangelosto
660ad6f4f89Sangelos.Er ERROR_SYNTAX ,
661ad6f4f89Sangelosdenoting either an invalid Base64 encoding or insufficient space in
662ad6f4f89Sangelos.Fa dst .
663ad6f4f89Sangelos.Pp
664ad6f4f89Sangelos.Fn kn_encode_hex
665ad6f4f89Sangelosencodes in ASCII-hexadecimal format the data of length
666ad6f4f89Sangelos.Fa srclen
667ad6f4f89Sangeloscontained in
668ad6f4f89Sangelos.Fa src .
669ad6f4f89SangelosThis function allocates a chunk of memory to store the result, which
670ad6f4f89Sangelosis returned in
671ad6f4f89Sangelos.Fa dst .
672ad6f4f89SangelosThus, this function should be used as follows:
673ad6f4f89Sangelos.Bd -literal
674ad6f4f89Sangelos  char *dst;
675ad6f4f89Sangelos
676ad6f4f89Sangelos  kn_encode_hex(src, &dst, srclen);
677ad6f4f89Sangelos.Ed
678ad6f4f89Sangelos.Pp
6790b5f7278SmpechThe length of the allocated buffer will be (2 * srclen + 1).
6800b5f7278SmpechOn success, this function returns 0.
6810b5f7278SmpechOn failure, it returns \-1 and sets
682ad6f4f89Sangelos.Va keynote_errno
683ad6f4f89Sangelosto
684ad6f4f89Sangelos.Er ERROR_MEMORY
685ad6f4f89Sangelosif it failed to allocate enough memory,
686ad6f4f89Sangelos.Er ERROR_SYNTAX
687ad6f4f89Sangelosif
688ad6f4f89Sangelos.Fa dst
689ad6f4f89Sangeloswas
690ad6f4f89Sangelos.Dv NULL .
691ad6f4f89Sangelos.Pp
692ad6f4f89Sangelos.Fn kn_decode_hex
693ad6f4f89Sangelosdecodes the ASCII hex-encoded string in
694ad6f4f89Sangelos.Fa src
6950b5f7278Smpechand stores the result in a memory chunk allocated by the function.
6960b5f7278SmpechA pointer to that memory is stored in
697ad6f4f89Sangelos.Fa dst .
6980b5f7278SmpechThe length of the allocated memory will be (strlen(src) / 2).
6990b5f7278SmpechOn success, this function returns 0.
7000b5f7278SmpechOn failure, it returns \-1 and sets
701ad6f4f89Sangelos.Va keynote_errno
702ad6f4f89Sangelosto
703ad6f4f89Sangelos.Er ERROR_MEMORY
704ad6f4f89Sangelosif it could not allocate enough memory, or
705ad6f4f89Sangelos.Er ERROR_SYNTAX
706ad6f4f89Sangelosif
707ad6f4f89Sangelos.Fa dst
708ad6f4f89Sangeloswas
709ad6f4f89Sangelos.Dv NULL ,
710ad6f4f89Sangelosor the length of
711ad6f4f89Sangelos.Fa src
712ad6f4f89Sangelosis not even.
713ad6f4f89Sangelos.Pp
714ad6f4f89Sangelos.Fn kn_encode_key
7150b5f7278SmpechASCII-encodes a cryptographic key.
7160b5f7278SmpechThe binary representation of the key is contained in
717ad6f4f89Sangelos.Fa dc .
718ad6f4f89SangelosThe field
719ad6f4f89Sangelos.Fa dec_key
720ad6f4f89Sangelosin that structure is a pointer to some cryptographic algorithm
7210b5f7278Smpechdependent information describing the key.
7220b5f7278SmpechIn this implementation, this pointer should be a
723ad6f4f89Sangelos.Fa DSA *
724ad6f4f89Sangelosor
725ad6f4f89Sangelos.Fa RSA *
726ad6f4f89Sangelosfor DSA or RSA keys respectively, as used in the SSL library, or a
727ad6f4f89Sangelos.Fa keynote_binary *
728ad6f4f89Sangelosfor cryptographic keys whose algorithm
7290b5f7278Smpech.Nm
730ad6f4f89Sangelosdoes not know about but the application wishes to include in the
7310b5f7278Smpechaction authorizers (and thus need to be canonicalized).
7320b5f7278SmpechThe field
733ad6f4f89Sangelos.Fa dec_algorithm
734ad6f4f89Sangelosdescribes the cryptographic algorithm, and may be one of
735ad6f4f89Sangelos.Dv KEYNOTE_ALGORITHM_DSA ,
736ad6f4f89Sangelos.Dv KEYNOTE_ALGORITHM_RSA ,
737ad6f4f89Sangelosor
738ad6f4f89Sangelos.Dv KEYNOTE_ALGORITHM_BINARY
739ad6f4f89Sangelosin this implementation.
740ad6f4f89Sangelos.Pp
741ad6f4f89Sangelos.Fa iencoding
7420b5f7278Smpechdescribes how the key should be binary-encoded.
7430b5f7278SmpechThis implementation supports
7442efaf18bSangelos.Dv INTERNAL_ENC_PKCS1
745ad6f4f89Sangelosfor RSA keys,
746ad6f4f89Sangelos.Dv INTERNAL_ENC_ASN1
747ad6f4f89Sangelosfor DSA keys, and
748ad6f4f89Sangelos.Dv INTERNAL_ENC_NONE
749ad6f4f89Sangelosfor BINARY keys.
750ad6f4f89Sangelos.Fa encoding
7510b5f7278Smpechdescribes what ASCII encoding should be applied to the key.
7520b5f7278SmpechValid values are
753ad6f4f89Sangelos.Dv ENCODING_HEX
754ad6f4f89Sangelosand
755ad6f4f89Sangelos.Dv ENCODING_BASE64 ,
756ad6f4f89Sangelosfor hexadecimal and Base64 encoding respectively.
757ad6f4f89Sangelos.Fa keytype
758ad6f4f89Sangelosis one of
759ad6f4f89Sangelos.Dv KEYNOTE_PUBLIC_KEY
760ad6f4f89Sangelosor
761ad6f4f89Sangelos.Dv KEYNOTE_PRIVATE_KEY
7620b5f7278Smpechto indicate whether the key is public or private.
7630b5f7278SmpechPrivate keys have the string
764ad6f4f89Sangelos.Dv KEYNOTE_PRIVATE_KEY_PREFIX
7650b5f7278Smpech(defined in keynote.h) prefixed to the algorithm name.
7660b5f7278SmpechOn success, this function returns a string containing the encoded key.
7670b5f7278SmpechOn failure, it returns
768ad6f4f89Sangelos.Dv NULL
769ad6f4f89Sangelosand sets
770ad6f4f89Sangelos.Va keynote_errno
771ad6f4f89Sangelosto
772ad6f4f89Sangelos.Er ERROR_NOTFOUND
773ad6f4f89Sangelosif the
774ad6f4f89Sangelos.Fa dc
775ad6f4f89Sangelosargument was invalid,
776ad6f4f89Sangelos.Er ERROR_MEMORY
777ad6f4f89Sangelosif it failed to allocate the necessary memory, or
778ad6f4f89Sangelos.Er ERROR_SYNTAX
779ad6f4f89Sangelosif the key to be converted was invalid.
780ad6f4f89Sangelos.Pp
781ad6f4f89Sangelos.Fn kn_decode_key
782ad6f4f89Sangelosdecodes the ASCII-encoded string contained in
783ad6f4f89Sangelos.Fa key .
784ad6f4f89SangelosThe result is placed in
785ad6f4f89Sangelos.Fa dc ,
786ad6f4f89Sangeloswith
787ad6f4f89Sangelos.Fa dec_algorithm
788ad6f4f89Sangelosdescribing the algorithm (see
7891e7790adSschwarze.Fn kn_encode_key ) ,
790ad6f4f89Sangelosand
791ad6f4f89Sangelos.Fa dec_key
7920b5f7278Smpechpointing to an algorithm-dependent structure.
7930b5f7278SmpechIn this implementation, this is an SSLeay/OpenSSL-defined
794ad6f4f89Sangelos.Fa DSA *
795ad6f4f89Sangelosfor DSA keys,
796ad6f4f89Sangelos.Fa RSA *
79793720372Sjmcfor RSA and X.509-based keys, and a
798ad6f4f89Sangelos.Fa keynote_binary *
799ad6f4f89Sangelosfor BINARY keys.
800ad6f4f89Sangelos.Fa keytype
801ad6f4f89Sangelostakes the values
802ad6f4f89Sangelos.Dv KEYNOTE_PUBLIC_KEY
803ad6f4f89Sangelosor
804ad6f4f89Sangelos.Dv KEYNOTE_PRIVATE_KEY
8050b5f7278Smpechto specify a public or private key, where applicable.
8060b5f7278SmpechOn success, this function returns 0.
8070b5f7278SmpechOn failure, it returns \-1 and sets
808ad6f4f89Sangelos.Va keynote_errno
809ad6f4f89Sangelosto
810ad6f4f89Sangelos.Er ERROR_MEMORY
811ad6f4f89Sangelosif necessary memory could not be allocated, or
812ad6f4f89Sangelos.Er ERROR_SYNTAX
813ad6f4f89Sangelosif the key or the ASCII encoding was malformed.
814ad6f4f89Sangelos.Pp
815ad6f4f89Sangelos.Fn kn_sign_assertion
816ad6f4f89Sangelosproduces the cryptographic signature for the assertion of length
817ad6f4f89Sangelos.Fa len
818ad6f4f89Sangelosstored in
819ad6f4f89Sangelos.Fa assertion ,
820ad6f4f89Sangelosusing the ASCII-encoded cryptographic key contained in
821ad6f4f89Sangelos.Fa key .
822ad6f4f89SangelosThe type of signature to be produced is described by the string
823ad6f4f89Sangelos.Fa algorithm .
824ad6f4f89SangelosPossible values for this string are
82537e04d0aSangelos.Dv SIG_RSA_SHA1_PKCS1_HEX ,
82637e04d0aSangelos.Dv SIG_RSA_SHA1_PKCS1_BASE64 ,
8270b5f7278Smpech.Dv SIG_RSA_MD5_HEX
828ad6f4f89Sangelosand
829ad6f4f89Sangelos.Dv SIG_RSA_MD5_HEX
830ad6f4f89Sangelosfor RSA keys,
831ad6f4f89Sangelos.Dv SIG_DSA_SHA1_HEX
832ad6f4f89Sangelosand
833ad6f4f89Sangelos.Dv SIG_DSA_SHA1_BASE64
8349186b70cSangelosfor DSA keys,
8350b5f7278Smpech.Dv SIG_X509_SHA1_HEX
8369186b70cSangelosand
8379186b70cSangelos.Dv SIG_X509_SHA1_BASE64
83893720372Sjmcfor X.509-based keys.
8390b5f7278SmpechNo other cryptographic signatures are currently
8400b5f7278Smpechsupported by this implementation.
8410b5f7278SmpechIf
842ad6f4f89Sangelos.Fa vflag
8430b5f7278Smpechis set to 1, then the generated signature will also be verified.
8440b5f7278SmpechOn success, this function returns a string containing the ASCII-encoded
845ad6f4f89Sangelossignature, without modifying the
846ad6f4f89Sangelos.Fa assertion .
847ad6f4f89SangelosOn failure, it returns
848ad6f4f89Sangelos.Dv NULL
849ad6f4f89Sangelosand sets
850ad6f4f89Sangelos.Va keynote_errno
851ad6f4f89Sangelosto
852ad6f4f89Sangelos.Er ERROR_NOTFOUND
853ad6f4f89Sangelosif one of the arguments was
854ad6f4f89Sangelos.Dv NULL ,
855ad6f4f89Sangelos.Er ERROR_MEMORY
856ad6f4f89Sangelosif necessary memory could not be allocated, or
857ad6f4f89Sangelos.Er ERROR_SYNTAX
858ad6f4f89Sangelosif the
859ad6f4f89Sangelos.Fa algorithm ,
860ad6f4f89Sangelosthe
861ad6f4f89Sangelos.Fa key ,
862ad6f4f89Sangelosor the
863ad6f4f89Sangelos.Fa assertion
864ad6f4f89Sangelos(if signature verification was requested) was invalid.
865ad6f4f89Sangelos.Pp
866ad6f4f89Sangelos.Fn kn_verify_assertion
867ad6f4f89Sangelosverifies the cryptographic signature on the assertion of length
868ad6f4f89Sangelos.Fa len
869ad6f4f89Sangeloscontained in string
870ad6f4f89Sangelos.Fa assertion .
871ad6f4f89SangelosOn success, this function returns
872ad6f4f89Sangelos.Dv SIGRESULT_TRUE
873ad6f4f89Sangelosif the signature could be verified, or
874ad6f4f89Sangelos.Dv SIGRESULT_FALSE
875ee997aeaSmpechotherwise.
876ee997aeaSmpechOn failure, this function returns \-1 and sets
877ad6f4f89Sangelos.Va keynote_errno
878ad6f4f89Sangelosto
879ad6f4f89Sangelos.Er ERROR_MEMORY
880ad6f4f89Sangelosif necessary memory could not be allocated, or
881ad6f4f89Sangelos.Er ERROR_SYNTAX
882ad6f4f89Sangelosif the assertion contained a syntactic error, or the cryptographic
883ad6f4f89Sangelosalgorithm was not supported.
8849186b70cSangelos.Pp
885088d08c7Sangelos.Fn kn_free_key
886c5ba4a6fSangelosfrees a cryptographic key.
887c5ba4a6fSangelos.Pp
888c5ba4a6fSangelos.Fn kn_get_string
889c5ba4a6fSangelosparses the argument, treating it as a
890c5ba4a6fSangelos.Xr keynote 4
8910b5f7278Smpech(quoted) string.
8920b5f7278SmpechThis is useful for parsing key files.
89303e13f1dShshoexerOn success, this function returns a pointer to the parsing result.
89403e13f1dShshoexerThe result is dynamically allocated and should be freed after use.
89503e13f1dShshoexerOn failure,
89603e13f1dShshoexer.Dv NULL
89703e13f1dShshoexeris returned.
898ad6f4f89Sangelos.Sh FILES
8992cfcb93bSaaron.Bl -tag -width libkeynote.a -compact
9002cfcb93bSaaron.It Pa keynote.h
9012cfcb93bSaaron.It Pa libkeynote.a
9022cfcb93bSaaron.El
90305299c44Sjmc.Sh DIAGNOSTICS
90405299c44SjmcThe return values of all the functions have been given along with the
90505299c44Sjmcfunction description above.
906ad6f4f89Sangelos.Sh SEE ALSO
90782db8f81Sangelos.Xr keynote 1 ,
908f7dfd180Sangelos.Xr keynote 4 ,
909f7dfd180Sangelos.Xr keynote 5
9100b5f7278Smpech.Rs
9110b5f7278Smpech.%A M. Blaze
9120b5f7278Smpech.%A J. Feigenbaum
9130b5f7278Smpech.%A J. Lacy
9140b5f7278Smpech.%D 1996
915cc15c4a4Sjmc.%J IEEE Symposium on Security and Privacy
916cc15c4a4Sjmc.%T Decentralized Trust Management
9170b5f7278Smpech.Re
9180b5f7278Smpech.Rs
9190b5f7278Smpech.%A M. Blaze
9200b5f7278Smpech.%A J. Feigenbaum
9210b5f7278Smpech.%A M. Strauss
9220b5f7278Smpech.%D 1998
923cc15c4a4Sjmc.%J Financial Crypto Conference
924cc15c4a4Sjmc.%T Compliance-Checking in the PolicyMaker Trust Management System
925cc15c4a4Sjmc.Re
926cc15c4a4Sjmc.Sh STANDARDS
927cc15c4a4Sjmc.Rs
928cc15c4a4Sjmc.%A M. Blaze
929cc15c4a4Sjmc.%A J. Feigenbaum
930cc15c4a4Sjmc.%A J. Ioannidis
931cc15c4a4Sjmc.%A A. Keromytis
932cc15c4a4Sjmc.%D September 1999
933cc15c4a4Sjmc.%R RFC 2704
934cc15c4a4Sjmc.%T The KeyNote Trust-Management System Version 2
9350b5f7278Smpech.Re
936ea2542f8Smpech.Sh AUTHORS
9377d353dc4Sschwarze.An Angelos D. Keromytis Aq Mt angelos@cs.columbia.edu
9380b5f7278Smpech.Sh WEB PAGE
939*d905fc10Sjsg.Lk https://www1.cs.columbia.edu/~angelos/keynote.html
940