Git Product home page Git Product logo

Comments (6)

iPermanent avatar iPermanent commented on September 15, 2024
image 以上分别是在521 384 224 三种曲线类型下生成的公钥和私钥长度,但是协商出来的密钥长度永远是64位导致和后台协商的对不上

from gmobjc.

iPermanent avatar iPermanent commented on September 15, 2024
image 看了下接口说明是永远只有64位,这样和其他端匹配不上了

from gmobjc.

iPermanent avatar iPermanent commented on September 15, 2024
image 这里应该根据实际的位数来做返回才对,目前是写死了32导致的位数不对

from gmobjc.

muzipiao avatar muzipiao commented on September 15, 2024

是的,项目使用时主要匹配的是 NID_sm2、NID_secp256k1、NID_X9_62_prime256v1 这几种 256 位的曲线,其他位的曲线未匹配,稍等我给你一种解决方案。

from gmobjc.

muzipiao avatar muzipiao commented on September 15, 2024

把签名长度计算方法修改一下就可以了。源码不复杂,都是调用 OpenSSL 实现的,如果有需求,项目中修改开源代码即可。

// 根据椭圆曲线密钥长度,计算签名长度
size_t outlen = (EC_GROUP_get_degree(group) + 7) / 8;
uint8_t *ecdh_text = (uint8_t *)OPENSSL_zalloc(outlen + 1);
int ret = ECDH_compute_key(ecdh_text, outlen, pub_point, key, 0);
if (ret <= 0) {
    break;
}
NSData *ecdhData = [NSData dataWithBytes:ecdh_text length:ret];
ecdhStr = [GMUtils dataToHex:ecdhData];

from gmobjc.

iPermanent avatar iPermanent commented on September 15, 2024

感谢,我自己hook了一下,改成了128 然后判断返回的字符串是否有 00的后缀,如果有的话就去掉,返回最后生成的可以对上了,不过你的这个新的写法更精确一些

from gmobjc.

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.