]> The Tcpdump Group git mirrors - tcpdump/blob - print-esp.c
Handle OpenSSL 1.1.x.
[tcpdump] / print-esp.c
1 /* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
2
3 /*
4 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 */
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <netdissect-stdinc.h>
29
30 #include <string.h>
31 #include <stdlib.h>
32
33 /* Any code in this file that depends on HAVE_LIBCRYPTO depends on
34 * HAVE_OPENSSL_EVP_H too. Undefining the former when the latter isn't defined
35 * is the simplest way of handling the dependency.
36 */
37 #ifdef HAVE_LIBCRYPTO
38 #ifdef HAVE_OPENSSL_EVP_H
39 #include <openssl/evp.h>
40 #else
41 #undef HAVE_LIBCRYPTO
42 #endif
43 #endif
44
45 #include "netdissect.h"
46 #include "strtoaddr.h"
47 #include "extract.h"
48
49 #include "ascii_strcasecmp.h"
50
51 #include "ip.h"
52 #include "ip6.h"
53
54 /*
55 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
56 * All rights reserved.
57 *
58 * Redistribution and use in source and binary forms, with or without
59 * modification, are permitted provided that the following conditions
60 * are met:
61 * 1. Redistributions of source code must retain the above copyright
62 * notice, this list of conditions and the following disclaimer.
63 * 2. Redistributions in binary form must reproduce the above copyright
64 * notice, this list of conditions and the following disclaimer in the
65 * documentation and/or other materials provided with the distribution.
66 * 3. Neither the name of the project nor the names of its contributors
67 * may be used to endorse or promote products derived from this software
68 * without specific prior written permission.
69 *
70 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
71 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
72 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
73 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
74 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
75 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
76 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
77 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
78 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
79 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
80 * SUCH DAMAGE.
81 */
82
83 /*
84 * RFC1827/2406 Encapsulated Security Payload.
85 */
86
87 struct newesp {
88 uint32_t esp_spi; /* ESP */
89 uint32_t esp_seq; /* Sequence number */
90 /*variable size*/ /* (IV and) Payload data */
91 /*variable size*/ /* padding */
92 /*8bit*/ /* pad size */
93 /*8bit*/ /* next header */
94 /*8bit*/ /* next header */
95 /*variable size, 32bit bound*/ /* Authentication data */
96 };
97
98 #ifdef HAVE_LIBCRYPTO
99 union inaddr_u {
100 struct in_addr in4;
101 struct in6_addr in6;
102 };
103 struct sa_list {
104 struct sa_list *next;
105 u_int daddr_version;
106 union inaddr_u daddr;
107 uint32_t spi; /* if == 0, then IKEv2 */
108 int initiator;
109 u_char spii[8]; /* for IKEv2 */
110 u_char spir[8];
111 const EVP_CIPHER *evp;
112 int ivlen;
113 int authlen;
114 u_char authsecret[256];
115 int authsecret_len;
116 u_char secret[256]; /* is that big enough for all secrets? */
117 int secretlen;
118 };
119
120 #ifndef HAVE_EVP_CIPHER_CTX_NEW
121 /*
122 * Allocate an EVP_CIPHER_CTX.
123 * Used if we have an older version of OpenSSL that doesn't provide
124 * routines to allocate and free them.
125 */
126 static EVP_CIPHER_CTX *
127 EVP_CIPHER_CTX_new(void)
128 {
129 EVP_CIPHER_CTX *ctx;
130
131 ctx = malloc(sizeof (EVP_CIPHER_CTX));
132 if (ctx == NULL)
133 return (NULL);
134 memset(ctx, 0, sizeof(*ctx));
135 return (ctx);
136 }
137
138 static void
139 EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
140 {
141 EVP_CIPHER_CTX_cleanup(ctx);
142 free(ctx);
143 }
144 #endif
145
146 /*
147 * this will adjust ndo_packetp and ndo_snapend to new buffer!
148 */
149 USES_APPLE_DEPRECATED_API
150 int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
151 int initiator,
152 u_char spii[8], u_char spir[8],
153 const u_char *buf, const u_char *end)
154 {
155 struct sa_list *sa;
156 const u_char *iv;
157 int len;
158 EVP_CIPHER_CTX *ctx;
159
160 /* initiator arg is any non-zero value */
161 if(initiator) initiator=1;
162
163 /* see if we can find the SA, and if so, decode it */
164 for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
165 if (sa->spi == 0
166 && initiator == sa->initiator
167 && memcmp(spii, sa->spii, 8) == 0
168 && memcmp(spir, sa->spir, 8) == 0)
169 break;
170 }
171
172 if(sa == NULL) return 0;
173 if(sa->evp == NULL) return 0;
174
175 /*
176 * remove authenticator, and see if we still have something to
177 * work with
178 */
179 end = end - sa->authlen;
180 iv = buf;
181 buf = buf + sa->ivlen;
182 len = end-buf;
183
184 if(end <= buf) return 0;
185
186 ctx = EVP_CIPHER_CTX_new();
187 if (ctx == NULL)
188 return 0;
189 if (EVP_CipherInit(ctx, sa->evp, sa->secret, NULL, 0) < 0)
190 (*ndo->ndo_warning)(ndo, "espkey init failed");
191 EVP_CipherInit(ctx, NULL, NULL, iv, 0);
192 EVP_Cipher(ctx, buf, buf, len);
193 EVP_CIPHER_CTX_free(ctx);
194
195 ndo->ndo_packetp = buf;
196 ndo->ndo_snapend = end;
197
198 return 1;
199
200 }
201 USES_APPLE_RST
202
203 static void esp_print_addsa(netdissect_options *ndo,
204 struct sa_list *sa, int sa_def)
205 {
206 /* copy the "sa" */
207
208 struct sa_list *nsa;
209
210 nsa = (struct sa_list *)malloc(sizeof(struct sa_list));
211 if (nsa == NULL)
212 (*ndo->ndo_error)(ndo, "ran out of memory to allocate sa structure");
213
214 *nsa = *sa;
215
216 if (sa_def)
217 ndo->ndo_sa_default = nsa;
218
219 nsa->next = ndo->ndo_sa_list_head;
220 ndo->ndo_sa_list_head = nsa;
221 }
222
223
224 static u_int hexdigit(netdissect_options *ndo, char hex)
225 {
226 if (hex >= '0' && hex <= '9')
227 return (hex - '0');
228 else if (hex >= 'A' && hex <= 'F')
229 return (hex - 'A' + 10);
230 else if (hex >= 'a' && hex <= 'f')
231 return (hex - 'a' + 10);
232 else {
233 (*ndo->ndo_error)(ndo, "invalid hex digit %c in espsecret\n", hex);
234 return 0;
235 }
236 }
237
238 static u_int hex2byte(netdissect_options *ndo, char *hexstring)
239 {
240 u_int byte;
241
242 byte = (hexdigit(ndo, hexstring[0]) << 4) + hexdigit(ndo, hexstring[1]);
243 return byte;
244 }
245
246 /*
247 * returns size of binary, 0 on failure.
248 */
249 static
250 int espprint_decode_hex(netdissect_options *ndo,
251 u_char *binbuf, unsigned int binbuf_len,
252 char *hex)
253 {
254 unsigned int len;
255 int i;
256
257 len = strlen(hex) / 2;
258
259 if (len > binbuf_len) {
260 (*ndo->ndo_warning)(ndo, "secret is too big: %d\n", len);
261 return 0;
262 }
263
264 i = 0;
265 while (hex[0] != '\0' && hex[1]!='\0') {
266 binbuf[i] = hex2byte(ndo, hex);
267 hex += 2;
268 i++;
269 }
270
271 return i;
272 }
273
274 /*
275 * decode the form: SPINUM@IP <tab> ALGONAME:0xsecret
276 */
277
278 USES_APPLE_DEPRECATED_API
279 static int
280 espprint_decode_encalgo(netdissect_options *ndo,
281 char *decode, struct sa_list *sa)
282 {
283 size_t i;
284 const EVP_CIPHER *evp;
285 int authlen = 0;
286 char *colon, *p;
287
288 colon = strchr(decode, ':');
289 if (colon == NULL) {
290 (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode);
291 return 0;
292 }
293 *colon = '\0';
294
295 if (strlen(decode) > strlen("-hmac96") &&
296 !strcmp(decode + strlen(decode) - strlen("-hmac96"),
297 "-hmac96")) {
298 p = strstr(decode, "-hmac96");
299 *p = '\0';
300 authlen = 12;
301 }
302 if (strlen(decode) > strlen("-cbc") &&
303 !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) {
304 p = strstr(decode, "-cbc");
305 *p = '\0';
306 }
307 evp = EVP_get_cipherbyname(decode);
308
309 if (!evp) {
310 (*ndo->ndo_warning)(ndo, "failed to find cipher algo %s\n", decode);
311 sa->evp = NULL;
312 sa->authlen = 0;
313 sa->ivlen = 0;
314 return 0;
315 }
316
317 sa->evp = evp;
318 sa->authlen = authlen;
319 sa->ivlen = EVP_CIPHER_iv_length(evp);
320
321 colon++;
322 if (colon[0] == '0' && colon[1] == 'x') {
323 /* decode some hex! */
324
325 colon += 2;
326 sa->secretlen = espprint_decode_hex(ndo, sa->secret, sizeof(sa->secret), colon);
327 if(sa->secretlen == 0) return 0;
328 } else {
329 i = strlen(colon);
330
331 if (i < sizeof(sa->secret)) {
332 memcpy(sa->secret, colon, i);
333 sa->secretlen = i;
334 } else {
335 memcpy(sa->secret, colon, sizeof(sa->secret));
336 sa->secretlen = sizeof(sa->secret);
337 }
338 }
339
340 return 1;
341 }
342 USES_APPLE_RST
343
344 /*
345 * for the moment, ignore the auth algorith, just hard code the authenticator
346 * length. Need to research how openssl looks up HMAC stuff.
347 */
348 static int
349 espprint_decode_authalgo(netdissect_options *ndo,
350 char *decode, struct sa_list *sa)
351 {
352 char *colon;
353
354 colon = strchr(decode, ':');
355 if (colon == NULL) {
356 (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode);
357 return 0;
358 }
359 *colon = '\0';
360
361 if(ascii_strcasecmp(colon,"sha1") == 0 ||
362 ascii_strcasecmp(colon,"md5") == 0) {
363 sa->authlen = 12;
364 }
365 return 1;
366 }
367
368 static void esp_print_decode_ikeline(netdissect_options *ndo, char *line,
369 const char *file, int lineno)
370 {
371 /* it's an IKEv2 secret, store it instead */
372 struct sa_list sa1;
373
374 char *init;
375 char *icookie, *rcookie;
376 int ilen, rlen;
377 char *authkey;
378 char *enckey;
379
380 init = strsep(&line, " \t");
381 icookie = strsep(&line, " \t");
382 rcookie = strsep(&line, " \t");
383 authkey = strsep(&line, " \t");
384 enckey = strsep(&line, " \t");
385
386 /* if any fields are missing */
387 if(!init || !icookie || !rcookie || !authkey || !enckey) {
388 (*ndo->ndo_warning)(ndo, "print_esp: failed to find all fields for ikev2 at %s:%u",
389 file, lineno);
390
391 return;
392 }
393
394 ilen = strlen(icookie);
395 rlen = strlen(rcookie);
396
397 if((init[0]!='I' && init[0]!='R')
398 || icookie[0]!='0' || icookie[1]!='x'
399 || rcookie[0]!='0' || rcookie[1]!='x'
400 || ilen!=18
401 || rlen!=18) {
402 (*ndo->ndo_warning)(ndo, "print_esp: line %s:%u improperly formatted.",
403 file, lineno);
404
405 (*ndo->ndo_warning)(ndo, "init=%s icookie=%s(%u) rcookie=%s(%u)",
406 init, icookie, ilen, rcookie, rlen);
407
408 return;
409 }
410
411 sa1.spi = 0;
412 sa1.initiator = (init[0] == 'I');
413 if(espprint_decode_hex(ndo, sa1.spii, sizeof(sa1.spii), icookie+2)!=8)
414 return;
415
416 if(espprint_decode_hex(ndo, sa1.spir, sizeof(sa1.spir), rcookie+2)!=8)
417 return;
418
419 if(!espprint_decode_encalgo(ndo, enckey, &sa1)) return;
420
421 if(!espprint_decode_authalgo(ndo, authkey, &sa1)) return;
422
423 esp_print_addsa(ndo, &sa1, FALSE);
424 }
425
426 /*
427 *
428 * special form: file /name
429 * causes us to go read from this file instead.
430 *
431 */
432 static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
433 const char *file, int lineno)
434 {
435 struct sa_list sa1;
436 int sa_def;
437
438 char *spikey;
439 char *decode;
440
441 spikey = strsep(&line, " \t");
442 sa_def = 0;
443 memset(&sa1, 0, sizeof(struct sa_list));
444
445 /* if there is only one token, then it is an algo:key token */
446 if (line == NULL) {
447 decode = spikey;
448 spikey = NULL;
449 /* sa1.daddr.version = 0; */
450 /* memset(&sa1.daddr, 0, sizeof(sa1.daddr)); */
451 /* sa1.spi = 0; */
452 sa_def = 1;
453 } else
454 decode = line;
455
456 if (spikey && ascii_strcasecmp(spikey, "file") == 0) {
457 /* open file and read it */
458 FILE *secretfile;
459 char fileline[1024];
460 int subfile_lineno=0;
461 char *nl;
462 char *filename = line;
463
464 secretfile = fopen(filename, FOPEN_READ_TXT);
465 if (secretfile == NULL) {
466 perror(filename);
467 exit(3);
468 }
469
470 while (fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) {
471 subfile_lineno++;
472 /* remove newline from the line */
473 nl = strchr(fileline, '\n');
474 if (nl)
475 *nl = '\0';
476 if (fileline[0] == '#') continue;
477 if (fileline[0] == '\0') continue;
478
479 esp_print_decode_onesecret(ndo, fileline, filename, subfile_lineno);
480 }
481 fclose(secretfile);
482
483 return;
484 }
485
486 if (spikey && ascii_strcasecmp(spikey, "ikev2") == 0) {
487 esp_print_decode_ikeline(ndo, line, file, lineno);
488 return;
489 }
490
491 if (spikey) {
492
493 char *spistr, *foo;
494 uint32_t spino;
495
496 spistr = strsep(&spikey, "@");
497
498 spino = strtoul(spistr, &foo, 0);
499 if (spistr == foo || !spikey) {
500 (*ndo->ndo_warning)(ndo, "print_esp: failed to decode spi# %s\n", foo);
501 return;
502 }
503
504 sa1.spi = spino;
505
506 if (strtoaddr6(spikey, &sa1.daddr.in6) == 1) {
507 sa1.daddr_version = 6;
508 } else if (strtoaddr(spikey, &sa1.daddr.in4) == 1) {
509 sa1.daddr_version = 4;
510 } else {
511 (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
512 return;
513 }
514 }
515
516 if (decode) {
517 /* skip any blank spaces */
518 while (isspace((unsigned char)*decode))
519 decode++;
520
521 if(!espprint_decode_encalgo(ndo, decode, &sa1)) {
522 return;
523 }
524 }
525
526 esp_print_addsa(ndo, &sa1, sa_def);
527 }
528
529 USES_APPLE_DEPRECATED_API
530 static void esp_init(netdissect_options *ndo _U_)
531 {
532
533 OpenSSL_add_all_algorithms();
534 EVP_add_cipher_alias(SN_des_ede3_cbc, "3des");
535 }
536 USES_APPLE_RST
537
538 void esp_print_decodesecret(netdissect_options *ndo)
539 {
540 char *line;
541 char *p;
542 static int initialized = 0;
543
544 if (!initialized) {
545 esp_init(ndo);
546 initialized = 1;
547 }
548
549 p = ndo->ndo_espsecret;
550
551 while (p && p[0] != '\0') {
552 /* pick out the first line or first thing until a comma */
553 if ((line = strsep(&p, "\n,")) == NULL) {
554 line = p;
555 p = NULL;
556 }
557
558 esp_print_decode_onesecret(ndo, line, "cmdline", 0);
559 }
560
561 ndo->ndo_espsecret = NULL;
562 }
563
564 #endif
565
566 #ifdef HAVE_LIBCRYPTO
567 USES_APPLE_DEPRECATED_API
568 #endif
569 int
570 esp_print(netdissect_options *ndo,
571 const u_char *bp, const int length, const u_char *bp2
572 #ifndef HAVE_LIBCRYPTO
573 _U_
574 #endif
575 ,
576 int *nhdr
577 #ifndef HAVE_LIBCRYPTO
578 _U_
579 #endif
580 ,
581 int *padlen
582 #ifndef HAVE_LIBCRYPTO
583 _U_
584 #endif
585 )
586 {
587 register const struct newesp *esp;
588 register const u_char *ep;
589 #ifdef HAVE_LIBCRYPTO
590 const struct ip *ip;
591 struct sa_list *sa = NULL;
592 const struct ip6_hdr *ip6 = NULL;
593 int advance;
594 int len;
595 u_char *secret;
596 int ivlen = 0;
597 const u_char *ivoff;
598 const u_char *p;
599 EVP_CIPHER_CTX *ctx;
600 #endif
601
602 esp = (const struct newesp *)bp;
603
604 #ifdef HAVE_LIBCRYPTO
605 secret = NULL;
606 advance = 0;
607 #endif
608
609 #if 0
610 /* keep secret out of a register */
611 p = (u_char *)&secret;
612 #endif
613
614 /* 'ep' points to the end of available data. */
615 ep = ndo->ndo_snapend;
616
617 if ((const u_char *)(esp + 1) >= ep) {
618 ND_PRINT((ndo, "[|ESP]"));
619 goto fail;
620 }
621 ND_PRINT((ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi)));
622 ND_PRINT((ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq)));
623 ND_PRINT((ndo, ", length %u", length));
624
625 #ifndef HAVE_LIBCRYPTO
626 goto fail;
627 #else
628 /* initiailize SAs */
629 if (ndo->ndo_sa_list_head == NULL) {
630 if (!ndo->ndo_espsecret)
631 goto fail;
632
633 esp_print_decodesecret(ndo);
634 }
635
636 if (ndo->ndo_sa_list_head == NULL)
637 goto fail;
638
639 ip = (const struct ip *)bp2;
640 switch (IP_V(ip)) {
641 case 6:
642 ip6 = (const struct ip6_hdr *)bp2;
643 /* we do not attempt to decrypt jumbograms */
644 if (!EXTRACT_16BITS(&ip6->ip6_plen))
645 goto fail;
646 /* if we can't get nexthdr, we do not need to decrypt it */
647 len = sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen);
648
649 /* see if we can find the SA, and if so, decode it */
650 for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
651 if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
652 sa->daddr_version == 6 &&
653 UNALIGNED_MEMCMP(&sa->daddr.in6, &ip6->ip6_dst,
654 sizeof(struct in6_addr)) == 0) {
655 break;
656 }
657 }
658 break;
659 case 4:
660 /* nexthdr & padding are in the last fragment */
661 if (EXTRACT_16BITS(&ip->ip_off) & IP_MF)
662 goto fail;
663 len = EXTRACT_16BITS(&ip->ip_len);
664
665 /* see if we can find the SA, and if so, decode it */
666 for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
667 if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
668 sa->daddr_version == 4 &&
669 UNALIGNED_MEMCMP(&sa->daddr.in4, &ip->ip_dst,
670 sizeof(struct in_addr)) == 0) {
671 break;
672 }
673 }
674 break;
675 default:
676 goto fail;
677 }
678
679 /* if we didn't find the specific one, then look for
680 * an unspecified one.
681 */
682 if (sa == NULL)
683 sa = ndo->ndo_sa_default;
684
685 /* if not found fail */
686 if (sa == NULL)
687 goto fail;
688
689 /* if we can't get nexthdr, we do not need to decrypt it */
690 if (ep - bp2 < len)
691 goto fail;
692 if (ep - bp2 > len) {
693 /* FCS included at end of frame (NetBSD 1.6 or later) */
694 ep = bp2 + len;
695 }
696
697 ivoff = (const u_char *)(esp + 1) + 0;
698 ivlen = sa->ivlen;
699 secret = sa->secret;
700 ep = ep - sa->authlen;
701
702 if (sa->evp) {
703 ctx = EVP_CIPHER_CTX_new();
704 if (ctx != NULL) {
705 if (EVP_CipherInit(ctx, sa->evp, secret, NULL, 0) < 0)
706 (*ndo->ndo_warning)(ndo, "espkey init failed");
707
708 p = ivoff;
709 EVP_CipherInit(ctx, NULL, NULL, p, 0);
710 EVP_Cipher(ctx, p + ivlen, p + ivlen, ep - (p + ivlen));
711 EVP_CIPHER_CTX_free(ctx);
712 advance = ivoff - (const u_char *)esp + ivlen;
713 } else
714 advance = sizeof(struct newesp);
715 } else
716 advance = sizeof(struct newesp);
717
718 /* sanity check for pad length */
719 if (ep - bp < *(ep - 2))
720 goto fail;
721
722 if (padlen)
723 *padlen = *(ep - 2) + 2;
724
725 if (nhdr)
726 *nhdr = *(ep - 1);
727
728 ND_PRINT((ndo, ": "));
729 return advance;
730 #endif
731
732 fail:
733 return -1;
734 }
735 #ifdef HAVE_LIBCRYPTO
736 USES_APPLE_RST
737 #endif
738
739 /*
740 * Local Variables:
741 * c-style: whitesmith
742 * c-basic-offset: 8
743 * End:
744 */