mingl0280

请问 RSA 密钥对可以在 C#中使用私钥解密,但 openssl 无法使用私钥解密是怎么回事

  •  
  •   mingl0280 · Apr 26, 2019 · 3913 views
    This topic created in 2585 days ago, the information mentioned may be changed or developed.
    使用密钥对的公钥加密数据以后,如果将二进制数据放到 C#程序中使用私钥解密,是没有问题的,但是如果放到 openssl 中进行解密,则直接提示
    140029040199320:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1217:
    140029040199320:error:0D06C03A:asn1 encoding routines:ASN1_D2I_EX_PRIMITIVE:nested asn1 error:tasn_dec.c:785:
    140029040199320:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:717:Field=n, Type=RSA
    140029040199320:error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA lib:rsa_ameth.c:119:
    140029040199320:error:0407B07B:rsa routines:RSA_check_key:d e not congruent to 1:rsa_chk.c:148:
    140029040199320:error:0407B07C:rsa routines:RSA_check_key:dmp1 not congruent to d:rsa_chk.c:167:
    140029040199320:error:0407B07D:rsa routines:RSA_check_key:dmq1 not congruent to d:rsa_chk.c:185:
    140029040199320:error:0407B07E:rsa routines:RSA_check_key:iqmp not inverse of q:rsa_chk.c:196:
    若使用 openssl 库进行解密,则提示
    rsa_ossl_private_decrypt:padding check failed
    有人遇到过这个问题吗?
    5 replies    2019-04-27 01:23:19 +08:00
    tomczhen
        1
    tomczhen  
       Apr 26, 2019 via Android
    填充模式( padding ),向量( iv ),实现程序 /库默认行为可能有差异。
    mingl0280
        2
    mingl0280  
    OP
       Apr 26, 2019
    @tomczhen RSA 哪有 IV ……
    不过之前问题应该是解决了,C#暴力写的 ASN1 文件估计是有 bug。
    lzvezr
        3
    lzvezr  
       Apr 26, 2019 via iPhone
    padding 错误不是填充的原因吗,一般使用标准填充和 0x00,不过前几天我遇到一个使用 0x20 的,搞的头疼
    miaomiao0323
        4
    miaomiao0323  
       Apr 26, 2019
    不同技术栈对密码算法的底层实现都有差异
    mingl0280
        5
    mingl0280  
    OP
       Apr 27, 2019
    @lzvezr 应该是 OpenSSL 的 padding 有鬼的锅……
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2795 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 10:08 · PVG 18:08 · LAX 03:08 · JFK 06:08
    ♥ Do have faith in what you're doing.