2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * Copyright (C) 1990 by the Massachusetts Institute of Technology
37 * Export of this software from the United States of America is assumed
38 * to require a specific license from the United States Government.
39 * It is the responsibility of any person or organization contemplating
40 * export to obtain such a license before exporting.
42 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
43 * distribute this software and its documentation for any purpose and
44 * without fee is hereby granted, provided that the above copyright
45 * notice appear in all copies and that both that copyright notice and
46 * this permission notice appear in supporting documentation, and that
47 * the name of M.I.T. not be used in advertising or publicity pertaining
48 * to distribution of the software without specific, written prior
49 * permission. M.I.T. makes no representations about the suitability of
50 * this software for any purpose. It is provided "as is" without express
51 * or implied warranty.
57 __RCSID("$Heimdal: encrypt.c 16802 2006-03-23 19:36:31Z lha $"
60 #if defined(ENCRYPTION)
63 #include <arpa/telnet.h>
78 * These functions pointers point to the current routines
79 * for encrypting and decrypting data.
81 void (*encrypt_output
) (unsigned char *, int);
82 int (*decrypt_input
) (int);
85 int encrypt_debug_mode
= 0;
86 static int decrypt_mode
= 0;
87 static int encrypt_mode
= 0;
88 static int encrypt_verbose
= 0;
89 static int autoencrypt
= 0;
90 static int autodecrypt
= 0;
91 static int havesessionkey
= 0;
92 static int Server
= 0;
93 static const char *Name
= "Noname";
95 #define typemask(x) ((x) > 0 ? 1 << ((x)-1) : 0)
97 static long i_support_encrypt
= typemask(ENCTYPE_DES_CFB64
)
98 | typemask(ENCTYPE_DES_OFB64
);
99 static long i_support_decrypt
= typemask(ENCTYPE_DES_CFB64
)
100 | typemask(ENCTYPE_DES_OFB64
);
101 static long i_wont_support_encrypt
= 0;
102 static long i_wont_support_decrypt
= 0;
103 #define I_SUPPORT_ENCRYPT (i_support_encrypt & ~i_wont_support_encrypt)
104 #define I_SUPPORT_DECRYPT (i_support_decrypt & ~i_wont_support_decrypt)
106 static long remote_supports_encrypt
= 0;
107 static long remote_supports_decrypt
= 0;
109 static Encryptions encryptions
[] = {
110 #if defined(DES_ENCRYPTION)
111 { "DES_CFB64", ENCTYPE_DES_CFB64
,
121 { "DES_OFB64", ENCTYPE_DES_OFB64
,
135 static unsigned char str_send
[64] = { IAC
, SB
, TELOPT_ENCRYPT
,
137 static unsigned char str_suplen
= 0;
138 static unsigned char str_start
[72] = { IAC
, SB
, TELOPT_ENCRYPT
};
139 static unsigned char str_end
[] = { IAC
, SB
, TELOPT_ENCRYPT
, 0, IAC
, SE
};
142 findencryption(int type
)
144 Encryptions
*ep
= encryptions
;
146 if (!(I_SUPPORT_ENCRYPT
& remote_supports_decrypt
& typemask(type
)))
148 while (ep
->type
&& ep
->type
!= type
)
150 return(ep
->type
? ep
: 0);
154 finddecryption(int type
)
156 Encryptions
*ep
= encryptions
;
158 if (!(I_SUPPORT_DECRYPT
& remote_supports_encrypt
& typemask(type
)))
160 while (ep
->type
&& ep
->type
!= type
)
162 return(ep
->type
? ep
: 0);
167 static struct key_info
{
168 unsigned char keyid
[MAXKEYLEN
];
172 Encryptions
*(*getcrypt
)();
174 { { 0 }, 0, DIR_ENCRYPT
, &encrypt_mode
, findencryption
},
175 { { 0 }, 0, DIR_DECRYPT
, &decrypt_mode
, finddecryption
},
179 encrypt_init(const char *name
, int server
)
181 Encryptions
*ep
= encryptions
;
185 i_support_encrypt
= i_support_decrypt
= 0;
186 remote_supports_encrypt
= remote_supports_decrypt
= 0;
192 encrypt_verbose
= !server
;
198 if (encrypt_debug_mode
)
199 printf(">>>%s: I will support %s\r\n",
200 Name
, ENCTYPE_NAME(ep
->type
));
201 i_support_encrypt
|= typemask(ep
->type
);
202 i_support_decrypt
|= typemask(ep
->type
);
203 if ((i_wont_support_decrypt
& typemask(ep
->type
)) == 0)
204 if ((str_send
[str_suplen
++] = ep
->type
) == IAC
)
205 str_send
[str_suplen
++] = IAC
;
210 str_send
[str_suplen
++] = IAC
;
211 str_send
[str_suplen
++] = SE
;
215 encrypt_list_types(void)
217 Encryptions
*ep
= encryptions
;
219 printf("Valid encryption types:\n");
221 printf("\t%s (%d)\r\n", ENCTYPE_NAME(ep
->type
), ep
->type
);
227 EncryptEnable(char *type
, char *mode
)
229 if (isprefix(type
, "help") || isprefix(type
, "?")) {
230 printf("Usage: encrypt enable <type> [input|output]\n");
231 encrypt_list_types();
234 if (EncryptType(type
, mode
))
235 return(EncryptStart(mode
));
240 EncryptDisable(char *type
, char *mode
)
245 if (isprefix(type
, "help") || isprefix(type
, "?")) {
246 printf("Usage: encrypt disable <type> [input|output]\n");
247 encrypt_list_types();
248 } else if ((ep
= (Encryptions
*)genget(type
, (char**)encryptions
,
249 sizeof(Encryptions
))) == 0) {
250 printf("%s: invalid encryption type\n", type
);
251 } else if (Ambiguous(ep
)) {
252 printf("Ambiguous type '%s'\n", type
);
254 if ((mode
== 0) || (isprefix(mode
, "input") ? 1 : 0)) {
255 if (decrypt_mode
== ep
->type
)
257 i_wont_support_decrypt
|= typemask(ep
->type
);
260 if ((mode
== 0) || (isprefix(mode
, "output"))) {
261 if (encrypt_mode
== ep
->type
)
263 i_wont_support_encrypt
|= typemask(ep
->type
);
267 printf("%s: invalid encryption mode\n", mode
);
273 EncryptType(char *type
, char *mode
)
278 if (isprefix(type
, "help") || isprefix(type
, "?")) {
279 printf("Usage: encrypt type <type> [input|output]\n");
280 encrypt_list_types();
281 } else if ((ep
= (Encryptions
*)genget(type
, (char**)encryptions
,
282 sizeof(Encryptions
))) == 0) {
283 printf("%s: invalid encryption type\n", type
);
284 } else if (Ambiguous(ep
)) {
285 printf("Ambiguous type '%s'\n", type
);
287 if ((mode
== 0) || isprefix(mode
, "input")) {
288 decrypt_mode
= ep
->type
;
289 i_wont_support_decrypt
&= ~typemask(ep
->type
);
292 if ((mode
== 0) || isprefix(mode
, "output")) {
293 encrypt_mode
= ep
->type
;
294 i_wont_support_encrypt
&= ~typemask(ep
->type
);
298 printf("%s: invalid encryption mode\n", mode
);
304 EncryptStart(char *mode
)
308 if (isprefix(mode
, "input"))
309 return(EncryptStartInput());
310 if (isprefix(mode
, "output"))
311 return(EncryptStartOutput());
312 if (isprefix(mode
, "help") || isprefix(mode
, "?")) {
313 printf("Usage: encrypt start [input|output]\n");
316 printf("%s: invalid encryption mode 'encrypt start ?' for help\n", mode
);
319 ret
+= EncryptStartInput();
320 ret
+= EncryptStartOutput();
325 EncryptStartInput(void)
328 encrypt_send_request_start();
331 printf("No previous decryption mode, decryption not enabled\r\n");
336 EncryptStartOutput(void)
339 encrypt_start_output(encrypt_mode
);
342 printf("No previous encryption mode, encryption not enabled\r\n");
347 EncryptStop(char *mode
)
351 if (isprefix(mode
, "input"))
352 return(EncryptStopInput());
353 if (isprefix(mode
, "output"))
354 return(EncryptStopOutput());
355 if (isprefix(mode
, "help") || isprefix(mode
, "?")) {
356 printf("Usage: encrypt stop [input|output]\n");
359 printf("%s: invalid encryption mode 'encrypt stop ?' for help\n", mode
);
362 ret
+= EncryptStopInput();
363 ret
+= EncryptStopOutput();
368 EncryptStopInput(void)
370 encrypt_send_request_end();
375 EncryptStopOutput(void)
382 encrypt_display(void)
384 printf("Autoencrypt for output is %s. Autodecrypt for input is %s.\r\n",
385 autoencrypt
?"on":"off", autodecrypt
?"on":"off");
388 printf("Currently encrypting output with %s\r\n",
389 ENCTYPE_NAME(encrypt_mode
));
391 printf("Currently not encrypting output\r\n");
394 printf("Currently decrypting input with %s\r\n",
395 ENCTYPE_NAME(decrypt_mode
));
397 printf("Currently not decrypting input\r\n");
403 printf("Autoencrypt for output is %s. Autodecrypt for input is %s.\r\n",
404 autoencrypt
?"on":"off", autodecrypt
?"on":"off");
407 printf("Currently encrypting output with %s\r\n",
408 ENCTYPE_NAME(encrypt_mode
));
409 else if (encrypt_mode
) {
410 printf("Currently output is clear text.\r\n");
411 printf("Last encryption mode was %s\r\n",
412 ENCTYPE_NAME(encrypt_mode
));
414 printf("Currently not encrypting output\r\n");
417 printf("Currently decrypting input with %s\r\n",
418 ENCTYPE_NAME(decrypt_mode
));
419 } else if (decrypt_mode
) {
420 printf("Currently input is clear text.\r\n");
421 printf("Last decryption mode was %s\r\n",
422 ENCTYPE_NAME(decrypt_mode
));
424 printf("Currently not decrypting input\r\n");
430 encrypt_send_support(void)
434 * If the user has requested that decryption start
435 * immediatly, then send a "REQUEST START" before
436 * we negotiate the type.
438 if (!Server
&& autodecrypt
)
439 encrypt_send_request_start();
440 telnet_net_write(str_send
, str_suplen
);
441 printsub('>', &str_send
[2], str_suplen
- 2);
450 encrypt_debug_mode
^= 1;
452 encrypt_debug_mode
= on
;
453 printf("Encryption debugging %s\r\n",
454 encrypt_debug_mode
? "enabled" : "disabled");
458 /* turn on verbose encryption, but dont keep telling the whole world
460 void encrypt_verbose_quiet(int on
)
463 encrypt_verbose
^= 1;
465 encrypt_verbose
= on
? 1 : 0;
469 EncryptVerbose(int on
)
471 encrypt_verbose_quiet(on
);
472 printf("Encryption %s verbose\r\n",
473 encrypt_verbose
? "is" : "is not");
478 EncryptAutoEnc(int on
)
481 printf("Automatic encryption of output is %s\r\n",
482 autoencrypt
? "enabled" : "disabled");
487 EncryptAutoDec(int on
)
490 printf("Automatic decryption of input is %s\r\n",
491 autodecrypt
? "enabled" : "disabled");
495 /* Called when we receive a WONT or a DONT ENCRYPT after we sent a DO
501 printf("[ Connection is NOT encrypted ]\r\n");
503 printf("\r\n*** Connection not encrypted! "
504 "Communication may be eavesdropped. ***\r\n");
508 * Called when ENCRYPT SUPPORT is received.
511 encrypt_support(unsigned char *typelist
, int cnt
)
513 int type
, use_type
= 0;
517 * Forget anything the other side has previously told us.
519 remote_supports_decrypt
= 0;
523 if (encrypt_debug_mode
)
524 printf(">>>%s: He is supporting %s (%d)\r\n",
526 ENCTYPE_NAME(type
), type
);
527 if ((type
< ENCTYPE_CNT
) &&
528 (I_SUPPORT_ENCRYPT
& typemask(type
))) {
529 remote_supports_decrypt
|= typemask(type
);
535 ep
= findencryption(use_type
);
538 type
= ep
->start
? (*ep
->start
)(DIR_ENCRYPT
, Server
) : 0;
539 if (encrypt_debug_mode
)
540 printf(">>>%s: (*ep->start)() returned %d\r\n",
544 encrypt_mode
= use_type
;
546 encrypt_start_output(use_type
);
551 encrypt_is(unsigned char *data
, int cnt
)
559 if (type
< ENCTYPE_CNT
)
560 remote_supports_encrypt
|= typemask(type
);
561 if (!(ep
= finddecryption(type
))) {
562 if (encrypt_debug_mode
)
563 printf(">>>%s: Can't find type %s (%d) for initial negotiation\r\n",
565 ENCTYPE_NAME_OK(type
)
566 ? ENCTYPE_NAME(type
) : "(unknown)",
571 if (encrypt_debug_mode
)
572 printf(">>>%s: No initial negotiation needed for type %s (%d)\r\n",
574 ENCTYPE_NAME_OK(type
)
575 ? ENCTYPE_NAME(type
) : "(unknown)",
579 ret
= (*ep
->is
)(data
, cnt
);
580 if (encrypt_debug_mode
)
581 printf("(*ep->is)(%p, %d) returned %s(%d)\n", data
, cnt
,
582 (ret
< 0) ? "FAIL " :
583 (ret
== 0) ? "SUCCESS " : "MORE_TO_DO ", ret
);
589 if (ret
== 0 && autodecrypt
)
590 encrypt_send_request_start();
595 encrypt_reply(unsigned char *data
, int cnt
)
603 if (!(ep
= findencryption(type
))) {
604 if (encrypt_debug_mode
)
605 printf(">>>%s: Can't find type %s (%d) for initial negotiation\r\n",
607 ENCTYPE_NAME_OK(type
)
608 ? ENCTYPE_NAME(type
) : "(unknown)",
613 if (encrypt_debug_mode
)
614 printf(">>>%s: No initial negotiation needed for type %s (%d)\r\n",
616 ENCTYPE_NAME_OK(type
)
617 ? ENCTYPE_NAME(type
) : "(unknown)",
621 ret
= (*ep
->reply
)(data
, cnt
);
622 if (encrypt_debug_mode
)
623 printf("(*ep->reply)(%p, %d) returned %s(%d)\n",
625 (ret
< 0) ? "FAIL " :
626 (ret
== 0) ? "SUCCESS " : "MORE_TO_DO ", ret
);
628 if (encrypt_debug_mode
)
629 printf(">>>%s: encrypt_reply returned %d\n", Name
, ret
);
634 if (ret
== 0 && autoencrypt
)
635 encrypt_start_output(type
);
640 * Called when ENCRYPT START is received.
643 encrypt_start(unsigned char *data
, int cnt
)
649 * Something is wrong. We should not get a START
650 * command without having already picked our
651 * decryption scheme. Send a REQUEST-END to
652 * attempt to clear the channel...
654 printf("%s: Warning, Cannot decrypt input stream!!!\r\n", Name
);
655 encrypt_send_request_end();
659 if ((ep
= finddecryption(decrypt_mode
))) {
660 decrypt_input
= ep
->input
;
662 printf("[ Input is now decrypted with type %s ]\r\n",
663 ENCTYPE_NAME(decrypt_mode
));
664 if (encrypt_debug_mode
)
665 printf(">>>%s: Start to decrypt input with type %s\r\n",
666 Name
, ENCTYPE_NAME(decrypt_mode
));
668 printf("%s: Warning, Cannot decrypt type %s (%d)!!!\r\n",
670 ENCTYPE_NAME_OK(decrypt_mode
)
671 ? ENCTYPE_NAME(decrypt_mode
)
674 encrypt_send_request_end();
679 encrypt_session_key(Session_Key
*key
, int server
)
681 Encryptions
*ep
= encryptions
;
687 (*ep
->session
)(key
, server
);
693 * Called when ENCRYPT END is received.
699 if (encrypt_debug_mode
)
700 printf(">>>%s: Input is back to clear text\r\n", Name
);
702 printf("[ Input is now clear text ]\r\n");
706 * Called when ENCRYPT REQUEST-END is received.
709 encrypt_request_end(void)
715 * Called when ENCRYPT REQUEST-START is received. If we receive
716 * this before a type is picked, then that indicates that the
717 * other side wants us to start encrypting data as soon as we
721 encrypt_request_start(unsigned char *data
, int cnt
)
723 if (encrypt_mode
== 0) {
728 encrypt_start_output(encrypt_mode
);
731 static unsigned char str_keyid
[(MAXKEYLEN
*2)+5] = { IAC
, SB
, TELOPT_ENCRYPT
};
734 encrypt_keyid(struct key_info
*kp
, unsigned char *keyid
, int len
)
740 if (!(ep
= (*kp
->getcrypt
)(*kp
->modep
))) {
744 } else if (len
== 0) {
746 * Empty option, indicates a failure.
752 (void)(*ep
->keyid
)(dir
, kp
->keyid
, &kp
->keylen
);
754 } else if ((len
!= kp
->keylen
) || (memcmp(keyid
,kp
->keyid
,len
) != 0)) {
756 * Length or contents are different
759 memcpy(kp
->keyid
,keyid
, len
);
761 (void)(*ep
->keyid
)(dir
, kp
->keyid
, &kp
->keylen
);
764 ret
= (*ep
->keyid
)(dir
, kp
->keyid
, &kp
->keylen
);
765 if ((ret
== 0) && (dir
== DIR_ENCRYPT
) && autoencrypt
)
766 encrypt_start_output(*kp
->modep
);
770 encrypt_send_keyid(dir
, kp
->keyid
, kp
->keylen
, 0);
773 void encrypt_enc_keyid(unsigned char *keyid
, int len
)
775 encrypt_keyid(&ki
[1], keyid
, len
);
778 void encrypt_dec_keyid(unsigned char *keyid
, int len
)
780 encrypt_keyid(&ki
[0], keyid
, len
);
784 void encrypt_send_keyid(int dir
, unsigned char *keyid
, int keylen
, int saveit
)
788 str_keyid
[3] = (dir
== DIR_ENCRYPT
)
789 ? ENCRYPT_ENC_KEYID
: ENCRYPT_DEC_KEYID
;
791 struct key_info
*kp
= &ki
[(dir
== DIR_ENCRYPT
) ? 0 : 1];
792 memcpy(kp
->keyid
,keyid
, keylen
);
796 for (strp
= &str_keyid
[4]; keylen
> 0; --keylen
) {
797 if ((*strp
++ = *keyid
++) == IAC
)
802 telnet_net_write(str_keyid
, strp
- str_keyid
);
803 printsub('>', &str_keyid
[2], strp
- str_keyid
- 2);
812 autoencrypt
= on
? 1 : 0;
821 autodecrypt
= on
? 1 : 0;
825 encrypt_start_output(int type
)
831 if (!(ep
= findencryption(type
))) {
832 if (encrypt_debug_mode
) {
833 printf(">>>%s: Can't encrypt with type %s (%d)\r\n",
835 ENCTYPE_NAME_OK(type
)
836 ? ENCTYPE_NAME(type
) : "(unknown)",
842 i
= (*ep
->start
)(DIR_ENCRYPT
, Server
);
843 if (encrypt_debug_mode
) {
844 printf(">>>%s: Encrypt start: %s (%d) %s\r\n",
847 "initial negotiation in progress",
848 i
, ENCTYPE_NAME(type
));
854 *p
++ = ENCRYPT_START
;
855 for (i
= 0; i
< ki
[0].keylen
; ++i
) {
856 if ((*p
++ = ki
[0].keyid
[i
]) == IAC
)
861 telnet_net_write(str_start
, p
- str_start
);
863 printsub('>', &str_start
[2], p
- &str_start
[2]);
865 * If we are already encrypting in some mode, then
866 * encrypt the ring (which includes our request) in
867 * the old mode, mark it all as "clear text" and then
868 * switch to the new mode.
870 encrypt_output
= ep
->output
;
872 if (encrypt_debug_mode
)
873 printf(">>>%s: Started to encrypt output with type %s\r\n",
874 Name
, ENCTYPE_NAME(type
));
876 printf("[ Output is now encrypted with type %s ]\r\n",
881 encrypt_send_end(void)
886 str_end
[3] = ENCRYPT_END
;
887 telnet_net_write(str_end
, sizeof(str_end
));
889 printsub('>', &str_end
[2], sizeof(str_end
) - 2);
891 * Encrypt the output buffer now because it will not be done by
895 if (encrypt_debug_mode
)
896 printf(">>>%s: Output is back to clear text\r\n", Name
);
898 printf("[ Output is now clear text ]\r\n");
902 encrypt_send_request_start(void)
908 *p
++ = ENCRYPT_REQSTART
;
909 for (i
= 0; i
< ki
[1].keylen
; ++i
) {
910 if ((*p
++ = ki
[1].keyid
[i
]) == IAC
)
915 telnet_net_write(str_start
, p
- str_start
);
916 printsub('>', &str_start
[2], p
- &str_start
[2]);
917 if (encrypt_debug_mode
)
918 printf(">>>%s: Request input to be encrypted\r\n", Name
);
922 encrypt_send_request_end(void)
924 str_end
[3] = ENCRYPT_REQEND
;
925 telnet_net_write(str_end
, sizeof(str_end
));
926 printsub('>', &str_end
[2], sizeof(str_end
) - 2);
928 if (encrypt_debug_mode
)
929 printf(">>>%s: Request input to be clear text\r\n", Name
);
933 void encrypt_wait(void)
935 if (encrypt_debug_mode
)
936 printf(">>>%s: in encrypt_wait\r\n", Name
);
937 if (!havesessionkey
|| !(I_SUPPORT_ENCRYPT
& remote_supports_decrypt
))
939 while (autoencrypt
&& !encrypt_output
)
947 if(!havesessionkey
||
948 (I_SUPPORT_ENCRYPT
& remote_supports_decrypt
) == 0 ||
949 (I_SUPPORT_DECRYPT
& remote_supports_encrypt
) == 0)
951 if(!(encrypt_output
&& decrypt_input
))
956 int encrypt_is_encrypting()
958 if (encrypt_output
&& decrypt_input
)
964 encrypt_debug(int mode
)
966 encrypt_debug_mode
= mode
;
969 void encrypt_gen_printsub(unsigned char *data
, int cnt
,
970 unsigned char *buf
, int buflen
)
976 buf
[buflen
-1] = '\0';
979 for (; cnt
> 0; cnt
--, data
++) {
980 snprintf(tbuf
, sizeof(tbuf
), " %d", *data
);
981 for (cp
= tbuf
; *cp
&& buflen
> 0; --buflen
)
990 encrypt_printsub(unsigned char *data
, int cnt
, unsigned char *buf
, int buflen
)
995 for (ep
= encryptions
; ep
->type
&& ep
->type
!= type
; ep
++)
999 (*ep
->printsub
)(data
, cnt
, buf
, buflen
);
1001 encrypt_gen_printsub(data
, cnt
, buf
, buflen
);