首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >vs code辅助gdb脚本进行源码调试分析

vs code辅助gdb脚本进行源码调试分析

原创
作者头像
Uncle匠
发布2025-09-16 18:09:25
发布2025-09-16 18:09:25
2110
举报

结论

  • vs code作为gdb的图形化调试工具基本够用,支持断点,条件断点,单步步过、单步进入,观察函数调用堆栈,双击选择堆栈,观察对应堆栈的参数变量值等。
  • vs code支持在“监视“窗口”添加表达式(如调用函数)观察值,也支持在右下角的"调试控制台"直接运行表达式,如OSSL_DECODER_CTX_get_num_decoders(ctx)可以直接返回结果,注意如果上下文不在当前堆栈,则在调用前先双击选择切换堆栈位置,另外注意调用的函数最好不会修改程序的全局状态(全局变量等)否则可能影响本次后续的运行。
  • 如果运行单个gdb命令,添加-exec前缀可以直接在“调试控制台”直接输入运行,“调试控制台“启动的时候有对应的输出提示:

Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)

  • 有时需要观察结构体数组相关的值,这时可以辅助gdb脚本,安装扩展“GDB syntax”可以高亮语法,然后把需求告诉AI,让AI帮你写,有问题修复后保存到文件,然后对应位置断下后,运行gdb脚本函数观察所有相关的值。
  • 有时F11步入未生效,没有打开对应的第三方库文件,也没有步入而是直接步过了,可以打开第三方库源码目录文件作为主工程,然后直接下断点来运行调试。 如当前工程是一个openssl的demo程序,不包含openssl源码工程,当F11想步入openssl函数时可能直接就跳过了,可以打开openssl源码作为工程下断点,设置demo二进制作为运行程序来调试。(这个不知道是不是bug)
  • 断点使用vs code 图形界面系统提供的能力,即在对应源码处按F9或单击行号左边的位置下断点,不要使用"调试控制台"用gdb脚本来下断点,如-exec break xxx 这种命令断下后有异常,可能跟vs code界面兼容不好有bug, 单独命令行gdb 启动的调试这种命令没有问题,跟图形界面混合用有问题。

系统环境

ubuntu系统版本

uname -a

Linux xx-ThinkPad-P15v-Gen-2i 5.15.0-86-generic #96~20.04.1-Ubuntu SMP Thu Sep 21 13:23:37 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

vs code版本

Version: 1.103.2

Commit: 6f17636121051a53c88d3e605c491d22af2ba755

Date: 2025-08-20T16:45:34.255Z

Electron: 37.2.3

ElectronBuildId: 12035395

Chromium: 138.0.7204.100

Node.js: 22.17.0

V8: 13.8.500258-electron.0

OS: Linux x64 5.15.0-86-generic

openssl源码版本: 3.2.1

调试准备

编译openssl源码开启调试

./config --debug

make -j16

编写.vscode/launch.json启动文件

菜单:运行->添加配置,可以生成一个空配置,接着再按F5(或菜单:运行->启动调试),选择gdb,会生成基础的gdb调试配置,然后按需添加修改。

本人参考配置如下:

