2 * Copyright (C) 2002, 2003 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 Shishi_asn1 authenticator
;
31 Shishi_asn1 encapreppart
;
32 int authenticatorcksumkeyusage
;
33 int authenticatorkeyusage
;
34 char *authenticatorcksumdata
;
35 int authenticatorcksumdatalen
;
40 * @handle: shishi handle as allocated by shishi_init().
41 * @ap: pointer to new structure that holds information about AP exchange
43 * Create a new AP exchange.
45 * Return value: Returns SHISHI_OK iff successful.
48 shishi_ap (Shishi
* handle
, Shishi_ap
** ap
)
52 *ap
= malloc (sizeof (**ap
));
54 return SHISHI_MALLOC_ERROR
;
56 memset (lap
, 0, sizeof (*lap
));
59 lap
->authenticatorcksumkeyusage
= SHISHI_KEYUSAGE_APREQ_AUTHENTICATOR_CKSUM
;
60 lap
->authenticatorkeyusage
= SHISHI_KEYUSAGE_APREQ_AUTHENTICATOR
;
62 lap
->authenticator
= shishi_authenticator (handle
);
63 if (lap
->authenticator
== NULL
)
65 shishi_error_printf (handle
, "Could not create Authenticator: %s\n",
66 shishi_strerror_details (handle
));
67 return SHISHI_ASN1_ERROR
;
70 lap
->apreq
= shishi_apreq (handle
);
71 if (lap
->apreq
== NULL
)
73 shishi_error_printf (handle
, "Could not create AP-REQ: %s\n",
74 shishi_strerror_details (handle
));
75 return SHISHI_ASN1_ERROR
;
78 lap
->aprep
= shishi_aprep (handle
);
79 if (lap
->aprep
== NULL
)
81 shishi_error_printf (handle
, "Could not create AP-REP: %s\n",
82 shishi_strerror_details (handle
));
83 return SHISHI_ASN1_ERROR
;
86 lap
->encapreppart
= shishi_encapreppart (handle
);
87 if (lap
->encapreppart
== NULL
)
89 shishi_error_printf (handle
, "Could not create EncAPRepPart: %s\n",
90 shishi_strerror_details (handle
));
91 return SHISHI_ASN1_ERROR
;
98 * shishi_ap_set_tktoptions:
99 * @ap: structure that holds information about AP exchange
100 * @tkt: ticket to set in AP.
101 * @options: AP-REQ options to set in AP.
103 * Set the ticket (see shishi_ap_tkt_set()) and set the AP-REQ
104 * apoptions (see shishi_apreq_options_set()).
106 * Return value: Returns SHISHI_OK iff successful.
109 shishi_ap_set_tktoptions (Shishi_ap
* ap
, Shishi_tkt
* tkt
, int options
)
113 shishi_ap_tkt_set (ap
, tkt
);
115 rc
= shishi_apreq_options_set (ap
->handle
, shishi_ap_req (ap
), options
);
118 printf ("Could not set AP-Options: %s", shishi_strerror (rc
));
126 * shishi_ap_set_tktoptionsdata:
127 * @ap: structure that holds information about AP exchange
128 * @tkt: ticket to set in AP.
129 * @options: AP-REQ options to set in AP.
130 * @data: input array with data to checksum in Authenticator.
131 * @len: length of input array with data to checksum in Authenticator.
133 * Set the ticket (see shishi_ap_tkt_set()) and set the AP-REQ
134 * apoptions (see shishi_apreq_options_set()) and set the
135 * Authenticator checksum data.
137 * Return value: Returns SHISHI_OK iff successful.
140 shishi_ap_set_tktoptionsdata (Shishi_ap
* ap
,
142 int options
, char *data
, int len
)
146 shishi_ap_tkt_set (ap
, tkt
);
148 rc
= shishi_apreq_options_set (ap
->handle
, shishi_ap_req (ap
), options
);
151 printf ("Could not set AP-Options: %s", shishi_strerror (rc
));
155 shishi_ap_authenticator_cksumdata_set (ap
, data
, len
);
161 * shishi_ap_set_tktoptionsasn1:
162 * @ap: structure that holds information about AP exchange
163 * @tkt: ticket to set in AP.
164 * @options: AP-REQ options to set in AP.
165 * @node: input ASN.1 structure to store as authenticator checksum data.
167 * Set ticket, options and authenticator checksum data using
168 * shishi_ap_set_tktoptionsdata(). The authenticator checksum data is
169 * the DER encoding of the ASN.1 structure provided.
171 * Return value: Returns SHISHI_OK iff successful.
174 shishi_ap_set_tktoptionsasn1usage (Shishi_ap
* ap
,
179 int authenticatorcksumkeyusage
,
180 int authenticatorkeyusage
)
186 res
= shishi_a2d_new_field (ap
->handle
, node
, field
, &buf
, &buflen
);
187 if (res
!= SHISHI_OK
)
190 /* XXX what is this? */
191 memmove (buf
, buf
+ 2, buflen
- 2);
194 res
= shishi_ap_set_tktoptionsdata (ap
, tkt
, options
, buf
, buflen
);
195 if (res
!= SHISHI_OK
)
198 ap
->authenticatorcksumkeyusage
= authenticatorcksumkeyusage
;
199 ap
->authenticatorkeyusage
= authenticatorkeyusage
;
205 * shishi_ap_tktoptions:
206 * @handle: shishi handle as allocated by shishi_init().
207 * @ap: pointer to new structure that holds information about AP exchange
208 * @tkt: ticket to set in newly created AP.
209 * @options: AP-REQ options to set in newly created AP.
211 * Create a new AP exchange using shishi_ap(), and set the ticket and
212 * AP-REQ apoptions using shishi_ap_set_tktoption().
214 * Return value: Returns SHISHI_OK iff successful.
217 shishi_ap_tktoptions (Shishi
* handle
,
218 Shishi_ap
** ap
, Shishi_tkt
* tkt
, int options
)
222 rc
= shishi_ap (handle
, ap
);
226 rc
= shishi_ap_set_tktoptions (*ap
, tkt
, options
);
234 * shishi_ap_tktoptionsdata:
235 * @handle: shishi handle as allocated by shishi_init().
236 * @ap: pointer to new structure that holds information about AP exchange
237 * @tkt: ticket to set in newly created AP.
238 * @options: AP-REQ options to set in newly created AP.
239 * @data: input array with data to checksum in Authenticator.
240 * @len: length of input array with data to checksum in Authenticator.
242 * Create a new AP exchange using shishi_ap(), and set the ticket,
243 * AP-REQ apoptions and the Authenticator checksum data using
244 * shishi_ap_set_tktoptionsdata().
246 * Return value: Returns SHISHI_OK iff successful.
249 shishi_ap_tktoptionsdata (Shishi
* handle
,
251 Shishi_tkt
* tkt
, int options
, char *data
, int len
)
255 rc
= shishi_ap (handle
, ap
);
259 rc
= shishi_ap_set_tktoptionsdata (*ap
, tkt
, options
, data
, len
);
267 * shishi_ap_tktoptionsasn1:
268 * @handle: shishi handle as allocated by shishi_init().
269 * @ap: pointer to new structure that holds information about AP exchange
270 * @tkt: ticket to set in newly created AP.
271 * @options: AP-REQ options to set in newly created AP.
272 * @node: input ASN.1 structure to store as authenticator checksum data.
274 * Create a new AP exchange using shishi_ap(), and set ticket, options
275 * and authenticator checksum data from the DER encoding of the ASN.1
276 * field using shishi_ap_set_tktoptionsasn1usage().
278 * Return value: Returns SHISHI_OK iff successful.
281 shishi_ap_tktoptionsasn1usage (Shishi
* handle
,
287 int authenticatorcksumkeyusage
,
288 int authenticatorkeyusage
)
292 rc
= shishi_ap (handle
, ap
);
296 rc
= shishi_ap_set_tktoptionsasn1usage (*ap
, tkt
, options
,
298 authenticatorcksumkeyusage
,
299 authenticatorkeyusage
);
308 * @ap: structure that holds information about AP exchange
310 * Return value: Returns the ticket from the AP exchange, or NULL if
311 * not yet set or an error occured.
314 shishi_ap_tkt (Shishi_ap
* ap
)
321 * @ap: structure that holds information about AP exchange
322 * @tkt: ticket to store in AP.
324 * Set the Ticket in the AP exchange.
327 shishi_ap_tkt_set (Shishi_ap
* ap
, Shishi_tkt
* tkt
)
333 * shishi_ap_authenticatorcksumdata:
334 * @ap: structure that holds information about AP exchange
335 * @out: output array that holds authenticator checksum data.
336 * @len: on input, maximum length of output array that holds
337 * authenticator checksum data, on output actual length of
338 * output array that holds authenticator checksum data.
340 * Return value: Returns SHISHI_OK if successful, or
341 * SHISHI_TOO_SMALL_BUFFER if buffer provided was too small.
344 shishi_ap_authenticator_cksumdata (Shishi_ap
* ap
, char *out
, int *len
)
346 if (*len
< ap
->authenticatorcksumdatalen
)
347 return SHISHI_TOO_SMALL_BUFFER
;
348 if (ap
->authenticatorcksumdata
)
349 memcpy (out
, ap
->authenticatorcksumdata
, ap
->authenticatorcksumdatalen
);
350 *len
= ap
->authenticatorcksumdatalen
;
355 * shishi_ap_authenticator_cksumdata_set:
356 * @ap: structure that holds information about AP exchange
357 * @authenticatorcksumdata: input array with authenticator checksum
359 * @authenticatorcksumdata: length of input array with authenticator
360 * checksum data to use in AP.
362 * Set the Authenticator Checksum Data in the AP exchange.
365 shishi_ap_authenticator_cksumdata_set (Shishi_ap
* ap
,
366 char *authenticatorcksumdata
,
367 int authenticatorcksumdatalen
)
369 ap
->authenticatorcksumdata
= authenticatorcksumdata
;
370 ap
->authenticatorcksumdatalen
= authenticatorcksumdatalen
;
374 * shishi_ap_authenticator:
375 * @ap: structure that holds information about AP exchange
377 * Return value: Returns the Authenticator from the AP exchange, or
378 * NULL if not yet set or an error occured.
381 shishi_ap_authenticator (Shishi_ap
* ap
)
383 return ap
->authenticator
;
387 * shishi_ap_authenticator_set:
388 * @ap: structure that holds information about AP exchange
389 * @authenticator: authenticator to store in AP.
391 * Set the Authenticator in the AP exchange.
394 shishi_ap_authenticator_set (Shishi_ap
* ap
, Shishi_asn1 authenticator
)
396 if (ap
->authenticator
)
397 shishi_asn1_done (ap
->handle
, ap
->authenticator
);
398 ap
->authenticator
= authenticator
;
403 * @ap: structure that holds information about AP exchange
405 * Return value: Returns the AP-REQ from the AP exchange, or NULL if
406 * not yet set or an error occured.
409 shishi_ap_req (Shishi_ap
* ap
)
417 * @ap: structure that holds information about AP exchange
418 * @apreq: apreq to store in AP.
420 * Set the AP-REQ in the AP exchange.
423 shishi_ap_req_set (Shishi_ap
* ap
, Shishi_asn1 apreq
)
426 shishi_asn1_done (ap
->handle
, ap
->apreq
);
432 * @ap: structure that holds information about AP exchange
433 * @out: output array with der encoding of AP-REQ.
434 * @outlen: length of output array with der encoding of AP-REQ.
436 * Build AP-REQ using shishi_ap_req_build() and DER encode it.
438 * Return value: Returns SHISHI_OK iff successful.
441 shishi_ap_req_der (Shishi_ap
* ap
, char *out
, int *outlen
)
445 rc
= shishi_ap_req_build (ap
);
449 rc
= shishi_a2d (ap
->handle
, ap
->apreq
, out
, outlen
);
457 * shishi_ap_req_der_new:
458 * @ap: structure that holds information about AP exchange
459 * @out: pointer to output array with der encoding of AP-REQ.
460 * @outlen: pointer to length of output array with der encoding of AP-REQ.
462 * Build AP-REQ using shishi_ap_req_build() and DER encode it. @out
463 * is allocated by this function, and it is the responsibility of
464 * caller to deallocate it.
466 * Return value: Returns SHISHI_OK iff successful.
469 shishi_ap_req_der_new (Shishi_ap
* ap
, char **out
, int *outlen
)
473 rc
= shishi_ap_req_build (ap
);
477 rc
= shishi_new_a2d (ap
->handle
, ap
->apreq
, out
, outlen
);
485 * shishi_ap_req_der_set:
486 * @ap: structure that holds information about AP exchange
487 * @der: input array with DER encoded AP-REQ.
488 * @derlen: length of input array with DER encoded AP-REQ.
490 * DER decode AP-REQ and set it AP exchange. If decoding fails, the
491 * AP-REQ in the AP exchange is lost.
493 * Return value: Returns SHISHI_OK.
496 shishi_ap_req_der_set (Shishi_ap
* ap
, char *der
, size_t derlen
)
498 ap
->apreq
= shishi_der2asn1_apreq (ap
->handle
, der
, derlen
);
503 return SHISHI_ASN1_ERROR
;
507 * shishi_ap_req_build:
508 * @ap: structure that holds information about AP exchange
510 * Checksum data in authenticator and add ticket and authenticator to
513 * Return value: Returns SHISHI_OK iff successful.
516 shishi_ap_req_build (Shishi_ap
* ap
)
520 if (VERBOSE (ap
->handle
))
521 printf ("Building AP-REQ...\n");
523 res
= shishi_apreq_set_ticket (ap
->handle
, ap
->apreq
,
524 shishi_tkt_ticket (ap
->tkt
));
525 if (res
!= SHISHI_OK
)
527 shishi_error_printf (ap
->handle
, "Could not set ticket in AP-REQ: %s\n",
528 shishi_strerror_details (ap
->handle
));
532 res
= shishi_authenticator_add_cksum (ap
->handle
, ap
->authenticator
,
533 shishi_tkt_key (ap
->tkt
),
534 ap
->authenticatorcksumkeyusage
,
535 ap
->authenticatorcksumdata
,
536 ap
->authenticatorcksumdatalen
);
537 if (res
!= SHISHI_OK
)
539 shishi_error_printf (ap
->handle
,
540 "Could not add checksum to authenticator: %s\n",
541 shishi_strerror_details (ap
->handle
));
545 if (VERBOSE (ap
->handle
))
546 printf ("Got Authenticator...\n");
548 if (VERBOSEASN1 (ap
->handle
))
549 shishi_authenticator_print (ap
->handle
, stdout
, ap
->authenticator
);
551 res
= shishi_apreq_add_authenticator (ap
->handle
, ap
->apreq
,
552 shishi_tkt_key (ap
->tkt
),
553 ap
->authenticatorkeyusage
,
555 if (res
!= SHISHI_OK
)
557 shishi_error_printf (ap
->handle
, "Could not set authenticator: %s\n",
558 shishi_strerror_details (ap
->handle
));
562 if (VERBOSEASN1 (ap
->handle
))
563 shishi_apreq_print (ap
->handle
, stdout
, ap
->apreq
);
569 * shishi_ap_req_process:
570 * @ap: structure that holds information about AP exchange
572 * Decrypt ticket in AP-REQ using supplied key and decrypt
573 * Authenticator in AP-REQ using key in decrypted ticket, and on
574 * success set the Ticket and Authenticator fields in the AP exchange.
576 * Return value: Returns SHISHI_OK iff successful.
579 shishi_ap_req_process (Shishi_ap
* ap
, Shishi_key
* key
)
581 Shishi_asn1 ticket
, authenticator
;
586 if (VERBOSEASN1 (ap
->handle
))
587 shishi_apreq_print (ap
->handle
, stdout
, ap
->apreq
);
589 rc
= shishi_apreq_get_ticket (ap
->handle
, ap
->apreq
, &ticket
);
592 shishi_error_printf (ap
->handle
,
593 "Could not extract ticket from AP-REQ: %s\n",
594 shishi_strerror (rc
));
598 tkt
= shishi_tkt2 (ap
->handle
, ticket
, NULL
, NULL
);
600 rc
= shishi_tkt_decrypt (tkt
, key
);
603 shishi_error_printf (ap
->handle
, "Error decrypting ticket: %s\n",
604 shishi_strerror (rc
));
608 rc
= shishi_encticketpart_get_key (ap
->handle
,
609 shishi_tkt_encticketpart (tkt
), &tktkey
);
612 shishi_error_printf (ap
->handle
, "Could not get key from ticket: %s\n",
613 shishi_strerror (rc
));
617 if (VERBOSEASN1 (ap
->handle
))
618 shishi_encticketpart_print (ap
->handle
, stdout
,
619 shishi_tkt_encticketpart (tkt
));
621 rc
= shishi_apreq_decrypt (ap
->handle
, ap
->apreq
, tktkey
, SHISHI_KEYUSAGE_APREQ_AUTHENTICATOR
, /* XXX */
625 shishi_error_printf (ap
->handle
, "Error decrypting apreq: %s\n",
626 shishi_strerror (rc
));
630 if (VERBOSEASN1 (ap
->handle
))
631 shishi_authenticator_print (ap
->handle
, stdout
, ap
->authenticator
);
634 ap
->authenticator
= authenticator
;
640 * shishi_ap_req_asn1:
641 * @ap: structure that holds information about AP exchange
642 * @apreq: output AP-REQ variable.
644 * Build AP-REQ using shishi_ap_req_build() and return it.
646 * Return value: Returns SHISHI_OK iff successful.
649 shishi_ap_req_asn1 (Shishi_ap
* ap
, Shishi_asn1
* apreq
)
653 rc
= shishi_ap_req_build (ap
);
664 * @ap: structure that holds information about AP exchange
666 * Return value: Returns the AP-REP from the AP exchange, or NULL if
667 * not yet set or an error occured.
670 shishi_ap_rep (Shishi_ap
* ap
)
677 * @ap: structure that holds information about AP exchange
678 * @aprep: aprep to store in AP.
680 * Set the AP-REP in the AP exchange.
683 shishi_ap_rep_set (Shishi_ap
* ap
, Shishi_asn1 aprep
)
686 shishi_asn1_done (ap
->handle
, ap
->aprep
);
692 * @ap: structure that holds information about AP exchange
693 * @out: output array with der encoding of AP-REP.
694 * @outlen: length of output array with der encoding of AP-REP.
696 * Build AP-REP using shishi_ap_rep_build() and DER encode it.
698 * Return value: Returns SHISHI_OK iff successful.
701 shishi_ap_rep_der (Shishi_ap
* ap
, char *out
, size_t * outlen
)
705 rc
= shishi_ap_rep_build (ap
);
709 rc
= shishi_a2d (ap
->handle
, ap
->aprep
, out
, outlen
);
717 * shishi_ap_rep_der_set:
718 * @ap: structure that holds information about AP exchange
719 * @der: input array with DER encoded AP-REP.
720 * @derlen: length of input array with DER encoded AP-REP.
722 * DER decode AP-REP and set it AP exchange. If decoding fails, the
723 * AP-REP in the AP exchange remains.
725 * Return value: Returns SHISHI_OK.
728 shishi_ap_rep_der_set (Shishi_ap
* ap
, char *der
, size_t derlen
)
732 aprep
= shishi_der2asn1_aprep (ap
->handle
, der
, derlen
);
735 return SHISHI_ASN1_ERROR
;
743 * shishi_ap_rep_build:
744 * @ap: structure that holds information about AP exchange
746 * Checksum data in authenticator and add ticket and authenticator to
749 * Return value: Returns SHISHI_OK iff successful.
752 shishi_ap_rep_build (Shishi_ap
* ap
)
757 if (VERBOSE (ap
->handle
))
758 printf ("Building AP-REP...\n");
760 aprep
= shishi_aprep (ap
->handle
);
761 rc
= shishi_aprep_enc_part_make (ap
->handle
, aprep
, ap
->authenticator
,
762 shishi_tkt_encticketpart (ap
->tkt
));
765 shishi_error_printf (ap
->handle
, "Error creating AP-REP: %s\n",
766 shishi_strerror (rc
));
770 if (VERBOSEASN1 (ap
->handle
))
771 shishi_aprep_print (ap
->handle
, stdout
, aprep
);
773 shishi_ap_rep_set (ap
, aprep
);
779 * shishi_ap_rep_asn1:
780 * @ap: structure that holds information about AP exchange
781 * @apreq: output AP-REP variable.
783 * Build AP-REP using shishi_ap_rep_build() and return it.
785 * Return value: Returns SHISHI_OK iff successful.
788 shishi_ap_rep_asn1 (Shishi_ap
* ap
, Shishi_asn1
* aprep
)
792 rc
= shishi_ap_rep_build (ap
);
802 * shishi_ap_rep_verify:
803 * @ap: structure that holds information about AP exchange
805 * Verify AP-REP compared to Authenticator.
807 * Return value: Returns SHISHI_OK, SHISHI_APREP_VERIFY_FAILED or an
811 shishi_ap_rep_verify (Shishi_ap
* ap
)
815 if (VERBOSE (ap
->handle
))
816 printf ("Decrypting AP-REP...\n");
818 if (VERBOSEASN1 (ap
->handle
))
819 shishi_aprep_print (ap
->handle
, stdout
, ap
->aprep
);
821 res
= shishi_aprep_decrypt (ap
->handle
, ap
->aprep
,
822 shishi_tkt_key (ap
->tkt
),
823 SHISHI_KEYUSAGE_ENCAPREPPART
,
825 if (res
!= SHISHI_OK
)
828 if (VERBOSEASN1 (ap
->handle
))
829 shishi_encapreppart_print (ap
->handle
, stdout
, ap
->encapreppart
);
831 res
= shishi_aprep_verify (ap
->handle
, ap
->authenticator
, ap
->encapreppart
);
832 if (res
!= SHISHI_OK
)
835 if (VERBOSE (ap
->handle
))
836 printf ("Verified AP-REP successfully...\n");
842 * shishi_ap_rep_verify_der:
843 * @ap: structure that holds information about AP exchange
844 * @der: input array with DER encoded AP-REP.
845 * @derlen: length of input array with DER encoded AP-REP.
847 * DER decode AP-REP and set it in AP exchange using
848 * shishi_ap_rep_der_set() and verify it using shishi_ap_rep_verify().
850 * Return value: Returns SHISHI_OK, SHISHI_APREP_VERIFY_FAILED or an
854 shishi_ap_rep_verify_der (Shishi_ap
* ap
, char *der
, size_t derlen
)
858 res
= shishi_ap_rep_der_set (ap
, der
, derlen
);
859 if (res
!= SHISHI_OK
)
862 res
= shishi_ap_rep_verify (ap
);
863 if (res
!= SHISHI_OK
)
870 * shishi_ap_rep_verify_asn1:
871 * @ap: structure that holds information about AP exchange
872 * @aprep: input AP-REP.
874 * Set the AP-REP in the AP exchange using shishi_ap_rep_set() and
875 * verify it using shishi_ap_rep_verify().
877 * Return value: Returns SHISHI_OK, SHISHI_APREP_VERIFY_FAILED or an
881 shishi_ap_rep_verify_asn1 (Shishi_ap
* ap
, Shishi_asn1 aprep
)
885 shishi_ap_rep_set (ap
, aprep
);
887 res
= shishi_ap_rep_verify (ap
);
888 if (res
!= SHISHI_OK
)
896 * @ap: structure that holds information about AP exchange
898 * Return value: Returns the EncAPREPPart from the AP exchange, or
899 * NULL if not yet set or an error occured.
902 shishi_ap_encapreppart (Shishi_ap
* ap
)
904 return ap
->encapreppart
;
908 * shishi_ap_encapreppart_set:
909 * @ap: structure that holds information about AP exchange
910 * @encapreppart: EncAPRepPart to store in AP.
912 * Set the EncAPRepPart in the AP exchange.
915 shishi_ap_encapreppart_set (Shishi_ap
* ap
, Shishi_asn1 encapreppart
)
917 if (ap
->encapreppart
)
918 shishi_asn1_done (ap
->handle
, ap
->encapreppart
);
919 ap
->encapreppart
= encapreppart
;
922 #define APOPTION_RESERVED "reserved"
923 #define APOPTION_USE_SESSION_KEY "use-session-key"
924 #define APOPTION_MUTUAL_REQUIRED "mutual-required"
925 #define APOPTION_UNKNOWN "unknown"
928 shishi_ap_option2string (int option
)
934 case SHISHI_APOPTIONS_RESERVED
:
935 str
= APOPTION_RESERVED
;
938 case SHISHI_APOPTIONS_USE_SESSION_KEY
:
939 str
= APOPTION_USE_SESSION_KEY
;
942 case SHISHI_APOPTIONS_MUTUAL_REQUIRED
:
943 str
= APOPTION_MUTUAL_REQUIRED
;
947 str
= APOPTION_UNKNOWN
;
955 shishi_ap_string2option (const char *str
)
959 if (strcasecmp (str
, APOPTION_RESERVED
) == 0)
960 option
= SHISHI_APOPTIONS_RESERVED
;
961 else if (strcasecmp (str
, APOPTION_USE_SESSION_KEY
) == 0)
962 option
= SHISHI_APOPTIONS_USE_SESSION_KEY
;
963 else if (strcasecmp (str
, APOPTION_MUTUAL_REQUIRED
) == 0)
964 option
= SHISHI_APOPTIONS_MUTUAL_REQUIRED
;
966 option
= strtol (str
, (char **) NULL
, 0);