Giter Club home page Giter Club logo

Comments (7)

hyfree avatar hyfree commented on June 26, 2024 1

https://blog.csdn.net/weixin_43408952/article/details/124584600

3059
	3013
		0607 2a8648ce3d0201
		0608 2a811ccf5501822d
	0342
		0004
			d713eadc1dc2c3653eb7e47b15bd09089bf2f3bfcb0db5031629468e4414f3d5
			4b979ee96d43cb294c0fda39c0c8e10a9894bd512b33f95c1735de3f6e374814

7F86A68FC89A80ACD9B4D0A4C26DC4DE558EEEB28A40763E56BF0C86C19EC3BB
37E6DB433426F9AB492D18A7D192874D59B64286C8F10102E3022A880C901D60

from gm.

hyfree avatar hyfree commented on June 26, 2024 1

请参考这个https://www.cnblogs.com/xinzhao/p/8963724.html
X509和ASN1,请参考相应规范,在此不赘述。

from gm.

qingfengzxr avatar qingfengzxr commented on June 26, 2024

已解决,是这个base64原文的格式问题,它的一个格式是这样的:
标准公钥头|裸公钥X|裸公钥Y

各字段字节长度:
(54)|(64)|(64)

解析时需要按照这种格式提取出 x和y, 之后再通过下面这种方法构建。

	pub := new(sm2.PublicKey)
	pub.Curve = sm2.GetSm2P256V1()
	xBytes, _ := hex.DecodeString(x)
	yBytes, _ := hex.DecodeString(y)
	pub.X = new(big.Int).SetBytes(xBytes)
	pub.Y = new(big.Int).SetBytes(yBytes)

无法直接使用sm2.RawBytesToPublicKey()方法进行构建。
我不太清楚这种是什么格式,如果能明确格式的话,我可以提交一个pull request来提供一个获取该格式公钥的解析方法。

from gm.

qingfengzxr avatar qingfengzxr commented on June 26, 2024

https://blog.csdn.net/weixin_43408952/article/details/124584600

3059
	3013
		0607 2a8648ce3d0201
		0608 2a811ccf5501822d
	0342
		0004
			d713eadc1dc2c3653eb7e47b15bd09089bf2f3bfcb0db5031629468e4414f3d5
			4b979ee96d43cb294c0fda39c0c8e10a9894bd512b33f95c1735de3f6e374814

7F86A68FC89A80ACD9B4D0A4C26DC4DE558EEEB28A40763E56BF0C86C19EC3BB
37E6DB433426F9AB492D18A7D192874D59B64286C8F10102E3022A880C901D60

感谢您的解答,我对密码学的研究不是很透彻,不太清楚这是不是就是PEM格式。目前我通过翻译Java的Demo, 已解决该问题,可以的话您可以看看我的回复,帮忙确认一下是否是PEM格式的问题。

from gm.

hyfree avatar hyfree commented on June 26, 2024

你可以确认一下XY是否为
d713eadc1dc2c3653eb7e47b15bd09089bf2f3bfcb0db5031629468e4414f3d5
4b979ee96d43cb294c0fda39c0c8e10a9894bd512b33f95c1735de3f6e374814

from gm.

qingfengzxr avatar qingfengzxr commented on June 26, 2024

你可以确认一下XY是否为 d713eadc1dc2c3653eb7e47b15bd09089bf2f3bfcb0db5031629468e4414f3d5 4b979ee96d43cb294c0fda39c0c8e10a9894bd512b33f95c1735de3f6e374814

Uploading image.png…
是的,是这两个数。

from gm.

qingfengzxr avatar qingfengzxr commented on June 26, 2024

请参考这个https://www.cnblogs.com/xinzhao/p/8963724.html X509和ASN1,请参考相应规范,在此不赘述。

好的,多谢

from gm.

Related Issues (17)

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.