代码语言:json
复制
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/out/target/platform-x64-linux-debug/install/verify/example/my_crypto_tls/bin/my_crypto_tls_demo",
            "args": [],
            "stopAtEntry": true,
            "externalConsole": false,
            "MIMode": "gdb",
            "cwd": "${workspaceFolder}",
            "environment": [
                {
                    "name": "LD_LIBRARY_PATH",
                    "value": "${LD_LIBRARY_PATH}:${workspaceFolder}/out/target/platform-x64-linux-debug/my/platform/modules/libraries/my_crypto_tls/lib/"
                },
                {
                    "name": "base_dir",
                    "value": "/home/xx/code/my/tls/files"
                },
                {
                    "name": "ENV_CLIENT_CERT_FILE",
                    "value": "/home/xx/code/my/tls/files/client-cert.pem"
                },
                {
                    "name": "ENV_CLIENT_KEY_FILE",
                    "value": "/home/xx/code/my/tls/files/client-key.pem"
                },
                {
                    "name": "ENV_CACERT_FILE",
                    "value": "/home/xx/code/my/tls/files/root-chain.pem"
                },
                {
                    "name": "ENV_TLS_SERVER_PORT",
                    "value": "8091"
                },
                {
                    "name": "ENV_TLS_SERVER_HOSTNAME",
                    "value": "localhost"
                }
            ],
            "setupCommands": [
                {
                    "description": "设置调试符号路径",
                    "text": "set solib-search-path  /home/xx/code/third/openssl-3.2.1",
                    "ignoreFailures": true
                },
                {
                    "description": "加载共享库符号",
                    "text": "sharedlibrary",
                    "ignoreFailures": true
                },
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                },
                {
                    "description": "加载自定义GDB脚本",
                    "text": "source /home/xx/Downloads/my_gdb_scripts.gdb",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

demo源码和cmake编译

demo源码省略

编译cmake开启调试并设置RPATH链接指定调试版本的openssl

代码语言:txt
复制
cmake_minimum_required(VERSION 3.10)
project(MyOpenSSLProvider CXX C) 
#设置调试
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 设置 OpenSSL 路径
set(OPENSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
set(OPENSSL_INCLUDE_DIR ${OPENSSL_ROOT_DIR}/include)
set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_ROOT_DIR}/libcrypto.so)
set(OPENSSL_SSL_LIBRARY ${OPENSSL_ROOT_DIR}/libssl.so)
# 包含 OpenSSL 头文件目录

# include_directories(
#   ${OPENSSL_INCLUDE_DIR} ${OPENSSL_ROOT_DIR}
#   ${OPENSSL_ROOT_DIR}/providers/common/include ${OPENSSL_ROOT_DIR}/crypto/ec
#   ${OPENSSL_ROOT_DIR}/providers/implementations/include)

  include_directories(/home/xx/code/third/openssl-3.2.1/include)
# 查找 OpenSSL
# find_package(OpenSSL REQUIRED)
# 创建可执行文件
add_executable(my_provider src/my_provider.cpp src/my_ecdsa_sig.c)

# 链接 OpenSSL 库
target_link_libraries(my_provider ${OPENSSL_ROOT_DIR}/libssl.so
                      ${OPENSSL_ROOT_DIR}/libcrypto.so)
# 设置运行时链接路径
set_target_properties(
  my_provider
  PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
             INSTALL_RPATH "${OPENSSL_ROOT_DIR}"
             INSTALL_RPATH_USE_LINK_PATH FALSE)
target_compile_definitions(my_provider PRIVATE OPENSSL_NO_DYNAMIC_ENGINE
                                               OPENSSL_SUPPRESS_DEPRECATED)

GDB脚本调试

本人要分析的是openssl中decoder_lib.c文件中的两个函数:

OSSL_DECODER_CTX_add_extra 函数

添加额外解码器函数,在读取pem密钥时,会先收集所有满足要求的解码器,即解码器的标志ID位有置位,这边是EVP_PKEY_KEYPAIR,如下

代码语言:c
复制
    return pem_read_bio_key(bp, x, cb, u, libctx, propq,
                            /* we also want the public key, if available */
                            EVP_PKEY_KEYPAIR); 

添加完后会再次获取系统所有解码器,然后看一下是否有解码的输出是现有解码器的输入,同时又不在现有解码器中的,也把它添加到解码器实例中。

