创建EVP_CIPHER_CTX数组

时间:2017-04-03 13:15:10

标签: c++ openssl

我使用的是CentOS 7和OpenSSL v1.1.0。

由于OpenSSL更改了API,因此出现以下错误:invalid use of incomplete type struct evp_cipher_ctx_st

static void InitAESKey(AES_KEY_CTX* ctx, BYTE* keybytes, int numkeys)
        {
                BYTE* pBufIdx = keybytes;
                for (int i = 0; i < numkeys; i++)
                {
                        OTEXT_AES_KEY_INIT(ctx + i, pBufIdx);
                        pBufIdx += AES_KEY_BYTES;
                }
        }

AES_KEY_CTXOTEXT_AES_KEY_INIT是定义的宏:

#define AES_KEY_CTX EVP_CIPHER_CTX
#define OTEXT_AES_KEY_INIT(ctx, buf) { \
        EVP_CIPHER_CTX_init(ctx); \
        EVP_EncryptInit_ex(ctx, EVP_aes_128_ecb(), NULL, buf, ZERO_IV); \
        }

我尝试将宏更改为#define AES_KEY_CTX EVP_CIPHER_CTX*,但错误仍然存​​在。

1 个答案:

答案 0 :(得分:0)

在我咨询了OpenSSL用户的电子邮件列表后,我进行了这些更改,以便编译代码:

    Y_pred = np.squeeze(model.predict(test_data[0:5]))
    classification_report(test_labels[0:5], Y_pred)


    ---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-235-49afd2f46d17> in <module>()
----> 1 classification_report(test_labels[0:5], Y_pred)

/Library/Python/2.7/site-packages/sklearn/metrics/classification.pyc in classification_report(y_true, y_pred, labels, target_names, sample_weight, digits)
   1356 
   1357     if labels is None:
-> 1358         labels = unique_labels(y_true, y_pred)
   1359     else:
   1360         labels = np.asarray(labels)

/Library/Python/2.7/site-packages/sklearn/utils/multiclass.pyc in unique_labels(*ys)
     97     _unique_labels = _FN_UNIQUE_LABELS.get(label_type, None)
     98     if not _unique_labels:
---> 99         raise ValueError("Unknown label type: %s" % repr(ys))
    100 
    101     ys_labels = set(chain.from_iterable(_unique_labels(y) for y in ys))

ValueError: Unknown label type: (array([-0.38947693,  0.18258421, -0.00295772, -0.06293461, -0.29382696]), array([-0.46586546,  0.1359883 , -0.00223112, -0.08303966, -0.29208803]))