2 chris zcl chris_zcl 于 2013.07.03 13:48 提问

Apache Modulue开发中遇到的问题,关于openssl加密,总是报错,错在哪里?

char *iaisession_getobmuid(request_rec *r, const char *encid, const unsigned char *enckey, unsigned char *iv, const char *mtiid)
{
unsigned char *obmuid = (unsigned char *) apr_pcalloc(r->pool, LENGTH_OBMUID + 1);
char *b64edobmuid;
// get muid length
int mtiidlen = strlen(mtiid);
// encrypted obmuid length
int obmuidlen = 0;
// padding length
int paddinglen = 0;
// according to the key length, decide 128bit or 256bit AES encryption algorithm.
const EVP_CIPHER *aes_cbc = NULL;
int keylen = strlen((char *)enckey);
if (keylen == LENGTH_KEY_16) {
aes_cbc = EVP_aes_128_cbc();
} else if (keylen == LENGTH_KEY_32) {
aes_cbc = EVP_aes_256_cbc();
}
// cipher contex
EVP_CIPHER_CTX ctx;
// initializes cipher contex.
EVP_CIPHER_CTX_init(&ctx);
// sets up cipher context ctx for encryption with cipher type from ENGINE (default implementation).
EVP_EncryptInit_ex(&ctx, aes_cbc, NULL, enckey, iv);
// encrypts mtiidlen bytes from the mtiid in and writes the encrypted version to obmuid.
EVP_EncryptUpdate(&ctx, obmuid, &obmuidlen, (unsigned char *)mtiid, mtiidlen);
// obmuid is the encrypts.
EVP_EncryptFinal_ex(&ctx, obmuid + obmuidlen, &paddinglen);
// clears all information from a cipher context and free up any allocated memory associate with it.
EVP_CIPHER_CTX_cleanup(&ctx);
// base64 encode
b64edobmuid = iaisession_encodebybase64(r->pool, obmuid);
return b64edobmuid;
}

[Wed Jul 03 01:43:13 2013] [notice] child pid 28278 exit signal Segmentation fault (11)

1个回答

oyljerry
oyljerry   Ds   Rxr 2015.01.03 11:37

segmentation fault,程序异常了,比如指针越界等

Csdn user default icon
上传中...
上传图片
插入图片