代码语言:c
复制
int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx,
                               OSSL_LIB_CTX *libctx, const char *propq)
{
    /*
     * This function goes through existing decoder methods in
     * |ctx->decoder_insts|, and tries to fetch new decoders that produce
     * what the existing ones want as input, and push those newly fetched
     * decoders on top of the same stack.
     * Then it does the same again, but looping over the newly fetched
     * decoders, until there are no more decoders to be fetched, or
     * when we have done this 10 times.
     *
     * we do this with sliding windows on the stack by keeping track of indexes
     * and of the end.
     *
     * +----------------+
     * |   DER to RSA   | <--- w_prev_start
     * +----------------+
     * |   DER to DSA   |
     * +----------------+
     * |   DER to DH    |
     * +----------------+
     * |   PEM to DER   | <--- w_prev_end, w_new_start
     * +----------------+
     *                    <--- w_new_end
     */
    struct collect_extra_decoder_data_st data;
    size_t depth = 0; /* Counts the number of iterations */
    size_t count; /* Calculates how many were added in each iteration */
    size_t numdecoders;
    STACK_OF(OSSL_DECODER) *skdecoders;

    if (!ossl_assert(ctx != NULL)) {
        ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER);
        return 0;
    }

    /*
     * If there is no stack of OSSL_DECODER_INSTANCE, we have nothing
     * more to add.  That's fine.
     */
    if (ctx->decoder_insts == NULL)
        return 1;

    OSSL_TRACE_BEGIN(DECODER) {
        BIO_printf(trc_out, "(ctx %p) Looking for extra decoders\n",
                   (void *)ctx);
    } OSSL_TRACE_END(DECODER);


    skdecoders = sk_OSSL_DECODER_new_null();
    if (skdecoders == NULL) {
        ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_CRYPTO_LIB);
        return 0;
    }
    OSSL_DECODER_do_all_provided(libctx, collect_all_decoders, skdecoders); //这边获取所有的解码器
    numdecoders = sk_OSSL_DECODER_num(skdecoders); //这边下断点打印所有的解码器: -exec print_skdecoders skdecoders

    memset(&data, 0, sizeof(data));
    data.ctx = ctx;
    data.w_prev_start = 0;
    data.w_prev_end = sk_OSSL_DECODER_INSTANCE_num(ctx->decoder_insts);
    do {
        size_t i, j;

        data.w_new_start = data.w_new_end = data.w_prev_end;

        /*
         * Two iterations:
         * 0.  All decoders that have the same name as their input type.
         *     This allows for decoders that unwrap some data in a specific
         *     encoding, and pass the result on with the same encoding.
         * 1.  All decoders that a different name than their input type.
         */
        for (data.type_check = IS_SAME;
             data.type_check <= IS_DIFFERENT;
             data.type_check++) {
            for (i = data.w_prev_start; i < data.w_prev_end; i++) {
                OSSL_DECODER_INSTANCE *decoder_inst =
                    sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);

                data.output_type
                    = OSSL_DECODER_INSTANCE_get_input_type(decoder_inst);

                data.output_type_id = 0;

                for (j = 0; j < numdecoders; j++)
                    collect_extra_decoder(sk_OSSL_DECODER_value(skdecoders, j),
                                          &data); //尝试添加额外解码器,要求当前解码器的输出格式是下一个解码器的输入格式
            }
        }
        /* How many were added in this iteration */
        count = data.w_new_end - data.w_new_start;

        /* Slide the "previous decoder" windows */
        data.w_prev_start = data.w_new_start;
        data.w_prev_end = data.w_new_end;

        depth++;
    } while (count != 0 && depth <= 10);

    sk_OSSL_DECODER_pop_free(skdecoders, OSSL_DECODER_free);
    return 1;
}

decoder_process函数

递归解码过程,从后往前递归解码当前输入,通常是pem->der->key的过程。

