aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/crypto/crypters
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2013-04-10 19:24:09 +0200
committerTobias Brunner <tobias@strongswan.org>2013-05-08 15:02:34 +0200
commit9d4fc8677fe8bc10e023be5c0a887062191ae602 (patch)
tree036d77187a7d250e80a23ddcca7c9576225e4fa9 /src/libstrongswan/crypto/crypters
parentc734c2d875bbea7673dbbc796a88f2f21e5265b1 (diff)
downloadstrongswan-9d4fc8677fe8bc10e023be5c0a887062191ae602.tar.bz2
strongswan-9d4fc8677fe8bc10e023be5c0a887062191ae602.tar.xz
Add implementation of the RC2 block cipher (RFC 2268)
Diffstat (limited to 'src/libstrongswan/crypto/crypters')
-rw-r--r--src/libstrongswan/crypto/crypters/crypter.c7
-rw-r--r--src/libstrongswan/crypto/crypters/crypter.h13
2 files changed, 16 insertions, 4 deletions
diff --git a/src/libstrongswan/crypto/crypters/crypter.c b/src/libstrongswan/crypto/crypters/crypter.c
index 0730c707c..8123adde5 100644
--- a/src/libstrongswan/crypto/crypters/crypter.c
+++ b/src/libstrongswan/crypto/crypters/crypter.c
@@ -46,12 +46,13 @@ ENUM_NEXT(encryption_algorithm_names, ENCR_CAMELLIA_CBC, ENCR_CAMELLIA_CCM_ICV16
"CAMELLIA_CCM_8",
"CAMELLIA_CCM_12",
"CAMELLIA_CCM_16");
-ENUM_NEXT(encryption_algorithm_names, ENCR_UNDEFINED, ENCR_TWOFISH_CBC, ENCR_CAMELLIA_CCM_ICV16,
+ENUM_NEXT(encryption_algorithm_names, ENCR_UNDEFINED, ENCR_RC2_CBC, ENCR_CAMELLIA_CCM_ICV16,
"UNDEFINED",
"DES_ECB",
"SERPENT_CBC",
- "TWOFISH_CBC");
-ENUM_END(encryption_algorithm_names, ENCR_TWOFISH_CBC);
+ "TWOFISH_CBC",
+ "RC2_CBC");
+ENUM_END(encryption_algorithm_names, ENCR_RC2_CBC);
/*
* Described in header.
diff --git a/src/libstrongswan/crypto/crypters/crypter.h b/src/libstrongswan/crypto/crypters/crypter.h
index fe854f53d..849aea500 100644
--- a/src/libstrongswan/crypto/crypters/crypter.h
+++ b/src/libstrongswan/crypto/crypters/crypter.h
@@ -60,7 +60,9 @@ enum encryption_algorithm_t {
ENCR_UNDEFINED = 1024,
ENCR_DES_ECB = 1025,
ENCR_SERPENT_CBC = 1026,
- ENCR_TWOFISH_CBC = 1027
+ ENCR_TWOFISH_CBC = 1027,
+ /* see macros below to handle RC2 (effective) key length */
+ ENCR_RC2_CBC = 1028,
};
#define DES_BLOCK_SIZE 8
@@ -71,6 +73,15 @@ enum encryption_algorithm_t {
#define TWOFISH_BLOCK_SIZE 16
/**
+ * For RC2, if the effective key size in bits is not key_size * 8, it should
+ * be encoded with the macro below. It can be decoded with the other two macros.
+ * After decoding the value should be validated.
+ */
+#define RC2_KEY_SIZE(kl, eff) ((kl) | ((eff) << 8))
+#define RC2_EFFECTIVE_KEY_LEN(ks) ((ks) >> 8)
+#define RC2_KEY_LEN(ks) ((ks) & 0xff)
+
+/**
* enum name for encryption_algorithm_t.
*/
extern enum_name_t *encryption_algorithm_names;