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
23 #define _SHISHI_HAS_LIBTASN1_H 1
26 /* Defined in kerberos5.c, generated from kerberos5.asn1. */
27 extern const ASN1_ARRAY_TYPE shishi_asn1_tab
[];
30 _shishi_asn1_init (Shishi
* handle
)
32 char errorDescription
[MAX_ERROR_DESCRIPTION_SIZE
] = "";
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
;
59 shishi_asn1_number_of_elements (Shishi
* handle
, Shishi_asn1 node
,
60 const char *field
, size_t * n
)
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
;
70 return SHISHI_ASN1_ERROR
;
77 shishi_asn1_empty_p (Shishi
* handle
, Shishi_asn1 node
, const char *field
)
83 rc
= asn1_read_value (node
, field
, NULL
, &datalen
);
84 if (rc
== ASN1_VALUE_NOT_FOUND
)
92 shishi_asn1_read (Shishi
* handle
, Shishi_asn1 node
,
93 const char *field
, char *data
, size_t * datalen
)
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
;
106 return SHISHI_ASN1_ERROR
;
112 /* XXX rename and document */
114 shishi_asn1_read2 (Shishi
* handle
,
115 Shishi_asn1 node
, const char *field
,
116 char **data
, size_t * datalen
)
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
;
130 return SHISHI_ASN1_ERROR
;
133 *data
= xmalloc (*datalen
);
135 rc
= shishi_asn1_read (handle
, node
, field
, *data
, datalen
);
143 shishi_asn1_read_int32 (Shishi
* handle
, Shishi_asn1 node
,
144 const char *field
, int32_t * i
)
146 unsigned char buf
[4];
150 memset (buf
, 0, sizeof (buf
));
151 buflen
= sizeof (buf
);
152 rc
= shishi_asn1_read (handle
, node
, field
, buf
, &buflen
);
158 memset (buf
, 0, sizeof (buf
));
159 rc
= shishi_asn1_read (handle
, node
, field
, &buf
[4 - buflen
], &buflen
);
163 *i
= buf
[3] | (buf
[2] << 8) | (buf
[1] << 16) | (buf
[0] << 24);
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
)
191 res
= shishi_asn1_read2 (handle
, node
, field
, &buf
, &buflen
);
192 if (res
!= SHISHI_OK
)
196 return SHISHI_ASN1_ERROR
;
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
);
214 shishi_asn1_read_optional (Shishi
* handle
,
215 Shishi_asn1 node
, const char *field
,
216 char *data
, size_t * datalen
)
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
)
234 shishi_asn1_write (Shishi
* handle
, Shishi_asn1 node
,
235 const char *field
, const char *data
, size_t datalen
)
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
;
251 shishi_asn1_write_uint32 (Shishi
* handle
, Shishi_asn1 node
,
252 const char *field
, uint32_t n
)
257 asprintf (&buf
, "%ud", n
);
258 res
= shishi_asn1_write (handle
, node
, field
, buf
, 0);
260 if (res
!= SHISHI_OK
)
267 shishi_asn1_write_int32 (Shishi
* handle
, Shishi_asn1 node
,
268 const char *field
, int32_t n
)
273 asprintf (&buf
, "%d", n
);
274 res
= shishi_asn1_write (handle
, node
, field
, buf
, 0);
276 if (res
!= 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];
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
)
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.
329 shishi_asn1_done (Shishi
* handle
, Shishi_asn1 node
)
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
));
341 shishi_asn1_new (Shishi
* handle
, const char *field
, const char *name
)
343 ASN1_TYPE node
= ASN1_TYPE_EMPTY
;
346 res
= asn1_create_element (handle
->asn1
, field
, &node
);
347 if (res
!= ASN1_SUCCESS
)
349 shishi_error_set (handle
, libtasn1_strerror (res
));
353 return (Shishi_asn1
) node
;
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.
365 shishi_asn1_asreq (Shishi
* handle
)
367 return shishi_asn1_new (handle
, "Kerberos5.AS-REQ", "KDC-REQ");
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.
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.
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.
407 shishi_asn1_tgsrep (Shishi
* handle
)
409 return shishi_asn1_new (handle
, "Kerberos5.TGS-REP", "KDC-REP");
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.
421 shishi_asn1_apreq (Shishi
* handle
)
423 return shishi_asn1_new (handle
, "Kerberos5.AP-REQ", "AP-REQ");
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.
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.
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.
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
)
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
)
484 return (Shishi_asn1
) node
;
487 shishi_error_set (handle
, libtasn1_strerror (res
));
489 asn1_delete_structure (&node
);
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.
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.
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.
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.
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.
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.
572 shishi_asn1_krbsafe (Shishi
* handle
)
574 return shishi_asn1_new (handle
, "Kerberos5.KRB-SAFE", "KRB-SAFE");
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.
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.
600 shishi_asn1_encprivpart (Shishi
* handle
)
602 return shishi_asn1_new (handle
, "Kerberos5.EncKrbPrivPart",
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
] = "";
615 rc
= asn1_der_coding (node
, field
, (unsigned char *) der
, len
,
617 if (rc
!= ASN1_SUCCESS
)
619 shishi_error_set (handle
, errorDescription
);
620 return SHISHI_ASN1_ERROR
;
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
] = "";
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
;
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
);
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
));
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
);
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.
708 shishi_asn1_msgtype (Shishi
* handle
, Shishi_asn1 node
)
713 /* XXX Use APPLICATION tag instead. */
714 rc
= shishi_asn1_read_uint32 (handle
, node
, "msg-type", &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.
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)
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.
754 shishi_der2asn1 (Shishi
* handle
, const char *der
, size_t derlen
)
758 switch (shishi_der_msgtype (handle
, der
, derlen
))
760 case SHISHI_MSGTYPE_AS_REQ
:
761 node
= shishi_der2asn1_asreq (handle
, der
, derlen
);
764 case SHISHI_MSGTYPE_AS_REP
:
765 node
= shishi_der2asn1_asrep (handle
, der
, derlen
);
768 case SHISHI_MSGTYPE_TGS_REQ
:
769 node
= shishi_der2asn1_tgsreq (handle
, der
, derlen
);
772 case SHISHI_MSGTYPE_TGS_REP
:
773 node
= shishi_der2asn1_tgsrep (handle
, der
, derlen
);
776 case SHISHI_MSGTYPE_AP_REQ
:
777 node
= shishi_der2asn1_apreq (handle
, der
, derlen
);
780 case SHISHI_MSGTYPE_AP_REP
:
781 node
= shishi_der2asn1_aprep (handle
, der
, derlen
);
784 case SHISHI_MSGTYPE_SAFE
:
785 node
= shishi_der2asn1_krbsafe (handle
, der
, derlen
);
788 case SHISHI_MSGTYPE_PRIV
:
789 node
= shishi_der2asn1_priv (handle
, der
, derlen
);
792 case SHISHI_MSGTYPE_CRED
:
793 /* node = shishi_der2asn1_cred (handle, der, derlen); */
796 case SHISHI_MSGTYPE_ERROR
:
797 node
= shishi_der2asn1_krberror (handle
, der
, derlen
);
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.
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.
835 shishi_der2asn1_encticketpart (Shishi
* handle
, const char *der
,
838 return der2asn1 (handle
, "Kerberos5.EncTicketPart", "EncTicketPart",
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.
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.
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.
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.
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.
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.
933 shishi_der2asn1_encasreppart (Shishi
* handle
, const char *der
, size_t derlen
)
935 return der2asn1 (handle
, "Kerberos5.EncASRepPart", "EncKDCRepPart",
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.
950 shishi_der2asn1_enctgsreppart (Shishi
* handle
, const char *der
,
953 return der2asn1 (handle
, "Kerberos5.EncTGSRepPart", "EncKDCRepPart",
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.
968 shishi_der2asn1_enckdcreppart (Shishi
* handle
, const char *der
,
971 return der2asn1 (handle
, "Kerberos5.EncKDCRepPart", "EncKDCRepPart",
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.
986 shishi_der2asn1_authenticator (Shishi
* handle
, const char *der
,
989 return der2asn1 (handle
, "Kerberos5.Authenticator", "Authenticator",
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.
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.
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.
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.
1052 shishi_der2asn1_encprivpart (Shishi
* handle
, const char *der
, size_t derlen
)
1054 return der2asn1 (handle
, "Kerberos5.EncKrbPrivPart", "EncKrbPrivPart",
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.
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.
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.
1101 shishi_der2asn1_encapreppart (Shishi
* handle
, const char *der
, size_t derlen
)
1103 return der2asn1 (handle
, "Kerberos5.EncAPRepPart", "EncAPRepPart",
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
1116 * Return value: Returns ASN.1 structure corresponding to DER data.
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");
1144 printf ("der2asn1_kdcreq: kdcreq!!\n");