Fix ARCFOUR.
[shishi.git] / lib / asn1.c
blobe4644c2c1baafe69c9b7db53aa91deb4d41b16d0
1 /* asn1.c utilities to manipulate RFC 1510 ASN.1 types
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
22 #include <libtasn1.h>
23 #define _SHISHI_HAS_LIBTASN1_H 1
24 #include "internal.h"
26 /* Defined in kerberos5.c, generated from kerberos5.asn1. */
27 extern const ASN1_ARRAY_TYPE shishi_asn1_tab[];
29 int
30 _shishi_asn1_init (Shishi * handle)
32 char errorDescription[MAX_ERROR_DESCRIPTION_SIZE] = "";
33 int asn1_result;
35 if (!asn1_check_version (LIBTASN1_VERSION))
37 shishi_warn (handle, "asn1_check-version(%s) failed: %s",
38 LIBTASN1_VERSION, asn1_check_version (NULL));
39 return SHISHI_ASN1_ERROR;
42 if (!asn1_check_version ("0.2.5"))
43 shishi_warn (handle, "libtasn1 >= 0.2.5 preferred, you may see bugs.");
45 asn1_result = asn1_array2tree (shishi_asn1_tab,
46 &handle->asn1, errorDescription);
47 if (asn1_result != ASN1_SUCCESS)
49 shishi_warn (handle, "asn1_array2tree() failed: %s\n",
50 libtasn1_strerror (asn1_result));
51 shishi_warn (handle, "%s", errorDescription);
52 return SHISHI_ASN1_ERROR;
55 return SHISHI_OK;
58 int
59 shishi_asn1_number_of_elements (Shishi * handle, Shishi_asn1 node,
60 const char *field, size_t * n)
62 int rc;
64 rc = asn1_number_of_elements (node, field, (int *) n);
65 if (rc != ASN1_SUCCESS)
67 if (rc == ASN1_ELEMENT_NOT_FOUND)
68 return SHISHI_ASN1_NO_ELEMENT;
69 else
70 return SHISHI_ASN1_ERROR;
73 return SHISHI_OK;
76 int
77 shishi_asn1_empty_p (Shishi * handle, Shishi_asn1 node, const char *field)
79 int rc;
80 int datalen;
82 datalen = 0;
83 rc = asn1_read_value (node, field, NULL, &datalen);
84 if (rc == ASN1_VALUE_NOT_FOUND)
85 return 1;
87 return 0;
90 /* XXX obsolete */
91 int
92 shishi_asn1_read (Shishi * handle, Shishi_asn1 node,
93 const char *field, char *data, size_t * datalen)
95 int rc;
97 rc = asn1_read_value (node, field, (unsigned char *) data, (int *) datalen);
98 if (rc != ASN1_SUCCESS)
100 shishi_error_set (handle, libtasn1_strerror (rc));
101 if (rc == ASN1_ELEMENT_NOT_FOUND)
102 return SHISHI_ASN1_NO_ELEMENT;
103 else if (rc == ASN1_VALUE_NOT_FOUND)
104 return SHISHI_ASN1_NO_VALUE;
105 else
106 return SHISHI_ASN1_ERROR;
109 return SHISHI_OK;
112 /* XXX rename and document */
114 shishi_asn1_read2 (Shishi * handle,
115 Shishi_asn1 node, const char *field,
116 char **data, size_t * datalen)
118 int rc;
120 *datalen = 0;
121 rc = asn1_read_value (node, field, NULL, (int *) datalen);
122 if (rc != ASN1_MEM_ERROR)
124 shishi_error_set (handle, libtasn1_strerror (rc));
125 if (rc == ASN1_ELEMENT_NOT_FOUND)
126 return SHISHI_ASN1_NO_ELEMENT;
127 else if (rc == ASN1_VALUE_NOT_FOUND)
128 return SHISHI_ASN1_NO_VALUE;
129 else
130 return SHISHI_ASN1_ERROR;
133 *data = xmalloc (*datalen);
135 rc = shishi_asn1_read (handle, node, field, *data, datalen);
136 if (rc != SHISHI_OK)
137 return rc;
139 return SHISHI_OK;
143 shishi_asn1_read_int32 (Shishi * handle, Shishi_asn1 node,
144 const char *field, int32_t * i)
146 unsigned char buf[4];
147 int buflen;
148 int rc;
150 memset (buf, 0, sizeof (buf));
151 buflen = sizeof (buf);
152 rc = shishi_asn1_read (handle, node, field, buf, &buflen);
153 if (rc != SHISHI_OK)
154 return rc;
156 if (buflen < 4)
158 memset (buf, 0, sizeof (buf));
159 rc = shishi_asn1_read (handle, node, field, &buf[4 - buflen], &buflen);
160 if (rc != SHISHI_OK)
161 return rc;
163 *i = buf[3] | (buf[2] << 8) | (buf[1] << 16) | (buf[0] << 24);
165 return SHISHI_OK;
169 shishi_asn1_read_uint32 (Shishi * handle, Shishi_asn1 node,
170 const char *field, uint32_t * i)
172 return shishi_asn1_read_int32 (handle, node, field, (int32_t *) i);
176 shishi_asn1_read_integer (Shishi * handle, Shishi_asn1 node,
177 const char *field, int *i)
179 return shishi_asn1_read_int32 (handle, node, field, (int32_t *) i);
183 shishi_asn1_read_bitstring (Shishi * handle, Shishi_asn1 node,
184 const char *field, uint32_t * flags)
186 char *buf;
187 size_t buflen;
188 size_t i;
189 int res;
191 res = shishi_asn1_read2 (handle, node, field, &buf, &buflen);
192 if (res != SHISHI_OK)
193 return res;
195 if (buflen < 4)
196 return SHISHI_ASN1_ERROR;
198 *flags = 0;
199 for (i = 0; i < 4; i++)
201 *flags |= (((buf[i] >> 7) & 0x01) |
202 ((buf[i] >> 5) & 0x02) |
203 ((buf[i] >> 3) & 0x04) |
204 ((buf[i] >> 1) & 0x08) |
205 ((buf[i] << 1) & 0x10) |
206 ((buf[i] << 3) & 0x20) |
207 ((buf[i] << 5) & 0x40) | ((buf[i] << 7) & 0x80)) << (8 * i);
210 return SHISHI_OK;
214 shishi_asn1_read_optional (Shishi * handle,
215 Shishi_asn1 node, const char *field,
216 char *data, size_t * datalen)
218 int rc;
220 rc = asn1_read_value (node, field, (unsigned char *) data, (int *) datalen);
221 if (rc != ASN1_SUCCESS && rc != ASN1_ELEMENT_NOT_FOUND)
223 shishi_error_set (handle, libtasn1_strerror (rc));
224 return SHISHI_ASN1_ERROR;
227 if (rc == ASN1_ELEMENT_NOT_FOUND)
228 *datalen = 0;
230 return SHISHI_OK;
234 shishi_asn1_write (Shishi * handle, Shishi_asn1 node,
235 const char *field, const char *data, size_t datalen)
237 int rc;
239 rc = asn1_write_value (node, field,
240 (const unsigned char *) data, (int) datalen);
241 if (rc != ASN1_SUCCESS)
243 shishi_error_set (handle, libtasn1_strerror (rc));
244 return SHISHI_ASN1_ERROR;
247 return SHISHI_OK;
251 shishi_asn1_write_uint32 (Shishi * handle, Shishi_asn1 node,
252 const char *field, uint32_t n)
254 char *buf;
255 int res;
257 asprintf (&buf, "%ud", n);
258 res = shishi_asn1_write (handle, node, field, buf, 0);
259 free (buf);
260 if (res != SHISHI_OK)
261 return res;
263 return SHISHI_OK;
267 shishi_asn1_write_int32 (Shishi * handle, Shishi_asn1 node,
268 const char *field, int32_t n)
270 char *buf;
271 int res;
273 asprintf (&buf, "%d", n);
274 res = shishi_asn1_write (handle, node, field, buf, 0);
275 free (buf);
276 if (res != SHISHI_OK)
277 return res;
279 return SHISHI_OK;
283 shishi_asn1_write_integer (Shishi * handle, Shishi_asn1 node,
284 const char *field, int n)
286 return shishi_asn1_write_int32 (handle, node, field, (int32_t) n);
290 shishi_asn1_write_bitstring (Shishi * handle, Shishi_asn1 node,
291 const char *field, uint32_t flags)
293 unsigned char buf[4];
294 size_t i;
295 int res;
297 /* XXX
298 Cannot handle bit strings longer than 32 bits.
299 Currently not needed though. */
301 for (i = 0; i < 4; i++)
303 buf[i] = ((((flags >> (8 * i)) >> 7) & 0x01) |
304 (((flags >> (8 * i)) >> 5) & 0x02) |
305 (((flags >> (8 * i)) >> 3) & 0x04) |
306 (((flags >> (8 * i)) >> 1) & 0x08) |
307 (((flags >> (8 * i)) << 1) & 0x10) |
308 (((flags >> (8 * i)) << 3) & 0x20) |
309 (((flags >> (8 * i)) << 5) & 0x40) |
310 (((flags >> (8 * i)) << 7) & 0x80));
313 res = shishi_asn1_write (handle, node, field, buf, 32);
314 if (res != SHISHI_OK)
315 return res;
317 return SHISHI_OK;
321 * shishi_asn1_done:
322 * @handle: shishi handle as allocated by shishi_init().
323 * @node: ASN.1 node to dellocate.
325 * Deallocate resources associated with ASN.1 structure. Note that
326 * the node must not be used after this call.
328 void
329 shishi_asn1_done (Shishi * handle, Shishi_asn1 node)
332 int rc;
334 rc = asn1_delete_structure (&node);
335 if (rc != ASN1_SUCCESS)
336 shishi_error_printf (handle, "Cannot dellocate ASN.1 structure: %s",
337 libtasn1_strerror (rc));
340 static Shishi_asn1
341 shishi_asn1_new (Shishi * handle, const char *field, const char *name)
343 ASN1_TYPE node = ASN1_TYPE_EMPTY;
344 int res;
346 res = asn1_create_element (handle->asn1, field, &node);
347 if (res != ASN1_SUCCESS)
349 shishi_error_set (handle, libtasn1_strerror (res));
350 return NULL;
353 return (Shishi_asn1) node;
357 * shishi_asn1_asreq:
358 * @handle: shishi handle as allocated by shishi_init().
360 * Create new ASN.1 structure for AS-REQ.
362 * Return value: Returns ASN.1 structure.
364 Shishi_asn1
365 shishi_asn1_asreq (Shishi * handle)
367 return shishi_asn1_new (handle, "Kerberos5.AS-REQ", "KDC-REQ");
371 * shishi_asn1_asrep:
372 * @handle: shishi handle as allocated by shishi_init().
374 * Create new ASN.1 structure for AS-REP.
376 * Return value: Returns ASN.1 structure.
378 Shishi_asn1
379 shishi_asn1_asrep (Shishi * handle)
381 return shishi_asn1_new (handle, "Kerberos5.AS-REP", "KDC-REP");
385 * shishi_asn1_tgsreq:
386 * @handle: shishi handle as allocated by shishi_init().
388 * Create new ASN.1 structure for TGS-REQ.
390 * Return value: Returns ASN.1 structure.
392 Shishi_asn1
393 shishi_asn1_tgsreq (Shishi * handle)
395 return shishi_asn1_new (handle, "Kerberos5.TGS-REQ", "KDC-REQ");
399 * shishi_asn1_tgsrep:
400 * @handle: shishi handle as allocated by shishi_init().
402 * Create new ASN.1 structure for TGS-REP.
404 * Return value: Returns ASN.1 structure.
406 Shishi_asn1
407 shishi_asn1_tgsrep (Shishi * handle)
409 return shishi_asn1_new (handle, "Kerberos5.TGS-REP", "KDC-REP");
413 * shishi_asn1_apreq:
414 * @handle: shishi handle as allocated by shishi_init().
416 * Create new ASN.1 structure for AP-REQ.
418 * Return value: Returns ASN.1 structure.
420 Shishi_asn1
421 shishi_asn1_apreq (Shishi * handle)
423 return shishi_asn1_new (handle, "Kerberos5.AP-REQ", "AP-REQ");
427 * shishi_asn1_aprep:
428 * @handle: shishi handle as allocated by shishi_init().
430 * Create new ASN.1 structure for AP-REP.
432 * Return value: Returns ASN.1 structure.
434 Shishi_asn1
435 shishi_asn1_aprep (Shishi * handle)
437 return shishi_asn1_new (handle, "Kerberos5.AP-REP", "AP-REP");
441 * shishi_asn1_encapreppart:
442 * @handle: shishi handle as allocated by shishi_init().
444 * Create new ASN.1 structure for AP-REP.
446 * Return value: Returns ASN.1 structure.
448 Shishi_asn1
449 shishi_asn1_encapreppart (Shishi * handle)
451 return shishi_asn1_new (handle, "Kerberos5.EncAPRepPart", "EncAPRepPart");
454 #define SHISHI_TICKET_DEFAULT_TKTVNO "5"
455 #define SHISHI_TICKET_DEFAULT_TKTVNO_LEN 0
458 * shishi_asn1_ticket:
459 * @handle: shishi handle as allocated by shishi_init().
461 * Create new ASN.1 structure for Ticket.
463 * Return value: Returns ASN.1 structure.
465 Shishi_asn1
466 shishi_asn1_ticket (Shishi * handle)
468 int res = ASN1_SUCCESS;
469 ASN1_TYPE node = ASN1_TYPE_EMPTY;
471 res = asn1_create_element (handle->asn1, "Kerberos5.Ticket", &node);
472 if (res != ASN1_SUCCESS)
473 goto error;
475 #if 1
476 res = asn1_write_value (node, "tkt-vno",
477 (const unsigned char *)
478 SHISHI_TICKET_DEFAULT_TKTVNO,
479 SHISHI_TICKET_DEFAULT_TKTVNO_LEN);
480 if (res != ASN1_SUCCESS)
481 goto error;
482 #endif
484 return (Shishi_asn1) node;
486 error:
487 shishi_error_set (handle, libtasn1_strerror (res));
488 if (node != NULL)
489 asn1_delete_structure (&node);
490 return NULL;
494 * shishi_asn1_encticketpart:
495 * @handle: shishi handle as allocated by shishi_init().
497 * Create new ASN.1 structure for EncTicketPart.
499 * Return value: Returns ASN.1 structure.
501 Shishi_asn1
502 shishi_asn1_encticketpart (Shishi * handle)
504 return shishi_asn1_new (handle, "Kerberos5.EncTicketPart", "EncTicketPart");
508 * shishi_asn1_authenticator:
509 * @handle: shishi handle as allocated by shishi_init().
511 * Create new ASN.1 structure for Authenticator.
513 * Return value: Returns ASN.1 structure.
515 Shishi_asn1
516 shishi_asn1_authenticator (Shishi * handle)
518 return shishi_asn1_new (handle, "Kerberos5.Authenticator", "Authenticator");
522 * shishi_asn1_enckdcreppart:
523 * @handle: shishi handle as allocated by shishi_init().
525 * Create new ASN.1 structure for EncKDCRepPart.
527 * Return value: Returns ASN.1 structure.
529 Shishi_asn1
530 shishi_asn1_enckdcreppart (Shishi * handle)
532 return shishi_asn1_new (handle, "Kerberos5.EncKDCRepPart", "EncKDCRepPart");
536 * shishi_asn1_encasreppart:
537 * @handle: shishi handle as allocated by shishi_init().
539 * Create new ASN.1 structure for EncASRepPart.
541 * Return value: Returns ASN.1 structure.
543 Shishi_asn1
544 shishi_asn1_encasreppart (Shishi * handle)
546 return shishi_asn1_new (handle, "Kerberos5.EncASRepPart", "EncKDCRepPart");
550 * shishi_asn1_krberror:
551 * @handle: shishi handle as allocated by shishi_init().
553 * Create new ASN.1 structure for KRB-ERROR.
555 * Return value: Returns ASN.1 structure.
557 Shishi_asn1
558 shishi_asn1_krberror (Shishi * handle)
560 return shishi_asn1_new (handle, "Kerberos5.KRB-ERROR", "KRB-ERROR");
564 * shishi_asn1_krbsafe:
565 * @handle: shishi handle as allocated by shishi_init().
567 * Create new ASN.1 structure for KRB-SAFE.
569 * Return value: Returns ASN.1 structure.
571 Shishi_asn1
572 shishi_asn1_krbsafe (Shishi * handle)
574 return shishi_asn1_new (handle, "Kerberos5.KRB-SAFE", "KRB-SAFE");
578 * shishi_asn1_priv:
579 * @handle: shishi handle as allocated by shishi_init().
581 * Create new ASN.1 structure for KRB-PRIV.
583 * Return value: Returns ASN.1 structure.
585 Shishi_asn1
586 shishi_asn1_priv (Shishi * handle)
588 return shishi_asn1_new (handle, "Kerberos5.KRB-PRIV", "KRB-PRIV");
592 * shishi_asn1_encprivpart:
593 * @handle: shishi handle as allocated by shishi_init().
595 * Create new ASN.1 structure for EncKrbPrivPart.
597 * Return value: Returns ASN.1 structure.
599 Shishi_asn1
600 shishi_asn1_encprivpart (Shishi * handle)
602 return shishi_asn1_new (handle, "Kerberos5.EncKrbPrivPart",
603 "EncKrbPrivPart");
606 /* XXX obsolete */
608 shishi_a2d_field (Shishi * handle,
609 Shishi_asn1 node, const char *field,
610 char *der, size_t * len)
612 char errorDescription[MAX_ERROR_DESCRIPTION_SIZE] = "";
613 int rc;
615 rc = asn1_der_coding (node, field, (unsigned char *) der, len,
616 errorDescription);
617 if (rc != ASN1_SUCCESS)
619 shishi_error_set (handle, errorDescription);
620 return SHISHI_ASN1_ERROR;
623 return SHISHI_OK;
626 /* XXX obsolete */
628 shishi_a2d (Shishi * handle, Shishi_asn1 node, char *der, size_t * len)
630 return shishi_a2d_field (handle, node, "", der, len);
633 /* XXX rename and docuemnt */
635 shishi_a2d_new_field (Shishi * handle, Shishi_asn1 node,
636 const char *field, char **der, size_t * len)
638 char errorDescription[MAX_ERROR_DESCRIPTION_SIZE] = "";
639 int rc;
641 *len = 0;
642 rc = asn1_der_coding (node, field, NULL, len, errorDescription);
643 if (rc != ASN1_MEM_ERROR)
645 shishi_error_set (handle, errorDescription);
646 return SHISHI_ASN1_ERROR;
649 *der = xmalloc (*len);
651 rc = asn1_der_coding (node, field, *der, len, errorDescription);
652 if (rc != ASN1_SUCCESS)
654 shishi_error_set (handle, errorDescription);
655 return SHISHI_ASN1_ERROR;
658 return SHISHI_OK;
661 /* XXX rename and docuemnt */
663 shishi_new_a2d (Shishi * handle, Shishi_asn1 node, char **der, size_t * len)
665 return shishi_a2d_new_field (handle, node, "", der, len);
668 static Shishi_asn1
669 der2asn1 (Shishi * handle,
670 const char *fieldname,
671 const char *nodename, const char *der, size_t derlen)
673 char errorDescription[MAX_ERROR_DESCRIPTION_SIZE] = "";
674 Shishi_asn1 structure = NULL;
675 int asn1_result = ASN1_SUCCESS;
677 asn1_result = asn1_create_element (handle->asn1, fieldname, &structure);
678 if (asn1_result != ASN1_SUCCESS)
680 shishi_error_set (handle, libtasn1_strerror (asn1_result));
681 return NULL;
684 asn1_result = asn1_der_decoding (&structure, (const unsigned char *) der,
685 (int) derlen, errorDescription);
686 if (asn1_result != ASN1_SUCCESS)
688 asn1_delete_structure (&structure);
689 shishi_error_set (handle, errorDescription);
690 return NULL;
693 return structure;
697 * shishi_asn1_msgtype:
698 * @handle: shishi handle as allocated by shishi_init().
699 * @node: ASN.1 type to get msg type for.
701 * Determine msg-type of ASN.1 type of a Kerberos Protocol
702 * packet. Currently this uses the msg-type field instead of the
703 * APPLICATION tag, but this may be changed in the future.
705 * Return value: Returns msg-type of ASN.1 type, 0 on failure.
707 Shishi_msgtype
708 shishi_asn1_msgtype (Shishi * handle, Shishi_asn1 node)
710 asn1_retCode rc;
711 uint32_t msgtype;
713 /* XXX Use APPLICATION tag instead. */
714 rc = shishi_asn1_read_uint32 (handle, node, "msg-type", &msgtype);
715 if (rc != SHISHI_OK)
716 return 0;
718 return msgtype;
722 * shishi_der_msgtype:
723 * @handle: shishi handle as allocated by shishi_init().
724 * @der: input character array with DER encoding.
725 * @derlen: length of input character array with DER encoding.
727 * Determine msg-type of DER coded data of a Kerberos Protocol packet.
729 * Return value: Returns msg-type of DER data, 0 on failure.
731 Shishi_msgtype
732 shishi_der_msgtype (Shishi * handle, const char *der, size_t derlen)
734 /* XXX Doesn't handle APPLICATION TAGS > 31. */
735 if (derlen > 1 && *der >= 0x60 && (unsigned char) *der <= 0x7F)
736 return *der - 0x60;
737 else
738 return 0;
742 * shishi_der2asn1:
743 * @handle: shishi handle as allocated by shishi_init().
744 * @der: input character array with DER encoding.
745 * @derlen: length of input character array with DER encoding.
747 * Convert arbitrary DER data of a Kerberos Protocol packet to a
748 * Kerberos ASN.1 type.
750 * Return value: Returns newly allocate ASN.1 corresponding to DER
751 * data, or %NULL on failure.
753 Shishi_asn1
754 shishi_der2asn1 (Shishi * handle, const char *der, size_t derlen)
756 Shishi_asn1 node;
758 switch (shishi_der_msgtype (handle, der, derlen))
760 case SHISHI_MSGTYPE_AS_REQ:
761 node = shishi_der2asn1_asreq (handle, der, derlen);
762 break;
764 case SHISHI_MSGTYPE_AS_REP:
765 node = shishi_der2asn1_asrep (handle, der, derlen);
766 break;
768 case SHISHI_MSGTYPE_TGS_REQ:
769 node = shishi_der2asn1_tgsreq (handle, der, derlen);
770 break;
772 case SHISHI_MSGTYPE_TGS_REP:
773 node = shishi_der2asn1_tgsrep (handle, der, derlen);
774 break;
776 case SHISHI_MSGTYPE_AP_REQ:
777 node = shishi_der2asn1_apreq (handle, der, derlen);
778 break;
780 case SHISHI_MSGTYPE_AP_REP:
781 node = shishi_der2asn1_aprep (handle, der, derlen);
782 break;
784 case SHISHI_MSGTYPE_SAFE:
785 node = shishi_der2asn1_krbsafe (handle, der, derlen);
786 break;
788 case SHISHI_MSGTYPE_PRIV:
789 node = shishi_der2asn1_priv (handle, der, derlen);
790 break;
792 case SHISHI_MSGTYPE_CRED:
793 /* node = shishi_der2asn1_cred (handle, der, derlen); */
794 break;
796 case SHISHI_MSGTYPE_ERROR:
797 node = shishi_der2asn1_krberror (handle, der, derlen);
798 break;
800 default:
801 node = NULL;
802 break;
805 return node;
809 * shishi_der2asn1_ticket:
810 * @handle: shishi handle as allocated by shishi_init().
811 * @der: input character array with DER encoding.
812 * @derlen: length of input character array with DER encoding.
814 * Decode DER encoding of Ticket and create a ASN.1 structure.
816 * Return value: Returns ASN.1 structure corresponding to DER data.
818 Shishi_asn1
819 shishi_der2asn1_ticket (Shishi * handle, const char *der, size_t derlen)
821 return der2asn1 (handle, "Kerberos5.Ticket", "Ticket", der, derlen);
825 * shishi_der2asn1_encticketpart:
826 * @handle: shishi handle as allocated by shishi_init().
827 * @der: input character array with DER encoding.
828 * @derlen: length of input character array with DER encoding.
830 * Decode DER encoding of EncTicketPart and create a ASN.1 structure.
832 * Return value: Returns ASN.1 structure corresponding to DER data.
834 Shishi_asn1
835 shishi_der2asn1_encticketpart (Shishi * handle, const char *der,
836 size_t derlen)
838 return der2asn1 (handle, "Kerberos5.EncTicketPart", "EncTicketPart",
839 der, derlen);
843 * shishi_der2asn1_asreq:
844 * @handle: shishi handle as allocated by shishi_init().
845 * @der: input character array with DER encoding.
846 * @derlen: length of input character array with DER encoding.
848 * Decode DER encoding of AS-REQ and create a ASN.1 structure.
850 * Return value: Returns ASN.1 structure corresponding to DER data.
852 Shishi_asn1
853 shishi_der2asn1_asreq (Shishi * handle, const char *der, size_t derlen)
855 return der2asn1 (handle, "Kerberos5.AS-REQ", "KDC-REQ", der, derlen);
859 * shishi_der2asn1_tgsreq:
860 * @handle: shishi handle as allocated by shishi_init().
861 * @der: input character array with DER encoding.
862 * @derlen: length of input character array with DER encoding.
864 * Decode DER encoding of TGS-REQ and create a ASN.1 structure.
866 * Return value: Returns ASN.1 structure corresponding to DER data.
868 Shishi_asn1
869 shishi_der2asn1_tgsreq (Shishi * handle, const char *der, size_t derlen)
871 return der2asn1 (handle, "Kerberos5.TGS-REQ", "KDC-REQ", der, derlen);
875 * shishi_der2asn1_asrep:
876 * @handle: shishi handle as allocated by shishi_init().
877 * @der: input character array with DER encoding.
878 * @derlen: length of input character array with DER encoding.
880 * Decode DER encoding of AS-REP and create a ASN.1 structure.
882 * Return value: Returns ASN.1 structure corresponding to DER data.
884 Shishi_asn1
885 shishi_der2asn1_asrep (Shishi * handle, const char *der, size_t derlen)
887 return der2asn1 (handle, "Kerberos5.AS-REP", "KDC-REP", der, derlen);
891 * shishi_der2asn1_tgsrep:
892 * @handle: shishi handle as allocated by shishi_init().
893 * @der: input character array with DER encoding.
894 * @derlen: length of input character array with DER encoding.
896 * Decode DER encoding of TGS-REP and create a ASN.1 structure.
898 * Return value: Returns ASN.1 structure corresponding to DER data.
900 Shishi_asn1
901 shishi_der2asn1_tgsrep (Shishi * handle, const char *der, size_t derlen)
903 return der2asn1 (handle, "Kerberos5.TGS-REP", "KDC-REP", der, derlen);
907 * shishi_der2asn1_kdcrep:
908 * @handle: shishi handle as allocated by shishi_init().
909 * @der: input character array with DER encoding.
910 * @derlen: length of input character array with DER encoding.
912 * Decode DER encoding of KDC-REP and create a ASN.1 structure.
914 * Return value: Returns ASN.1 structure corresponding to DER data.
916 Shishi_asn1
917 shishi_der2asn1_kdcrep (Shishi * handle, const char *der, size_t derlen)
919 return der2asn1 (handle, "Kerberos5.KDC-REP", "KDC-REP", der, derlen);
923 * shishi_der2asn1_encasreppart:
924 * @handle: shishi handle as allocated by shishi_init().
925 * @der: input character array with DER encoding.
926 * @derlen: length of input character array with DER encoding.
928 * Decode DER encoding of EncASRepPart and create a ASN.1 structure.
930 * Return value: Returns ASN.1 structure corresponding to DER data.
932 Shishi_asn1
933 shishi_der2asn1_encasreppart (Shishi * handle, const char *der, size_t derlen)
935 return der2asn1 (handle, "Kerberos5.EncASRepPart", "EncKDCRepPart",
936 der, derlen);
940 * shishi_der2asn1_enctgsreppart:
941 * @handle: shishi handle as allocated by shishi_init().
942 * @der: input character array with DER encoding.
943 * @derlen: length of input character array with DER encoding.
945 * Decode DER encoding of EncTGSRepPart and create a ASN.1 structure.
947 * Return value: Returns ASN.1 structure corresponding to DER data.
949 Shishi_asn1
950 shishi_der2asn1_enctgsreppart (Shishi * handle, const char *der,
951 size_t derlen)
953 return der2asn1 (handle, "Kerberos5.EncTGSRepPart", "EncKDCRepPart",
954 der, derlen);
958 * shishi_der2asn1_enckdcreppart:
959 * @handle: shishi handle as allocated by shishi_init().
960 * @der: input character array with DER encoding.
961 * @derlen: length of input character array with DER encoding.
963 * Decode DER encoding of EncKDCRepPart and create a ASN.1 structure.
965 * Return value: Returns ASN.1 structure corresponding to DER data.
967 Shishi_asn1
968 shishi_der2asn1_enckdcreppart (Shishi * handle, const char *der,
969 size_t derlen)
971 return der2asn1 (handle, "Kerberos5.EncKDCRepPart", "EncKDCRepPart",
972 der, derlen);
976 * shishi_der2asn1_authenticator:
977 * @handle: shishi handle as allocated by shishi_init().
978 * @der: input character array with DER encoding.
979 * @derlen: length of input character array with DER encoding.
981 * Decode DER encoding of Authenticator and create a ASN.1 structure.
983 * Return value: Returns ASN.1 structure corresponding to DER data.
985 Shishi_asn1
986 shishi_der2asn1_authenticator (Shishi * handle, const char *der,
987 size_t derlen)
989 return der2asn1 (handle, "Kerberos5.Authenticator", "Authenticator",
990 der, derlen);
994 * shishi_der2asn1_krberror:
995 * @handle: shishi handle as allocated by shishi_init().
996 * @der: input character array with DER encoding.
997 * @derlen: length of input character array with DER encoding.
999 * Decode DER encoding of KRB-ERROR and create a ASN.1 structure.
1001 * Return value: Returns ASN.1 structure corresponding to DER data.
1003 Shishi_asn1
1004 shishi_der2asn1_krberror (Shishi * handle, const char *der, size_t derlen)
1006 return der2asn1 (handle, "Kerberos5.KRB-ERROR", "KRB-ERROR", der, derlen);
1010 * shishi_der2asn1_krbsafe:
1011 * @handle: shishi handle as allocated by shishi_init().
1012 * @der: input character array with DER encoding.
1013 * @derlen: length of input character array with DER encoding.
1015 * Decode DER encoding of KRB-SAFE and create a ASN.1 structure.
1017 * Return value: Returns ASN.1 structure corresponding to DER data.
1019 Shishi_asn1
1020 shishi_der2asn1_krbsafe (Shishi * handle, const char *der, size_t derlen)
1022 return der2asn1 (handle, "Kerberos5.KRB-SAFE", "KRB-SAFE", der, derlen);
1026 * shishi_der2asn1_priv:
1027 * @handle: shishi handle as allocated by shishi_init().
1028 * @der: input character array with DER encoding.
1029 * @derlen: length of input character array with DER encoding.
1031 * Decode DER encoding of KRB-PRIV and create a ASN.1 structure.
1033 * Return value: Returns ASN.1 structure corresponding to DER data.
1035 Shishi_asn1
1036 shishi_der2asn1_priv (Shishi * handle, const char *der, size_t derlen)
1038 return der2asn1 (handle, "Kerberos5.KRB-PRIV", "KRB-PRIV", der, derlen);
1042 * shishi_der2asn1_encprivpart:
1043 * @handle: shishi handle as allocated by shishi_init().
1044 * @der: input character array with DER encoding.
1045 * @derlen: length of input character array with DER encoding.
1047 * Decode DER encoding of EncKrbPrivPart and create a ASN.1 structure.
1049 * Return value: Returns ASN.1 structure corresponding to DER data.
1051 Shishi_asn1
1052 shishi_der2asn1_encprivpart (Shishi * handle, const char *der, size_t derlen)
1054 return der2asn1 (handle, "Kerberos5.EncKrbPrivPart", "EncKrbPrivPart",
1055 der, derlen);
1059 * shishi_der2asn1_apreq:
1060 * @handle: shishi handle as allocated by shishi_init().
1061 * @der: input character array with DER encoding.
1062 * @derlen: length of input character array with DER encoding.
1064 * Decode DER encoding of AP-REQ and create a ASN.1 structure.
1066 * Return value: Returns ASN.1 structure corresponding to DER data.
1068 Shishi_asn1
1069 shishi_der2asn1_apreq (Shishi * handle, const char *der, size_t derlen)
1071 return der2asn1 (handle, "Kerberos5.AP-REQ", "AP-REQ", der, derlen);
1075 * shishi_der2asn1_aprep:
1076 * @handle: shishi handle as allocated by shishi_init().
1077 * @der: input character array with DER encoding.
1078 * @derlen: length of input character array with DER encoding.
1080 * Decode DER encoding of AP-REP and create a ASN.1 structure.
1082 * Return value: Returns ASN.1 structure corresponding to DER data.
1084 Shishi_asn1
1085 shishi_der2asn1_aprep (Shishi * handle, const char *der, size_t derlen)
1087 return der2asn1 (handle, "Kerberos5.AP-REP", "AP-REP", der, derlen);
1091 * shishi_der2asn1_encapreppart:
1092 * @handle: shishi handle as allocated by shishi_init().
1093 * @der: input character array with DER encoding.
1094 * @derlen: length of input character array with DER encoding.
1096 * Decode DER encoding of EncAPRepPart and create a ASN.1 structure.
1098 * Return value: Returns ASN.1 structure corresponding to DER data.
1100 Shishi_asn1
1101 shishi_der2asn1_encapreppart (Shishi * handle, const char *der, size_t derlen)
1103 return der2asn1 (handle, "Kerberos5.EncAPRepPart", "EncAPRepPart",
1104 der, derlen);
1108 * shishi_der2asn1_kdcreq:
1109 * @handle: shishi handle as allocated by shishi_init().
1110 * @der: input character array with DER encoding.
1111 * @derlen: length of input character array with DER encoding.
1113 * Decode DER encoding of AS-REQ, TGS-REQ or KDC-REQ and create a
1114 * ASN.1 structure.
1116 * Return value: Returns ASN.1 structure corresponding to DER data.
1118 Shishi_asn1
1119 shishi_der2asn1_kdcreq (Shishi * handle, const char *der, size_t derlen)
1121 Shishi_asn1 structure = NULL;
1123 structure = shishi_der2asn1_asreq (handle, der, derlen);
1124 if (structure == NULL)
1126 printf ("der2asn1_kdcreq: not asreq\n");
1127 shishi_error_printf (handle, "Could not DER decode AS-REQ\n");
1129 structure = shishi_der2asn1_tgsreq (handle, der, derlen);
1130 if (structure == NULL)
1132 printf ("der2asn1_kdcreq: not tgsreq\n");
1133 shishi_error_printf (handle, "Could not DER decode TGS-REQ\n");
1135 structure = shishi_der2asn1_kdcreq (handle, der, derlen);
1136 if (structure == NULL)
1138 printf ("der2asn1_kdcreq: not kdcreq\n");
1139 shishi_error_printf (handle, "Could not DER decode KDC-REQ\n");
1141 return NULL;
1143 else
1144 printf ("der2asn1_kdcreq: kdcreq!!\n");
1148 return structure;