]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Moved print messages back to generic crypto.c from cipher backends
authorAdriaan de Jong <dejong@fox-it.com>
Thu, 14 Jul 2011 19:19:12 +0000 (21:19 +0200)
committerDavid Sommerseth <davids@redhat.com>
Sat, 22 Oct 2011 16:00:34 +0000 (18:00 +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_backend.h
crypto_openssl.c
crypto_polarssl.c

index 6f0a44e770f23bdbdcdb98396e5836a8d5da8595..d8d6656c03b2cb93b0cfa1612d3d671c480bdd26 100644 (file)
--- a/crypto.c
+++ b/crypto.c
@@ -438,12 +438,26 @@ init_key_ctx (struct key_ctx *ctx, struct key *key,
              const struct key_type *kt, int enc,
              const char *prefix)
 {
+  struct gc_arena gc = gc_new ();
   CLEAR (*ctx);
   if (kt->cipher && kt->cipher_length > 0)
     {
+
       ALLOC_OBJ(ctx->cipher, cipher_ctx_t);
       cipher_ctx_init (ctx->cipher, key->cipher, kt->cipher_length,
-         kt->cipher, enc, prefix);
+         kt->cipher, enc);
+
+      msg (D_HANDSHAKE, "%s: Cipher '%s' initialized with %d bit key",
+          prefix,
+          cipher_kt_name(kt->cipher),
+          kt->cipher_length *8);
+
+      dmsg (D_SHOW_KEYS, "%s: CIPHER KEY: %s", prefix,
+          format_hex (key->cipher, kt->cipher_length, 0, &gc));
+      dmsg (D_CRYPTO_DEBUG, "%s: CIPHER block_size=%d iv_size=%d",
+          prefix,
+          cipher_kt_block_size(kt->cipher),
+          cipher_kt_iv_size(kt->cipher));
     }
   if (kt->digest && kt->hmac_length > 0)
     {
@@ -451,6 +465,7 @@ init_key_ctx (struct key_ctx *ctx, struct key *key,
       hmac_ctx_init (ctx->hmac, key->hmac, kt->hmac_length, kt->digest,
          prefix);
     }
+  gc_free (&gc);
 }
 
 void
index 71c3f47cdd6b4941d1a1f793c9d321bb8b93241b..25d985b8e2d0924963e3ce1a4e7202534b8312f6 100644 (file)
@@ -236,10 +236,9 @@ bool cipher_kt_mode (const cipher_kt_t *cipher_kt);
  * @param kt           Static cipher parameters to use
  * @param enc          Whether to encrypt or decrypt (either
  *                     \c POLARSSL_OP_ENCRYPT or \c POLARSSL_OP_DECRYPT).
- * @param prefix       Prefix to use for output.
  */
 void cipher_ctx_init (cipher_ctx_t *ctx, uint8_t *key, int key_len,
-    const cipher_kt_t *kt, int enc, const char *prefix);
+    const cipher_kt_t *kt, int enc);
 
 /**
  * Cleanup the specified context.
index 09811178d7601724592d624b01bcd5217f30f3fe..b94451a217903fcefb4a3b86f5d54616f570601f 100644 (file)
@@ -571,10 +571,8 @@ cipher_kt_mode (const EVP_CIPHER *cipher_kt)
 
 void
 cipher_ctx_init (EVP_CIPHER_CTX *ctx, uint8_t *key, int key_len,
-    const EVP_CIPHER *kt, int enc, const char *prefix)
+    const EVP_CIPHER *kt, int enc)
 {
-  struct gc_arena gc = gc_new ();
-
   ASSERT(NULL != kt && NULL != ctx);
 
   CLEAR (*ctx);
@@ -589,22 +587,8 @@ cipher_ctx_init (EVP_CIPHER_CTX *ctx, uint8_t *key, int key_len,
   if (!EVP_CipherInit_ov (ctx, NULL, key, NULL, enc))
     msg (M_SSLERR, "EVP cipher init #2");
 
-  msg (D_HANDSHAKE, "%s: Cipher '%s' initialized with %d bit key",
-      prefix,
-      OBJ_nid2sn (EVP_CIPHER_CTX_nid (ctx)),
-      EVP_CIPHER_CTX_key_length (ctx) * 8);
-
   /* make sure we used a big enough key */
   ASSERT (EVP_CIPHER_CTX_key_length (ctx) <= key_len);
-
-  dmsg (D_SHOW_KEYS, "%s: CIPHER KEY: %s", prefix,
-      format_hex (key, key_len, 0, &gc));
-  dmsg (D_CRYPTO_DEBUG, "%s: CIPHER block_size=%d iv_size=%d",
-      prefix,
-      EVP_CIPHER_CTX_block_size (ctx),
-      EVP_CIPHER_CTX_iv_length (ctx));
-
-  gc_free (&gc);
 }
 
 void
index 9c3647808f0f601eeb9d0d1802f916496c4bcece..368e8f84aba526ed03cd37a81d6dce2427b0edb2 100644 (file)
@@ -329,10 +329,8 @@ cipher_kt_mode (const cipher_info_t *cipher_kt)
 
 void
 cipher_ctx_init (cipher_context_t *ctx, uint8_t *key, int key_len,
-    const cipher_info_t *kt, int enc, const char *prefix)
+    const cipher_info_t *kt, int enc)
 {
-  struct gc_arena gc = gc_new ();
-
   ASSERT(NULL != kt && NULL != ctx);
 
   CLEAR (*ctx);
@@ -343,22 +341,8 @@ cipher_ctx_init (cipher_context_t *ctx, uint8_t *key, int key_len,
   if (0 != cipher_setkey(ctx, key, key_len*8, enc))
     msg (M_FATAL, "PolarSSL cipher set key");
 
-  msg (D_HANDSHAKE, "%s: Cipher '%s' initialized with %d bit key",
-       prefix,
-       cipher_kt_name(kt),
-       cipher_get_key_size(ctx));
-
   /* make sure we used a big enough key */
   ASSERT (ctx->key_length <= key_len*8);
-
-  dmsg (D_SHOW_KEYS, "%s: CIPHER KEY: %s", prefix,
-       format_hex (key, key_len, 0, &gc));
-  dmsg (D_CRYPTO_DEBUG, "%s: CIPHER block_size=%d iv_size=%d",
-       prefix,
-       cipher_get_block_size(ctx),
-       cipher_get_iv_size(ctx));
-
-  gc_free (&gc);
 }
 
 void cipher_ctx_cleanup (cipher_context_t *ctx)