代码语言:c
复制
static int decoder_process(const OSSL_PARAM params[], void *arg)
{
    struct decoder_process_data_st *data = arg;
    OSSL_DECODER_CTX *ctx = data->ctx;
    OSSL_DECODER_INSTANCE *decoder_inst = NULL;
    OSSL_DECODER *decoder = NULL;
    OSSL_CORE_BIO *cbio = NULL;
    BIO *bio = data->bio;
    //....
    if (params == NULL) {
        /* First iteration, where we prepare for what is to come */

        OSSL_TRACE_BEGIN(DECODER) {
            BIO_printf(trc_out,
                       "(ctx %p) starting to walk the decoder chain\n",
                       (void *)new_data.ctx);
        } OSSL_TRACE_END(DECODER);

        data->current_decoder_inst_index =
            OSSL_DECODER_CTX_get_num_decoders(ctx); //获取解码器数量

        bio = data->bio;
    } else {
        const OSSL_PARAM *p;
        const char *trace_data_structure;

        decoder_inst =
            sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts,
                                           data->current_decoder_inst_index);
        decoder = OSSL_DECODER_INSTANCE_get_decoder(decoder_inst);

        data->flag_construct_called = 0;
        if (ctx->construct != NULL) {
            int rv;

            OSSL_TRACE_BEGIN(DECODER) {
                BIO_printf(trc_out,
                           "(ctx %p) %s Running constructor\n",
                           (void *)new_data.ctx, LEVEL);
            } OSSL_TRACE_END(DECODER);

            rv = ctx->construct(decoder_inst, params, ctx->construct_data);

            OSSL_TRACE_BEGIN(DECODER) {
                BIO_printf(trc_out,
                           "(ctx %p) %s Running constructor => %d\n",
                           (void *)new_data.ctx, LEVEL, rv);
            } OSSL_TRACE_END(DECODER);

            ok = (rv > 0);
            if (ok) {
                data->flag_construct_called = 1;
                goto end;
            }
        }

 //...
 //从后往前遍历解码器,看输入格式是否匹配
    for (i = data->current_decoder_inst_index; i-- > 0;) {
        OSSL_DECODER_INSTANCE *new_decoder_inst =
            sk_OSSL_DECODER_INSTANCE_value(ctx->decoder_insts, i);
        OSSL_DECODER *new_decoder =
            OSSL_DECODER_INSTANCE_get_decoder(new_decoder_inst);
        void *new_decoderctx =
            OSSL_DECODER_INSTANCE_get_decoder_ctx(new_decoder_inst);
        const char *new_input_type =
            OSSL_DECODER_INSTANCE_get_input_type(new_decoder_inst);
        int n_i_s_was_set = 0;   /* We don't care here */
        const char *new_input_structure =
            OSSL_DECODER_INSTANCE_get_input_structure(new_decoder_inst,
                                                      &n_i_s_was_set);

//.....
        ERR_set_mark();

        new_data.current_decoder_inst_index = i;
        new_data.flag_input_structure_checked
            = data->flag_input_structure_checked;
        ok = new_decoder->decode(new_decoderctx, cbio,
                                 new_data.ctx->selection,
                                 decoder_process, &new_data, //回调函数填写decoder_process自身,实现递归解码
                                 ossl_pw_passphrase_callback_dec,
                                 &new_data.ctx->pwdata); //找到满足要求的解码器,尝试解码解码

 //....
}

gdb脚本和解码器打印

代码语言:txt
复制
# --- print_decoders being---
define print_decoders
    if $arg0 != 0
        set $ctx = (OSSL_DECODER_CTX *)$arg0
        set $num = OSSL_DECODER_CTX_get_num_decoders($ctx)
        printf "Total decoders: %d\n", $num
        if $num > 0
            set $i = 0
            while $i < $num
                set $decoder_inst = sk_OSSL_DECODER_INSTANCE_value($ctx->decoder_insts, $i)
                if $decoder_inst != 0
                    set $decoder = OSSL_DECODER_INSTANCE_get_decoder($decoder_inst)
                    set $decoderctx = OSSL_DECODER_INSTANCE_get_decoder_ctx($decoder_inst)
                    set $input_type = OSSL_DECODER_INSTANCE_get_input_type($decoder_inst)
                    
                    # 直接访问结构体成员避免地址问题
                    set $input_structure = $decoder_inst->input_structure
                    set $n_i_s_was_set = $decoder_inst->flag_input_structure_was_set
                    
                    if $decoder != 0
                        set $provider = OSSL_DECODER_get0_provider($decoder)
                        if $provider != 0
                            printf "[%d] Provider: %s, Decoder: %s\n", $i, OSSL_PROVIDER_get0_name($provider), OSSL_DECODER_get0_name($decoder)
                        else
                            printf "[%d] Provider: (null)\n", $i
                        end
                    else
                        printf "[%d] Decoder: (null)\n", $i
                    end
                    
                    printf "     Input type: %s\n", $input_type
                    if $input_structure != 0
                        printf "     Input structure: %s (set: %d)\n", $input_structure, $n_i_s_was_set
                    else
                        printf "     Input structure: (null) (set: %d)\n", $n_i_s_was_set
                    end
                    printf "     Decoder context: %p\n", $decoderctx
                else
                    printf "[%d] Decoder instance: (null)\n", $i
                end
                set $i = $i + 1
            end
        end
        
        # 打印其他上下文信息
        printf "\nContext information:\n"
        if $ctx->start_input_type != 0
            printf "Start input type: %s\n", $ctx->start_input_type
        else
            printf "Start input type: (null)\n"
        end
        
        if $ctx->input_structure != 0
            printf "Input structure: %s\n", $ctx->input_structure
        else
            printf "Input structure: (null)\n"
        end
        
        printf "Selection: %d\n", $ctx->selection
    else
        printf "ERROR: Null context passed to print_decoders\n"
    end
end

document print_decoders
Print all decoders in the OSSL_DECODER_CTX with detailed information
Usage: print_decoders <ctx>
End of detailed information:
- Provider and decoder names
- Input type for each decoder
- Input structure for each decoder
- Decoder context pointer
- Overall context information (start_input_type, input_structure, selection)
end
# --- print_decoders end---


# --- print_skdecoders begin---
define print_skdecoders
    if $arg0 != 0
        set $skdecoders = $arg0
        set $num = sk_OSSL_DECODER_num($skdecoders)
        printf "Total OSSL_DECODERs in stack: %d\n", $num
        if $num > 0
            set $i = 0
            while $i < $num
                set $decoder = sk_OSSL_DECODER_value($skdecoders, $i)
                if $decoder != 0
                    set $provider = OSSL_DECODER_get0_provider($decoder)
                    if $provider != 0
                        printf "[%d] Provider: %s, Decoder: %s\n", $i, OSSL_PROVIDER_get0_name($provider), OSSL_DECODER_get0_name($decoder)
                        printf "     Properties: %s\n", OSSL_DECODER_get0_properties($decoder)
                    else
                        printf "[%d] Provider: (null), Decoder: %s\n", $i, OSSL_DECODER_get0_name($decoder)
                    end
                    printf "     Decoder pointer: %p\n", $decoder
                else
                    printf "[%d] Decoder: (null)\n", $i
                end
                set $i = $i + 1
            end
        end
    else
        printf "ERROR: Null stack passed to print_skdecoders\n"
    end
end

document print_skdecoders
Print all OSSL_DECODERs in the STACK_OF(OSSL_DECODER) with detailed information
Usage: print_skdecoders <skdecoders>
End of detailed information:
- Provider and decoder names
- Decoder properties
- Decoder pointer address
end
# --- print_skdecoders end---


# run when load this script
## 在decoder_process设置断点
# break decoder_process
# set scheduler-locking on
# break decoder_lib.c:713
# commands
#     # 先执行到下一行确保栈帧稳定
#     next
#     # 然后再执行调试命令
#     print_decoders ctx
#     continue
# end

脚本加载方式有两种,一种是在launch.json启动时自动添加,如上配置所示。

一种是在“调试控制台”执行添加:

-exec source /home/xx/Downloads//my_gdb_scripts.gdb

然后可以在对应位置断下后或切换到对应堆栈上下文后在"调试控制台"执行对应的gdb脚本

-exec help user-defined

代码语言:shell
复制
-exec help user-defined
User-defined commands.
The commands in this class are those defined by the user.
Use the "define" command to define a command.

List of commands:

print_decoders -- Print all decoders in the OSSL_DECODER_CTX with detailed information
print_skdecoders -- Print all OSSL_DECODERs in the STACK_OF(OSSL_DECODER) with detailed information

Type "help" followed by command name for full documentation.
Type "apropos word" to search for commands related to "word".
Type "apropos -v word" for full documentation of commands related to "word".
Command name abbreviations are allowed if unambiguous.

-exec print_skdecoders skdecoders

代码语言:shell
复制
...
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)

