2013-05-06 205 views
1

我編譯& make install openssl。只是檢查,以確保包安裝正確,我運行下面的程序。它編譯&爲我正確運行。 Means openssl is installed correctly &沒有損壞。如何擺脫 - openssl錯誤

#include <openssl/engine.h> 
#include <openssl/evp.h> 
#include <openssl/err.h> 

int main(int c, char **v) 
{ 
    ERR_load_crypto_strings(); 
    OpenSSL_add_all_algorithms(); 
    ENGINE_load_builtin_engines(); 
    ENGINE_register_all_complete(); 
    puts("Stuff seems okay."); 
    return 0; 
} 
(It build okay with "gcc -Wall -lcrypto test.c -o test" 
Also run fines) 

現在我有程序,它使用openssl庫。在這裏我得到這個錯誤。如果軟件包安裝正確,那麼爲什麼在運行時會出現錯誤。我使用的openssl函數是否存在一些我錯過的依賴項:---

openssl是否需要TOR?這個鏈接說造成類似的錯誤: -
https://lists.torproject.org/pipermail/tor-talk/2013-February/027252.html
https://trac.torproject.org/projects/tor/ticket/7215

md5.cpp:---

#include <stdio.h> 
#include <openssl/evp.h> 

#include "md5.h" 

////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 

Cmd5::Cmd5(void) 
{ 
    *m_szDigest = 0; 
} 

Cmd5::Cmd5(unsigned char *pstr) 
{ 
    digest(pstr); 
} 

Cmd5::~Cmd5() 
{ 

} 

/////////////////////////////////////////////////////////////////////////////// 
// digest 
// 

char *Cmd5::digest(unsigned char *pstr) 
{ 

    EVP_MD_CTX mdctx; 
    const EVP_MD *md; 
    unsigned char md_value[EVP_MAX_MD_SIZE]; 
    unsigned int md_len; 

    OpenSSL_add_all_digests(); 

    md = EVP_get_digestbyname("md5"); 
    EVP_MD_CTX_init(&mdctx); 
    EVP_DigestInit_ex(&mdctx, md, NULL); 
    EVP_DigestUpdate(&mdctx, pstr, strlen((const char *)pstr)); 
    EVP_DigestFinal_ex(&mdctx, md_value, &md_len); 
    EVP_MD_CTX_cleanup(&mdctx); 

    sprintf(m_szDigest, 
     "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\0", 
     md_value[0],md_value[1],md_value[2],md_value[3],md_value[4],md_value[5],md_value[6],md_value[7], 
     md_value[8],md_value[9],md_value[10],md_value[11],md_value[12],md_value[13],md_value[14],md_value[15]); 


    return m_szDigest; 

} 

md5.h:---

#include <openssl/md5.h> 

class Cmd5 
{ 

public: 

    /*! 
     Default constructor 
    */ 
    Cmd5(void); 

    /*! 
     Constructor 
     @param pstr string to encrypt. 
    */ 
    Cmd5(unsigned char *pstr); 

    /*! 
     Destructor 
    */ 
    virtual ~Cmd5(); 

    /*! 
     Perform MD5 
     @param pstr string to encrypt. 
     @return Encrypted data. 
    */ 
    char *digest(unsigned char *pstr); 

    /*! 
     Perform MD5 
     @return Encrypted data. 
    */ 
    char *getDigest(void) { return m_szDigest; }; 

private: 

    /*! 
     MD5 data 
    */ 
    char m_szDigest[128]; 
}; 

錯誤: - ---

[email protected] ~ $ gdb vscpd 
gdb: /usr/local/lib/libcrypto.so.1.0.0: no version information available (required by /usr/lib/libpython2.7.so.1.0) 
gdb: /usr/local/lib/libssl.so.1.0.0: no version information available (required by /usr/lib/libpython2.7.so.1.0) 
GNU gdb (GDB) 7.4.1-debian 
Copyright (C) 2012 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "arm-linux-gnueabihf". 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>... 
Reading symbols from /home/pi/vscpd...done. 


(gdb) break main 
Breakpoint 1 at 0xdd30: file vscpd.cpp, line 99. 


(gdb) run 
Starting program: /home/pi/vscpd 
[Thread debugging using libthread_db enabled] 
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1". 

Program received signal SIGILL, Illegal instruction. 
0x4025f7a0 in _armv7_neon_probe() from /usr/local/lib/libcrypto.so.1.0.0 



(gdb) bt 
#0 0x4025f7a0 in _armv7_neon_probe() from /usr/local/lib/libcrypto.so.1.0.0 
#1 0x4025bdc4 in OPENSSL_cpuid_setup() from /usr/local/lib/libcrypto.so.1.0.0 
#2 0x4000f250 in ??() from /lib/ld-linux-armhf.so.3 
#3 0xbefff858 in ??() 
#4 0xbefff858 in ??() 
Backtrace stopped: previous frame identical to this frame (corrupt stack?) 
(gdb) debug2: client_check_window_change: changed 
debug2: channel 0: request window-change confirm 0 
(gdb) 

請提出造成此錯誤的原因是什麼?

回答

3

嘗試設置環境變量OPENSSL_armcap = 0以禁用該代碼。

OPENSSL_cpuid_setup中的代碼假定它可以捕獲SIGILL並在指令無法執行時繼續。 你可以在gdb中繼續,OPENSSL_cpuid_setup中的處理程序應該讓它通過 - 並且應該正常工作。

你通常會(本)使用類似在gdb下面讓這種情況發生:

手柄SIGILL通過

蒂姆。

+0

謝謝...處理SIGILL傳遞 - 命令& - 繼續在gdb工作 - 然後我能夠步進程序 - 什麼是設置環境變量的commad ...應該在我的.bashrc文件? – Katoch 2013-05-06 14:38:12

+0

也可以禁用此錯誤的時候,我..編譯openssl ..即在製造時間..? – Katoch 2013-05-06 16:06:17