标签: openssl-engine

将ENGINE上下文附加到SSL_CTX

我想知道是否有可能将ENGINE*实现附加到SSL_CTX*和/或SSL*结构.我想要实现的是使用SSL_CTX*OpenSSL中内置的默认加密操作设置,另一个SSL_CTX*使用专用HSM作为加密层.

我可以通过这种方式实现这一目标吗?从我读过的内容可以注册并设置为默认一些加密操作(随机,密码,md等等),但已经设置的那些将被使用而不是内置的.

例如EVP_CipherInit_ex,它的第三个参数是ENGINE*.以EVP_CIPHER_CTX*这种方式初始化的加密/解密将通过ENGINE实现处理加密/解密.

ssl openssl openssl-engine

6
推荐指数
1
解决办法
393
查看次数

如何使用openssl从HSM重新加载密钥?

我通过pkcs11 openssl引擎使用HSM. ENGINE_load_private_key()用于加载要使用的密钥.除了生成密钥对之外,它工作正常:

在为HSM生成新密钥对后,ENGINE_load_private_key()仍会返回旧密钥.

显然后来的调用ENGINE_load_private_key()不会从HSM读取密钥.相反,ENGINE_load_private_key()似乎返回一些缓存的值.

是否有某种方法可以强制openssl从HSM中读取新密钥,而不返回HSM中不再存在的旧密钥?

这段代码用于解决问题:

static void print_public_key_via_openssl( const char* name )
{
    ENGINE *e = ENGINE_by_id( "pkcs11");

    if ( e )
    {
        if ( ENGINE_init( e ) )
        {
            EVP_PKEY* key = ENGINE_load_private_key( e, name, NULL, NULL );
            if( key )
            {
                printf( "Public key:\n%s", public_key_to_str(key) );
                EVP_PKEY_free( key );
            }
            ENGINE_finish( e );
        }
        ENGINE_free( e );
    }
}

int main( int argc, char** argv )
{
    ...

    // …
Run Code Online (Sandbox Code Playgroud)

openssl pki hsm openssl-engine

5
推荐指数
0
解决办法
711
查看次数

链接到 OpenSSL 函数中的 ENGINE_load_private_key

我正在为我的应用程序开发一个示例 OpenSSL 引擎。

#include <openssl/engine.h>

static const char *engine_id = "sample";
static const char *engine_name = "developed by Devang";

static int engine_init(ENGINE *e);  
static EVP_PKEY *load_key(ENGINE *e, const char *id, UI_METHOD *ui, void *cb);

int bind_helper(ENGINE*e, const char *id)  {
      if(!ENGINE_set_id(e, engine_id) ||
         !ENGINE_set_init_function(e, engine_init) ||
         !ENGINE_set_load_privkey_function(e, load_key))
         return 0;

  return 1;  

}

IMPLEMENT_DYNAMIC_CHECK_FN(); IMPLEMENT_DYANMIC_BIND_FN(bind_helper);

static int engine_init(ENGINE *e) 
{
    printf("In engine_init \n"); 
} 
static EVP_PKEY *load_key(ENGINE *e, const char *id, UI_METHOD *ui, void *cb) {    
    printf(" In load_key function\n"); …
Run Code Online (Sandbox Code Playgroud)

openssl openssl-engine

5
推荐指数
1
解决办法
1745
查看次数

OpenSSL RSA引擎 - RSA验证失败

我有一个最小的,完整的,可验证的例子,我想做什么.
基本上我想实现一个集成了一些CUDA代码的OpenSSL RSA引擎.CUDA部分应该进行模幂运算,但在这个例子中并不重要,所以我只使用了BN_mod_exp(参见engine.c文件,modexp函数)以简化代码.我提供的代码是我项目的简化版本,使用这些命令可以很容易地构建/编译它:

gcc -fPIC -I/usr/local/cuda/include -c engine.c
nvcc --compiler-options '-fPIC' -c my_cuda.cu -lcrypto
g++ -L/usr/local/cuda/lib64 -shared -o gpu.so engine.o my_cuda.o -lcuda -lcudart
openssl engine -t -c `pwd`/gpu.so
Run Code Online (Sandbox Code Playgroud)

...最后一个命令的输出表明RSA引擎可用

/*engine.c*/

#include <openssl/opensslconf.h>

#include <stdio.h>
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/buffer.h>
#include <openssl/engine.h>

#include <openssl/rsa.h>

#include <openssl/bn.h>
#include <openssl/err.h>
#include "my_cuda.h"

/* Constants used when creating the ENGINE */
static const char *engine_e_rsax_id = "rsa_gpu";
static const char *engine_e_rsax_name = "RSAX engine support";
static int modexp(BIGNUM *r, …
Run Code Online (Sandbox Code Playgroud)

openssl openssl-engine

2
推荐指数
1
解决办法
726
查看次数

OpenSSL 调试 - 如何在 openssl 中转储中间 ASN.1?

我有一个 PKCS#12 测试文件,其中有一个用 PBES2 (PBEWithHmacSHA256AndAES_256) 加密的单个条目,它在 OpenSSL 中不起作用(但在其他地方有效)。

所以我想弄清楚我的文件是否已损坏,或者 OpenSSL 是否无法正确处理 PBES2。

该文件被附加:test.p12(pass:test)

openssl pkcs12(v.1.0.2p-dev)的输出是:

$ openssl pkcs12 -info -nodes -in out.p12 -passin pass:test
MAC Iteration 100000
MAC verified OK
PKCS7 Data
Shrouded Keybag: PBES2<unsupported parameters>
Bag Attributes
    friendlyName: test
    localKeyID: 54 69 6D 65 20 31 35 33 30 38 32 31 38 34 39 32 39 39
Error outputting keys and certificates
10564:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:.\crypto\asn1\tasn_dec.c:1220:
10564:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:.\crypto\asn1\tasn_dec.c:386:Type=X509_ALGOR
10564:error:0D08303A:asn1 encoding …
Run Code Online (Sandbox Code Playgroud)

c encryption openssl pkcs#12 openssl-engine

2
推荐指数
1
解决办法
2723
查看次数

OpenSSL 无法建立 SSL 连接,因为协议不受支持

我正在尝试从这里构建 OpenCog ,当我发出此命令时

octool -rdcpav -l default
Run Code Online (Sandbox Code Playgroud)

它构建了所有东西,然后进入了安装 Link-Grammar 的步骤,这发生了

[octool] Installing Link-Grammar....
--2020-06-13 10:09:36--  http://www.abisource.com/downloads/link-grammar/current/
Resolving www.abisource.com (www.abisource.com)... 130.89.149.216
Connecting to www.abisource.com (www.abisource.com)|130.89.149.216|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://www.abisource.com/downloads/link-grammar/current/ [following]
--2020-06-13 10:09:37--  https://www.abisource.com/downloads/link-grammar/current/
Connecting to www.abisource.com (www.abisource.com)|130.89.149.216|:443... connected.
OpenSSL: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol
Unable to establish SSL connection.
Run Code Online (Sandbox Code Playgroud)

我在 ubuntu 20.04 LTS

ssl openssl openssl-engine ubuntu-18.04 ubuntu-20.04

1
推荐指数
1
解决办法
5389
查看次数

标签 统计

openssl ×6

openssl-engine ×6

ssl ×2

c ×1

encryption ×1

hsm ×1

pkcs#12 ×1

pki ×1

ubuntu-18.04 ×1

ubuntu-20.04 ×1