Breakpoint 28, OSSL_DECODER_CTX_add_extra (ctx=0x555555599870, libctx=0x0, propq=0x0) at crypto/encode_decode/decoder_lib.c:544
544	    numdecoders = sk_OSSL_DECODER_num(skdecoders);

-var-create: unable to create variable object
-exec print_skdecoders skdecoders
Total OSSL_DECODERs in stack: 40
[0] Provider: default, Decoder: RSA
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555af7f0
[1] Provider: default, Decoder: RSA
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555afa30
[2] Provider: default, Decoder: RSA
     Properties: provider=default,fips=yes,input=der,structure=type-specific
     Decoder pointer: 0x5555555afbc0
[3] Provider: default, Decoder: RSA
     Properties: provider=default,fips=yes,input=der,structure=rsa
     Decoder pointer: 0x5555555afd00
[4] Provider: default, Decoder: RSA
     Properties: provider=default,fips=yes,input=msblob
     Decoder pointer: 0x5555555b0350
[5] Provider: default, Decoder: RSA
     Properties: provider=default,fips=yes,input=pvk
     Decoder pointer: 0x5555555b04a0
[6] Provider: default, Decoder: DH
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x55555559ea10
[7] Provider: default, Decoder: DH
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x55555559b6c0
[8] Provider: default, Decoder: DH
     Properties: provider=default,fips=yes,input=der,structure=type-specific
     Decoder pointer: 0x5555555abf50
