如何摆脱 -- openssl 错误

Kat*_*och 2 openssl embedded-linux

我已经编译并安装 openssl。只是为了检查软件包是否安装正确,我运行以下程序。它为我编译并正确运行。Means openssl is installed correctly& 没有损坏。

#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 )
Run Code Online (Sandbox Code Playgroud)

现在我有程序,它使用 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;

}
Run Code Online (Sandbox Code Playgroud)

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];
};
Run Code Online (Sandbox Code Playgroud)

错误 : - -

pi@raspberrypi ~ $ 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) 
Run Code Online (Sandbox Code Playgroud)

请建议是什么原因导致此错误?

小智 5

尝试设置环境变量 OPENSSL_armcap=0 以禁用该代码。

OPENSSL_cpuid_setup 中的代码假设它可以捕获 SIGILL,并在指令无法执行时继续。您可以在 gdb 中继续,OPENSSL_cpuid_setup 中的处理程序应该让它通过 - 并且应该可以正常运行。

通常(为此)您会在 gdb 中使用类似以下内容来实现这种情况:

处理SIGILL通行证

蒂姆.