GithubHelp home page GithubHelp logo

Comments (4)

conezxy avatar conezxy commented on May 10, 2024

请看GM/T 0009-2012 SM2算法使用规范

from gmssl.

mrpre avatar mrpre commented on May 10, 2024

@conezxy 谢谢,已在 GM/T 0009-2012 7. 2节中找到报文对应的格式。
但是不解 GM/T 0003.4-2012 中 SM2公钥加密输出密文( C=C1 || C2 || C3 )难道不就是 指 GM/T 0009-2012 的 ‘加密数据格式’,两者难道含义不一样?

@guanzhi GMSSL有函数可以 decode&decrypt GM/T 0009-2012 7. 2 中定义的密文数据吗?(没有的话我自己写也行)

from gmssl.

conezxy avatar conezxy commented on May 10, 2024

对于同样的数据,在不同场景和层次中的表达和定义不同:

  • GM/T 0003-2012的定义( C=C1 || C2 || C3 )是数学意义上的表达。如果要对应到编程实现,则需要将其定义为C语言的结构。
  • GM/T 0016/0017/0018-2012(SDF和SKF规范)中的定义是基于C编程的表达
typedef struct Struct_ECCCIPHERBLOB{
    BYTE    XCoordinate[ECC_MAX_XCOORDINATE_BITS_LEN/8];
    BYTE    YCoordinate[ECC_MAX_YCOORDINATE_BITS_LEN/8];
    BYTE    HASH[32]; 
    ULONG   CipherLen;
    BYTE    Cipher[128];
} ECCCIPHERBLOB, *PECCCIPHERBLOB;
  • 但仅有C编程上的定义,还无法解决不同系统之间数据互通的问题(比如大小端问题)。因此在GM/T 0009-2012中定义了适用于序列化的表达(ASN.1)
SM2Cipher:: = Sequence {
    XCoordinate INTEGER,
    YCoordinate INTEGER,
    HASH        OCTET STRING SIZE(32),
    C           OCTET STRING,
}

from gmssl.

guanzhi avatar guanzhi commented on May 10, 2024

@mrpre 还没有,请参考 sm2/sm2_asn1.c

from gmssl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.