[9] Provider: default, Decoder: DH
     Properties: provider=default,fips=yes,input=der,structure=dh
     Decoder pointer: 0x5555555ac220
[10] Provider: default, Decoder: DSA
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555acc10
[11] Provider: default, Decoder: DSA
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555ace50
[12] Provider: default, Decoder: DSA
     Properties: provider=default,fips=yes,input=der,structure=type-specific
     Decoder pointer: 0x5555555acfe0
[13] Provider: default, Decoder: DSA
     Properties: provider=default,fips=yes,input=der,structure=dsa
     Decoder pointer: 0x5555555ad120
[14] Provider: default, Decoder: DSA
     Properties: provider=default,fips=yes,input=msblob
     Decoder pointer: 0x5555555ad420
[15] Provider: default, Decoder: DSA
     Properties: provider=default,fips=yes,input=pvk
     Decoder pointer: 0x5555555ad630
[16] Provider: default, Decoder: EC
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555ad840
[17] Provider: default, Decoder: EC
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555adaa0
[18] Provider: default, Decoder: EC
     Properties: provider=default,fips=yes,input=der,structure=type-specific
     Decoder pointer: 0x5555555adc30
[19] Provider: default, Decoder: EC
     Properties: provider=default,fips=yes,input=der,structure=ec
     Decoder pointer: 0x5555555add70
[20] Provider: default, Decoder: RSA-PSS
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555aff80
[21] Provider: default, Decoder: RSA-PSS
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555b01c0
[22] Provider: default, Decoder: DHX
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555ac480
[23] Provider: default, Decoder: DHX
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555ac6c0
[24] Provider: default, Decoder: DHX
     Properties: provider=default,fips=yes,input=der,structure=type-specific
     Decoder pointer: 0x5555555ac850
[25] Provider: default, Decoder: DHX
     Properties: provider=default,fips=yes,input=der,structure=dhx
     Decoder pointer: 0x5555555ac990
[26] Provider: default, Decoder: X25519
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555ae820
[27] Provider: default, Decoder: X25519
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555aea70
[28] Provider: default, Decoder: X448
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555aec00
[29] Provider: default, Decoder: X448
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555aee50
[30] Provider: default, Decoder: ED25519
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555adfe0
[31] Provider: default, Decoder: ED25519
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555ae2b0
[32] Provider: default, Decoder: ED448
     Properties: provider=default,fips=yes,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555ae440
[33] Provider: default, Decoder: ED448
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555ae690
[34] Provider: default, Decoder: SM2
     Properties: provider=default,fips=no,input=der,structure=PrivateKeyInfo
     Decoder pointer: 0x5555555aefe0
[35] Provider: default, Decoder: SM2
     Properties: provider=default,fips=no,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555af300
[36] Provider: default, Decoder: SM2
     Properties: provider=default,fips=no,input=der,structure=type-specific
     Decoder pointer: 0x5555555af5c0
