File openssl-1.0.2a-cryptodev-allow-copying-EVP-contexts.patch of Package openssl
diff -Ndurp openssl-1.0.2a/crypto/engine/eng_cryptodev.c openssl-1.0.2a-cryptodev-allow-copying-EVP-contexts/crypto/engine/eng_cryptodev.c
--- openssl-1.0.2a/crypto/engine/eng_cryptodev.c 2015-03-19 15:30:36.000000000 +0200
+++ openssl-1.0.2a-cryptodev-allow-copying-EVP-contexts/crypto/engine/eng_cryptodev.c 2015-06-07 17:14:58.039789624 +0300
@@ -534,111 +534,123 @@ static int cryptodev_cleanup(EVP_CIPHER_
* gets called when libcrypto requests a cipher NID.
*/
+static int cryptodev_cipher_ctrl(EVP_CIPHER_CTX *ctx, int type, int p1, void *p2)
+{
+ if (type == EVP_CTRL_COPY) {
+ struct dev_crypto_state *state = ctx->cipher_data;
+ struct session_op *sess = &state->d_sess;
+ EVP_CIPHER_CTX *out = p2;
+ return cryptodev_init_key(out, sess->key, ctx->iv, 0);
+ }
+
+ return 0;
+}
+
/* RC4 */
const EVP_CIPHER cryptodev_rc4 = {
NID_rc4,
1, 16, 0,
- EVP_CIPH_VARIABLE_LENGTH,
+ EVP_CIPH_VARIABLE_LENGTH|EVP_CIPH_CUSTOM_COPY,
cryptodev_init_key,
cryptodev_cipher,
cryptodev_cleanup,
sizeof(struct dev_crypto_state),
NULL,
NULL,
- NULL
+ cryptodev_cipher_ctrl
};
/* DES CBC EVP */
const EVP_CIPHER cryptodev_des_cbc = {
NID_des_cbc,
8, 8, 8,
- EVP_CIPH_CBC_MODE,
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
cryptodev_init_key,
cryptodev_cipher,
cryptodev_cleanup,
sizeof(struct dev_crypto_state),
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
- NULL
+ cryptodev_cipher_ctrl
};
/* 3DES CBC EVP */
const EVP_CIPHER cryptodev_3des_cbc = {
NID_des_ede3_cbc,
8, 24, 8,
- EVP_CIPH_CBC_MODE,
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
cryptodev_init_key,
cryptodev_cipher,
cryptodev_cleanup,
sizeof(struct dev_crypto_state),
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
- NULL
+ cryptodev_cipher_ctrl
};
const EVP_CIPHER cryptodev_bf_cbc = {
NID_bf_cbc,
8, 16, 8,
- EVP_CIPH_CBC_MODE,
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
cryptodev_init_key,
cryptodev_cipher,
cryptodev_cleanup,
sizeof(struct dev_crypto_state),
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
- NULL
+ cryptodev_cipher_ctrl
};
const EVP_CIPHER cryptodev_cast_cbc = {
NID_cast5_cbc,
8, 16, 8,
- EVP_CIPH_CBC_MODE,
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
cryptodev_init_key,
cryptodev_cipher,
cryptodev_cleanup,
sizeof(struct dev_crypto_state),
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
- NULL
+ cryptodev_cipher_ctrl
};
const EVP_CIPHER cryptodev_aes_cbc = {
NID_aes_128_cbc,
16, 16, 16,
- EVP_CIPH_CBC_MODE,
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
cryptodev_init_key,
cryptodev_cipher,
cryptodev_cleanup,
sizeof(struct dev_crypto_state),
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
- NULL
+ cryptodev_cipher_ctrl
};
const EVP_CIPHER cryptodev_aes_192_cbc = {
NID_aes_192_cbc,
16, 24, 16,
- EVP_CIPH_CBC_MODE,
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
cryptodev_init_key,
cryptodev_cipher,
cryptodev_cleanup,
sizeof(struct dev_crypto_state),
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
- NULL
+ cryptodev_cipher_ctrl
};
const EVP_CIPHER cryptodev_aes_256_cbc = {
NID_aes_256_cbc,
16, 32, 16,
- EVP_CIPH_CBC_MODE,
+ EVP_CIPH_CBC_MODE|EVP_CIPH_CUSTOM_COPY,
cryptodev_init_key,
cryptodev_cipher,
cryptodev_cleanup,
sizeof(struct dev_crypto_state),
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
- NULL
+ cryptodev_cipher_ctrl
};
# ifdef CRYPTO_AES_CTR