【问题标题】:how to get rid of -- openssl error如何摆脱 -- openssl 错误
【发布时间】:2013-05-06 20:18:28
【问题描述】:

我已经编译并安装 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 )

现在我有了使用 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];
};

错误:----

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) 

请提出导致此错误的原因?

【问题讨论】:

    标签: openssl embedded-linux


    【解决方案1】:

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

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

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

    处理 SIGILL 通行证

    提姆。

    【讨论】:

    • 谢谢 ...handle SIGILL pass -- command & -- continue 在 gdb 工作 -- 然后我可以执行程序 --- 设置环境变量的命令是什么......它应该在我的 .bashrc 文件中吗?
    • 也可以在我 .. 编译 openssl .. 时禁用此错误 .. 即在 MAKE 时 .. 吗?
    猜你喜欢
    • 2011-08-08
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-23
    相关资源
    最近更新 更多