[37] Provider: default, Decoder: DER
     Properties: provider=default,fips=yes,input=der,structure=SubjectPublicKeyInfo
     Decoder pointer: 0x5555555b05c0
[38] Provider: default, Decoder: DER
     Properties: provider=default,fips=yes,input=pem
     Decoder pointer: 0x5555555b0870
[39] Provider: default, Decoder: DER
     Properties: provider=default,fips=yes,input=der,structure=EncryptedPrivateKeyInfo
     Decoder pointer: 0x5555555ad210
     

-exec print_decoders ctx

代码语言:shell
复制
Breakpoint 8, decoder_process (params=0x0, arg=0x7fffffffbc40) at crypto/encode_decode/decoder_lib.c:875
875	        OSSL_TRACE_BEGIN(DECODER) {
    
 -exec print_decoders ctx
Total decoders: 25
[0] Provider: default, Decoder: RSA
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b2f20
[1] Provider: default, Decoder: RSA
     Input type: der
     Input structure: type-specific (set: 0)
     Decoder context: 0x5555555b3070
[2] Provider: default, Decoder: RSA
     Input type: der
     Input structure: rsa (set: 0)
     Decoder context: 0x5555555b31c0
[3] Provider: default, Decoder: RSA
     Input type: msblob
     Input structure: (null) (set: 0)
     Decoder context: 0x5555555b3310
[4] Provider: default, Decoder: RSA
     Input type: pvk
     Input structure: (null) (set: 0)
     Decoder context: 0x5555555b3360
[5] Provider: default, Decoder: DH
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b34b0
[6] Provider: default, Decoder: DSA
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b3600
[7] Provider: default, Decoder: DSA
     Input type: der
     Input structure: type-specific (set: 0)
     Decoder context: 0x5555555b3750
[8] Provider: default, Decoder: DSA
     Input type: der
     Input structure: dsa (set: 0)
     Decoder context: 0x5555555b38a0
[9] Provider: default, Decoder: DSA
     Input type: msblob
     Input structure: (null) (set: 0)
     Decoder context: 0x5555555b39f0
[10] Provider: default, Decoder: DSA
     Input type: pvk
     Input structure: (null) (set: 0)
     Decoder context: 0x5555555b3a40
[11] Provider: default, Decoder: EC
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b3b90
[12] Provider: default, Decoder: EC
     Input type: der
     Input structure: type-specific (set: 0)
     Decoder context: 0x5555555b3ce0
[13] Provider: default, Decoder: EC
     Input type: der
     Input structure: ec (set: 0)
     Decoder context: 0x5555555b3e30
[14] Provider: default, Decoder: RSA-PSS
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b3f80
[15] Provider: default, Decoder: DHX
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b40d0
[16] Provider: default, Decoder: X25519
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b4220
[17] Provider: default, Decoder: X448
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b4370
[18] Provider: default, Decoder: ED25519
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b44c0
[19] Provider: default, Decoder: ED448
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b4610
[20] Provider: default, Decoder: SM2
     Input type: der
     Input structure: privatekeyinfo (set: 0)
     Decoder context: 0x5555555b4760
[21] Provider: default, Decoder: SM2
     Input type: der
     Input structure: type-specific (set: 0)
     Decoder context: 0x5555555b48b0
[22] Provider: default, Decoder: DER
     Input type: der
     Input structure: subjectpublickeyinfo (set: 0)
     Decoder context: 0x55555559bdc0
[23] Provider: default, Decoder: DER
     Input type: der
     Input structure: encryptedprivatekeyinfo (set: 0)
     Decoder context: 0x55555558ba30
[24] Provider: default, Decoder: DER
     Input type: pem
     Input structure: (null) (set: 0)
     Decoder context: 0x5555555b4a60

Context information:
Start input type: PEM
Input structure: (null)
Selection: 135

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 结论
  • 系统环境
  • 调试准备
    • 编译openssl源码开启调试
    • 编写.vscode/launch.json启动文件
    • demo源码和cmake编译
  • GDB脚本调试
    • gdb脚本和解码器打印
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档