Lines Matching refs:cipher
99 if (ctx->cipher)
102 const int iv_size = cipher_ctx_iv_length (ctx->cipher);
103 const unsigned int mode = cipher_ctx_mode (ctx->cipher);
114 /* Put packet ID in plaintext buffer or IV, depending on cipher mode */
151 ASSERT (cipher_ctx_reset(ctx->cipher, iv_buf));
154 if (!buf_safe (&work, buf->len + cipher_ctx_block_size(ctx->cipher)))
163 cipher_ctx_block_size (ctx->cipher));
168 ASSERT (cipher_ctx_update (ctx->cipher, BPTR (&work), &outlen, BPTR (buf), BLEN (buf)));
172 ASSERT(cipher_ctx_final(ctx->cipher, BPTR (&work) + outlen, &outlen));
198 /* HMAC the ciphertext (or plaintext if !cipher) */
273 if (ctx->cipher)
275 const unsigned int mode = cipher_ctx_mode (ctx->cipher);
276 const int iv_size = cipher_ctx_iv_length (ctx->cipher);
300 /* ctx->cipher was already initialized with key & keylen */
301 if (!cipher_ctx_reset (ctx->cipher, iv_buf))
302 CRYPT_ERROR ("cipher init failed");
309 if (!cipher_ctx_update (ctx->cipher, BPTR (&work), &outlen, BPTR (buf), BLEN (buf)))
310 CRYPT_ERROR ("cipher update failed");
314 if (!cipher_ctx_final (ctx->cipher, BPTR (&work) + outlen, &outlen))
315 CRYPT_ERROR ("cipher final failed");
321 /* Get packet ID from plaintext buffer or IV, depending on cipher mode */
405 ((cipher_defined && use_iv) ? cipher_kt_iv_size (kt->cipher) : 0) +
406 (cipher_defined ? cipher_kt_block_size (kt->cipher) : 0) + /* worst case padding expansion */
422 kt->cipher = cipher_kt_get (translate_cipher_name_from_openvpn(ciphername));
423 kt->cipher_length = cipher_kt_key_size (kt->cipher);
427 /* check legal cipher mode */
429 const unsigned int mode = cipher_kt_mode (kt->cipher);
445 msg (M_WARN, "******* WARNING *******: null cipher specified, no encryption will be used");
467 if (kt->cipher && kt->cipher_length > 0)
470 ALLOC_OBJ(ctx->cipher, cipher_ctx_t);
471 cipher_ctx_init (ctx->cipher, key->cipher, kt->cipher_length,
472 kt->cipher, enc);
476 cipher_kt_name(kt->cipher),
480 format_hex (key->cipher, kt->cipher_length, 0, &gc));
483 cipher_kt_block_size(kt->cipher),
484 cipher_kt_iv_size(kt->cipher));
510 if (ctx->cipher)
512 cipher_ctx_cleanup(ctx->cipher);
513 free(ctx->cipher);
514 ctx->cipher = NULL;
537 if (key->cipher[i])
544 * Make sure that cipher key is a valid key for current key_type.
549 if (kt->cipher)
561 const int ndc = key_des_num_cblocks (kt->cipher);
563 return key_des_check (key->cipher, kt->cipher_length, ndc);
583 if (kt->cipher)
588 const int ndc = key_des_num_cblocks (kt->cipher);
591 key_des_fixup (key->cipher, kt->cipher_length, ndc);
596 if (memcmp (orig.cipher, key->cipher, kt->cipher_length))
598 format_hex (orig.cipher, kt->cipher_length, 0, &gc),
599 format_hex (key->cipher, kt->cipher_length, 0, &gc));
610 msg (M_FATAL, "--no-replay or --no-iv cannot be used with a CFB or OFB mode cipher");
616 if (kt && kt->cipher) {
617 const unsigned int mode = cipher_kt_mode (kt->cipher);
639 if (kt->cipher && kt->cipher_length > 0 && kt->cipher_length <= cipher_len)
645 if (!rand_bytes (key->cipher, cipher_len)
649 dmsg (D_SHOW_KEY_SOURCE, "Cipher source entropy: %s", format_hex (key->cipher, cipher_len, 0, &gc));
670 dmsg (D_SHOW_KEY_SOURCE, "%s (cipher): %s",
672 format_hex (k->keys[0].cipher, kt->cipher_length, 0, &gc));
676 dmsg (D_SHOW_KEY_SOURCE, "%s (cipher): %s",
678 format_hex (k->keys[1].cipher, kt->cipher_length, 0, &gc));
756 kt.cipher = NULL;
1250 if (!buf_write (buf, key->cipher, kt->cipher_length))
1276 if (!buf_read (buf, key->cipher, cipher_length))
1292 "TLS Error: key length mismatch, local cipher/hmac %d/%d, remote cipher/hmac %d/%d",