1 /* $Id: algorithm.c,v 1.11.4.1 2005/06/28 22:38:02 manubsd Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/param.h>
35 #include <sys/types.h>
44 #include "crypto_openssl.h"
46 #include "algorithm.h"
48 #include "isakmp_var.h"
50 #include "ipsec_doi.h"
53 static struct hash_algorithm oakley_hashdef
[] = {
54 { "md5", algtype_md5
, OAKLEY_ATTR_HASH_ALG_MD5
,
55 eay_md5_init
, eay_md5_update
,
56 eay_md5_final
, eay_md5_hashlen
,
58 { "sha1", algtype_sha1
, OAKLEY_ATTR_HASH_ALG_SHA
,
59 eay_sha1_init
, eay_sha1_update
,
60 eay_sha1_final
, eay_sha1_hashlen
,
63 { "sha2_256", algtype_sha2_256
, OAKLEY_ATTR_HASH_ALG_SHA2_256
,
64 eay_sha2_256_init
, eay_sha2_256_update
,
65 eay_sha2_256_final
, eay_sha2_256_hashlen
,
67 { "sha2_384", algtype_sha2_384
, OAKLEY_ATTR_HASH_ALG_SHA2_384
,
68 eay_sha2_384_init
, eay_sha2_384_update
,
69 eay_sha2_384_final
, eay_sha2_384_hashlen
,
71 { "sha2_512", algtype_sha2_512
, OAKLEY_ATTR_HASH_ALG_SHA2_512
,
72 eay_sha2_512_init
, eay_sha2_512_update
,
73 eay_sha2_512_final
, eay_sha2_512_hashlen
,
78 static struct hmac_algorithm oakley_hmacdef
[] = {
79 { "hmac_md5", algtype_md5
, OAKLEY_ATTR_HASH_ALG_MD5
,
80 eay_hmacmd5_init
, eay_hmacmd5_update
,
81 eay_hmacmd5_final
, NULL
,
83 { "hmac_sha1", algtype_sha1
, OAKLEY_ATTR_HASH_ALG_SHA
,
84 eay_hmacsha1_init
, eay_hmacsha1_update
,
85 eay_hmacsha1_final
, NULL
,
88 { "hmac_sha2_256", algtype_sha2_256
, OAKLEY_ATTR_HASH_ALG_SHA2_256
,
89 eay_hmacsha2_256_init
, eay_hmacsha2_256_update
,
90 eay_hmacsha2_256_final
, NULL
,
91 eay_hmacsha2_256_one
, },
92 { "hmac_sha2_384", algtype_sha2_384
, OAKLEY_ATTR_HASH_ALG_SHA2_384
,
93 eay_hmacsha2_384_init
, eay_hmacsha2_384_update
,
94 eay_hmacsha2_384_final
, NULL
,
95 eay_hmacsha2_384_one
, },
96 { "hmac_sha2_512", algtype_sha2_512
, OAKLEY_ATTR_HASH_ALG_SHA2_512
,
97 eay_hmacsha2_512_init
, eay_hmacsha2_512_update
,
98 eay_hmacsha2_512_final
, NULL
,
99 eay_hmacsha2_512_one
, },
103 static struct enc_algorithm oakley_encdef
[] = {
104 { "des", algtype_des
, OAKLEY_ATTR_ENC_ALG_DES
, 8,
105 eay_des_encrypt
, eay_des_decrypt
,
106 eay_des_weakkey
, eay_des_keylen
, },
107 #ifdef HAVE_OPENSSL_IDEA_H
108 { "idea", algtype_idea
, OAKLEY_ATTR_ENC_ALG_IDEA
, 8,
109 eay_idea_encrypt
, eay_idea_decrypt
,
110 eay_idea_weakkey
, eay_idea_keylen
, },
112 { "blowfish", algtype_blowfish
, OAKLEY_ATTR_ENC_ALG_BLOWFISH
, 8,
113 eay_bf_encrypt
, eay_bf_decrypt
,
114 eay_bf_weakkey
, eay_bf_keylen
, },
115 #ifdef HAVE_OPENSSL_RC5_H
116 { "rc5", algtype_rc5
, OAKLEY_ATTR_ENC_ALG_RC5
, 8,
117 eay_rc5_encrypt
, eay_rc5_decrypt
,
118 eay_rc5_weakkey
, eay_rc5_keylen
, },
120 { "3des", algtype_3des
, OAKLEY_ATTR_ENC_ALG_3DES
, 8,
121 eay_3des_encrypt
, eay_3des_decrypt
,
122 eay_3des_weakkey
, eay_3des_keylen
, },
123 { "cast", algtype_cast128
, OAKLEY_ATTR_ENC_ALG_CAST
, 8,
124 eay_cast_encrypt
, eay_cast_decrypt
,
125 eay_cast_weakkey
, eay_cast_keylen
, },
126 { "aes", algtype_aes
, OAKLEY_ATTR_ENC_ALG_AES
, 16,
127 eay_aes_encrypt
, eay_aes_decrypt
,
128 eay_aes_weakkey
, eay_aes_keylen
, },
131 static struct enc_algorithm ipsec_encdef
[] = {
132 { "des-iv64", algtype_des_iv64
, IPSECDOI_ESP_DES_IV64
, 8,
134 NULL
, eay_des_keylen
, },
135 { "des", algtype_des
, IPSECDOI_ESP_DES
, 8,
137 NULL
, eay_des_keylen
, },
138 { "3des", algtype_3des
, IPSECDOI_ESP_3DES
, 8,
140 NULL
, eay_3des_keylen
, },
141 #ifdef HAVE_OPENSSL_RC5_H
142 { "rc5", algtype_rc5
, IPSECDOI_ESP_RC5
, 8,
144 NULL
, eay_rc5_keylen
, },
146 { "cast", algtype_cast128
, IPSECDOI_ESP_CAST
, 8,
148 NULL
, eay_cast_keylen
, },
149 { "blowfish", algtype_blowfish
, IPSECDOI_ESP_BLOWFISH
, 8,
151 NULL
, eay_bf_keylen
, },
152 { "des-iv32", algtype_des_iv32
, IPSECDOI_ESP_DES_IV32
, 8,
154 NULL
, eay_des_keylen
, },
155 { "null", algtype_null_enc
, IPSECDOI_ESP_NULL
, 8,
157 NULL
, eay_null_keylen
, },
158 { "aes", algtype_aes
, IPSECDOI_ESP_AES
, 16,
160 NULL
, eay_aes_keylen
, },
161 { "twofish", algtype_twofish
, IPSECDOI_ESP_TWOFISH
, 16,
163 NULL
, eay_twofish_keylen
, },
164 #ifdef HAVE_OPENSSL_IDEA_H
165 { "3idea", algtype_3idea
, IPSECDOI_ESP_3IDEA
, 8,
168 { "idea", algtype_idea
, IPSECDOI_ESP_IDEA
, 8,
172 { "rc4", algtype_rc4
, IPSECDOI_ESP_RC4
, 8,
177 static struct hmac_algorithm ipsec_hmacdef
[] = {
178 { "md5", algtype_hmac_md5
, IPSECDOI_ATTR_AUTH_HMAC_MD5
,
180 NULL
, eay_md5_hashlen
,
182 { "sha1", algtype_hmac_sha1
, IPSECDOI_ATTR_AUTH_HMAC_SHA1
,
184 NULL
, eay_sha1_hashlen
,
186 { "kpdk", algtype_kpdk
, IPSECDOI_ATTR_AUTH_KPDK
,
188 NULL
, eay_kpdk_hashlen
,
190 { "null", algtype_non_auth
, IPSECDOI_ATTR_AUTH_NONE
,
192 NULL
, eay_null_hashlen
,
195 { "hmac_sha2_256", algtype_hmac_sha2_256
,IPSECDOI_ATTR_AUTH_HMAC_SHA2_256
,
197 NULL
, eay_sha2_256_hashlen
,
199 { "hmac_sha2_384", algtype_hmac_sha2_384
,IPSECDOI_ATTR_AUTH_HMAC_SHA2_384
,
201 NULL
, eay_sha2_384_hashlen
,
203 { "hmac_sha2_512", algtype_hmac_sha2_512
,IPSECDOI_ATTR_AUTH_HMAC_SHA2_512
,
205 NULL
, eay_sha2_512_hashlen
,
210 static struct misc_algorithm ipsec_compdef
[] = {
211 { "oui", algtype_oui
, IPSECDOI_IPCOMP_OUI
, },
212 { "deflate", algtype_deflate
, IPSECDOI_IPCOMP_DEFLATE
, },
213 { "lzs", algtype_lzs
, IPSECDOI_IPCOMP_LZS
, },
216 static struct misc_algorithm oakley_authdef
[] = {
217 { "pre_shared_key", algtype_psk
, OAKLEY_ATTR_AUTH_METHOD_PSKEY
, },
218 { "dsssig", algtype_dsssig
, OAKLEY_ATTR_AUTH_METHOD_DSSSIG
, },
219 { "rsasig", algtype_rsasig
, OAKLEY_ATTR_AUTH_METHOD_RSASIG
, },
220 { "rsaenc", algtype_rsaenc
, OAKLEY_ATTR_AUTH_METHOD_RSAENC
, },
221 { "rsarev", algtype_rsarev
, OAKLEY_ATTR_AUTH_METHOD_RSAREV
, },
222 { "gssapi_krb", algtype_gssapikrb
, OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
, },
224 { "hybrid_rsa_server", algtype_hybrid_rsa_s
,
225 OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_I
, },
226 { "hybrid_dss_server", algtype_hybrid_dss_s
,
227 OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_I
, },
228 { "hybrid_rsa_client", algtype_hybrid_rsa_c
,
229 OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_R
, },
230 { "hybrid_dss_client", algtype_hybrid_dss_c
,
231 OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_R
, },
235 static struct dh_algorithm oakley_dhdef
[] = {
236 { "modp768", algtype_modp768
, OAKLEY_ATTR_GRP_DESC_MODP768
,
238 { "modp1024", algtype_modp1024
, OAKLEY_ATTR_GRP_DESC_MODP1024
,
240 { "modp1536", algtype_modp1536
, OAKLEY_ATTR_GRP_DESC_MODP1536
,
242 { "modp2048", algtype_modp2048
, OAKLEY_ATTR_GRP_DESC_MODP2048
,
244 { "modp3072", algtype_modp3072
, OAKLEY_ATTR_GRP_DESC_MODP3072
,
246 { "modp4096", algtype_modp4096
, OAKLEY_ATTR_GRP_DESC_MODP4096
,
248 { "modp6144", algtype_modp6144
, OAKLEY_ATTR_GRP_DESC_MODP6144
,
250 { "modp8192", algtype_modp8192
, OAKLEY_ATTR_GRP_DESC_MODP8192
,
254 static struct hash_algorithm
*alg_oakley_hashdef
__P((int));
255 static struct hmac_algorithm
*alg_oakley_hmacdef
__P((int));
256 static struct enc_algorithm
*alg_oakley_encdef
__P((int));
257 static struct enc_algorithm
*alg_ipsec_encdef
__P((int));
258 static struct hmac_algorithm
*alg_ipsec_hmacdef
__P((int));
259 static struct dh_algorithm
*alg_oakley_dhdef
__P((int));
261 /* oakley hash algorithm */
262 static struct hash_algorithm
*
263 alg_oakley_hashdef(doi
)
268 for (i
= 0; i
< ARRAYLEN(oakley_hashdef
); i
++)
269 if (doi
== oakley_hashdef
[i
].doi
) {
270 plog(LLV_DEBUG
, LOCATION
, NULL
, "hash(%s)\n",
271 oakley_hashdef
[i
].name
);
272 return &oakley_hashdef
[i
];
278 alg_oakley_hashdef_ok(doi
)
281 struct hash_algorithm
*f
;
283 f
= alg_oakley_hashdef(doi
);
291 alg_oakley_hashdef_doi(type
)
296 for (i
= 0; i
< ARRAYLEN(oakley_hashdef
); i
++)
297 if (type
== oakley_hashdef
[i
].type
) {
298 res
= oakley_hashdef
[i
].doi
;
305 alg_oakley_hashdef_hashlen(doi
)
308 struct hash_algorithm
*f
;
310 f
= alg_oakley_hashdef(doi
);
311 if (f
== NULL
|| f
->hashlen
== NULL
)
314 return (f
->hashlen
)();
318 alg_oakley_hashdef_name (doi
)
321 struct hash_algorithm
*f
;
323 f
= alg_oakley_hashdef(doi
);
331 alg_oakley_hashdef_one(doi
, buf
)
335 struct hash_algorithm
*f
;
337 f
= alg_oakley_hashdef(doi
);
338 if (f
== NULL
|| f
->hashlen
== NULL
)
341 return (f
->one
)(buf
);
344 /* oakley hmac algorithm */
345 static struct hmac_algorithm
*
346 alg_oakley_hmacdef(doi
)
351 for (i
= 0; i
< ARRAYLEN(oakley_hmacdef
); i
++)
352 if (doi
== oakley_hmacdef
[i
].doi
) {
353 plog(LLV_DEBUG
, LOCATION
, NULL
, "hmac(%s)\n",
354 oakley_hmacdef
[i
].name
);
355 return &oakley_hmacdef
[i
];
361 alg_oakley_hmacdef_doi(type
)
366 for (i
= 0; i
< ARRAYLEN(oakley_hmacdef
); i
++)
367 if (type
== oakley_hmacdef
[i
].type
) {
368 res
= oakley_hmacdef
[i
].doi
;
375 alg_oakley_hmacdef_one(doi
, key
, buf
)
379 struct hmac_algorithm
*f
;
382 struct timeval start
, end
;
385 f
= alg_oakley_hmacdef(doi
);
386 if (f
== NULL
|| f
->one
== NULL
)
390 gettimeofday(&start
, NULL
);
393 res
= (f
->one
)(key
, buf
);
396 gettimeofday(&end
, NULL
);
397 syslog(LOG_NOTICE
, "%s(%s size=%d): %8.6f", __func__
,
398 f
->name
, buf
->l
, timedelta(&start
, &end
));
404 /* oakley encryption algorithm */
405 static struct enc_algorithm
*
406 alg_oakley_encdef(doi
)
411 for (i
= 0; i
< ARRAYLEN(oakley_encdef
); i
++)
412 if (doi
== oakley_encdef
[i
].doi
) {
413 plog(LLV_DEBUG
, LOCATION
, NULL
, "encryption(%s)\n",
414 oakley_encdef
[i
].name
);
415 return &oakley_encdef
[i
];
421 alg_oakley_encdef_ok(doi
)
424 struct enc_algorithm
*f
;
426 f
= alg_oakley_encdef(doi
);
434 alg_oakley_encdef_doi(type
)
439 for (i
= 0; i
< ARRAYLEN(oakley_encdef
); i
++)
440 if (type
== oakley_encdef
[i
].type
) {
441 res
= oakley_encdef
[i
].doi
;
448 alg_oakley_encdef_keylen(doi
, len
)
451 struct enc_algorithm
*f
;
453 f
= alg_oakley_encdef(doi
);
454 if (f
== NULL
|| f
->keylen
== NULL
)
457 return (f
->keylen
)(len
);
461 alg_oakley_encdef_blocklen(doi
)
464 struct enc_algorithm
*f
;
466 f
= alg_oakley_encdef(doi
);
474 alg_oakley_encdef_name (doi
)
477 struct enc_algorithm
*f
;
479 f
= alg_oakley_encdef(doi
);
487 alg_oakley_encdef_decrypt(doi
, buf
, key
, iv
)
489 vchar_t
*buf
, *key
, *iv
;
492 struct enc_algorithm
*f
;
494 struct timeval start
, end
;
497 f
= alg_oakley_encdef(doi
);
498 if (f
== NULL
|| f
->decrypt
== NULL
)
502 gettimeofday(&start
, NULL
);
505 res
= (f
->decrypt
)(buf
, key
, iv
);
508 gettimeofday(&end
, NULL
);
509 syslog(LOG_NOTICE
, "%s(%s klen=%d size=%d): %8.6f", __func__
,
510 f
->name
, key
->l
<< 3, buf
->l
, timedelta(&start
, &end
));
516 alg_oakley_encdef_encrypt(doi
, buf
, key
, iv
)
518 vchar_t
*buf
, *key
, *iv
;
521 struct enc_algorithm
*f
;
523 struct timeval start
, end
;
526 f
= alg_oakley_encdef(doi
);
527 if (f
== NULL
|| f
->encrypt
== NULL
)
531 gettimeofday(&start
, NULL
);
534 res
= (f
->encrypt
)(buf
, key
, iv
);
537 gettimeofday(&end
, NULL
);
538 syslog(LOG_NOTICE
, "%s(%s klen=%d size=%d): %8.6f", __func__
,
539 f
->name
, key
->l
<< 3, buf
->l
, timedelta(&start
, &end
));
544 /* ipsec encryption algorithm */
545 static struct enc_algorithm
*
546 alg_ipsec_encdef(doi
)
551 for (i
= 0; i
< ARRAYLEN(ipsec_encdef
); i
++)
552 if (doi
== ipsec_encdef
[i
].doi
) {
553 plog(LLV_DEBUG
, LOCATION
, NULL
, "encryption(%s)\n",
554 ipsec_encdef
[i
].name
);
555 return &ipsec_encdef
[i
];
561 alg_ipsec_encdef_doi(type
)
566 for (i
= 0; i
< ARRAYLEN(ipsec_encdef
); i
++)
567 if (type
== ipsec_encdef
[i
].type
) {
568 res
= ipsec_encdef
[i
].doi
;
575 alg_ipsec_encdef_keylen(doi
, len
)
578 struct enc_algorithm
*f
;
580 f
= alg_ipsec_encdef(doi
);
581 if (f
== NULL
|| f
->keylen
== NULL
)
584 return (f
->keylen
)(len
);
587 /* ipsec hmac algorithm */
588 static struct hmac_algorithm
*
589 alg_ipsec_hmacdef(doi
)
594 for (i
= 0; i
< ARRAYLEN(ipsec_hmacdef
); i
++)
595 if (doi
== ipsec_hmacdef
[i
].doi
) {
596 plog(LLV_DEBUG
, LOCATION
, NULL
, "hmac(%s)\n",
597 oakley_hmacdef
[i
].name
);
598 return &ipsec_hmacdef
[i
];
604 alg_ipsec_hmacdef_doi(type
)
609 for (i
= 0; i
< ARRAYLEN(ipsec_hmacdef
); i
++)
610 if (type
== ipsec_hmacdef
[i
].type
) {
611 res
= ipsec_hmacdef
[i
].doi
;
618 alg_ipsec_hmacdef_hashlen(doi
)
621 struct hmac_algorithm
*f
;
623 f
= alg_ipsec_hmacdef(doi
);
624 if (f
== NULL
|| f
->hashlen
== NULL
)
627 return (f
->hashlen
)();
632 alg_ipsec_compdef_doi(type
)
637 for (i
= 0; i
< ARRAYLEN(ipsec_compdef
); i
++)
638 if (type
== ipsec_compdef
[i
].type
) {
639 res
= ipsec_compdef
[i
].doi
;
646 static struct dh_algorithm
*
647 alg_oakley_dhdef(doi
)
652 for (i
= 0; i
< ARRAYLEN(oakley_dhdef
); i
++)
653 if (doi
== oakley_dhdef
[i
].doi
) {
654 plog(LLV_DEBUG
, LOCATION
, NULL
, "hmac(%s)\n",
655 oakley_dhdef
[i
].name
);
656 return &oakley_dhdef
[i
];
662 alg_oakley_dhdef_ok(doi
)
665 struct dh_algorithm
*f
;
667 f
= alg_oakley_dhdef(doi
);
675 alg_oakley_dhdef_doi(type
)
680 for (i
= 0; i
< ARRAYLEN(oakley_dhdef
); i
++)
681 if (type
== oakley_dhdef
[i
].type
) {
682 res
= oakley_dhdef
[i
].doi
;
689 alg_oakley_dhdef_group(doi
)
692 struct dh_algorithm
*f
;
694 f
= alg_oakley_dhdef(doi
);
695 if (f
== NULL
|| f
->dhgroup
== NULL
)
702 alg_oakley_dhdef_name (doi
)
705 struct dh_algorithm
*f
;
707 f
= alg_oakley_dhdef(doi
);
713 /* authentication method */
715 alg_oakley_authdef_doi(type
)
720 for (i
= 0; i
< ARRAYLEN(oakley_authdef
); i
++)
721 if (type
== oakley_authdef
[i
].type
) {
722 res
= oakley_authdef
[i
].doi
;
729 alg_oakley_authdef_name (doi
)
734 for (i
= 0; i
< ARRAYLEN(oakley_authdef
); i
++)
735 if (doi
== oakley_authdef
[i
].doi
) {
736 return oakley_authdef
[i
].name
;
742 * give the default key length
744 * 0: fixed key cipher, key length not allowed
745 * positive: default key length
748 default_keylen(class, type
)
753 case algclass_isakmp_enc
:
754 case algclass_ipsec_enc
:
761 case algtype_blowfish
:
763 case algtype_cast128
:
765 case algtype_twofish
:
778 check_keylen(class, type
, len
)
779 int class, type
, len
;
784 case algclass_isakmp_enc
:
785 case algclass_ipsec_enc
:
788 /* unknown class, punt */
789 plog(LLV_ERROR
, LOCATION
, NULL
,
790 "unknown algclass %d\n", class);
794 /* key length must be multiple of 8 bytes - RFC2451 2.2 */
796 case algtype_blowfish
:
798 case algtype_cast128
:
800 case algtype_twofish
:
802 plog(LLV_ERROR
, LOCATION
, NULL
,
803 "key length %d is not multiple of 8\n", len
);
809 /* key length range */
812 case algtype_blowfish
:
813 if (len
< 40 || 448 < len
)
817 if (len
< 40 || 2040 < len
)
820 case algtype_cast128
:
821 if (len
< 40 || 128 < len
)
825 if (!(len
== 128 || len
== 192 || len
== 256))
828 case algtype_twofish
:
829 if (len
< 40 || 256 < len
)
834 plog(LLV_ERROR
, LOCATION
, NULL
,
835 "key length is not allowed");
841 plog(LLV_ERROR
, LOCATION
, NULL
,
842 "key length out of range\n");
850 * convert algorithm type to DOI value.
855 algtype2doi(class, type
)
861 case algclass_ipsec_enc
:
862 res
= alg_ipsec_encdef_doi(type
);
864 case algclass_ipsec_auth
:
865 res
= alg_ipsec_hmacdef_doi(type
);
867 case algclass_ipsec_comp
:
868 res
= alg_ipsec_compdef_doi(type
);
870 case algclass_isakmp_enc
:
871 res
= alg_oakley_encdef_doi(type
);
873 case algclass_isakmp_hash
:
874 res
= alg_oakley_hashdef_doi(type
);
876 case algclass_isakmp_dh
:
877 res
= alg_oakley_dhdef_doi(type
);
879 case algclass_isakmp_ameth
:
880 res
= alg_oakley_authdef_doi(type
);
887 * convert algorithm class to DOI value.
896 case algclass_ipsec_enc
:
897 return IPSECDOI_PROTO_IPSEC_ESP
;
898 case algclass_ipsec_auth
:
899 return IPSECDOI_ATTR_AUTH
;
900 case algclass_ipsec_comp
:
901 return IPSECDOI_PROTO_IPCOMP
;
902 case algclass_isakmp_enc
:
903 return OAKLEY_ATTR_ENC_ALG
;
904 case algclass_isakmp_hash
:
905 return OAKLEY_ATTR_HASH_ALG
;
906 case algclass_isakmp_dh
:
907 return OAKLEY_ATTR_GRP_DESC
;
908 case algclass_isakmp_ameth
:
909 return OAKLEY_ATTR_AUTH_METHOD
;