@@ -336,10 +336,10 @@
* @param key Buffer containing the key to use
* @param ciphername Ciphername of the cipher to use
* @param enc Whether to encrypt or decrypt (either
- * \c MBEDTLS_OP_ENCRYPT or \c MBEDTLS_OP_DECRYPT).
+ * \c OPENVPN_OP_ENCRYPT or \c OPENVPN_OP_DECRYPT).
*/
void cipher_ctx_init(cipher_ctx_t *ctx, const uint8_t *key,
- const char *cipername, int enc);
+ const char *cipername, crypto_operation_t enc);
/**
* Returns the size of the IV used by the cipher, in bytes, or 0 if no IV is
@@ -566,7 +566,7 @@
void
cipher_ctx_init(mbedtls_cipher_context_t *ctx, const uint8_t *key,
- const char *ciphername, const mbedtls_operation_t operation)
+ const char *ciphername, crypto_operation_t enc)
{
ASSERT(NULL != ciphername && NULL != ctx);
CLEAR(*ctx);
@@ -580,7 +580,7 @@
msg(M_FATAL, "mbed TLS cipher context init #1");
}
- if (!mbed_ok(mbedtls_cipher_setkey(ctx, key, (int)key_bitlen, operation)))
+ if (!mbed_ok(mbedtls_cipher_setkey(ctx, key, (int)key_bitlen, enc)))
{
msg(M_FATAL, "mbed TLS cipher set key");
}
@@ -63,6 +63,8 @@
/** Cipher is in GCM mode */
#define OPENVPN_MODE_GCM MBEDTLS_MODE_GCM
+typedef mbedtls_operation_t crypto_operation_t;
+
/** Cipher should encrypt */
#define OPENVPN_OP_ENCRYPT MBEDTLS_ENCRYPT
@@ -840,7 +840,7 @@
void
cipher_ctx_init(EVP_CIPHER_CTX *ctx, const uint8_t *key,
- const char *ciphername, int enc)
+ const char *ciphername, crypto_operation_t enc)
{
ASSERT(NULL != ciphername && NULL != ctx);
evp_cipher_type *kt = cipher_get(ciphername);
@@ -85,6 +85,8 @@
/** Cipher is in GCM mode */
#define OPENVPN_MODE_GCM EVP_CIPH_GCM_MODE
+typedef int crypto_operation_t;
+
/** Cipher should encrypt */
#define OPENVPN_OP_ENCRYPT 1