]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Refactored maximum cipher and hmac length constants
authorAdriaan de Jong <dejong@fox-it.com>
Thu, 23 Jun 2011 07:41:28 +0000 (09:41 +0200)
committerDavid Sommerseth <davids@redhat.com>
Wed, 19 Oct 2011 20:05:45 +0000 (22:05 +0200)
Signed-off-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
crypto.c
crypto.h
crypto_backend.h
crypto_openssl.c

index 8af5b7ad54b073885583ebe42117fccab609f991..a1986e096ffc71016d964ca63573a7626d441a58 100644 (file)
--- a/crypto.c
+++ b/crypto.c
 
 #include "memdbg.h"
 
-/*
- * Check for key size creepage.
- */
-
-#if MAX_CIPHER_KEY_LENGTH < EVP_MAX_KEY_LENGTH
-#warning Some OpenSSL EVP ciphers now support key lengths greater than MAX_CIPHER_KEY_LENGTH -- consider increasing MAX_CIPHER_KEY_LENGTH
-#endif
-
-#if MAX_HMAC_KEY_LENGTH < EVP_MAX_MD_SIZE
-#warning Some OpenSSL HMAC message digests now support key lengths greater than MAX_HMAC_KEY_LENGTH -- consider increasing MAX_HMAC_KEY_LENGTH
-#endif
-
 /*
  * Encryption and Compression Routines.
  *
index 5165d0f3eb1337766f2c26b6c4f08011f7c02300..2ddee5f1528f189e384ba7a2ba804ecf68d3964e 100644 (file)
--- a/crypto.h
+++ b/crypto.h
@@ -172,29 +172,6 @@ cipher_ok (const char* name)
 #define EVP_MD_name(e)                 OBJ_nid2sn(EVP_MD_type(e))
 #endif
 
-/*
- * Max size in bytes of any cipher key that might conceivably be used.
- *
- * This value is checked at compile time in crypto.c to make sure
- * it is always at least EVP_MAX_KEY_LENGTH.
- *
- * We define our own value, since this parameter
- * is used to control the size of static key files.
- * If the OpenSSL library increases EVP_MAX_KEY_LENGTH,
- * we don't want our key files to be suddenly rendered
- * unusable.
- */
-#define MAX_CIPHER_KEY_LENGTH 64
-
-/*
- * Max size in bytes of any HMAC key that might conceivably be used.
- *
- * This value is checked at compile time in crypto.c to make sure
- * it is always at least EVP_MAX_MD_SIZE.  We define our own value
- * for the same reason as above.
- */
-#define MAX_HMAC_KEY_LENGTH 64
-
 /*
  * Defines a key type and key length for both cipher and HMAC.
  */
@@ -206,7 +183,6 @@ struct key_type
   const EVP_MD *digest;
 };
 
-
 /**
  * Container for unidirectional cipher and HMAC %key material.
  * @ingroup control_processor
index 9f8eb047ec02347172cb4f121acf6cdda60e8a3e..31935ed24232b7d28a17832204abf77547648455 100644 (file)
  */
 int rand_bytes (uint8_t *output, int len);
 
+/*
+ *
+ * Generic cipher key type functions
+ *
+ */
+/*
+ * Max size in bytes of any cipher key that might conceivably be used.
+ *
+ * This value is checked at compile time in crypto.c to make sure
+ * it is always at least EVP_MAX_KEY_LENGTH.
+ *
+ * We define our own value, since this parameter
+ * is used to control the size of static key files.
+ * If the OpenSSL library increases EVP_MAX_KEY_LENGTH,
+ * we don't want our key files to be suddenly rendered
+ * unusable.
+ */
+#define MAX_CIPHER_KEY_LENGTH 64
+
+/*
+ *
+ * Generic message digest information functions
+ *
+ */
+
+/*
+ * Max size in bytes of any HMAC key that might conceivably be used.
+ *
+ * This value is checked at compile time in crypto.c to make sure
+ * it is always at least EVP_MAX_MD_SIZE.  We define our own value
+ * for the same reason as above.
+ */
+#define MAX_HMAC_KEY_LENGTH 64
+
 #endif /* CRYPTO_BACKEND_H_ */
index cbe559afa7a41e8efeb203a7a26e894d0bbe5085..9e547b478ddf54ee1f9fb4328a206034090bf318 100644 (file)
 #include <openssl/evp.h>
 #include <openssl/des.h>
 
+/*
+ * Check for key size creepage.
+ */
+
+#if MAX_CIPHER_KEY_LENGTH < EVP_MAX_KEY_LENGTH
+#warning Some OpenSSL EVP ciphers now support key lengths greater than MAX_CIPHER_KEY_LENGTH -- consider increasing MAX_CIPHER_KEY_LENGTH
+#endif
+
+#if MAX_HMAC_KEY_LENGTH < EVP_MAX_MD_SIZE
+#warning Some OpenSSL HMAC message digests now support key lengths greater than MAX_HMAC_KEY_LENGTH -- consider increasing MAX_HMAC_KEY_LENGTH
+#endif
+
 /*
  *
  * Random number functions, used in cases where we want