2 * Copyright (C) 2011 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include <sa/ikev1/keymat_v1.h>
19 #include <sa/ikev2/keymat_v2.h>
24 keymat_t
*keymat_create(ike_version_t version
, bool initiator
)
30 return &keymat_v1_create(initiator
)->keymat
;
35 return &keymat_v2_create(initiator
)->keymat
;
45 * Implicit key length for an algorithm
48 /** IKEv2 algorithm identifier */
50 /** key length in bits */
57 int keymat_get_keylen_encr(encryption_algorithm_t alg
)
59 keylen_entry_t map
[] = {
65 for (i
= 0; i
< countof(map
); i
++)
67 if (map
[i
].alg
== alg
)
78 int keymat_get_keylen_integ(integrity_algorithm_t alg
)
80 keylen_entry_t map
[] = {
81 {AUTH_HMAC_MD5_96
, 128},
82 {AUTH_HMAC_SHA1_96
, 160},
83 {AUTH_HMAC_SHA2_256_96
, 256},
84 {AUTH_HMAC_SHA2_256_128
, 256},
85 {AUTH_HMAC_SHA2_384_192
, 384},
86 {AUTH_HMAC_SHA2_512_256
, 512},
87 {AUTH_AES_XCBC_96
, 128},
91 for (i
= 0; i
< countof(map
); i
++)
93 if (map
[i
].alg
== alg
)